source: rtems/c/src/lib/libbsp/m68k/mvme147s/startup/bspstart.c @ c244a9ee

4.104.114.84.95
Last change on this file since c244a9ee was c244a9ee, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 21:32:12

Stack checker extension now accounted for in confdefs.h

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[afe99c2]1/*  bsp_start()
2 *
3 *  This routine starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before this routine is invoked.
7 *
8 *  INPUT:  NONE
9 *
10 *  OUTPUT: NONE
11 *
[60b791ad]12 *  COPYRIGHT (c) 1989-1998.
[afe99c2]13 *  On-Line Applications Research Corporation (OAR).
[03f2154e]14 *  Copyright assigned to U.S. Government, 1994.
[afe99c2]15 *
[98e4ebf5]16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
[03f2154e]18 *  http://www.OARcorp.com/rtems/license.html.
[afe99c2]19 *
20 *  MVME147 port for TNI - Telecom Bretagne
21 *  by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr)
22 *  May 1996
23 *
24 *  $Id$
25 */
26
27#include <bsp.h>
28#include <rtems/libio.h>
29
30#include <libcsupport.h>
31
32#include <string.h>
33
34#ifdef STACK_CHECKER_ON
35#include <stackchk.h>
36#endif
37
38/*
39 *  The original table from the application and our copy of it with
40 *  some changes.
41 */
42
43extern rtems_configuration_table  Configuration;
44rtems_configuration_table         BSP_Configuration;
45
46rtems_cpu_table Cpu_table;
47
48char *rtems_progname;
49
50/*      Initialize whatever libc we are using
51 *      called from postdriver hook
52 */
53
54void bsp_libc_init()
55{
56    extern int end;
57    rtems_unsigned32        heap_start;
58
59    heap_start = (rtems_unsigned32) &end;
60    if (heap_start & (CPU_ALIGNMENT-1))
61        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
62
63    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
64
65    /*
66     *  Init the RTEMS libio facility to provide UNIX-like system
[634e746]67     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
[afe99c2]68     *  Uses malloc() to get area for the iops, so must be after malloc init
69     */
70
71    rtems_libio_init();
72
73    /*
74     * Set up for the libc handling.
75     */
76
77    if (BSP_Configuration.ticks_per_timeslice > 0)
78        libc_init(1);                /* reentrant if possible */
79    else
80        libc_init(0);                /* non-reentrant */
81}
82
83/*
84 *  Function:   bsp_pretasking_hook
85 *  Created:    95/03/10
86 *
87 *  Description:
88 *      BSP pretasking hook.  Called just before drivers are initialized.
89 *      Used to setup libc and install any BSP extensions.
90 *
91 *  NOTES:
92 *      Must not use libc (to do io) from here, since drivers are
93 *      not yet initialized.
94 *
95 */
96 
97void
98bsp_pretasking_hook(void)
99{
100    bsp_libc_init();
101 
102#ifdef STACK_CHECKER_ON
103    /*
104     *  Initialize the stack bounds checker
105     *  We can either turn it on here or from the app.
106     */
107 
108    Stack_check_Initialize();
109#endif
110 
111#ifdef RTEMS_DEBUG
112    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
113#endif
114}
115 
116
117/*
[8f95b5f]118 *  Use the shared bsp_postdriver_hook() implementation
[afe99c2]119 */
120 
[8f95b5f]121void bsp_postdriver_hook(void);
122
[afe99c2]123
[e2a2ec60]124void bsp_start( void )
[afe99c2]125{
126  m68k_isr_entry *monitors_vector_table;
127  int             index;
128  rtems_unsigned8 node_number;
129
130  monitors_vector_table = (m68k_isr_entry *)0;   /* 147Bug Vectors are at 0 */
131  m68k_set_vbr( monitors_vector_table );
132
133  for ( index=2 ; index<=255 ; index++ )
134    M68Kvec[ index ] = monitors_vector_table[ 32 ];
135
136  M68Kvec[  2 ] = monitors_vector_table[  2 ];   /* bus error vector */
137  M68Kvec[  4 ] = monitors_vector_table[  4 ];   /* breakpoints vector */
138  M68Kvec[  9 ] = monitors_vector_table[  9 ];   /* trace vector */
139  M68Kvec[ 47 ] = monitors_vector_table[ 47 ];   /* system call vector */
140
141  m68k_set_vbr( &M68Kvec );
142
143  pcc->int_base_vector = PCC_BASE_VECTOR & 0xF0;
144  /* Set the PCC int vectors base */
145 
146  /* VME shared memory configuration */
147  /* Only the first node shares its top 128k DRAM */
148
149  vme_lcsr->utility_interrupt_vector = VME_BASE_VECTOR & 0xF8;
150  /* Set VMEchip base interrupt vector */
151  vme_lcsr->utility_interrupt_mask |= 0x02;
152  /* Enable SIGLP interruption (see shm support) */
153  pcc->general_purpose_control &= 0x10;
154  /* Enable VME master interruptions */
155 
156  if (vme_lcsr->system_controller & 0x01) {
157    /* the board is system controller */
158    vme_lcsr->system_controller = 0x08;
159    /* Make VME access round-robin */
160  }
161
162 
163  node_number =
164    (rtems_unsigned8)
165    (Configuration.User_multiprocessing_table->node - 1) & 0xF;
166  /* Get and store node ID, first node_number = 0 */
167  vme_gcsr->board_identification = node_number;
168
169  vme_lcsr->gcsr_base_address = node_number;
170  /* Setup the base address of this board's gcsr */
171  vme_lcsr->timer_configuration = 0x6a;
172  /* Enable VME time outs, maximum periods */
173
174  if (node_number == 0) {
175    pcc->slave_base_address = 0x01;
176    /* Set local DRAM base address on the VME bus to the DRAM size */
177
178    vme_lcsr->vme_bus_requester = 0x80;
179    while (! (vme_lcsr->vme_bus_requester & 0x40));
180    /* Get VMEbus mastership */
181    vme_lcsr->slave_address_modifier = 0xfb;
182    /* Share everything */
183    vme_lcsr->slave_configuration = 0x80;
184    /* Share local DRAM */
185    vme_lcsr->vme_bus_requester = 0x0;
186    /* release bus */
187  } else {
188    pcc->slave_base_address = 0;
189    /* Set local DRAM base address on the VME bus to 0 */
190
191    vme_lcsr->vme_bus_requester = 0x80;
192    while (! (vme_lcsr->vme_bus_requester & 0x40));
193    /* Get VMEbus mastership */
194    vme_lcsr->slave_address_modifier = 0x08;
195    /* Share only the short adress range */
196    vme_lcsr->slave_configuration = 0;
197    /* Don't share local DRAM */
198    vme_lcsr->vme_bus_requester = 0x0;
199    /* release bus */
200  }
201
202  vme_lcsr->master_address_modifier = 0;
203  /* Automatically set the address modifier */
204  vme_lcsr->master_configuration = 1;
205  /* Disable D32 transfers : they don't work on my VMEbus rack */
206
207  m68k_enable_caching();
208
209  /*
210   *  we only use a hook to get the C library initialized.
211   */
212
213  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
214
215  Cpu_table.predriver_hook = NULL;
216
217  Cpu_table.postdriver_hook = bsp_postdriver_hook;
218
219  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
220
221  Cpu_table.do_zero_of_workspace = TRUE;
222
223  Cpu_table.interrupt_vector_table = (m68k_isr_entry *) &M68Kvec;
224
225  Cpu_table.interrupt_stack_size = 4096;
226
227  Cpu_table.extra_mpci_receive_server_stack = 0;
228
229  /*
230   *  Copy the table
231   */
232
233  BSP_Configuration = Configuration;
234
235  BSP_Configuration.work_space_start = (void *)
236     (RAM_END - BSP_Configuration.work_space_size);
237
238  /*
239   * Tell libio how many fd's we want and allow it to tweak config
240   */
241
242  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
243}
Note: See TracBrowser for help on using the repository browser.