[b6394ae] | 1 | /* |
---|
[8961188] | 2 | * This set of routines starts the application. It includes application, |
---|
| 3 | * board, and monitor specific initialization and configuration. |
---|
| 4 | * The generic CPU dependent initialization has been performed |
---|
| 5 | * before any of these are invoked. |
---|
| 6 | * |
---|
[4c94ffff] | 7 | * COPYRIGHT (c) 1989-2008. |
---|
[8961188] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
[b6394ae] | 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. |
---|
[8961188] | 13 | */ |
---|
| 14 | |
---|
| 15 | #include <string.h> |
---|
| 16 | #include <fcntl.h> |
---|
[eba2e4f] | 17 | #include <bsp.h> |
---|
[270ce1ff] | 18 | #include <bsp/irq.h> |
---|
[b094233] | 19 | #include <psim.h> |
---|
[d4886a06] | 20 | #include <bsp/bootcard.h> |
---|
[6457fb29] | 21 | #include <bsp/linker-symbols.h> |
---|
[f844cfcc] | 22 | #include <rtems/bspIo.h> |
---|
[24bf11e] | 23 | #include <rtems/counter.h> |
---|
[1899fe4] | 24 | #include <rtems/powerpc/powerpc.h> |
---|
| 25 | |
---|
[270ce1ff] | 26 | #include <libcpu/cpuIdent.h> |
---|
[a725a4d7] | 27 | #include <libcpu/bat.h> |
---|
[270ce1ff] | 28 | #include <libcpu/spr.h> |
---|
| 29 | |
---|
| 30 | SPR_RW(SPRG1) |
---|
| 31 | |
---|
| 32 | /* On psim, each click of the decrementer register corresponds |
---|
| 33 | * to 1 instruction. By setting this to 100, we are indicating |
---|
| 34 | * that we are assuming it can execute 100 instructions per |
---|
| 35 | * microsecond. This corresponds to sustaining 1 instruction |
---|
| 36 | * per cycle at 100 Mhz. Whether this is a good guess or not |
---|
| 37 | * is anyone's guess. |
---|
| 38 | */ |
---|
[1b47871d] | 39 | extern int PSIM_INSTRUCTIONS_PER_MICROSECOND[]; |
---|
[eba2e4f] | 40 | |
---|
[270ce1ff] | 41 | /* |
---|
| 42 | * PCI Bus Frequency |
---|
| 43 | */ |
---|
[07e9642c] | 44 | unsigned int BSP_bus_frequency; |
---|
[270ce1ff] | 45 | |
---|
[bb20cc63] | 46 | /* |
---|
| 47 | * Driver configuration parameters |
---|
| 48 | */ |
---|
| 49 | uint32_t bsp_clicks_per_usec; |
---|
| 50 | |
---|
[07e9642c] | 51 | /* |
---|
[af2eb77] | 52 | * Memory on this board. |
---|
[07e9642c] | 53 | */ |
---|
[b094233] | 54 | uint32_t BSP_mem_size = (uint32_t)RamSize; |
---|
[270ce1ff] | 55 | |
---|
| 56 | /* |
---|
[af2eb77] | 57 | * Time base divisior (how many tick for 1 second). |
---|
[270ce1ff] | 58 | */ |
---|
[af2eb77] | 59 | unsigned int BSP_time_base_divisor; |
---|
[270ce1ff] | 60 | |
---|
[2dc00910] | 61 | extern unsigned long __rtems_end[]; |
---|
| 62 | |
---|
[65f868c] | 63 | uint32_t _CPU_Counter_frequency(void) |
---|
| 64 | { |
---|
| 65 | return bsp_clicks_per_usec * 1000000; |
---|
| 66 | } |
---|
| 67 | |
---|
[8961188] | 68 | /* |
---|
| 69 | * bsp_start |
---|
| 70 | * |
---|
| 71 | * This routine does the bulk of the system initialization. |
---|
| 72 | */ |
---|
| 73 | void bsp_start( void ) |
---|
| 74 | { |
---|
[6128a4a] | 75 | /* |
---|
[1a1c3fb] | 76 | * Note we can not get CPU identification dynamically. |
---|
| 77 | * PVR has to be set to PPC_PSIM (0xfffe) from the device |
---|
| 78 | * file. |
---|
[8961188] | 79 | */ |
---|
[1a1c3fb] | 80 | |
---|
| 81 | get_ppc_cpu_type(); |
---|
[8961188] | 82 | |
---|
| 83 | /* |
---|
[d34d8692] | 84 | * initialize the device driver parameters |
---|
[8961188] | 85 | */ |
---|
[1b47871d] | 86 | BSP_bus_frequency = (unsigned int)PSIM_INSTRUCTIONS_PER_MICROSECOND; |
---|
[bb20cc63] | 87 | bsp_clicks_per_usec = BSP_bus_frequency; |
---|
[270ce1ff] | 88 | BSP_time_base_divisor = 1; |
---|
| 89 | |
---|
[5f91272] | 90 | ppc_exc_initialize_with_vector_base( |
---|
[fad3f79b] | 91 | (uintptr_t) _Configuration_Interrupt_stack_area_begin, |
---|
[5f91272] | 92 | (void *) 0xfff00000 |
---|
[a86f3aac] | 93 | ); |
---|
[270ce1ff] | 94 | |
---|
| 95 | /* |
---|
| 96 | * Initalize RTEMS IRQ system |
---|
| 97 | */ |
---|
| 98 | BSP_rtems_irq_mng_init(0); |
---|
| 99 | |
---|
[a725a4d7] | 100 | /* |
---|
| 101 | * Setup BATs and enable MMU |
---|
| 102 | */ |
---|
| 103 | /* Memory */ |
---|
[b094233] | 104 | setdbat(0, 0x0<<24, 0x0<<24, 2<<24, _PAGE_RW); |
---|
| 105 | setibat(0, 0x0<<24, 0x0<<24, 2<<24, 0); |
---|
[a725a4d7] | 106 | /* PCI */ |
---|
| 107 | setdbat(1, 0x8<<24, 0x8<<24, 1<<24, IO_PAGE); |
---|
| 108 | setdbat(2, 0xc<<24, 0xc<<24, 1<<24, IO_PAGE); |
---|
| 109 | |
---|
| 110 | _write_MSR(_read_MSR() | MSR_DR | MSR_IR); |
---|
[4ac74d01] | 111 | __asm__ volatile("sync; isync"); |
---|
[1a1c3fb] | 112 | |
---|
[8961188] | 113 | } |
---|