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

4.104.114.84.95
Last change on this file since a24d946 was a24d946, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 2002 at 1:57:03 PM

2002-08-06 Chris Ziomkowski <chris@…>

  • .cvsignore, Makefile.am, README, bsp_specs, configure.ac, times, clock/.cvsignore, clock/Makefile.am, clock/clockdrv.c, console/.cvsignore, console/Makefile.am, console/console.c, console/console.h, include/.cvsignore, include/Makefile.am, include/bsp.h, start/.cvsignore, start/Makefile.am, start/start.S, startup/.cvsignore, startup/bspclean.c, startup/bspstart.c, startup/linkcmds, startup/main.c, startup/setvec.c, timer/.cvsignore, timer/Makefile.am, timer/timer.c, timer/timerisr.c, wrapup/.cvsignore, wrapup/Makefile.am, ChangeLog?: New files added as part of merge from OpenCores? repository.
  • 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.OARcorp.com/rtems/license.html.
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 <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
38char *rtems_progname;
39
40/*
41 *  Use the shared implementations of the following routines
42 */
43 
44void bsp_postdriver_hook(void);
45void bsp_libc_init( void *, unsigned32, int );
46
47/*
48 *  Function:   bsp_pretasking_hook
49 *  Created:    95/03/10
50 *
51 *  Description:
52 *      BSP pretasking hook.  Called just before drivers are initialized.
53 *      Used to setup libc and install any BSP extensions.
54 *
55 *  NOTES:
56 *      Must not use libc (to do io) from here, since drivers are
57 *      not yet initialized.
58 *
59 */
60 
61void bsp_pretasking_hook(void)
62{
63    rtems_unsigned32        heap_start;
64
65    heap_start = (rtems_unsigned32) _mem_end;
66    if (heap_start & (CPU_ALIGNMENT-1))
67        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
68
69    bsp_libc_init((void *) heap_start, 64 * 1024, 0);
70
71#ifdef RTEMS_DEBUG
72    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
73#endif
74}
75 
76/*
77 *  bsp_start
78 *
79 *  This routine does the bulk of the system initialization.
80 */
81
82void bsp_start( void )
83{
84  /*
85   *  Allocate the memory for the RTEMS Work Space.  This can come from
86   *  a variety of places: hard coded address, malloc'ed from outside
87   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
88   *  typically done by stock BSPs) by subtracting the required amount
89   *  of work space from the last physical address on the CPU board.
90   */
91
92  /*
93   *  Need to "allocate" the memory for the RTEMS Workspace and
94   *  tell the RTEMS configuration where it is.  This memory is
95   *  not malloc'ed.  It is just "pulled from the air".
96   */
97
98  BSP_Configuration.work_space_start = _mem_end;
99  _mem_end += BSP_Configuration.work_space_size + 512;
100  ( BSP_Configuration.work_space_size + 512 );
101   
102  BSP_Configuration.work_space_start = (void *) ((unsigned int)((char *)BSP_Configuration.work_space_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1));
103
104  /*
105   *  initialize the CPU table for this BSP
106   */
107
108  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
109  Cpu_table.postdriver_hook = bsp_postdriver_hook;
110  Cpu_table.do_zero_of_workspace = FALSE;
111  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
112
113  /*
114   *  Start RTEMS
115   */
116
117  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
118
119  bsp_cleanup();
120
121  return 0;
122}
Note: See TracBrowser for help on using the repository browser.