summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-31 22:56:20 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-31 22:56:20 +0000
commitde9edc4b52d40df34b60ad1c8ba8abb4af4c477b (patch)
tree756d1353b726f4a15961211224dea0f5b4905929 /c
parentPatch from Eric Norum <eric@skatter.usask.ca>: (diff)
downloadrtems-de9edc4b52d40df34b60ad1c8ba8abb4af4c477b.tar.bz2
Patch from Eric Valette <valette@crf.canon.fr>:
Here is a brief description of the attached patch : 1) There was a bug in the code for the COM2 serial line driver. Aleksey gave me a fix that fixes the driver code itself. I would like to thank him again publicly, 2) I introduced constants in the serial driver code because I had a hard time reading the meanning of hexadecimal values in the NS data book :) 3)You can now mix printk and printf on serial line (tested on COM2). There is a #ifdef PRINTK_ON_SERIAL in console.c that enables to have printk on console while printf on serial line, 4) Removed call to displayCpuInfo because anyway if was at the wrong place for serial line console (too early). It can anyway be called at application level, 5) The original printk was unable to display negative integer values and was also recursive. It now works corectly, All the modifications have been tested here on the COM2 port from a PC running RTEMS to a PC running linux, NB : there is still a bug on PC386 serial line : exit does not flush the remaining output queue. As this is not a bug in the driver itself but somewhere in PC386 initialization/termios relationship it will be part of another patch. NB2 : As Emmanuel excerced the exception hanlder code, while porting the SMC driver to the new BSD stack, we found a bug in the exception handler : it shall not delete the current thread in case we are running at interrupt level. This will be part of another patch...
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/console/console.c30
-rw-r--r--c/src/lib/libbsp/i386/shared/io/printk.c44
2 files changed, 49 insertions, 25 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/console/console.c b/c/src/lib/libbsp/i386/pc386/console/console.c
index 734c4b6efd..e3851b1d40 100644
--- a/c/src/lib/libbsp/i386/pc386/console/console.c
+++ b/c/src/lib/libbsp/i386/pc386/console/console.c
@@ -42,7 +42,14 @@
#include <pc386uart.h>
#include <libcpu/cpuModel.h>
-int PC386ConsolePort = PC386_CONSOLE_PORT_CONSOLE;
+/*
+ * Possible value for console input/output :
+ * PC386_CONSOLE_PORT_CONSOLE
+ * PC386_UART_COM1
+ * PC386_UART_COM2
+ */
+
+int PC386ConsolePort = PC386_UART_COM2;
static int conSetAttr(int minor, const struct termios *);
extern BSP_polling_getchar_function_type BSP_poll_char;
@@ -79,8 +86,6 @@ void __assert(const char *file, int line, const char *msg)
{
static char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot...";
unsigned char ch;
- const unsigned char *cp;
-
/*
* Note we cannot call exit or printf from here,
@@ -184,15 +189,18 @@ console_initialize(rtems_device_major_number major,
{
printk("Initialized console on port COM2 9600-8-N-1\n\n");
}
+#define PRINTK_ON_SERIAL
+#ifdef PRINTK_ON_SERIAL
+ /*
+ * You can remove the follwoing tree lines if you want to have printk
+ * using the video console for output while printf use serial line.
+ * This may be convenient to debug the serial line driver itself...
+ */
printk("Warning : This will be the last message displayed on console\n");
BSP_output_char = (BSP_output_char_function_type) BSP_output_char_via_serial;
BSP_poll_char = (BSP_polling_getchar_function_type) BSP_poll_char_via_serial;
+#endif
}
-#define DISPLAY_CPU_INFO
-#ifdef DISPLAY_CPU_INFO
- printCpuInfo();
-#endif
-
return RTEMS_SUCCESSFUL;
} /* console_initialize */
@@ -446,9 +454,3 @@ void BSP_emergency_output_init()
}
-
-
-
-
-
-
diff --git a/c/src/lib/libbsp/i386/shared/io/printk.c b/c/src/lib/libbsp/i386/shared/io/printk.c
index c34b20e730..7555fb6262 100644
--- a/c/src/lib/libbsp/i386/shared/io/printk.c
+++ b/c/src/lib/libbsp/i386/shared/io/printk.c
@@ -20,8 +20,9 @@
#include <stdarg.h>
-
+#include <stdio.h>
#include <bspIo.h>
+#include <libcpu/cpu.h>
/*-------------------------------------------------------------------------+
| Function: printNum
@@ -31,13 +32,27 @@
| Returns: Nothing.
+--------------------------------------------------------------------------*/
static void
-printNum(long int num, int base)
+printNum(long unsigned int num, int base, int sign)
{
- long int n;
+ 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;
- if ((n = num / base) > 0)
- printNum(n, base);
- BSP_output_char("0123456789ABCDEF"[(int)(num % base)]);
+ for (n = 0; n < count; n++){
+ BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
+ }
} /* printNum */
@@ -54,13 +69,17 @@ printk(char *fmt, ...)
{
va_list ap; /* points to each unnamed argument in turn */
char c, *str;
- int lflag, base;
+ int lflag, base, sign;
+ unsigned int level;
+
+ _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')
@@ -70,9 +89,10 @@ printk(char *fmt, ...)
}
switch (c)
{
- case 'o': case 'O': base = 8; break;
- case 'd': case 'D': base = 10; break;
- case 'x': case 'X': base = 16; break;
+ 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);
@@ -87,7 +107,7 @@ printk(char *fmt, ...)
if (base)
printNum(lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int),
- base);
+ base, sign);
}
else
{
@@ -95,5 +115,7 @@ printk(char *fmt, ...)
}
}
va_end(ap); /* clean up when done */
+ _CPU_ISR_Enable(level);
+
} /* printk */