summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/shared
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/src/lib/libbsp/i386/shared
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/src/lib/libbsp/i386/shared')
-rw-r--r--c/src/lib/libbsp/i386/shared/io/printk.c44
1 files changed, 33 insertions, 11 deletions
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 */