diff options
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/console.c | 30 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/shared/io/printk.c | 44 |
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 */ |