1 | /* |
---|
2 | * This routine starts the application. It includes application, |
---|
3 | * board, and monitor specific initialization and configuration. |
---|
4 | * The generic CPU dependent initialization has been performed |
---|
5 | * before this routine is invoked. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-1999. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <string.h> |
---|
18 | |
---|
19 | #include <bsp.h> |
---|
20 | #include <rtems/libio.h> |
---|
21 | #include <rtems/libcsupport.h> |
---|
22 | |
---|
23 | uint32_t bsp_clicks_per_microsecond; |
---|
24 | |
---|
25 | /* |
---|
26 | * Use the shared implementations of the following routines |
---|
27 | */ |
---|
28 | |
---|
29 | void bsp_libc_init( void *, uint32_t, int ); |
---|
30 | |
---|
31 | void init_exc_vecs(void); |
---|
32 | |
---|
33 | /* |
---|
34 | * Function: bsp_pretasking_hook |
---|
35 | * Created: 95/03/10 |
---|
36 | * |
---|
37 | * Description: |
---|
38 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
39 | * Used to setup libc and install any BSP extensions. |
---|
40 | * |
---|
41 | * NOTES: |
---|
42 | * Must not use libc (to do io) from here, since drivers are |
---|
43 | * not yet initialized. |
---|
44 | * |
---|
45 | */ |
---|
46 | |
---|
47 | #define LIBC_HEAP_SIZE (64 * 1024) |
---|
48 | |
---|
49 | void bsp_pretasking_hook(void) |
---|
50 | { |
---|
51 | extern int end; |
---|
52 | uint32_t heap_start; |
---|
53 | |
---|
54 | heap_start = (uint32_t) &end; |
---|
55 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
56 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
57 | |
---|
58 | bsp_libc_init((void *) heap_start, LIBC_HEAP_SIZE, 0); |
---|
59 | } |
---|
60 | |
---|
61 | extern int end; /* defined by linker */ |
---|
62 | |
---|
63 | /* |
---|
64 | * bsp_start |
---|
65 | * |
---|
66 | * This routine does the bulk of the system initialization. |
---|
67 | */ |
---|
68 | |
---|
69 | void bsp_start( void ) |
---|
70 | { |
---|
71 | /* |
---|
72 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
73 | * a variety of places: hard coded address, malloc'ed from outside |
---|
74 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
75 | * typically done by stock BSPs) by subtracting the required amount |
---|
76 | * of work space from the last physical address on the CPU board. |
---|
77 | */ |
---|
78 | |
---|
79 | /* |
---|
80 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
81 | * tell the RTEMS configuration where it is. This memory is |
---|
82 | * not malloc'ed. It is just "pulled from the air". |
---|
83 | */ |
---|
84 | |
---|
85 | Configuration.work_space_start = |
---|
86 | (void *)((uint64_t)((&end) + LIBC_HEAP_SIZE + 0x2000) & ~0x7); |
---|
87 | |
---|
88 | bsp_clicks_per_microsecond = CPU_CLOCK_RATE_MHZ; |
---|
89 | |
---|
90 | mips_install_isr_entries(); /* Install generic MIPS exception handler */ |
---|
91 | } |
---|