[e21c287c] | 1 | /* |
---|
[7078a00b] | 2 | * Copyright (c) 2012, 2017 embedded brains GmbH. All rights reserved. |
---|
[e21c287c] | 3 | * |
---|
| 4 | * embedded brains GmbH |
---|
[b7cd6d51] | 5 | * Dornierstr. 4 |
---|
[e21c287c] | 6 | * 82178 Puchheim |
---|
| 7 | * Germany |
---|
| 8 | * <rtems@embedded-brains.de> |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 12 | * http://www.rtems.org/license/LICENSE. |
---|
[e21c287c] | 13 | */ |
---|
| 14 | |
---|
| 15 | #include <rtems/config.h> |
---|
[24bf11e] | 16 | #include <rtems/counter.h> |
---|
[e21c287c] | 17 | |
---|
| 18 | #include <bsp.h> |
---|
| 19 | #include <bsp/vectors.h> |
---|
| 20 | #include <bsp/bootcard.h> |
---|
| 21 | #include <bsp/irq-generic.h> |
---|
| 22 | #include <bsp/linker-symbols.h> |
---|
| 23 | |
---|
| 24 | LINKER_SYMBOL(bsp_exc_vector_base); |
---|
| 25 | |
---|
| 26 | /* |
---|
| 27 | * Configuration parameter for clock driver. The Trace32 PowerPC simulator has |
---|
| 28 | * an odd decrementer frequency. The time base frequency is one tick per |
---|
| 29 | * instruction. The decrementer frequency is one tick per ten instructions. |
---|
| 30 | * The clock driver assumes that the time base and decrementer frequencies are |
---|
| 31 | * equal. For now we simulate processor that issues 10000000 instructions per |
---|
| 32 | * second. |
---|
| 33 | */ |
---|
[7078a00b] | 34 | uint32_t bsp_time_base_frequency = 10000000; |
---|
[e21c287c] | 35 | |
---|
| 36 | void BSP_panic(char *s) |
---|
| 37 | { |
---|
| 38 | rtems_interrupt_level level; |
---|
| 39 | |
---|
[585706a4] | 40 | rtems_interrupt_local_disable(level); |
---|
[b7cd6d51] | 41 | (void) level; |
---|
[e21c287c] | 42 | |
---|
| 43 | printk("%s PANIC %s\n", rtems_get_version_string(), s); |
---|
| 44 | |
---|
| 45 | while (1) { |
---|
| 46 | /* Do nothing */ |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | void _BSP_Fatal_error(unsigned n) |
---|
| 51 | { |
---|
| 52 | rtems_interrupt_level level; |
---|
| 53 | |
---|
[585706a4] | 54 | rtems_interrupt_local_disable(level); |
---|
[b7cd6d51] | 55 | (void) level; |
---|
[e21c287c] | 56 | |
---|
| 57 | printk("%s PANIC ERROR %u\n", rtems_get_version_string(), n); |
---|
| 58 | |
---|
| 59 | while (1) { |
---|
| 60 | /* Do nothing */ |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
[7078a00b] | 64 | #define MTIVPR(base) \ |
---|
| 65 | __asm__ volatile ("mtivpr %0" : : "r" (base)) |
---|
| 66 | |
---|
| 67 | #define VECTOR_TABLE_ENTRY_SIZE 16 |
---|
| 68 | |
---|
| 69 | #define MTIVOR(vec, offset) \ |
---|
| 70 | do { \ |
---|
| 71 | __asm__ volatile ("mtspr " RTEMS_XSTRING(vec) ", %0" : : "r" (offset)); \ |
---|
| 72 | offset += VECTOR_TABLE_ENTRY_SIZE; \ |
---|
| 73 | } while (0) |
---|
| 74 | |
---|
| 75 | static void t32mppc_initialize_exceptions(void *interrupt_stack_begin) |
---|
| 76 | { |
---|
| 77 | uintptr_t addr; |
---|
| 78 | |
---|
| 79 | ppc_exc_initialize_interrupt_stack( |
---|
| 80 | (uintptr_t) interrupt_stack_begin, |
---|
| 81 | rtems_configuration_get_interrupt_stack_size() |
---|
| 82 | ); |
---|
| 83 | |
---|
| 84 | addr = (uintptr_t) bsp_exc_vector_base; |
---|
| 85 | MTIVPR(addr); |
---|
| 86 | MTIVOR(BOOKE_IVOR0, addr); |
---|
| 87 | MTIVOR(BOOKE_IVOR1, addr); |
---|
| 88 | MTIVOR(BOOKE_IVOR2, addr); |
---|
| 89 | MTIVOR(BOOKE_IVOR3, addr); |
---|
| 90 | MTIVOR(BOOKE_IVOR4, addr); |
---|
| 91 | MTIVOR(BOOKE_IVOR5, addr); |
---|
| 92 | MTIVOR(BOOKE_IVOR6, addr); |
---|
| 93 | MTIVOR(BOOKE_IVOR7, addr); |
---|
| 94 | MTIVOR(BOOKE_IVOR8, addr); |
---|
| 95 | MTIVOR(BOOKE_IVOR9, addr); |
---|
| 96 | MTIVOR(BOOKE_IVOR10, addr); |
---|
| 97 | MTIVOR(BOOKE_IVOR11, addr); |
---|
| 98 | MTIVOR(BOOKE_IVOR12, addr); |
---|
| 99 | MTIVOR(BOOKE_IVOR13, addr); |
---|
| 100 | MTIVOR(BOOKE_IVOR14, addr); |
---|
| 101 | MTIVOR(BOOKE_IVOR15, addr); |
---|
| 102 | MTIVOR(BOOKE_IVOR32, addr); |
---|
| 103 | MTIVOR(BOOKE_IVOR33, addr); |
---|
| 104 | MTIVOR(BOOKE_IVOR34, addr); |
---|
| 105 | MTIVOR(BOOKE_IVOR35, addr); |
---|
| 106 | } |
---|
| 107 | |
---|
[e21c287c] | 108 | void bsp_start(void) |
---|
| 109 | { |
---|
| 110 | get_ppc_cpu_type(); |
---|
| 111 | get_ppc_cpu_revision(); |
---|
| 112 | |
---|
[24bf11e] | 113 | rtems_counter_initialize_converter(bsp_time_base_frequency); |
---|
| 114 | |
---|
[7078a00b] | 115 | t32mppc_initialize_exceptions(bsp_section_work_begin); |
---|
[dd8df59] | 116 | bsp_interrupt_initialize(); |
---|
[e21c287c] | 117 | } |
---|