[574fb67] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup mpc83xx |
---|
| 5 | * |
---|
| 6 | * @brief Source for BSP startup code. |
---|
| 7 | */ |
---|
[f610e83f] | 8 | |
---|
[dfef80e8] | 9 | /* |
---|
[574fb67] | 10 | * Copyright (c) 2008 |
---|
| 11 | * Embedded Brains GmbH |
---|
| 12 | * Obere Lagerstr. 30 |
---|
| 13 | * D-82178 Puchheim |
---|
| 14 | * Germany |
---|
| 15 | * rtems@embedded-brains.de |
---|
| 16 | * |
---|
[e570c313] | 17 | * The license and distribution terms for this file may be |
---|
| 18 | * found in the file LICENSE in this distribution or at |
---|
| 19 | * http://www.rtems.com/license/LICENSE. |
---|
[dfef80e8] | 20 | */ |
---|
| 21 | |
---|
[8a54204] | 22 | #include <libchip/serial.h> |
---|
| 23 | |
---|
[574fb67] | 24 | #include <libcpu/powerpc-utility.h> |
---|
[f610e83f] | 25 | |
---|
[574fb67] | 26 | #include <bsp.h> |
---|
[2d2de4eb] | 27 | #include <bsp/vectors.h> |
---|
[d4886a06] | 28 | #include <bsp/bootcard.h> |
---|
[574fb67] | 29 | #include <bsp/irq-generic.h> |
---|
[ce0922e] | 30 | #include <bsp/u-boot.h> |
---|
[574fb67] | 31 | |
---|
| 32 | /* Configuration parameters for console driver, ... */ |
---|
[42bf1b9] | 33 | unsigned int BSP_bus_frequency; |
---|
[f610e83f] | 34 | |
---|
[8bb00ac] | 35 | /* Configuration parameter for clock driver */ |
---|
| 36 | uint32_t bsp_time_base_frequency; |
---|
| 37 | |
---|
| 38 | /* Legacy */ |
---|
[574fb67] | 39 | uint32_t bsp_clicks_per_usec; |
---|
| 40 | |
---|
[bbbb8f0] | 41 | /* Default decrementer exception handler */ |
---|
| 42 | static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number) |
---|
| 43 | { |
---|
[d9be8024] | 44 | ppc_set_decrementer_register(UINT32_MAX); |
---|
[bbbb8f0] | 45 | |
---|
[d9be8024] | 46 | return 0; |
---|
[bbbb8f0] | 47 | } |
---|
[f610e83f] | 48 | |
---|
[d9be8024] | 49 | void BSP_panic(char *s) |
---|
[574fb67] | 50 | { |
---|
[d9be8024] | 51 | rtems_interrupt_level level; |
---|
[f610e83f] | 52 | |
---|
[d9be8024] | 53 | rtems_interrupt_disable(level); |
---|
[574fb67] | 54 | |
---|
[d9be8024] | 55 | printk("%s PANIC %s\n", rtems_get_version_string(), s); |
---|
[574fb67] | 56 | |
---|
[d9be8024] | 57 | while (1) { |
---|
| 58 | /* Do nothing */ |
---|
| 59 | } |
---|
[574fb67] | 60 | } |
---|
| 61 | |
---|
[d9be8024] | 62 | void _BSP_Fatal_error(unsigned n) |
---|
[f610e83f] | 63 | { |
---|
[d9be8024] | 64 | rtems_interrupt_level level; |
---|
[f610e83f] | 65 | |
---|
[d9be8024] | 66 | rtems_interrupt_disable( level); |
---|
[574fb67] | 67 | |
---|
[d9be8024] | 68 | printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n); |
---|
[574fb67] | 69 | |
---|
[d9be8024] | 70 | while (1) { |
---|
| 71 | /* Do nothing */ |
---|
| 72 | } |
---|
[574fb67] | 73 | } |
---|
| 74 | |
---|
| 75 | void bsp_start( void) |
---|
[f610e83f] | 76 | { |
---|
[d9be8024] | 77 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
[8a54204] | 78 | unsigned long i = 0; |
---|
[bbbb8f0] | 79 | |
---|
[d9be8024] | 80 | ppc_cpu_id_t myCpu; |
---|
| 81 | ppc_cpu_revision_t myCpuRevision; |
---|
[574fb67] | 82 | |
---|
[2d2de4eb] | 83 | uintptr_t interrupt_stack_start = (uintptr_t) bsp_interrupt_stack_start; |
---|
| 84 | uintptr_t interrupt_stack_size = (uintptr_t) bsp_interrupt_stack_size; |
---|
[574fb67] | 85 | |
---|
[d9be8024] | 86 | /* |
---|
| 87 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function |
---|
| 88 | * store the result in global variables so that it can be used latter... |
---|
| 89 | */ |
---|
| 90 | myCpu = get_ppc_cpu_type(); |
---|
| 91 | myCpuRevision = get_ppc_cpu_revision(); |
---|
[574fb67] | 92 | |
---|
[d9be8024] | 93 | /* Basic CPU initialization */ |
---|
| 94 | cpu_init(); |
---|
[574fb67] | 95 | |
---|
[d9be8024] | 96 | /* |
---|
| 97 | * Enable instruction and data caches. Do not force writethrough mode. |
---|
| 98 | */ |
---|
[d3c32136] | 99 | |
---|
[1bb72a9] | 100 | #ifdef BSP_INSTRUCTION_CACHE_ENABLED |
---|
[d9be8024] | 101 | rtems_cache_enable_instruction(); |
---|
[d3c32136] | 102 | #endif |
---|
| 103 | |
---|
[1bb72a9] | 104 | #ifdef BSP_DATA_CACHE_ENABLED |
---|
[d9be8024] | 105 | rtems_cache_enable_data(); |
---|
[d3c32136] | 106 | #endif |
---|
| 107 | |
---|
[d9be8024] | 108 | /* |
---|
| 109 | * This is evaluated during runtime, so it should be ok to set it |
---|
| 110 | * before we initialize the drivers. |
---|
| 111 | */ |
---|
[574fb67] | 112 | |
---|
[d9be8024] | 113 | /* Initialize some device driver parameters */ |
---|
[574fb67] | 114 | |
---|
| 115 | #ifdef HAS_UBOOT |
---|
[f044f9c] | 116 | BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq; |
---|
[574fb67] | 117 | #else /* HAS_UBOOT */ |
---|
[d9be8024] | 118 | BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID; |
---|
[574fb67] | 119 | #endif /* HAS_UBOOT */ |
---|
[8bb00ac] | 120 | bsp_time_base_frequency = BSP_bus_frequency / 4; |
---|
| 121 | bsp_clicks_per_usec = bsp_time_base_frequency / 1000000; |
---|
[574fb67] | 122 | |
---|
[8a54204] | 123 | /* Initialize some console parameters */ |
---|
[c988f180] | 124 | for (i = 0; i < Console_Configuration_Count; ++i) { |
---|
[3bb9f198] | 125 | Console_Configuration_Ports [i].ulClock = BSP_bus_frequency; |
---|
[8a54204] | 126 | |
---|
| 127 | #ifdef HAS_UBOOT |
---|
[3bb9f198] | 128 | Console_Configuration_Ports [i].pDeviceParams = |
---|
[8a54204] | 129 | (void *) bsp_uboot_board_info.bi_baudrate; |
---|
| 130 | #endif |
---|
| 131 | } |
---|
| 132 | |
---|
[d9be8024] | 133 | /* Initialize exception handler */ |
---|
[1bb72a9] | 134 | #ifndef BSP_DATA_CACHE_ENABLED |
---|
| 135 | ppc_exc_cache_wb_check = 0; |
---|
| 136 | #endif |
---|
[2d2de4eb] | 137 | sc = ppc_exc_initialize( |
---|
[d9be8024] | 138 | PPC_INTERRUPT_DISABLE_MASK_DEFAULT, |
---|
| 139 | interrupt_stack_start, |
---|
| 140 | interrupt_stack_size |
---|
| 141 | ); |
---|
[2d2de4eb] | 142 | if (sc != RTEMS_SUCCESSFUL) { |
---|
| 143 | BSP_panic("cannot initialize exceptions"); |
---|
| 144 | } |
---|
[d9be8024] | 145 | |
---|
| 146 | /* Install default handler for the decrementer exception */ |
---|
[2d2de4eb] | 147 | sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler); |
---|
| 148 | if (sc != RTEMS_SUCCESSFUL) { |
---|
| 149 | BSP_panic("cannot install decrementer exception handler"); |
---|
[d9be8024] | 150 | } |
---|
| 151 | |
---|
| 152 | /* Initalize interrupt support */ |
---|
| 153 | sc = bsp_interrupt_initialize(); |
---|
| 154 | if (sc != RTEMS_SUCCESSFUL) { |
---|
[2d2de4eb] | 155 | BSP_panic("cannot intitialize interrupts\n"); |
---|
[d9be8024] | 156 | } |
---|
[f610e83f] | 157 | |
---|
| 158 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
[d9be8024] | 159 | printk("Exit from bspstart\n"); |
---|
[f610e83f] | 160 | #endif |
---|
[574fb67] | 161 | } |
---|