diff options
author | Joel Sherrill <joel@rtems.org> | 2016-01-23 16:47:35 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2016-01-23 16:47:35 -0600 |
commit | 482d4974b86d43ede7a24aeb5f3dd0d251901319 (patch) | |
tree | 5dcdea9c314e7ac3c712b200bd8e984bbbc1faf0 /c/src/lib/libbsp/m68k/ods68302/startup | |
parent | Obsolete and remove m68k/gen68302 (diff) | |
download | rtems-482d4974b86d43ede7a24aeb5f3dd0d251901319.tar.bz2 |
Obsolete and remove m68k/ods68302 BSP
closes #2544.
Diffstat (limited to 'c/src/lib/libbsp/m68k/ods68302/startup')
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/cpuboot.c | 140 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/crc.c | 86 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/debugger | 76 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/debugport.c | 160 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/gdb-hooks.c | 79 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/linkcmds | 223 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/m68302scc.c | 146 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c | 1087 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/rom | 77 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/ods68302/startup/trace.c | 171 |
10 files changed, 0 insertions, 2245 deletions
diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/cpuboot.c b/c/src/lib/libbsp/m68k/ods68302/startup/cpuboot.c deleted file mode 100644 index 2d537facc2..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/cpuboot.c +++ /dev/null @@ -1,140 +0,0 @@ -/*****************************************************************************/ -/* - Boot the CPU. - - Occurs in 3 phases for a 68302. - - Phase 1. - - Called as soon as able after reset. The BAR has been programed, and - a small stack exists in the DPRAM. All interrupts are masked, and - the processor is running in supervisor mode. No other hardware or - chip selects are active. - - This phase programs the chip select registers, the parallel ports - are set into default configurations, and basic registers cleared or - reset. The leds are programmed to show the end of phase 1. - - Phase 2. - - This is a piece of code which is copied to DPRAM and executed. It - should not do any more thann is currently present. The return to ROM - is managed by modifing the return address. Again leds show the status. - - Phase 3. - - This code executes with a valid C environment. That is the data - section has been intialised and the bss section set to 0. This phase - performs any special card initialisation and then calls boot card. - -*/ -/*****************************************************************************/ - -#include <bsp.h> -#include <bsp/bootcard.h> -#include <rtems/m68k/m68302.h> -#include <debugport.h> -#include <crc.h> - -/* - Open the address, reset all registers - */ - -extern int ROM_SIZE, ROM_BASE; -extern int RAM_SIZE, RAM_BASE; - -#define _ROM_SIZE ((unsigned int)&ROM_SIZE) -#define _ROM_BASE ((unsigned int)&ROM_BASE) -#define _RAM_SIZE ((unsigned int)&RAM_SIZE) -#define _RAM_BASE ((unsigned int)&RAM_BASE) - -void boot_phase_1(void) -{ - M302_SCR = SCR_DEFAULT; - - WRITE_OR(CSEL_ROM, _ROM_SIZE, ROM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC); - WRITE_BR(CSEL_ROM, _RAM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED); - WRITE_OR(CSEL_RAM, _RAM_SIZE, RAM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC); - WRITE_BR(CSEL_RAM, _ROM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED); - -#if defined(CSEL_1) - WRITE_OR(CSEL_1, CSEL_1_SIZE, CSEL_1_WAIT_STATES, OR_MASK_RW, OR_MASK_FC); - WRITE_BR(CSEL_1, CSEL_1_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED); -#endif - -#if defined(CSEL_2) - WRITE_OR(CSEL_2, CSEL_2_SIZE, CSEL_2_WAIT_STATES, OR_MASK_RW, OR_MASK_FC); - WRITE_BR(CSEL_2, CSEL_2_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED); -#endif - - m302.reg.ipr = m302.reg.imr = m302.reg.isr = 0; - m302.reg.gimr = 0x0080; - - m302.reg.simode = 0; - - m302.reg.pacnt = CARD_PA_CONFIGURATION; - m302.reg.paddr = CARD_PA_DEFAULT_DIRECTIONS; - m302.reg.padat = CARD_PA_DEFAULT_DATA; - - m302.reg.pbcnt = CARD_PB_CONFIGURATION; - m302.reg.pbddr = CARD_PB_DEFAULT_DIRECTIONS; - m302.reg.pbdat = CARD_PB_DEFAULT_DATA; - - m302.reg.wrr = WATCHDOG_TIMEOUT_PERIOD | WATCHDOG_ENABLE; - -#if defined(LED_CONTROL) - LED_CONTROL(LED_1_RED, LED_2_OFF, LED_3_OFF, LED_4_OFF, - LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF); -#endif -} - -/* - Swap the chip select mapping for ROM and RAM - */ - -void boot_phase_2(void) -{ - uint32_t stack; - -#if defined(LED_CONTROL) - LED_CONTROL(LED_1_RED, LED_2_RED, LED_3_OFF, LED_4_OFF, - LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF); -#endif - - WRITE_BR(CSEL_ROM, _ROM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED); - WRITE_BR(CSEL_RAM, _RAM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED); - -#if defined(LED_CONTROL) - LED_CONTROL(LED_1_GREEN, LED_2_RED, LED_3_OFF, LED_4_OFF, - LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF); -#endif - - /* seems to want 2, looked at assember code output */ - *((volatile uint32_t*) (&stack + 2)) |= ROM_BASE; -} - -/* - Any pre-main initialisation, the C environment is setup, how-ever C++ - static constructors have not been called, and RTEMS is not initialised. - */ - -void set_debug_traps(void); -void breakpoint(void); - -void boot_phase_3(void) -{ - if (GDB_RUN_MONITOR()) - { - set_debug_traps(); - breakpoint(); - } - - debug_port_banner(); - - /* FIXME : add RAM and ROM checks */ - - /* boot the bsp, what ever this means */ - boot_card((void*)0); - - WATCHDOG_TRIGGER(); -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/crc.c b/c/src/lib/libbsp/m68k/ods68302/startup/crc.c deleted file mode 100644 index 4170f9c57b..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/*****************************************************************************/ -/* - CRC 16 Calculation - - This module calculates the CRC-16. - - */ -/*****************************************************************************/ - -#include "bsp.h" -#include <rtems/m68k/m68302.h> -#include "crc.h" - - /* ---- - C O N S T A N T S - - */ - -static const uint16_t factor[] = - { - 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, - 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, - 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, - 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, - 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, - 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, - 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, - 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, - 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, - 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, - 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, - 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, - 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, - 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, - 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, - 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, - 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, - 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, - 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, - 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, - 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, - 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, - 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, - 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, - 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, - 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, - 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, - 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, - 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, - 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, - 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, - 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 - }; - -/* - MACRO : calculates a CRC byte wise - */ - -#define NEW_CRC(byte, crc) factor[(byte) ^ ((crc) & 0xFF)] ^ (((crc) >> 8) & 0xFF) - -/* ---- - CalcCRC - - Calculates the CRC value of a block of memory -*/ - -uint16_t calc_crc(void* vdata, /* pointer to memory block */ - uint32_t count) /* length of block in bytes */ -{ - register uint8_t *data = vdata; - register uint16_t crc; - register uint32_t byte; - - /* initialise to either 0x0 or 0xffff depending on the - CRC implementation */ - - crc = 0; - - for (byte = count; byte > 0; byte--) - { - WATCHDOG_TOGGLE(); - crc = NEW_CRC(*data++, crc); - } - - return crc; -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/debugger b/c/src/lib/libbsp/m68k/ods68302/startup/debugger deleted file mode 100644 index 62fd5bc07d..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/debugger +++ /dev/null @@ -1,76 +0,0 @@ -/* - * MC68302 Linker command file - */ - -SECTIONS -{ - .text . : - { - text_start = .; - *(.text) - etext = .; - . = ALIGN(4); - __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) - *(.ctors) - LONG(0) - __CTOR_END__ = .; - . = ALIGN(4); - __DTOR_LIST__ = .; - LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) - *(.dtors) - LONG(0) - __DTOR_END__ = .; - } - - .tdata : { - _TLS_Data_begin = .; - *(.tdata .tdata.* .gnu.linkonce.td.*) - _TLS_Data_end = .; - } - .tbss : { - _TLS_BSS_begin = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) - _TLS_BSS_end = .; - } - _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)); - - .vtable (ADDR(.text) + SIZEOF(.text)) : - { - vtable_start = .; - *(.vtable) - evtable = .; - } - .data (ADDR(.vtable) + SIZEOF(.vtable)) : - { - data_start = .; - *(.data) - KEEP (*(SORT(.rtemsroset.*))) - KEEP (*(SORT(.rtemsrwset.*))) - edata = .; - } - .bss (ADDR(.data) + SIZEOF(.data)) : - { - bss_start = .; - *(.bss) - *(COMMON) - end = . ; - _end = . ; - } -} - - -RAM_BASE = DEFINED(RAM_BASE) ? RAM_BASE : 0x00000000; -RAM_SIZE = DEFINED(RAM_SIZE) ? RAM_SIZE : 0x00100000; -ROM_BASE = DEFINED(ROM_BASE) ? ROM_BASE : 0x00010000; -ROM_SIZE = DEFINED(ROM_SIZE) ? ROM_SIZE : 0x00100000; -MC68302_BASE = DEFINED(MC68302_BASE) ? MC68302_BASE : 0x00700000; -m302 = MC68302_BASE; -_VBR = 0; /* location of the VBR table (in RAM) */ - -ENTRY(start); diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/debugport.c b/c/src/lib/libbsp/m68k/ods68302/startup/debugport.c deleted file mode 100644 index fcbdc99e86..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/debugport.c +++ /dev/null @@ -1,160 +0,0 @@ -/*****************************************************************************/ -/* - High Level Debug Port Functions - - */ -/*****************************************************************************/ - -#include <stdio.h> -#include <stdarg.h> - -#include "debugport.h" -#include "m68302scc.h" -#include "bsp.h" - -static int initialised; - -void debug_port_initialise(void) -{ - scc_initialise(CONSOLE_PORT, CONSOLE_BAUD, FALSE); -#if defined(DEBUG_PORT) - scc_initialise(DEBUG_PORT, DEBUG_BAUD, FALSE); -#endif -} - -unsigned char debug_port_status(const unsigned char status) -{ - if (!initialised) - { - initialised = 1; - debug_port_initialise(); - } - - return scc_status(CONSOLE_PORT, status); -} - -unsigned char debug_port_in(void) -{ - if (!initialised) - { - initialised = 1; - debug_port_initialise(); - } - - return scc_in(CONSOLE_PORT); -} - -void debug_port_out(const unsigned char character) -{ - if (!initialised) - { - initialised = 1; - debug_port_initialise(); - } - - scc_out(CONSOLE_PORT, character); -} - -void debug_port_write(const char *buffer) -{ - while (*buffer != '\0') - { - debug_port_out(*buffer++); - } -} - -void debug_port_write_buffer(const char *buffer, unsigned int size) -{ - unsigned int count; - for (count = 0; count < size; count++) - { - debug_port_out(buffer[count]); - } -} - -void debug_port_write_hex_uint(const unsigned int value) -{ - unsigned int bits = sizeof(value) * 8; - unsigned char c; - - do - { - bits -= 4; - c = (unsigned char) ((value >> bits) & 0x0F); - if (c < 10) - { - c += '0'; - } - else - { - c += 'a' - 10; - } - debug_port_out((char) c); - } - while (bits); -} - -void debug_port_write_hex_ulong(const unsigned long value) -{ - unsigned int bits = sizeof(value) * 8; - unsigned char c; - - do - { - bits -= 4; - c = (unsigned char) ((value >> bits) & 0x0F); - if (c < 10) - { - c += '0'; - } - else - { - c += 'a' - 10; - } - debug_port_out((char) c); - } - while (bits); -} - -#define BUFFER_SIZE (256) -static char buffer[BUFFER_SIZE]; - -void debug_port_printf(const char *format, ...) -{ - va_list args; - int written; - - /* gain access to the argument list */ - va_start(args, format); - - /* set the trap */ - buffer[BUFFER_SIZE - 2] = '\xAA'; - buffer[BUFFER_SIZE - 1] = '\x55'; - - /* format the string and send to stdout */ - written = vsprintf(buffer, format, args); - - /* try an trap format buffer overflows */ - if ((buffer[BUFFER_SIZE - 2] != '\xAA') || - (buffer[BUFFER_SIZE - 1] != '\x55')) - { - debug_port_write("debug port buffer overflow, halting..."); - DISABLE_WATCHDOG(); - while (1 == 1); - } - - /* see if an error occurred, if not flush the output buffer */ - if (written != -1) - { - debug_port_write_buffer(buffer, written); - } -} - -void debug_port_banner(void) -{ -#define CARD_LABEL "ods68302-" #VARIANT - - debug_port_write("\n\n\r"); - debug_port_write(_Copyright_Notice); - debug_port_write("\n\r " CARD_ID "\n\r"); -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/gdb-hooks.c b/c/src/lib/libbsp/m68k/ods68302/startup/gdb-hooks.c deleted file mode 100644 index 45bfe42725..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/gdb-hooks.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Hooks for GDB - * - */ - -#include <bsp.h> -#include <rtems/m68k/m68302.h> -#include <m68302scc.h> - -static int initialised = 0; - -/* - * This file does not intend to make things part of the public interface. - * Methods here are only available to the GDB stub. So prototypes are - * needed to avoid warnings. - */ -void putDebugChar(char ch); -char getDebugChar(void); -void exceptionHandler(unsigned int vector, void *handler); - -void putDebugChar(char ch) -{ - if (!initialised) - { - scc_initialise(DEBUG_PORT, DEBUG_BAUD, 0); - initialised = 1; - } - - scc_out(DEBUG_PORT, ch); -} - -char getDebugChar(void) -{ - if (!initialised) - { - scc_initialise(DEBUG_PORT, DEBUG_BAUD, 0); - initialised = 1; - } - - while (!scc_status(DEBUG_PORT, 0)); - - return scc_in(DEBUG_PORT); -} - -/* - * Need to create yet another jump table for gdb this time - */ - -void (*exceptionHook)(unsigned int) = 0; - -typedef struct { - uint16_t move_a7; /* move #FORMAT_ID,%a7@- */ - uint16_t format_id; - uint16_t jmp; /* jmp _ISR_Handlers */ - uint32_t isr_handler; -} GDB_HANDLER_ENTRY; - -#if !defined(M68K_MOVE_A7) -#define M68K_MOVE_A7 0x3F3C -#endif - -#if !defined(M68K_JMP) -#define M68K_JMP 0x4EF9 -#endif - -/* points to jsr-exception-table in targets wo/ VBR register */ -static GDB_HANDLER_ENTRY gdb_jump_table[256]; - -void exceptionHandler(unsigned int vector, void *handler) -{ - uint32_t *interrupt_table = 0; - - gdb_jump_table[vector].move_a7 = M68K_MOVE_A7; - gdb_jump_table[vector].format_id = vector; - gdb_jump_table[vector].jmp = M68K_JMP; - gdb_jump_table[vector].isr_handler = (uint32_t) handler; - - interrupt_table[vector] = (uint32_t) &gdb_jump_table[vector]; -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/linkcmds b/c/src/lib/libbsp/m68k/ods68302/startup/linkcmds deleted file mode 100644 index 39bdee0cbc..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/linkcmds +++ /dev/null @@ -1,223 +0,0 @@ -/* - * MC68302 Linker command file - * - */ - -/* - * Declare some sizes. - */ -RamBase = DEFINED(RamBase) ? RamBase : 0x0; -RamSize = DEFINED(RamSize) ? RamSize : 1M; -HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0; -_StackSize = DEFINED(_StackSize) ? _StackSize : 0x1000; - -/* - * Memory map. - */ -RAM_BASE = DEFINED(RAM_BASE) ? RAM_BASE : 0x00000000; -RAM_SIZE = DEFINED(RAM_SIZE) ? RAM_SIZE : 0x00100000; -ROM_BASE = DEFINED(ROM_BASE) ? ROM_BASE : 0x00C00000; -ROM_SIZE = DEFINED(ROM_SIZE) ? ROM_SIZE : 0x00100000; -MC68302_BASE = DEFINED(MC68302_BASE) ? MC68302_BASE : 0x00700000; - -/* - * Declare on-board memory. - */ -MEMORY { - ram : ORIGIN = 0x00000000, LENGTH = 1M - rom : ORIGIN = 0x00C00000, LENGTH = 512K -} -SECTIONS -{ - .vtable RAM_BASE : - { - vtable_start = .; - *(.vtable*) - evtable = .; - } >ram - - /* - * Text, data and bss segments - */ - .text ROM_BASE : { - /* - * Needs to be first. 8K limit on CS0 at reset. - */ - *(.resettext); - *cpuboot.o(.text*) - - /* - * The reset of the text is entered once CS0 is remapped. - */ - *(.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 = .); - } >rom - - .tdata : { - _TLS_Data_begin = .; - *(.tdata .tdata.* .gnu.linkonce.td.*) - _TLS_Data_end = .; - } >rom - - .tbss : { - _TLS_BSS_begin = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) - _TLS_BSS_end = .; - } >rom - - _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 (ADDR(.vtable) + SIZEOF(.vtable)) : - AT (ADDR(.tdata) + SIZEOF(.tdata)) { - PROVIDE (_copy_start = .); - *(.data*) - KEEP (*(SORT(.rtemsrwset.*))) - *(.gnu.linkonce.d*) - *(.gcc_except_table*) - *(.jcr) - . = ALIGN (16); - PROVIDE (_edata = .); - PROVIDE (_copy_end = .); - } >ram - .bss (ADDR(.data) + SIZEOF(.data)) : { - _clear_start = .; - *(.dynbss) - *(.bss* .gnu.linkonce.b.*) - *(COMMON) - . = ALIGN (16); - PROVIDE (end = .); - - . += _StackSize; - . = ALIGN (16); - _stack_init = .; - _clear_end = .; - - WorkAreaBase = .; - } >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 . */ -} - -m302 = MC68302_BASE; -_VBR = ADDR(.vtable); /* location of the VBR table (in RAM) */ - diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/m68302scc.c b/c/src/lib/libbsp/m68k/ods68302/startup/m68302scc.c deleted file mode 100644 index 6065cfb1ac..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/m68302scc.c +++ /dev/null @@ -1,146 +0,0 @@ -/*****************************************************************************/ -/* - M68302 SCC Polled Driver - - */ -/*****************************************************************************/ - -#include <bsp.h> -#include <rtems/m68k/m68302.h> -#include <m68302scc.h> - -#define M68302_SCC_COUNT (3) - -static volatile m302_SCC_t *scc[M68302_SCC_COUNT] = { 0, 0, 0 }; -static volatile m302_SCC_Registers_t *scc_reg[M68302_SCC_COUNT] = { 0, 0, 0 }; -static int scc_translate[M68302_SCC_COUNT] = { 0, 0, 0 }; - -static const uint16_t baud_clocks[] = -{ - (SYSTEM_CLOCK / ( 4800 * 16)), - (SYSTEM_CLOCK / ( 9600 * 16)), - (SYSTEM_CLOCK / ( 19200 * 16)), - (SYSTEM_CLOCK / ( 38400 * 16)), - (SYSTEM_CLOCK / ( 57600 * 16)), - (SYSTEM_CLOCK / (115700 * 16)) -}; - -void scc_initialise(int channel, int baud, int translate) -{ - uint16_t scon; - - if (channel < M68302_SCC_COUNT) - { - scc[channel] = &m302.scc1 + channel; - scc_reg[channel] = &m302.reg.scc[channel]; - scc_translate[channel] = translate; - - scon = (baud_clocks[baud] & 0xF800) == 0 ? 0 : 1; - scon |= (((baud_clocks[baud] / (1 + scon * 3)) - 1) << 1) & 0x0FFE; - - scc_reg[channel]->scon = scon; - scc_reg[channel]->scm = 0x0171; - - scc[channel]->bd.tx[0].status = 0x2000; - scc[channel]->bd.tx[0].length = 0; - scc[channel]->bd.tx[0].buffer = - (uint8_t*) &(scc[channel]->bd.tx[1].buffer); - - scc[channel]->bd.rx[0].status = 0x2000; - scc[channel]->bd.rx[0].length = 0; - scc[channel]->bd.rx[0].buffer = - (uint8_t*) &(scc[channel]->bd.rx[1].buffer); - - scc[channel]->parm.rfcr = 0x50; - scc[channel]->parm.tfcr = 0x50; - - scc[channel]->parm.mrblr = 0x0001; - scc[channel]->prot.uart.max_idl = 0x0004; - scc[channel]->prot.uart.brkcr = 1; - scc[channel]->prot.uart.parec = 0; - scc[channel]->prot.uart.frmec = 0; - scc[channel]->prot.uart.nosec = 0; - scc[channel]->prot.uart.brkec = 0; - scc[channel]->prot.uart.uaddr1 = 0; - scc[channel]->prot.uart.uaddr2 = 0; - scc[channel]->prot.uart.character[0] = 0x0003; - scc[channel]->prot.uart.character[1] = 0x8000; - - scc_reg[channel]->scce = 0xFF; - scc_reg[channel]->sccm = 0x15; - - scc_reg[channel]->scm = 0x17d; - } -} - -unsigned char scc_status(int channel, unsigned char status) -{ - uint16_t rx_status; - - m302.reg.wcn = 0; - - if ((channel < M68302_SCC_COUNT) && scc[channel]) - { - rx_status = scc[channel]->bd.rx[0].status; - - if ((rx_status & 0x8000) == 0) - { - if (rx_status & 0x003B) - { - return 2; - } - if (status == 0) - { - return 1; - } - } - } - - return 0; -} - -unsigned char scc_in(int channel) -{ - m302.reg.wcn = 0; - - if ((channel < M68302_SCC_COUNT) && scc[channel]) - { - if ((scc[channel]->bd.rx[0].status & 0x8000) == 0) - { - unsigned char c; - - c = *(scc[channel]->bd.rx[0].buffer); - - scc[channel]->bd.rx[0].status = 0xa000; - - return c; - } - } - - return 0; -} - -void scc_out(int channel, unsigned char character) -{ - if ((channel < M68302_SCC_COUNT) && scc[channel]) - { - do - { - m302.reg.wcn = 0; - } - while (scc[channel]->bd.tx[0].status & 0x8000); - - *(scc[channel]->bd.tx[0].buffer) = character; - - scc[channel]->bd.tx[0].length = 1; - scc[channel]->bd.tx[0].status = 0xa000; - - if (scc_translate[channel]) - { - if (character == '\n') - { - scc_out(channel, '\r'); - } - } - } -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c b/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c deleted file mode 100644 index d9533efa06..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c +++ /dev/null @@ -1,1087 +0,0 @@ -/**************************************************************************** - - THIS SOFTWARE IS NOT COPYRIGHTED - - HP offers the following for use in the public domain. HP makes no - warranty with regard to the software or it's performance and the - user accepts the software "AS IS" with all faults. - - HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD - TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -****************************************************************************/ - -/**************************************************************************** - * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $ - * - * Module name: remcom.c $ - * Revision: 1.34 $ - * Date: 91/03/09 12:29:49 $ - * Contributor: Lake Stevens Instrument Division$ - * - * Description: low level support for gdb debugger. $ - * - * Considerations: only works on target hardware $ - * - * Written by: Glenn Engel $ - * ModuleState: Experimental $ - * - * NOTES: See Below $ - * - * To enable debugger support, two things need to happen. One, a - * call to set_debug_traps() is necessary in order to allow any breakpoints - * or error conditions to be properly intercepted and reported to gdb. - * Two, a breakpoint needs to be generated to begin communication. This - * is most easily accomplished by a call to breakpoint(). Breakpoint() - * simulates a breakpoint by executing a trap #1. The breakpoint instruction - * is hardwired to trap #1 because not to do so is a compatibility problem-- - * there either should be a standard breakpoint instruction, or the protocol - * should be extended to provide some means to communicate which breakpoint - * instruction is in use (or have the stub insert the breakpoint). - * - * Some explanation is probably necessary to explain how exceptions are - * handled. When an exception is encountered the 68000 pushes the current - * program counter and status register onto the supervisor stack and then - * transfers execution to a location specified in it's vector table. - * The handlers for the exception vectors are hardwired to jmp to an address - * given by the relation: (exception - 256) * 6. These are decending - * addresses starting from -6, -12, -18, ... By allowing 6 bytes for - * each entry, a jsr, jmp, bsr, ... can be used to enter the exception - * handler. Using a jsr to handle an exception has an added benefit of - * allowing a single handler to service several exceptions and use the - * return address as the key differentiation. The vector number can be - * computed from the return address by [ exception = (addr + 1530) / 6 ]. - * The sole purpose of the routine _catchException is to compute the - * exception number and push it on the stack in place of the return address. - * The external function exceptionHandler() is - * used to attach a specific handler to a specific m68k exception. - * For 68020 machines, the ability to have a return address around just - * so the vector can be determined is not necessary because the '020 pushes an - * extra word onto the stack containing the vector offset - * - * Because gdb will sometimes write to the stack area to execute function - * calls, this program cannot rely on using the supervisor stack so it - * uses it's own stack area reserved in the int array remcomStack. - * - ************* - * - * The following gdb commands are supported: - * - * command function Return value - * - * g return the value of the CPU registers hex data or ENN - * G set the value of the CPU registers OK or ENN - * - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN - * - * c Resume at current address SNN ( signal NN) - * cAA..AA Continue at address AA..AA SNN - * - * s Step one instruction SNN - * sAA..AA Step one instruction from AA..AA SNN - * - * k kill - * - * ? What was the last sigval ? SNN (signal NN) - * - * All commands and responses are sent with a packet which includes a - * checksum. A packet consists of - * - * $<packet info>#<checksum>. - * - * where - * <packet info> :: <characters representing the command or response> - * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>> - * - * When a packet is received, it is first acknowledged with either '+' or '-'. - * '+' indicates a successful transfer. '-' indicates a failed transfer. - * - * Example: - * - * Host: Reply: - * $m0,10#2a +$00010203040506070809101112131415#42 - * - ****************************************************************************/ - -#include <stdio.h> -#include <string.h> -#include <setjmp.h> - -#include <bsp.h> -#include <debugport.h> - -/************************************************************************ - * - * external low-level support routines - */ -typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ -typedef void (*Function)(void); /* pointer to a function */ - -/* assign an exception handler */ -Function exceptionHandler(int vector, Function handler); -extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ - -int putDebugChar(char ch); -char getDebugChar(void); - -/************************/ -/* FORWARD DECLARATIONS */ -/************************/ -static int hex(char ch); -static void getpacket(char *buffer); -static void putpacket(char *buffer); -static char* mem2hex(char *mem, char *buf, int count); -static char* hex2mem(char *buf, char *mem, int count); -static void handle_buserror(void); -static int computeSignal(int exceptionVector); -static int hexToInt(char **ptr, int *intValue); - void handle_exception(int exceptionVector); -static void initializeRemcomErrorFrame(void); - -void set_debug_traps(void); -void breakpoint(void); - -/************************************************************************/ -/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ -/* at least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX 400 - -static bool initialized = false; /* boolean flag. != 0 means we've been initialized */ - -int remote_debug; -/* debug > 0 prints ill-formed commands in valid packets & checksum errors */ - -static const char hexchars[]="0123456789abcdef"; - -/* there are 180 bytes of registers on a 68020 w/68881 */ -/* many of the fpa registers are 12 byte (96 bit) registers */ -#define NUMREGBYTES 180 -enum regnames {D0,D1,D2,D3,D4,D5,D6,D7, - A0,A1,A2,A3,A4,A5,A6,A7, - PS,PC, - FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7, - FPCONTROL,FPSTATUS,FPIADDR - }; - - -/* We keep a whole frame cache here. "Why?", I hear you cry, "doesn't - GDB handle that sort of thing?" Well, yes, I believe the only - reason for this cache is to save and restore floating point state - (fsave/frestore). A cleaner way to do this would be to make the - fsave data part of the registers which GDB deals with like any - other registers. This should not be a performance problem if the - ability to read individual registers is added to the protocol. */ - -typedef struct FrameStruct -{ - struct FrameStruct *previous; - int exceptionPC; /* pc value when this frame created */ - int exceptionVector; /* cpu vector causing exception */ - short frameSize; /* size of cpu frame in words */ - short sr; /* for 68000, this not always sr */ - int pc; - short format; - int fsaveHeader; - int morejunk[0]; /* exception frame, fp save... */ -} Frame; - -#define FRAMESIZE 500 -int gdbFrameStack[FRAMESIZE]; -static Frame *lastFrame; - -/* - * these should not be static cuz they can be used outside this module - */ -int registers[NUMREGBYTES/4]; -int superStack; - -#define STACKSIZE 10000 -int remcomStack[STACKSIZE/sizeof(int)]; -static int* stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1]; - -/* - * In many cases, the system will want to continue exception processing - * when a continue command is given. - * oldExceptionHook is a function to invoke in this case. - */ - -static ExceptionHook oldExceptionHook; - -#if (defined(__mc68020__) && !defined(__mcpu32__)) -/* the size of the exception stack on the 68020 varies with the type of - * exception. The following table is the number of WORDS used - * for each exception format. - */ -const short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,12,4,4,4 }; -#endif - -#if defined(__mc68332__) -static const short exceptionSize[] = { 4,4,6,4,4,4,4,4,4,4,4,4,16,4,4,4 }; -#endif - -/************* jump buffer used for setjmp/longjmp **************************/ -jmp_buf remcomEnv; - -/*************************** ASSEMBLY CODE MACROS *************************/ -/* */ - -#if defined(__HAVE_68881__) - -/* do an fsave, then remember the address to begin a restore from */ -#define SAVE_FP_REGS() \ - __asm__ (" fsave %a0@-"); \ - __asm__ (" fmovemx %fp0-%fp7,registers+72"); \ - __asm__ (" fmoveml %fpcr/%fpsr/%fpi,registers+168"); - -#define RESTORE_FP_REGS() \ -__asm__ (" \n\ - fmoveml registers+168,%fpcr/%fpsr/%fpi \n\ - fmovemx registers+72,%fp0-%fp7 \n\ - cmpl #-1,%a0@ | skip frestore flag set ? \n\ - beq skip_frestore \n\ - frestore %a0@+ \n\ -skip_frestore: \n\ -"); - -#else - -#define SAVE_FP_REGS() -#define RESTORE_FP_REGS() - -#endif /* __HAVE_68881__ */ - -void return_to_super(void); -void return_to_user(void); - -__asm__ ("\n\ - .text\n\ -\n\ - .globl return_to_super\n\ - .align 4\n\ -return_to_super:\n\ - movel registers+60,%sp /* get new stack pointer */ \n\ - movel lastFrame,%a0 /* get last frame info */ \n\ - bra return_to_any\n\ -\n\ - .globl return_to_user\n\ - .align 4\n\ -\n\ -return_to_user:\n\ - movel registers+60,%a0 /* get usp */ \n\ - movel %a0,%usp /* set usp */ \n\ - movel superStack,%sp /* get original stack pointer */ \n\ -\n\ -return_to_any:\n\ - movel lastFrame,%a0 /* get last frame info */ \n\ - movel %a0@+,lastFrame /* link in previous frame */ \n\ - addql #8,%a0 /* skip over pc, vector#*/ \n\ - movew %a0@+,%d0 /* get # of words in cpu frame */ \n\ - addw %d0,%a0 /* point to end of data */ \n\ - addw %d0,%a0 /* point to end of data */ \n\ - movel %a0,%a1 \n\ -# \n\ -# copy the stack frame \n\ - subql #1,%d0\n\ -\n\ -copyUserLoop: \n\ - movew %a1@-,%sp@- \n\ - dbf %d0,copyUserLoop \n\ -"); - RESTORE_FP_REGS() -__asm__ ("\n\ - moveml registers,%d0-%d7/%a0-%a6\n\ - rte /* pop and go! */\n\ -"); - -#define DISABLE_INTERRUPTS() __asm__ (" oriw #0x0700,%sr"); -#define BREAKPOINT() __asm__ (" trap #1"); - -/* this function is called immediately when a level 7 interrupt occurs */ -/* if the previous interrupt level was 7 then we're already servicing */ -/* this interrupt and an rte is in order to return to the debugger. */ -/* For the 68000, the offset for sr is 6 due to the jsr return address */ -__asm__ ("\n\ - .text\n\ - .globl _debug_level7\n\ - .align 4\n\ -\n\ -_debug_level7:\n\ - movew %d0,%sp@-\n\ -"); - -#if (defined(__mc68020__) && !defined(__mcpu32__)) || defined(__mc68332__) -__asm__ ("\n\ - movew %sp@(2),%d0\n\ -"); -#else -__asm__ ("\n\ - movew %sp@(6),%d0\n\ -"); -#endif -__asm__ ("\n\ - andiw #0x700,%d0\n\ - cmpiw #0x700,%d0\n\ - beq _already7\n\ - movew %sp@+,%d0 \n\ - bra _catchException\n\ -_already7:\n\ - movew %sp@+,%d0\n\ -"); -#if defined (__mc68000__) && !(defined(__mc68020__) && !defined(__mcpu32__)) -__asm__ ("\n\ - lea %sp@(4),%sp"); /* pull off 68000 return address */ -#endif -__asm__ ("\n\ - rte\n\ -"); - -extern void _catchException(void); - -#if (defined(__mc68020__) && !defined(__mcpu32__)) || defined(__mc68332__) -/* This function is called when a 68020 exception occurs. It saves - * all the cpu and fpcp regs in the _registers array, creates a frame on a - * linked list of frames which has the cpu and fpcp stack frames needed - * to properly restore the context of these processors, and invokes - * an exception handler (remcom_handler). - * - * stack on entry: stack on exit: - * N bytes of junk exception # MSWord - * Exception Format Word exception # MSWord - * Program counter LSWord - * Program counter MSWord - * Status Register - * - * - */ -__asm__ (" \n\ - .text\n\ -\n\ - .globl _catchException\n\ - .align 4\n\ -_catchException:\n\ -"); - -DISABLE_INTERRUPTS(); - -__asm__ ("\n\ - moveml %d0-%d7/%a0-%a6,registers /* save registers */\n\ - movel lastFrame,%a0 /* last frame pointer */\n\ -"); -SAVE_FP_REGS(); -__asm__ ("\n\ - lea registers,%a5 /* get address of registers */\n\ - movew %sp@,%d1 /* get status register */\n\ - movew %d1,%a5@(66) /* save sr */ \n\ - movel %sp@(2),%a4 /* save pc in %a4 for later use */\n\ - movel %a4,%a5@(68) /* save pc in _regisers[] */\n\ -\n\ -#\n\ -# figure out how many bytes in the stack frame\n\ -#\n\ - movew %sp@(6),%d0 /* get '020 exception format */\n\ - movew %d0,%d2 /* make a copy of format word */\n\ - andiw #0xf000,%d0 /* mask off format type */\n\ - rolw #5,%d0 /* rotate into the low byte *2 */\n\ - lea exceptionSize,%a1 \n\ - addw %d0,%a1 /* index into the table */\n\ - movew %a1@,%d0 /* get number of words in frame */\n\ - movew %d0,%d3 /* save it */\n\ - subw %d0,%a0 /* adjust save pointer */\n\ - subw %d0,%a0 /* adjust save pointer(bytes) */\n\ - movel %a0,%a1 /* copy save pointer */\n\ - subql #1,%d0 /* predecrement loop counter */\n\ -#\n\ -# copy the frame\n\ -#\n\ -saveFrameLoop:\n\ - movew %sp@+,%a1@+\n\ - dbf %d0,saveFrameLoop\n\ -#\n\ -# now that the stack has been clenaed,\n\ -# save the %a7 in use at time of exception\n\ -\n\ - movel %sp,superStack /* save supervisor %sp */\n\ - andiw #0x2000,%d1 /* were we in supervisor mode ? */\n\ - beq userMode \n\ - movel %a7,%a5@(60) /* save %a7 */\n\ - bra a7saveDone\n\ -userMode: \n\ - movel %usp,%a1 \n\ - movel %a1,%a5@(60) /* save user stack pointer */\n\ -a7saveDone:\n\ -\n\ -#\n\ -# save size of frame\n\ - movew %d3,%a0@-\n\ -\n\ -#\n\ -# compute exception number\n\ - andl #0xfff,%d2 /* mask off vector offset */\n\ - lsrw #2,%d2 /* divide by 4 to get vect num */\n\ - movel %d2,%a0@- /* save it */\n\ -#\n\ -# save pc causing exception\n\ - movel %a4,%a0@-\n\ -#\n\ -# save old frame link and set the new value\n\ - movel lastFrame,%a1 /* last frame pointer */\n\ - movel %a1,%a0@- /* save pointer to prev frame */\n\ - movel %a0,lastFrame\n\ -\n\ - movel %d2,%sp@- /* push exception num */\n\ - movel exceptionHook,%a0 /* get address of handler */\n\ - jbsr %a0@ /* and call it */\n\ - clrl %sp@ /* replace exception num parm with frame ptr */\n\ - jbsr _returnFromException /* jbsr, but never returns */\n\ -\n\ -"); - -#else /* mc68000 */ - -/* This function is called when an exception occurs. It translates the - * return address found on the stack into an exception vector # which - * is then handled by either handle_exception or a system handler. - * _catchException provides a front end for both. - * - * stack on entry: stack on exit: - * Program counter MSWord exception # MSWord - * Program counter LSWord exception # MSWord - * Status Register - * Return Address MSWord - * Return Address LSWord - */ -__asm__ ("\n\ - .text\n\ - .globl _catchException\n\ - .align 4\n\ -_catchException:\n\ -"); -DISABLE_INTERRUPTS(); -__asm__ ("\n\ - moveml %d0-%d7/%a0-%a6,registers /* save registers */\n\ - movel lastFrame,%a0 /* last frame pointer */\n\ -"); - -SAVE_FP_REGS(); -__asm__ ("\n\ - moveq.l #0,%d2\n\ - movew %sp@+,%d2\n\ - lea registers,%a5 /* get address of registers */\n\ -\n\ - moveql #3,%d3 /* assume a three word frame */\n\ -\n\ - cmpiw #3,%d2 /* bus error or address error ? */\n\ - bgt normal /* if >3 then normal error */\n\ - movel %sp@+,%a0@- /* copy error info to frame buff*/\n\ - movel %sp@+,%a0@- /* these are never used */\n\ - moveql #7,%d3 /* this is a 7 word frame */\n\ - \n\ -normal: \n\ - movew %sp@+,%d1 /* pop status register */\n\ - movel %sp@+,%a4 /* pop program counter */\n\ -\n\ - cmpiw #33,%d2 /* trap #1, breakpoint ? */\n\ - bne not_breakpoint\n\ -\n\ - subql #2,%a4 /* trap leaves the pc after the trap */\n\ -\n\ -not_breakpoint:\n\ - movew %d1,%a5@(66) /* save sr */ \n\ - movel %a4,%a5@(68) /* save pc in _regisers[] */\n\ - movel %a4,%a0@- /* copy pc to frame buffer */\n\ - movew %d1,%a0@- /* copy sr to frame buffer */\n\ -\n\ - movel %sp,superStack /* save supervisor %sp */\n\ -\n\ - andiw #0x2000,%d1 /* were we in supervisor mode ? */\n\ - beq userMode \n\ - movel %a7,%a5@(60) /* save %a7 */\n\ - bra saveDone \n\ -userMode:\n\ - movel %usp,%a1 /* save user stack pointer */\n\ - movel %a1,%a5@(60) /* save user stack pointer */\n\ -saveDone:\n\ -\n\ - movew %d3,%a0@- /* push frame size in words */\n\ - movel %d2,%a0@- /* push vector number */\n\ - movel %a4,%a0@- /* push exception pc */\n\ -\n\ -#\n\ -# save old frame link and set the new value\n\ -#\n\ - movel lastFrame,%a1 /* last frame pointer */\n\ - movel %a1,%a0@- /* save pointer to prev frame */\n\ - movel %a0,lastFrame\n\ -\n\ - movel %d2,%sp@- /* push exception num */\n\ - movel exceptionHook,%a0 /* get address of handler */\n\ -\n\ - jbsr %a0@ /* and call it */\n\ - clrl %sp@ /* replace exception num parm with frame ptr */\n\ - jbsr _returnFromException /* jbsr, but never returns */\n\ -"); -#endif - -/* - * remcomHandler is a front end for handle_exception. It moves the - * stack pointer into an area reserved for debugger use in case the - * breakpoint happened in supervisor mode. - */ -__asm__ ("remcomHandler:"); -__asm__ (" addl #4,%sp"); /* pop off return address */ -__asm__ (" movel %sp@+,%d0"); /* get the exception number */ -__asm__ (" movel stackPtr,%sp"); /* move to remcom stack area */ -__asm__ (" movel %d0,%sp@-"); /* push exception onto stack */ -__asm__ (" jbsr handle_exception"); /* this never returns */ -__asm__ (" rts"); /* return */ - -/* - * This is only called from assembly in this file. This file is a self - * contained gdb stub. - */ -void _returnFromException(Frame *frame); - -void _returnFromException(Frame *frame) -{ - /* if no passed in frame, use the last one */ - if (! frame) - { - frame = lastFrame; - frame->frameSize = 4; - frame->format = 0; - frame->fsaveHeader = -1; /* restore regs, but we dont have fsave info*/ - } - -#if defined(__mc68000__) && !(defined(__mc68020__) && !defined(__mcpu32__)) - /* a 68000 cannot use the internal info pushed onto a bus error - * or address error frame when doing an RTE so don't put this info - * onto the stack or the stack will creep every time this happens. - */ - frame->frameSize=3; -#endif - - /* throw away any frames in the list after this frame */ - lastFrame = frame; - - frame->sr = registers[(int) PS]; - frame->pc = registers[(int) PC]; - - if (registers[(int) PS] & 0x2000) - { - /* return to supervisor mode... */ - return_to_super(); - } - else - { /* return to user mode */ - return_to_user(); - } -} - -int hex(char ch) -{ - if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) return (ch-'0'); - if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10); - return (-1); -} - -/* scan for the sequence $<data>#<checksum> */ -void getpacket(char *buffer) -{ - unsigned char checksum; - unsigned char xmitcsum; - int i; - int count; - char ch; - - do { - /* wait around for the start character, ignore all other characters */ - while ((ch = (getDebugChar() & 0x7f)) != '$'); - checksum = 0; - xmitcsum = -1; - - count = 0; - - /* now, read until a # or end of buffer is found */ - while (count < (BUFMAX - 1)) { - ch = getDebugChar() & 0x7f; - if (ch == '#') break; - checksum = checksum + ch; - buffer[count] = ch; - count = count + 1; - } - buffer[count] = 0; - - if (ch == '#') { - xmitcsum = hex(getDebugChar() & 0x7f) << 4; - xmitcsum += hex(getDebugChar() & 0x7f); - if ((remote_debug ) && (checksum != xmitcsum)) { - debug_port_printf ("bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); - } - - if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ - else { - putDebugChar('+'); /* successful transfer */ - /* if a sequence char is present, reply the sequence ID */ - if (buffer[2] == ':') { - putDebugChar( buffer[0] ); - putDebugChar( buffer[1] ); - /* remove sequence chars from buffer */ - count = strlen(buffer); - for (i=3; i <= count; i++) buffer[i-3] = buffer[i]; - } - } - } - } while (checksum != xmitcsum); -} - -/* send the packet in buffer. The host get's one chance to read it. - This routine does not wait for a positive acknowledge. */ - -void -putpacket(char *buffer) -{ - unsigned char checksum; - int count; - char ch; - - /* $<packet info>#<checksum>. */ - do { - putDebugChar('$'); - checksum = 0; - count = 0; - - while ((ch=buffer[count])) { - if (! putDebugChar(ch)) return; - checksum += ch; - count += 1; - } - - putDebugChar('#'); - putDebugChar(hexchars[checksum >> 4]); - putDebugChar(hexchars[checksum % 16]); - - } while (1 == 0); /* (getDebugChar() != '+'); */ - -} - -char remcomInBuffer[BUFMAX]; -char remcomOutBuffer[BUFMAX]; -static short error; - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -char *mem2hex(char *mem, char *buf, int count) -{ - int i; - unsigned char ch; - - if (remote_debug) - debug_port_printf("mem=0x%x, count=0x%x\n", mem, count); - - for (i=0;i<count;i++) { - ch = *mem++; - *buf++ = hexchars[ch >> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - return(buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ -char *hex2mem(char *buf, char *mem, int count) -{ - int i; - unsigned char ch; - - if (remote_debug) - debug_port_printf("mem=0x%x, count=0x%x\n", mem, count); - - for (i=0;i<count;i++) { - ch = hex(*buf++) << 4; - ch = ch + hex(*buf++); - *mem++ = ch; - } - return(mem); -} - -/* a bus error has occurred, perform a longjmp - to return execution and allow handling of the error */ - -void handle_buserror() -{ - longjmp(remcomEnv,1); -} - -/* this function takes the 68000 exception number and attempts to - translate this number into a unix compatible signal value */ -int computeSignal(int exceptionVector) -{ - int sigval; - switch (exceptionVector) { - case 2 : sigval = 10; break; /* bus error */ - case 3 : sigval = 10; break; /* address error */ - case 4 : sigval = 4; break; /* illegal instruction */ - case 5 : sigval = 8; break; /* zero divide */ - case 6 : sigval = 8; break; /* chk instruction */ - case 7 : sigval = 8; break; /* trapv instruction */ - case 8 : sigval = 11; break; /* privilege violation */ - case 9 : sigval = 5; break; /* trace trap */ - case 10: sigval = 4; break; /* line 1010 emulator */ - case 11: sigval = 4; break; /* line 1111 emulator */ - - /* Coprocessor protocol violation. Using a standard MMU or FPU - this cannot be triggered by software. Call it a SIGBUS. */ - case 13: sigval = 10; break; - - case 31: sigval = 2; break; /* interrupt */ - case 33: sigval = 5; break; /* breakpoint */ - - /* This is a trap #8 instruction. Apparently it is someone's software - convention for some sort of SIGFPE condition. Whose? How many - people are being screwed by having this code the way it is? - Is there a clean solution? */ - case 40: sigval = 8; break; /* floating point err */ - - case 48: sigval = 8; break; /* floating point err */ - case 49: sigval = 8; break; /* floating point err */ - case 50: sigval = 8; break; /* zero divide */ - case 51: sigval = 8; break; /* underflow */ - case 52: sigval = 8; break; /* operand error */ - case 53: sigval = 8; break; /* overflow */ - case 54: sigval = 8; break; /* NAN */ - default: - sigval = 7; /* "software generated"*/ - } - return (sigval); -} - -/**********************************************/ -/* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */ -/* RETURN NUMBER OF CHARS PROCESSED */ -/**********************************************/ -int hexToInt(char **ptr, int *intValue) -{ - int numChars = 0; - int hexValue; - - *intValue = 0; - - while (**ptr) - { - hexValue = hex(**ptr); - if (hexValue >=0) - { - *intValue = (*intValue <<4) | hexValue; - numChars ++; - } - else - break; - - (*ptr)++; - } - - return (numChars); -} - -/* - * This function does all command procesing for interfacing to gdb. - */ -void handle_exception(int exceptionVector) -{ - int sigval; - int addr, length; - char * ptr; - int newPC; - Frame *frame; - - if (remote_debug) - printf("vector=%d, sr=0x%x, pc=0x%x\n", - exceptionVector, - registers[ PS ], - registers[ PC ]); - - /* reply to host that an exception has occurred */ - sigval = computeSignal( exceptionVector ); - remcomOutBuffer[0] = 'S'; - remcomOutBuffer[1] = hexchars[sigval >> 4]; - remcomOutBuffer[2] = hexchars[sigval % 16]; - remcomOutBuffer[3] = 0; - - putpacket(remcomOutBuffer); - - while (1==1) { - error = 0; - remcomOutBuffer[0] = 0; - getpacket(remcomInBuffer); - switch (remcomInBuffer[0]) { - case '?' : remcomOutBuffer[0] = 'S'; - remcomOutBuffer[1] = hexchars[sigval >> 4]; - remcomOutBuffer[2] = hexchars[sigval % 16]; - remcomOutBuffer[3] = 0; - break; - case 'd' : - remote_debug = !(remote_debug); /* toggle debug flag */ - debug_port_printf("debug mode "); - if (remote_debug) - { - debug_port_printf("on\n"); - } - else - { - debug_port_printf("off\n"); - } - break; - case 'g' : /* return the value of the CPU registers */ - mem2hex((char*) registers, remcomOutBuffer, NUMREGBYTES); - break; - case 'G' : /* set the value of the CPU registers - return OK */ - hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES); - strcpy(remcomOutBuffer,"OK"); - break; - - /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ - case 'm' : - if (setjmp(remcomEnv) == 0) - { - exceptionHandler(2,handle_buserror); - - /* TRY TO READ %x,%x. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - { - ptr = 0; - mem2hex((char*) addr, remcomOutBuffer, length); - } - - if (ptr) - { - strcpy(remcomOutBuffer,"E01"); - if (remote_debug) - printf("malformed read memory command: %s",remcomInBuffer); - } - } - else { - exceptionHandler(2,_catchException); - strcpy(remcomOutBuffer,"E03"); - if (remote_debug) - printf("bus error"); - } - - /* restore handler for bus error */ - exceptionHandler(2,_catchException); - break; - - /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ - case 'M' : - if (setjmp(remcomEnv) == 0) { - exceptionHandler(2,handle_buserror); - - /* TRY TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - if (*(ptr++) == ':') - { - hex2mem(ptr, (char*) addr, length); - ptr = 0; - strcpy(remcomOutBuffer,"OK"); - } - if (ptr) - { - strcpy(remcomOutBuffer,"E02"); - if (remote_debug) - printf("malformed write memory command: %s",remcomInBuffer); - } - } - else { - exceptionHandler(2,_catchException); - strcpy(remcomOutBuffer,"E03"); - if (remote_debug) - printf("bus error"); - } - - /* restore handler for bus error */ - exceptionHandler(2,_catchException); - break; - - /* cAA..AA Continue at address AA..AA(optional) */ - /* sAA..AA Step one instruction from AA..AA(optional) */ - case 'c' : - case 's' : - /* try to read optional parameter, pc unchanged if no parm */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - registers[ PC ] = addr; - - newPC = registers[ PC]; - - /* clear the trace bit */ - registers[ PS ] &= 0x7fff; - - /* set the trace bit if we're stepping */ - if (remcomInBuffer[0] == 's') registers[ PS ] |= 0x8000; - - /* - * look for newPC in the linked list of exception frames. - * if it is found, use the old frame it. otherwise, - * fake up a dummy frame in returnFromException(). - */ - if (remote_debug) debug_port_printf("new pc = 0x%x\n",newPC); - - frame = lastFrame; - while (frame) - { - if (remote_debug) - debug_port_printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - (unsigned int) frame->exceptionVector); - if (frame->exceptionPC == newPC) break; /* bingo! a match */ - /* - * for a breakpoint instruction, the saved pc may - * be off by two due to re-executing the instruction - * replaced by the trap instruction. Check for this. - */ - if ((frame->exceptionVector == 33) && - (frame->exceptionPC == newPC)) break; - if (frame == frame->previous) - { - frame = 0; /* no match found */ - break; - } - frame = frame->previous; - } - - /* - * If we found a match for the PC AND we are not returning - * as a result of a breakpoint (33), - * trace exception (9), nmi (31), jmp to - * the old exception handler as if this code never ran. - */ - if (frame) - { - if ((frame->exceptionVector != 9) && - (frame->exceptionVector != 31) && - (frame->exceptionVector != 33)) - { - /* - * invoke the previous handler. - */ - if (oldExceptionHook) - (*oldExceptionHook) (frame->exceptionVector); - newPC = registers[ PC ]; /* pc may have changed */ - if (newPC != frame->exceptionPC) - { - if (remote_debug) - debug_port_printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - (unsigned int) frame->exceptionVector); - /* re-use the last frame, we're skipping it (longjump?)*/ - frame = (Frame *) 0; - _returnFromException( frame ); /* this is a jump */ - } - } - } - - /* if we couldn't find a frame, create one */ - if (frame == 0) - { - frame = lastFrame -1 ; - - /* by using a bunch of print commands with breakpoints, - it's possible for the frame stack to creep down. If it creeps - too far, give up and reset it to the top. Normal use should - not see this happen. - */ - if ((unsigned int) (frame-2) < (unsigned int) &gdbFrameStack) - { - initializeRemcomErrorFrame(); - frame = lastFrame; - } - frame->previous = lastFrame; - lastFrame = frame; - frame = 0; /* null so _return... will properly initialize it */ - } - - _returnFromException( frame ); /* this is a jump */ - - break; - - /* kill the program */ - case 'k' : - /* reset the board */ - WATCHDOG_TRIGGER(); - while (1 == 1); - break; - - } /* switch */ - - /* reply to the request */ - putpacket(remcomOutBuffer); - } -} - -void initializeRemcomErrorFrame() -{ - lastFrame = ((Frame *) &gdbFrameStack[FRAMESIZE-1]) - 1; - lastFrame->previous = lastFrame; -} - -extern void _debug_level7(void); -extern void remcomHandler(void); - -/* this function is used to set up exception handlers for tracing and - breakpoints */ -void set_debug_traps() -{ - int exception; - - initializeRemcomErrorFrame(); - stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1]; - - registers[ PC ] = 0x400; - registers[ PS ] = 0x2700; - - for (exception = 2; exception <= 30; exception++) - exceptionHandler(exception,_catchException); - - /* level 7 interrupt */ - exceptionHandler(31,_debug_level7); - - for (exception = 32; exception <= 47; exception++) - exceptionHandler(exception,_catchException); - - /* exclude the unassigned, reserved vector locations */ - - for (exception = 64; exception <= 255; exception++) - exceptionHandler(exception,_catchException); - - if (oldExceptionHook != (ExceptionHook) remcomHandler) - { - oldExceptionHook = exceptionHook; - exceptionHook = (ExceptionHook) remcomHandler; - } - - initialized = true; - -#if defined(UPDATE_DISPLAY) - UPDATE_DISPLAY("gdb "); -#endif -} - -/* This function will generate a breakpoint exception. It is used at the - beginning of a program to sync up with a debugger and can be used - otherwise as a quick means to stop program execution and "break" into - the debugger. */ - -void breakpoint() -{ - if (initialized) BREAKPOINT(); -} diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/rom b/c/src/lib/libbsp/m68k/ods68302/startup/rom deleted file mode 100644 index 4b0e81050f..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/rom +++ /dev/null @@ -1,77 +0,0 @@ -/* - * MC68302 Linker command file - */ - -SECTIONS -{ - .text . : - { - text_start = .; - *(.text) - etext = .; - . = ALIGN(4); - __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) - *(.ctors) - LONG(0) - __CTOR_END__ = .; - . = ALIGN(4); - __DTOR_LIST__ = .; - LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) - *(.dtors) - LONG(0) - __DTOR_END__ = .; - } - - .tdata : { - _TLS_Data_begin = .; - *(.tdata .tdata.* .gnu.linkonce.td.*) - _TLS_Data_end = .; - } - .tbss : { - _TLS_BSS_begin = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) - _TLS_BSS_end = .; - } - _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)); - - .vtable 0 : - { - vtable_start = .; - *(.vtable) - evtable = .; - } - - .data (ADDR(.vtable) + SIZEOF(.vtable)) : - AT (ADDR(.text) + SIZEOF(.text)) - { - data_start = .; - *(.data) - KEEP (*(SORT(.rtemsroset.*))) - KEEP (*(SORT(.rtemsrwset.*))) - edata = .; - } - .bss (ADDR(.data) + SIZEOF(.data)) : - { - bss_start = .; - *(.bss) - *(COMMON) - end = . ; - _end = . ; - } -} - -RAM_BASE = DEFINED(RAM_BASE) ? RAM_BASE : 0x00000000; -RAM_SIZE = DEFINED(RAM_SIZE) ? RAM_SIZE : 0x00100000; -ROM_BASE = DEFINED(ROM_BASE) ? ROM_BASE : 0x00C00000; -ROM_SIZE = DEFINED(ROM_SIZE) ? ROM_SIZE : 0x00100000; -MC68302_BASE = DEFINED(MC68302_BASE) ? MC68302_BASE : 0x00700000; -m302 = MC68302_BASE; -_VBR = 0; /* location of the VBR table (in RAM) */ - - diff --git a/c/src/lib/libbsp/m68k/ods68302/startup/trace.c b/c/src/lib/libbsp/m68k/ods68302/startup/trace.c deleted file mode 100644 index efe8abf3dd..0000000000 --- a/c/src/lib/libbsp/m68k/ods68302/startup/trace.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Trace Exception dumps a back trace to the debug serial port - * - */ - -#include <bsp.h> -#include <debugport.h> - -#if 0 -/* FIXME : could get the string to print when in the BSP */ -static const char *exception_names[] = -{ - "RESET STACK TOP", - "RESET", - "BUS ERROR", - "ADDRESS ERROR", - "ILLEGAL OPCODE", - "ZERO DIVIDE", - "CHK", - "OVERFLOW", - "PRIVILEGE", - "TRACE", - "LINE 1010 EMULATOR", - "LINE 1111 EMULATOR", - "UNASSIGNED 12", - "UNASSIGNED 13", - "FORMAT ERROR", - "UNINITIALISED INTERRUPT", - "UNASSIGNED 16", - "NODE ANCHOR", - "SYSTEM ANCHOR", - "UNASSIGNED 19", - "UNASSIGNED 20", - "UNASSIGNED 21", - "UNASSIGNED 22", - "UNASSIGNED 23", - "SPURIOUS HANDLER", - "LEVEL 1", - "LEVEL 2", - "LEVEL 3", - "LEVEL 4", - "LEVEL 5", - "LEVEL 6", - "LEVEL 7", - "TRAP 0", - "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" -}; -#endif - -void trace_exception(unsigned long d0, - unsigned long d1, - unsigned long d2, - unsigned long d3, - unsigned long d4, - unsigned long d5, - unsigned long d6, - unsigned long d7, - unsigned long a0, - unsigned long a1, - unsigned long a2, - unsigned long a3, - unsigned long a4, - unsigned long a5, - unsigned long a6, - unsigned long a7, - unsigned long sr_pch, - unsigned long pcl_format) -{ - unsigned int sr = sr_pch >> 16; - unsigned long pc = (sr_pch << 16) | (pcl_format >> 16); - unsigned int format = pcl_format & 0xFFFF; - unsigned int index; - unsigned char ch; - - __asm__ volatile(" orw #0x0700,%sr"); - - debug_port_banner(); - - debug_port_write("unhandled exception="); - debug_port_write_hex_uint(format >> 2); - debug_port_write("\n"); - - debug_port_write("sr="); - debug_port_write_hex_uint(sr); - debug_port_write(", pc="); - debug_port_write_hex_ulong(pc); - debug_port_write("\n"); - - for (index = 0; index < 16; index++) - { - if (index == 8) - { - debug_port_write("\n\r"); - } - if (index < 8) - { - debug_port_out('d'); - debug_port_out('0' + index); - } - else - { - debug_port_out('a'); - debug_port_out('0' + index - 8); - } - debug_port_out('='); - debug_port_write_hex_ulong(*(((unsigned long*) &d0) + index)); - debug_port_out(' '); - } - - for (index = 0; index < (16 * 10); index++) - { - if ((index % 16) == 0) - { - debug_port_write("\n"); - debug_port_write_hex_ulong((unsigned long) (((char*) &index) + index)); - debug_port_write(" : "); - } - else - { - debug_port_out(' '); - } - - ch = (*(((char*) &index) + index) >> 4) & 0x0F; - - if (ch < 10) - { - ch += '0'; - } - else - { - ch += 'a' - 10; - } - - debug_port_out((char) ch); - - ch = *(((char*) &index) + index) & 0x0F; - - if (ch < 10) - { - ch += '0'; - } - else - { - ch += 'a' - 10; - } - debug_port_out((char) ch); - } - - debug_port_write("\nhalting cpu..."); - -#if defined(UPDATE_DISPLAY) - UPDATE_DISPLAY("HALT"); -#endif - - WATCHDOG_TRIGGER(); - while (1 == 1); -} |