Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:59

0001 /*
0002  *  This routine does the bulk of the system initialization.
0003  */
0004 
0005 /*
0006  *  COPYRIGHT (c) 1989-2007.
0007  *  On-Line Applications Research Corporation (OAR).
0008  *
0009  *  The license and distribution terms for this file may be
0010  *  found in the file LICENSE in this distribution or at
0011  *  http://www.rtems.org/license/LICENSE.
0012  *
0013  *  SS555 port sponsored by Defence Research and Development Canada - Suffield
0014  *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
0015  *
0016  *  Derived from c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c:
0017  *
0018  *  Modifications for MBX860:
0019  *  Copyright (c) 1999, National Research Council of Canada
0020  */
0021 
0022 #include <rtems/bspIo.h>
0023 #include <rtems/counter.h>
0024 #include <bsp/bootcard.h>
0025 #include <rtems/powerpc/powerpc.h>
0026 
0027 #include <libcpu/cpuIdent.h>
0028 #include <libcpu/spr.h>
0029 
0030 #include <bsp/irq.h>
0031 #include <bsp.h>
0032 
0033 SPR_RW(SPRG1)
0034 
0035 /*
0036  *  Driver configuration parameters
0037  */
0038 uint32_t   bsp_clicks_per_usec;
0039 uint32_t   bsp_clock_speed;        /* Serial clocks per second */
0040 
0041 uint32_t _CPU_Counter_frequency(void)
0042 {
0043   return BSP_CRYSTAL_HZ / 4;
0044 }
0045 
0046 /*
0047  *  bsp_start()
0048  *
0049  *  Board-specific initialization code. Called from the generic boot_card()
0050  *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
0051  *  does some of the board independent initialization. It is called from the
0052  *  SS555 entry point _start() defined in
0053  *  rtems/c/src/lib/libbsp/powerpc/ss555/start/start.S
0054  *
0055  *  _start() has set up a stack, has zeroed the .bss section, has set up the
0056  *  .data section from contents stored in ROM, has turned off interrupts,
0057  *  and placed the processor in the supervisor mode.  boot_card() has left
0058  *  the processor in that state when bsp_start() was called.
0059  *
0060  *  Input parameters: NONE
0061  *
0062  *  Output parameters: NONE
0063  *
0064  *  Return values: NONE
0065  */
0066 void bsp_start(void)
0067 {
0068   char* intrStack;
0069 
0070   /*
0071    * Get CPU identification dynamically.  Note that the get_ppc_cpu_type()
0072    * function stores the result in global variables so that it can be used
0073    * later.
0074    */
0075   get_ppc_cpu_type();
0076   get_ppc_cpu_revision();
0077 
0078   /*
0079    * Initialize some SPRG registers related to irq handling
0080    */
0081   intrStack = (char *)_ISR_Stack_area_end -
0082      PPC_MINIMUM_STACK_FRAME_SIZE;
0083   _write_SPRG1((unsigned int)intrStack);
0084 
0085   /*
0086    * Install our own set of exception vectors
0087    */
0088   initialize_exceptions();
0089 
0090   /*
0091    *  initialize the device driver parameters
0092    */
0093   bsp_clicks_per_usec = BSP_CRYSTAL_HZ / 4 / 1000000;
0094   bsp_clock_speed     = BSP_CLOCK_HZ;   /* for SCI baud rate generator */
0095 
0096   /*
0097    * Initalize RTEMS IRQ system
0098    */
0099   BSP_rtems_irq_mng_init(0);
0100 }