AM261x MCU+ SDK: bootloader.h Source File

| AM261x MCU+ SDK 26.00.00 |

bootloader.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2021-2026 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_H_
40 #define BOOTLOADER_H_
41
42 #include <stdint.h>
43 #include <kernel/dpl/SystemP.h>
44 #include <drivers/soc.h>
45 #include <drivers/hw_include/csl_types.h>
46 #include <drivers/hw_include/cslr_soc.h>
47 #include <drivers/bootloader/soc/bootloader_soc.h>
48 #include <drivers/bootloader/bootloader_profile.h>
49 #include <drivers/hw_include/soc_config.h>
50
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55
68 #define BOOTLOADER_INVALID_ID (0xDEADBABE)
69
73 #define BOOTLOADER_OPMODE_LOCKSTEP (0U)
74 #define BOOTLOADER_OPMODE_STANDALONE (1U)
75
79 #define BOOTLOADER_MEDIA_MEM (0xB0070001)
80 #define BOOTLOADER_MEDIA_FLASH (0xB0070002)
81 #define BOOTLOADER_MEDIA_EMMC (0xB0070003)
82 #define BOOTLOADER_MEDIA_SD (0xB0070004)
83 #define BOOTLOADER_MEDIA_BUFIO (0xB0070005)
84 #define BOOTLOADER_MEDIA_PCIE (0xB0070006)
85 #define BOOTLOADER_MEDIA_USB (0xB0070007)
86 #define BOOTLOADER_MEDIA_UART (0xB0070008)
87
91 #define BOOTLOADER_SCRATCH_MEM_ENABLE (1U)
92
96 #define LINUX_LOAD_ONLY_IMAGE_ID (21U)
97
101 typedef void* Bootloader_Handle;
102
106 typedef struct Bootloader_Params_s
107 {
108 uint32_t memArgsAppImageBaseAddr;
109 /* Base address of the appimage in case of a memory bootloader */
110
111 uint8_t *bufIoTempBuf;
112 /* Temporary buffer to be used if the boot media is a buffered IO */
113
114 uint32_t bufIoTempBufSize;
115 /* Size of the temporary buffer to be used if the boot media is a buffered IO */
116
117 uint32_t bufIoDeviceIndex;
118 /* Instance index of the IO device driver (UART) */
119
120 char* fileName;
121 /*Pointer to the C string that hold name of file to be opened if the boot media is SD*/
122
123 } Bootloader_Params;
124
142 typedef int32_t (*Bootloader_imgOpenFxn)(void *args, Bootloader_Params *params);
143
156 typedef int32_t (*Bootloader_imgReadFxn)(void *dstAddr, uint32_t length, void *args);
157
168 typedef uint32_t (*Bootloader_imgOffsetFxn)(void *args);
169
181 typedef void (*Bootloader_imgSeekFxn)(uint32_t location, void *args);
182
194 typedef void (*Bootloader_imgCloseFxn)(void* handle, void *args);
195
206 typedef int32_t (*Bootloader_imgCustomFxn)(void *args);
207
214 typedef struct Bootloader_Fxns_s
215 {
216 Bootloader_imgOpenFxn imgOpenFxn;
217 Bootloader_imgReadFxn imgReadFxn;
218 Bootloader_imgOffsetFxn imgOffsetFxn;
219 Bootloader_imgSeekFxn imgSeekFxn;
220 Bootloader_imgCloseFxn imgCloseFxn;
221 Bootloader_imgCustomFxn imgCustomFxn;
222
223 } Bootloader_Fxns;
224
228 typedef struct Bootloader_Config_s
229 {
230 Bootloader_Fxns *fxns;
231 void *args;
232 uint32_t bootMedia;
233 uint32_t bootImageSize;
234 uint32_t coresPresentMap;
235 uint8_t *scratchMemPtr;
236 void *socCoreOpMode;
237 /* These options are for supporting HS-FS development, should be removed
238 after the boot time degradation is fixed for HS devices. */
239 uint32_t isAppimageSigned;
240 uint32_t disableAppImageAuth;
241 /* Whether to initialize ICSS cores or not */
242 uint32_t initICSSCores;
243 uint32_t enableScratchMem;
244
245 } Bootloader_Config;
246
247 #include <drivers/bootloader/bootloader_flash.h>
248 #include <drivers/bootloader/bootloader_mem.h>
249 #include <drivers/bootloader/bootloader_buf_io.h>
250 #if defined(SOC_AM64X) || defined(SOC_AM243X)
251 #include <drivers/bootloader/bootloader_uart.h>
252 #endif
253
257 typedef struct Bootloader_CpuInfo_s
258 {
259 uint32_t cpuId;
260 uint32_t clkHz;
261 uint32_t rprcOffset;
262 uintptr_t entryPoint;
263
264 } Bootloader_CpuInfo;
265
269 typedef struct Bootloader_BootImageInfo_s
270 {
271 Bootloader_CpuInfo cpuInfo[CSL_CORE_ID_MAX];
272
273 } Bootloader_BootImageInfo;
274
280 void Bootloader_Params_init(Bootloader_Params *params);
281
287 void Bootloader_BootImageInfo_init(Bootloader_BootImageInfo *bootImageInfo);
288
294 void Bootloader_CpuInfo_init(Bootloader_CpuInfo *cpuInfo);
295
311 Bootloader_Handle Bootloader_open(uint32_t instanceNum, Bootloader_Params *openParams);
312
318 void Bootloader_close(Bootloader_Handle handle);
319
335 int32_t Bootloader_initCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
336
352 int32_t Bootloader_loadCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
353
369 int32_t Bootloader_loadSelfCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo, uint32_t skipLoad);
370
384 int32_t Bootloader_runCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
385
398 int32_t Bootloader_runSelfCpu(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
399
413 int32_t Bootloader_bootCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
414
426 int32_t Bootloader_bootSelfCpu(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
427
441 int32_t Bootloader_parseMultiCoreAppImage(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
442
451 int32_t Bootloader_cpuSetAppEntryPoint(Bootloader_BootImageInfo *bootImageInfo, uint32_t bDualSelfR5F);
452
458 int32_t Bootloader_rprcImageParseEntryPoint(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
459
465 int32_t Bootloader_rprcImageLoad(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo);
466
475 int32_t Bootloader_parseAndLoadLinuxAppImage(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
476
485 int32_t Bootloader_runSelfCpuWithLinux(void);
486
497 uint32_t Bootloader_getMulticoreImageSize(Bootloader_Handle handle);
498
511 uint32_t Bootloader_isCorePresent(Bootloader_Handle handle, uint32_t cslCoreId);
512
522 uint32_t Bootloader_getBootMedia(Bootloader_Handle handle);
523
534 int32_t Bootloader_parseAndLoadMultiCoreELF(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
535
536 #if defined(SOC_AM64X)
537
547 int32_t Bootloader_parseAndLoadMultiCoreELFLinux(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
548 #endif
549
559 uint32_t Bootloader_getX509CertLen(uint8_t *x509_cert_ptr);
560
571 uint32_t Bootloader_getMsgLen(uint8_t *x509_cert_ptr, uint32_t x509_cert_size);
572
573 #if defined(SOC_AM64X) || defined(SOC_AM243X)
574
589 int32_t Bootloader_UartParseAndLoadMultiCoreELF(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo);
590 #endif
591
593 #ifdef __cplusplus
594 }
595 #endif
596
597 #endif
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:146
Bootloader_Config::coresPresentMap
uint32_t coresPresentMap
Definition: bootloader.h:234
args
void * args
Definition: hsmclient_msg.h:4
Bootloader_Config::fxns
Bootloader_Fxns * fxns
Definition: bootloader.h:230
Bootloader_Config::disableAppImageAuth
uint32_t disableAppImageAuth
Definition: bootloader.h:240
Bootloader_isCorePresent
uint32_t Bootloader_isCorePresent(Bootloader_Handle handle, uint32_t cslCoreId)
API to check if a particular core's image is present in the multicore image.
Bootloader_Params::memArgsAppImageBaseAddr
uint32_t memArgsAppImageBaseAddr
Definition: bootloader.h:108
SystemP.h
Bootloader_bootSelfCpu
int32_t Bootloader_bootSelfCpu(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
API to boot self CPU.
Bootloader_imgCloseFxn
void(* Bootloader_imgCloseFxn)(void *handle, void *args)
Driver implementation to close a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.
Definition: bootloader.h:194
Bootloader_rprcImageParseEntryPoint
int32_t Bootloader_rprcImageParseEntryPoint(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
Parse entrypoint from RPRC.
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.h:216
Bootloader_BootImageInfo_init
void Bootloader_BootImageInfo_init(Bootloader_BootImageInfo *bootImageInfo)
Initialize BootImage info.
Bootloader_Config::isAppimageSigned
uint32_t isAppimageSigned
Definition: bootloader.h:239
Bootloader_Params::bufIoDeviceIndex
uint32_t bufIoDeviceIndex
Definition: bootloader.h:117
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_CpuInfo::rprcOffset
uint32_t rprcOffset
Definition: bootloader.h:261
Bootloader_Config::args
void * args
Definition: bootloader.h:231
Bootloader_Fxns::imgSeekFxn
Bootloader_imgSeekFxn imgSeekFxn
Definition: bootloader.h:219
Bootloader_runSelfCpuWithLinux
int32_t Bootloader_runSelfCpuWithLinux(void)
API to boot self CPU with Linux.
Bootloader_parseAndLoadMultiCoreELF
int32_t Bootloader_parseAndLoadMultiCoreELF(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
API to parse and load MCELF image.
Bootloader_Params::bufIoTempBuf
uint8_t * bufIoTempBuf
Definition: bootloader.h:111
Bootloader_parseMultiCoreAppImage
int32_t Bootloader_parseMultiCoreAppImage(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
Parse Multicore Appimage.
Bootloader_Config
Bootloader driver configuration, these are filled by SysCfg based on the boot media selected.
Definition: bootloader.h:229
Bootloader_imgCustomFxn
int32_t(* Bootloader_imgCustomFxn)(void *args)
Driver implementation to enable a custom function for a specific bootloader driver - Memory,...
Definition: bootloader.h:206
Bootloader_imgOffsetFxn
uint32_t(* Bootloader_imgOffsetFxn)(void *args)
Driver implementation to get the current offset in the boot media.
Definition: bootloader.h:168
Bootloader_Fxns::imgOffsetFxn
Bootloader_imgOffsetFxn imgOffsetFxn
Definition: bootloader.h:218
Bootloader_close
void Bootloader_close(Bootloader_Handle handle)
Close bootloader driver.
Bootloader_Config::socCoreOpMode
void * socCoreOpMode
Definition: bootloader.h:236
Bootloader_cpuSetAppEntryPoint
int32_t Bootloader_cpuSetAppEntryPoint(Bootloader_BootImageInfo *bootImageInfo, uint32_t bDualSelfR5F)
Set Application entry point for self CPU in the AM65x SOC from reset.
Bootloader_loadSelfCpu
int32_t Bootloader_loadSelfCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo, uint32_t skipLoad)
API to load self CPU.
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.h:233
Bootloader_Params::bufIoTempBufSize
uint32_t bufIoTempBufSize
Definition: bootloader.h:114
Bootloader_Params::fileName
char * fileName
Definition: bootloader.h:120
Bootloader_getMsgLen
uint32_t Bootloader_getMsgLen(uint8_t *x509_cert_ptr, uint32_t x509_cert_size)
API to get image length from a x509 certificate.
Bootloader_CpuInfo::clkHz
uint32_t clkHz
Definition: bootloader.h:260
Bootloader_CpuInfo::cpuId
uint32_t cpuId
Definition: bootloader.h:259
Bootloader_CpuInfo
Data structure containing information related to a particular CPU, required for RPRC loading.
Definition: bootloader.h:258
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.h:142
Bootloader_BootImageInfo
Data structure containing information related all CPUs, this will be filled by Bootloader_parseMultiC...
Definition: bootloader.h:270
Bootloader_Config::bootMedia
uint32_t bootMedia
Definition: bootloader.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.h:221
Bootloader_initCpu
int32_t Bootloader_initCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
API to initialize a non-self CPU.
Bootloader_rprcImageLoad
int32_t Bootloader_rprcImageLoad(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
Load application binaries into SOC memory.
Bootloader_imgSeekFxn
void(* Bootloader_imgSeekFxn)(uint32_t location, void *args)
Driver implementation to read from boot media using a specific bootloader driver - Memory,...
Definition: bootloader.h:181
Bootloader_Fxns::imgCloseFxn
Bootloader_imgCloseFxn imgCloseFxn
Definition: bootloader.h:220
Bootloader_parseAndLoadLinuxAppImage
int32_t Bootloader_parseAndLoadLinuxAppImage(Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
Parse and load linux Appimage, containing linux binaries(ATF, OPTEE, SPL)
Bootloader_Fxns
Driver implementation callbacks.
Definition: bootloader.h:215
Bootloader_getX509CertLen
uint32_t Bootloader_getX509CertLen(uint8_t *x509_cert_ptr)
API to get the length of an x509 certificate.
Bootloader_Config::enableScratchMem
uint32_t enableScratchMem
Definition: bootloader.h:243
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.h:156
Bootloader_Handle
void * Bootloader_Handle
Handle to the Bootloader driver returned by Bootloader_open()
Definition: bootloader.h:101
Bootloader_CpuInfo_init
void Bootloader_CpuInfo_init(Bootloader_CpuInfo *cpuInfo)
Initialize CPU info.
Bootloader_Params
Parameters passed during Bootloader_open()
Definition: bootloader.h:107
Bootloader_open
Bootloader_Handle Bootloader_open(uint32_t instanceNum, Bootloader_Params *openParams)
Open bootloader driver.
Bootloader_loadCpu
int32_t Bootloader_loadCpu(Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
API to load a non-self CPU.
Bootloader_Config::scratchMemPtr
uint8_t * scratchMemPtr
Definition: bootloader.h:235
Bootloader_CpuInfo::entryPoint
uintptr_t entryPoint
Definition: bootloader.h:262
Bootloader_Config::initICSSCores
uint32_t initICSSCores
Definition: bootloader.h:242
Bootloader_Fxns::imgReadFxn
Bootloader_imgReadFxn imgReadFxn
Definition: bootloader.h:217