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

4.104.114.95
Last change on this file since 6ea100c1 was 6ea100c1, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/08 at 18:43:55

2008-05-12 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Refactored and renamed initialization routines to rtems_initialize_data_structures, rtems_initialize_before_drivers, rtems_initialize_device_drivers, and rtems_initialize_start_multitasking. This opened the sequence up so that bootcard() could provide a more robust and flexible framework which is easier to explain and understand. This also lays the groundwork for sharing the division of available memory between the RTEMS workspace and heap and the C library initialization across all BSPs.
  • 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.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 *  Use the shared implementations of the following routines
30 */
31
32void bsp_libc_init( void *, uint32_t, int );
33
34/*
35 *  Function:   bsp_pretasking_hook
36 *  Created:    95/03/10
37 *
38 *  Description:
39 *      BSP pretasking hook.  Called just before drivers are initialized.
40 *      Used to setup libc and install any BSP extensions.
41 *
42 *  NOTES:
43 *      Must not use libc (to do io) from here, since drivers are
44 *      not yet initialized.
45 *
46 */
47
48void bsp_pretasking_hook(void)
49{
50    extern int HeapBase;
51    extern int HeapSize;
52    void         *heapStart = &HeapBase;
53    unsigned long heapSize = (unsigned long)&HeapSize;
54
55    bsp_libc_init(heapStart, (uint32_t) heapSize, 0);
56
57#ifdef RTEMS_DEBUG
58    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
59#endif
60
61}
62
63/*
64 *  bsp_start
65 *
66 *  This routine does the bulk of the system initialization.
67 */
68
69void bsp_start( void )
70{
71   extern void _sys_exit(int);
72   extern int WorkspaceBase;
73   extern void mips_install_isr_entries();
74   extern void mips_gdb_stub_install(void);
75
76   /* HACK -- tied to value linkcmds */
77   if ( rtems_configuration_get_work_space_size() > (4096*1024) )
78      _sys_exit( 1 );
79
80   Configuration.work_space_start = (void *) &WorkspaceBase;
81
82   /* mask off any interrupts */
83   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
84
85   /* reset the config register & clear any pending peripheral interrupts */
86   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
87   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
88   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
89
90   /* reset both timers */
91   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
92   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
93
94   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
95   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
96
97   /* clear any pending interrupts */
98   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
99
100   /* clear any writable bits in the cause register */
101   mips_set_cause( 0 );
102
103   /* set interrupt mask, but globally off. */
104
105   /*
106   **  Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit  9 | Bit  8 |
107   **  periph | unused |  FPU   | unused | timer2 | timer1 | swint1 | swint2 |
108   **  extern |        |        |        |        |        |        |        |
109   **
110   **    1        0        1        0        0        1        0        0
111   **
112   **    0x8C00   Enable only internal Mongoose V timers.
113   **    0xA400   Enable Peripherial ints, FPU and timer1
114   **    0x0400   Timer1 only
115   */
116
117   /* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
118
119   /* to start up, only enable coprocessor 0 & timer int. per-task
120   ** processor settings will be applied as they are created, this
121   ** is just to configure the processor for startup
122   */
123   mips_set_sr( (SR_CU0 | 0x400) );
124
125   mips_install_isr_entries();
126}
127
128void clear_cache( void )
129{
130   extern void promCopyIcacheFlush(void);       /* from start.S */
131   extern void promCopyDcacheFlush(void);
132
133   promCopyIcacheFlush();
134   promCopyDcacheFlush();
135}
136
137#if 0
138
139/* Structure filled in by get_mem_info. */
140
141struct s_mem
142{
143  unsigned int size;
144  unsigned int icsize;
145  unsigned int dcsize;
146};
147
148extern uint32_t   _RamSize;
149
150void get_mem_info ( struct s_mem *mem )
151{
152   mem->size = (uint32_t)&_RamSize;
153   mem->icsize = MONGOOSEV_IC_SIZE;
154   mem->dcsize = MONGOOSEV_DC_SIZE;
155}
156
157#endif
Note: See TracBrowser for help on using the repository browser.