source: rtems/c/src/lib/libbsp/powerpc/shared/startup/bspstart.c @ 7294054b

4.115
Last change on this file since 7294054b was 7294054b, checked in by Joel Sherrill <joel.sherrill@…>, on 10/20/14 at 19:13:47

powerpc/shared/startup/bspstart.c: Fix warning for mvme2100

  • Property mode set to 100644
File size: 9.2 KB
Line 
1/*
2 *  This routine does the bulk of the system initialization.
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2007.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 *
13 *  Modified to support the MCP750.
14 *  Modifications Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
15 */
16
17#include <string.h>
18
19#include <bsp.h>
20#include <bsp/bootcard.h>
21#include <rtems/bspIo.h>
22#include <rtems/counter.h>
23#include <bsp/consoleIo.h>
24#include <libcpu/spr.h>
25#include <bsp/residual.h>
26#include <bsp/pci.h>
27#include <bsp/openpic.h>
28#include <bsp/irq.h>
29#include <libcpu/bat.h>
30#include <libcpu/pte121.h>
31#include <libcpu/cpuIdent.h>
32#include <bsp/vectors.h>
33#include <bsp/motorola.h>
34#include <rtems/powerpc/powerpc.h>
35
36extern void _return_to_ppcbug(void);
37extern unsigned long __rtems_end[];
38extern void L1_caches_enables(void);
39extern unsigned get_L2CR(void);
40extern void set_L2CR(unsigned);
41extern Triv121PgTbl BSP_pgtbl_setup(unsigned int *);
42extern void                     BSP_pgtbl_activate(Triv121PgTbl);
43
44SPR_RW(SPRG1)
45
46#if defined(DEBUG_BATS)
47extern void ShowBATS(void);
48#endif
49
50/*
51 *  Driver configuration parameters
52 */
53uint32_t   bsp_clicks_per_usec;
54
55/*
56 * Copy of residuals passed by firmware
57 */
58RESIDUAL residualCopy;
59/*
60 * Copy Additional boot param passed by boot loader
61 */
62#define MAX_LOADER_ADD_PARM 80
63char loaderParam[MAX_LOADER_ADD_PARM];
64
65char *BSP_commandline_string = loaderParam;
66/*
67 * Vital Board data Start using DATA RESIDUAL
68 */
69/*
70 * Total memory using RESIDUAL DATA
71 */
72unsigned int BSP_mem_size;
73
74/*
75 * PCI Bus Frequency
76 */
77unsigned int BSP_bus_frequency;
78/*
79 * processor clock frequency
80 */
81unsigned int BSP_processor_frequency;
82/*
83 * Time base divisior (how many tick for 1 second).
84 */
85unsigned int BSP_time_base_divisor;
86
87void BSP_panic(char *s)
88{
89  printk("%s PANIC %s\n",_RTEMS_version, s);
90  __asm__ __volatile ("sc");
91}
92
93void _BSP_Fatal_error(unsigned int v)
94{
95  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
96  __asm__ __volatile ("sc");
97}
98
99/*
100 *  Use the shared implementations of the following routines
101 */
102
103char *save_boot_params(
104  void *r3,
105  void *r4,
106  void *r5,
107  char *cmdline_start,
108  char *cmdline_end
109)
110{
111
112  residualCopy = *(RESIDUAL *)r3;
113  strncpy(loaderParam, cmdline_start, MAX_LOADER_ADD_PARM);
114  loaderParam[MAX_LOADER_ADD_PARM - 1] ='\0';
115  return loaderParam;
116}
117
118#if defined(mvme2100)
119unsigned int EUMBBAR;
120
121/*
122 * Return the current value of the Embedded Utilities Memory Block Base Address
123 * Register (EUMBBAR) as read from the processor configuration register using
124 * Processor Address Map B (CHRP).
125 */
126static unsigned int get_eumbbar(void) {
127  out_le32( (volatile unsigned *)0xfec00000, 0x80000078 );
128  return in_le32( (volatile unsigned *)0xfee00000 );
129}
130#endif
131
132/*
133 *  bsp_start
134 *
135 *  This routine does the bulk of the system initialization.
136 */
137
138void bsp_start( void )
139{
140#if !defined(mvme2100)
141  unsigned l2cr;
142#endif
143  uintptr_t intrStackStart;
144  uintptr_t intrStackSize;
145  prep_t boardManufacturer;
146  motorolaBoard myBoard;
147  Triv121PgTbl  pt=0;
148
149  /*
150   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
151   * function store the result in global variables so that it can be used
152   * later...
153   */
154  get_ppc_cpu_type();
155  get_ppc_cpu_revision();
156
157  /*
158   * Init MMU block address translation to enable hardware access
159   */
160
161#if !defined(mvme2100)
162  /*
163   * PC legacy IO space used for inb/outb and all PC compatible hardware
164   */
165  setdbat(1, _IO_BASE, _IO_BASE, 0x10000000, IO_PAGE);
166#endif
167
168  /*
169   * PCI devices memory area. Needed to access OpenPIC features
170   * provided by the Raven
171   *
172   * T. Straumann: give more PCI address space
173   */
174  setdbat(2, PCI_MEM_BASE+PCI_MEM_WIN0, PCI_MEM_BASE+PCI_MEM_WIN0, 0x10000000, IO_PAGE);
175
176  /*
177   * Must have acces to open pic PCI ACK registers provided by the RAVEN
178   */
179#ifndef qemu
180  setdbat(3, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
181#else
182  setdbat(3, 0xb0000000, 0xb0000000, 0x10000000, IO_PAGE);
183#endif
184
185#if defined(mvme2100)
186  /* Need 0xfec00000 mapped for this */
187  EUMBBAR = get_eumbbar();
188#endif
189
190  /*
191   * enables L1 Cache. Note that the L1_caches_enables() codes checks for
192   * relevant CPU type so that the reason why there is no use of myCpu...
193   */
194  L1_caches_enables();
195
196  select_console(CONSOLE_LOG);
197
198  /*
199   * We check that the keyboard is present and immediately
200   * select the serial console if not.
201   */
202#if defined(BSP_KBD_IOBASE)
203  { int err;
204    err = kbdreset();
205    if (err) select_console(CONSOLE_SERIAL);
206  }
207#else
208  select_console(CONSOLE_SERIAL);
209#endif
210
211
212#if !defined(mvme2100)
213  /*
214   * Enable L2 Cache. Note that the set_L2CR(L2CR) codes checks for
215   * relevant CPU type (mpc750)...
216   */
217  l2cr = get_L2CR();
218#ifdef SHOW_LCR2_REGISTER
219  printk("Initial L2CR value = %x\n", l2cr);
220#endif
221  if ( (! (l2cr & 0x80000000)) && ((int) l2cr == -1))
222    set_L2CR(0xb9A14000);
223#endif
224
225  /*
226   * Initialize the interrupt related settings.
227   */
228  intrStackStart = (uintptr_t) __rtems_end;
229  intrStackSize = rtems_configuration_get_interrupt_stack_size();
230
231  /*
232   * Initialize default raw exception handlers.
233   */
234  ppc_exc_initialize(intrStackStart, intrStackSize);
235
236  boardManufacturer   =  checkPrepBoardType(&residualCopy);
237  if (boardManufacturer != PREP_Motorola) {
238    printk("Unsupported hardware vendor\n");
239    while (1);
240  }
241  myBoard = getMotorolaBoard();
242
243  printk("-----------------------------------------\n");
244  printk("Welcome to %s on %s\n", _RTEMS_version,
245                                    motorolaBoardToString(myBoard));
246  printk("-----------------------------------------\n");
247#ifdef SHOW_MORE_INIT_SETTINGS
248  printk("Residuals are located at %x\n", (unsigned) &residualCopy);
249  printk("Additionnal boot options are %s\n", loaderParam);
250  printk("Software IRQ stack starts at %x with size %u\n", intrStackStart, intrStackSize);
251  printk("-----------------------------------------\n");
252#endif
253
254#ifdef TEST_RETURN_TO_PPCBUG
255  printk("Hit <Enter> to return to PPCBUG monitor\n");
256  printk("When Finished hit GO. It should print <Back from monitor>\n");
257  debug_getc();
258  _return_to_ppcbug();
259  printk("Back from monitor\n");
260  _return_to_ppcbug();
261#endif /* TEST_RETURN_TO_PPCBUG  */
262
263#ifdef SHOW_MORE_INIT_SETTINGS
264  printk("Going to start PCI buses scanning and initialization\n");
265#endif
266
267  pci_initialize();
268  {
269    const struct _int_map *bspmap  = motorolaIntMap(currentBoard);
270    if( bspmap ) {
271       printk("pci : Configuring interrupt routing for '%s'\n",
272          motorolaBoardToString(currentBoard));
273       FixupPCI(bspmap, motorolaIntSwizzle(currentBoard));
274    }
275    else
276       printk("pci : Interrupt routing not available for this bsp\n");
277 }
278
279#ifdef SHOW_MORE_INIT_SETTINGS
280  printk("Number of PCI buses found is : %d\n", pci_bus_count());
281#endif
282#ifdef TEST_RAW_EXCEPTION_CODE
283  printk("Testing exception handling Part 1\n");
284  /*
285   * Cause a software exception
286   */
287  __asm__ __volatile ("sc");
288  /*
289   * Check we can still catch exceptions and return coorectly.
290   */
291  printk("Testing exception handling Part 2\n");
292  __asm__ __volatile ("sc");
293
294  /*
295   * Somehow doing the above seems to clobber SPRG0 on the mvme2100.  The
296   * interrupt disable mask is stored in SPRG0. Is this a problem?
297   */
298  ppc_interrupt_set_disable_mask( PPC_INTERRUPT_DISABLE_MASK_DEFAULT);
299
300#endif
301
302/* See above */
303
304  BSP_mem_size            = residualCopy.TotalMemory;
305  BSP_bus_frequency       = residualCopy.VitalProductData.ProcessorBusHz;
306  BSP_processor_frequency = residualCopy.VitalProductData.ProcessorHz;
307  BSP_time_base_divisor   = (residualCopy.VitalProductData.TimeBaseDivisor?
308                    residualCopy.VitalProductData.TimeBaseDivisor : 4000);
309
310  /* clear hostbridge errors but leave MCP disabled -
311   * PCI config space scanning code will trip otherwise :-(
312   */
313  _BSP_clear_hostbridge_errors(0 /* enableMCP */, 0/*quiet*/);
314
315  /* Allocate and set up the page table mappings
316   * This is only available on >604 CPUs.
317   *
318   * NOTE: This setup routine may modify the available memory
319   *       size. It is essential to call it before
320   *       calculating the workspace etc.
321   */
322  pt = BSP_pgtbl_setup(&BSP_mem_size);
323
324  if (!pt || TRIV121_MAP_SUCCESS != triv121PgTblMap(
325            pt, TRIV121_121_VSID,
326#ifndef qemu
327            0xfeff0000,
328#else
329            0xbffff000,
330#endif
331            1,
332            TRIV121_ATTR_IO_PAGE, TRIV121_PP_RW_PAGE)) {
333        printk("WARNING: unable to setup page tables VME "
334               "bridge must share PCI space\n");
335  }
336
337  /*
338   *  initialize the device driver parameters
339   */
340  bsp_clicks_per_usec    = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
341  rtems_counter_initialize_converter(
342    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
343  );
344
345  /*
346   * Initalize RTEMS IRQ system
347   */
348  BSP_rtems_irq_mng_init(0);
349
350  /* Activate the page table mappings only after
351   * initializing interrupts because the irq_mng_init()
352   * routine needs to modify the text
353   */
354  if (pt) {
355#ifdef  SHOW_MORE_INIT_SETTINGS
356    printk("Page table setup finished; will activate it NOW...\n");
357#endif
358    BSP_pgtbl_activate(pt);
359    /* finally, switch off DBAT3 */
360    setdbat(3, 0, 0, 0, 0);
361  }
362
363#if defined(DEBUG_BATS)
364  ShowBATS();
365#endif
366
367#ifdef SHOW_MORE_INIT_SETTINGS
368  printk("Exit from bspstart\n");
369#endif
370}
Note: See TracBrowser for help on using the repository browser.