1 /******************************************************************************* 2 * Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions. 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * MPFS HAL Embedded Software 7 * 8 */ 9 10 /****************************************************************************** 11 * @file system_startup.h 12 * @author Microchip-FPGA Embedded Systems Solutions 13 * @brief Macros and APIs for the system_startup.c 14 */ 15 16 #ifndef SYSTEM_STARTUP_H 17 #define SYSTEM_STARTUP_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 typedef enum WFI_SM_ 24 { 25 INIT_THREAD_PR = 0x00, /*!< 0 init pointer */ 26 CHECK_WFI = 0x01, /*!< is hart in wfi? */ 27 SEND_WFI = 0x02, /*!< separate state to 28 add a little delay*/ 29 CHECK_WAKE = 0x03, /*!< has hart left wfi*/ 30 } WFI_SM; 31 32 /*------------------------------------------------------------------------------ 33 * Markers used to indicate startup status of hart 34 */ 35 #ifndef HLS_DATA_IN_WFI 36 #define HLS_DATA_IN_WFI 0x12345678U 37 #endif 38 #ifndef HLS_DATA_PASSED_WFI 39 #define HLS_DATA_PASSED_WFI 0x87654321U 40 #endif 41 42 #ifndef SHARED_MEM_INITALISED_MARKER 43 #define SHARED_MEM_INITALISED_MARKER 0xA1A2A3A4UL 44 #endif 45 #ifndef SHARED_MEM_DEFAULT_STATUS 46 #define SHARED_MEM_DEFAULT_STATUS 0x00000000UL 47 #endif 48 49 typedef struct HLS_DATA_ 50 { 51 volatile uint32_t in_wfi_indicator; 52 volatile uint32_t my_hart_id; 53 volatile uint32_t shared_mem_marker; 54 volatile uint32_t shared_mem_status; 55 volatile uint64_t * shared_mem; 56 } HLS_DATA; 57 58 /*------------------------------------------------------------------------------ 59 * Symbols from the linker script used to locate the text, data and bss sections. 60 */ 61 extern unsigned long __stack_top_h0$; 62 extern unsigned long __stack_bottom_h0$; 63 extern unsigned long __stack_top_h1$; 64 extern unsigned long __stack_bottom_h1$; 65 extern unsigned long __stack_top_h2$; 66 extern unsigned long __stack_bottom_h2$; 67 extern unsigned long __stack_top_h3$; 68 extern unsigned long __stack_bottom_h3$; 69 extern unsigned long __stack_top_h4$; 70 extern unsigned long __stack_bottom_h4$; 71 extern unsigned long __app_hart_common_start; 72 extern unsigned long __app_hart_common_end; 73 74 extern unsigned long __data_load; 75 extern unsigned long __data_start; 76 extern unsigned long __data_end; 77 78 extern unsigned long __sbss_start; 79 extern unsigned long __sbss_end; 80 81 extern unsigned long __bss_start; 82 extern unsigned long __bss_end; 83 84 extern unsigned long __sdata_load; 85 extern unsigned long __sdata_start; 86 extern unsigned long __sdata_end; 87 88 extern unsigned long __text_load; 89 extern unsigned long __text_start; 90 extern unsigned long __text_end; 91 92 extern unsigned long __l2lim_end; 93 94 extern unsigned long __e51itim_start; 95 extern unsigned long __e51itim_end; 96 97 extern unsigned long __u54_1_itim_start; 98 extern unsigned long __u54_1_itim_end; 99 100 extern unsigned long __u54_2_itim_start; 101 extern unsigned long __u54_2_itim_end; 102 103 extern unsigned long __u54_3_itim_start; 104 extern unsigned long __u54_3_itim_end; 105 106 extern unsigned long __u54_4_itim_start; 107 extern unsigned long __u54_4_itim_end; 108 109 #ifndef MPFS_HAL_HW_CONFIG 110 extern unsigned long __uninit_bottom$; 111 extern unsigned long __uninit_top$; 112 #endif 113 114 /* 115 * Function Declarations 116 */ 117 int main_first_hart(HLS_DATA* hls); 118 int main_other_hart(HLS_DATA* hls); 119 void e51(void); 120 void u54_1(void); 121 void u54_2(void); 122 void u54_3(void); 123 void u54_4(void); 124 void init_memory( void); 125 void init_ddr( void); 126 uint8_t init_mem_protection_unit(void); 127 uint8_t init_pmp(uint8_t hart_id); 128 uint8_t init_bus_error_unit( void); 129 uint8_t mss_set_apb_bus_cr(uint32_t reg_value); 130 uint8_t mss_get_apb_bus_cr(void); 131 char * memfill(void *dest, const void * src, size_t len); 132 char * config_copy(void *dest, const void * src, size_t len); 133 char * config_16_copy(void *dest, const void * src, size_t len); 134 char * config_32_copy(void *dest, const void * src, size_t len); 135 char * config_64_copy(void *dest, const void * src, size_t len); 136 137 void copy_section 138 ( 139 uint64_t * p_load, 140 uint64_t * p_vma, 141 uint64_t * p_vma_end 142 ); 143 void zero_section 144 ( 145 uint64_t *__sbss_start, 146 uint64_t * __sbss_end 147 ); 148 void load_virtual_rom(void); 149 150 void count_section 151 ( 152 uint64_t * start_address, 153 uint64_t * end_address, 154 uint64_t * start_value 155 ); 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* SYSTEM_STARTUP_H */ 162