diff options
Diffstat (limited to 'c/src/lib/libbsp/m68k/gen68340/startup')
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/Makefile.in | 56 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/bspclean.c | 27 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/bspstart.c | 118 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/dumpanic.c | 193 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/init68340.c | 39 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/gen68340/startup/linkcmds | 155 |
6 files changed, 588 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/Makefile.in b/c/src/lib/libbsp/m68k/gen68340/startup/Makefile.in new file mode 100644 index 0000000000..c2e43aab72 --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/Makefile.in @@ -0,0 +1,56 @@ +# +# $Id$ +# + +@SET_MAKE@ +srcdir = @srcdir@ +VPATH = @srcdir@:@srcdir@/../../shared:@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=bspclean bsplibc bsppost bspstart init68340 main sbrk setvec dumpanic +C_FILES=$(C_PIECES:%=%.c) +C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) + +H_FILES= + +SRCS=$(srcdir)/linkcmds \ + $(C_FILES) $(H_FILES) +OBJS=$(C_O_FILES) $(CC_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 + +# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile + diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/bspclean.c b/c/src/lib/libbsp/m68k/gen68340/startup/bspclean.c new file mode 100644 index 0000000000..66f6531b84 --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/bspclean.c @@ -0,0 +1,27 @@ +/* bsp_cleanup() + * + * This routine normally is part of start.s and usually returns + * control to a monitor. + * + * INPUT: NONE + * + * OUTPUT: NONE + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems.h> +#include <bsp.h> + +void bsp_cleanup( void ) +{ + /* Cause double bus fault to force reset? */ +} diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/bspstart.c b/c/src/lib/libbsp/m68k/gen68340/startup/bspstart.c new file mode 100644 index 0000000000..cb8945a5fc --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/bspstart.c @@ -0,0 +1,118 @@ +/* bsp_start() + * + * This routine starts the application. It includes application, + * board, and monitor specific initialization and configuration. + * The generic CPU dependent initialization has been performed + * before this routine is invoked. + * + * INPUT: NONE + * + * OUTPUT: NONE + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> +#include <rtems/libio.h> + +#include <libcsupport.h> + +#include <string.h> + + +/* + * 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; + +char *rtems_progname; + +/* Initialize whatever libc we are using + * called from postdriver hook + */ +void bsp_postdriver_hook(void); +void bsp_libc_init( void *, unsigned32, int ); + +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void bsp_pretasking_hook(void) +{ + extern void *_HeapStart; + extern rtems_unsigned32 _HeapSize; + + bsp_libc_init(&_HeapStart, _HeapSize, 0); + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif +} + +/* + * bsp_start + * + * This routine does the bulk of the system initialization. + */ + +void bsp_start( void ) +{ + extern void *_WorkspaceBase; + + /* + * Allocate the memory for the RTEMS Work Space. This can come from + * a variety of places: hard coded address, malloc'ed from outside + * RTEMS world (e.g. simulator or primitive memory manager), or (as + * typically done by stock BSPs) by subtracting the required amount + * of work space from the last physical address on the CPU board. + */ +#if 0 + Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/; +#endif + + /* + * Need to "allocate" the memory for the RTEMS Workspace and + * tell the RTEMS configuration where it is. This memory is + * not malloc'ed. It is just "pulled from the air". + */ + + BSP_Configuration.work_space_start = (void *)&_WorkspaceBase; + + /* + * Account for the console's resources + */ + + console_reserve_resources( &BSP_Configuration ); + + /* + * initialize the CPU table for this BSP + */ + + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + Cpu_table.postdriver_hook = bsp_postdriver_hook; + Cpu_table.do_zero_of_workspace = TRUE; + Cpu_table.interrupt_stack_size = 4096; +} diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/dumpanic.c b/c/src/lib/libbsp/m68k/gen68340/startup/dumpanic.c new file mode 100644 index 0000000000..8323b533df --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/dumpanic.c @@ -0,0 +1,193 @@ +/* + * M68340/349 registers and stack dump if an exception is raised + * + * Author: + * Pascal Cadic + * France Telecom - CNET/DSM/TAM/CAT + * 4, rue du Clos Courtel + * 35512 CESSON-SEVIGNE + * FRANCE + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <stdio.h> + +const char *exceptionName[] = + { + "INITIAL STACK POINTER", + "INITIAL PROGRAM COUNTER", + "BUS ERROR", + "ADDRESS ERROR", + "ILLEGAL INSTRUCTION", + "DIVISION BY ZERO", + "CHK, CHK2", + "TRAPcc, TRAPv", + "PRIVILEGE VIOLATION", + "TRACE", + "LINE A EMULATOR", + "LINE F EMULATOR", + "HARDWARE BREAK", + "COPROCESSOR PROTOCOL VIOLATION", + "FORMAT ERROR", + "UNINITIALIZED INTERRUPT", + "RESERVED 16", + "RESERVED 17", + "RESERVED 18", + "RESERVED 19", + "RESERVED 20", + "RESERVED 21", + "RESERVED 22", + "RESERVED 23", + "SPURIOUS INTERRUPT", + "LEVEL 1 AUTOVECTOR", + "LEVEL 2 AUTOVECTOR", + "LEVEL 3 AUTOVECTOR", + "LEVEL 4 AUTOVECTOR", + "LEVEL 5 AUTOVECTOR", + "LEVEL 6 AUTOVECTOR", + "LEVEL 7 AUTOVECTOR", + "TRAP 1", + "TRAP 2", + "TRAP 3", + "TRAP 4", + "TRAP 5", + "TRAP 6", + "TRAP 7", + "TRAP 8", + "TRAP 9", + "TRAP 10", + "TRAP 11", + "TRAP 12", + "TRAP 13", + "TRAP 14", + "TRAP 15", + "VECTOR 48", + "VECTOR 49", + "VECTOR 50", + "VECTOR 51", + "VECTOR 52", + "VECTOR 53", + "VECTOR 54", + "VECTOR 55", + "VECTOR 56", + "VECTOR 57", + "VECTOR 58", + "VECTOR 59", + "VECTOR 60", + "VECTOR 61", + "VECTOR 62", + "VECTOR 63", + }; + +typedef struct { + unsigned long pc; + unsigned short sr; + unsigned short format_id; + unsigned long d0, d1, d2, d3, d4, d5, d6, d7; + unsigned long a0, a1, a2, a3, a4, a5, a6, a7; + unsigned long sfc, dfc, vbr; +} boot_panic_registers_t; + +boot_panic_registers_t _boot_panic_registers; + +extern void RAW_FMT( int minor, const char* fmt, ... ); +extern char RAW_GETC(int minor); + +/****************************************************** + Name: _dbug_dump + Input parameters: sr, pc, stack pointer, + size to display + Output parameters: - + Description: display the supervisor stack + *****************************************************/ +void _dbug_dump(unsigned short sr, void* pc, unsigned short *stack, int size) +{ +int i; + + RAW_FMT(0,"%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16)); + for (i=2; i<size; i++) { + if ((i%8)==0) RAW_FMT(0,"\n%x :",i/8); + RAW_FMT(0," %x\t",stack[i-2]); + } + RAW_FMT(0,"\n"); +} + +/****************************************************** + Name: _dbug_dump + Input parameters: - + Output parameters: - + Description: display microcontroler state. Registers + values are stored in _boot_panic_registers + which is filled in _uhoh ASM routine + *****************************************************/ +void _dbug_dumpanic(void) +{ + int c; + void *faultedAddr, *pc; + unsigned short vector, status; + unsigned char frametype, *stack; + #define ESCAPE 27 + + stack = (unsigned char*)(_boot_panic_registers.a7); + do { + status = _boot_panic_registers.sr; + pc = (void*)_boot_panic_registers.pc; + faultedAddr = *(void**)(stack+4); + vector = (_boot_panic_registers.format_id&0x0FFF)>>2; + frametype = (_boot_panic_registers.format_id&0xF000)>>12; + + RAW_FMT(0,"\n---------------------------------------------\n"); + if (vector<64) + RAW_FMT(0,"%s",exceptionName[vector]); + else { + RAW_FMT(0,"RESERVED USER"); + } + RAW_FMT(0," exception (vector %x, type %x)\n",vector,frametype); + RAW_FMT(0,"---------------------------------------------\n"); + RAW_FMT(0,"PC : 0x%x ",pc); + RAW_FMT(0,"A7 : 0x%x ",_boot_panic_registers.a7); + RAW_FMT(0,"SR : 0x%x\n",status); + if (frametype==0x0c) { + RAW_FMT(0,"\nfaulted address = 0x%x\n",faultedAddr); + } + RAW_FMT(0,"---------------------------------------------\n"); + RAW_FMT(0," panic regs\n"); + RAW_FMT(0,"---------------------------------------------\n"); + RAW_FMT(0,"D[0..3] : %x \t%x \t%x \t%x\n", + _boot_panic_registers.d0,_boot_panic_registers.d1, + _boot_panic_registers.d2,_boot_panic_registers.d3); + RAW_FMT(0,"D[4..7] : %x \t%x \t%x \t%x\n", + _boot_panic_registers.d4,_boot_panic_registers.d5, + _boot_panic_registers.d6,_boot_panic_registers.d7); + RAW_FMT(0,"A[0..3] : %x \t%x \t%x \t%x\n", + _boot_panic_registers.a0,_boot_panic_registers.a1, + _boot_panic_registers.a2,_boot_panic_registers.a3); + RAW_FMT(0,"A[4..7] : %x \t%x \t%x \t%x\n", + _boot_panic_registers.a4,_boot_panic_registers.a5, + _boot_panic_registers.a6,_boot_panic_registers.a7); + + RAW_FMT(0," SFC : %x",_boot_panic_registers.sfc); + RAW_FMT(0," DFC : %x\n",_boot_panic_registers.dfc); + RAW_FMT(0," VBR : %x\n",_boot_panic_registers.vbr); + RAW_FMT(0,"---------------------------------------------\n"); + RAW_FMT(0," panic stack\n"); + RAW_FMT(0,"---------------------------------------------\n"); + _dbug_dump(status, pc, (unsigned short*)stack,64*2); + + RAW_FMT(0,"---------------------------------------------\n"); + RAW_FMT(0,"press escape to reboot\n"); + } while ((c=RAW_GETC(0))!=ESCAPE); /* cgets ne marche pas si les IT sont bloquées */ +} + + + diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c b/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c new file mode 100644 index 0000000000..96caf9e585 --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c @@ -0,0 +1,39 @@ +/* + * MC68340/349 support routines + * + * Geoffroy Montel + * France Telecom - CNET/DSM/TAM/CAT + * 4, rue du Clos Courtel + * 35512 CESSON-SEVIGNE + * FRANCE + * + * e-mail: g_montel@yahoo.com + * + * $Id$ + */ + +#include <rtems.h> +#include <bsp.h> + +/* + * Initialize MC68340 + */ +void _Init68340 (void) +{ + extern void _CopyDataClearBSSAndStart (void); + m68k_isr_entry *vbr; + int i; + + /* + * Copy the exception vector table to system RAM + */ + m68k_get_vbr (vbr); + for (i = 0; i < 256; ++i) + M68Kvec[i] = vbr[i]; + m68k_set_vbr (M68Kvec); + + /* + * Copy data, clear BSS, switch stacks and call main() + */ + _CopyDataClearBSSAndStart (); +} diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/linkcmds b/c/src/lib/libbsp/m68k/gen68340/startup/linkcmds new file mode 100644 index 0000000000..4dbfa37084 --- /dev/null +++ b/c/src/lib/libbsp/m68k/gen68340/startup/linkcmds @@ -0,0 +1,155 @@ +/* + * This file contains GNU linker directives for a generic MC68340/349 board. + * Variations in hardware type and dynamic memory size can be made + * by overriding some values with linker command-line arguments. + * + * ATTENTION: RAM and ROM placement must accord those in start340.S!! + * (next time I'll use some shared variables :) ) + * + * Geoffroy Montel + * France Telecom - CNET/DSM/TAM/CAT + * 4, rue du Clos Courtel + * 35512 CESSON-SEVIGNE + * FRANCE + * + * e-mail: g_montel@yahoo.com + * + * $Id$ + */ + +/* + * a.out format doesn't handle prom images very well + */ +OUTPUT_FORMAT(coff-m68k) + +/* + * Declare some sizes. + * XXX: The assignment of ". += XyzSize;" fails in older gld's if the + * number used there is not constant. If this happens to you, edit + * the lines marked XXX below to use a constant value. + */ +RamSize = DEFINED(RamSize) ? RamSize : 4M; +HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000; +StackSize = DEFINED(StackSize) ? StackSize : 0x1000; + +/* + * Declare on-board memory. + * It would be nice if the ram length could be given as + * LENGTH=RamSize, but gld doesn't allow non-constant + * values in the LENGTH expression. + */ +MEMORY { + ram : ORIGIN = 0x10000000, LENGTH = 4M + rom : ORIGIN = 0x01000000, LENGTH = 4M +/* dpram : ORIGIN = 0xFE000000, LENGTH = 8k */ +} + +/* + * Declare low-order three octets of Ethernet address. + */ +ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12; + +/* + * Load objects + */ +SECTIONS { + /* + * Hardware variations + */ + _RamSize = RamSize; + __RamSize = RamSize; + + /* + * Boot PROM + */ + rom : { + _RomBase = .; + __RomBase = .; + } >rom + + /* + * Dynamic RAM + */ + ram : { + _RamBase = .; + __RamBase = .; + } >ram + + /* + * Text, data and bss segments + */ + .text : { + CREATE_OBJECT_SYMBOLS + *(.text) + . = ALIGN (16); + + /* + * C++ constructors + */ + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; + __DTOR_LIST__ = .; + LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) + *(.dtors) + LONG(0) + __DTOR_END__ = .; + + etext = .; + _etext = .; + } >rom + + .eh_fram : { + . = ALIGN (16); + *(.eh_fram) + } >ram + + .gcc_exc : { + . = ALIGN (16); + *(.gcc_exc) + } >ram + + /* + * On-chip memory/peripherals + * + */ + dpram : { + m340 = .; + _m340 = .; + . += (8 * 1024); + } >ram + + .data : { + copy_start = .; + *(.data) + . = ALIGN (16); + _edata = .; + copy_end = .; + } >ram + + .bss : { + M68Kvec = .; + _M68Kvec = .; + . += (256 * 4); + clear_start = .; + *(.bss) + *(COMMON) + . = ALIGN (16); + _end = .; + + _HeapStart = .; + __HeapStart = .; + . += HeapSize; /* XXX -- Old gld can't handle this */ + . += StackSize; /* XXX -- Old gld can't handle this */ + /* . += 0x10000; */ /* HeapSize for old gld */ + /* . += 0x1000; */ /* StackSize for old gld */ + . = ALIGN (16); + stack_init = .; + clear_end = .; + + _WorkspaceBase = .; + __WorkspaceBase = .; + } >ram +} |