Changeset 6bbe470 in mainline
- Timestamp:
- 2012-10-29T22:56:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 21b6307
- Parents:
- 5030acad
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r5030acad r6bbe470 464 464 465 465 % Use NS16550 controller as dummy serial output (kernel console) 466 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_NS16550_KCON=y] CONFIG_NS16550_ DSRLNOUT (y)466 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_NS16550_KCON=y] CONFIG_NS16550_OUT (y) 467 467 468 468 % Support for ARM926 on-chip UART … … 491 491 492 492 % Dummy serial line output 493 ! [CONFIG_MIPS_PRN=y|CONFIG_ARM_PRN=y |CONFIG_NS16550_DSRLNOUT=y] CONFIG_DSRLNOUT (y)493 ! [CONFIG_MIPS_PRN=y|CONFIG_ARM_PRN=y] CONFIG_DSRLNOUT (y) 494 494 495 495 % Serial line input module -
kernel/arch/amd64/src/amd64.c
r5030acad r6bbe470 55 55 #include <genarch/kbrd/kbrd.h> 56 56 #include <genarch/srln/srln.h> 57 #include <genarch/drivers/dsrln/dsrlnout.h>58 57 #include <genarch/multiboot/multiboot.h> 59 58 #include <genarch/multiboot/multiboot2.h> … … 219 218 #endif 220 219 221 #if def CONFIG_NS16550220 #if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT)) 222 221 /* 223 * Initialize the ns16550 controller. Then initialize the serial 224 * input module and connect it to ns16550. 222 * Initialize the ns16550 controller. 225 223 */ 226 224 ns16550_instance_t *ns16550_instance 227 225 = ns16550_init((ns16550_t *) NS16550_BASE, IRQ_NS16550, NULL, NULL); 228 226 if (ns16550_instance) { 227 #ifdef CONFIG_NS16550 229 228 srln_instance_t *srln_instance = srln_init(); 230 229 if (srln_instance) { … … 234 233 trap_virtual_enable_irqs(1 << IRQ_NS16550); 235 234 } 236 } 237 #endif 238 239 #ifdef CONFIG_NS16550_DSRLNOUT 240 /* 241 * Initialize dummy serial output to the ns16550. 242 */ 243 outdev_t *dsrlndev = dsrlnout_init(NS16550_BASE); 244 if (dsrlndev) { 245 stdout_wire(dsrlndev); 235 #endif 236 #ifdef CONFIG_NS16550_OUT 237 outdev_t *ns16550_out = ns16550_output(ns16550_instance); 238 if (ns16550_out) { 239 stdout_wire(ns16550_out); 240 } 241 #endif 246 242 } 247 243 #endif -
kernel/arch/ia32/src/ia32.c
r5030acad r6bbe470 56 56 #include <genarch/kbrd/kbrd.h> 57 57 #include <genarch/srln/srln.h> 58 #include <genarch/drivers/dsrln/dsrlnout.h>59 58 #include <genarch/multiboot/multiboot.h> 60 59 #include <genarch/multiboot/multiboot2.h> … … 173 172 #endif 174 173 175 #if def CONFIG_NS16550174 #if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT)) 176 175 /* 177 * Initialize the ns16550 controller. Then initialize the serial 178 * input module and connect it to ns16550. 176 * Initialize the ns16550 controller. 179 177 */ 180 178 ns16550_instance_t *ns16550_instance 181 179 = ns16550_init((ns16550_t *) NS16550_BASE, IRQ_NS16550, NULL, NULL); 182 180 if (ns16550_instance) { 181 #ifdef CONFIG_NS16550 183 182 srln_instance_t *srln_instance = srln_init(); 184 183 if (srln_instance) { … … 188 187 trap_virtual_enable_irqs(1 << IRQ_NS16550); 189 188 } 190 } 191 #endif 192 193 #ifdef CONFIG_NS16550_DSRLNOUT 194 /* 195 * Initialize dummy serial output to the ns16550. 196 */ 197 outdev_t *dsrlndev = dsrlnout_init(NS16550_BASE); 198 if (dsrlndev) { 199 stdout_wire(dsrlndev); 189 #endif 190 #ifdef CONFIG_NS16550_OUT 191 outdev_t *ns16550_out = ns16550_output(ns16550_instance); 192 if (ns16550_out) { 193 stdout_wire(ns16550_out); 194 } 195 #endif 200 196 } 201 197 #endif -
kernel/genarch/include/drivers/ns16550/ns16550.h
r5030acad r6bbe470 38 38 #define KERN_NS16550_H_ 39 39 40 #include <ddi/ddi.h> 40 41 #include <ddi/irq.h> 41 42 #include <typedefs.h> … … 50 51 /** NS16550 registers. */ 51 52 typedef struct { 52 ioport8_t rbr; /**< Receiver Buffer Register. */ 53 union { 54 ioport8_t rbr; /**< Receiver Buffer Register (read). */ 55 ioport8_t thr; /**< Transmitter Holder Register (write). */ 56 } __attribute__ ((packed)); 53 57 ioport8_t ier; /**< Interrupt Enable Register. */ 54 58 union { … … 65 69 irq_t irq; 66 70 ns16550_t *ns16550; 67 indev_t *kbrdin; 71 indev_t *input; 72 outdev_t *output; 73 parea_t parea; 68 74 } ns16550_instance_t; 69 75 70 76 extern ns16550_instance_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *); 71 77 extern void ns16550_wire(ns16550_instance_t *, indev_t *); 78 extern outdev_t *ns16550_output(ns16550_instance_t *); 72 79 73 80 #endif -
kernel/genarch/src/drivers/ns16550/ns16550.c
r5030acad r6bbe470 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 } … … 72 74 (void) pio_read_8(&dev->rbr); 73 75 } 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 }; 74 100 75 101 /** Initialize ns16550. … … 90 116 if (instance) { 91 117 instance->ns16550 = dev; 92 instance->kbrdin = NULL; 118 instance->input = NULL; 119 instance->output = NULL; 93 120 94 121 irq_initialize(&instance->irq); … … 100 127 instance->irq.cir = cir; 101 128 instance->irq.cir_arg = cir_arg; 129 130 instance->parea.pbase = (uintptr_t) dev; 131 instance->parea.frames = 1; 132 instance->parea.unpriv = false; 133 instance->parea.mapped = false; 134 ddi_parea_register(&instance->parea); 102 135 } 103 136 … … 105 138 } 106 139 107 void ns16550_wire(ns16550_instance_t *instance, indev_t * kbrdin)140 void ns16550_wire(ns16550_instance_t *instance, indev_t *input) 108 141 { 109 142 ASSERT(instance); 110 ASSERT( kbrdin);143 ASSERT(input); 111 144 112 instance-> kbrdin = kbrdin;145 instance->input = input; 113 146 irq_register(&instance->irq); 114 147 … … 120 153 } 121 154 155 outdev_t *ns16550_output(ns16550_instance_t *instance) 156 { 157 ASSERT(instance); 158 159 if (instance->output == NULL) { 160 instance->output = malloc(sizeof(outdev_t), 161 FRAME_ATOMIC); 162 if (instance->output) { 163 outdev_initialize("ns16550", instance->output, 164 &ns16550_ops); 165 instance->output->data = instance; 166 } 167 } 168 169 return instance->output; 170 } 171 122 172 /** @} 123 173 */
Note:
See TracChangeset
for help on using the changeset viewer.