[3d6669cc] | 1 | /* |
---|
| 2 | * Cirrus EP7312 Startup code |
---|
| 3 | * |
---|
| 4 | * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> |
---|
[6128a4a] | 5 | * |
---|
[3d6669cc] | 6 | * The license and distribution terms for this file may be |
---|
| 7 | * found in the file LICENSE in this distribution or at |
---|
| 8 | * |
---|
[f2f11abe] | 9 | * http://www.rtems.com/license/LICENSE. |
---|
[3d6669cc] | 10 | * |
---|
| 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #include <bsp.h> |
---|
| 16 | #include <rtems/libcsupport.h> |
---|
| 17 | #include <rtems/libio.h> |
---|
| 18 | #include <ep7312.h> |
---|
| 19 | #include <uart.h> |
---|
| 20 | |
---|
| 21 | /*************************************************************/ |
---|
| 22 | /* Macros */ |
---|
| 23 | /*************************************************************/ |
---|
| 24 | |
---|
| 25 | /*************************************************************/ |
---|
| 26 | /* Data Structures */ |
---|
| 27 | /*************************************************************/ |
---|
| 28 | |
---|
| 29 | /*************************************************************/ |
---|
| 30 | /* Global Variables */ |
---|
| 31 | /*************************************************************/ |
---|
| 32 | extern void *_flash_size; |
---|
| 33 | extern void *_flash_base; |
---|
| 34 | extern void *_sdram_size; |
---|
| 35 | extern void *_sdram_base; |
---|
| 36 | extern void *_bss_free_start; |
---|
| 37 | |
---|
| 38 | unsigned long free_mem_start; |
---|
| 39 | unsigned long free_mem_end; |
---|
| 40 | |
---|
| 41 | /* The original BSP configuration table from the application and our copy of it |
---|
| 42 | with some changes. */ |
---|
| 43 | |
---|
| 44 | extern rtems_configuration_table Configuration; |
---|
| 45 | rtems_configuration_table BSP_Configuration; |
---|
| 46 | |
---|
| 47 | rtems_cpu_table Cpu_table; /* CPU configuration table. */ |
---|
| 48 | char *rtems_progname; /* Program name - from main(). */ |
---|
| 49 | |
---|
| 50 | /*************************************************************/ |
---|
| 51 | /* Function prototypes */ |
---|
| 52 | /*************************************************************/ |
---|
| 53 | extern void rtems_irq_mngt_init(void); |
---|
[2a7f710f] | 54 | void bsp_libc_init( void *, uint32_t, int ); |
---|
[3d6669cc] | 55 | void bsp_postdriver_hook(void); |
---|
| 56 | |
---|
| 57 | /**************************************************************************/ |
---|
| 58 | /* */ |
---|
| 59 | /* NAME: bps_pretasking_hook - Function to setup system before startup */ |
---|
| 60 | /* */ |
---|
| 61 | /* DESCRIPTION: */ |
---|
| 62 | /* This function is called before drivers are initialized and used */ |
---|
| 63 | /* to setup libc and BSP extensions. It configures non cacheable */ |
---|
| 64 | /* SDRAM, SRAM, AIM, and ADM regions and sets up the CPU's memory */ |
---|
| 65 | /* protection unit. */ |
---|
| 66 | /* */ |
---|
| 67 | /* GLOBALS USED: */ |
---|
| 68 | /* free_mem_start */ |
---|
| 69 | /* free_mem_end */ |
---|
| 70 | /* */ |
---|
| 71 | /* RESTRICTIONS/LIMITATIONS: */ |
---|
| 72 | /* Since this function is setting up libc, it cannot use and libc */ |
---|
| 73 | /* functions. */ |
---|
| 74 | /* */ |
---|
| 75 | /**************************************************************************/ |
---|
| 76 | void bsp_pretasking_hook(void) |
---|
| 77 | { |
---|
[2a7f710f] | 78 | uint32_t heap_start; |
---|
| 79 | uint32_t heap_size; |
---|
[3d6669cc] | 80 | |
---|
[6128a4a] | 81 | /* |
---|
[3d6669cc] | 82 | * Set up the heap. It uses all free SDRAM except that reserved |
---|
| 83 | * for non-cached uses. |
---|
| 84 | */ |
---|
| 85 | heap_start = free_mem_start; |
---|
[6128a4a] | 86 | |
---|
[3d6669cc] | 87 | /* heap_size = (free_mem_end - heap_start - MEM_NOCACHE_SIZE); */ |
---|
| 88 | heap_size = 0x200000; |
---|
| 89 | |
---|
| 90 | bsp_libc_init((void *)heap_start, heap_size, 0); |
---|
| 91 | |
---|
| 92 | #ifdef RTEMS_DEBUG |
---|
| 93 | |
---|
| 94 | rtems_debug_enable(RTEMS_DEBUG_ALL_MASK); |
---|
| 95 | |
---|
| 96 | #endif /* RTEMS_DEBUG */ |
---|
| 97 | |
---|
| 98 | } /* bsp_pretasking_hook */ |
---|
[6128a4a] | 99 | |
---|
[3d6669cc] | 100 | /**************************************************************************/ |
---|
| 101 | /* */ |
---|
| 102 | /* NAME: bsp_start_default - BSP initialization function */ |
---|
| 103 | /* */ |
---|
| 104 | /* DESCRIPTION: */ |
---|
| 105 | /* This function is called before RTEMS is initialized and used */ |
---|
| 106 | /* adjust the kernel's configuration. */ |
---|
| 107 | /* */ |
---|
| 108 | /* This function also configures the CPU's memory protection unit. */ |
---|
| 109 | /* */ |
---|
| 110 | /* GLOBALS USED: */ |
---|
| 111 | /* CPU_table */ |
---|
| 112 | /* BSP_Configuration */ |
---|
| 113 | /* free_mem_start */ |
---|
| 114 | /* free_mem_end */ |
---|
| 115 | /* free_mem_nocache_start */ |
---|
| 116 | /* _bss_free_start */ |
---|
| 117 | /* mpu_region_tbl */ |
---|
| 118 | /* */ |
---|
| 119 | /* */ |
---|
| 120 | /* */ |
---|
| 121 | /* */ |
---|
| 122 | /* RESTRICTIONS/LIMITATIONS: */ |
---|
| 123 | /* Since RTEMS is not configured, no RTEMS functions can be called. */ |
---|
| 124 | /* */ |
---|
| 125 | /**************************************************************************/ |
---|
| 126 | void bsp_start_default( void ) |
---|
| 127 | { |
---|
| 128 | /* disable interrupts */ |
---|
| 129 | *EP7312_INTMR1 = 0; |
---|
| 130 | *EP7312_INTMR2 = 0; |
---|
| 131 | Cpu_table.pretasking_hook = bsp_pretasking_hook; |
---|
| 132 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
[6128a4a] | 133 | |
---|
[3d6669cc] | 134 | /* Place RTEMS workspace at beginning of free memory. */ |
---|
| 135 | BSP_Configuration.work_space_start = (void *)&_bss_free_start; |
---|
[6128a4a] | 136 | |
---|
| 137 | free_mem_start = ((uint32_t)&_bss_free_start + |
---|
[3d6669cc] | 138 | BSP_Configuration.work_space_size); |
---|
[6128a4a] | 139 | |
---|
[2a7f710f] | 140 | free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size); |
---|
[6128a4a] | 141 | |
---|
[3d6669cc] | 142 | /* |
---|
| 143 | * Init rtems exceptions management |
---|
| 144 | */ |
---|
| 145 | rtems_exception_init_mngt(); |
---|
[6128a4a] | 146 | |
---|
[3d6669cc] | 147 | /* |
---|
| 148 | * Init rtems interrupt management |
---|
| 149 | */ |
---|
[6128a4a] | 150 | rtems_irq_mngt_init(); |
---|
| 151 | |
---|
[3d6669cc] | 152 | /* |
---|
| 153 | * The following information is very useful when debugging. |
---|
| 154 | */ |
---|
| 155 | #if 0 |
---|
| 156 | printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size ); |
---|
| 157 | printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions ); |
---|
| 158 | printk( "microseconds_per_tick = 0x%x\n", |
---|
| 159 | BSP_Configuration.microseconds_per_tick ); |
---|
| 160 | printk( "ticks_per_timeslice = 0x%x\n", |
---|
| 161 | BSP_Configuration.ticks_per_timeslice ); |
---|
| 162 | printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices ); |
---|
| 163 | printk( "number_of_device_drivers = 0x%x\n", |
---|
| 164 | BSP_Configuration.number_of_device_drivers ); |
---|
| 165 | printk( "Device_driver_table = 0x%x\n", |
---|
| 166 | BSP_Configuration.Device_driver_table ); |
---|
[6128a4a] | 167 | |
---|
[3d6669cc] | 168 | /* printk( "_stack_size = 0x%x\n", _stack_size );*/ |
---|
| 169 | printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start ); |
---|
| 170 | printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size ); |
---|
| 171 | #endif |
---|
| 172 | } /* bsp_start */ |
---|
| 173 | |
---|
| 174 | /* |
---|
| 175 | * By making this a weak alias for bsp_start_default, a brave soul |
---|
| 176 | * can override the actual bsp_start routine used. |
---|
| 177 | */ |
---|
| 178 | |
---|
| 179 | void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); |
---|