From a531683ae99448696a29127a056e126493fe1e37 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 18 Apr 2014 10:52:21 -0500 Subject: shsim: Add printk() support and move all code to console subdirectory --- c/src/lib/libbsp/sh/shsim/Makefile.am | 29 ++++++--- .../lib/libbsp/sh/shsim/console/console-debugio.c | 36 +++++++++++ c/src/lib/libbsp/sh/shsim/console/console-io.c | 72 ++++++++++++++++++++++ .../lib/libbsp/sh/shsim/console/console-support.S | 18 ++++++ c/src/lib/libbsp/sh/shsim/trap34/console-io.c | 72 ---------------------- c/src/lib/libbsp/sh/shsim/trap34/console-support.S | 18 ------ 6 files changed, 145 insertions(+), 100 deletions(-) create mode 100644 c/src/lib/libbsp/sh/shsim/console/console-debugio.c create mode 100644 c/src/lib/libbsp/sh/shsim/console/console-io.c create mode 100644 c/src/lib/libbsp/sh/shsim/console/console-support.S delete mode 100644 c/src/lib/libbsp/sh/shsim/trap34/console-io.c delete mode 100644 c/src/lib/libbsp/sh/shsim/trap34/console-support.S diff --git a/c/src/lib/libbsp/sh/shsim/Makefile.am b/c/src/lib/libbsp/sh/shsim/Makefile.am index aa4039619f..eb0d4790fc 100644 --- a/c/src/lib/libbsp/sh/shsim/Makefile.am +++ b/c/src/lib/libbsp/sh/shsim/Makefile.am @@ -20,30 +20,39 @@ noinst_LIBRARIES = libbspstart.a libbspstart_a_SOURCES = start/start.S project_lib_DATA = start.$(OBJEXT) -dist_project_lib_DATA += startup/linkcmds startup/linkcmds.sim +dist_project_lib_DATA += startup/linkcmds +dist_project_lib_DATA += startup/linkcmds.sim noinst_LIBRARIES += libbsp.a libbsp_a_SOURCES = # startup -libbsp_a_SOURCES += ../../shared/bsplibc.c ../../shared/bsppost.c \ - ../../shared/bsppredriverhook.c ../shared/startup/bspstart.c \ - ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ - ../../shared/bspclean.c ../../shared/sbrk.c ../../shared/bootcard.c \ - ../../shared/gnatinstallhandler.c ../shared/bsphwinit.c +libbsp_a_SOURCES += ../../shared/bsplibc.c +libbsp_a_SOURCES += ../../shared/bsppost.c +libbsp_a_SOURCES += ../../shared/bsppredriverhook.c +libbsp_a_SOURCES += ../shared/startup/bspstart.c +libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c +libbsp_a_SOURCES += ../../shared/bspgetworkarea.c +libbsp_a_SOURCES += ../../shared/bspclean.c +libbsp_a_SOURCES += ../../shared/sbrk.c ../../shared/bootcard.c +libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c +libbsp_a_SOURCES += ../shared/bsphwinit.c + # clock libbsp_a_SOURCES += ../../shared/clock_driver_simidle.c -# trap34 -libbsp_a_SOURCES += trap34/console-io.c trap34/console-support.S \ - ../../shared/dummy_printk_support.c # console libbsp_a_SOURCES += ../../shared/console-polled.c +libbsp_a_SOURCES += console/console-io.c +libbsp_a_SOURCES += console/console-support.S +libbsp_a_SOURCES += console/console-debugio.c + # timer libbsp_a_SOURCES += ../../shared/timerstub.c libbsp_a_LIBADD = \ - ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/score.rel + ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/score.rel \ + ../../../libcpu/@RTEMS_CPU@/cache.rel include $(srcdir)/preinstall.am include $(top_srcdir)/../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/shsim/console/console-debugio.c b/c/src/lib/libbsp/sh/shsim/console/console-debugio.c new file mode 100644 index 0000000000..38b6c8f698 --- /dev/null +++ b/c/src/lib/libbsp/sh/shsim/console/console-debugio.c @@ -0,0 +1,36 @@ +/** + * @file + * @brief Stub printk() support + * + * This file contains a stub for the required printk() support. + * It is NOT functional!!! + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * To support printk + */ + +#include +#include + +void console_outbyte_polled( + int port, + char ch +); + +void BSP_output_char_f(char c) +{ + console_outbyte_polled( 0, c ); +} + +BSP_output_char_function_type BSP_output_char = BSP_output_char_f; +BSP_polling_getchar_function_type BSP_poll_char = NULL; diff --git a/c/src/lib/libbsp/sh/shsim/console/console-io.c b/c/src/lib/libbsp/sh/shsim/console/console-io.c new file mode 100644 index 0000000000..b327192d5d --- /dev/null +++ b/c/src/lib/libbsp/sh/shsim/console/console-io.c @@ -0,0 +1,72 @@ +/* + * This file contains the hardware specific portions of the TTY driver + * for the simulators stdin/out. + * + * Logic based on newlib-1.8.2/newlib/libc/sys/sh/syscalls.c + * + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include +#include +#include +#include + +#include + +int errno; + +extern int __trap34(int, int, void*, int ); + +/* + * console_initialize_hardware + * + * This routine initializes the console hardware. + * + */ + +void console_initialize_hardware(void) +{ + return; +} + +/* + * console_outbyte_polled + * + * This routine transmits a character using polling. + */ + +void console_outbyte_polled( + int port, + char ch +) +{ + __trap34 (SYS_write, 1, &ch, 1); + return; +} + +/* + * console_inbyte_nonblocking + * + * This routine polls for a character. + */ + +int console_inbyte_nonblocking( + int port +) +{ + unsigned char c; + + return __trap34 (SYS_read, 0, &c, 1); +} + +/* XXX wrong place for this */ +int _sys_exit (int n) +{ + return __trap34 (SYS_exit, n, 0, 0); +} diff --git a/c/src/lib/libbsp/sh/shsim/console/console-support.S b/c/src/lib/libbsp/sh/shsim/console/console-support.S new file mode 100644 index 0000000000..63f72f794b --- /dev/null +++ b/c/src/lib/libbsp/sh/shsim/console/console-support.S @@ -0,0 +1,18 @@ +/* + * newlib-1.8.2/newlib/libc/sys/sh/trap.S + */ + .text + .global ___trap34 +___trap34: + trapa #34 + tst r1,r1 ! r1 is errno + bt ret + mov.l perrno,r2 + mov.l r1,@r2 +ret: + rts + nop + + .align 2 +perrno: + .long _errno diff --git a/c/src/lib/libbsp/sh/shsim/trap34/console-io.c b/c/src/lib/libbsp/sh/shsim/trap34/console-io.c deleted file mode 100644 index b327192d5d..0000000000 --- a/c/src/lib/libbsp/sh/shsim/trap34/console-io.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file contains the hardware specific portions of the TTY driver - * for the simulators stdin/out. - * - * Logic based on newlib-1.8.2/newlib/libc/sys/sh/syscalls.c - * - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include -#include -#include -#include - -#include - -int errno; - -extern int __trap34(int, int, void*, int ); - -/* - * console_initialize_hardware - * - * This routine initializes the console hardware. - * - */ - -void console_initialize_hardware(void) -{ - return; -} - -/* - * console_outbyte_polled - * - * This routine transmits a character using polling. - */ - -void console_outbyte_polled( - int port, - char ch -) -{ - __trap34 (SYS_write, 1, &ch, 1); - return; -} - -/* - * console_inbyte_nonblocking - * - * This routine polls for a character. - */ - -int console_inbyte_nonblocking( - int port -) -{ - unsigned char c; - - return __trap34 (SYS_read, 0, &c, 1); -} - -/* XXX wrong place for this */ -int _sys_exit (int n) -{ - return __trap34 (SYS_exit, n, 0, 0); -} diff --git a/c/src/lib/libbsp/sh/shsim/trap34/console-support.S b/c/src/lib/libbsp/sh/shsim/trap34/console-support.S deleted file mode 100644 index 63f72f794b..0000000000 --- a/c/src/lib/libbsp/sh/shsim/trap34/console-support.S +++ /dev/null @@ -1,18 +0,0 @@ -/* - * newlib-1.8.2/newlib/libc/sys/sh/trap.S - */ - .text - .global ___trap34 -___trap34: - trapa #34 - tst r1,r1 ! r1 is errno - bt ret - mov.l perrno,r2 - mov.l r1,@r2 -ret: - rts - nop - - .align 2 -perrno: - .long _errno -- cgit v1.2.3