/* * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2024, Arm Limited. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * - Neither the name of ARM nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "target_cfg.h" #include "Driver_MPC.h" #include "device_definition.h" #include "region_defs.h" #include "region.h" #include "cmsis_driver_config.h" #include "target_cfg.h" #include "boot_hal.h" #include "Driver_Flash.h" #include "flash_layout.h" /* Import MPC driver */ extern ARM_DRIVER_MPC Driver_MRAM_MPC; extern ARM_DRIVER_MPC Driver_ISRAM0_MPC, Driver_ISRAM1_MPC; extern ARM_DRIVER_MPC Driver_ISRAM2_MPC, Driver_ISRAM3_MPC; extern ARM_DRIVER_FLASH Driver_FLASH0; REGION_DECLARE(Image$$, ER_DATA, $$Base)[]; REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[]; REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base); #if defined(__ICCARM__) #pragma required = ER_DATA$$Base #pragma required = ARM_LIB_HEAP$$Limit #endif /* bootloader platform-specific hw initialization */ int32_t boot_platform_init(void) { int32_t result; ARM_DRIVER_MPC* mpc_data_region2 = &Driver_ISRAM2_MPC; ARM_DRIVER_MPC* mpc_data_region3 = &Driver_ISRAM3_MPC; /* Rever MPC configuration */ Driver_MRAM_MPC.Initialize(); Driver_MRAM_MPC.ConfigRegion(MPC_MRAM_RANGE_BASE_S, MPC_MRAM_RANGE_LIMIT_S, ARM_MPC_ATTR_SECURE); mpc_data_region2->Initialize(); mpc_data_region2->ConfigRegion(MPC_ISRAM2_RANGE_BASE_S, MPC_ISRAM2_RANGE_LIMIT_S, ARM_MPC_ATTR_SECURE); mpc_data_region3->Initialize(); mpc_data_region3->ConfigRegion(MPC_ISRAM3_RANGE_BASE_S, MPC_ISRAM3_RANGE_LIMIT_S, ARM_MPC_ATTR_SECURE); /* Add barriers to assure the MPC configuration is done before continue * the execution. */ __DSB(); __ISB(); /* Initialize stack limit register */ uint32_t msp_stack_bottom = (uint32_t)®ION_NAME(Image$$, ARM_LIB_STACK, $$ZI$$Base); __set_MSPLIM(msp_stack_bottom); result = FLASH_DEV_NAME.Initialize(NULL); if (result != ARM_DRIVER_OK) { return 1; } return 0; }