OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [a29k/] [portsw/] [startup/] [bspstart.c] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  $Id: bspstart.c,v 1.2 2001-09-27 11:59:42 chris Exp $
15
 */
16
 
17
#include <bsp.h>
18
#include <rtems/libio.h>
19
 
20
#include <libcsupport.h>
21
 
22
#include <string.h>
23
 
24
#ifndef lint
25
static char _sccsid[] = "@(#)bspstart.c 09/11/96     1.15\n";
26
#endif
27
 
28
/*
29
 *  The original table from the application and our copy of it with
30
 *  some changes.
31
 */
32
 
33
extern rtems_configuration_table Configuration;
34
 
35
rtems_configuration_table  BSP_Configuration;
36
 
37
rtems_cpu_table Cpu_table;
38
 
39
char *rtems_progname;
40
 
41
/*      Initialize whatever libc we are using
42
 *      called from postdriver hook
43
 */
44
 
45
#define HEAP_BLOCK_SIZE (16 * 1024)
46
 
47
rtems_unsigned32        heap_size = 0;
48
rtems_unsigned32        heap_start;
49
 
50
/*
51
 *  Use the shared implementations of the following routines
52
 */
53
 
54
void bsp_postdriver_hook(void);
55
void bsp_libc_init( void *, unsigned32, int );
56
 
57
/*
58
 *  Function:   bsp_pretasking_hook
59
 *  Created:    95/03/10
60
 *
61
 *  Description:
62
 *      BSP pretasking hook.  Called just before drivers are initialized.
63
 *      Used to setup libc and install any BSP extensions.
64
 *
65
 *  NOTES:
66
 *      Must not use libc (to do io) from here, since drivers are
67
 *      not yet initialized.
68
 *
69
 */
70
 
71
void bsp_pretasking_hook(void)
72
{
73
   /* allocate a maximum of 2 megabytes for the heap */
74
    heap_size = 2 * 1024 * 1024;
75
 
76
    /* allocate all remaining memory to the heap */
77
    do {
78
       heap_size -= HEAP_BLOCK_SIZE;
79
       heap_start = _sysalloc( heap_size );
80
    } while ( !heap_start );
81
 
82
    if (!heap_start)
83
       rtems_fatal_error_occurred( heap_size );
84
 
85
    if (heap_start & (CPU_ALIGNMENT-1))
86
        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
87
 
88
 
89
    bsp_libc_init((void *) heap_start, heap_size, 0);
90
 
91
 
92
#ifdef RTEMS_DEBUG
93
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
94
#endif
95
}
96
 
97
/*
98
 *  bsp_start
99
 *
100
 *  This routine does the bulk of the system initialization.
101
 */
102
 
103
int bsp_start(
104
  int argc,
105
  char **argv,
106
  char **environp
107
)
108
{
109
  if ((argc > 0) && argv && argv[0])
110
    rtems_progname = argv[0];
111
  else
112
    rtems_progname = "RTEMS";
113
 
114
  /* set the PIA0 register wait states */
115
  *(volatile unsigned32 *)0x80000020 = 0x04080000;
116
 
117
  /*
118
   *  Allocate the memory for the RTEMS Work Space.  This can come from
119
   *  a variety of places: hard coded address, malloc'ed from outside
120
   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
121
   *  typically done by stock BSPs) by subtracting the required amount
122
   *  of work space from the last physical address on the CPU board.
123
   */
124
 
125
  /*
126
   *  Need to "allocate" the memory for the RTEMS Workspace and
127
   *  tell the RTEMS configuration where it is.  This memory is
128
   *  not malloc'ed.  It is just "pulled from the air".
129
   */
130
 
131
  BSP_Configuration.work_space_start = _sysalloc( BSP_Configuration.work_space_size + 512 );
132
  if (!BSP_Configuration.work_space_start)
133
    rtems_fatal_error_occurred( BSP_Configuration.work_space_size );
134
 
135
  BSP_Configuration.work_space_start = (void *) ((unsigned int)((char *)BSP_Configuration.work_space_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1));
136
 
137
  /*
138
   *  initialize the CPU table for this BSP
139
   */
140
 
141
  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
142
  Cpu_table.postdriver_hook = bsp_postdriver_hook;
143
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
144
 
145
  _settrap( 109,&a29k_enable_sup);
146
  _settrap( 110,&a29k_disable_sup);
147
  _settrap( 111,&a29k_enable_all_sup);
148
  _settrap( 112,&a29k_disable_all_sup);
149
  _settrap( 106,&a29k_context_switch_sup);
150
  _settrap( 107,&a29k_context_restore_sup);
151
  _settrap( 108,&a29k_context_save_sup);
152
  _settrap( 105,&a29k_sigdfl_sup);
153
 
154
  /*
155
   *  Start RTEMS
156
   */
157
 
158
  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
159
 
160
  bsp_cleanup();
161
 
162
  return 0;
163
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.