Changeset 58775d30 in mainline for kernel/genarch/src/drivers/ns16550/ns16550.c
- Timestamp:
- 2015-03-16T16:07:21Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2003739
- Parents:
- 6069061 (diff), 795e2bf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/ns16550/ns16550.c
r6069061 r58775d30 41 41 #include <mm/slab.h> 42 42 #include <ddi/device.h> 43 #include <str.h> 43 44 44 45 #define LSR_DATA_READY 0x01 46 #define LSR_TH_READY 0x20 45 47 46 48 static irq_ownership_t ns16550_claim(irq_t *irq) … … 62 64 if (pio_read_8(&dev->lsr) & LSR_DATA_READY) { 63 65 uint8_t data = pio_read_8(&dev->rbr); 64 indev_push_character(instance-> kbrdin, data);66 indev_push_character(instance->input, data); 65 67 } 66 68 } … … 73 75 } 74 76 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 else 92 ns16550_sendb(instance->ns16550, U_SPECIAL); 93 } 94 } 95 96 static outdev_operations_t ns16550_ops = { 97 .write = ns16550_putchar, 98 .redraw = NULL 99 }; 100 75 101 /** Initialize ns16550. 76 102 * 77 103 * @param dev Addrress of the beginning of the device in I/O space. 78 * @param devno Device number.79 104 * @param inr Interrupt number. 80 105 * @param cir Clear interrupt function. 81 106 * @param cir_arg First argument to cir. 107 * @param output Where to store pointer to the output device 108 * or NULL if the caller is not interested in 109 * writing to the serial port. 82 110 * 83 111 * @return Keyboard instance or NULL on failure. 84 112 * 85 113 */ 86 ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, void *cir_arg) 114 ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, 115 void *cir_arg, outdev_t **output) 87 116 { 88 117 ns16550_instance_t *instance … … 90 119 if (instance) { 91 120 instance->ns16550 = dev; 92 instance->kbrdin = NULL; 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 } 93 137 94 138 irq_initialize(&instance->irq); … … 100 144 instance->irq.cir = cir; 101 145 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); 102 152 } 103 153 … … 105 155 } 106 156 107 void ns16550_wire(ns16550_instance_t *instance, indev_t * kbrdin)157 void ns16550_wire(ns16550_instance_t *instance, indev_t *input) 108 158 { 109 159 ASSERT(instance); 110 ASSERT( kbrdin);160 ASSERT(input); 111 161 112 instance-> kbrdin = kbrdin;162 instance->input = input; 113 163 irq_register(&instance->irq); 114 164
Note:
See TracChangeset
for help on using the changeset viewer.