source: rtems/c/src/lib/libbsp/mips/genmongoosev/startup/bspstart.c @ cafa2c5

4.104.114.95
Last change on this file since cafa2c5 was cafa2c5, checked in by Joel Sherrill <joel.sherrill@…>, on 12/04/07 at 22:22:03

2007-12-04 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Move interrupt_stack_size field from CPU Table to Configuration Table. Eliminate CPU Table from all ports. Delete references to CPU Table in all forms.
  • Property mode set to 100644
File size: 4.5 KB
Line 
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-2001.
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 * Modification History:
17 *        12/10/01  A.Ferrer, NASA/GSFC, Code 582
18 *           Set interrupt mask to 0xAF00 (Line 139).
19 */
20
21#include <string.h>
22
23#include <bsp.h>
24#include <rtems/libio.h>
25#include <rtems/libcsupport.h>
26#include <libcpu/mongoose-v.h>
27
28/*
29 *  The original table from the application and our copy of it with
30 *  some changes.
31 */
32
33extern rtems_configuration_table Configuration;
34rtems_configuration_table  BSP_Configuration;
35char *rtems_progname;
36
37/*
38 *  Use the shared implementations of the following routines
39 */
40
41void bsp_postdriver_hook(void);
42void bsp_libc_init( void *, uint32_t, int );
43
44/*
45 *  Function:   bsp_pretasking_hook
46 *  Created:    95/03/10
47 *
48 *  Description:
49 *      BSP pretasking hook.  Called just before drivers are initialized.
50 *      Used to setup libc and install any BSP extensions.
51 *
52 *  NOTES:
53 *      Must not use libc (to do io) from here, since drivers are
54 *      not yet initialized.
55 *
56 */
57
58void bsp_pretasking_hook(void)
59{
60    extern int HeapBase;
61    extern int HeapSize;
62    void         *heapStart = &HeapBase;
63    unsigned long heapSize = (unsigned long)&HeapSize;
64
65    bsp_libc_init(heapStart, (uint32_t) heapSize, 0);
66
67#ifdef RTEMS_DEBUG
68    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
69#endif
70
71}
72
73/*
74 *  bsp_start
75 *
76 *  This routine does the bulk of the system initialization.
77 */
78
79void bsp_start( void )
80{
81   extern void _sys_exit(int);
82   extern int WorkspaceBase;
83   extern void mips_install_isr_entries();
84   extern void mips_gdb_stub_install(void);
85
86   /* HACK -- tied to value linkcmds */
87   if ( BSP_Configuration.work_space_size > (4096*1024) )
88      _sys_exit( 1 );
89
90   BSP_Configuration.work_space_start = (void *) &WorkspaceBase;
91
92   /* mask off any interrupts */
93   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
94
95   /* reset the config register & clear any pending peripheral interrupts */
96   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
97   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
98   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
99
100   /* reset both timers */
101   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
102   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
103
104   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
105   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
106
107   /* clear any pending interrupts */
108   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
109
110   /* clear any writable bits in the cause register */
111   mips_set_cause( 0 );
112
113   /* set interrupt mask, but globally off. */
114
115   /*
116   **  Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit  9 | Bit  8 |
117   **  periph | unused |  FPU   | unused | timer2 | timer1 | swint1 | swint2 |
118   **  extern |        |        |        |        |        |        |        |
119   **
120   **    1        0        1        0        0        1        0        0
121   **
122   **    0x8C00   Enable only internal Mongoose V timers.
123   **    0xA400   Enable Peripherial ints, FPU and timer1
124   **    0x0400   Timer1 only
125   */
126
127   /* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
128
129   /* to start up, only enable coprocessor 0 & timer int. per-task
130   ** processor settings will be applied as they are created, this
131   ** is just to configure the processor for startup
132   */
133   mips_set_sr( (SR_CU0 | 0x400) );
134
135   mips_install_isr_entries();
136}
137
138void clear_cache( void )
139{
140   extern void promCopyIcacheFlush(void);       /* from start.S */
141   extern void promCopyDcacheFlush(void);
142
143   promCopyIcacheFlush();
144   promCopyDcacheFlush();
145}
146
147#if 0
148
149/* Structure filled in by get_mem_info. */
150
151struct s_mem
152{
153  unsigned int size;
154  unsigned int icsize;
155  unsigned int dcsize;
156};
157
158extern uint32_t   _RamSize;
159
160void get_mem_info ( struct s_mem *mem )
161{
162   mem->size = (uint32_t)&_RamSize;
163   mem->icsize = MONGOOSEV_IC_SIZE;
164   mem->dcsize = MONGOOSEV_DC_SIZE;
165}
166
167#endif
Note: See TracBrowser for help on using the repository browser.