2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file ss_sm_boot_access.h
19 * @brief This file provides API for get boot information from nor flash
22 /** @addtogroup BaseSystem
25 /** @addtogroup system_service
29 /** @addtogroup rom_access_library
30 * @ingroup system_service
34 #ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
35 #define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
37 #include <native_service/frameworkunified_types.h>
38 #include <native_service/frameworkunified_framework_types.h>
40 // Top memory map of LINUX management outside domain (SYS area)
41 // Must not use it other than the model of C language specifications to refer to BOOT
43 #define LBM_UINT32 unsigned int
44 #define LBM_UINT16 uint16_t
45 #define LBM_UINT8 unsigned char
46 #define LBM_INT64 int64_t
47 #define LBM_INT32 unsigned int
48 #define LBM_INT16 uint16_t
49 #define LBM_INT8 unsigned char
52 #define LBM_NOR_MIRROR_SIZE 0x10000 // MIRROR area of NOR
53 #define LBM_DRAM_SIZE 0x10000 // RAM area to share with BOOT in LINUX
55 #define LBM_NOR_BOOT_SIZE 128
56 #define LBM_NOR_TSKM_SIZE 128
57 #define LBM_NOR_VUP_SIZE 1024
58 #define LBM_NOR_ANA_SIZE 32
59 #define LBM_NOR_VEHI_SIZE 32
60 #define LBM_NOR_DEVMGR_SIZE 32
63 //********* Value of the field ****************
64 /* SDRAMstart identification */
65 #define SYSUP_DRAM_NORMAL (LBM_UINT32)0x4E524E52 /* normal value NRNR*/
66 #define SYSUP_DRAM_SFTERRSR (LBM_UINT32)0x73667366 /* abnormal Soft Reset(softwareabnormality) sfsf*/
67 #define SYSUP_DRAM_DISCARD (LBM_UINT32)0x44434443 /* need to discard backup DCDC*/
69 /* Start is in a state (navigator initial use)/System start state */
70 #define SYSUP_CND_FACTRESET (LBM_UINT16)0x434c /* COLD START */
71 #define SYSUP_CND_NORMAL (LBM_UINT16)0x4853 /* HOT START */
73 /* Start mode preservation table level */
74 #define SYSUP_MODE_NORMAL (LBM_UINT32)0x4E524E52 /* normal mode */
75 #define SYSUP_MODE_VERUP (LBM_UINT32)0x56555655 /* versionup mode */
77 /* Communication state between NAVI-SYS */
78 #define SUBCPU_STS_NOMAL (LBM_UINT32)0x00000000 /* Communication normal */
79 #define SUBCPU_STS_COMNG (LBM_UINT32)0x88888888 /* Communication abnormal */
81 /* SDRAM power supply abnormality detection */
82 #define SDRAM_STS_NOMAL (LBM_UINT32)0x11111111 /* backup power supply is normal */
83 #define SDRAM_STS_BUPNG (LBM_UINT32)0x99999999 /* backup power supply is abnormal */
86 #define HWDT_STS_NOMAL (LBM_UINT32)0x22222222 /* WDT normal */
87 #define HWDT_STS_WDTTO (LBM_UINT32)0xAAAAAAAA /* WDT time-out outbreak */
90 #define SWDT_STS_NOMAL HWDT_STS_NOMAL /* SWDT normal */
91 #define SWDT_STS_WDTTO HWDT_STS_WDTTO /* SWDT time-out outbreak */
94 #define IFS_PROG1_CODE (LBM_UINT8)0xAA /* Side PROG1 */
95 #define IFS_PROG2_CODE (LBM_UINT8)0x55 /* Side PROG2 */
97 /* Start infomation ID */
98 #define UPTBLE_ID_MAX (LBM_UINT8)0x20 /* LBM_UPTBLINFO Maximum value */
99 #define UPTBLE_ID_NORBOOT (LBM_UINT8)0x00 /* NOR-BOOT ID */
100 #define UPTBLE_ID_SCRLDR (LBM_UINT8)0x01 /* SecureLoader ID */
101 #define UPTBLE_ID_NANDBOOT (LBM_UINT8)0x02 /* NAND-BOOT ID */
102 #define UPTBLE_ID_ROOTFS (LBM_UINT8)0x03 /* Rootfs1 ID */
103 #define UPTBLE_ID_ROOTFS2 (LBM_UINT8)0x04 /* Rootfs2 ID */
106 #define STUP_STS_NORMAL (LBM_UINT32)0x00000000 /* normal status */
107 /* Rollback of protectionism is necessary by abnormal reset repetition */
108 #define STUP_STS_ERROR_DETEC (LBM_UINT32)0x22222222
109 #define STUP_STS_UPDATING (LBM_UINT32)0x33333333 /* updating status */
110 /* not for use(will be removed) */
111 #define STUP_STS_SIGNVRFY_ERROR (LBM_UINT32)0x11111111
113 /* mdUpdate/sdUpdate */
114 #define UPDATE_NOTI_NONE (LBM_UINT32)0x00000000 /* Notify is NOT required. */
115 #define UPDATE_NOTI_EXIST (LBM_UINT32)0xEEEEEEEE /* Notify is required. */
118 #define RAMJUDGE_STS_NOMAL (LBM_UINT32)0x44444444 /* RAM Judge Port is High */
119 #define RAMJUDGE_STS_NG (LBM_UINT32)0xDDDDDDDD /* RAM Judge Port is Low */
121 /* DRAM Self Refresh */
122 #define SELF_REFRESH_OK (LBM_UINT32)0x55555555 /* DRAM Self Refresh is OK */
123 #define SELF_REFRESH_NG (LBM_UINT32)0xCCCCCCCC /* DRAM Self Refresh is NG */
125 /* Release ROM type */
126 #define PRODUCTROM (LBM_UINT32)0x11111111
127 #define RELEASEROM (LBM_UINT32)0x22222222
128 #define RELEASEROM_REMAIN_USBBOOT (LBM_UINT32)0x44444444
129 #define DEBUGROM (LBM_UINT32)0x88888888
132 #define WRITE_NONE (LBM_UINT32)0x00000000
133 #define WRITE_DONE (LBM_UINT32)0x11111111
137 #define DEFAULT_OPIMAGE_DRAM_BACKUPED (LBM_UINT32)0x00000000
138 #define DEFAULT_OPIMAGE_FROM_EMMC (LBM_UINT32)0xAAAAAAAA
139 #define SPECIFIC_OPIMAGE_DRAM_BACKUPED (LBM_UINT32)0x11111111
140 #define SPECIFIC_OPIMAGE_FROM_EMMC (LBM_UINT32)0xBBBBBBBB
143 #define SPECIFIC_OPIMAGE_FLAG_NONE (LBM_UINT32)0x00000000
144 #define SPECIFIC_OPIMAGE_FILE_NONE (LBM_UINT32)0x11111111
145 #define SPECIFIC_OPIMAGE_FILESIZE_0 (LBM_UINT32)0x22222222
146 #define SPECIFIC_OPIMAGE_FILE_EXIST (LBM_UINT32)0xEEEEEEEE
149 #pragma pack(push, 4)
151 // Memory map of the SYS area of the mem0
153 #define SS_SYS_AREA_BOOT_MAX_SIZE (0x00010000UL)
155 #define SS_SYS_AREA_ROM_OFFSET (0x00010000UL)
156 #define SS_SYS_AREA_ROM_MAX_SIZE (0x00001000UL)
158 #define SS_SYS_AREA_RAM_OFFSET (0x00011000UL)
159 #define SS_SYS_AREA_RAM_MAX_SIZE (0x00001000UL)
161 //********* NOR area ****************
162 typedef struct LBM_boot_wpinfo_t {
163 LBM_UINT32 currentside; // IFS_PROG*_CODE
164 LBM_UINT32 stupStsA; // STUP_STS_*
165 LBM_UINT32 stupStsB; // STUP_STS_*
168 typedef struct LBM_boot_t {
169 LBM_UINT32 sts1; // SYSUP_CND_*
170 LBM_UINT32 btmode; // SYSUP_MODE_*
171 LBM_UINT32 sts2; // SYSUP_CND_*
172 LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
173 LBM_UINT32 sts3; // SYSUP_CND_*
176 //********* DRAM area ****************
177 typedef struct _tmb_ram_t {
178 LBM_UINT32 dram1; // SYSUP_DRAM_*
179 LBM_UINT32 sts; // SYSUP_CND_*
180 LBM_UINT32 upmode; // SYSUP_MODE_*
181 LBM_UINT32 dram2; // SYSUP_DRAM_*
182 LBM_UINT32 syscomSts; // SUBCPU_STS_*
183 LBM_UINT32 pwSts; // SDRAM_STS_*
184 LBM_UINT32 hwdtSts; // HWDT_STS_*
185 LBM_UINT32 dram3; // SYSUP_DRAM_*
186 LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
187 LBM_UINT32 sectorNo; // NOR Shared SectorNo
188 LBM_UINT32 mdUpdate; // UPDATE_NOTI_* LanServer Update Notification
189 LBM_UINT32 sdUpdate; // UPDATE_NOTI_* SettingService Update Notification
190 LBM_UINT32 ramjudgeSts; // RAMJUDGE_STS_*
191 LBM_UINT32 swdtSts; // SWDT_STS_*
192 LBM_UINT32 dram_self_refresh; // DRAM Self Refresh
193 LBM_UINT32 releaseNorType;
194 LBM_UINT32 socCpuType; // H2/E2/M2
195 LBM_UINT32 socEsNumber; // ES1x/ES2x/ES3x
196 LBM_UINT32 spiBootDevice; // NorDeviceID
197 LBM_UINT32 bootNorWrite; // uboot-api
198 LBM_UINT32 naviDetFactor;
200 LBM_UINT32 emmcTap; //emmcTap
201 LBM_UINT32 opdtUpdateReq;
202 LBM_UINT32 opdtLoadSatus;
203 LBM_UINT32 opdtLoadFactor;
211 * \~english Access type to the boot information
214 BAI_OPEN_RO, /* \~english Access type for the Read only*/
215 BAI_OPEN_RW /* \~english Access type for the Read and Write*/
219 * @class BOOT_AccessIf
220 * \~english @brief BOOT_AccessIf
221 * \~english @par Brief Introduction
222 * Class to provide the function of BOOT AccessIf
227 static void* g_m_plock;
232 * \ingroup BOOT_AccessIf
233 * \~english @par Summary:
234 * Obtain the access permission to the boot information (secondary storage area).
235 * \~english @param [in] type
236 * BAI_OPEN_t - Access type to the boot information\n
239 * - BAI_MTD_DEV_RO Access type for the Read only \n
240 * - BAI_MTD_DEV_RW Access type for the Read and Write
241 * \~english @retval None
242 * \~english @par Precondition:
244 * \~english @par Change in the internal status:
245 * - The change in the internal status does not occur by this API.
246 * \~english @par Conditions of processing failure
248 * \~english @par Classification:
250 * \~english @par Type
252 * \~english @par Detail:
253 * Obtain the access permission to the boot information \n
254 * When the access permission is locked, the API waits for Mutex until the access permission is released. \n
255 * This API is assumed to be called by SystemManager.
256 * \~english @see ~BOOT_AccessIf, CL_LockMap, CL_LockGet
258 explicit BOOT_AccessIf(BAI_OPEN_t type);
261 * \ingroup ~BOOT_AccessIf
262 * \~english @par Summary:
263 * Release the access permission to the boot information (secondary storage area).
264 * \~english @param None
265 * \~english @retval None
266 * \~english @par Precondition:
268 * \~english @par Change in the internal status:
269 * - The change in the internal status does not occur by this API.
270 * \~english @par Conditions of processing failure
272 * \~english @par Classification:
274 * \~english @par Type
276 * \~english @par Detail:
277 * Release the access permission to the boot information.\n
278 * \~english @see BOOT_AccessIf, CL_LockRelease
283 * \ingroup getBootInfo
284 * \~english @par Summary:
285 * Read the boot information (secondary storage area).
286 * \~english @param [out] p_boot_info
287 * LBM_NOR_t * - Destination buffer to read the boot information
289 * LBM_NOR_t Structure body
291 * typedef struct LBM_boot_t{
292 * LBM_UINT32 sts1; //SYSUP_CND_*
293 * LBM_UINT32 btmode; //SYSUP_MODE_*
294 * LBM_UINT32 sts2; //SYSUP_CND_*
295 * LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
296 * LBM_UINT32 sts3; //SYSUP_CND_*
299 * Refer to "ss_boot_map.h" for the parameters to be set to the member of struct LBM_NOR_t.
300 * \~english @retval eFrameworkunifiedStatusOK Reading success
301 * \~english @retval eFrameworkunifiedStatusFail Reading failed
302 * \~english @par Precondition:
304 * \~english @par Change in the internal status:
305 * - The change in the internal status does not occur by this API.
306 * \~english @par Conditions of processing failure
307 * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
308 * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
309 * \~english @par Classification:
311 * \~english @par Type
312 * Sync only(None communication)
313 * \~english @par Detail:
314 * Copy the boot information stored in the secondary storage area to p_boot_info. \n
315 * \~english @see setBootInfo
317 EFrameworkunifiedStatus getBootInfo(LBM_NOR_t* p_boot_info);
320 * \ingroup setBootInfo
321 * \~english @par Summary:
322 * Write the boot information (secondary storage area).
323 * \~english @param [in] p_boot_info
324 * LBM_NOR_t * - Original buffer to write the boot information
326 * LBM_NOR_tStructure body
328 * typedef struct LBM_boot_t{
329 * LBM_UINT32 sts1; //SYSUP_CND_*
330 * LBM_UINT32 btmode; //SYSUP_MODE_*
331 * LBM_UINT32 sts2; //SYSUP_CND_*
332 * LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
333 * LBM_UINT32 sts3; //SYSUP_CND_*
336 * Refer to "ss_boot_map.h" for the parameters to be set to the member of struct LBM_NOR_t.
337 * \~english @retval eFrameworkunifiedStatusOK Write success
338 * \~english @retval eFrameworkunifiedStatusFail Write failed
339 * \~english @par Precondition:
341 * \~english @par Change in the internal status:
342 * - The change in the internal status does not occur by this API.
343 * \~english @par Conditions of processing failure
344 * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
345 * - BOOT_AccessIf Opened secondary storage area with BAI_MTD_DEV_RO [eFrameworkunifiedStatusFail]
346 * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
347 * \~english @par Classification:
349 * \~english @par Type
350 * Sync only(None communication)
351 * \~english @par Detail:
352 * Write the boot information stored in p_boot_info to the secondary storage area. \n
353 * \~english @see getBootInfo
355 EFrameworkunifiedStatus setBootInfo(LBM_NOR_t* p_boot_info);
358 #endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
360 /** @}*/ // end of rom_access_library
361 /** @}*/ // end of system_service
362 /** @}*/ // end of BaseSystem