[862c2317] | 1 | /* bsp_start() |
---|
| 2 | * |
---|
| 3 | * This routine starts the application. It includes application, |
---|
| 4 | * board, and monitor specific initialization and configuration. |
---|
| 5 | * The generic CPU dependent initialization has been performed |
---|
| 6 | * before this routine is invoked. |
---|
| 7 | * |
---|
| 8 | * INPUT: NONE |
---|
| 9 | * |
---|
| 10 | * OUTPUT: NONE |
---|
| 11 | * |
---|
| 12 | * Author: Thomas Doerfler <td@imd.m.isar.de> |
---|
| 13 | * IMD Ingenieurbuero fuer Microcomputertechnik |
---|
| 14 | * |
---|
| 15 | * COPYRIGHT (c) 1998 by IMD |
---|
| 16 | * |
---|
| 17 | * Changes from IMD are covered by the original distributions terms. |
---|
| 18 | * This file has been derived from the papyrus BSP: |
---|
| 19 | * |
---|
| 20 | * Author: Andrew Bray <andy@i-cubed.co.uk> |
---|
| 21 | * |
---|
| 22 | * COPYRIGHT (c) 1995 by i-cubed ltd. |
---|
| 23 | * |
---|
| 24 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
| 25 | * without any express or implied warranty: |
---|
| 26 | * permission to use, copy, modify, and distribute this file |
---|
| 27 | * for any purpose is hereby granted without fee, provided that |
---|
| 28 | * the above copyright notice and this notice appears in all |
---|
| 29 | * copies, and that the name of i-cubed limited not be used in |
---|
| 30 | * advertising or publicity pertaining to distribution of the |
---|
| 31 | * software without specific, written prior permission. |
---|
| 32 | * i-cubed limited makes no representations about the suitability |
---|
| 33 | * of this software for any purpose. |
---|
| 34 | * |
---|
| 35 | * Modifications for spooling console driver and control of memory layout |
---|
| 36 | * with linker command file by |
---|
| 37 | * Thomas Doerfler <td@imd.m.isar.de> |
---|
| 38 | * for these modifications: |
---|
| 39 | * COPYRIGHT (c) 1997 by IMD, Puchheim, Germany. |
---|
| 40 | * |
---|
| 41 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
| 42 | * without any express or implied warranty: |
---|
| 43 | * permission to use, copy, modify, and distribute this file |
---|
| 44 | * for any purpose is hereby granted without fee, provided that |
---|
| 45 | * the above copyright notice and this notice appears in all |
---|
| 46 | * copies. IMD makes no representations about the suitability |
---|
| 47 | * of this software for any purpose. |
---|
| 48 | * |
---|
| 49 | * Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c: |
---|
| 50 | * |
---|
| 51 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 52 | * On-Line Applications Research Corporation (OAR). |
---|
| 53 | * |
---|
| 54 | * Modifications for PPC405GP by Dennis Ehlin |
---|
| 55 | */ |
---|
[a86f3aac] | 56 | |
---|
[862c2317] | 57 | #include <string.h> |
---|
| 58 | #include <fcntl.h> |
---|
| 59 | |
---|
| 60 | #include <bsp.h> |
---|
| 61 | #include <bsp/irq.h> |
---|
[0ba2736] | 62 | #include <bsp/linker-symbols.h> |
---|
[862c2317] | 63 | #include <rtems/bspIo.h> |
---|
| 64 | #include <libcpu/cpuIdent.h> |
---|
| 65 | #include <libcpu/spr.h> |
---|
| 66 | #include <rtems/powerpc/powerpc.h> |
---|
| 67 | |
---|
| 68 | #include RTEMS_XPARAMETERS_H |
---|
| 69 | #include <stdio.h> |
---|
| 70 | |
---|
[0ba2736] | 71 | /* Symbols defined in linker command file */ |
---|
| 72 | LINKER_SYMBOL(virtex_exc_vector_base); |
---|
| 73 | |
---|
[07e9642c] | 74 | /* |
---|
| 75 | * Driver configuration parameters |
---|
| 76 | */ |
---|
| 77 | uint32_t bsp_clicks_per_usec; |
---|
| 78 | uint32_t bsp_serial_per_sec; /* Serial clocks per second */ |
---|
[39d08d55] | 79 | bool bsp_serial_external_clock; |
---|
| 80 | bool bsp_serial_xon_xoff; |
---|
| 81 | bool bsp_serial_cts_rts; |
---|
[07e9642c] | 82 | uint32_t bsp_serial_rate; |
---|
| 83 | uint32_t bsp_timer_average_overhead; /* Average overhead of timer in ticks */ |
---|
| 84 | uint32_t bsp_timer_least_valid; /* Least valid number from timer */ |
---|
[39d08d55] | 85 | bool bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ |
---|
[07e9642c] | 86 | |
---|
[862c2317] | 87 | /* Initialize whatever libc we are using |
---|
| 88 | * called from postdriver hook |
---|
| 89 | */ |
---|
| 90 | |
---|
| 91 | void bsp_XAssertHandler(const char* file, int line); |
---|
| 92 | |
---|
| 93 | void bsp_XAssertHandler(const char* file, int line) { |
---|
| 94 | printf("\n***\n*** XAssert Failed! File: %s, Line: %d\n***\n", file, line); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /* |
---|
| 98 | * bsp_start |
---|
| 99 | * |
---|
| 100 | * This routine does the bulk of the system initialization. |
---|
| 101 | */ |
---|
| 102 | void bsp_start( void ) |
---|
| 103 | { |
---|
| 104 | /* |
---|
[ac7af4a] | 105 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() |
---|
| 106 | * function store the result in global variables |
---|
[862c2317] | 107 | * so that it can be used latter... |
---|
| 108 | */ |
---|
| 109 | myCpu = get_ppc_cpu_type(); |
---|
| 110 | myCpuRevision = get_ppc_cpu_revision(); |
---|
[d34d8692] | 111 | |
---|
[862c2317] | 112 | /* |
---|
[d34d8692] | 113 | * initialize the device driver parameters |
---|
[862c2317] | 114 | */ |
---|
| 115 | |
---|
| 116 | /* timebase register ticks/microsecond */ |
---|
[07e9642c] | 117 | bsp_clicks_per_usec = (250000000 / 1000000); |
---|
| 118 | bsp_serial_per_sec = 14625000; |
---|
[39d08d55] | 119 | bsp_serial_external_clock = false; |
---|
| 120 | bsp_timer_internal_clock = true; |
---|
| 121 | bsp_serial_xon_xoff = false; |
---|
| 122 | bsp_serial_cts_rts = false; |
---|
[07e9642c] | 123 | bsp_serial_rate = 115200; |
---|
| 124 | bsp_timer_average_overhead = 2; |
---|
| 125 | bsp_timer_least_valid = 3; |
---|
[862c2317] | 126 | |
---|
| 127 | /* |
---|
[ac7af4a] | 128 | * Initialize default raw exception handlers. |
---|
[862c2317] | 129 | */ |
---|
[0ba2736] | 130 | ppc_exc_initialize_with_vector_base( |
---|
[2d2de4eb] | 131 | PPC_INTERRUPT_DISABLE_MASK_DEFAULT, |
---|
[0ba2736] | 132 | (uintptr_t) bsp_section_work_begin, |
---|
| 133 | rtems_configuration_get_interrupt_stack_size(), |
---|
| 134 | virtex_exc_vector_base |
---|
[336495b9] | 135 | ); |
---|
[0ba2736] | 136 | __asm__ volatile ("mtevpr %0" : : "r" (virtex_exc_vector_base)); |
---|
[862c2317] | 137 | |
---|
| 138 | /* |
---|
| 139 | * Install our own set of exception vectors |
---|
| 140 | */ |
---|
| 141 | BSP_rtems_irq_mng_init(0); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | void BSP_ask_for_reset(void) |
---|
| 145 | { |
---|
| 146 | printk("system stopped, press RESET"); |
---|
| 147 | while(1) {}; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | void BSP_panic(char *s) |
---|
| 151 | { |
---|
| 152 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
| 153 | BSP_ask_for_reset(); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | void _BSP_Fatal_error(unsigned int v) |
---|
| 157 | { |
---|
| 158 | printk("%s PANIC ERROR %x\n",_RTEMS_version, v); |
---|
| 159 | BSP_ask_for_reset(); |
---|
| 160 | } |
---|