From 6335022e2062931771857bf84711dedcc32bc247 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 11 Mar 1997 15:42:59 +0000 Subject: updates from John Gwynne --- c/src/lib/libbsp/m68k/efi332/README | 22 +- c/src/lib/libbsp/m68k/efi332/bsp_specs | 8 +- c/src/lib/libbsp/m68k/efi332/console/console.c | 20 +- c/src/lib/libbsp/m68k/efi332/include/bsp.h | 23 +- c/src/lib/libbsp/m68k/efi332/include/efi332.h | 9 +- c/src/lib/libbsp/m68k/efi332/misc/dotests | 15 ++ c/src/lib/libbsp/m68k/efi332/misc/gdbinit68 | 13 + c/src/lib/libbsp/m68k/efi332/misc/interr.c | 95 +++++++ c/src/lib/libbsp/m68k/efi332/spurious/spinit.c | 3 + c/src/lib/libbsp/m68k/efi332/startup/bspstart.c | 33 ++- .../m68k/efi332/startup/except_vect_332_ROM.S | 290 +++++++++++++++++++++ c/src/lib/libbsp/m68k/efi332/startup/linkcmds | 1 + c/src/lib/libbsp/m68k/efi332/startup/linkcmds_ROM | 110 ++++++++ c/src/lib/libbsp/m68k/efi68k/README | 11 +- c/src/lib/libbsp/m68k/efi68k/bsp_specs | 8 +- c/src/lib/libbsp/m68k/efi68k/console/console.c | 17 +- c/src/lib/libbsp/m68k/efi68k/include/bsp.h | 23 +- c/src/lib/libbsp/m68k/efi68k/start/start.c | 63 +++++ c/src/lib/libbsp/m68k/efi68k/start68k/start68k.c | 63 +++++ c/src/lib/libbsp/m68k/efi68k/startup/bspstart.c | 42 +-- c/src/lib/libbsp/m68k/efi68k/startup/linkcmds | 1 + 21 files changed, 778 insertions(+), 92 deletions(-) create mode 100644 c/src/lib/libbsp/m68k/efi332/misc/dotests create mode 100644 c/src/lib/libbsp/m68k/efi332/misc/gdbinit68 create mode 100644 c/src/lib/libbsp/m68k/efi332/misc/interr.c create mode 100644 c/src/lib/libbsp/m68k/efi332/startup/except_vect_332_ROM.S create mode 100644 c/src/lib/libbsp/m68k/efi332/startup/linkcmds_ROM create mode 100644 c/src/lib/libbsp/m68k/efi68k/start/start.c create mode 100644 c/src/lib/libbsp/m68k/efi68k/start68k/start68k.c (limited to 'c/src/lib') diff --git a/c/src/lib/libbsp/m68k/efi332/README b/c/src/lib/libbsp/m68k/efi332/README index 12d8cc13cf..097ce132ad 100644 --- a/c/src/lib/libbsp/m68k/efi332/README +++ b/c/src/lib/libbsp/m68k/efi332/README @@ -12,25 +12,20 @@ ROM: 512k (supports several configurations) Internet subscribes to the mailing list "efi332" (an offshoot of the "diy_efi" mailing list). Although efi332 was initially designed for automotive research, it is a fairly generalized embedded controller -when used without the companion EFI board. It is patterned much after +when used without the companion EFI I/O board. It is patterned much after the the Motorola BCC but cost on the order of $250US. A 4x3 inch -(approx.) printed circuit board is available. For complete +(approx.) printed circuit board is available (about $14US). For complete information see - http://www.cim.swin.edu.au/wwwhome/aden/efi332/332_index.html - + http://efi332.eng.ohio-state.edu TODO: ===== -- add separate interrupt stack (low priority). - +- integrate the interrupt driven stdin/stdout into RTEMS to (a) reduce + the interrupt priority and (2) to prevent it from blocking. (high + priority) - add a timer driver for the tmtest set. - -- generate include/coverhd.c to preform the tmtest. - -- the interrupt drive I/O should be integrated into the RTEMS. - -- finish the ROM memory model. - +- generate include/coverhd.c to perform the tmtest. +- add separate interrupt stack (low priority... may never happen :). John S Gwynne Gwynne.1@osu.edu @@ -39,4 +34,3 @@ _______________________________________________________________________________ ElectroScience Laboratory, 1320 Kinnear Road, Columbus, Ohio 43212, USA Telephone: (614) 292-7981 * Fax: (614) 292-7297 ------------------------------------------------------------------------------- - diff --git a/c/src/lib/libbsp/m68k/efi332/bsp_specs b/c/src/lib/libbsp/m68k/efi332/bsp_specs index 70d6a7ab66..5ba97705d5 100644 --- a/c/src/lib/libbsp/m68k/efi332/bsp_specs +++ b/c/src/lib/libbsp/m68k/efi332/bsp_specs @@ -4,12 +4,12 @@ predefines: startfile: replace mrtems: -pg: start.o%s +pg: start332.o%s {!pg: -g: start.o%s +g: start332.o%s {!g: -p: start.o%s -!p: start.o%s +p: start332.o%s +!p: start332.o%s }} {!mrtems: pg: pgcrt0%O diff --git a/c/src/lib/libbsp/m68k/efi332/console/console.c b/c/src/lib/libbsp/m68k/efi332/console/console.c index b16ec72334..1e0e60d7f9 100644 --- a/c/src/lib/libbsp/m68k/efi332/console/console.c +++ b/c/src/lib/libbsp/m68k/efi332/console/console.c @@ -36,7 +36,7 @@ static volatile struct UART_buf xmt = { xmt_buf, (char *)0, (char *)1}; static volatile struct UART_buf rcv = { rcv_buf, (char *)0, (char *)1}; static volatile char _debug_flag = 0; -#define SET_RTS(a) {*PORTF0 = (*PORTF0 & 0x4) | ( (a)? 0 : 0x4); } +#define SET_RTS(a) {*PORTF0 = (*PORTF0 & ~0x4) | ( (a)? 0 : 0x4); } #define GET_CTS (!(*PORTF0 & 0x2)) /* _catchSCIint, _catchCTSint, and _catchSPURIOUSint are the @@ -234,14 +234,8 @@ void _UART_flush(void) { * Return values: */ -rtems_device_driver console_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -) +void console_init() { - rtems_status_code status; - *QSMCR = ( SAM(QSM_IARB,0,IARB) ); *QILR = ( SAM(ISRL_QSPI,4,ILQSPI) | SAM(ISRL_SCI,0,ILSCI) ); *QIVR = ( SAM(EFI_QIVR,0,INTV) ); @@ -252,6 +246,16 @@ rtems_device_driver console_initialize( set_vector(_catchSPURIOUSint, EFI_SPINT, 0); set_vector(_catchSCIint, EFI_QIVR, 0); set_vector(_catchCTSint, EFI_INT1, 0); +} + +rtems_device_driver console_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +) +{ + rtems_status_code status; + status = rtems_io_register_name( "/dev/console", major, diff --git a/c/src/lib/libbsp/m68k/efi332/include/bsp.h b/c/src/lib/libbsp/m68k/efi332/include/bsp.h index dd876eeeec..ef6447bbc9 100644 --- a/c/src/lib/libbsp/m68k/efi332/include/bsp.h +++ b/c/src/lib/libbsp/m68k/efi332/include/bsp.h @@ -71,10 +71,27 @@ extern "C" { : "0" (_tmp), "1" (_delay) ); \ } -/* macros */ +/* externals */ + +extern char _endtext[]; +extern char _sdata[]; +extern char _edata[]; +extern char __bss_start[]; +extern char _end[]; +extern char _copy_data_from_rom[]; +extern char __end_of_ram[]; + +/* constants */ + +#define RAM_END ((int)__end_of_ram) -#define RAM_START 0x80000 -#define RAM_END 0xc0000 +#ifdef __START_C__ +#define STACK_SIZE "#0x800" +#else +#define STACK_SIZE 0x800 +#endif + +/* macros */ #define RAW_PUTS(str) \ { register char *ptr = str; \ diff --git a/c/src/lib/libbsp/m68k/efi332/include/efi332.h b/c/src/lib/libbsp/m68k/efi332/include/efi332.h index 6226ec6a4a..1c1a3d0c17 100644 --- a/c/src/lib/libbsp/m68k/efi332/include/efi332.h +++ b/c/src/lib/libbsp/m68k/efi332/include/efi332.h @@ -36,15 +36,10 @@ #define EFI_X 1 #define EFI_Y 0x38 #define SYS_CLOCK (XTAL*4.0*(EFI_Y+1)*(1 << (2*EFI_W+EFI_X))) -#define SCI_BAUD 19200 /* RS232 Baud Rate */ +#define SCI_BAUD 115200 /* RS232 Baud Rate */ /* macros/functions */ -#if 0 -static void reboot(void) __attribute__ ((noreturn)); -__inline__ static void reboot() {asm("trap #15");} -#else -#define reboot() do {asm("trap #15");} while(0) -#endif +void reboot(void) __attribute__ ((noreturn)); #endif /* _EFI332_H_ */ diff --git a/c/src/lib/libbsp/m68k/efi332/misc/dotests b/c/src/lib/libbsp/m68k/efi332/misc/dotests new file mode 100644 index 0000000000..b9449bffc3 --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi332/misc/dotests @@ -0,0 +1,15 @@ +#! /bin/bash +# +# $Id$ +# + +/bin/rm sp* &>/dev/null +(cd ..; for f in sp*; do cp ${f}/o-efi332/${f}.nxe hold; done) + +stty 5:0:800008bf:0:0:0:0:0:0:1:1:0:0:0:0:0:0:0:0:0:0:0:0 /dev/null diff --git a/c/src/lib/libbsp/m68k/efi332/misc/gdbinit68 b/c/src/lib/libbsp/m68k/efi332/misc/gdbinit68 new file mode 100644 index 0000000000..984af7d3eb --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi332/misc/gdbinit68 @@ -0,0 +1,13 @@ +echo Setting up the environment for efi332 debuging.\n + +target bdm /dev/pdbdm0 +bdm_setdelay 405 +bdm_autoreset on +set remotecache off +bdm_timetocomeup 0 +bdm_init +bdm_reset +set $sfc=5 +set $dfc=5 +r +q diff --git a/c/src/lib/libbsp/m68k/efi332/misc/interr.c b/c/src/lib/libbsp/m68k/efi332/misc/interr.c new file mode 100644 index 0000000000..0a82581314 --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi332/misc/interr.c @@ -0,0 +1,95 @@ +/* + * Internal Error Handler + * + * 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 +#include +#include +#include + +/*PAGE + * + * _Internal_error_Occurred + * + * This routine will invoke the fatal error handler supplied by the user + * followed by the the default one provided by the executive. The default + * error handler assumes no hardware is present to help inform the user + * of the problem. Halt stores the error code in a known register, + * disables interrupts, and halts the CPU. If the CPU does not have a + * halt instruction, it will loop to itself. + * + * Input parameters: + * the_source - what subsystem the error originated in + * is_internal - if the error was internally generated + * the_error - fatal error status code + * + * Output parameters: + * As much information as possible is stored in a CPU dependent fashion. + * See the CPU dependent code for more information. + * + * NOTE: The the_error is not necessarily a directive status code. + */ + +/* + * Ugly hack.... _CPU_Fatal_halt() disonnects the bdm. Without this + * change, the_error is only known only to the cpu :). + * + * From "bsp.h" which is not yet available in the arch tree during + * this phase of install. jsg + */ +void outbyte(char); +void bsp_cleanup( void ); + +#define RAW_PUTS(str) \ + { register char *ptr = str; \ + while (*ptr) outbyte(*ptr++); \ + } + +#define RAW_PUTI(n) { \ + register int i, j; \ + \ + RAW_PUTS("0x"); \ + for (i=28;i>=0;i -= 4) { \ + j = (n>>i) & 0xf; \ + outbyte( (j>9 ? j-10+'a' : j+'0') ); \ + } \ + } + +void volatile _Internal_error_Occurred( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error +) +{ + + Internal_errors_What_happened.the_source = the_source; + Internal_errors_What_happened.is_internal = is_internal; + Internal_errors_What_happened.the_error = the_error; + + _User_extensions_Fatal( the_source, is_internal, the_error ); + + _System_state_Set( SYSTEM_STATE_FAILED ); + + /* try to print error message to outbyte */ + RAW_PUTS("\r\nRTEMS: A fatal error has occured.\r\n"); + RAW_PUTS("RTEMS: fatal error "); + RAW_PUTI( the_error ); + RAW_PUTS(".\r\n"); + + /* configure peripherals for a safe exit */ + bsp_cleanup(); + + _CPU_Fatal_halt( the_error ); + + /* will not return from this routine */ +} diff --git a/c/src/lib/libbsp/m68k/efi332/spurious/spinit.c b/c/src/lib/libbsp/m68k/efi332/spurious/spinit.c index 3370cb0e30..ed85697286 100644 --- a/c/src/lib/libbsp/m68k/efi332/spurious/spinit.c +++ b/c/src/lib/libbsp/m68k/efi332/spurious/spinit.c @@ -73,6 +73,9 @@ rtems_isr Spurious_Isr( bsp_cleanup(); + /* BDM SIGEMT */ + asm(" .word 0x4afa"); + for(;;); } diff --git a/c/src/lib/libbsp/m68k/efi332/startup/bspstart.c b/c/src/lib/libbsp/m68k/efi332/startup/bspstart.c index 449ad5e19a..b62bc14dc6 100644 --- a/c/src/lib/libbsp/m68k/efi332/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/efi332/startup/bspstart.c @@ -49,14 +49,22 @@ char *rtems_progname; void bsp_libc_init() { - extern int end; +/* extern int end; */ rtems_unsigned32 heap_start; - heap_start = (rtems_unsigned32) &end; + heap_start = (rtems_unsigned32) BSP_Configuration.work_space_start + + (rtems_unsigned32) BSP_Configuration.work_space_size; if (heap_start & (CPU_ALIGNMENT-1)) heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); + if (heap_start > RAM_END) { + /* rtems_fatal_error_occurred can not be used before initalization */ + RAW_PUTS("\n\rRTEMS: Out of memory.\n\r"); + RAW_PUTS("RTEMS: Check RAM_END and the size of the work space.\n\r"); + } + + RTEMS_Malloc_Initialize((void *) heap_start, + (RAM_END - heap_start), 0); /* * Init the RTEMS libio facility to provide UNIX-like system @@ -164,7 +172,7 @@ int main( m68k_get_vbr( vbr ); Cpu_table.interrupt_vector_table = vbr; - Cpu_table.interrupt_stack_size = 4096; + Cpu_table.interrupt_stack_size = 0; Cpu_table.extra_mpci_receive_server_stack = 0; @@ -175,15 +183,7 @@ int main( BSP_Configuration = Configuration; BSP_Configuration.work_space_start = (void *) - (RAM_END - BSP_Configuration.work_space_size); - - if ((unsigned int)BSP_Configuration.work_space_start < - (unsigned int)((stack_start + stack_size) & 0xffffffc0) ) { - /* rtems_fatal_error_occurred can not be used before initalization */ - RAW_PUTS("\n\rRTEMS: Out of memory.\n\r"); - RAW_PUTS("RTEMS: Check RAM_END and the size of the work space.\n\r"); - goto exit; - } + (((unsigned int)_end + STACK_SIZE + 0x100) & 0xffffff00); /* * Add 1 region for Malloc in libc_low @@ -207,12 +207,17 @@ int main( BSP_Configuration.maximum_extensions++; #endif + /* + * Tell libio how many fd's we want and allow it to tweak config + */ + + rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); + rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); /* does not return */ /* Clock_exit is done as an atexit() function */ -exit: /* configure peripherals for safe exit */ bsp_cleanup(); diff --git a/c/src/lib/libbsp/m68k/efi332/startup/except_vect_332_ROM.S b/c/src/lib/libbsp/m68k/efi332/startup/except_vect_332_ROM.S new file mode 100644 index 0000000000..0e5e11c085 --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi332/startup/except_vect_332_ROM.S @@ -0,0 +1,290 @@ +/* + * $Id$ + */ + +/* Exception Vector definitions follow */ + + /* !!! Warning !!! This table is not tested, and + the user must make sure it is complete. */ + + /* If we use TRAP #15 for reboot, note that group 0 and 1 exceptions + will have priority. */ + + /* Vector 0: RESET: Initial SSP */ + .long __end_of_ram + /* Vector 1: RESET: Initial PC */ + .long start + + /* default action for undefined vectors is to re-boot */ + + /* Note group 0 and 1 exception (like trace) have priority + over other exceptions (like trap #15) that may call this. */ + + /* Vectors 2-255 */ + .long reboot /* exception vector: 2 */ + .long reboot /* exception vector: 3 */ + .long reboot /* exception vector: 4 */ + .long reboot /* exception vector: 5 */ + .long reboot /* exception vector: 6 */ + .long reboot /* exception vector: 7 */ + .long reboot /* exception vector: 8 */ + .long reboot /* exception vector: 9 */ + .long reboot /* exception vector: 10 */ + .long reboot /* exception vector: 11 */ + .long reboot /* exception vector: 12 */ + .long reboot /* exception vector: 13 */ + .long reboot /* exception vector: 14 */ + .long reboot /* exception vector: 15 */ + .long reboot /* exception vector: 16 */ + .long reboot /* exception vector: 17 */ + .long reboot /* exception vector: 18 */ + .long reboot /* exception vector: 19 */ + .long reboot /* exception vector: 20 */ + .long reboot /* exception vector: 21 */ + .long reboot /* exception vector: 22 */ + .long reboot /* exception vector: 23 */ + .long reboot /* exception vector: 24 */ + .long reboot /* exception vector: 25 */ + .long reboot /* exception vector: 26 */ + .long reboot /* exception vector: 27 */ + .long reboot /* exception vector: 28 */ + .long reboot /* exception vector: 29 */ + .long reboot /* exception vector: 30 */ + .long reboot /* exception vector: 31 */ + .long reboot /* exception vector: 32 */ + .long reboot /* exception vector: 33 */ + .long reboot /* exception vector: 34 */ + .long reboot /* exception vector: 35 */ + .long reboot /* exception vector: 36 */ + .long reboot /* exception vector: 37 */ + .long reboot /* exception vector: 38 */ + .long reboot /* exception vector: 39 */ + .long reboot /* exception vector: 40 */ + .long reboot /* exception vector: 41 */ + .long reboot /* exception vector: 42 */ + .long reboot /* exception vector: 43 */ + .long reboot /* exception vector: 44 */ + .long reboot /* exception vector: 45 */ + .long reboot /* exception vector: 46 */ + .long _reboot /* the reboot trap: 47 */ + .long reboot /* exception vector: 48 */ + .long reboot /* exception vector: 49 */ + .long reboot /* exception vector: 50 */ + .long reboot /* exception vector: 51 */ + .long reboot /* exception vector: 52 */ + .long reboot /* exception vector: 53 */ + .long reboot /* exception vector: 54 */ + .long reboot /* exception vector: 55 */ + .long reboot /* exception vector: 56 */ + .long reboot /* exception vector: 57 */ + .long reboot /* exception vector: 58 */ + .long reboot /* exception vector: 59 */ + .long reboot /* exception vector: 60 */ + .long reboot /* exception vector: 61 */ + .long reboot /* exception vector: 62 */ + .long reboot /* exception vector: 63 */ + .long reboot /* exception vector: 64 */ + .long reboot /* exception vector: 65 */ + .long reboot /* exception vector: 66 */ + .long reboot /* exception vector: 67 */ + .long reboot /* exception vector: 68 */ + .long reboot /* exception vector: 69 */ + .long reboot /* exception vector: 70 */ + .long reboot /* exception vector: 71 */ + .long reboot /* exception vector: 72 */ + .long reboot /* exception vector: 73 */ + .long reboot /* exception vector: 74 */ + .long reboot /* exception vector: 75 */ + .long reboot /* exception vector: 76 */ + .long reboot /* exception vector: 77 */ + .long reboot /* exception vector: 78 */ + .long reboot /* exception vector: 79 */ + .long reboot /* exception vector: 80 */ + .long reboot /* exception vector: 81 */ + .long reboot /* exception vector: 82 */ + .long reboot /* exception vector: 83 */ + .long reboot /* exception vector: 84 */ + .long reboot /* exception vector: 85 */ + .long reboot /* exception vector: 86 */ + .long reboot /* exception vector: 87 */ + .long reboot /* exception vector: 88 */ + .long reboot /* exception vector: 89 */ + .long reboot /* exception vector: 90 */ + .long reboot /* exception vector: 91 */ + .long reboot /* exception vector: 92 */ + .long reboot /* exception vector: 93 */ + .long reboot /* exception vector: 94 */ + .long reboot /* exception vector: 95 */ + .long reboot /* exception vector: 96 */ + .long reboot /* exception vector: 97 */ + .long reboot /* exception vector: 98 */ + .long reboot /* exception vector: 99 */ + .long reboot /* exception vector: 100 */ + .long reboot /* exception vector: 101 */ + .long reboot /* exception vector: 102 */ + .long reboot /* exception vector: 103 */ + .long reboot /* exception vector: 104 */ + .long reboot /* exception vector: 105 */ + .long reboot /* exception vector: 106 */ + .long reboot /* exception vector: 107 */ + .long reboot /* exception vector: 108 */ + .long reboot /* exception vector: 109 */ + .long reboot /* exception vector: 110 */ + .long reboot /* exception vector: 111 */ + .long reboot /* exception vector: 112 */ + .long reboot /* exception vector: 113 */ + .long reboot /* exception vector: 114 */ + .long reboot /* exception vector: 115 */ + .long reboot /* exception vector: 116 */ + .long reboot /* exception vector: 117 */ + .long reboot /* exception vector: 118 */ + .long reboot /* exception vector: 119 */ + .long reboot /* exception vector: 120 */ + .long reboot /* exception vector: 121 */ + .long reboot /* exception vector: 122 */ + .long reboot /* exception vector: 123 */ + .long reboot /* exception vector: 124 */ + .long reboot /* exception vector: 125 */ + .long reboot /* exception vector: 126 */ + .long reboot /* exception vector: 127 */ + .long reboot /* exception vector: 128 */ + .long reboot /* exception vector: 129 */ + .long reboot /* exception vector: 130 */ + .long reboot /* exception vector: 131 */ + .long reboot /* exception vector: 132 */ + .long reboot /* exception vector: 133 */ + .long reboot /* exception vector: 134 */ + .long reboot /* exception vector: 135 */ + .long reboot /* exception vector: 136 */ + .long reboot /* exception vector: 137 */ + .long reboot /* exception vector: 138 */ + .long reboot /* exception vector: 139 */ + .long reboot /* exception vector: 140 */ + .long reboot /* exception vector: 141 */ + .long reboot /* exception vector: 142 */ + .long reboot /* exception vector: 143 */ + .long reboot /* exception vector: 144 */ + .long reboot /* exception vector: 145 */ + .long reboot /* exception vector: 146 */ + .long reboot /* exception vector: 147 */ + .long reboot /* exception vector: 148 */ + .long reboot /* exception vector: 149 */ + .long reboot /* exception vector: 150 */ + .long reboot /* exception vector: 151 */ + .long reboot /* exception vector: 152 */ + .long reboot /* exception vector: 153 */ + .long reboot /* exception vector: 154 */ + .long reboot /* exception vector: 155 */ + .long reboot /* exception vector: 156 */ + .long reboot /* exception vector: 157 */ + .long reboot /* exception vector: 158 */ + .long reboot /* exception vector: 159 */ + .long reboot /* exception vector: 160 */ + .long reboot /* exception vector: 161 */ + .long reboot /* exception vector: 162 */ + .long reboot /* exception vector: 163 */ + .long reboot /* exception vector: 164 */ + .long reboot /* exception vector: 165 */ + .long reboot /* exception vector: 166 */ + .long reboot /* exception vector: 167 */ + .long reboot /* exception vector: 168 */ + .long reboot /* exception vector: 169 */ + .long reboot /* exception vector: 170 */ + .long reboot /* exception vector: 171 */ + .long reboot /* exception vector: 172 */ + .long reboot /* exception vector: 173 */ + .long reboot /* exception vector: 174 */ + .long reboot /* exception vector: 175 */ + .long reboot /* exception vector: 176 */ + .long reboot /* exception vector: 177 */ + .long reboot /* exception vector: 178 */ + .long reboot /* exception vector: 179 */ + .long reboot /* exception vector: 180 */ + .long reboot /* exception vector: 181 */ + .long reboot /* exception vector: 182 */ + .long reboot /* exception vector: 183 */ + .long reboot /* exception vector: 184 */ + .long reboot /* exception vector: 185 */ + .long reboot /* exception vector: 186 */ + .long reboot /* exception vector: 187 */ + .long reboot /* exception vector: 188 */ + .long reboot /* exception vector: 189 */ + .long reboot /* exception vector: 190 */ + .long reboot /* exception vector: 191 */ + .long reboot /* exception vector: 192 */ + .long reboot /* exception vector: 193 */ + .long reboot /* exception vector: 194 */ + .long reboot /* exception vector: 195 */ + .long reboot /* exception vector: 196 */ + .long reboot /* exception vector: 197 */ + .long reboot /* exception vector: 198 */ + .long reboot /* exception vector: 199 */ + .long reboot /* exception vector: 200 */ + .long reboot /* exception vector: 201 */ + .long reboot /* exception vector: 202 */ + .long reboot /* exception vector: 203 */ + .long reboot /* exception vector: 204 */ + .long reboot /* exception vector: 205 */ + .long reboot /* exception vector: 206 */ + .long reboot /* exception vector: 207 */ + .long reboot /* exception vector: 208 */ + .long reboot /* exception vector: 209 */ + .long reboot /* exception vector: 210 */ + .long reboot /* exception vector: 211 */ + .long reboot /* exception vector: 212 */ + .long reboot /* exception vector: 213 */ + .long reboot /* exception vector: 214 */ + .long reboot /* exception vector: 215 */ + .long reboot /* exception vector: 216 */ + .long reboot /* exception vector: 217 */ + .long reboot /* exception vector: 218 */ + .long reboot /* exception vector: 219 */ + .long reboot /* exception vector: 220 */ + .long reboot /* exception vector: 221 */ + .long reboot /* exception vector: 222 */ + .long reboot /* exception vector: 223 */ + .long reboot /* exception vector: 224 */ + .long reboot /* exception vector: 225 */ + .long reboot /* exception vector: 226 */ + .long reboot /* exception vector: 227 */ + .long reboot /* exception vector: 228 */ + .long reboot /* exception vector: 229 */ + .long reboot /* exception vector: 230 */ + .long reboot /* exception vector: 231 */ + .long reboot /* exception vector: 232 */ + .long reboot /* exception vector: 233 */ + .long reboot /* exception vector: 234 */ + .long reboot /* exception vector: 235 */ + .long reboot /* exception vector: 236 */ + .long reboot /* exception vector: 237 */ + .long reboot /* exception vector: 238 */ + .long reboot /* exception vector: 239 */ + .long reboot /* exception vector: 240 */ + .long reboot /* exception vector: 241 */ + .long reboot /* exception vector: 242 */ + .long reboot /* exception vector: 243 */ + .long reboot /* exception vector: 244 */ + .long reboot /* exception vector: 245 */ + .long reboot /* exception vector: 246 */ + .long reboot /* exception vector: 247 */ + .long reboot /* exception vector: 248 */ + .long reboot /* exception vector: 249 */ + .long reboot /* exception vector: 250 */ + .long reboot /* exception vector: 251 */ + .long reboot /* exception vector: 252 */ + .long reboot /* exception vector: 253 */ + .long reboot /* exception vector: 254 */ + .long reboot /* exception vector: 255 */ + + +_reboot: + move #0x2700,%sr /* mask interrupts */ + movea.l (0x0).w,%a7 /* load stack */ + movea.l (0x4).w,%a0 /* jmp to location of reset vector */ + jmp (%a0) + +reboot: + trap #15 /* use trap exception to enter supervisor + state. Trace mode ( and other group 0 + and 1 exceptions) *could* screw this up if + not vectored to reboot or did not return. */ diff --git a/c/src/lib/libbsp/m68k/efi332/startup/linkcmds b/c/src/lib/libbsp/m68k/efi332/startup/linkcmds index 37d1eb5667..85c0b20b5c 100644 --- a/c/src/lib/libbsp/m68k/efi332/startup/linkcmds +++ b/c/src/lib/libbsp/m68k/efi332/startup/linkcmds @@ -35,6 +35,7 @@ MEMORY ram : ORIGIN = 0x80000, LENGTH = 256K } +__end_of_ram = 0xc0000; _copy_data_from_rom = 0; /* diff --git a/c/src/lib/libbsp/m68k/efi332/startup/linkcmds_ROM b/c/src/lib/libbsp/m68k/efi332/startup/linkcmds_ROM new file mode 100644 index 0000000000..e879396c8c --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi332/startup/linkcmds_ROM @@ -0,0 +1,110 @@ +/* linkcmds + * + * linkcmds,v 1.1 1995/09/20 15:04:47 joel Exp + */ + +OUTPUT_ARCH(m68k) +STARTUP(except_vect_332_ROM.o) +__DYNAMIC = 0; + +/* + * ROM: + * +--------------------+ <- low memory + * | .text | + * | etext | + * | ctor list | the ctor and dtor lists are for + * | dtor list | C++ support + * | _endtext | + * | temporary .data | .data is moved to RAM by crt0 + * | | + * +--------------------+ <- high memory + * + * + * RAM: + * +--------------------+ <- low memory + * | .data | initialized data goes here + * | _sdata | + * | _edata | + * +--------------------+ + * | .bss | + * | __bss_start | start of bss, cleared by crt0 + * | _end | start of heap, used by sbrk() + * +--------------------+ + * | heap space | + * | _ENDHEAP | + * | stack space | + * | __stack | top of stack + * +--------------------+ <- high memory + */ + +MEMORY +{ + rom : ORIGIN = 0x00000, LENGTH = 256K + ram : ORIGIN = 0x80000, LENGTH = 256K +} + +__end_of_ram = 0xc0000; +_copy_data_from_rom = 1; + +/* + * + */ +SECTIONS +{ + .text : + { + CREATE_OBJECT_SYMBOLS + text_start = .; + _text_start = .; + *(.text) + etext = ALIGN(0x10); + _etext = .; + __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__ = .; + *(.lit) + *(.shdata) + _endtext = .; + } > rom + .data : + AT ( ADDR(.text) + SIZEOF( .text ) ) + { + data_start = .; + _data_start = .; + _sdata = . ; + *(.data) + CONSTRUCTORS + edata = ALIGN(0x10); + _edata = .; + } > ram + .shbss : + { + *(.shbss) + } > ram + .bss : + { + __bss_start = ALIGN(0x8); + bss_start = .; + _bss_start = .; + *(.bss) + *(COMMON) + end = .; + _end = ALIGN(0x8); + __end = ALIGN(0x8); + } > ram + .stab . (NOLOAD) : + { + [ .stab ] + } + .stabstr . (NOLOAD) : + { + [ .stabstr ] + } +} diff --git a/c/src/lib/libbsp/m68k/efi68k/README b/c/src/lib/libbsp/m68k/efi68k/README index 7a431fd48b..a4cc364c04 100644 --- a/c/src/lib/libbsp/m68k/efi68k/README +++ b/c/src/lib/libbsp/m68k/efi68k/README @@ -23,20 +23,13 @@ files related to 68hc000-1.00 with the "get diy_efi " command. efi68k does not have an available printed circuit board, but can be wire-wrapped in about four days. Cost is about $100US. -For more information, I can be contacted at the address below. - - TODO: ===== -- add separate interrupt stack (low priority). - - add the "tm27 vector" ... can we use a trap instruction? - -- generate include/coverhd.c to preform the tmtest. - +- generate include/coverhd.c to perform the tmtest. - the interrupt drive I/O should be integrated into the RTEMS. - - finish the ROM memory model. +- add separate interrupt stack (low priority). John S Gwynne Gwynne.1@osu.edu diff --git a/c/src/lib/libbsp/m68k/efi68k/bsp_specs b/c/src/lib/libbsp/m68k/efi68k/bsp_specs index 70d6a7ab66..8ca61fbb24 100644 --- a/c/src/lib/libbsp/m68k/efi68k/bsp_specs +++ b/c/src/lib/libbsp/m68k/efi68k/bsp_specs @@ -4,12 +4,12 @@ predefines: startfile: replace mrtems: -pg: start.o%s +pg: start68k.o%s {!pg: -g: start.o%s +g: start68k.o%s {!g: -p: start.o%s -!p: start.o%s +p: start68k.o%s +!p: start68k.o%s }} {!mrtems: pg: pgcrt0%O diff --git a/c/src/lib/libbsp/m68k/efi68k/console/console.c b/c/src/lib/libbsp/m68k/efi68k/console/console.c index 73e3cff1fe..2efbca6605 100644 --- a/c/src/lib/libbsp/m68k/efi68k/console/console.c +++ b/c/src/lib/libbsp/m68k/efi68k/console/console.c @@ -194,14 +194,8 @@ void _UART_flush(void) { * Return values: */ -rtems_device_driver console_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -) +void console_init() { - rtems_status_code status; - /* set clock divisor */ *LCR = (char)(DLAB); *DLL = (char)((int)(CLK_FREQ/BAUD/16.0+0.5) & 0xFF); @@ -223,6 +217,15 @@ rtems_device_driver console_initialize( _tx_stop = ( (*MDSR & CTS) ? 0 : 1); set_vector(_catchUARTint, UART_ISR_LEVEL+24, 0); +} + +rtems_device_driver console_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +) +{ + rtems_status_code status; status = rtems_io_register_name( "/dev/console", diff --git a/c/src/lib/libbsp/m68k/efi68k/include/bsp.h b/c/src/lib/libbsp/m68k/efi68k/include/bsp.h index 988383c0d1..362ea3f840 100644 --- a/c/src/lib/libbsp/m68k/efi68k/include/bsp.h +++ b/c/src/lib/libbsp/m68k/efi68k/include/bsp.h @@ -71,10 +71,27 @@ extern "C" { : "0" (_tmp), "1" (_delay) ); \ } -/* macros */ +/* externals */ + +extern char _endtext[]; +extern char _sdata[]; +extern char _edata[]; +extern char __bss_start[]; +extern char _end[]; +extern char _copy_data_from_rom[]; +extern char __end_of_ram[]; + +/* constants */ + +#define RAM_END ((int)__end_of_ram) -#define RAM_START 0x200000 -#define RAM_END 0x240000 +#ifdef __START_C__ +#define STACK_SIZE "#0x800" +#else +#define STACK_SIZE 0x800 +#endif + +/* macros */ #define RAW_PUTS(str) \ { register char *ptr = str; \ diff --git a/c/src/lib/libbsp/m68k/efi68k/start/start.c b/c/src/lib/libbsp/m68k/efi68k/start/start.c new file mode 100644 index 0000000000..a3da42d100 --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi68k/start/start.c @@ -0,0 +1,63 @@ +/* + * $Id$ + */ + +#include +#define __START_C__ +#include "bsp.h" + +m68k_isr_entry M68Kvec[256]; +m68k_isr_entry vectors[256]; +char * const __argv[]= {"main", ""}; +char * const __env[]= {""}; + +int main(const int argc, char * const argv[], char * const env[]); + +void dumby_start () __attribute__ ((noreturn)); +void dumby_start() { + + /* We need to by-pass the link instruction since the RAM chip- + select pins are not yet configured. */ + asm volatile ( ".global start ; + start:"); + + /* disable interrupts, load stack pointer */ + asm volatile ( "oriw #0x0700, %sr; + movel #_end, %d0; + addl " STACK_SIZE ",%d0; + movel %d0,%sp; + link %a6, #0" + ); + /* + * Initialize RAM by copying the .data section out of ROM (if + * needed) and "zero-ing" the .bss section. + */ + { + register char *src = _endtext; + register char *dst = _sdata; + + if (_copy_data_from_rom) + /* ROM has data at end of text; copy it. */ + while (dst < _edata) + *dst++ = *src++; + + /* Zero bss */ + for (dst = __bss_start; dst< _end; dst++) + *dst = 0; + } + + /* + * Initalize the board. + */ + Spurious_Initialize(); + console_init(); + watch_dog_init(); + tcp_init(); + + /* + * Execute main with arguments argv and environment env + */ + main(1, __argv, __env); + + reboot(); +} diff --git a/c/src/lib/libbsp/m68k/efi68k/start68k/start68k.c b/c/src/lib/libbsp/m68k/efi68k/start68k/start68k.c new file mode 100644 index 0000000000..a3da42d100 --- /dev/null +++ b/c/src/lib/libbsp/m68k/efi68k/start68k/start68k.c @@ -0,0 +1,63 @@ +/* + * $Id$ + */ + +#include +#define __START_C__ +#include "bsp.h" + +m68k_isr_entry M68Kvec[256]; +m68k_isr_entry vectors[256]; +char * const __argv[]= {"main", ""}; +char * const __env[]= {""}; + +int main(const int argc, char * const argv[], char * const env[]); + +void dumby_start () __attribute__ ((noreturn)); +void dumby_start() { + + /* We need to by-pass the link instruction since the RAM chip- + select pins are not yet configured. */ + asm volatile ( ".global start ; + start:"); + + /* disable interrupts, load stack pointer */ + asm volatile ( "oriw #0x0700, %sr; + movel #_end, %d0; + addl " STACK_SIZE ",%d0; + movel %d0,%sp; + link %a6, #0" + ); + /* + * Initialize RAM by copying the .data section out of ROM (if + * needed) and "zero-ing" the .bss section. + */ + { + register char *src = _endtext; + register char *dst = _sdata; + + if (_copy_data_from_rom) + /* ROM has data at end of text; copy it. */ + while (dst < _edata) + *dst++ = *src++; + + /* Zero bss */ + for (dst = __bss_start; dst< _end; dst++) + *dst = 0; + } + + /* + * Initalize the board. + */ + Spurious_Initialize(); + console_init(); + watch_dog_init(); + tcp_init(); + + /* + * Execute main with arguments argv and environment env + */ + main(1, __argv, __env); + + reboot(); +} diff --git a/c/src/lib/libbsp/m68k/efi68k/startup/bspstart.c b/c/src/lib/libbsp/m68k/efi68k/startup/bspstart.c index 48522be884..1755808d1f 100644 --- a/c/src/lib/libbsp/m68k/efi68k/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/efi68k/startup/bspstart.c @@ -20,7 +20,6 @@ * $Id$ */ -#include #include #include #include @@ -46,8 +45,8 @@ char *rtems_progname; rtems_unsigned32 Timer_interrupts; -/* extern void set_debug_traps(void); */ -/* extern void breakpoint(void); */ +extern void set_debug_traps(void); +extern void breakpoint(void); /* Initialize whatever libc we are using * called from postdriver hook @@ -55,14 +54,22 @@ rtems_unsigned32 Timer_interrupts; void bsp_libc_init() { - extern int end; +/* extern int end; */ rtems_unsigned32 heap_start; - heap_start = (rtems_unsigned32) &end; + heap_start = (rtems_unsigned32) BSP_Configuration.work_space_start + + (rtems_unsigned32) BSP_Configuration.work_space_size; if (heap_start & (CPU_ALIGNMENT-1)) heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); + if (heap_start > RAM_END) { + /* rtems_fatal_error_occurred can not be used before initalization */ + RAW_PUTS("\n\rRTEMS: Out of memory.\n\r"); + RAW_PUTS("RTEMS: Check RAM_END and the size of the work space.\n\r"); + } + + RTEMS_Malloc_Initialize((void *) heap_start, + (RAM_END - heap_start), 0); /* * Init the RTEMS libio facility to provide UNIX-like system @@ -80,7 +87,6 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ - } /* @@ -161,7 +167,7 @@ int main( * we only use a hook to get the C library initialized. */ - Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + Cpu_table.pretasking_hook = bsp_pretasking_hook; Cpu_table.predriver_hook = NULL; @@ -174,7 +180,7 @@ int main( m68k_get_vbr( vbr ); Cpu_table.interrupt_vector_table = vbr; - Cpu_table.interrupt_stack_size = 4096; + Cpu_table.interrupt_stack_size = 0; Cpu_table.extra_mpci_receive_server_stack = 0; @@ -185,15 +191,7 @@ int main( BSP_Configuration = Configuration; BSP_Configuration.work_space_start = (void *) - (RAM_END - BSP_Configuration.work_space_size); - - if ((unsigned int)BSP_Configuration.work_space_start < - (unsigned int)((stack_start + stack_size) & 0xffffffc0) ) { - /* rtems_fatal_error_occurred can not be used before initalization */ - RAW_PUTS("\n\rRTEMS: Out of memory.\n\r"); - RAW_PUTS("RTEMS: Check RAM_END and the size of the work space.\n\r"); - goto exit; - } + (((unsigned int)_end + STACK_SIZE + 0x100) & 0xffffff00); /* * Add 1 region for Malloc in libc_low @@ -217,12 +215,18 @@ int main( BSP_Configuration.maximum_extensions++; #endif + /* + * Tell libio how many fd's we want and allow it to tweak config + */ + + rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); + rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); /* does not return */ /* Clock_exit is done as an atexit() function */ -exit: +/* exit: */ /* configure peripherals for safe exit */ bsp_cleanup(); diff --git a/c/src/lib/libbsp/m68k/efi68k/startup/linkcmds b/c/src/lib/libbsp/m68k/efi68k/startup/linkcmds index f34bafab92..b980d87502 100644 --- a/c/src/lib/libbsp/m68k/efi68k/startup/linkcmds +++ b/c/src/lib/libbsp/m68k/efi68k/startup/linkcmds @@ -43,6 +43,7 @@ MEMORY } _VBR = 0x200000; /* location of the VBR table (in RAM) */ +__end_of_ram = 0x240000; _copy_data_from_rom = 0; /* -- cgit v1.2.3