Ignore:
Timestamp:
Nov 10, 2004, 11:51:17 PM (16 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a84392d
Parents:
f9877d25
Message:

2004-11-10 Richard Campbell <richard.campbell@…>

  • Makefile.am, bootloader/misc.c, bootloader/pci.c, bootloader/pci.h, console/console.c, console/inch.c, console/reboot.c, console/uart.c, console/uart.h, irq/irq.c, irq/irq.h, irq/irq_init.c, motorola/motorola.c, motorola/motorola.h, openpic/openpic.c, openpic/openpic.h, pci/detect_raven_bridge.c, pci/pci.c, start/start.S, startup/bspstart.c, vectors/vectors_init.c, vme/vmeconfig.c: Add MVME2100 BSP and MPC8240 support. There was also a significant amount of spelling and whitespace cleanup.
  • tod/todcfg.c: New file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/shared/startup/bspstart.c

    rf9877d25 re79a1947  
    2020#include <string.h>
    2121
     22#include <bsp.h>
    2223#include <rtems/libio.h>
    2324#include <rtems/libcsupport.h>
     
    2930#include <bsp/irq.h>
    3031#include <bsp/VME.h>
    31 #include <bsp.h>
    3232#include <libcpu/bat.h>
    3333#include <libcpu/pte121.h>
     
    4949SPR_RW(SPRG1)
    5050
     51#if defined(DEBUG_BATS)
     52void printBAT( int bat, unsigned32 upper, unsigned32 lower )
     53{
     54  unsigned32 lowest_addr;
     55  unsigned32 size;
     56
     57  printk("BAT%d raw(upper=0x%08x, lower=0x%08x) ", bat, upper, lower );
     58
     59  lowest_addr = (upper & 0xFFFE0000);
     60  size = (((upper & 0x00001FFC) >> 2) + 1) * (128 * 1024);
     61  printk(" range(0x%08x, 0x%08x) %s%s %s%s%s%s %s\n",
     62    lowest_addr,
     63    lowest_addr + (size - 1),
     64    (upper & 0x01) ? "P" : "p",
     65    (upper & 0x02) ? "S" : "s",
     66    (lower & 0x08) ? "G" : "g",
     67    (lower & 0x10) ? "M" : "m",
     68    (lower & 0x20) ? "I" : "i",
     69    (lower & 0x40) ? "W" : "w",
     70    (lower & 0x01) ? "Read Only" :
     71      ((lower & 0x02) ? "Read/Write" : "No Access")
     72  );
     73}
     74
     75void ShowBATS(){
     76  unsigned32 lower;
     77  unsigned32 upper;
     78
     79  __MFSPR(536, upper); __MFSPR(537, lower); printBAT( 0, upper, lower );
     80  __MFSPR(538, upper); __MFSPR(539, lower); printBAT( 1, upper, lower );
     81  __MFSPR(540, upper); __MFSPR(541, lower); printBAT( 2, upper, lower );
     82  __MFSPR(542, upper); __MFSPR(543, lower); printBAT( 3, upper, lower );
     83}
     84#endif
     85
    5186/*
    5287 * Copy of residuals passed by firmware
     
    131166void bsp_pretasking_hook(void)
    132167{
    133     uint32_t                heap_start;
    134     uint32_t                heap_size;
    135     uint32_t                heap_sbrk_spared;
    136         extern uint32_t         _bsp_sbrk_init(uint32_t, uint32_t*);
    137 
    138     heap_start = ((uint32_t) __rtems_end) +INIT_STACK_SIZE + INTR_STACK_SIZE;
    139     if (heap_start & (CPU_ALIGNMENT-1))
    140         heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
    141 
    142     heap_size = (BSP_mem_size - heap_start) - BSP_Configuration.work_space_size;
    143 
    144         heap_sbrk_spared=_bsp_sbrk_init(heap_start, &heap_size);
    145 
    146 #ifdef SHOW_MORE_INIT_SETTINGS
    147         printk(" HEAP start %x  size %x (%x bytes spared for sbrk)\n", heap_start, heap_size, heap_sbrk_spared);
    148 #endif
    149 
    150     bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
     168  rtems_unsigned32        heap_start;   
     169  rtems_unsigned32        heap_size;
     170  rtems_unsigned32        heap_sbrk_spared;
     171  extern rtems_unsigned32 _bsp_sbrk_init(rtems_unsigned32, rtems_unsigned32*);
     172
     173  heap_start = ((rtems_unsigned32) __rtems_end) +
     174                INIT_STACK_SIZE + INTR_STACK_SIZE;
     175  if (heap_start & (CPU_ALIGNMENT-1))
     176      heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
     177
     178  heap_size = (BSP_mem_size - heap_start) - BSP_Configuration.work_space_size;
     179  heap_sbrk_spared=_bsp_sbrk_init(heap_start, &heap_size);
     180
     181#ifdef SHOW_MORE_INIT_SETTINGS
     182  printk( "HEAP start %x  size %x (%x bytes spared for sbrk)\n",
     183             heap_start, heap_size, heap_sbrk_spared);
     184#endif   
     185
     186  bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
    151187
    152188#ifdef RTEMS_DEBUG
    153     rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
     189  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
    154190#endif
    155191}
     
    173209}
    174210
     211#if defined(mpc8240) || defined(mpc8245)
     212unsigned int EUMBBAR;
     213
     214/*
     215 * Return the current value of the Embedded Utilities Memory Block Base Address
     216 * Register (EUMBBAR) as read from the processor configuration register using
     217 * Processor Address Map B (CHRP).
     218 */
     219unsigned int get_eumbbar() {
     220  register int a, e;
     221
     222  asm volatile( "lis %0,0xfec0; ori  %0,%0,0x0000": "=r" (a) );
     223  asm volatile("sync");
     224                                                               
     225  asm volatile("lis %0,0x8000; ori %0,%0,0x0078": "=r"(e) );
     226  asm volatile("stwbrx  %0,0x0,%1": "=r"(e): "r"(a)); 
     227  asm volatile("sync");
     228
     229  asm volatile("lis %0,0xfee0; ori %0,%0,0x0000": "=r" (a) );
     230  asm volatile("sync");
     231                                                         
     232  asm volatile("lwbrx %0,0x0,%1": "=r" (e): "r" (a));
     233  asm volatile("isync");
     234  return e;
     235}
     236#endif
     237
    175238/*
    176239 *  bsp_start
     
    181244void bsp_start( void )
    182245{
    183   int err;
    184246  unsigned char *stack;
     247#if !defined(mpc8240) && !defined(mpc8245)
    185248  unsigned l2cr;
     249#endif
    186250  register unsigned char* intrStack;
    187251  unsigned char *work_space_start;
     
    191255  motorolaBoard myBoard;
    192256  Triv121PgTbl  pt=0;
    193   /*
    194    * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
    195    * store the result in global variables so that it can be used latter...
     257
     258  /*
     259   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
     260   * function store the result in global variables so that it can be used
     261   * later...
    196262   */
    197263  myCpu         = get_ppc_cpu_type();
    198264  myCpuRevision = get_ppc_cpu_revision();
     265
     266#if defined(mvme2100)
     267  EUMBBAR = get_eumbbar();
     268
     269  Cpu_table.exceptions_in_RAM    = TRUE;
     270  { unsigned v = 0x3000 ; _CPU_MSR_SET(v); }
     271#endif
     272
     273#if !defined(mpc8240) && !defined(mpc8245)
    199274  /*
    200275   * enables L1 Cache. Note that the L1_caches_enables() codes checks for
     
    202277   */
    203278  L1_caches_enables();
     279
    204280  /*
    205281   * Enable L2 Cache. Note that the set_L2CR(L2CR) codes checks for
     
    212288  if ( (! (l2cr & 0x80000000)) && ((int) l2cr == -1))
    213289    set_L2CR(0xb9A14000);
     290#endif
     291
    214292  /*
    215293   * the initial stack  has aready been set to this value in start.S
     
    217295   * so that It can be printed without accessing R1.
    218296   */
    219   stack = ((unsigned char*) __rtems_end) + INIT_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
    220 
    221  /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
     297  stack = ((unsigned char*) __rtems_end) +
     298               INIT_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
     299
     300  /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
    222301  *((uint32_t*)stack) = 0;
    223302
     
    226305   * SPRG1 = software managed IRQ stack
    227306   *
    228    * This could be done latter (e.g in IRQ_INIT) but it helps to understand
     307   * This could be done later (e.g in IRQ_INIT) but it helps to understand
    229308   * some settings below...
    230309   */
    231   intrStack = ((unsigned char*) __rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
     310  intrStack = ((unsigned char*) __rtems_end) +
     311    INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
    232312
    233313  /* make sure it's properly aligned */
     
    243323
    244324  /*
    245    * Initialize default raw exception hanlders. See vectors/vectors_init.c
     325   * Initialize default raw exception handlers. See vectors/vectors_init.c
    246326   */
    247327  initialize_exceptions();
    248   /*
    249    * Init MMU block address translation to enable hardware
    250    * access
    251    */
    252   /*
    253    * PC legacy IO space used for inb/outb and all PC
    254    * compatible hardware
     328
     329  /*
     330   * Init MMU block address translation to enable hardware access
     331   */
     332
     333#if !defined(mvme2100)
     334  /*
     335   * PC legacy IO space used for inb/outb and all PC compatible hardware
    255336   */
    256337  setdbat(1, _IO_BASE, _IO_BASE, 0x10000000, IO_PAGE);
    257   /*
    258    * PCI devices memory area. Needed to access OPENPIC features
    259    * provided by the RAVEN
    260    */
    261   /* T. Straumann: give more PCI address space */
     338#endif
     339
     340  /*
     341   * PCI devices memory area. Needed to access OpenPIC features
     342   * provided by the Raven
     343   *
     344   * T. Straumann: give more PCI address space
     345   */
    262346  setdbat(2, PCI_MEM_BASE, PCI_MEM_BASE, 0x10000000, IO_PAGE);
    263   /*
    264    * Must have acces to open pic PCI ACK registers
    265    * provided by the RAVEN
    266    *
     347
     348  /*
     349   * Must have acces to open pic PCI ACK registers provided by the RAVEN
    267350   */
    268351  setdbat(3, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
     
    270353  select_console(CONSOLE_LOG);
    271354
    272   /* We check that the keyboard is present and immediately
     355  /*
     356   * We check that the keyboard is present and immediately
    273357   * select the serial console if not.
    274358   */
    275   err = kbdreset();
    276   if (err) select_console(CONSOLE_SERIAL);
     359#if defined(BSP_KBD_IOBASE)
     360  { int err;
     361    err = kbdreset();
     362    if (err) select_console(CONSOLE_SERIAL);
     363  }
     364#else
     365  select_console(CONSOLE_SERIAL);
     366#endif
    277367
    278368  boardManufacturer   =  checkPrepBoardType(&residualCopy);
     
    284374
    285375  printk("-----------------------------------------\n");
    286   printk("Welcome to %s on %s\n", _RTEMS_version, motorolaBoardToString(myBoard));
     376  printk("Welcome to %s on %s\n", _RTEMS_version,
     377                                    motorolaBoardToString(myBoard));
    287378  printk("-----------------------------------------\n");
    288379#ifdef SHOW_MORE_INIT_SETTINGS
     
    308399  InitializePCI();
    309400
    310  {
    311     const struct _int_map     *bspmap   = motorolaIntMap(currentBoard);
    312     if( bspmap )
    313     {
    314        printk("pci : Configuring interrupt routing for '%s'\n", motorolaBoardToString(currentBoard));
    315        FixupPCI(bspmap, motorolaIntSwizzle(currentBoard) );
     401  {
     402    const struct _int_map *bspmap  = motorolaIntMap(currentBoard);
     403    if( bspmap ) {
     404       printk("pci : Configuring interrupt routing for '%s'\n",
     405         motorolaBoardToString(currentBoard));
     406       FixupPCI(bspmap, motorolaIntSwizzle(currentBoard));
    316407    }
    317408    else
     
    329420  __asm__ __volatile ("sc");
    330421  /*
    331    * Check we can still catch exceptions and returned coorectly.
     422   * Check we can still catch exceptions and return coorectly.
    332423   */
    333424  printk("Testing exception handling Part 2\n");
    334425  __asm__ __volatile ("sc");
    335 #endif
    336 
    337   BSP_mem_size                          = residualCopy.TotalMemory;
    338   BSP_bus_frequency                     = residualCopy.VitalProductData.ProcessorBusHz;
    339   BSP_processor_frequency               = residualCopy.VitalProductData.ProcessorHz;
    340   BSP_time_base_divisor                 = (residualCopy.VitalProductData.TimeBaseDivisor?
    341                                            residualCopy.VitalProductData.TimeBaseDivisor : 4000);
     426
     427  /*
     428   *  Somehow doing the above seems to clobber SPRG0 on the mvme2100.  It
     429   *  is probably a not so subtle hint that you do not want to use PPCBug
     430   *  once RTEMS is up and running.  Anyway, we still needs to indicate
     431   *  that we have fixed PR288.  Eventually, this should go away.
     432   */
     433  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
     434#endif
     435
     436  BSP_mem_size            = residualCopy.TotalMemory;
     437  BSP_bus_frequency       = residualCopy.VitalProductData.ProcessorBusHz;
     438  BSP_processor_frequency = residualCopy.VitalProductData.ProcessorHz;
     439  BSP_time_base_divisor   = (residualCopy.VitalProductData.TimeBaseDivisor?
     440                    residualCopy.VitalProductData.TimeBaseDivisor : 4000);
    342441
    343442  /* clear hostbridge errors but leave MCP disabled -
     
    355454  pt = BSP_pgtbl_setup(&BSP_mem_size);
    356455
    357   if (!pt ||
    358           TRIV121_MAP_SUCCESS != triv121PgTblMap(
    359                                                                                 pt,
    360                                                                                 TRIV121_121_VSID,
    361                                                                                 0xfeff0000,
    362                                                                                 1,
    363                                                                                 TRIV121_ATTR_IO_PAGE,
    364                                                                                 TRIV121_PP_RW_PAGE
    365                                                                                 )) {
    366         printk("WARNING: unable to setup page tables VME bridge must share PCI space\n");
     456  if (!pt || TRIV121_MAP_SUCCESS != triv121PgTblMap(
     457            pt, TRIV121_121_VSID, 0xfeff0000, 1,
     458            TRIV121_ATTR_IO_PAGE, TRIV121_PP_RW_PAGE)) {
     459        printk("WARNING: unable to setup page tables VME "
     460               "bridge must share PCI space\n");
    367461  }
    368462
     
    381475
    382476#ifdef SHOW_MORE_INIT_SETTINGS
    383   printk("BSP_Configuration.work_space_size = %x\n", BSP_Configuration.work_space_size);
    384 #endif
     477  printk("BSP_Configuration.work_space_size = %x\n",
     478          BSP_Configuration.work_space_size);
     479#endif
     480
    385481  work_space_start =
    386482    (unsigned char *)BSP_mem_size - BSP_Configuration.work_space_size;
    387483
    388   if ( work_space_start <= ((unsigned char *)__rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE) {
     484  if ( work_space_start <=
     485       ((unsigned char *)__rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE) {
    389486    printk( "bspstart: Not enough RAM!!!\n" );
    390487    bsp_cleanup();
     
    407504#endif
    408505    BSP_pgtbl_activate(pt);
    409         /* finally, switch off DBAT3 */
    410         setdbat(3, 0, 0, 0, 0);
     506#if !defined(mvme2100)
     507    /* finally, switch off DBAT3 */
     508    setdbat(3, 0, 0, 0, 0);
     509#endif
    411510  }
    412511
    413512  /*
    414    * Initialize VME bridge - needs working PCI
    415    * and IRQ subsystems...
     513   * Initialize VME bridge - needs working PCI and IRQ subsystems...
    416514   */
    417515#ifdef SHOW_MORE_INIT_SETTINGS
    418516  printk("Going to initialize VME bridge\n");
    419517#endif
    420   /* VME initialization is in a separate file so apps which don't use
    421    * VME or want a different configuration may link against a customized
    422    * routine.
     518  /*
     519   * VME initialization is in a separate file so apps which don't use VME or
     520   * want a different configuration may link against a customized routine.
    423521   */
    424522  BSP_vme_config();
    425523
     524#if defined(DEBUG_BATS)
     525  ShowBATS();
     526#endif
     527
    426528#ifdef SHOW_MORE_INIT_SETTINGS
    427529  printk("Exit from bspstart\n");
Note: See TracChangeset for help on using the changeset viewer.