1 |
30 |
unneback |
/* bspstart.c
|
2 |
|
|
*
|
3 |
|
|
* This set of routines starts the application. It includes application,
|
4 |
|
|
* board, and monitor specific initialization and configuration. The generic
|
5 |
|
|
* CPU dependent initialization has been performed before any of these are
|
6 |
|
|
* invoked.
|
7 |
|
|
*
|
8 |
|
|
* COPYRIGHT (c) 1989-1999.
|
9 |
|
|
* On-Line Applications Research Corporation (OAR).
|
10 |
|
|
*
|
11 |
|
|
* The license and distribution terms for this file may be
|
12 |
|
|
* found in the file LICENSE in this distribution or at
|
13 |
|
|
* http://www.OARcorp.com/rtems/license.html.
|
14 |
|
|
*
|
15 |
|
|
* Modifications of respective RTEMS files:
|
16 |
|
|
* Copyright (c) 1998, National Research Council of Canada
|
17 |
|
|
*
|
18 |
|
|
* $Id: bspstart.c,v 1.2 2001-09-27 12:00:20 chris Exp $
|
19 |
|
|
*/
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
#include <bsp.h>
|
23 |
|
|
#include <page_table.h>
|
24 |
|
|
#include <fatal.h>
|
25 |
|
|
#include <rtems/libio.h>
|
26 |
|
|
|
27 |
|
|
#include <libcsupport.h>
|
28 |
|
|
|
29 |
|
|
#include <string.h>
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/*
|
33 |
|
|
* The original table from the application (in ROM) and our copy of it with
|
34 |
|
|
* some changes. Configuration is defined in <confdefs.h>. Make sure that
|
35 |
|
|
* our configuration tables are uninitialized so that they get allocated in
|
36 |
|
|
* the .bss section (RAM).
|
37 |
|
|
*/
|
38 |
|
|
extern rtems_configuration_table Configuration;
|
39 |
|
|
rtems_configuration_table BSP_Configuration;
|
40 |
|
|
rtems_extensions_table user_extension_table;
|
41 |
|
|
|
42 |
|
|
rtems_cpu_table Cpu_table;
|
43 |
|
|
|
44 |
|
|
/*
|
45 |
|
|
* Use the shared implementations of the following routines.
|
46 |
|
|
* Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
|
47 |
|
|
* rtems/c/src/lib/libbsp/shared/bsplibc.c.
|
48 |
|
|
*/
|
49 |
|
|
void bsp_postdriver_hook( void );
|
50 |
|
|
void bsp_libc_init( void *, unsigned32, int );
|
51 |
|
|
void bsp_pretasking_hook(void); /* m68k version */
|
52 |
|
|
|
53 |
|
|
/*
|
54 |
|
|
* bsp_start()
|
55 |
|
|
*
|
56 |
|
|
* Board-specific initialization code. Called from the generic boot_card()
|
57 |
|
|
* function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
|
58 |
|
|
* does some of the board independent initialization. It is called from the
|
59 |
|
|
* generic MC680x0 entry point _start() defined in
|
60 |
|
|
* rtems/c/src/lib/start/m68k/start.s
|
61 |
|
|
*
|
62 |
|
|
* _start() has set up a stack, has zeroed the .bss section, has turned off
|
63 |
|
|
* interrupts, and placed the processor in the supervisor mode. boot_card()
|
64 |
|
|
* has left the processor in that state when bsp_start() was called.
|
65 |
|
|
*
|
66 |
|
|
* RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
|
67 |
|
|
* ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
|
68 |
|
|
* ADDRESSES. Software-controlled address translation would be required
|
69 |
|
|
* otherwise.
|
70 |
|
|
*
|
71 |
|
|
* ASSUMES THAT 167BUG IS PRESENT TO CATCH ANY EXCEPTIONS DURING
|
72 |
|
|
* INITIALIZATION.
|
73 |
|
|
*
|
74 |
|
|
* Input parameters: NONE
|
75 |
|
|
*
|
76 |
|
|
* Output parameters: NONE
|
77 |
|
|
*
|
78 |
|
|
* Return values: NONE
|
79 |
|
|
*/
|
80 |
|
|
void bsp_start( void )
|
81 |
|
|
{
|
82 |
|
|
void M68KFPSPInstallExceptionHandlers (void);
|
83 |
|
|
|
84 |
|
|
extern m68k_isr_entry M68Kvec[];
|
85 |
|
|
extern void *_WorkspaceBase;
|
86 |
|
|
extern void *_RamSize;
|
87 |
|
|
extern unsigned long _M68k_Ramsize;
|
88 |
|
|
|
89 |
|
|
m68k_isr_entry *rom_monitor_vector_table;
|
90 |
|
|
int index;
|
91 |
|
|
|
92 |
|
|
_M68k_Ramsize = (unsigned long)&_RamSize; /* RAM size set in linker script */
|
93 |
|
|
|
94 |
|
|
/*
|
95 |
|
|
* 167Bug Vectors are at 0xFFE00000
|
96 |
|
|
*/
|
97 |
|
|
rom_monitor_vector_table = (m68k_isr_entry *)0xFFE00000;
|
98 |
|
|
m68k_set_vbr( rom_monitor_vector_table );
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
/*
|
102 |
|
|
* Copy 167Bug Bus Error handler into our exception vector. All 167Bug
|
103 |
|
|
* exception vectors are the same and point to the generalized exception
|
104 |
|
|
* handler. The bus error handler is the one that Motorola says to copy
|
105 |
|
|
* (p. 2-13, Debugging Package for Motorola 68K CISC CPUs User's Manual
|
106 |
|
|
* 68KBUG/D1A3, October 1993).
|
107 |
|
|
*/
|
108 |
|
|
for ( index=2 ; index<=255 ; index++ )
|
109 |
|
|
M68Kvec[ index ] = rom_monitor_vector_table[ 2 ];
|
110 |
|
|
|
111 |
|
|
/* Any exceptions during initialization should be trapped by 167Bug */
|
112 |
|
|
m68k_set_vbr( &M68Kvec );
|
113 |
|
|
|
114 |
|
|
/* Install the 68040 FPSP here */
|
115 |
|
|
M68KFPSPInstallExceptionHandlers();
|
116 |
|
|
|
117 |
|
|
/*
|
118 |
|
|
* You may wish to make the VME arbitration round-robin here, currently
|
119 |
|
|
* we leave it as it is.
|
120 |
|
|
*/
|
121 |
|
|
|
122 |
|
|
/* Set the Interrupt Base Vectors */
|
123 |
|
|
lcsr->vector_base = (VBR0 << 28) | (VBR1 << 24);
|
124 |
|
|
|
125 |
|
|
/*
|
126 |
|
|
* Initialize address translation
|
127 |
|
|
* May need to pass the multiprocessor configuration table.
|
128 |
|
|
*/
|
129 |
|
|
page_table_init( &Configuration );
|
130 |
|
|
|
131 |
|
|
/* We only use a hook to get the C library initialized. */
|
132 |
|
|
Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
|
133 |
|
|
Cpu_table.postdriver_hook = bsp_postdriver_hook;
|
134 |
|
|
Cpu_table.interrupt_vector_table = (m68k_isr_entry *) &M68Kvec;
|
135 |
|
|
/* Must match value in start.s */
|
136 |
|
|
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* If the application has not overriden the default User_extension_table,
|
140 |
|
|
* supply one with our own fatal error handler that returns control to
|
141 |
|
|
* 167Bug.
|
142 |
|
|
*/
|
143 |
|
|
if ( BSP_Configuration.User_extension_table == NULL ) {
|
144 |
|
|
user_extension_table.fatal = bsp_fatal_error_occurred;
|
145 |
|
|
BSP_Configuration.User_extension_table = &user_extension_table;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
/*
|
149 |
|
|
* Need to "allocate" the memory for the RTEMS Workspace and
|
150 |
|
|
* tell the RTEMS configuration where it is. This memory is
|
151 |
|
|
* not malloc'ed. It is just "pulled from the air".
|
152 |
|
|
*/
|
153 |
|
|
BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
|
154 |
|
|
}
|