Changes in kernel/genarch/src/drivers/ns16550/ns16550.c [21b6307:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/ns16550/ns16550.c
r21b6307 r9d58539 41 41 #include <mm/slab.h> 42 42 #include <ddi/device.h> 43 #include <str.h>44 43 45 44 #define LSR_DATA_READY 0x01 46 #define LSR_TH_READY 0x2047 45 48 46 static irq_ownership_t ns16550_claim(irq_t *irq) … … 64 62 if (pio_read_8(&dev->lsr) & LSR_DATA_READY) { 65 63 uint8_t data = pio_read_8(&dev->rbr); 66 indev_push_character(instance-> input, data);64 indev_push_character(instance->kbrdin, data); 67 65 } 68 66 } … … 75 73 } 76 74 77 static void ns16550_sendb(ns16550_t *dev, uint8_t byte)78 {79 while (!(pio_read_8(&dev->lsr) & LSR_TH_READY))80 ;81 pio_write_8(&dev->thr, byte);82 }83 84 static void ns16550_putchar(outdev_t *dev, wchar_t ch)85 {86 ns16550_instance_t *instance = (ns16550_instance_t *) dev->data;87 88 if ((!instance->parea.mapped) || (console_override)) {89 if (ascii_check(ch))90 ns16550_sendb(instance->ns16550, (uint8_t) ch);91 else92 ns16550_sendb(instance->ns16550, U_SPECIAL);93 }94 }95 96 static outdev_operations_t ns16550_ops = {97 .write = ns16550_putchar,98 .redraw = NULL99 };100 101 75 /** Initialize ns16550. 102 76 * 103 77 * @param dev Addrress of the beginning of the device in I/O space. 78 * @param devno Device number. 104 79 * @param inr Interrupt number. 105 80 * @param cir Clear interrupt function. 106 81 * @param cir_arg First argument to cir. 107 * @param output Where to store pointer to the output device108 * or NULL if the caller is not interested in109 * writing to the serial port.110 82 * 111 83 * @return Keyboard instance or NULL on failure. 112 84 * 113 85 */ 114 ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, 115 void *cir_arg, outdev_t **output) 86 ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, void *cir_arg) 116 87 { 117 88 ns16550_instance_t *instance … … 119 90 if (instance) { 120 91 instance->ns16550 = dev; 121 instance->input = NULL; 122 instance->output = NULL; 123 124 if (output) { 125 instance->output = malloc(sizeof(outdev_t), 126 FRAME_ATOMIC); 127 if (!instance->output) { 128 free(instance); 129 return NULL; 130 } 131 132 outdev_initialize("ns16550", instance->output, 133 &ns16550_ops); 134 instance->output->data = instance; 135 *output = instance->output; 136 } 92 instance->kbrdin = NULL; 137 93 138 94 irq_initialize(&instance->irq); … … 144 100 instance->irq.cir = cir; 145 101 instance->irq.cir_arg = cir_arg; 146 147 instance->parea.pbase = (uintptr_t) dev;148 instance->parea.frames = 1;149 instance->parea.unpriv = false;150 instance->parea.mapped = false;151 ddi_parea_register(&instance->parea);152 102 } 153 103 … … 155 105 } 156 106 157 void ns16550_wire(ns16550_instance_t *instance, indev_t * input)107 void ns16550_wire(ns16550_instance_t *instance, indev_t *kbrdin) 158 108 { 159 109 ASSERT(instance); 160 ASSERT( input);110 ASSERT(kbrdin); 161 111 162 instance-> input = input;112 instance->kbrdin = kbrdin; 163 113 irq_register(&instance->irq); 164 114
Note:
See TracChangeset
for help on using the changeset viewer.