source: rtems/c/src/lib/libbsp/powerpc/eth_comm/startup/bspstart.c @ adc5f630

Last change on this file since adc5f630 was adc5f630, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/03 at 17:21:27

2003-07-18 Till Straumann <strauman@…>

PR 288/rtems

  • irq/irq_asm.S, startup/bspstart.c: _ISR_Nest_level is now properly maintained.
  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*  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$
18 */
19
20#include <string.h>
21
22#include <bsp.h>
23#include <bsp/irq.h>
24#include <rtems/libio.h>
25#include <rtems/libcsupport.h>
26#include <info.h>
27#include <libcpu/cpuIdent.h>
28#include <libcpu/spr.h>
29#include <rtems/bspIo.h>
30
31boardinfo_t M860_binfo;
32
33/*
34 *  The original table from the application and our copy of it with
35 *  some changes.
36 */
37extern rtems_configuration_table Configuration;
38extern unsigned long intrStackPtr;
39rtems_configuration_table  BSP_Configuration;
40
41rtems_cpu_table Cpu_table;
42
43char *rtems_progname;
44
45/*
46 *  Use the shared implementations of the following routines
47 */
48void bsp_postdriver_hook(void);
49void bsp_libc_init( void *, unsigned32, int );
50
51void BSP_panic(char *s)
52{
53  printk("%s PANIC %s\n",_RTEMS_version, s);
54  __asm__ __volatile ("sc");
55}
56
57void _BSP_Fatal_error(unsigned int v)
58{
59  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
60  __asm__ __volatile ("sc");
61}
62
63/*
64 *  Function:   bsp_pretasking_hook
65 *  Created:    95/03/10
66 *
67 *  Description:
68 *      BSP pretasking hook.  Called just before drivers are initialized.
69 *      Used to setup libc and install any BSP extensions.
70 *
71 *  NOTES:
72 *      Must not use libc (to do io) from here, since drivers are
73 *      not yet initialized.
74 *
75 */
76 
77void
78bsp_pretasking_hook(void)
79{
80  extern int       _end;
81  rtems_unsigned32  heap_start;
82
83  /*
84   * Let's check to see if the size of M860_binfo is what
85   * it should be. It might not be if the info.h files
86   * for RTEMS and the bootloader define boardinfo_t
87   * differently.
88   */
89
90  /* Oops. printf() won't work yet, since the console is not initialized.
91     I should probably find some way of doing this though.
92  if (M860_binfo.size != sizeof(boardinfo_t)) {
93      printf("The size of the Board Info Block appears to be incorrect.\n");
94      printf(" This could occur if the 'info.h' files for RTEMS and the\n");
95      printf(" bootloader differ in their definition of boardinfo_t\n");
96  }
97  */
98  heap_start = (rtems_unsigned32) &_end;
99
100  /* Align the heap on a natural boundary (4 bytes?) */
101  if (heap_start & (CPU_ALIGNMENT-1)) {
102    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
103  }
104  /* set up a 256K heap */
105  bsp_libc_init((void *) heap_start, 256 * 1024, 0);
106 
107#ifdef RTEMS_DEBUG
108  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
109#endif
110}
111
112SPR_RW(SPRG0)
113SPR_RW(SPRG1)
114
115void bsp_start(void)
116{
117  extern int _end;
118  rtems_unsigned32  heap_start;
119  rtems_unsigned32  ws_start;
120  ppc_cpu_id_t myCpu;
121  ppc_cpu_revision_t myCpuRevision;
122  register unsigned char* intrStack;
123  extern void cpu_init(void);
124   
125  /*
126   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
127   * store the result in global variables so that it can be used latter...
128   */
129  myCpu         = get_ppc_cpu_type();
130  myCpuRevision = get_ppc_cpu_revision();
131
132  cpu_init();
133  mmu_init();
134  /*
135   * Initialize some SPRG registers related to irq handling
136   */
137   
138  intrStack = (((unsigned char*)&intrStackPtr) - CPU_MINIMUM_STACK_FRAME_SIZE);
139
140  _write_SPRG1((unsigned int)intrStack);
141
142  /* Signal them that this BSP has fixed PR288 - eventually, this should go away */
143  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
144 
145   /*
146    * Install our own set of exception vectors
147    */
148   initialize_exceptions();
149 
150  /*
151   *  Allocate the memory for the RTEMS Work Space.  This can come from
152   *  a variety of places: hard coded address, malloc'ed from outside
153   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
154   *  typically done by stock BSPs) by subtracting the required amount
155   *  of work space from the last physical address on the CPU board.
156   */
157
158  /*
159   *  Need to "allocate" the memory for the RTEMS Workspace and
160   *  tell the RTEMS configuration where it is.  This memory is
161   *  not malloc'ed.  It is just "pulled from the air".
162   */
163
164  heap_start = (rtems_unsigned32) &_end;
165  if (heap_start & (CPU_ALIGNMENT-1))
166    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
167
168
169  ws_start = heap_start + (256 * 1024);
170  if (ws_start & ((512 * 1024) - 1)) {  /* align to 512K boundary */
171    ws_start = (ws_start + (512 * 1024)) & ~((512 * 1024) - 1);
172  }
173
174  BSP_Configuration.work_space_start = (void *)ws_start;
175  BSP_Configuration.work_space_size = 512 * 1024;
176
177  /*
178   *  initialize the CPU table for this BSP
179   */
180
181  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
182  Cpu_table.postdriver_hook = bsp_postdriver_hook;
183  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
184
185  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
186  Cpu_table.serial_per_sec = 10000000;
187  Cpu_table.serial_external_clock = 1;
188  Cpu_table.serial_xon_xoff = 0;
189  Cpu_table.serial_cts_rts = 1;
190  Cpu_table.serial_rate = 9600;
191  Cpu_table.timer_average_overhead = 0;
192  Cpu_table.timer_least_valid = 0;
193  Cpu_table.clock_speed = 40000000;
194
195  /*
196   * Since we are currently autodetecting whether to use SCC1 or
197   * the FEC for ethernet, we set up a register in the ethernet
198   * transciever that is used for 10/100 Mbps ethernet now, so that
199   * we can attempt to read it later in rtems_enet_driver_attach()
200  */
201  m8xx.fec.mii_speed = 0x0a;
202  m8xx.fec.mii_data = 0x680a0000;
203
204
205  m8xx.scc2.sccm=0;
206  m8xx.scc2p.rbase=0;
207  m8xx.scc2p.tbase=0;
208  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
209  /*
210   * Initalize RTEMS IRQ system
211   */
212  BSP_rtems_irq_mng_init(0);
213#ifdef SHOW_MORE_INIT_SETTINGS
214  printk("Exit from bspstart\n");
215#endif 
216
217}
218
219
Note: See TracBrowser for help on using the repository browser.