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

4.104.114.84.95
Last change on this file since 8ef3818 was 8ef3818, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 19:57:02

Patch from John Cotton <john.cotton@…>, Charles-Antoine Gauthier
<charles.gauthier@…>, and Darlene A. Stewart
<Darlene.Stewart@…> to add support for a number of very
significant things:

+ BSPs for many variations on the Motorola MBX8xx board series
+ Cache Manager including initial support for m68040

and PowerPC

+ Rework of mpc8xx libcpu code so all mpc8xx CPUs now use

same code base.

+ Rework of eth_comm BSP to utiltize above.

John reports this works on the 821 and 860

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