1 /*
2  * Copyright 2021 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #include "fsl_flash.h"
8 #include "fsl_flash_ffr.h"
9 #include "fsl_flexspi_nor_flash.h"
10 #include "fsl_runbootloader.h"
11 
12 /*! @brief Component ID definition, used by tools. */
13 #ifndef FSL_COMPONENT_ID
14 #define FSL_COMPONENT_ID "platform.drivers.runBootloader"
15 #endif
16 
17 /*******************************************************************************
18  * Definitions
19  ******************************************************************************/
20 #define BOOTLOADER_API_TREE_POINTER ((bootloader_tree_t *)0x1302FC00U)
21 
22 /*!
23  * @brief Root of the bootloader API tree.
24  *
25  * An instance of this struct resides in read-only memory in the bootloader. It
26  * provides a user application access to APIs exported by the bootloader.
27  *
28  * @note The order of existing fields must not be changed.
29  */
30 typedef struct BootloaderTree
31 {
32     void (*runBootloader)(void *arg); /*!< Function to start the bootloader executing.*/
33     const uint32_t version;           /*!< Bootloader version number.*/
34     const char *copyright;            /*!< Copyright string.*/
35     const uint32_t reserved0;         /*!< reserved*/
36     const uint32_t flashDriver;       /*!< Internal Flash driver API.*/
37     const uint32_t reserved1[5];      /*!< reserved*/
38     const uint32_t nbootDriver;       /*!< Please refer to "fsl_nboot.h" */
39     const uint32_t flexspiNorDriver;  /*!< FlexSPI NOR FLASH Driver API.*/
40     const uint32_t reserved2;         /*!< reserved*/
41     const uint32_t memoryInterface;   /*!< Please refer to "fsl_mem_interface.h" */
42 } bootloader_tree_t;
43 
44 /*******************************************************************************
45  * API
46  ******************************************************************************/
47 
bootloader_user_entry(void * arg)48 void bootloader_user_entry(void *arg)
49 {
50     assert(BOOTLOADER_API_TREE_POINTER);
51     BOOTLOADER_API_TREE_POINTER->runBootloader(arg);
52 }
53