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

4.104.114.84.95
Last change on this file since d88661c was d88661c, checked in by Joel Sherrill <joel.sherrill@…>, on 02/08/02 at 23:05:35

2002-02-08 Joel Sherrill <joel@…>

  • startup/Makefile.am: Now compile the gdb stub.
  • startup/bspstart.c: Fixed header block.
  • startup/gdb-support.c: New file in stub state.
  • Property mode set to 100644
File size: 4.3 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.OARcorp.com/rtems/license.html.
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
30/*
31 *  The original table from the application and our copy of it with
32 *  some changes.
33 */
34
35extern rtems_configuration_table Configuration;
36
37rtems_configuration_table  BSP_Configuration;
38
39rtems_cpu_table Cpu_table;
40
41char *rtems_progname;
42
43/*
44 *  Use the shared implementations of the following routines
45 */
46
47void bsp_postdriver_hook(void);
48void bsp_libc_init( void *, unsigned32, int );
49
50/*
51 *  Function:   bsp_pretasking_hook
52 *  Created:    95/03/10
53 *
54 *  Description:
55 *      BSP pretasking hook.  Called just before drivers are initialized.
56 *      Used to setup libc and install any BSP extensions.
57 *
58 *  NOTES:
59 *      Must not use libc (to do io) from here, since drivers are
60 *      not yet initialized.
61 *
62 */
63
64void bsp_pretasking_hook(void)
65{
66    extern int HeapBase;
67    extern int HeapSize;
68    void         *heapStart = &HeapBase;
69    unsigned long heapSize = (unsigned long)&HeapSize;
70    unsigned long ramSpace;
71
72    bsp_libc_init(heapStart, (unsigned32) heapSize, 0);
73
74#ifdef RTEMS_DEBUG
75    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
76#endif
77
78}
79
80
81
82/*
83 *  bsp_start
84 *
85 *  This routine does the bulk of the system initialization.
86 */
87
88void bsp_start( void )
89{
90  extern int WorkspaceBase;
91  extern void mips_install_isr_entries();
92
93  /* Configure Number of Register Caches */
94
95  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
96  Cpu_table.postdriver_hook = bsp_postdriver_hook;
97  Cpu_table.interrupt_stack_size = 4096;
98
99  /* HACK -- tied to value linkcmds */
100  if ( BSP_Configuration.work_space_size > (4096*1024) )
101     _sys_exit( 1 );
102
103  BSP_Configuration.work_space_start = (void *) &WorkspaceBase;
104
105  /* mask off any interrupts */
106  MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
107
108  MONGOOSEV_WRITE( MONGOOSEV_WATCHDOG, 0xA0 );
109
110  /* reset the config register & clear any pending peripheral interrupts */
111  MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
112  MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
113  MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
114
115  /* reset both timers */
116  MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
117  MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
118
119  MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
120  MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
121
122  /* clear any pending interrupts */
123  MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
124
125  /* clear any writable bits in the cause register */
126  mips_set_cause( 0 );
127
128  /* set interrupt mask, but globally off. */
129
130  /*
131  **  Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit  9 | Bit  8 |
132  **  periph | unused |  FPU   | unused | timer2 | timer1 | swint1 | swint2 |
133  **  extern |        |        |        |        |        |        |        |
134  **
135  **    1        0        1        0        0        1        0        0
136  **
137  **    0x8C00   Enable only internal Mongoose V timers.
138  **    0xA400   Enable Peripherial ints, FPU and timer1
139  */
140
141  mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) );
142
143  mips_install_isr_entries();
144}
145
146
147void clear_cache( void *address, size_t n )
148{
149}
150
151/* Structure filled in by get_mem_info.  Only the size field is
152   actually used (to clear bss), so the others aren't even filled in.  */
153
154struct s_mem
155{
156  unsigned int size;
157  unsigned int icsize;
158  unsigned int dcsize;
159};
160
161
162
163extern unsigned32 _RamSize;
164
165void get_mem_info ( struct s_mem *mem )
166{
167   mem->size = (unsigned32)&_RamSize;
168}
169
Note: See TracBrowser for help on using the repository browser.