summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/shared/io
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-07-27 01:04:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-07-27 01:04:11 +0000
commit08330bf0be8fed443402ffd1664b2ca4d16b6f8e (patch)
treed569b8f1786695e639ddef8e9caedf8874c1a24e /c/src/lib/libbsp/arm/shared/io
parentPatch from Charles-Antoine Gauthier <charles.gauthier@nrc.ca> that (diff)
downloadrtems-08330bf0be8fed443402ffd1664b2ca4d16b6f8e.tar.bz2
Port of RTEMS to the ARM processor family by Eric Valette
<valette@crf.canon.fr> and Emmanuel Raguet <raguet@crf.canon.fr> of Canon CRF - Communication Dept. This port includes a basic BSP that is sufficient to link hello world.
Diffstat (limited to 'c/src/lib/libbsp/arm/shared/io')
-rw-r--r--c/src/lib/libbsp/arm/shared/io/.cvsignore2
-rw-r--r--c/src/lib/libbsp/arm/shared/io/Makefile.am22
-rw-r--r--c/src/lib/libbsp/arm/shared/io/bspio.h38
-rw-r--r--c/src/lib/libbsp/arm/shared/io/printk.c113
4 files changed, 175 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/shared/io/.cvsignore b/c/src/lib/libbsp/arm/shared/io/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/io/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/arm/shared/io/Makefile.am b/c/src/lib/libbsp/arm/shared/io/Makefile.am
new file mode 100644
index 0000000000..2c543cc77d
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/io/Makefile.am
@@ -0,0 +1,22 @@
+##
+## $Id$
+##
+
+AUTOMAKE_OPTIONS = foreign 1.4
+
+H_FILES = bspio.h
+
+C_FILES = printk.c
+
+$(PROJECT_INCLUDE):
+ $(mkinstalldirs) $@
+$(PROJECT_INCLUDE)/%.h: %.h
+ $(INSTALL_DATA) $< $@
+
+PREINSTALL_FILES += $(PROJECT_INCLUDE) $(H_FILES:%.h=$(PROJECT_INCLUDE)/%.h)
+
+all: $(PREINSTALL_FILES)
+
+EXTRA_DIST = bspio.h printk.c
+
+include $(top_srcdir)/../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/arm/shared/io/bspio.h b/c/src/lib/libbsp/arm/shared/io/bspio.h
new file mode 100644
index 0000000000..b4ef8510da
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/io/bspio.h
@@ -0,0 +1,38 @@
+/* bspIo.h
+ *
+ * This include file contains declaration of interface that
+ * will be provided by the file contained in this directory.
+ *
+ *
+ * COPYRIGHT (c) 2000 Canon Research France SA.
+ * Emmanuel Raguet, mailto:raguet@crf.canon.fr
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+#ifndef _LIBBSP_ARM_SHARED_IO_BSP_IO_H
+#define _LIBBSP_ARM_SHARED_IO_BSP_IO_H
+
+/*
+ * All the functions declared as extern after this comment
+ * MUST be implemented in each BSP. Using this function,
+ * this directory contains shared code that export higher level
+ * functionnality described after the next command.
+ */
+typedef void (*BSP_output_char_function_type) (char c);
+typedef char (*BSP_polling_getchar_function_type) (void);
+
+extern BSP_output_char_function_type BSP_output_char;
+extern BSP_polling_getchar_function_type BSP_poll_char;
+/*
+ * All the function declared as extern after this comment
+ * are available for each ix86 BSP by compiling and linking
+ * the files contained in this directory PROVIDED definition
+ * and initialisation of the previous variable are done.
+ */
+void printk(char *fmt, ...);
+
+#endif
diff --git a/c/src/lib/libbsp/arm/shared/io/printk.c b/c/src/lib/libbsp/arm/shared/io/printk.c
new file mode 100644
index 0000000000..d53699a3de
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/io/printk.c
@@ -0,0 +1,113 @@
+/*-------------------------------------------------------------------------+
+| printk.c - ARM BSP
++--------------------------------------------------------------------------+
+|
+| COPYRIGHT (c) 2000 Canon Research France SA.
+| Emmanuel Raguet, mailto:raguet@crf.canon.fr
+|
+| The license and distribution terms for this file may be
+| found in found in the file LICENSE in this distribution or at
+| http://www.OARcorp.com/rtems/license.html.
+|
+| $Id$
++--------------------------------------------------------------------------*/
+
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <bspio.h>
+
+/*-------------------------------------------------------------------------+
+| Function: printNum
+| Description: print number in a given base.
+| Global Variables: None.
+| Arguments: num - number to print, base - base used to print the number.
+| Returns: Nothing.
++--------------------------------------------------------------------------*/
+static void
+printNum(long unsigned int num, int base, int sign)
+{
+ long unsigned int n;
+ int count;
+ char toPrint[20];
+
+ if ( (sign == 1) && ((long)num < 0) ) {
+ BSP_output_char('-');
+ num = -num;
+ }
+
+ count = 0;
+ while ((n = num / base) > 0) {
+ toPrint[count++] = (num - (n*base));
+ num = n ;
+ }
+ toPrint[count++] = num;
+
+ for (n = 0; n < count; n++){
+ BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
+ }
+} /* printNum */
+
+
+/*-------------------------------------------------------------------------+
+| Function: printk
+| Description: a simplified version of printf intended for use when the
+ console is not yet initialized or in ISR's.
+| Global Variables: None.
+| Arguments: as in printf: fmt - format string, ... - unnamed arguments.
+| Returns: Nothing.
++--------------------------------------------------------------------------*/
+void
+printk(char *fmt, ...)
+{
+ va_list ap; /* points to each unnamed argument in turn */
+ char c, *str;
+ int lflag, base, sign;
+
+ _CPU_ISR_Disable(level);
+
+ va_start(ap, fmt); /* make ap point to 1st unnamed arg */
+ for (; *fmt != '\0'; fmt++)
+ {
+ lflag = 0;
+ base = 0;
+ sign = 0;
+ if (*fmt == '%')
+ {
+ if ((c = *++fmt) == 'l')
+ {
+ lflag = 1;
+ c = *++fmt;
+ }
+ switch (c)
+ {
+ case 'o': case 'O': base = 8; sign = 0; break;
+ case 'd': case 'D': base = 10; sign = 1; break;
+ case 'u': case 'U': base = 10; sign = 0; break;
+ case 'x': case 'X': base = 16; sign = 0; break;
+ case 's':
+ for (str = va_arg(ap, char *); *str; str++)
+ BSP_output_char(*str);
+ break;
+ case 'c':
+ BSP_output_char(va_arg(ap, char));
+ break;
+ default:
+ BSP_output_char(c);
+ break;
+ } /* switch*/
+
+ if (base)
+ printNum(lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int),
+ base, sign);
+ }
+ else
+ {
+ BSP_output_char(*fmt);
+ }
+ }
+ va_end(ap); /* clean up when done */
+ _CPU_ISR_Enable(level);
+
+} /* printk */
+