1 | /* |
---|
2 | * Cirrus EP7312 Startup code |
---|
3 | * |
---|
4 | * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
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 | /*************************************************************/ |
---|
42 | /* Function prototypes */ |
---|
43 | /*************************************************************/ |
---|
44 | extern void rtems_irq_mngt_init(void); |
---|
45 | void bsp_libc_init( void *, uint32_t, int ); |
---|
46 | |
---|
47 | /**************************************************************************/ |
---|
48 | /* */ |
---|
49 | /* NAME: bps_pretasking_hook - Function to setup system before startup */ |
---|
50 | /* */ |
---|
51 | /* DESCRIPTION: */ |
---|
52 | /* This function is called before drivers are initialized and used */ |
---|
53 | /* to setup libc and BSP extensions. It configures non cacheable */ |
---|
54 | /* SDRAM, SRAM, AIM, and ADM regions and sets up the CPU's memory */ |
---|
55 | /* protection unit. */ |
---|
56 | /* */ |
---|
57 | /* GLOBALS USED: */ |
---|
58 | /* free_mem_start */ |
---|
59 | /* free_mem_end */ |
---|
60 | /* */ |
---|
61 | /* RESTRICTIONS/LIMITATIONS: */ |
---|
62 | /* Since this function is setting up libc, it cannot use and libc */ |
---|
63 | /* functions. */ |
---|
64 | /* */ |
---|
65 | /**************************************************************************/ |
---|
66 | void bsp_pretasking_hook(void) |
---|
67 | { |
---|
68 | uint32_t heap_start; |
---|
69 | uint32_t heap_size; |
---|
70 | |
---|
71 | /* |
---|
72 | * Set up the heap. It uses all free SDRAM except that reserved |
---|
73 | * for non-cached uses. |
---|
74 | */ |
---|
75 | heap_start = free_mem_start; |
---|
76 | |
---|
77 | /* heap_size = (free_mem_end - heap_start - MEM_NOCACHE_SIZE); */ |
---|
78 | heap_size = 0x200000; |
---|
79 | |
---|
80 | bsp_libc_init((void *)heap_start, heap_size, 0); |
---|
81 | |
---|
82 | } /* bsp_pretasking_hook */ |
---|
83 | |
---|
84 | /**************************************************************************/ |
---|
85 | /* */ |
---|
86 | /* NAME: bsp_start_default - BSP initialization function */ |
---|
87 | /* */ |
---|
88 | /* DESCRIPTION: */ |
---|
89 | /* This function is called before RTEMS is initialized and used */ |
---|
90 | /* adjust the kernel's configuration. */ |
---|
91 | /* */ |
---|
92 | /* This function also configures the CPU's memory protection unit. */ |
---|
93 | /* */ |
---|
94 | /* GLOBALS USED: */ |
---|
95 | /* CPU_table */ |
---|
96 | /* Configuration */ |
---|
97 | /* free_mem_start */ |
---|
98 | /* free_mem_end */ |
---|
99 | /* free_mem_nocache_start */ |
---|
100 | /* _bss_free_start */ |
---|
101 | /* mpu_region_tbl */ |
---|
102 | /* */ |
---|
103 | /* */ |
---|
104 | /* */ |
---|
105 | /* */ |
---|
106 | /* RESTRICTIONS/LIMITATIONS: */ |
---|
107 | /* Since RTEMS is not configured, no RTEMS functions can be called. */ |
---|
108 | /* */ |
---|
109 | /**************************************************************************/ |
---|
110 | void bsp_start_default( void ) |
---|
111 | { |
---|
112 | /* disable interrupts */ |
---|
113 | *EP7312_INTMR1 = 0; |
---|
114 | *EP7312_INTMR2 = 0; |
---|
115 | |
---|
116 | /* Place RTEMS workspace at beginning of free memory. */ |
---|
117 | Configuration.work_space_start = (void *)&_bss_free_start; |
---|
118 | |
---|
119 | free_mem_start = ((uint32_t)&_bss_free_start + |
---|
120 | rtems_configuration_get_work_space_size()); |
---|
121 | |
---|
122 | free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size); |
---|
123 | |
---|
124 | /* |
---|
125 | * Init rtems exceptions management |
---|
126 | */ |
---|
127 | rtems_exception_init_mngt(); |
---|
128 | |
---|
129 | /* |
---|
130 | * Init rtems interrupt management |
---|
131 | */ |
---|
132 | rtems_irq_mngt_init(); |
---|
133 | |
---|
134 | /* |
---|
135 | * The following information is very useful when debugging. |
---|
136 | */ |
---|
137 | #if 0 |
---|
138 | printk( "work_space_size = 0x%x\n", |
---|
139 | rtems_configuration_get_work_space_size() ); |
---|
140 | printk( "microseconds_per_tick = 0x%x\n", |
---|
141 | rtems_configuration_get_microseconds_per_tick() ); |
---|
142 | printk( "ticks_per_timeslice = 0x%x\n", |
---|
143 | rtems_configuration_get_ticks_per_timeslice() ); |
---|
144 | |
---|
145 | /* printk( "_stack_size = 0x%x\n", _stack_size );*/ |
---|
146 | printk( "work_space_start = 0x%x\n", Configuration.work_space_start ); |
---|
147 | printk( "work_space_size = 0x%x\n", rtems_configuration_get_work_space_size() ); |
---|
148 | #endif |
---|
149 | } /* bsp_start */ |
---|
150 | |
---|
151 | /* |
---|
152 | * By making this a weak alias for bsp_start_default, a brave soul |
---|
153 | * can override the actual bsp_start routine used. |
---|
154 | */ |
---|
155 | |
---|
156 | void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); |
---|