[ca680bc5] | 1 | /*===============================================================*\ |
---|
| 2 | | Project: RTEMS generic MPC5200 BSP | |
---|
| 3 | +-----------------------------------------------------------------+ |
---|
| 4 | | Partially based on the code references which are named below. | |
---|
| 5 | | Adaptions, modifications, enhancements and any recent parts of | |
---|
| 6 | | the code are: | |
---|
| 7 | | Copyright (c) 2005 | |
---|
| 8 | | Embedded Brains GmbH | |
---|
| 9 | | Obere Lagerstr. 30 | |
---|
| 10 | | D-82178 Puchheim | |
---|
| 11 | | Germany | |
---|
| 12 | | rtems@embedded-brains.de | |
---|
| 13 | +-----------------------------------------------------------------+ |
---|
| 14 | | The license and distribution terms for this file may be | |
---|
| 15 | | found in the file LICENSE in this distribution or at | |
---|
| 16 | | | |
---|
| 17 | | http://www.rtems.com/license/LICENSE. | |
---|
| 18 | | | |
---|
| 19 | +-----------------------------------------------------------------+ |
---|
| 20 | | this file contains the BSP initialization code | |
---|
| 21 | \*===============================================================*/ |
---|
| 22 | /***********************************************************************/ |
---|
| 23 | /* */ |
---|
| 24 | /* Module: bspstart.c */ |
---|
| 25 | /* Date: 07/17/2003 */ |
---|
| 26 | /* Purpose: RTEMS MPC5x00 C level startup code */ |
---|
| 27 | /* */ |
---|
| 28 | /*---------------------------------------------------------------------*/ |
---|
| 29 | /* */ |
---|
| 30 | /* Description: This routine starts the application. It includes */ |
---|
| 31 | /* application, board, and monitor specific */ |
---|
| 32 | /* initialization and configuration. The generic CPU */ |
---|
| 33 | /* dependent initialization has been performed before */ |
---|
| 34 | /* this routine is invoked. */ |
---|
| 35 | /* */ |
---|
| 36 | /*---------------------------------------------------------------------*/ |
---|
| 37 | /* */ |
---|
| 38 | /* Code */ |
---|
| 39 | /* References: MPC8260ads C level startup code */ |
---|
| 40 | /* Module: bspstart.c */ |
---|
| 41 | /* Project: RTEMS 4.6.0pre1 / MCF8260ads BSP */ |
---|
| 42 | /* Version 1.2 */ |
---|
| 43 | /* Date: 04/17/2002 */ |
---|
| 44 | /* */ |
---|
| 45 | /* Author(s) / Copyright(s): */ |
---|
| 46 | /* */ |
---|
| 47 | /* The MPC860 specific stuff was written by Jay Monkman */ |
---|
| 48 | /* (jmonkman@frasca.com) */ |
---|
| 49 | /* */ |
---|
| 50 | /* Modified for the MPC8260ADS board by Andy Dachs */ |
---|
| 51 | /* <a.dachs@sstl.co.uk> */ |
---|
| 52 | /* Surrey Satellite Technology Limited, 2001 */ |
---|
| 53 | /* A 40MHz system clock is assumed. */ |
---|
| 54 | /* The PON. RST.CONF. Dip switches (DS1) are */ |
---|
| 55 | /* 1 - Off */ |
---|
| 56 | /* 2 - On */ |
---|
| 57 | /* 3 - Off */ |
---|
| 58 | /* 4 - On */ |
---|
| 59 | /* 5 - Off */ |
---|
| 60 | /* 6 - Off */ |
---|
| 61 | /* 7 - Off */ |
---|
| 62 | /* 8 - Off */ |
---|
| 63 | /* Dip switches on DS2 and DS3 are all set to ON */ |
---|
| 64 | /* The LEDs on the board are used to signal panic and fatal_error */ |
---|
| 65 | /* conditions. */ |
---|
| 66 | /* The mmu is unused at this time. */ |
---|
| 67 | /* */ |
---|
[eabd9f0] | 68 | /* COPYRIGHT (c) 1989-2007. */ |
---|
[ca680bc5] | 69 | /* On-Line Applications Research Corporation (OAR). */ |
---|
| 70 | /* */ |
---|
| 71 | /* The license and distribution terms for this file may be */ |
---|
| 72 | /* found in found in the file LICENSE in this distribution or at */ |
---|
[eabd9f0] | 73 | /* http://www.rtems.com/license/LICENSE. */ |
---|
[ca680bc5] | 74 | /* */ |
---|
| 75 | /*---------------------------------------------------------------------*/ |
---|
| 76 | /* */ |
---|
| 77 | /* Partially based on the code references which are named above. */ |
---|
| 78 | /* Adaptions, modifications, enhancements and any recent parts of */ |
---|
| 79 | /* the code are under the right of */ |
---|
| 80 | /* */ |
---|
[1af911b8] | 81 | /* IPR Engineering, Dachauer StraÃe 38, D-80335 MÃŒnchen */ |
---|
[ca680bc5] | 82 | /* Copyright(C) 2003 */ |
---|
| 83 | /* */ |
---|
| 84 | /*---------------------------------------------------------------------*/ |
---|
| 85 | /* */ |
---|
| 86 | /* IPR Engineering makes no representation or warranties with */ |
---|
| 87 | /* respect to the performance of this computer program, and */ |
---|
| 88 | /* specifically disclaims any responsibility for any damages, */ |
---|
| 89 | /* special or consequential, connected with the use of this program. */ |
---|
| 90 | /* */ |
---|
| 91 | /*---------------------------------------------------------------------*/ |
---|
| 92 | /* */ |
---|
| 93 | /* Version history: 1.0 */ |
---|
| 94 | /* */ |
---|
| 95 | /***********************************************************************/ |
---|
| 96 | |
---|
[a86f3aac] | 97 | #warning The interrupt disable mask is now stored in SPRG0, please verify that this is compatible to this BSP (see also bootcard.c). |
---|
| 98 | |
---|
[1c79f01] | 99 | #include <rtems.h> |
---|
[82bd8d9d] | 100 | #include <libcpu/powerpc-utility.h> |
---|
| 101 | #include <libcpu/raw_exception.h> |
---|
[ca680bc5] | 102 | |
---|
[82bd8d9d] | 103 | #include <bsp.h> |
---|
| 104 | #include <bsp/bootcard.h> |
---|
| 105 | #include <bsp/ppc_exc_bspsupp.h> |
---|
| 106 | |
---|
| 107 | #include <bsp/irq.h> |
---|
[ca680bc5] | 108 | |
---|
| 109 | #if defined(HAS_UBOOT) |
---|
[144ad33] | 110 | /* will be overwritten from startup code */ |
---|
| 111 | bd_t *bsp_uboot_board_info_ptr = (bd_t *)1; |
---|
| 112 | /* will be overwritten with copy of board information */ |
---|
| 113 | bd_t bsp_uboot_board_info; |
---|
[ca680bc5] | 114 | #endif |
---|
| 115 | |
---|
[62577f9] | 116 | /* |
---|
| 117 | * Driver configuration parameters |
---|
| 118 | */ |
---|
| 119 | uint32_t bsp_clicks_per_usec; |
---|
[ca680bc5] | 120 | |
---|
| 121 | void BSP_panic(char *s) |
---|
[379a4761] | 122 | { |
---|
[ca680bc5] | 123 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
| 124 | __asm__ __volatile ("sc"); |
---|
[379a4761] | 125 | } |
---|
[ca680bc5] | 126 | |
---|
| 127 | void _BSP_Fatal_error(unsigned int v) |
---|
[379a4761] | 128 | { |
---|
[ca680bc5] | 129 | printk("%s PANIC ERROR %x\n",_RTEMS_version, v); |
---|
| 130 | __asm__ __volatile ("sc"); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | void bsp_start(void) |
---|
| 134 | { |
---|
| 135 | ppc_cpu_id_t myCpu; |
---|
| 136 | ppc_cpu_revision_t myCpuRevision; |
---|
| 137 | |
---|
| 138 | /* |
---|
[6826a4c] | 139 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() |
---|
| 140 | * function store the result in global variables so that it can be used |
---|
| 141 | * later... |
---|
[ca680bc5] | 142 | */ |
---|
[7da3405] | 143 | myCpu = get_ppc_cpu_type(); |
---|
[ca680bc5] | 144 | myCpuRevision = get_ppc_cpu_revision(); |
---|
| 145 | |
---|
[6826a4c] | 146 | #if defined(HAS_UBOOT) |
---|
[144ad33] | 147 | bsp_uboot_board_info = *bsp_uboot_board_info_ptr; |
---|
[6826a4c] | 148 | #endif |
---|
[7da3405] | 149 | |
---|
[6826a4c] | 150 | #if defined(HAS_UBOOT) && defined(SHOW_MORE_INIT_SETTINGS) |
---|
| 151 | { |
---|
| 152 | void dumpUBootBDInfo( bd_t * ); |
---|
[144ad33] | 153 | dumpUBootBDInfo( bsp_uboot_board_info_ptr ); |
---|
[6826a4c] | 154 | } |
---|
| 155 | #endif |
---|
[7da3405] | 156 | |
---|
[ca680bc5] | 157 | cpu_init(); |
---|
| 158 | |
---|
[87b9739] | 159 | bsp_clicks_per_usec = (IPB_CLOCK/1000000); |
---|
[62577f9] | 160 | |
---|
[ca680bc5] | 161 | /* |
---|
| 162 | * Enable instruction and data caches. Do not force writethrough mode. |
---|
| 163 | */ |
---|
[6826a4c] | 164 | #if INSTRUCTION_CACHE_ENABLE |
---|
| 165 | rtems_cache_enable_instruction(); |
---|
| 166 | #endif |
---|
| 167 | #if DATA_CACHE_ENABLE |
---|
| 168 | rtems_cache_enable_data(); |
---|
| 169 | #endif |
---|
[ca680bc5] | 170 | |
---|
[82bd8d9d] | 171 | /* Initialize exception handler */ |
---|
| 172 | ppc_exc_cache_wb_check = 0; |
---|
| 173 | ppc_exc_initialize( |
---|
| 174 | PPC_INTERRUPT_DISABLE_MASK_DEFAULT, |
---|
| 175 | (uint32_t) bsp_interrupt_stack_start, |
---|
| 176 | (uint32_t) bsp_interrupt_stack_size |
---|
| 177 | ); |
---|
| 178 | |
---|
| 179 | /* Initalize interrupt support */ |
---|
| 180 | if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) { |
---|
| 181 | BSP_panic( "Cannot intitialize interrupt support\n"); |
---|
| 182 | } |
---|
[ca680bc5] | 183 | |
---|
[6826a4c] | 184 | /* |
---|
| 185 | * If the BSP was built with IRQ benchmarking enabled, |
---|
| 186 | * then intialize it. |
---|
| 187 | */ |
---|
| 188 | #if (BENCHMARK_IRQ_PROCESSING == 1) |
---|
| 189 | BSP_IRQ_Benchmarking_Reset(); |
---|
| 190 | #endif |
---|
[5023c874] | 191 | |
---|
[6826a4c] | 192 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
| 193 | printk("Exit from bspstart\n"); |
---|
| 194 | #endif |
---|
| 195 | } |
---|
[ca680bc5] | 196 | |
---|
| 197 | /* |
---|
| 198 | * |
---|
[eef91af] | 199 | * bsp_idle_thread |
---|
[ca680bc5] | 200 | * |
---|
| 201 | * Replaces the one in c/src/exec/score/src/threadidlebody.c |
---|
| 202 | * The MSR[POW] bit is set to put the CPU into the low power mode |
---|
| 203 | * defined in HID0. HID0 is set during starup in start.S. |
---|
| 204 | * |
---|
| 205 | */ |
---|
[eef91af] | 206 | void *bsp_idle_thread( uintptr_t ignored ) |
---|
[5023c874] | 207 | { |
---|
| 208 | for(;;) { |
---|
| 209 | asm volatile( |
---|
| 210 | "mfmsr 3; oris 3,3,4; sync; mtmsr 3; isync; ori 3,3,0; ori 3,3,0" |
---|
| 211 | ); |
---|
[ca680bc5] | 212 | } |
---|
[5023c874] | 213 | return 0; |
---|
| 214 | } |
---|