Changeset de9edc4 in rtems


Ignore:
Timestamp:
Aug 31, 1998, 10:56:20 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
b285860
Parents:
85734b3
Message:

Patch from Eric Valette <valette@…>:

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...

Location:
c/src/lib/libbsp/i386
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/console/console.c

    r85734b3 rde9edc4  
    4343#include <libcpu/cpuModel.h>
    4444
    45 int PC386ConsolePort = PC386_CONSOLE_PORT_CONSOLE;
     45/*
     46 * Possible value for console input/output :
     47 *      PC386_CONSOLE_PORT_CONSOLE
     48 *      PC386_UART_COM1
     49 *      PC386_UART_COM2
     50 */
     51
     52int PC386ConsolePort = PC386_UART_COM2;
    4653
    4754static int conSetAttr(int minor, const struct termios *);
     
    8087  static   char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot...";
    8188  unsigned char  ch;
    82   const    unsigned char *cp;
    83        
    8489 
    8590  /*
     
    185190          printk("Initialized console on port COM2 9600-8-N-1\n\n");
    186191        }
     192#define  PRINTK_ON_SERIAL     
     193#ifdef PRINTK_ON_SERIAL
     194      /*
     195       * You can remove the follwoing tree lines if you want to have printk
     196       * using the video console for output while printf use serial line.
     197       * This may be convenient to debug the serial line driver itself...
     198       */
    187199      printk("Warning : This will be the last message displayed on console\n");
    188200      BSP_output_char = (BSP_output_char_function_type) BSP_output_char_via_serial;
    189201      BSP_poll_char   = (BSP_polling_getchar_function_type) BSP_poll_char_via_serial;
    190     }
    191 #define  DISPLAY_CPU_INFO
    192 #ifdef DISPLAY_CPU_INFO
    193   printCpuInfo();
    194 #endif
    195  
     202#endif 
     203    }
    196204  return RTEMS_SUCCESSFUL;
    197205} /* console_initialize */
     
    447455
    448456
    449 
    450 
    451 
    452 
    453 
    454 
  • c/src/lib/libbsp/i386/shared/io/printk.c

    r85734b3 rde9edc4  
    2121
    2222#include <stdarg.h>
    23 
     23#include <stdio.h>
    2424#include <bspIo.h>
     25#include <libcpu/cpu.h>
    2526
    2627/*-------------------------------------------------------------------------+
     
    3233+--------------------------------------------------------------------------*/
    3334static void
    34 printNum(long int num, int base)
     35printNum(long unsigned int num, int base, int sign)
    3536{
    36   long int n;
     37  long unsigned int n;
     38  int count;
     39  char toPrint[20];
    3740
    38   if ((n = num / base) > 0)
    39     printNum(n, base);
    40   BSP_output_char("0123456789ABCDEF"[(int)(num % base)]);
     41  if ( (sign == 1) && ((long)num <  0) ) {
     42    BSP_output_char('-');
     43    num = -num;
     44  }
     45 
     46  count = 0;
     47  while ((n = num / base) > 0) {
     48    toPrint[count++] = (num - (n*base));
     49    num = n ;
     50  }
     51  toPrint[count++] = num;
     52
     53  for (n = 0; n < count; n++){
     54    BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
     55  }
    4156} /* printNum */
    4257
     
    5570  va_list  ap;      /* points to each unnamed argument in turn */
    5671  char     c, *str;
    57   int      lflag, base;
     72  int      lflag, base, sign;
     73  unsigned int level;
     74
     75  _CPU_ISR_Disable(level);
    5876 
    5977  va_start(ap, fmt); /* make ap point to 1st unnamed arg */
     
    6280    lflag = 0;
    6381    base  = 0;
     82    sign = 0;
    6483    if (*fmt == '%')
    6584    {
     
    7190      switch (c)
    7291      {
    73         case 'o': case 'O': base = 8; break;
    74         case 'd': case 'D': base = 10; break;
    75         case 'x': case 'X': base = 16; break;
     92        case 'o': case 'O': base = 8; sign = 0; break;
     93        case 'd': case 'D': base = 10; sign = 1; break;
     94        case 'u': case 'U': base = 10; sign = 0; break;
     95        case 'x': case 'X': base = 16; sign = 0; break;
    7696        case 's':
    7797          for (str = va_arg(ap, char *); *str; str++)
     
    88108      if (base)
    89109        printNum(lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int),
    90                  base);
     110                 base, sign);
    91111    }
    92112    else
     
    96116  }
    97117  va_end(ap); /* clean up when done */
     118  _CPU_ISR_Enable(level);
     119
    98120} /* printk */
    99121
Note: See TracChangeset for help on using the changeset viewer.