AM275 FreeRTOS SDK  11.01.00
bootloader_mcelf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-2023 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
39 #ifndef BOOTLOADER_MCELF_H_
40 #define BOOTLOADER_MCELF_H_
41 
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
45 
46 #include <stdint.h>
47 #include <kernel/dpl/SystemP.h>
48 #include <drivers/soc.h>
49 #include <drivers/hw_include/csl_types.h>
50 #include <drivers/hw_include/cslr_soc.h>
51 #include <drivers/hw_include/soc_config.h>
52 #include <drivers/bootloader/soc/bootloader_soc.h>
53 #include <drivers/bootloader/bootloader_profile.h>
54 #include <drivers/bootloader/bootloader_elf.h>
55 
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
70 /* ========================================================================== */
71 /* Macros & Typedefs */
72 /* ========================================================================== */
73 
77 #define BOOTLOADER_INVALID_ID ((uint32_t)0xDEADBABE)
78 
82 #define BOOTLOADER_OPMODE_LOCKSTEP (0U)
83 #define BOOTLOADER_OPMODE_STANDALONE (1U)
84 
88 #define BOOTLOADER_MEDIA_MEM ((uint32_t)0xB0070001U)
89 #define BOOTLOADER_MEDIA_FLASH ((uint32_t)0xB0070002U)
90 #define BOOTLOADER_MEDIA_EMMC ((uint32_t)0xB0070003U)
91 #define BOOTLOADER_MEDIA_SD ((uint32_t)0xB0070004U)
92 #define BOOTLOADER_MEDIA_BUFIO ((uint32_t)0xB0070005U)
93 #define BOOTLOADER_MEDIA_UART ((uint32_t)0xB0070006U)
94 
98 typedef void* Bootloader_Handle;
99 
100 /* ========================================================================== */
101 /* Structure Declarations */
102 /* ========================================================================== */
103 
107 typedef struct Bootloader_Params_s
108 {
110  /* Base address of the appimage in case of a memory bootloader */
111 
112  uint8_t *bufIoTempBuf;
113  /* Temporary buffer to be used if the boot media is a buffered IO */
114 
116  /* Size of the temporary buffer to be used if the boot media is a buffered IO */
117 
118  char* fileName;
119  /*Pointer to the C string that hold name of file to be opened if the boot media is SD*/
120 
122  /* Instance index of the IO device driver (UART) */
123 
125 
143 typedef int32_t (*Bootloader_imgOpenFxn)(void *args, Bootloader_Params *params);
144 
157 typedef int32_t (*Bootloader_imgReadFxn)(void *dstAddr, uint32_t length, void *args);
158 
169 typedef uint32_t (*Bootloader_imgOffsetFxn)(void *args);
170 
182 typedef void (*Bootloader_imgSeekFxn)(uint32_t location, void *args);
183 
195 typedef void (*Bootloader_imgCloseFxn)(void* handle, void *args);
196 
207 typedef int32_t (*Bootloader_imgCustomFxn)(void *args);
208 
214 typedef struct Bootloader_Fxns_s
215 {
222 
224 
228 typedef struct Bootloader_Config_s
229 {
231  void *args;
232  uint32_t bootMedia;
233  uint32_t bootImageSize;
234  uint32_t coresPresentMap;
235  uint8_t *scratchMemPtr;
237  uint32_t enableDma;
239 
240 #include <drivers/bootloader/bootloader_flash.h>
241 #include <drivers/bootloader/bootloader_mem.h>
242 #include <drivers/bootloader/bootloader_buf_io.h>
243 #include <drivers/bootloader/bootloader_sd.h>
244 #include <drivers/bootloader/bootloader_uart.h>
245 
249 typedef struct Bootloader_CpuInfo_s
250 {
251  uint32_t cpuId;
252  uint32_t clkHz;
253  uintptr_t entryPoint;
254  bool smpEnable;
255 
257 
261 typedef struct Bootloader_BootImageInfo_s
262 {
264 
266 
270 typedef enum
271 {
275 
279 typedef struct
280 {
284  uint8_t coreId;
287 
288 /* ========================================================================== */
289 /* Function Declarations */
290 /* ========================================================================== */
291 
298 
305 
312 
328 Bootloader_Handle Bootloader_open(uint32_t instanceNum, Bootloader_Params *openParams);
329 
336 
351 
364 
373 
385 
395 
407 
420 uint32_t Bootloader_isCorePresent(Bootloader_Handle handle, uint32_t cslCoreId);
421 
432 
442 void Bootloader_ReservedMemInit(uint32_t startAddress, uint32_t regionlength);
443 
453 
469 
486 
491 
498 #ifdef __cplusplus
499 }
500 #endif
501 
502 #endif /* #ifndef BOOTLOADER_MCELF_H_ */
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:79
Bootloader_Config::coresPresentMap
uint32_t coresPresentMap
Definition: bootloader_mcelf.h:234
Bootloader_Config::fxns
Bootloader_Fxns * fxns
Definition: bootloader_mcelf.h:230
Bootloader_isCorePresent
uint32_t Bootloader_isCorePresent(Bootloader_Handle handle, uint32_t cslCoreId)
API to check if a particular core's ELF image is present in the multicore image.
Bootloader_Params::memArgsAppImageBaseAddr
uint32_t memArgsAppImageBaseAddr
Definition: bootloader_mcelf.h:109
Bootloader_LoadImageParams::bootImageInfo
Bootloader_BootImageInfo bootImageInfo
Definition: bootloader_mcelf.h:281
Bootloader_ReservedMemInit
void Bootloader_ReservedMemInit(uint32_t startAddress, uint32_t regionlength)
API to set the memory region of bootloader.
SystemP.h
Bootloader_imgCloseFxn
void(* Bootloader_imgCloseFxn)(void *handle, void *args)
Driver implementation to close a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.
Definition: bootloader_mcelf.h:195
Bootloader_getBootMedia
uint32_t Bootloader_getBootMedia(Bootloader_Handle handle)
API to get the selected boot media in the bootloader instance.
Bootloader_Fxns::imgOpenFxn
Bootloader_imgOpenFxn imgOpenFxn
Definition: bootloader_mcelf.h:216
Bootloader_BootImageInfo_init
void Bootloader_BootImageInfo_init(Bootloader_BootImageInfo *bootImageInfo)
Initialize BootImage info.
BOOTLOADER_IMAGE_NOT_LOADED
@ BOOTLOADER_IMAGE_NOT_LOADED
Definition: bootloader_mcelf.h:272
Bootloader_LoadImageParams::loadStatus
Bootloader_AppImageLoadStatus loadStatus
Definition: bootloader_mcelf.h:285
Bootloader_Params::bufIoDeviceIndex
uint32_t bufIoDeviceIndex
Definition: bootloader_mcelf.h:121
Bootloader_Params_init
void Bootloader_Params_init(Bootloader_Params *params)
Initialize Bootloader params.
Bootloader_getMulticoreImageSize
uint32_t Bootloader_getMulticoreImageSize(Bootloader_Handle handle)
API to fetch the size of the multicore image.
Bootloader_LoadImageParams::bootParams
Bootloader_Params bootParams
Definition: bootloader_mcelf.h:282
Bootloader_JumpSelfCpu
void Bootloader_JumpSelfCpu(void)
API to jump self CPU.
Bootloader_Config::args
void * args
Definition: bootloader_mcelf.h:231
Bootloader_UartParseAndLoadMultiCoreELF
int32_t Bootloader_UartParseAndLoadMultiCoreELF(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
API to parse and load a multicore ELF image for Uart bootmedia.
Bootloader_Fxns::imgSeekFxn
Bootloader_imgSeekFxn imgSeekFxn
Definition: bootloader_mcelf.h:219
Bootloader_parseAndLoadMultiCoreELF
int32_t Bootloader_parseAndLoadMultiCoreELF(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
API to parse and load a multicore ELF image for Flash, eMMC & SD bootmedia.
Bootloader_Params::bufIoTempBuf
uint8_t * bufIoTempBuf
Definition: bootloader_mcelf.h:112
Bootloader_Config
Bootloader driver configuration, these are filled by SysCfg based on the boot media selected.
Definition: bootloader_mcelf.h:229
Bootloader_LoadImageParams::coreId
uint8_t coreId
Definition: bootloader_mcelf.h:284
Bootloader_imgCustomFxn
int32_t(* Bootloader_imgCustomFxn)(void *args)
Driver implementation to enable a custom function for a specific bootloader driver - Memory,...
Definition: bootloader_mcelf.h:207
Bootloader_imgOffsetFxn
uint32_t(* Bootloader_imgOffsetFxn)(void *args)
Driver implementation to get the current offset in the boot media.
Definition: bootloader_mcelf.h:169
Bootloader_Fxns::imgOffsetFxn
Bootloader_imgOffsetFxn imgOffsetFxn
Definition: bootloader_mcelf.h:218
Bootloader_close
void Bootloader_close(Bootloader_Handle handle)
Close bootloader driver.
Bootloader_Config::socCoreOpMode
void * socCoreOpMode
Definition: bootloader_mcelf.h:236
Bootloader_bootCpu
int32_t Bootloader_bootCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
API to boot a non-self CPU.
Bootloader_runCpu
int32_t Bootloader_runCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
API to run a non-self CPU.
Bootloader_Config::bootImageSize
uint32_t bootImageSize
Definition: bootloader_mcelf.h:233
Bootloader_AppImageLoadStatus
Bootloader_AppImageLoadStatus
AppImage load status.
Definition: bootloader_mcelf.h:271
Bootloader_runSelfCpuWithLinux
int32_t Bootloader_runSelfCpuWithLinux()
API to boot self CPU with Linux.
Bootloader_Params::bufIoTempBufSize
uint32_t bufIoTempBufSize
Definition: bootloader_mcelf.h:115
Bootloader_Params::fileName
char * fileName
Definition: bootloader_mcelf.h:118
Bootloader_CpuInfo::clkHz
uint32_t clkHz
Definition: bootloader_mcelf.h:252
Bootloader_CpuInfo::cpuId
uint32_t cpuId
Definition: bootloader_mcelf.h:251
Bootloader_CpuInfo
Data structure containing information related to a particular CPU, required for MCELF loading.
Definition: bootloader_mcelf.h:250
Bootloader_imgOpenFxn
int32_t(* Bootloader_imgOpenFxn)(void *args, Bootloader_Params *params)
Driver implementation to open a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.
Definition: bootloader_mcelf.h:143
Bootloader_powerOffCpu
void Bootloader_powerOffCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
API to power off a core.
Bootloader_BootImageInfo
Data structure containing information related all CPUs, this will be filled by Bootloader_parseAndLoa...
Definition: bootloader_mcelf.h:262
Bootloader_Config::bootMedia
uint32_t bootMedia
Definition: bootloader_mcelf.h:232
Bootloader_runSelfCpu
int32_t Bootloader_runSelfCpu(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
API to boot self CPU.
Bootloader_Fxns::imgCustomFxn
Bootloader_imgCustomFxn imgCustomFxn
Definition: bootloader_mcelf.h:221
Bootloader_imgSeekFxn
void(* Bootloader_imgSeekFxn)(uint32_t location, void *args)
Driver implementation to move read offset on boot media using a specific bootloader driver - Memory,...
Definition: bootloader_mcelf.h:182
Bootloader_CpuInfo::smpEnable
bool smpEnable
Definition: bootloader_mcelf.h:254
Bootloader_Fxns::imgCloseFxn
Bootloader_imgCloseFxn imgCloseFxn
Definition: bootloader_mcelf.h:220
Bootloader_Fxns
Driver implementation callbacks.
Definition: bootloader_mcelf.h:215
Bootloader_openDma
void Bootloader_openDma()
API to open DMA channel.
Bootloader_LoadImageParams::bootHandle
Bootloader_Handle bootHandle
Definition: bootloader_mcelf.h:283
Bootloader_imgReadFxn
int32_t(* Bootloader_imgReadFxn)(void *dstAddr, uint32_t length, void *args)
Driver implementation to read from boot media using a specific bootloader driver - Memory,...
Definition: bootloader_mcelf.h:157
Bootloader_Handle
void * Bootloader_Handle
Handle to the Bootloader driver returned by Bootloader_open()
Definition: bootloader_mcelf.h:98
Bootloader_Config::enableDma
uint32_t enableDma
Definition: bootloader_mcelf.h:237
Bootloader_CpuInfo_init
void Bootloader_CpuInfo_init(Bootloader_CpuInfo *cpuInfo)
Initialize CPU info.
Bootloader_closeDma
void Bootloader_closeDma()
API to close DMA channel.
Bootloader_Params
Parameters passed during Bootloader_open()
Definition: bootloader_mcelf.h:108
Bootloader_open
Bootloader_Handle Bootloader_open(uint32_t instanceNum, Bootloader_Params *openParams)
Open bootloader driver.
Bootloader_Config::scratchMemPtr
uint8_t * scratchMemPtr
Definition: bootloader_mcelf.h:235
Bootloader_CpuInfo::entryPoint
uintptr_t entryPoint
Definition: bootloader_mcelf.h:253
BOOTLOADER_IMAGE_LOADED
@ BOOTLOADER_IMAGE_LOADED
Definition: bootloader_mcelf.h:273
Bootloader_LoadImageParams
Data structure containing necessary structs to load AppImage on different CPUs.
Definition: bootloader_mcelf.h:280
Bootloader_Fxns::imgReadFxn
Bootloader_imgReadFxn imgReadFxn
Definition: bootloader_mcelf.h:217