Ignore:
Timestamp:
Aug 21, 2008, 4:16:47 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
cec5c069
Parents:
d79a27be
Message:

2008-08-21 Joel Sherrill <joel.sherrill@…>

  • Makefile.am: Added bspclean.c and use shared bsppretaskinghook.c.
  • console/console.c: Added poll for char helper.
  • include/bsp.h: Add macro definitions for optional reset behavior.
  • startup/bspstart.c: Split out bsp_cleanup(). Clean up.
  • startup/bspclean.c: New file. Not can press any key on normal shutdown to reset board when on MPC8313erdb.
File:
1 edited

Legend:

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

    rd79a27be rd9be8024  
    5757static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
    5858{
    59         ppc_set_decrementer_register( UINT32_MAX);
    60 
    61         return 0;
    62 }
    63 
    64 void BSP_panic( char *s)
    65 {
    66         rtems_interrupt_level level;
    67 
    68         rtems_interrupt_disable( level);
    69 
    70         printk( "%s PANIC %s\n", _RTEMS_version, s);
    71 
    72         while (1) {
    73                 /* Do nothing */
    74         }
    75 }
    76 
    77 void _BSP_Fatal_error( unsigned n)
    78 {
    79         rtems_interrupt_level level;
    80 
    81         rtems_interrupt_disable( level);
    82 
    83         printk( "%s PANIC ERROR %u\n", _RTEMS_version, n);
    84 
    85         while (1) {
    86                 /* Do nothing */
    87         }
    88 }
    89 
    90 void bsp_pretasking_hook( void)
    91 {
    92         /* Do noting */
    93 }
    94 
    95 void bsp_get_work_area( void **work_area_start, size_t *work_area_size, void **heap_start, size_t *heap_size)
     59  ppc_set_decrementer_register(UINT32_MAX);
     60
     61  return 0;
     62}
     63
     64void BSP_panic(char *s)
     65{
     66  rtems_interrupt_level level;
     67
     68  rtems_interrupt_disable(level);
     69
     70  printk("%s PANIC %s\n", rtems_get_version_string(), s);
     71
     72  while (1) {
     73    /* Do nothing */
     74  }
     75}
     76
     77void _BSP_Fatal_error(unsigned n)
     78{
     79  rtems_interrupt_level level;
     80
     81  rtems_interrupt_disable( level);
     82
     83  printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
     84
     85  while (1) {
     86    /* Do nothing */
     87  }
     88}
     89
     90void bsp_get_work_area(
     91  void   **work_area_start,
     92  size_t  *work_area_size,
     93  void   **heap_start,
     94  size_t  *heap_size)
    9695{
    9796#ifdef HAS_UBOOT
    98         char *ram_end = (char *) mpc83xx_uboot_board_info.bi_memstart + mpc83xx_uboot_board_info.bi_memsize;
     97  char *ram_end = (char *) mpc83xx_uboot_board_info.bi_memstart +
     98                                 mpc83xx_uboot_board_info.bi_memsize;
    9999#else /* HAS_UBOOT */
    100         char *ram_end = bsp_ram_end;
     100  char *ram_end = bsp_ram_end;
    101101#endif /* HAS_UBOOT */
    102102
    103         *work_area_start = bsp_work_area_start;
    104         *work_area_size = ram_end - bsp_work_area_start;
    105         *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
    106         *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
     103  *work_area_start = bsp_work_area_start;
     104  *work_area_size = ram_end - bsp_work_area_start;
     105  *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
     106  *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
    107107}
    108108
    109109void bsp_start( void)
    110110{
    111         rtems_status_code sc = RTEMS_SUCCESSFUL;
    112         int rv = 0;
    113 
    114         ppc_cpu_id_t myCpu;
    115         ppc_cpu_revision_t myCpuRevision;
    116 
    117         uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start;
    118         uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size;
    119 
    120         /*
    121         * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
    122         * store the result in global variables so that it can be used latter...
    123         */
    124         myCpu = get_ppc_cpu_type();
    125         myCpuRevision = get_ppc_cpu_revision();
    126 
    127         /* Basic CPU initialization */
    128         cpu_init();
    129 
    130         /*
    131         * Enable instruction and data caches. Do not force writethrough mode.
    132         */
     111  rtems_status_code sc = RTEMS_SUCCESSFUL;
     112  int rv = 0;
     113
     114  ppc_cpu_id_t myCpu;
     115  ppc_cpu_revision_t myCpuRevision;
     116
     117  uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start;
     118  uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size;
     119
     120  /*
     121  * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
     122  * store the result in global variables so that it can be used latter...
     123  */
     124  myCpu = get_ppc_cpu_type();
     125  myCpuRevision = get_ppc_cpu_revision();
     126
     127  /* Basic CPU initialization */
     128  cpu_init();
     129
     130  /*
     131  * Enable instruction and data caches. Do not force writethrough mode.
     132  */
    133133
    134134#if INSTRUCTION_CACHE_ENABLE
    135         rtems_cache_enable_instruction();
     135  rtems_cache_enable_instruction();
    136136#endif
    137137
    138138#if DATA_CACHE_ENABLE
    139         rtems_cache_enable_data();
     139  rtems_cache_enable_data();
    140140#endif
    141141
    142         /*
    143         * This is evaluated during runtime, so it should be ok to set it
    144         * before we initialize the drivers.
    145         */
    146 
    147         /* Initialize some device driver parameters */
     142  /*
     143  * This is evaluated during runtime, so it should be ok to set it
     144  * before we initialize the drivers.
     145  */
     146
     147  /* Initialize some device driver parameters */
    148148
    149149#ifdef HAS_UBOOT
    150         BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq;
    151         bsp_clicks_per_usec = mpc83xx_uboot_board_info.bi_intfreq / 8000000;
     150  BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq;
     151  bsp_clicks_per_usec = mpc83xx_uboot_board_info.bi_intfreq / 8000000;
    152152#else /* HAS_UBOOT */
    153         BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
    154         bsp_clicks_per_usec = BSP_bus_frequency / 1000000;
     153  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
     154  bsp_clicks_per_usec = BSP_bus_frequency / 1000000;
    155155#endif /* HAS_UBOOT */
    156156
    157         /* Initialize exception handler */
    158         ppc_exc_initialize(
    159                 PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
    160                 interrupt_stack_start,
    161                 interrupt_stack_size
    162         );
    163 
    164         /* Install default handler for the decrementer exception */
    165         rv = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
    166         if (rv < 0) {
    167                 BSP_panic( "Cannot install decrementer exception handler!\n");
    168         }
    169 
    170         /* Initalize interrupt support */
    171         sc = bsp_interrupt_initialize();
    172         if (sc != RTEMS_SUCCESSFUL) {
    173                 BSP_panic( "Cannot intitialize interrupt support\n");
    174         }
     157  /* Initialize exception handler */
     158  ppc_exc_initialize(
     159    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
     160    interrupt_stack_start,
     161    interrupt_stack_size
     162  );
     163
     164  /* Install default handler for the decrementer exception */
     165  rv = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
     166  if (rv < 0) {
     167    BSP_panic( "Cannot install decrementer exception handler!\n");
     168  }
     169
     170  /* Initalize interrupt support */
     171  sc = bsp_interrupt_initialize();
     172  if (sc != RTEMS_SUCCESSFUL) {
     173    BSP_panic( "Cannot intitialize interrupt support\n");
     174  }
    175175
    176176#ifdef SHOW_MORE_INIT_SETTINGS
    177         printk("Exit from bspstart\n");
     177  printk("Exit from bspstart\n");
    178178#endif
    179179}
     
    189189{
    190190
    191         while (1) {
    192                 asm volatile (
    193                         "mfmsr 3;"
    194                         "oris 3, 3, 4;"
    195                         "sync;"
    196                         "mtmsr 3;"
    197                         "isync;"
    198                         "ori 3, 3, 0;"
    199                         "ori 3, 3, 0"
    200                 );
    201         }
    202 
    203         return NULL;
    204 }
    205 
    206 void bsp_cleanup( void)
    207 {
    208 #ifdef MPC8313ERDB
    209 
    210         /* Set Reset Protection Register (RPR) to "RSTE" */
    211         mpc83xx.res.rpr = 0x52535445;
    212 
    213         /*
    214          * Wait for Control Register Enabled in the
    215          * Reset Control Enable Register (RCER).
    216          */
    217         while (mpc83xx.res.rcer != 0x00000001) {
    218                 /* Wait */
    219         }
    220 
    221         /* Set Software Hard Reset in the Reset Control Register (RCR) */
    222         mpc83xx.res.rcr = 0x00000002;
    223 
    224 #else /* MPC8313ERDB */
    225 
    226         /* Do nothing */
    227 
    228 #endif /* MPC8313ERDB */
    229 }
     191  while (1) {
     192    asm volatile (
     193      "mfmsr 3;"
     194      "oris 3, 3, 4;"
     195      "sync;"
     196      "mtmsr 3;"
     197      "isync;"
     198      "ori 3, 3, 0;"
     199      "ori 3, 3, 0"
     200    );
     201  }
     202
     203  return NULL;
     204}
Note: See TracChangeset for help on using the changeset viewer.