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

4.104.114.84.95
Last change on this file since ee733965 was ee733965, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 17, 1999 at 8:24:53 PM

Jay Monkman <jmonkman@…> submitted the eth_comm BSP for a PPC860
based board.

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