1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _STM32_PLAT_H_
18 #define _STM32_PLAT_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include <seos.h>
27 
28 enum PlatSleepDevID
29 {
30     Stm32sleepDevTim2, /* we use this for short sleeps in WFI mode */
31     Stm32sleepDevTim4, /* input capture uses this, potentially */
32     Stm32sleepDevTim5, /* input capture uses this, potentially */
33     Stm32sleepDevTim9, /* input capture uses this, potentially */
34     Stm32sleepWakeup,  /* we use this to wakeup from AP */
35     Stm32sleepDevSpi2, /* we use this to prevent stop mode during spi2 xfers */
36     Stm32sleepDevSpi3, /* we use this to prevent stop mode during spi3 xfers */
37     Stm32sleepDevI2c1, /* we use this to prevent stop mode during i2c1 xfers */
38     Stm32sleepDevI2c2, /* we use this to prevent stop mode during i2c2 xfers */
39     Stm32sleepDevI2c3, /* we use this to prevent stop mode during i2c3 xfers */
40     Stm32sleepDevExti, /* we use this for max external interrupt latency */
41 
42     Stm32sleepDevNum,  //must be last always, and must be <= PLAT_MAX_SLEEP_DEVS
43 };
44 
platGetInternalAppList(uint32_t * numAppsP)45 static inline const struct AppHdr* platGetInternalAppList(uint32_t *numAppsP)
46 {
47     extern const struct AppHdr __internal_app_start, __internal_app_end;
48 
49     *numAppsP = &__internal_app_end - &__internal_app_start;
50     return &__internal_app_start;
51 }
52 
platGetSharedAreaInfo(uint32_t * areaSzP)53 static inline uint8_t* platGetSharedAreaInfo(uint32_t *areaSzP)
54 {
55     extern uint8_t __shared_start[];
56     extern uint8_t __shared_end[];
57 
58     *areaSzP = __shared_end - __shared_start;
59     return __shared_start;
60 }
61 
62 //used for dropbox
63 void* platGetPersistentRamStore(uint32_t *bytes);
64 
platWake(void)65 static inline void platWake(void)
66 {
67 }
68 
69 // GCC aligns 64-bit types on an 8-byte boundary, but Cortex-M4 only requires
70 // 4-byte alignment for these types. So limit the return value, as we're
71 // interested in the minimum alignment requirement.
72 #if defined(__GNUC__) && !defined(alignof)
73 #define alignof(type) ((__alignof__(type) > 4) ? 4 : __alignof__(type))
74 #endif
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
81