diff options
Diffstat (limited to 'bsps/powerpc/haleakala/start')
-rw-r--r-- | bsps/powerpc/haleakala/start/bspstart.c | 190 | ||||
-rw-r--r-- | bsps/powerpc/haleakala/start/linkcmds | 274 | ||||
-rw-r--r-- | bsps/powerpc/haleakala/start/mmu_405.c | 293 | ||||
-rw-r--r-- | bsps/powerpc/haleakala/start/mmu_405asm.S | 83 | ||||
-rw-r--r-- | bsps/powerpc/haleakala/start/start.S | 237 |
5 files changed, 0 insertions, 1077 deletions
diff --git a/bsps/powerpc/haleakala/start/bspstart.c b/bsps/powerpc/haleakala/start/bspstart.c deleted file mode 100644 index 61fb376e28..0000000000 --- a/bsps/powerpc/haleakala/start/bspstart.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * This routine does the bulk of the system initialization. - */ - -/* - * Author: Thomas Doerfler <td@imd.m.isar.de> - * IMD Ingenieurbuero fuer Microcomputertechnik - * - * COPYRIGHT (c) 1998 by IMD - * - * Changes from IMD are covered by the original distributions terms. - * This file has been derived from the papyrus BSP: - * - * Author: Andrew Bray <andy@i-cubed.co.uk> - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Modifications for spooling console driver and control of memory layout - * with linker command file by - * Thomas Doerfler <td@imd.m.isar.de> - * for these modifications: - * COPYRIGHT (c) 1997 by IMD, Puchheim, Germany. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies. IMD makes no representations about the suitability - * of this software for any purpose. - * - * Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c: - * - * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. - * On-Line Applications Research Corporation (OAR). - * - * Modifications for PPC405GP by Dennis Ehlin - * - * Further modified for the PPC405EX Haleakala board by - * Michael Hamel ADInstruments Ltd May 2008 - */ -#include <string.h> -#include <fcntl.h> - -#include <rtems/bspIo.h> -#include <rtems/counter.h> - -#include <bsp.h> -#include <bsp/bootcard.h> -#include <bsp/uart.h> -#include <bsp/irq.h> -#include <libcpu/powerpc-utility.h> -#include <bsp/vectors.h> -#include <ppc4xx/ppc405gp.h> -#include <ppc4xx/ppc405ex.h> - -#include <stdio.h> -/* - * Driver configuration parameters - */ - -/* Expected by clock.c */ -uint32_t bsp_clicks_per_usec; - -/*-------------------- Haleakala-specific UART setup -------------------------*/ - -static void -EarlyUARTInit(int baudRate) -{ - volatile uint8_t* up = (uint8_t*)(BSP_UART_IOBASE_COM1); - int divider = BSP_UART_BAUD_BASE / baudRate; - up[LCR] = DLAB; /* Access DLM/DLL */ - up[DLL] = divider & 0x0FF; - up[DLM] = divider >> 8; - up[LCR] = CHR_8_BITS; - up[MCR] = DTR | RTS; - up[FCR] = FIFO_EN | XMIT_RESET | RCV_RESET; - up[THR] = '+'; -} - - -static void -InitUARTClock(void) -{ - uint32_t reg; - mfsdr(SDR0_UART0,reg); - reg &= ~0x008000FF; - reg |= 0x00800001; /* Ext clock, div 1 */ - mtsdr(SDR0_UART0,reg); -} - -static void GPIO_AlternateSelect(int bitnum, int source) -/* PPC405EX: select a GPIO function for the specified pin */ -{ - int shift; - unsigned long value, mask; - GPIORegisters* gpioPtr = (GPIORegisters*)(GPIOAddress); - - shift = (31 - bitnum) & 0xF; - value = (source & 3) << (shift*2); - mask = 3 << (shift*2); - if (bitnum <= 15) { - gpioPtr->OSRL = (gpioPtr->OSRL & ~mask) | value; - gpioPtr->TSRL = (gpioPtr->TSRL & ~mask) | value; - } else { - gpioPtr->OSRH = (gpioPtr->OSRH & ~mask) | value; - gpioPtr->TSRH = (gpioPtr->TSRH & ~mask) | value; - } -} - -static void Init_FPGA(void) -{ - /* Have to write to the FPGA to enable the UART drivers */ - /* Have to enable CS2 as an output in GPIO to get the FPGA working */ - mtebc(EBC0_B2CR,0xF0018000); /* Set up CS2 at 0xF0000000 */ - mtebc(EBC0_B2AP,0x9400C800); - GPIO_AlternateSelect(9,1); /* GPIO9 = PerCS2 */ - { - unsigned long *fpgaPtr = (unsigned long*)(0xF0000000); - unsigned long n; - n = *(fpgaPtr); - n &= ~0x00100; /* User LEDs on */ - n |= 0x30000; /* UART 0 and 1 transcievers on! */ - *fpgaPtr = n; - } -} - -/*===================================================================*/ - -static void -DirectUARTWrite(const char c) -{ - volatile uint8_t* up = (uint8_t*)(BSP_UART_IOBASE_COM1); - while ((up[LSR] & THRE) == 0) { ; } - up[THR] = c; -} - -/* We will provide our own printk output function as it may get used early */ -BSP_output_char_function_type BSP_output_char = DirectUARTWrite; -BSP_polling_getchar_function_type BSP_poll_char = NULL; - -uint32_t _CPU_Counter_frequency(void) -{ - return bsp_clicks_per_usec * 1000000; -} - -/*===================================================================*/ - -void bsp_start( void ) -{ - /* Get the UART clock initialized first in case we call printk */ - - InitUARTClock(); - Init_FPGA(); - EarlyUARTInit(115200); - - /* - * Get CPU identification dynamically. Note that the get_ppc_cpu_type() - * function store the result in global variables - * so that it can be used later... - */ - get_ppc_cpu_type(); - get_ppc_cpu_revision(); - - /* - * initialize the device driver parameters - */ - - /* Set globals visible to clock.c */ - /* timebase register ticks/microsecond = CPU Clk in MHz */ - bsp_clicks_per_usec = 400; - - ppc_exc_initialize(); - - /* - * Install our own set of exception vectors - */ - BSP_rtems_irq_mng_init(0); -} diff --git a/bsps/powerpc/haleakala/start/linkcmds b/bsps/powerpc/haleakala/start/linkcmds deleted file mode 100644 index dc5a198b00..0000000000 --- a/bsps/powerpc/haleakala/start/linkcmds +++ /dev/null @@ -1,274 +0,0 @@ -/* - * This file contains directives for the GNU linker which are specific - * to the 405GP/EX - * This file is intended to be used together with dlentry.s - * it will generate downloadable code - * - * Modifications for gen405 by Dennis Ehlin - * Modifications for virtex by Keith, Greg, and Bob - * Modifications for 405GP/EX by Michael Hamel - */ - -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") -OUTPUT_ARCH(powerpc) -STARTUP(start.o) -ENTRY(download_entry) -EXTERN(__vectors) - -RamBase = DEFINED(RamBase) ? RamBase : 0; -RamSize = DEFINED(RamSize) ? RamSize : 256M; -RamEnd = RamBase + RamSize; -HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0; - -MEMORY { - RAM : ORIGIN = 0, LENGTH = 256M - /*FLASH : ORIGIN = 0xFFE00000, LENGTH = 16M*/ -} - -/* - * Max sdata/bss. - */ -bsp_section_small_data_area_size = 65536; - -SECTIONS -{ - /* First 16K is occupied by exception vectors and anything else we want to put there */ - .text 0x4000: - { - text.start = . ; - *(.entry) - *(.entry2) - *(.text*) - *(.rodata*) - *(.rodata1) - KEEP (*(SORT(.rtemsroset.*))) - - /* - * Special FreeBSD sysctl sections. - */ - . = ALIGN (16); - __start_set_sysctl_set = .; - *(set_sysctl_*); - __stop_set_sysctl_set = ABSOLUTE(.); - *(set_domain_*); - *(set_pseudo_*); - - /* C++ constructors/destructors */ - *(.gnu.linkonce.t*) - - /* Initialization and finalization code. - * - * Various files can provide initialization and finalization functions. - * The bodies of these functions are in .init and .fini sections. We - * accumulate the bodies here, and prepend function prologues from - * ecrti.o and function epilogues from ecrtn.o. ecrti.o must be linked - * first; ecrtn.o must be linked last. Because these are wildcards, it - * doesn't matter if the user does not actually link against ecrti.o and - * ecrtn.o; the linker won't look for a file to match a wildcard. The - * wildcard also means that it doesn't matter which directory ecrti.o - * and ecrtn.o are in. - */ - PROVIDE (_init = .); - *ecrti.o(.init) - *(.init) - *ecrtn.o(.init) - - PROVIDE (_fini = .); - *ecrti.o(.fini) - *(.fini) - *ecrtn.o(.init) - - KEEP (*ecrti.o(.ctors)) - KEEP (*crtbegin.o(.ctors)) - KEEP (*crtbegin?.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - KEEP (*ecrti.o(.dtors)) - KEEP (*crtbegin.o(.dtors)) - KEEP (*crtbegin?.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - - /* Exception frame info */ - *(.eh_frame) - /* Miscellaneous read-only data */ - _rodata_start = . ; - *(.gnu.linkonce.r*) - *(.lit) - *(.shdata) - *(.rodata) - *(.rodata1) - *(.descriptors) - *(rom_ver) - _erodata = .; - - PROVIDE (__EXCEPT_START__ = .); - *(.gcc_except_table*) - PROVIDE (__EXCEPT_END__ = .); - __GOT_START__ = .; - s.got = .; - *(.got.plt) - *(.got) - *(.got1) - PROVIDE (__GOT2_START__ = .); - PROVIDE (_GOT2_START_ = .); - *(.got2) - PROVIDE (__GOT2_END__ = .); - PROVIDE (_GOT2_END_ = .); - - PROVIDE (__FIXUP_START__ = .); - PROVIDE (_FIXUP_START_ = .); - *(.fixup) - PROVIDE (_FIXUP_END_ = .); - PROVIDE (__FIXUP_END__ = .); - - - /* Various possible names for the end of the .text section */ - etext = ALIGN(0x10); - _etext = .; - - *(.lit) - *(.shdata) - _endtext = ALIGN(0x10); - text.end = .; - text.size = text.end - text.start; - } >RAM - - text.size = text.end - text.start; - - .tdata : { - _TLS_Data_begin = .; - *(.tdata .tdata.* .gnu.linkonce.td.*) - _TLS_Data_end = .; - } >RAM - - .tbss : { - _TLS_BSS_begin = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) - _TLS_BSS_end = .; - } >RAM - - _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; - _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; - _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; - _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; - _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; - _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); - - .jcr : { KEEP (*(.jcr)) } >RAM - - .rel.dyn : { - *(.rel.init) - *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) - *(.rel.fini) - *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) - *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) - *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) - *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) - *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) - *(.rel.ctors) - *(.rel.dtors) - *(.rel.got) - *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) - *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) - *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) - *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) - *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) - } >RAM - .rela.dyn : { - *(.rela.init) - *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) - *(.rela.fini) - *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) - *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) - *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) - *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) - *(.rela.ctors) - *(.rela.dtors) - *(.rela.got) - *(.rela.got1) - *(.rela.got2) - *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) - *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) - *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) - *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) - *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) - } >RAM - - - /* Initialised large data */ - .data ( . ) : - { - . = ALIGN (4); - data.start = .; - *(.data) - *(.data1) - KEEP (*(SORT(.rtemsrwset.*))) - *(.data.* .gnu.linkonce.d.*) - data.end = .; - } > RAM - - /* Initialised small data addressed as offsets from r13 */ - .sdata : { - . = ALIGN (4); - PROVIDE (__SDATA_START__ = .); - bsp_section_sdata_begin = .; - sdata.start = .; - *(.sdata*) - *(.gnu.linkonce.s.*) - sdata.end = .; - bsp_section_sdata_end = .; - } > RAM - - /* Zeroed small data addressed as offsets from r13 */ - .sbss : { - . = ALIGN (4); - PROVIDE(__SBSS_START__ = .); - bsp_section_sbss_begin = .; - sbss.start = .; - *(.sbss .sbss.* *.gnu.linkonce.sb.*); - sbss.end = .; - bsp_section_sbss_end = .; - bsp_section_sdata_libdl_begin = .; - . = DEFINED(bsp_section_small_data_area_size) ? - bsp_section_sdata_begin + bsp_section_small_data_area_size : .; - bsp_section_sdata_libdl_end = .; - } > RAM - PROVIDE(__SBSS_END__ = .); - - /* Zeroed large data */ - .bss : { - . = ALIGN (4); - bss.start = .; - *(.bss .bss* .gnu.linkonce.b*) - . = ALIGN(4); - bss.end = .; - } > RAM - - bss.size = bss.end - bss.start; - sbss.size = sbss.end - sbss.start; - - .noinit (NOLOAD) : { - *(.noinit*) - } >RAM - - .rtemsstack (NOLOAD) : { - *(SORT(.rtemsstack.*)) - } >RAM - - WorkAreaBase = .; - - /* Debugging information */ - .line 0 : { *(.line) } - .debug 0 : { *(.debug) } - .debug_sfnames 0 : { *(.debug_sfnames) } - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } - .debug_aregion 0 : { *(.debug_aregion) } - .debug_macinfo 0 : { *(.debug_macinfo) } - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } -} diff --git a/bsps/powerpc/haleakala/start/mmu_405.c b/bsps/powerpc/haleakala/start/mmu_405.c deleted file mode 100644 index ea45807b8f..0000000000 --- a/bsps/powerpc/haleakala/start/mmu_405.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Simple interface to the PowerPC 405 MMU - * - * Michael Hamel ADInstruments 2008 - * - */ - - -#include <bsp.h> -#include <libcpu/powerpc-utility.h> -#include "mmu_405.h" -#include <inttypes.h> - -/* #define qLogTLB */ -/* #define qLogTLBDetails */ - - -/*----------------------------- TLB handling -------------------------------- */ -/* The following are in assembler in mmu_405asm.S */ -extern void MMU_GetTLBEntry(uint8_t index, uint32_t* tagword, uint32_t* dataword, uint8_t* pid); -extern void MMU_SetTLBEntry(uint8_t index, uint32_t hiword, uint32_t loword, uint8_t pid); -extern void MMU_ClearTLBs(void); -extern int16_t MMU_FindTLBEntry(uint32_t address); - - -enum { kNTLBs = 64 }; /* for 403GCX and 405 */ - -static bool sFreeTLBs[kNTLBs]; -static uint8_t sLastIndex = 0; -static int sNInUse = 0; - -static void MMUFault(const char* what) -/* Used for all setup faults; these can't really be ignored */ -{ - printk("\n>>>MMU fatal error %s\n",what); - rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR); -} - -static uint8_t AllocTLB(void) -{ - uint8_t index; - - index = sLastIndex; - do { - index++; - if (index == kNTLBs) - index = 0; - if (index == sLastIndex) - MMUFault("TLB table full"); - } while (! sFreeTLBs[index]); - sFreeTLBs[index] = false; - sLastIndex = index; - sNInUse++; - return index; -} - -static void FreeTLB(uint8_t index) -{ - MMU_SetTLBEntry(index,0,0,0); - sFreeTLBs[index] = true; - sLastIndex = index-1; - sNInUse--; -} - - -/*---------------------------- MMU operations ---------------------------------- */ - -int DataMissException(BSP_Exception_frame *f, unsigned int vector); -int InstructionMissException(BSP_Exception_frame *f, unsigned int vector); -int InstructionFetchException(BSP_Exception_frame *f, unsigned int vector); -void mmu_initialise(void); -int mmu_get_tlb_count(void); -uint8_t mmu_new_processID(void); -uint8_t mmu_current_processID(void); - -void -mmu_initialise(void) -/* Clear the TLBs and set up exception handlers for the MMU miss handlers */ -{ - int i; - - MMU_ClearTLBs(); - for (i=0; i<kNTLBs; i++) { - sFreeTLBs[i] = true; - MMU_SetTLBEntry(i,0,0,0xFF); - } - ppc_exc_set_handler(ASM_ISI_VECTOR ,InstructionFetchException); - ppc_exc_set_handler(ASM_BOOKE_ITLBMISS_VECTOR ,DataMissException); - ppc_exc_set_handler(ASM_BOOKE_DTLBMISS_VECTOR ,InstructionMissException); -} - -static void -MakeTLBEntries(uint32_t startAt, uint32_t nBytes, bool EX, bool WR, bool I, uint8_t PID) -{ - uint32_t mask, options, tagWord, dataWord; - uint8_t index, sizeCode, pid; - - if ((startAt & 0x3FF) != 0) - MMUFault("TLB entry not on 1K boundary"); - if ((nBytes & 0x3FF) != 0) - MMUFault("TLB size not on 1K boundary"); - - options = 0; - if (EX) options += 0x200; - if (WR) options += 0x100; - if (I) options += 5; - - #ifdef qLogTLB - printk("TLB: make entries for $%X bytes from $%X..$%X PID %d",nBytes, startAt, startAt+nBytes-1, PID); - if (EX) printk(" EX"); - if (WR) printk(" WR"); - if (I) printk(" I"); - printk("\n"); - #endif - - while (nBytes > 0) { - /* Find the largest block we can base on this address */ - mask = 0x3FF; - sizeCode = 0; - while (mask < nBytes && ((startAt & mask)==0) && sizeCode < 8) { - mask = (mask<<2) + 3; - sizeCode++; - } - mask >>= 2; - sizeCode--; - - /* Make a TLB entry describing this, ZSEL=0 */ - tagWord = startAt | (sizeCode<<7) | 0x40; - dataWord = startAt | options; - index = AllocTLB(); - MMU_SetTLBEntry( index , tagWord, dataWord, PID); - - { - /* Paranoia: check that we can read that back... */ - uint8_t tdex, oldpid; - - oldpid = mmu_current_processID(); - mmu_set_processID(PID); - tdex = MMU_FindTLBEntry(startAt); - mmu_set_processID(oldpid); - - if (tdex != index) { - printk(" Add TLB %d: At %" PRIx32 " for $%" PRIx32 - " sizecode %d tagWord $%" PRIx32 " ", - index, startAt, mask+1,sizeCode,tagWord); - printk(" -- find failed, %d/%d!\n",tdex,index); - MMU_GetTLBEntry(index, &tagWord, &dataWord, &pid); - printk(" -- reads back $%" PRIx32 " : $%" PRIx32 - ", PID %d\n",tagWord,dataWord,pid); - } else { - #ifdef qLogTLBDetails - printk(" Add TLB %d: At %X for $%X sizecode %d tagWord $%X\n",index, startAt, mask+1,sizeCode,tagWord); - #endif - } - } - - /* Subtract block from startAddr and nBytes */ - mask++; /* Convert to a byte count */ - startAt += mask; - nBytes -= mask; - } - #ifdef qLogTLB - printk(" %d in use\n",sNInUse); - #endif -} - -void -mmu_remove_space(uint32_t startAt, uint32_t endAt) -{ - int16_t index; - int32_t size; - uint32_t tagword, dataword, nBytes; - uint8_t pid, sCode; - - nBytes = endAt - startAt; - - #ifdef qLogTLB - printk("TLB: delete entries for $%X bytes from $%X\n",nBytes,startAt); - #endif - - while (nBytes > 0) { - index = MMU_FindTLBEntry( (uint32_t)startAt ); - size = 1024; - if (index >= 0) { - MMU_GetTLBEntry(index, &tagword, &dataword, &pid); - if ((tagword & 0x40) == 0) - MMUFault("Undefine failed: redundant entries?"); - if ((tagword & 0xFFFFFC00) != (uint32_t)startAt) - MMUFault("Undefine not on TLB boundary"); - FreeTLB(index); - sCode = (tagword >> 7) & 7; - while (sCode > 0) { - size <<= 2; - sCode--; - } - #ifdef qLogTLBDetails - printk(" Free TLB %d: At %X for $%X\n",index, startAt, size); - #endif - } - startAt += size; - nBytes -= size; - } -} - -void -mmu_add_space(uint32_t startAddr, uint32_t endAddr, MMUAccessType permissions, uint8_t processID) -/* Convert accesstype to write-enable, executable, and cache-inhibit bits */ -{ - bool EX, WR, I; - - EX = false; - WR = false; - I = false; - switch (permissions) { - case executable : EX = true; break; - case readOnlyData : break; - case readOnlyNoCache : I = true; break; - case readWriteData : WR = true; break; - case readWriteNoCache : WR = true; I= true; break; - case readWriteExecutable: WR = true; EX = true; break; - } - MakeTLBEntries( (uint32_t)startAddr, (uint32_t)(endAddr-startAddr+1), EX, WR, I, processID); -} - -int -mmu_get_tlb_count(void) -{ - return sNInUse; -} - -/*---------------------------- CPU process ID handling ---------------------------------- - * Really dumb system where we just hand out sequential numbers and eventually fail - * As long as we only use 8-9 processes this isn't a problem */ - -static uint8_t sNextPID = 1; - -#define SPR_PID 0x3B1 - -uint8_t mmu_new_processID(void) -{ - return sNextPID++; -} - -void mmu_free_processID(uint8_t freeThis) -{ -} - -uint8_t mmu_current_processID(void) -{ - return PPC_SPECIAL_PURPOSE_REGISTER(SPR_PID); -} - -uint8_t mmu_set_processID(uint8_t newID) -{ - uint8_t prev = mmu_current_processID(); - PPC_SET_SPECIAL_PURPOSE_REGISTER(SPR_PID,newID); - return prev; -} - - -/* ------------------ Fault handlers ------------------ */ - -#define SPR_ESR 0x3D4 -#define SPR_DEAR 0x3D5 - -enum { kESR_DST = 0x00800000 }; - -int DataMissException(BSP_Exception_frame *f, unsigned int vector) -{ - uint32_t addr, excSyn; - - addr = PPC_SPECIAL_PURPOSE_REGISTER(SPR_DEAR); - excSyn = PPC_SPECIAL_PURPOSE_REGISTER(SPR_ESR); - if (excSyn & kESR_DST) printk("\n---Data write to $%" PRIx32 - " attempted at $%" PRIxPTR "\n",addr,f->EXC_SRR0); - else printk("\n---Data read from $%" PRIx32 " attempted at $%" - PRIxPTR "\n",addr,f->EXC_SRR0); - return -1; -} - -int InstructionMissException(BSP_Exception_frame *f, unsigned int vector) -{ - printk("\n---Instruction fetch attempted from $%" PRIxPTR ", no TLB exists\n", - f->EXC_SRR0); - return -1; -} - -int InstructionFetchException(BSP_Exception_frame *f, unsigned int vector) -{ - printk("\n---Instruction fetch attempted from $%" PRIxPTR - ", TLB is no-execute\n",f->EXC_SRR0); - return -1; -} diff --git a/bsps/powerpc/haleakala/start/mmu_405asm.S b/bsps/powerpc/haleakala/start/mmu_405asm.S deleted file mode 100644 index 5fef5fb11f..0000000000 --- a/bsps/powerpc/haleakala/start/mmu_405asm.S +++ /dev/null @@ -1,83 +0,0 @@ -/* - -Low-level interface to the PPC405 MMU - -M.Hamel ADInstruments 2008 - -*/ - -#include <rtems/asm.h> - -/* Useful MMU SPR values */ - -#define SPR_ZPR 0x3B0 -#define SPR_PID 0x3B1 - - .text - -/* void MMU_ClearTLBs(); */ - PUBLIC_VAR(MMU_ClearTLBs) -SYM (MMU_ClearTLBs): - tlbia - isync - lis r3,0x5555 // *** Gratuitous fiddle of ZPR to 0101010101 to take it out of - mtspr SPR_ZPR,r3 // the picture - blr - -/* void MMU_SetTLBEntry(UInt8 index, UInt32 tagword, UInt32 dataword, UInt8 SPR_PID) */ - PUBLIC_VAR(MMU_SetTLBEntry) -SYM (MMU_SetTLBEntry): - mfspr r7,SPR_PID // Save the current SPR_PID - mtspr SPR_PID,r6 // Write to SPR_PID - tlbwehi r4,r3 // Write hiword - mtspr SPR_PID,r7 // Restore the SPR_PID - tlbwelo r5,r3 // Write loword - isync - blr - -/* void MMU_GetTLBEntry(UInt8 index, UInt32& tagword, UInt32& dataword, UInt8& SPR_PID) */ - PUBLIC_VAR(MMU_GetTLBEntry) -SYM (MMU_GetTLBEntry): - mfspr r7,SPR_PID // Save the current SPR_PID - tlbrehi r8,r3 // Read hiword & SPR_PID - mfspr r9,SPR_PID // Copy the SPR_PID - mtspr SPR_PID,r7 // Restore original SPR_PID so we can proceed - stw r8,0(r4) // Write to r4 pointer - stb r9,0(r6) // Write to r6 pointer - tlbrelo r8,r3 // Read loword - stw r8,0(r5) // Write to r5 pointer - blr - -/* SInt16 MMU_FindTLBEntry(UInt32 address) */ -/* Returns index of covering TLB entry (0..63), or -1 if there isn't one */ - PUBLIC_VAR(MMU_FindTLBEntry) -SYM (MMU_FindTLBEntry): - tlbsx. r3,0,r3 - beqlr - li r3,0xFFFFFFFF - blr - -/* bool mmu_enable_code(bool enable); */ - PUBLIC_VAR(mmu_enable_code) -SYM (mmu_enable_code): - li r5,0x20 // IR bit - b msrbits - -/* bool mmu_enable_data(bool enable); */ - PUBLIC_VAR(mmu_enable_data) -SYM (mmu_enable_data): - li r5,0x10 // DR bit -msrbits: cmpwi r3,0 // Common code: parameter 0? - mfmsr r4 // r4 = MSR state - beq clrBit - or r6,r4,r5 // If 1, r6 = MSR with bit set - b setmsr -clrBit: andc r6,r4,r5 // If 0 r6 = MSR with bit clear -setmsr: mtmsr r6 // Write new MSR - and. r3,r4,r5 // Result = old MSR bit - beqlr // If zero return zero - li r3,0xFF // If nonzero return byte -1 - blr - - - diff --git a/bsps/powerpc/haleakala/start/start.S b/bsps/powerpc/haleakala/start/start.S deleted file mode 100644 index 43dde91255..0000000000 --- a/bsps/powerpc/haleakala/start/start.S +++ /dev/null @@ -1,237 +0,0 @@ -/* dlentry.s - * - * This file contains the entry code for RTEMS programs starting - * after download to RAM - * - * Author: Thomas Doerfler <td@imd.m.isar.de> - * IMD Ingenieurbuero fuer Microcomputertechnik - * - * COPYRIGHT (c) 1998 by IMD - * - * Changes from IMD are covered by the original distributions terms. - * This file has been derived from the papyrus BSP: - * - * This file contains the entry veneer for RTEMS programs - * downloaded to Papyrus. - * - * Author: Andrew Bray <andy@i-cubed.co.uk> - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * derived from "helas403/dlentry.S": - * - * Further changes to derive for the PPC405CR/GP/GPr/EX/EXr - * by Michael Hamel ADInstruments Ltd 2008 - */ - -#include <rtems/asm.h> - -/* - * The virtex ELF link scripts support three special sections: - * .entry The actual entry point - * .vectors The section containing the interrupt entry veneers. - */ - -/* - * Downloaded code loads the vectors separately to 0x00000100, - * so .entry can be over 256 bytes. - * - * The other sections are linked in the following order: - * .entry - * .text - * .data - * .bss - * see linker command file for section placement - * - * The initial stack is set to _ISR_Stack_area_end. - * - * All the entry veneer has to do is to clear the BSS. - */ - -/* - * GDB likes to have debugging information for the entry veneer. - * Here was some DWARF information. IMD removed it, because we - * could not check, whether it was still correct. Sorry. - - */ - - - .section .entry - - PUBLIC_VAR (start) - PUBLIC_VAR (download_entry) - PUBLIC_VAR (__rtems_entry_point) - -SYM(start): -SYM(download_entry): -SYM(__rtems_entry_point): - - .extern SYM (boot_card) - - bl .startup /* First word is branch to reset_entry */ - - -/*--------------------------------------------------------------------------- - * Parameters from linker - *--------------------------------------------------------------------------*/ - -base_addr: -toc_pointer: - .long s.got -bss_length: - .long bss.size -bss_addr: - .long bss.start -sbss_length: - .long sbss.size -sbss_addr: - .long sbss.start -stack_top: - .long _ISR_Stack_area_end -PUBLIC_VAR (text_addr) -text_addr: - .long text.start -PUBLIC_VAR (text_length) -text_length: - .long text.size - -/*--------------------------------------------------------------------------- - * Reset_entry. - *--------------------------------------------------------------------------*/ -.startup: - /* Get entrypoint address in R1 so we can find linker variables */ - mflr r1 - - /* Initialise procesor registers generally */ - bl init405 - - /* Clear .bss and .sbss */ - bl bssclr - - /*------------------------------------------------------------------- - * C_setup. - *------------------------------------------------------------------*/ - lwz r1,stack_top - base_addr(r1) /* Now set R1 to stack_top */ - addi r1,r1,-56-4 /* start stack at text_addr - 56 */ - li r3,0 - stw r3, 0(r1) /* Clear stack chain */ - stw r3, 4(r1) - stw r3, 8(r1) - stw r3, 12(r1) - - bl __eabi /* Initialise EABI: sets up r2 & r13 */ - - li r3, 0 /* command line */ - - b SYM (boot_card) /* call the first C routine */ - -/*--------------------------------------------------------------------------- - * bssclr. - *--------------------------------------------------------------------------*/ -bssclr: lwz r2,bss_addr-base_addr(r1) /* start of bss set by loader */ - lwz r3,bss_length-base_addr(r1) /* bss length */ - srwi. r3,r3,2 /* div 4 to get # of words */ - li r0,0 - beq dosbss /* no bss */ - mtctr r3 /* set ctr reg */ - subi r2,r2,4 -clear_bss: stwu r0,4(r2) - bdnz clear_bss /* decrement counter and loop */ - -dosbss: lwz r2,sbss_addr-base_addr(r1) /* start of sbss set by loader */ - lwz r3,sbss_length-base_addr(r1) /* sbss length */ - slwi. r3,r3,2 /* div 4 to get # of words */ - subi r2,r2,4 - beqlr /* no sbss */ - mtctr r3 /* set ctr reg */ -clear_sbss: stwu r0,4(r2) - bdnz clear_sbss /* decrement counter and loop */ - - blr /* return */ - - -/*--------------------------------------------------------------------------- - * Generic 405 register setup - *--------------------------------------------------------------------------*/ -init405: - li r0, 0 - mtmsr r0 - mticcr r0 - mtdccr r0 - - li r3,0x7FFC # 405EX-specific - mtsgr r3 # Clear guarded mode on all storage except PCIe region - - mtsler r0 # Storage is all big-endian - mtsu0r r0 # and uncompressed - - iccci r3,0 # Invalidate the instruction cache - li r3,1 # Enable F800 0000 to FFFF FFFF - oris r3,r3,0xC000 # Enable 0000 0000 to 0FFF FFFF - mticcr r3 - isync - - li r3,0 - li r4,256 # 405 has 128 or 256 32-byte lines: do 256 - mtctr r4 # set loop ctr -dcloop: dccci 0,r3 # invalidate line - addi r3,r3,0x20 # bump to next line - bdnz dcloop - mtdcwr r0 # Select write-back caching - lis r3,0xC000 # Enable 0000 0000 to 0FFF FFFF - # mtdccr r3 # Enable data cache - - mtevpr r0 - mtesr r0 - mtxer r0 - - lwarx r3,r0,r0 # get some data/set resv bit - stwcx. r3,r0,r0 # store out and clear resv bit - - lis r3,0xDEAD - ori r3,r3,0xBEEF # Make distintive uninitialised value - mr r4, r3 - mr r5, r3 - mr r6, r3 - mr r7, r3 - mr r8, r3 - mr r9, r3 - mr r10, r3 - mr r11, r3 - mr r12, r3 - mr r13, r3 - mr r14, r3 - mr r15, r3 - mr r16, r3 - mr r17, r3 - mr r18, r3 - mr r19, r3 - mr r20, r3 - mr r21, r3 - mr r22, r3 - mr r23, r3 - mr r24, r3 - mr r25, r3 - mr r26, r3 - mr r27, r3 - mr r28, r3 - mr r29, r3 - mr r30, r3 - mr r31, r3 - - blr - -.L_text_e: - - .comm environ,4,4 |