1 | /*-------------------------------------------------------------------------+ |
---|
2 | | This file contains the ARM BSP startup package. It includes application, |
---|
3 | | board, and monitor specific initialization and configuration. The generic CPU |
---|
4 | | dependent initialization has been performed before this routine is invoked. |
---|
5 | +--------------------------------------------------------------------------+ |
---|
6 | | |
---|
7 | | Copyright (c) 2000 Canon Research Centre France SA. |
---|
8 | | Emmanuel Raguet, mailto:raguet@crf.canon.fr |
---|
9 | | |
---|
10 | | The license and distribution terms for this file may be |
---|
11 | | found in found in the file LICENSE in this distribution or at |
---|
12 | | http://www.OARcorp.com/rtems/license.html. |
---|
13 | | |
---|
14 | +--------------------------------------------------------------------------*/ |
---|
15 | |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <rtems/libcsupport.h> |
---|
19 | #include <rtems/libio.h> |
---|
20 | |
---|
21 | #include <uart.h> |
---|
22 | |
---|
23 | /*-------------------------------------------------------------------------+ |
---|
24 | | Global Variables |
---|
25 | +--------------------------------------------------------------------------*/ |
---|
26 | |
---|
27 | /* |
---|
28 | * must be initialized with the right address |
---|
29 | */ |
---|
30 | volatile unsigned long *Regs = (unsigned long*)0xdeadbeef; /* Chip registers */ |
---|
31 | |
---|
32 | extern rtems_unsigned32 _end; /* End of BSS. Defined in 'linkcmds'. */ |
---|
33 | /* |
---|
34 | * Size of heap if it is 0 it will be dynamically defined by memory size, |
---|
35 | * otherwise the value should be changed by binary patch |
---|
36 | */ |
---|
37 | rtems_unsigned32 _heap_size = 0; |
---|
38 | |
---|
39 | /* Size of stack used during initialization. Defined in 'start.s'. */ |
---|
40 | extern rtems_unsigned32 _stack_size; |
---|
41 | |
---|
42 | rtems_unsigned32 rtemsFreeMemStart; |
---|
43 | /* Address of start of free memory - should be updated |
---|
44 | after creating new partitions or regions. */ |
---|
45 | |
---|
46 | /* The original BSP configuration table from the application and our copy of it |
---|
47 | with some changes. */ |
---|
48 | |
---|
49 | extern rtems_configuration_table Configuration; |
---|
50 | rtems_configuration_table BSP_Configuration; |
---|
51 | |
---|
52 | rtems_cpu_table Cpu_table; /* CPU configuration table. */ |
---|
53 | char *rtems_progname; /* Program name - from main(). */ |
---|
54 | |
---|
55 | /*-------------------------------------------------------------------------+ |
---|
56 | | External Prototypes |
---|
57 | +--------------------------------------------------------------------------*/ |
---|
58 | extern void rtems_irq_mngt_init(void); |
---|
59 | void bsp_libc_init( void *, unsigned32, int ); |
---|
60 | void bsp_postdriver_hook(void); |
---|
61 | |
---|
62 | /*-------------------------------------------------------------------------+ |
---|
63 | | Function: bsp_pretasking_hook |
---|
64 | | Description: BSP pretasking hook. Called just before drivers are |
---|
65 | | initialized. Used to setup libc and install any BSP |
---|
66 | | extensions. NOTE: Must not use libc (to do io) from here, |
---|
67 | | since drivers are not yet initialized. |
---|
68 | | Global Variables: None. |
---|
69 | | Arguments: None. |
---|
70 | | Returns: Nothing. |
---|
71 | +--------------------------------------------------------------------------*/ |
---|
72 | void bsp_pretasking_hook(void) |
---|
73 | { |
---|
74 | |
---|
75 | if(_heap_size == 0) |
---|
76 | { |
---|
77 | _heap_size = 0x420000 - rtemsFreeMemStart; |
---|
78 | } |
---|
79 | |
---|
80 | bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0); |
---|
81 | |
---|
82 | rtemsFreeMemStart += _heap_size; /* HEAP_SIZE in KBytes */ |
---|
83 | |
---|
84 | |
---|
85 | #ifdef RTEMS_DEBUG |
---|
86 | |
---|
87 | rtems_debug_enable(RTEMS_DEBUG_ALL_MASK); |
---|
88 | |
---|
89 | #endif /* RTEMS_DEBUG */ |
---|
90 | |
---|
91 | } /* bsp_pretasking_hook */ |
---|
92 | |
---|
93 | |
---|
94 | /*-------------------------------------------------------------------------+ |
---|
95 | | Function: bsp_start |
---|
96 | | Description: Called before main is invoked. |
---|
97 | | Global Variables: None. |
---|
98 | | Arguments: None. |
---|
99 | | Returns: Nothing. |
---|
100 | +--------------------------------------------------------------------------*/ |
---|
101 | void bsp_start_default( void ) |
---|
102 | { |
---|
103 | rtemsFreeMemStart = (rtems_unsigned32)(&_end); /* &_end+_stack_size;*/ |
---|
104 | /* set the value of start of free memory. */ |
---|
105 | |
---|
106 | /* If we don't have command line arguments set default program name. */ |
---|
107 | |
---|
108 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
109 | Cpu_table.predriver_hook = NULL; /* use system's */ |
---|
110 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
111 | Cpu_table.idle_task = NULL; |
---|
112 | /* do not override system IDLE task */ |
---|
113 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
114 | Cpu_table.interrupt_stack_size = 4096; |
---|
115 | Cpu_table.extra_mpci_receive_server_stack = 0; |
---|
116 | |
---|
117 | /* Place RTEMS workspace at beginning of free memory. */ |
---|
118 | BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart; |
---|
119 | |
---|
120 | rtemsFreeMemStart += BSP_Configuration.work_space_size; |
---|
121 | |
---|
122 | /* |
---|
123 | * Init rtems exceptions management |
---|
124 | */ |
---|
125 | rtems_exception_init_mngt(); |
---|
126 | |
---|
127 | /* |
---|
128 | * Init rtems interrupt management |
---|
129 | */ |
---|
130 | rtems_irq_mngt_init(); |
---|
131 | |
---|
132 | /* |
---|
133 | * The following information is very useful when debugging. |
---|
134 | */ |
---|
135 | |
---|
136 | #if 0 |
---|
137 | printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size ); |
---|
138 | printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions ); |
---|
139 | printk( "microseconds_per_tick = 0x%x\n", |
---|
140 | BSP_Configuration.microseconds_per_tick ); |
---|
141 | printk( "ticks_per_timeslice = 0x%x\n", |
---|
142 | BSP_Configuration.ticks_per_timeslice ); |
---|
143 | printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices ); |
---|
144 | printk( "number_of_device_drivers = 0x%x\n", |
---|
145 | BSP_Configuration.number_of_device_drivers ); |
---|
146 | printk( "Device_driver_table = 0x%x\n", |
---|
147 | BSP_Configuration.Device_driver_table ); |
---|
148 | |
---|
149 | printk( "_heap_size = 0x%x\n", _heap_size ); |
---|
150 | /* printk( "_stack_size = 0x%x\n", _stack_size );*/ |
---|
151 | printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart ); |
---|
152 | printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start ); |
---|
153 | printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size ); |
---|
154 | #endif |
---|
155 | |
---|
156 | } /* bsp_start */ |
---|
157 | |
---|
158 | /* |
---|
159 | * By making this a weak alias for bsp_start_default, a brave soul |
---|
160 | * can override the actual bsp_start routine used. |
---|
161 | */ |
---|
162 | |
---|
163 | void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); |
---|