source: rtems/c/src/lib/libbsp/or32/orp/startup/bspstart.c @ c725258

Last change on this file since c725258 was c725258, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:44:58

2003-09-04 Joel Sherrill <joel@…>

  • clock/clockdrv.c, console/console.c, console/console.h, include/bsp.h, start/start.S, startup/bspclean.c, startup/bspstart.c, startup/linkcmds, startup/setvec.c, timer/timer.c, timer/timerisr.c: URL for license changed.
  • Property mode set to 100644
File size: 3.2 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-1999.
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 *  This file adapted from no_bsp board library of the RTEMS distribution.
15 *  The body has been modified for the Bender Or1k implementation by
16 *  Chris Ziomkowski. <chris@asics.ws>
17 */
18
19#include <bsp.h>
20#include <rtems/libio.h>
21 
22#include <rtems/libcsupport.h>
23 
24#include <string.h>
25extern int _mem_end;
26 
27/*
28 *  The original table from the application and our copy of it with
29 *  some changes.
30 */
31
32extern rtems_configuration_table Configuration;
33
34rtems_configuration_table  BSP_Configuration;
35
36rtems_cpu_table Cpu_table;
37
38/*
39 *  Use the shared implementations of the following routines
40 */
41 
42void bsp_postdriver_hook(void);
43void bsp_libc_init( void *, unsigned32, int );
44
45/*
46 *  Function:   bsp_pretasking_hook
47 *  Created:    95/03/10
48 *
49 *  Description:
50 *      BSP pretasking hook.  Called just before drivers are initialized.
51 *      Used to setup libc and install any BSP extensions.
52 *
53 *  NOTES:
54 *      Must not use libc (to do io) from here, since drivers are
55 *      not yet initialized.
56 *
57 */
58 
59void bsp_pretasking_hook(void)
60{
61    rtems_unsigned32        heap_start;
62
63    heap_start = (rtems_unsigned32) _mem_end;
64    if (heap_start & (CPU_ALIGNMENT-1))
65        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
66
67    bsp_libc_init((void *) heap_start, 64 * 1024, 0);
68
69#ifdef RTEMS_DEBUG
70    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
71#endif
72}
73 
74/*
75 *  bsp_start
76 *
77 *  This routine does the bulk of the system initialization.
78 */
79
80void bsp_start( void )
81{
82  /*
83   *  Allocate the memory for the RTEMS Work Space.  This can come from
84   *  a variety of places: hard coded address, malloc'ed from outside
85   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
86   *  typically done by stock BSPs) by subtracting the required amount
87   *  of work space from the last physical address on the CPU board.
88   */
89
90  /*
91   *  Need to "allocate" the memory for the RTEMS Workspace and
92   *  tell the RTEMS configuration where it is.  This memory is
93   *  not malloc'ed.  It is just "pulled from the air".
94   */
95
96  BSP_Configuration.work_space_start = _mem_end;
97  _mem_end += BSP_Configuration.work_space_size + 512;
98  ( BSP_Configuration.work_space_size + 512 );
99   
100  BSP_Configuration.work_space_start = (void *) ((unsigned int)((char *)BSP_Configuration.work_space_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1));
101
102  /*
103   *  initialize the CPU table for this BSP
104   */
105
106  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
107  Cpu_table.postdriver_hook = bsp_postdriver_hook;
108  Cpu_table.do_zero_of_workspace = FALSE;
109  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
110
111  /*
112   *  Start RTEMS
113   */
114
115  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
116
117  bsp_cleanup();
118}
Note: See TracBrowser for help on using the repository browser.