1 /**
2   ******************************************************************************
3   * @file    openamp_conf.h
4   * @author  MCD Application Team
5   * @brief   Configuration file for OpenAMP MW
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.</center></h2>
11   *
12   * This software component is licensed by ST under BSD 3-Clause license,
13   * the "License"; You may not use this file except in compliance with the
14   * License. You may obtain a copy of the License at:
15   *                       opensource.org/licenses/BSD-3-Clause
16   *
17   ******************************************************************************
18   */
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __OPENAMP_CONF__H__
22 #define __OPENAMP_CONF__H__
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_)
30 #include "openamp_log.h"
31 #endif
32 
33  /* ########################## Mailbox Interface Selection ############################## */
34  /**
35    * @brief This is the list of Mailbox interface  to be used in the OpenAMP MW
36    *        Please note that not all interfaces are supported by a STM32 device
37    */
38 #define MAILBOX_IPCC_IF_ENABLED
39 //#define MAILBOX_HSEM_IF_ENABLED
40 
41  /* Includes ------------------------------------------------------------------*/
42  /**
43    * @brief Include Maibox interface  header file
44    */
45 
46 #ifdef MAILBOX_IPCC_IF_ENABLED
47 #include "mbox_ipcc.h"
48 #endif /* MAILBOX_IPCC_IF_ENABLED */
49 
50 #ifdef MAILBOX_HSEM_IF_ENABLED
51 #include "mbox_hsem.h"
52 #endif /* MAILBOX_HSEM_IF_ENABLED */
53 
54  /* ########################## Virtual Diver Module Selection ############################## */
55  /**
56    * @brief This is the list of modules to be used in the OpenAMP Virtual driver module
57    *        Please note that virtual driver are not supported on all stm32 families
58    */
59 //#define VIRTUAL_UART_MODULE_ENABLED
60 //#define VIRTUAL_I2C_MODULE_ENABLED
61 
62  /* Includes ------------------------------------------------------------------*/
63  /**
64    * @brief Include Virtual Driver module's  header file
65    */
66 
67 #ifdef VIRTUAL_UART_MODULE_ENABLED
68 #include "virt_uart.h"
69 #endif /* VIRTUAL_UART_MODULE_ENABLED */
70 
71 #ifdef VIRTUAL_I2C_MODULE_ENABLED
72 #include "virt_i2c.h"
73 #endif /* VIRTUAL_I2C_MODULE_ENABLED */
74 
75  /* ########################## Linux Master Selection ############################## */
76  /**
77   * @brief Due to Linux compatibility, it's important to distinguish if the MASTER is Linux or not.
78   *        In that case, the LINUX_RPROC_MASTER define is required
79   */
80 #define LINUX_RPROC_MASTER
81 
82 /* USER CODE BEGIN INCLUDE */
83 
84 /* USER CODE END INCLUDE */
85 
86 /** @addtogroup OPENAMP_MW
87   * @{
88   */
89 
90 /** @defgroup OPENAMP_CONF OPENAMP_CONF
91   * @brief Configuration file for Openamp mw
92   * @{
93   */
94 
95 /** @defgroup OPENAMP_CONF_Exported_Variables OPENAMP_CONF_Exported_Variables
96   * @brief Public variables.
97   * @{
98   */
99 
100 /**
101   * @}
102   */
103 
104 /** @defgroup OPENAMP_CONF_Exported_Defines OPENAMP_CONF_Exported_Defines
105   * @brief Defines for configuration of the Openamp mw
106   * @{
107   */
108 
109 #if defined (__ICCARM__)
110 /*
111  * For IAR, the .icf file should contain the following lines:
112  * define symbol __OPENAMP_region_start__ = BASE_ADDRESS; (0x38000400 for example)
113  * define symbol __OPENAMP_region_size__   = MEM_SIZE; (0xB000 as example)
114  *
115  * export symbol __OPENAMP_region_start__;
116  * export symbol __OPENAMP_region_size__;
117  */
118 extern const uint32_t  __OPENAMP_region_start__;
119 extern const uint8_t  __OPENAMP_region_size__;
120 #define SHM_START_ADDRESS       ((metal_phys_addr_t)&__OPENAMP_region_start__)
121 #define SHM_SIZE        ((size_t)&__OPENAMP_region_size__)
122 
123 #elif defined(__CC_ARM)
124 /*
125  * For MDK-ARM, the scatter file .sct should contain the following line:
126  * LR_IROM1 ....  {
127  *  ...
128  *   __OpenAMP_SHMEM__ 0x38000400  EMPTY 0x0000B000 {} ; Shared Memory area used by OpenAMP
129  *  }
130  *
131  */
132 extern unsigned int Image$$__OpenAMP_SHMEM__$$Base;
133 extern unsigned int Image$$__OpenAMP_SHMEM__$$ZI$$Length;
134 #define SHM_START_ADDRESS (unsigned int)&Image$$__OpenAMP_SHMEM__$$Base
135 #define SHM_SIZE          ((size_t)&Image$$__OpenAMP_SHMEM__$$ZI$$Length)
136 
137 #else
138 /*
139  * for GCC add the following content to the .ld file:
140  * MEMORY
141  * {
142  * ...
143  * OPEN_AMP_SHMEM (xrw) : ORIGIN = 0x38000400, LENGTH = 63K
144  * }
145  * __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
146  * __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);
147  *
148  * using the LENGTH(OPEN_AMP_SHMEM) to set the SHM_SIZE lead to a crash thus we
149  * use the start and end address.
150  */
151 
152 extern int __OPENAMP_region_start__[];  /* defined by linker script */
153 extern int __OPENAMP_region_end__[];    /* defined by linker script */
154 
155 #define SHM_START_ADDRESS       ((metal_phys_addr_t)__OPENAMP_region_start__)
156 #define SHM_SIZE                (size_t)((void *)__OPENAMP_region_end__ - (void *) __OPENAMP_region_start__)
157 
158 #endif
159 
160 #if defined LINUX_RPROC_MASTER
161 #define VRING_RX_ADDRESS        -1        /* allocated by Master processor: CA7 */
162 #define VRING_TX_ADDRESS        -1        /* allocated by Master processor: CA7 */
163 #define VRING_BUFF_ADDRESS      -1        /* allocated by Master processor: CA7 */
164 #define VRING_ALIGNMENT         16        /* fixed to match with linux constraint */
165 #define VRING_NUM_BUFFS         16		  /* number of rpmsg buffer */
166 #else
167 
168 #define VRING_RX_ADDRESS     0x10040000             /* allocated by Master processor: CA7 */
169 #define VRING_TX_ADDRESS     0x10040400             /* allocated by Master processor: CA7 */
170 #define VRING_BUFF_ADDRESS   0x10040800             /* allocated by Master processor: CA7 */
171 #define VRING_ALIGNMENT      16         /* fixed to match with 4k page alignement requested by linux  */
172 #define VRING_NUM_BUFFS      16             /* number of rpmsg buffer */
173 #endif
174 /* Fixed parameter */
175 #define NUM_RESOURCE_ENTRIES 2
176 #define VRING_COUNT          2
177 #define VDEV_ID              0xFF
178 #define VRING0_ID            0              /* VRING0 ID (master to remote) fixed to 0 for linux compatibility*/
179 #define VRING1_ID            1              /* VRING1 ID (remote to master) fixed to 1 for linux compatibility  */
180 
181 /**
182   * @}
183   */
184 
185 /** @defgroup OPENAMP_CONF_Exported_Macros OPENAMP_CONF_Exported_Macros
186   * @brief Aliases.
187   * @{
188   */
189 
190 /* DEBUG macros */
191 
192 #if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_)
193   #define OPENAMP_log_dbg               log_dbg
194   #define OPENAMP_log_info              log_info
195   #define OPENAMP_log_warn              log_warn
196   #define OPENAMP_log_err               log_err
197 #else
198   #define OPENAMP_log_dbg(...)
199   #define OPENAMP_log_info(...)
200   #define OPENAMP_log_warn(...)
201   #define OPENAMP_log_err(...)
202 #endif
203 
204 /**
205   * @}
206   */
207 
208 /** @defgroup OPENAMP_CONF_Exported_Types OPENAMP_CONF_Exported_Types
209   * @brief Types.
210   * @{
211   */
212 
213 /**
214   * @}
215   */
216 
217 /** @defgroup OPENAMP_CONF_Exported_FunctionsPrototype OPENAMP_CONF_Exported_FunctionsPrototype
218   * @brief Declaration of public functions for OpenAMP mw.
219   * @{
220   */
221 
222 /* Exported functions -------------------------------------------------------*/
223 
224 /**
225   * @}
226   */
227 
228 /**
229   * @}
230   */
231 
232 /**
233   * @}
234   */
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* __OPENAMP_CONF__H__ */
241 
242 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
243