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