Changes in kernel/genarch/src/drivers/ns16550/ns16550.c [39e1b9a:28a5ebd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/ns16550/ns16550.c
r39e1b9a r28a5ebd 112 112 } 113 113 114 static void ns16550_ write(outdev_t *dev, const char *s, size_t n)114 static void ns16550_putuchar(outdev_t *dev, char32_t ch) 115 115 { 116 116 ns16550_instance_t *instance = (ns16550_instance_t *) dev->data; 117 117 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') 126 120 ns16550_sendb(instance, '\r'); 127 121 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); 129 126 } 130 127 } 131 128 132 129 static outdev_operations_t ns16550_ops = { 133 .write = ns16550_ write,130 .write = ns16550_putuchar, 134 131 .redraw = NULL 135 132 }; 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 by143 * 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 }160 133 161 134 /** Initialize ns16550.
Note:
See TracChangeset
for help on using the changeset viewer.