Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/ns16550/ns16550.c

    r39e1b9a r28a5ebd  
    112112}
    113113
    114 static void ns16550_write(outdev_t *dev, const char *s, size_t n)
     114static void ns16550_putuchar(outdev_t *dev, char32_t ch)
    115115{
    116116        ns16550_instance_t *instance = (ns16550_instance_t *) dev->data;
    117117
    118         if (instance->parea.mapped && !console_override)
    119                 return;
    120 
    121         const char *top = s + n;
    122         assert(top >= s);
    123 
    124         for (; s < top; s++) {
    125                 if (*s == '\n')
     118        if ((!instance->parea.mapped) || (console_override)) {
     119                if (ch == '\n')
    126120                        ns16550_sendb(instance, '\r');
    127121
    128                 ns16550_sendb(instance, (uint8_t) *s);
     122                if (ascii_check(ch))
     123                        ns16550_sendb(instance, (uint8_t) ch);
     124                else
     125                        ns16550_sendb(instance, U_SPECIAL);
    129126        }
    130127}
    131128
    132129static outdev_operations_t ns16550_ops = {
    133         .write = ns16550_write,
     130        .write = ns16550_putuchar,
    134131        .redraw = NULL
    135132};
    136 
    137 /** Configure ns16550 transmission format.
    138  *
    139  * @param instance   NS 16550 driver instance.
    140  * @param baud_rate  Transmission speed in bits per second, also known as baud,
    141  *                   maximum value is 115200.
    142  * @param lcr_format Line Control Register configuration bits, as defined by
    143  *                   the @c LCR_ macros.  These configure the word width,
    144  *                   parity type, and stop bit count.
    145  */
    146 void ns16550_format_set(ns16550_instance_t *instance,
    147     unsigned baud_rate, uint8_t lcr_format)
    148 {
    149         uint16_t divisor;
    150 
    151         divisor = (uint16_t)(NS156440_CLOCK / baud_rate);
    152         if (divisor == 0)
    153                 divisor = 1;  /* Avoid division by zero. */
    154 
    155         ns16550_reg_write(instance, NS16550_REG_LCR, LCR_DLAB);
    156         ns16550_reg_write(instance, NS16550_REG_DLL, divisor & 0xFF);
    157         ns16550_reg_write(instance, NS16550_REG_DLH, (divisor >> 8) & 0xFF);
    158         ns16550_reg_write(instance, NS16550_REG_LCR, lcr_format & ~LCR_DLAB);
    159 }
    160133
    161134/** Initialize ns16550.
Note: See TracChangeset for help on using the changeset viewer.