diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-09-24 16:39:44 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-09-24 16:39:44 +0000 |
commit | ae1a501c95543752facf37234e8108aa41280357 (patch) | |
tree | b7dc926e7cb11384e050e9b7e433ea630e2d1fba /c/src/lib/libbsp/sh | |
parent | 2008-09-24 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-ae1a501c95543752facf37234e8108aa41280357.tar.bz2 |
2008-09-24 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac, clock/clockdrv.c, include/bsp.h,
start/start.S, startup/linkcmds: Now runs ticker and hello on
sh-rtems4.10-gdb. The SH simulator in gdb has no hardware IO or
interrupt simulation so we use the trap interface to print.
* gdbsci/gdbsci.c: Removed.
Diffstat (limited to 'c/src/lib/libbsp/sh')
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/ChangeLog | 8 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/Makefile.am | 7 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/clock/clockdrv.c | 31 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/configure.ac | 32 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/gdbsci/gdbsci.c | 388 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/include/bsp.h | 20 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/start/start.S | 2 | ||||
-rw-r--r-- | c/src/lib/libbsp/sh/shsim/startup/linkcmds | 11 |
8 files changed, 53 insertions, 446 deletions
diff --git a/c/src/lib/libbsp/sh/shsim/ChangeLog b/c/src/lib/libbsp/sh/shsim/ChangeLog index c317fd0a55..e8bcd2c952 100644 --- a/c/src/lib/libbsp/sh/shsim/ChangeLog +++ b/c/src/lib/libbsp/sh/shsim/ChangeLog @@ -1,3 +1,11 @@ +2008-09-24 Joel Sherrill <joel.sherrill@OARcorp.com> + + * Makefile.am, configure.ac, clock/clockdrv.c, include/bsp.h, + start/start.S, startup/linkcmds: Now runs ticker and hello on + sh-rtems4.10-gdb. The SH simulator in gdb has no hardware IO or + interrupt simulation so we use the trap interface to print. + * gdbsci/gdbsci.c: Removed. + 2008-09-23 Joel Sherrill <joel.sherrill@oarcorp.com> * configure.ac: Make letting boot_card() handle work area allocation diff --git a/c/src/lib/libbsp/sh/shsim/Makefile.am b/c/src/lib/libbsp/sh/shsim/Makefile.am index 3f0cfabd65..2afc7168ad 100644 --- a/c/src/lib/libbsp/sh/shsim/Makefile.am +++ b/c/src/lib/libbsp/sh/shsim/Makefile.am @@ -40,17 +40,14 @@ startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \ ../../shared/bspclean.c ../../shared/sbrk.c ../../shared/bootcard.c \ ../../shared/gnatinstallhandler.c ../shared/bsphwinit.c clock_SOURCES = clock/clockdrv.c -scitab_SOURCES = scitab.c -gdbsci_SOURCES = gdbsci/gdbsci.c -# FIXME: trap34 is unused trap34_SOURCES = trap34/console-io.c trap34/console-support.S \ ../../shared/dummy_printk_support.c -console_SOURCES = ../../sh/shared/console.c +console_SOURCES = ../../shared/console-polled.c noinst_LIBRARIES = libbsp.a libbsp_a_SOURCES = $(startup_SOURCES) $(clock_SOURCES) $(console_SOURCES) \ - $(gdbsci_SOURCES) $(scitab_SOURCES) $(trap34_SOURCES) + $(scitab_SOURCES) $(trap34_SOURCES) libbsp_a_LIBADD = \ ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/score.rel diff --git a/c/src/lib/libbsp/sh/shsim/clock/clockdrv.c b/c/src/lib/libbsp/sh/shsim/clock/clockdrv.c index f61b66e42d..a432d2982b 100644 --- a/c/src/lib/libbsp/sh/shsim/clock/clockdrv.c +++ b/c/src/lib/libbsp/sh/shsim/clock/clockdrv.c @@ -7,6 +7,8 @@ * $Id$ */ +#include <rtems.h> + #define CLOCK_VECTOR 0 #define Clock_driver_support_at_tick() @@ -14,8 +16,33 @@ #define Clock_driver_support_install_isr( _new, _old ) \ do { _old = 0; } while(0) -#define Clock_driver_support_initialize_hardware() +volatile bool clock_driver_enabled; + +#define Clock_driver_support_initialize_hardware() \ + do { \ + clock_driver_enabled = true; \ + } while (0) -#define Clock_driver_support_shutdown_hardware() +#define Clock_driver_support_shutdown_hardware() \ + do { \ + clock_driver_enabled = false; \ + } while (0) #include "../../../shared/clockdrv_shell.c" + + +/* + * Since there is no interrupt on this simulator, let's just + * fake time passing. This will not let preemption from an + * interrupt work but is enough for many tests. + */ +Thread clock_driver_sim_idle_body( + uintptr_t ignored +) +{ + for( ; ; ) { + if ( clock_driver_enabled ) + rtems_clock_tick(); + } + return 0; /* to avoid warning */ +} diff --git a/c/src/lib/libbsp/sh/shsim/configure.ac b/c/src/lib/libbsp/sh/shsim/configure.ac index 03ade8929a..3f72c1f945 100644 --- a/c/src/lib/libbsp/sh/shsim/configure.ac +++ b/c/src/lib/libbsp/sh/shsim/configure.ac @@ -15,38 +15,6 @@ RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm]) RTEMS_CANONICALIZE_TOOLS RTEMS_PROG_CCAS -## bsp-specific options -RTEMS_BSP_ARG_ENABLE([console], -[ --enable-console=[[null|gdbsci1]]],[ - case $enable_console in - null) - BSP_CONSOLE_DEVNAME=\"/dev/null\" - BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVNULL_DRIVER_TABLE_ENTRY - ;; -# Not yet -# trap34) -# BSP_CONSOLE_DEVNAME=\"/dev/trap34\" -# BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVTRAP34_DRIVER_TABLE_ENTRY -# ;; - yes|gdbsci1) - BSP_CONSOLE_DEVNAME=\"/dev/gdbsci1\" - BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVGDBSCI_DRIVER_TABLE_ENTRY - ;; - *) AC_MSG_WARN([bad value $enable_console for --enable-console=<value>]) - ;; - esac],[ - BSP_CONSOLE_DEVNAME=\"/dev/gdbsci1\" - BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVGDBSCI_DRIVER_TABLE_ENTRY -]) -AC_DEFINE_UNQUOTED( - [BSP_CONSOLE_DEVNAME], - [${BSP_CONSOLE_DEVNAME}], - [device name to redirect the console to]) -AC_DEFINE_UNQUOTED( - [BSP_CONSOLE_DRIVER_TABLE_ENTRY], - [${BSP_CONSOLE_DRIVER_TABLE_ENTRY}], - [Driver table entry for the console device]) - ## RTEMS_BSP_ARG_ENABLE([iomem-patch], [ --enable-iomem-patch=[[yes|no]]]) diff --git a/c/src/lib/libbsp/sh/shsim/gdbsci/gdbsci.c b/c/src/lib/libbsp/sh/shsim/gdbsci/gdbsci.c deleted file mode 100644 index 1b4732a925..0000000000 --- a/c/src/lib/libbsp/sh/shsim/gdbsci/gdbsci.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * /dev/gdbsci[0|1] for gdb's simulator's SH sci emulation - * - * Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de) - * - * COPYRIGHT (c) 2001, Ralf Corsepius, Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id$ - */ - -#include <rtems.h> - -#include <stdlib.h> - -#include <rtems/libio.h> -#include <rtems/iosupp.h> -#include <rtems/score/sh_io.h> -/* HACK: There must be something better than this :) */ -#if defined(__sh1__) -#include <rtems/score/ispsh7032.h> -#include <rtems/score/iosh7032.h> -#elif defined(__sh2__) -#include <rtems/score/ispsh7045.h> -#include <rtems/score/iosh7045.h> -#else -#error unsupported sh model -#endif -#include <sh/sh7_sci.h> -#include <sh/sh7_pfc.h> -#include <sh/sci.h> - -/* - * gdb assumes area 5/char access (base address & 0x0500000), - * the RTEMS's sh7045 code however defaults to area 5/int/short/char access - * [Very likely a bug in the sh7045 code, RC.] - */ - -#define GDBSCI_BASE 0x05ffffff - -#define GDBSCI0_SMR (SCI0_SMR & GDBSCI_BASE) -#define GDBSCI0_BRR (SCI0_BRR & GDBSCI_BASE) -#define GDBSCI0_SCR (SCI0_SCR & GDBSCI_BASE) -#define GDBSCI0_TDR (SCI0_TDR & GDBSCI_BASE) -#define GDBSCI0_SSR (SCI0_SSR & GDBSCI_BASE) -#define GDBSCI0_RDR (SCI0_RDR & GDBSCI_BASE) - -#define GDBSCI1_SMR (SCI1_SMR & GDBSCI_BASE) -#define GDBSCI1_BRR (SCI1_BRR & GDBSCI_BASE) -#define GDBSCI1_SCR (SCI1_SCR & GDBSCI_BASE) -#define GDBSCI1_TDR (SCI1_TDR & GDBSCI_BASE) -#define GDBSCI1_SSR (SCI1_SSR & GDBSCI_BASE) -#define GDBSCI1_RDG (SCI1_RDR & GDBSCI_BASE) - -/* - * NOTE: Only device 1 is valid for the simulator - */ - -#define SH_GDBSCI_MINOR_DEVICES 2 - -/* Force SIGBUS by using an unsupported address for /dev/gdbsci0 */ -#define SH_GDBSCI_BASE_0 SCI0_SMR -#define SH_GDBSCI_BASE_1 GDBSCI1_SMR - -struct scidev_t { - char * name ; - uint32_t addr ; - rtems_device_minor_number minor ; - unsigned short opened ; - tcflag_t cflags ; -} sci_device[SH_GDBSCI_MINOR_DEVICES] = -{ - { "/dev/gdbsci0", SH_GDBSCI_BASE_0, 0, 0, B9600 | CS8 }, - { "/dev/gdbsci1", SH_GDBSCI_BASE_1, 1, 0, B9600 | CS8 } -} ; - -/* imported from scitab.rel */ -extern int _sci_get_brparms( - tcflag_t cflag, - unsigned char *smr, - unsigned char *brr ); - -#if 0 -/* Translate termios' tcflag_t into sci settings */ -static int _sci_set_cflags( - struct scidev_t *sci_dev, - tcflag_t c_cflag ) -{ - uint8_t smr; - uint8_t brr; - - if ( c_cflag & CBAUD ) - { - if ( _sci_get_brparms( c_cflag, &smr, &brr ) != 0 ) - return -1 ; - } - - if ( c_cflag & CSIZE ) - { - if ( c_cflag & CS8 ) - smr &= ~SCI_SEVEN_BIT_DATA; - else if ( c_cflag & CS7 ) - smr |= SCI_SEVEN_BIT_DATA; - else - return -1 ; - } - - if ( c_cflag & CSTOPB ) - smr |= SCI_STOP_BITS_2; - else - smr &= ~SCI_STOP_BITS_2; - - if ( c_cflag & PARENB ) - smr |= SCI_PARITY_ON ; - else - smr &= ~SCI_PARITY_ON ; - - if ( c_cflag & PARODD ) - smr |= SCI_ODD_PARITY ; - else - smr &= ~SCI_ODD_PARITY; - - write8( smr, sci_dev->addr + SCI_SMR ); - write8( brr, sci_dev->addr + SCI_BRR ); - - return 0 ; -} -#endif - -static void _sci_init( - rtems_device_minor_number minor ) -{ -#if NOT_SUPPORTED_BY_GDB - uint16_t temp16 ; - - /* Pin function controller initialisation for asynchronous mode */ - if( minor == 0) - { - temp16 = read16( PFC_PBCR1); - temp16 &= ~( PB8MD | PB9MD ); - temp16 |= (PB_TXD0 | PB_RXD0); - write16( temp16, PFC_PBCR1); - } - else - { - temp16 = read16( PFC_PBCR1); - temp16 &= ~( PB10MD | PB11MD); - temp16 |= (PB_TXD1 | PB_RXD1); - write16( temp16, PFC_PBCR1); - } - - /* disable sck-pin */ - if( minor == 0) - { - temp16 = read16( PFC_PBCR1); - temp16 &= ~(PB12MD); - write16( temp16, PFC_PBCR1); - } - else - { - temp16 = read16( PFC_PBCR1); - temp16 &= ~(PB13MD); - write16( temp16, PFC_PBCR1); - } -#endif -} - -static void _sci_tx_polled( - int minor, - const char buf ) -{ - struct scidev_t *scidev = &sci_device[minor] ; -#if NOT_SUPPORTED_BY_GDB - int8_t ssr ; - - while ( !inb((scidev->addr + SCI_SSR) & SCI_TDRE )) - ; -#endif - write8(buf,scidev->addr+SCI_TDR); - -#if NOT_SUPPORTED_BY_GDB - ssr = inb(scidev->addr+SCI_SSR); - ssr &= ~SCI_TDRE ; - write8(ssr,scidev->addr+SCI_SSR); -#endif -} - -static int _sci_rx_polled ( - int minor) -{ - struct scidev_t *scidev = &sci_device[minor] ; - - unsigned char c; -#if NOT_SUPPORTED_BY_GDB - char ssr ; - ssr = read8(scidev->addr + SCI_SSR) ; - - if (ssr & (SCI_PER | SCI_FER | SCI_ORER)) - write8(ssr & ~(SCI_PER | SCI_FER | SCI_ORER), scidev->addr+SCI_SSR); - - if ( !(ssr & SCI_RDRF) ) - return -1; -#endif - c = read8(scidev->addr + SCI_RDR) ; -#if NOT_SUPPORTED_BY_GDB - write8(ssr & ~SCI_RDRF,scidev->addr + SCI_SSR); -#endif - return c; -} - -/* - * sci_initialize - */ - -rtems_device_driver sh_gdbsci_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg ) -{ - rtems_device_driver status ; - rtems_device_minor_number i; - - /* - * register all possible devices. - * the initialization of the hardware is done by sci_open - */ - - for ( i = 0 ; i < SH_GDBSCI_MINOR_DEVICES ; i++ ) - { - status = rtems_io_register_name( - sci_device[i].name, - major, - sci_device[i].minor ); - if (status != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred(status); - } - - /* default hardware setup */ - - return RTEMS_SUCCESSFUL; -} - -/* - * Open entry point - */ - -rtems_device_driver sh_gdbsci_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg ) -{ -#if NOT_SUPPORTED_BY_GDB - uint8_t temp8; -#endif - /* check for valid minor number */ - if(( minor > ( SH_GDBSCI_MINOR_DEVICES -1 )) || ( minor < 0 )) - { - return RTEMS_INVALID_NUMBER; - } - - /* device already opened */ - if ( sci_device[minor].opened > 0 ) - { - sci_device[minor].opened++ ; - return RTEMS_SUCCESSFUL ; - } - - _sci_init( minor ); - -#if NOT_SUPPORTED_BY_GDB - if (minor == 0) { - temp8 = read8(sci_device[minor].addr + SCI_SCR); - temp8 &= ~(SCI_TE | SCI_RE) ; - write8(temp8, sci_device[minor].addr + SCI_SCR); /* Clear SCR */ - _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags ); - -/* FIXME: Should be one bit delay */ - CPU_delay(50000); /* microseconds */ - - temp8 |= SCI_RE | SCI_TE; - write8(temp8, sci_device[minor].addr + SCI_SCR); /* Enable clock output */ - } else { - temp8 = read8(sci_device[minor].addr + SCI_SCR); - temp8 &= ~(SCI_TE | SCI_RE) ; - write8(temp8, sci_device[minor].addr + SCI_SCR); /* Clear SCR */ - _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags ); - -/* FIXME: Should be one bit delay */ - CPU_delay(50000); /* microseconds */ - - temp8 |= SCI_RE | SCI_TE; - write8(temp8, sci_device[minor].addr + SCI_SCR); /* Enable clock output */ - } -#endif - - sci_device[minor].opened++ ; - - return RTEMS_SUCCESSFUL ; -} - -/* - * Close entry point - */ - -rtems_device_driver sh_gdbsci_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - if( sci_device[minor].opened == 0 ) - { - return RTEMS_INVALID_NUMBER; - } - - sci_device[minor].opened-- ; - - return RTEMS_SUCCESSFUL ; -} - -/* - * read bytes from the serial port. - */ - -rtems_device_driver sh_gdbsci_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - int count = 0; - - rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; - char * buffer = rw_args->buffer; - int maximum = rw_args->count; - - for (count = 0; count < maximum; count++) { - buffer[ count ] = _sci_rx_polled(minor); - if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { - buffer[ count++ ] = '\n'; - break; - } - } - - rw_args->bytes_moved = count; - return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; -} - -/* - * write bytes to the serial port. - */ - -rtems_device_driver sh_gdbsci_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - int count; - - rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; - char *buffer = rw_args->buffer; - int maximum = rw_args->count; - - for (count = 0; count < maximum; count++) { - _sci_tx_polled( minor, buffer[ count ] ); - } - - rw_args->bytes_moved = maximum; - return 0; -} - -/* - * IO Control entry point - */ - -rtems_device_driver sh_gdbsci_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - /* Not yet supported */ - return RTEMS_SUCCESSFUL ; -} diff --git a/c/src/lib/libbsp/sh/shsim/include/bsp.h b/c/src/lib/libbsp/sh/shsim/include/bsp.h index 3613fe8fa7..b4b0c3e074 100644 --- a/c/src/lib/libbsp/sh/shsim/include/bsp.h +++ b/c/src/lib/libbsp/sh/shsim/include/bsp.h @@ -42,6 +42,9 @@ extern "C" { /* Constants */ +Thread clock_driver_sim_idle_body(uintptr_t); +#define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body + /* * Simple spin delay in microsecond units for device drivers. * This is very dependent on the clock speed of the target. @@ -59,23 +62,6 @@ extern "C" { extern void *CPU_Interrupt_stack_low ; extern void *CPU_Interrupt_stack_high ; -/* - * Device Driver Table Entries - */ - -/* - * Redefine CONSOLE_DRIVER_TABLE_ENTRY to redirect /dev/console - */ -#undef CONSOLE_DRIVER_TABLE_ENTRY -#define CONSOLE_DRIVER_TABLE_ENTRY \ - BSP_CONSOLE_DRIVER_TABLE_ENTRY, \ - { console_initialize, console_open, console_close, \ - console_read, console_write, console_control } - -/* - * NOTE: Use the standard Clock driver entry - */ - #ifdef __cplusplus } #endif diff --git a/c/src/lib/libbsp/sh/shsim/start/start.S b/c/src/lib/libbsp/sh/shsim/start/start.S index f2e5d62b92..661204300f 100644 --- a/c/src/lib/libbsp/sh/shsim/start/start.S +++ b/c/src/lib/libbsp/sh/shsim/start/start.S @@ -77,7 +77,7 @@ end_k: main_k: .long SYM(boot_card) exit_k: - .long SYM(exit) + .long SYM(_sys_exit) vects_k: .long SYM(vectab) diff --git a/c/src/lib/libbsp/sh/shsim/startup/linkcmds b/c/src/lib/libbsp/sh/shsim/startup/linkcmds index 353a8bafbf..22a9be2d64 100644 --- a/c/src/lib/libbsp/sh/shsim/startup/linkcmds +++ b/c/src/lib/libbsp/sh/shsim/startup/linkcmds @@ -178,6 +178,13 @@ SECTIONS _end = . ; PROVIDE (end = .); + .stack : { + . += 0x1000; + *(.stack) + _stack = .; + } > ram + _stack = .; + _WorkAreaBase = . ; _CPU_Interrupt_stack_low = 0x00080000 ; @@ -217,6 +224,8 @@ SECTIONS .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } - .stack /* 0x00081ff0 */: { _stack = .; *(.stack) } > ram /* > onchip_ram */ +/* + .stack 0x00081ff0 : { _stack = .; *(.stack) } > onchip_ram +*/ /* These must appear regardless of . */ } |