diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-04-14 19:49:13 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-04-14 19:49:13 +0000 |
commit | 89611889fe6e255dec90a5157a4f25c0f65057b4 (patch) | |
tree | 2facca64edc8503b3149c8157a43fb6674e4523f /c/src/lib/libbsp/powerpc/psim/startup | |
parent | Changed arc to archive. (diff) | |
download | rtems-89611889fe6e255dec90a5157a4f25c0f65057b4.tar.bz2 |
new files
Diffstat (limited to 'c/src/lib/libbsp/powerpc/psim/startup')
-rw-r--r-- | c/src/lib/libbsp/powerpc/psim/startup/Makefile.in | 58 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/psim/startup/bspstart.c | 357 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/psim/startup/device-tree | 3 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/psim/startup/linkcmds | 172 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/psim/startup/setvec.c | 58 |
5 files changed, 648 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/psim/startup/Makefile.in b/c/src/lib/libbsp/powerpc/psim/startup/Makefile.in new file mode 100644 index 0000000000..b7fa673d11 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/psim/startup/Makefile.in @@ -0,0 +1,58 @@ +# +# $Id$ +# + +@SET_MAKE@ +srcdir = @srcdir@ +VPATH = @srcdir@:@srcdir@/../../../shared +RTEMS_ROOT = @top_srcdir@ +PROJECT_ROOT = @PROJECT_ROOT@ + +PGM=${ARCH}/startup.rel + +# C source names, if any, go here -- minus the .c +C_PIECES=bsppost bspstart main sbrk setvec +C_FILES=$(C_PIECES:%=%.c) +C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) + +H_FILES= + +# Assembly source names, if any, go here -- minus the .s +S_PIECES=bspclean +S_FILES=$(S_PIECES:%=%.s) +S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o) + +SRCS=linkcmds device-tree $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES) +OBJS=$(C_O_FILES) $(S_O_FILES) + +include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg +include $(RTEMS_ROOT)/make/leaf.cfg + +# +# (OPTIONAL) Add local stuff here using += +# + +DEFINES += +CPPFLAGS += +CFLAGS += + +LD_PATHS += +LD_LIBS += +LDFLAGS += + +# +# Add your list of files to delete here. The config files +# already know how to delete some stuff, so you may want +# to just run 'make clean' first to see what gets missed. +# 'make clobber' already includes 'make clean' +# + +CLEAN_ADDITIONS += +CLOBBER_ADDITIONS += + +${PGM}: ${SRCS} ${OBJS} + $(make-rel) + +all: ${ARCH} $(SRCS) $(PGM) + $(INSTALL) $(srcdir)/linkcmds ${PROJECT_RELEASE}/lib + $(INSTALL) $(srcdir)/device-tree ${PROJECT_RELEASE}/lib diff --git a/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c new file mode 100644 index 0000000000..91bdae7fba --- /dev/null +++ b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c @@ -0,0 +1,357 @@ +/* bspstart.c + * + * This set of routines starts the application. It includes application, + * board, and monitor specific initialization and configuration. + * The generic CPU dependent initialization has been performed + * before any of these are invoked. + * + * Called by RTEMS::RTEMS constructor in rtems-ctor.cc + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <bsp.h> +#include <rtems/libio.h> + +#include <libcsupport.h> + +#include <string.h> +#include <fcntl.h> + +#ifdef STACK_CHECKER_ON +#include <stackchk.h> +#endif + +/* + * The original table from the application and our copy of it with + * some changes. + */ + +extern rtems_configuration_table Configuration; +rtems_configuration_table BSP_Configuration; + +rtems_cpu_table Cpu_table; +rtems_unsigned32 bsp_isr_level; + +/* + * Tells us where to put the workspace in case remote debugger is present. + */ + +#if 0 +extern rtems_unsigned32 rdb_start; +#endif + +/* + * Amount to increment itimer by each pass + * It is a variable instead of a #define to allow the 'looptest' + * script to bump it without recompiling rtems + * + * NOTE: This is based on the PA-RISC simulator. I don't know if we + * can actually pull this trick on the PPC simulator. + */ + +rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK; + +#if PSIM_FAST_IDLE + +/* + * Many of the tests are very slow on the simulator because they have + * have 5 second delays hardwired in. + * + * Try to speed those tests up by speeding up the clock when in the idle task. + * + * NOTE: At the current setting, 5 second delays in the tests take + * approximately 5 seconds of wall time. + */ + +rtems_extension +fast_idle_switch_hook(rtems_tcb *current_task, + rtems_tcb *heir_task) +{ + static rtems_unsigned32 normal_clock = ~0; + static rtems_unsigned32 fast_clock; + + /* init our params on first call */ + if (normal_clock == (rtems_unsigned32) ~0) + { + normal_clock = CPU_PPC_CLICKS_PER_TICK; + fast_clock = 10000; +#if 0 + fast_clock = CPU_PPC_CLICKS_PER_TICK / 0x10 ; +#endif + if (fast_clock == 0) /* handle pathological case */ + fast_clock++; + } + + /* + * Run the clock faster when idle is in place. + */ + + if (heir_task == _Thread_Idle) + CPU_PPC_CLICKS_PER_TICK = fast_clock; + else if (current_task == _Thread_Idle) + CPU_PPC_CLICKS_PER_TICK = normal_clock; +} + +#endif + +/* + * bsp_libc_init + * + * Initialize whatever libc we are using called from bsp_postdriver_hook. + */ + +void bsp_libc_init(void) +{ + extern int end; + rtems_unsigned32 heap_start; + rtems_unsigned32 heap_size; + + heap_start = (rtems_unsigned32) &end; + if (heap_start & (CPU_ALIGNMENT-1)) + heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); + + heap_size = BSP_Configuration.work_space_start - (void *)&end; + heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ + + RTEMS_Malloc_Initialize((void *) heap_start, heap_size, 0); + + /* + * Init the RTEMS libio facility to provide UNIX-like system + * calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc) + * Uses malloc() to get area for the iops, so must be after malloc init + */ + + rtems_libio_init(); + + /* + * Set up for the libc handling. + */ + + if (BSP_Configuration.ticks_per_timeslice > 0) + libc_init(1); /* reentrant if possible */ + else + libc_init(0); /* non-reentrant */ + +} + + +/* + * bsp_pretasking_hook + * + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + */ + +void bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#if PSIM_FAST_IDLE + /* + * Install the fast idle task switch extension + * + * On MP systems, might not want to do this; it confuses at least + * one test (mp06) on the PA-RISC simulator + */ + +#if 0 + if (BSP_Configuration.User_multiprocessing_table == 0) +#endif + { + rtems_extensions_table fast_idle_extension; + rtems_id extension_id; + rtems_status_code rc; + + memset(&fast_idle_extension, 0, sizeof(fast_idle_extension)); + + fast_idle_extension.thread_switch = fast_idle_switch_hook; + + rc = rtems_extension_create( + rtems_build_name('F', 'D', 'L', 'E'), + &fast_idle_extension, + &extension_id + ); + if (rc != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred(rc); + } +#endif + + +#ifdef STACK_CHECKER_ON + /* + * Initialize the stack bounds checker + * We can either turn it on here or from the app. + */ + + Stack_check_Initialize(); +#endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif + +} + +/* + * Use the shared bsp_postdriver_hook() implementation + */ + +void bsp_postdriver_hook(void); + +/* + * bsp_start + * + * This routine does the bulk of the system initialization. + */ + +void bsp_start( void ) +{ + unsigned char *work_space_start; + +#if 0 + /* + * Set MSR to show vectors at 0 XXX + */ + _CPU_MSR_Value( msr_value ); + msr_value &= ~PPC_MSR_EP; + _CPU_MSR_SET( msr_value ); +#endif + + /* + * Set up our hooks + * Make sure libc_init is done before drivers initialized so that + * they can use atexit() + */ + + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + + Cpu_table.predriver_hook = NULL; /* bsp_spurious_initialize;*/ + + Cpu_table.postdriver_hook = bsp_postdriver_hook; + + Cpu_table.idle_task = NULL; /* do not override system IDLE task */ + + /* + * PSIM does zero out memory BUT only when IT begins execution. Thus + * if we want to have a clean slate in the workspace each time we + * begin execution of OUR application, then we must zero the workspace. + */ + + Cpu_table.do_zero_of_workspace = FALSE; + + /* + * This should be enough interrupt stack. + */ + + Cpu_table.interrupt_stack_size = (12 * 1024); + + /* + * SIS does not support MP configurations so there is really no way + * to check this out. + */ + + Cpu_table.extra_mpci_receive_server_stack = 0; + + /* + * The monitor likes the exception table to be at 0x0. + */ + + Cpu_table.exceptions_in_RAM = TRUE; + + /* + * Copy the table and allocate memory for the RTEMS Workspace + */ + + BSP_Configuration = Configuration; + +#if defined(RTEMS_POSIX_API) + BSP_Configuration.work_space_size *= 3; +#endif + + +#if 0 + work_space_start = + (unsigned char *)rdb_start - BSP_Configuration.work_space_size; +#endif + + work_space_start = + (unsigned char *)&RAM_END - BSP_Configuration.work_space_size; + + if ( work_space_start <= (unsigned char *)&end ) { + DEBUG_puts( "bspstart: Not enough RAM!!!\n" ); + bsp_cleanup(); + } + + BSP_Configuration.work_space_start = work_space_start; + + /* + * Add 1 region for RTEMS Malloc + */ + + BSP_Configuration.RTEMS_api_configuration->maximum_regions++; + +#ifdef RTEMS_NEWLIB + /* + * Add 1 extension for newlib libc + */ + + BSP_Configuration.maximum_extensions++; +#endif + +#ifdef STACK_CHECKER_ON + /* + * Add 1 extension for stack checker + */ + + BSP_Configuration.maximum_extensions++; +#endif + +#if PSIM_FAST_IDLE + /* + * Add 1 extension for fast idle + */ + + BSP_Configuration.maximum_extensions++; +#endif + + /* + * Add 1 extension for MPCI_fatal + */ + + if (BSP_Configuration.User_multiprocessing_table) + BSP_Configuration.maximum_extensions++; + + /* + * Set the "clicks per tick" for the simulator + * used by XXX/clock/clock.c to schedule interrupts + * + * NOTE: On psim, each click of the decrementer register corresponds + * to 1 instruction. By setting this to 100, we are indicating + * that we are assuming it can execute 100 instructions per + * microsecond. This corresponds to sustaining 1 instruction + * per cycle at 100 Mhz. Whether this is a good guess or not + * is anyone's guess. + */ + + { + extern int PSIM_INSTRUCTIONS_PER_MICROSECOND; + + CPU_PPC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick * + (int) &PSIM_INSTRUCTIONS_PER_MICROSECOND; + } + + /* + * Initialize RTEMS. main() will finish it up and start multitasking. + */ + + rtems_libio_config( &BSP_Configuration, BSP_LIBIO_MAX_FDS ); +} diff --git a/c/src/lib/libbsp/powerpc/psim/startup/device-tree b/c/src/lib/libbsp/powerpc/psim/startup/device-tree new file mode 100644 index 0000000000..29873839e5 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/psim/startup/device-tree @@ -0,0 +1,3 @@ +#/openprom/init/register/pc 0 +#/openprom/options/smp 2 +/openprom/options/oea-memory-size 4194304 diff --git a/c/src/lib/libbsp/powerpc/psim/startup/linkcmds b/c/src/lib/libbsp/powerpc/psim/startup/linkcmds new file mode 100644 index 0000000000..467d982812 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/psim/startup/linkcmds @@ -0,0 +1,172 @@ +OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", + "elf32-powerpc") +OUTPUT_ARCH(powerpc) +ENTRY(_start) + /*SEARCH_DIR(/usr1/gnu/cross/powerpc-unknown-eabi//powerpc-unknown-eabi/lib); */ +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +PROVIDE (__stack = 0); +PROVIDE (PSIM_INSTRUCTIONS_PER_MICROSECOND = 100); +MEMORY + { + RAM : ORIGIN = 0, LENGTH = 4M + EPROM : ORIGIN = 0xFFF00000, LENGTH = 0x20000 + } + +SECTIONS +{ + .vectors 0xFFF00100 : + { + *(.vectors) + } + + /* Read-only sections, merged into text segment: */ + /* . = 0x40000 + SIZEOF_HEADERS; */ + . = 0x4000; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rela.text : { *(.rela.text) } + .rela.data : { *(.rela.data) } + .rela.rodata : { *(.rela.rodata) } + .rela.got : { *(.rela.got) } + .rela.got1 : { *(.rela.got1) } + .rela.got2 : { *(.rela.got2) } + .rela.ctors : { *(.rela.ctors) } + .rela.dtors : { *(.rela.dtors) } + .rela.init : { *(.rela.init) } + .rela.fini : { *(.rela.fini) } + .rela.bss : { *(.rela.bss) } + .rela.plt : { *(.rela.plt) } + .rela.sdata : { *(.rela.sdata2) } + .rela.sbss : { *(.rela.sbss2) } + .rela.sdata2 : { *(.rela.sdata2) } + .rela.sbss2 : { *(.rela.sbss2) } + .plt : { *(.plt) } + .text : + { + *(.text) + *(.descriptors) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + .init : { *(.init) } =0 + .fini : { *(.fini) } =0 + .rodata : { *(.rodata) } + .rodata1 : { *(.rodata1) } + _etext = .; + PROVIDE (etext = .); + PROVIDE (__SDATA2_START__ = .); + .sdata2 : { *(.sdata2) } + .sbss2 : { *(.sbss2) } + PROVIDE (__SBSS2_END__ = .); + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. It would + be more correct to do this: + . = ALIGN(0x40000) + (ALIGN(8) & (0x40000 - 1)); + The current expression does not correctly handle the case of a + text segment ending precisely at the end of a page; it causes the + data segment to skip a page. The above expression does not have + this problem, but it will currently (2/95) cause BFD to allocate + a single segment, combining both text and data, for this case. + This will prevent the text segment from being shared among + multiple executions of the program; I think that is more + important than losing a page of the virtual address space (note + that no actual memory is lost; the page which is skipped can not + be referenced). */ + . = ALIGN(8) + 0x40000; + .data : + { + *(.data) + CONSTRUCTORS + } + PROVIDE (__EXCEPT_START__ = .); + .gcc_except_table : { *(.gcc_except_table) } + PROVIDE (__EXCEPT_END__ = .); + + .data1 : { *(.data1) } + .got1 : { *(.got1) } + .dynamic : { *(.dynamic) } + /* Put .ctors and .dtors next to the .got2 section, so that the pointers + get relocated with -mrelocatable. Also put in the .fixup pointers. + The current compiler no longer needs this, but keep it around for 2.7.2 */ + PROVIDE (_GOT2_START_ = .); + .got2 : { *(.got2) } + PROVIDE (__GOT2_END__ = .); + PROVIDE (__CTOR_LIST__ = .); + .ctors : { *(.ctors) } + PROVIDE (__CTOR_END__ = .); + PROVIDE (__DTOR_LIST__ = .); + .dtors : { *(.dtors) } + PROVIDE (__DTOR_END__ = .); + PROVIDE (_FIXUP_START_ = .); + .fixup : { *(.fixup) } + PROVIDE (_FIXUP_END_ = .); + PROVIDE (__FIXUP_END__ = .); + PROVIDE (_GOT2_END_ = .); + PROVIDE (_GOT_START_ = .); + s.got = .; + .got : { *(.got) } + .got.plt : { *(.got.plt) } + PROVIDE (_GOT_END_ = .); + PROVIDE (__GOT_END__ = .); + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + PROVIDE (__SDATA_START__ = .); + .sdata : { *(.sdata) } + _edata = .; + PROVIDE (edata = .); + PROVIDE (RAM_END = 0x3f0000); + .sbss : + { + PROVIDE (__sbss_start = .); + *(.sbss) + *(.scommon) + PROVIDE (__sbss_end = .); + } + PROVIDE (__SBSS_END__ = .); + .bss : + { + PROVIDE (__bss_start = .); + *(.dynbss) + *(.bss) + *(COMMON) + } + . = ALIGN(8) + 0x8000; + __stack = .; + _end = . ; + PROVIDE (end = .); + + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* These must appear regardless of . */ +} diff --git a/c/src/lib/libbsp/powerpc/psim/startup/setvec.c b/c/src/lib/libbsp/powerpc/psim/startup/setvec.c new file mode 100644 index 0000000000..efb3e9d8e0 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/psim/startup/setvec.c @@ -0,0 +1,58 @@ +/* set_vector + * + * This routine installs an interrupt vector on the target Board/CPU. + * This routine is allowed to be as board dependent as necessary. + * + * INPUT: + * handler - interrupt handler entry point + * vector - vector number + * type - 0 indicates raw hardware connect + * 1 indicates RTEMS interrupt connect + * + * RETURNS: + * address of previous interrupt handler + * + * 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 c/src/lib/libbsp/no_cpu/no_bsp/startup/setvec.c: + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems.h> +#include <bsp.h> + +rtems_isr_entry set_vector( /* returns old vector */ + rtems_isr_entry handler, /* isr routine */ + rtems_vector_number vector, /* vector number */ + int type /* RTEMS or RAW intr */ +) +{ + rtems_isr_entry previous_isr; + + rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr ); + + return previous_isr; +} + |