summaryrefslogtreecommitdiffstats
path: root/bsps/m68k/gen68340
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 10:35:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:52:14 +0200
commit99648958668d3a33ee57974479b36201fe303f34 (patch)
tree6f27ea790e2823c6156e71219a4f54680263fac6 /bsps/m68k/gen68340
parentbsps: Move start files to bsps (diff)
downloadrtems-99648958668d3a33ee57974479b36201fe303f34.tar.bz2
bsps: Move startup files to bsps
Adjust build support files to new directory layout. This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'bsps/m68k/gen68340')
-rw-r--r--bsps/m68k/gen68340/start/bsp_specs10
-rw-r--r--bsps/m68k/gen68340/start/dumpanic.c190
-rw-r--r--bsps/m68k/gen68340/start/init68340.c38
-rw-r--r--bsps/m68k/gen68340/start/linkcmds248
4 files changed, 486 insertions, 0 deletions
diff --git a/bsps/m68k/gen68340/start/bsp_specs b/bsps/m68k/gen68340/start/bsp_specs
new file mode 100644
index 0000000000..3a20757667
--- /dev/null
+++ b/bsps/m68k/gen68340/start/bsp_specs
@@ -0,0 +1,10 @@
+%rename endfile old_endfile
+%rename startfile old_startfile
+
+*startfile:
+%{!qrtems: %(old_startfile)} \
+%{!nostdlib: %{qrtems: crti.o%s crtbegin.o%s}}
+
+*endfile:
+%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s crtn.o%s}
+
diff --git a/bsps/m68k/gen68340/start/dumpanic.c b/bsps/m68k/gen68340/start/dumpanic.c
new file mode 100644
index 0000000000..7f82ab3a77
--- /dev/null
+++ b/bsps/m68k/gen68340/start/dumpanic.c
@@ -0,0 +1,190 @@
+/*
+ * 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-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <rtems/bspIo.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;
+
+/******************************************************
+ Name: _dbug_dump
+ Input parameters: sr, pc, stack pointer,
+ size to display
+ Output parameters: -
+ Description: display the supervisor stack
+ *****************************************************/
+static void _dbug_dump(
+ unsigned short sr,
+ void* pc,
+ unsigned short *stack,
+ int size
+)
+{
+ int i;
+
+ printk("%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16));
+ for (i=2; i<size; i++) {
+ if ((i%8)==0) printk("\n%x :",i/8);
+ printk(" %x\t",stack[i-2]);
+ }
+ printk("\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;
+
+ printk("\n---------------------------------------------\n");
+ if (vector<64)
+ printk("%s",exceptionName[vector]);
+ else {
+ printk("RESERVED USER");
+ }
+ printk(" exception (vector %x, type %x)\n",vector,frametype);
+ printk("---------------------------------------------\n");
+ printk("PC : %p ",pc);
+ printk("A7 : 0x%lx ",_boot_panic_registers.a7);
+ printk("SR : 0x%x\n",status);
+ if (frametype==0x0c) {
+ printk("\nfaulted address = %p\n",faultedAddr);
+ }
+ printk("---------------------------------------------\n");
+ printk(" panic regs\n");
+ printk("---------------------------------------------\n");
+ printk("D[0..3] : %lx \t%lx \t%lx \t%lx\n",
+ _boot_panic_registers.d0,_boot_panic_registers.d1,
+ _boot_panic_registers.d2,_boot_panic_registers.d3);
+ printk("D[4..7] : %lx \t%lx \t%lx \t%lx\n",
+ _boot_panic_registers.d4,_boot_panic_registers.d5,
+ _boot_panic_registers.d6,_boot_panic_registers.d7);
+ printk("A[0..3] : %lx \t%lx \t%lx \t%lx\n",
+ _boot_panic_registers.a0,_boot_panic_registers.a1,
+ _boot_panic_registers.a2,_boot_panic_registers.a3);
+ printk("A[4..7] : %lx \t%lx \t%lx \t%lx\n",
+ _boot_panic_registers.a4,_boot_panic_registers.a5,
+ _boot_panic_registers.a6,_boot_panic_registers.a7);
+
+ printk(" SFC : %lx",_boot_panic_registers.sfc);
+ printk(" DFC : %lx\n",_boot_panic_registers.dfc);
+ printk(" VBR : %lx\n",_boot_panic_registers.vbr);
+ printk("---------------------------------------------\n");
+ printk(" panic stack\n");
+ printk("---------------------------------------------\n");
+ _dbug_dump(status, pc, (unsigned short*)stack,64*2);
+
+ printk("---------------------------------------------\n");
+ printk("press escape to reboot\n");
+ } while ((c=getchark())!=ESCAPE);
+}
diff --git a/bsps/m68k/gen68340/start/init68340.c b/bsps/m68k/gen68340/start/init68340.c
new file mode 100644
index 0000000000..ee30f415e9
--- /dev/null
+++ b/bsps/m68k/gen68340/start/init68340.c
@@ -0,0 +1,38 @@
+/*
+ * 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
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+extern void _CopyDataClearBSSAndStart (void);
+
+/*
+ * Initialize MC68340
+ */
+void _Init68340 (void)
+{
+ rtems_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/bsps/m68k/gen68340/start/linkcmds b/bsps/m68k/gen68340/start/linkcmds
new file mode 100644
index 0000000000..860115930e
--- /dev/null
+++ b/bsps/m68k/gen68340/start/linkcmds
@@ -0,0 +1,248 @@
+/*
+ * 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
+ */
+
+/*
+ * Declare some sizes.
+ */
+RamBase = DEFINED(RamBase) ? RamBase : 0x10000000;
+RamSize = DEFINED(RamSize) ? RamSize : 4M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
+_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 */
+}
+
+ENTRY(start)
+STARTUP(start.o)
+
+/*
+ * Declare low-order three octets of Ethernet address.
+ */
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
+
+/*
+ * Load objects
+ */
+SECTIONS {
+
+ /*
+ * Boot PROM
+ */
+ rom : {
+ _RomBase = .;
+ __RomBase = .;
+ } >rom
+
+ /*
+ * Dynamic RAM
+ */
+ ram : {
+ . = .;
+ } >ram
+
+ /*
+ * Text, data and bss segments
+ */
+ .text : {
+ *(.text*)
+
+ /*
+ * C++ constructors/destructors
+ */
+ *(.gnu.linkonce.t.*)
+
+ /*
+ * Initialization and finalization code.
+ *
+ * Various files can provide initialization and finalization
+ * functions. crtbegin.o and crtend.o are two instances. The
+ * body of these functions are in .init and .fini sections. We
+ * accumulate the bodies here, and prepend function prologues
+ * from crti.o and function epilogues from crtn.o. crti.o must
+ * be linked first; crtn.o must be linked last. Because these
+ * are wildcards, it doesn't matter if the user does not
+ * actually link against crti.o and crtn.o; the linker won't
+ * look for a file to match a wildcard. The wildcard also
+ * means that it doesn't matter which directory crti.o and
+ * crtn.o are in.
+ */
+ PROVIDE (_init = .);
+ *crti.o(.init)
+ *(.init)
+ *crtn.o(.init)
+ PROVIDE (_fini = .);
+ *crti.o(.fini)
+ *(.fini)
+ *crtn.o(.fini)
+
+ /*
+ * Special FreeBSD sysctl sections.
+ */
+ . = ALIGN (16);
+ __start_set_sysctl_set = .;
+ *(set_sysctl_*);
+ __stop_set_sysctl_set = ABSOLUTE(.);
+ *(set_domain_*);
+ *(set_pseudo_*);
+
+ /*
+ * C++ constructors/destructors
+ *
+ * gcc uses crtbegin.o to find the start of the constructors
+ * and destructors so we make sure it is first. Because this
+ * is a wildcard, it doesn't matter if the user does not
+ * actually link against crtbegin.o; the linker won't look for
+ * a file to match a wildcard. The wildcard also means that
+ * it doesn't matter which directory crtbegin.o is in. The
+ * constructor and destructor list are terminated in
+ * crtend.o. The same comments apply to it.
+ */
+ . = ALIGN (16);
+ *crtbegin.o(.ctors)
+ *(.ctors)
+ *crtend.o(.ctors)
+ *crtbegin.o(.dtors)
+ *(.dtors)
+ *crtend.o(.dtors)
+
+ /*
+ * Exception frame info
+ */
+ . = ALIGN (16);
+ *(.eh_frame)
+
+ /*
+ * Read-only data
+ */
+ . = ALIGN (16);
+ _rodata_start = . ;
+ *(.rodata*)
+ KEEP (*(SORT(.rtemsroset.*)))
+ *(.gnu.linkonce.r*)
+
+ . = ALIGN (16);
+ PROVIDE (_etext = .);
+ } >ram
+
+ .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));
+
+ .data : {
+ PROVIDE (_copy_start = .);
+ *(.data*)
+ KEEP (*(SORT(.rtemsrwset.*)))
+ *(.gnu.linkonce.d*)
+ *(.gcc_except_table*)
+ *(.jcr)
+ . = ALIGN (16);
+ PROVIDE (_edata = .);
+ PROVIDE (_copy_end = .);
+ } >ram
+ .bss : {
+ M68Kvec = .;
+ . += (256 * 4);
+ _clear_start = .;
+ *(.dynbss)
+ *(.bss* .gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN (16);
+ PROVIDE (end = .);
+
+ . += _StackSize;
+ . = ALIGN (16);
+ _stack_init = .;
+ _clear_end = .;
+
+ WorkAreaBase = .;
+ } >ram
+
+ /*
+ * On-chip memory/peripherals
+ *
+ */
+ dpram : {
+ m340 = .;
+ _m340 = .;
+ . += (8 * 1024);
+ } >ram
+
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+
+ /* 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 . */
+}