source: rtems/c/src/lib/libbsp/m68k/mvme167/startup/bspstart.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 6.8 KB
Line 
1/*  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$
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 */
38extern rtems_configuration_table Configuration;
39rtems_configuration_table BSP_Configuration;
40rtems_extensions_table user_extension_table;
41
42rtems_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 */
49void bsp_postdriver_hook( void );
50void bsp_libc_init( void *, unsigned32, int );
51
52
53/*
54 *  bsp_pretasking_hook
55 *
56 *  Called when RTEMS initialization is complete but before interrupts and
57 *  tasking are enabled. Used to setup libc and install any BSP extensions.
58 *
59 *  Must not use libc (to do io) from here, since drivers are not yet
60 *  initialized.
61 *
62 *  Installed in the rtems_cpu_table defined in
63 *  rtems/c/src/exec/score/cpu/m68k/cpu.h in main() below. Called from
64 *  rtems_initialize_executive() defined in rtems/c/src/exec/sapi/src/init.c
65 *
66 *  Input parameters: NONE
67 *
68 *  Output parameters: NONE
69 *
70 *  Return values: NONE
71 */
72void bsp_pretasking_hook( void )
73{   
74  /*
75   *  These are assigned addresses in the linkcmds file for the BSP. This
76   *  approach is better than having these defined as manifest constants and
77   *  compiled into the kernel, but it is still not ideal when dealing with
78   *  multiprocessor configuration in which each board as a different memory
79   *  map. A better place for defining these symbols might be the makefiles.
80   *  Consideration should also be given to developing an approach in which
81   *  the kernel and the application can be linked and burned into ROM
82   *  independently of each other.
83   */
84  extern unsigned char _HeapStart, _HeapEnd;
85
86  bsp_libc_init(&_HeapStart, &_HeapEnd - &_HeapStart, 0);
87
88#ifdef RTEMS_DEBUG
89    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
90#endif
91}
92
93
94/*
95 *  bsp_start()
96 *
97 *  Board-specific initialization code. Called from the generic boot_card()
98 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
99 *  does some of the board independent initialization. It is called from the
100 *  generic MC680x0 entry point _start() defined in
101 *  rtems/c/src/lib/start/m68k/start.s
102 *
103 *  _start() has set up a stack, has zeroed the .bss section, has turned off
104 *  interrupts, and placed the processor in the supervisor mode. boot_card()
105 *  has left the processor in that state when bsp_start() was called.
106 *
107 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
108 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
109 *  ADDRESSES. Software-controlled address translation would be required
110 *  otherwise.
111 *
112 *  ASSUMES THAT 167BUG IS PRESENT TO CATCH ANY EXCEPTIONS DURING
113 *  INITIALIZATION.
114 *
115 *  Input parameters: NONE
116 *
117 *  Output parameters: NONE
118 *
119 *  Return values: NONE
120 */
121void bsp_start( void )
122{
123  extern void *_WorkspaceBase;
124  extern m68k_isr_entry M68Kvec[];
125 
126  void M68KFPSPInstallExceptionHandlers (void);
127 
128  m68k_isr_entry *rom_monitor_vector_table;
129  int index;
130
131  /*
132   *  167Bug Vectors are at 0xFFE00000
133   */
134  rom_monitor_vector_table = (m68k_isr_entry *)0xFFE00000;
135  m68k_set_vbr( rom_monitor_vector_table );
136
137
138  /*
139   *  Copy 167Bug Bus Error handler into our exception vector. All 167Bug
140   *  exception vectors are the same and point to the generalized exception
141   *  handler. The bus error handler is the one that Motorola says to copy
142   *  (p. 2-13, Debugging Package for Motorola 68K CISC CPUs User's Manual
143   *  68KBUG/D1A3, October 1993).
144   */
145  for ( index=2 ; index<=255 ; index++ )
146    M68Kvec[ index ] = rom_monitor_vector_table[ 2 ];
147
148  /* Any exceptions during initialization should be trapped by 167Bug */
149  m68k_set_vbr( &M68Kvec );
150 
151  /* Install the 68040 FPSP here */
152  M68KFPSPInstallExceptionHandlers();
153
154  /*
155   *  You may wish to make the VME arbitration round-robin here, currently
156   *  we leave it as it is.
157   */
158
159  /* Set the Interrupt Base Vectors */
160  lcsr->vector_base = (VBR0 << 28) | (VBR1 << 24);
161
162  /*
163   *  Initialize address translation
164   *  May need to pass the multiprocessor configuration table.
165   */
166  page_table_init( &Configuration );
167
168  /* We only use a hook to get the C library initialized. */
169  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
170  Cpu_table.postdriver_hook = bsp_postdriver_hook;
171  Cpu_table.interrupt_vector_table = (m68k_isr_entry *) &M68Kvec;
172  Cpu_table.interrupt_stack_size = 4096; /* Must match value in start.s */
173 
174  /*
175   *  If the application has not overriden the default User_extension_table,
176   *  supply one with our own fatal error handler that returns control to
177   *  167Bug.
178   */
179  if ( BSP_Configuration.User_extension_table == NULL ) {
180    user_extension_table.fatal = bsp_fatal_error_occurred;
181    BSP_Configuration.User_extension_table = &user_extension_table;
182  }
183 
184  /*
185   *  Need to "allocate" the memory for the RTEMS Workspace and
186   *  tell the RTEMS configuration where it is.  This memory is
187   *  not malloc'ed.  It is just "pulled from the air".
188   */
189  BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
190
191  /*
192   *  Increase the number of semaphores that can be created on this node. The
193   *  termios package requires one semaphore to protect the list of termios-
194   *  capable terminals, and up to four semaphores per termios-capable
195   *  terminal (add calls here as required). The maximum number of semaphores
196   *  must be set before returning to boot_card(), which will call
197   *  rtems_initialize_executive_early(). This latter function eventually
198   *  calls _RTEMS_API_Initialize(), which in turn calls
199   *  _Semaphore_Manager_initialization(), which allocates the space for the
200   *  maximum number of semaphores in the object table. These calls occur
201   *  before the call to the predriver hook and the calls to the device
202   *  initialization callbacks. Hence, we must do this here.
203   */
204  console_reserve_resources( &BSP_Configuration );
205}
Note: See TracBrowser for help on using the repository browser.