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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [eth_comm/] [startup/] [bspstart.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  bsp_start()
2
 *
3
 *  This routine starts the application.  It includes application,
4
 *  board, and monitor specific initialization and configuration.
5
 *  The generic CPU dependent initialization has been performed
6
 *  before this routine is invoked.
7
 *
8
 *  The MPC860 specific stuff was written by Jay Monkman (jmonkman@frasca.com)
9
 *
10
 *  COPYRIGHT (c) 1989-1999.
11
 *  On-Line Applications Research Corporation (OAR).
12
 *
13
 *  The license and distribution terms for this file may be
14
 *  found in the file LICENSE in this distribution or at
15
 *  http://www.OARcorp.com/rtems/license.html.
16
 *
17
 *  $Id: bspstart.c,v 1.2 2001-09-27 12:00:36 chris Exp $
18
 */
19
 
20
#include <bsp.h>
21
#include <mpc860.h>
22
#include <rtems/libio.h>
23
 
24
#include <libcsupport.h>
25
 
26
#include <string.h>
27
#include <info.h>
28
 
29
#ifdef STACK_CHECKER_ON
30
#include <stackchk.h>
31
#endif
32
 
33
boardinfo_t M860_binfo;
34
 
35
 
36
/*
37
 *  The original table from the application and our copy of it with
38
 *  some changes.
39
 */
40
extern rtems_configuration_table Configuration;
41
 
42
rtems_configuration_table  BSP_Configuration;
43
 
44
rtems_cpu_table Cpu_table;
45
 
46
char *rtems_progname;
47
 
48
/*
49
 *  Use the shared implementations of the following routines
50
 */
51
void bsp_postdriver_hook(void);
52
void bsp_libc_init( void *, unsigned32, int );
53
 
54
/*
55
 *  Function:   bsp_pretasking_hook
56
 *  Created:    95/03/10
57
 *
58
 *  Description:
59
 *      BSP pretasking hook.  Called just before drivers are initialized.
60
 *      Used to setup libc and install any BSP extensions.
61
 *
62
 *  NOTES:
63
 *      Must not use libc (to do io) from here, since drivers are
64
 *      not yet initialized.
65
 *
66
 */
67
 
68
void
69
bsp_pretasking_hook(void)
70
{
71
  extern int       _end;
72
  rtems_unsigned32  heap_start;
73
 
74
  /*
75
   * Let's check to see if the size of M860_binfo is what
76
   * it should be. It might not be if the info.h files
77
   * for RTEMS and the bootloader define boardinfo_t
78
   * differently.
79
   */
80
 
81
  /* Oops. printf() won't work yet, since the console is not initialized.
82
     I should probably find some way of doing this though.
83
  if (M860_binfo.size != sizeof(boardinfo_t)) {
84
      printf("The size of the Board Info Block appears to be incorrect.\n");
85
      printf(" This could occur if the 'info.h' files for RTEMS and the\n");
86
      printf(" bootloader differ in their definition of boardinfo_t\n");
87
  }
88
  */
89
  heap_start = (rtems_unsigned32) &_end;
90
 
91
  /* Align the heap on a natural boundary (4 bytes?) */
92
  if (heap_start & (CPU_ALIGNMENT-1)) {
93
    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
94
  }
95
  /* set up a 256K heap */
96
  bsp_libc_init((void *) heap_start, 256 * 1024, 0);
97
 
98
#ifdef STACK_CHECKER_ON
99
  /*
100
   *  Initialize the stack bounds checker
101
   *  We can either turn it on here or from the app.
102
   */
103
 
104
  Stack_check_Initialize();
105
#endif
106
 
107
#ifdef RTEMS_DEBUG
108
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
109
#endif
110
}
111
 
112
 
113
void bsp_start(void)
114
{
115
  extern int _end;
116
  rtems_unsigned32  heap_start;
117
  rtems_unsigned32  ws_start;
118
  /*
119
   *  Allocate the memory for the RTEMS Work Space.  This can come from
120
   *  a variety of places: hard coded address, malloc'ed from outside
121
   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
122
   *  typically done by stock BSPs) by subtracting the required amount
123
   *  of work space from the last physical address on the CPU board.
124
   */
125
 
126
  /*
127
   *  Need to "allocate" the memory for the RTEMS Workspace and
128
   *  tell the RTEMS configuration where it is.  This memory is
129
   *  not malloc'ed.  It is just "pulled from the air".
130
   */
131
 
132
  heap_start = (rtems_unsigned32) &_end;
133
  if (heap_start & (CPU_ALIGNMENT-1))
134
    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
135
 
136
 
137
  ws_start = heap_start + (256 * 1024);
138
  if (ws_start & ((512 * 1024) - 1)) {  /* align to 512K boundary */
139
    ws_start = (ws_start + (512 * 1024)) & ~((512 * 1024) - 1);
140
  }
141
 
142
  BSP_Configuration.work_space_start = (void *)ws_start;
143
  BSP_Configuration.work_space_size = 512 * 1024;
144
 
145
  /*
146
   *  initialize the CPU table for this BSP
147
   */
148
 
149
  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
150
  Cpu_table.postdriver_hook = bsp_postdriver_hook;
151
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
152
 
153
  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
154
  Cpu_table.serial_per_sec = 10000000;
155
  Cpu_table.serial_external_clock = 1;
156
  Cpu_table.serial_xon_xoff = 0;
157
  Cpu_table.serial_cts_rts = 1;
158
  Cpu_table.serial_rate = 9600;
159
  Cpu_table.timer_average_overhead = 0;
160
  Cpu_table.timer_least_valid = 0;
161
  Cpu_table.clock_speed = 40000000;
162
 
163
  /*
164
   * Since we are currently autodetecting whether to use SCC1 or
165
   * the FEC for ethernet, we set up a register in the ethernet
166
   * transciever that is used for 10/100 Mbps ethernet now, so that
167
   * we can attempt to read it later in rtems_enet_driver_attach()
168
  */
169
  m860.fec.mii_speed = 0x0a;
170
  m860.fec.mii_data = 0x680a0000;
171
 
172
 
173
  m860.scc2.sccm=0;
174
  m860.scc2p.rbase=0;
175
  m860.scc2p.tbase=0;
176
  M860ExecuteRISC(M860_CR_OP_STOP_TX | M860_CR_CHAN_SCC2);
177
 
178
  mmu_init();
179
}
180
 
181
 

powered by: WebSVN 2.1.0

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