Changeset 448e093 in mainline
- Timestamp:
- 2018-02-13T10:07:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 06ae793
- Parents:
- 38b0ae2
- git-author:
- Jiri Svoboda <jiri@…> (2018-02-12 21:06:46)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-02-13 10:07:22)
- Location:
- kernel/genarch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/genarch/drivers/ns16550/ns16550.h
r38b0ae2 r448e093 50 50 51 51 /** NS16550 registers. */ 52 enum {52 typedef enum { 53 53 NS16550_REG_RBR = 0, /**< Receiver Buffer Register (read). */ 54 54 NS16550_REG_THR = 0, /**< Transmitter Holder Register (write). */ … … 59 59 NS16550_REG_MCR = 4, /**< Modem Control Register. */ 60 60 NS16550_REG_LSR = 5, /**< Line Status Register. */ 61 } ;61 } ns16550_reg_t; 62 62 63 63 /** Structure representing the ns16550 device. */ … … 71 71 } ns16550_instance_t; 72 72 73 extern ns16550_instance_t *ns16550_init(ioport8_t *, int, inr_t, cir_t, void *,74 outdev_t **);73 extern ns16550_instance_t *ns16550_init(ioport8_t *, unsigned, inr_t, cir_t, 74 void *, outdev_t **); 75 75 extern void ns16550_wire(ns16550_instance_t *, indev_t *); 76 76 -
kernel/genarch/src/drivers/ns16550/ns16550.c
r38b0ae2 r448e093 47 47 #define LSR_TH_READY 0x20 48 48 49 static inline uint8_t _read(ns16550_instance_t *inst, int reg) { 49 static uint8_t ns16550_reg_read(ns16550_instance_t *inst, ns16550_reg_t reg) 50 { 50 51 return pio_read_8(&inst->ns16550[reg << inst->reg_shift]); 51 52 } 52 53 53 static inline void _write(ns16550_instance_t *inst, int reg, uint8_t val) { 54 static void ns16550_reg_write(ns16550_instance_t *inst, ns16550_reg_t reg, 55 uint8_t val) 56 { 54 57 pio_write_8(&inst->ns16550[reg << inst->reg_shift], val); 55 58 } … … 59 62 ns16550_instance_t *instance = irq->instance; 60 63 61 if ( _read(instance, NS16550_REG_LSR) & LSR_DATA_READY)64 if (ns16550_reg_read(instance, NS16550_REG_LSR) & LSR_DATA_READY) 62 65 return IRQ_ACCEPT; 63 66 else … … 69 72 ns16550_instance_t *instance = irq->instance; 70 73 71 while ( _read(instance, NS16550_REG_LSR) & LSR_DATA_READY) {72 uint8_t data = _read(instance, NS16550_REG_RBR);74 while (ns16550_reg_read(instance, NS16550_REG_LSR) & LSR_DATA_READY) { 75 uint8_t data = ns16550_reg_read(instance, NS16550_REG_RBR); 73 76 indev_push_character(instance->input, data); 74 77 } … … 78 81 static void ns16550_clear_buffer(ns16550_instance_t *instance) 79 82 { 80 while ( _read(instance, NS16550_REG_LSR) & LSR_DATA_READY)81 (void) _read(instance, NS16550_REG_RBR);83 while (ns16550_reg_read(instance, NS16550_REG_LSR) & LSR_DATA_READY) 84 (void) ns16550_reg_read(instance, NS16550_REG_RBR); 82 85 } 83 86 84 87 static void ns16550_sendb(ns16550_instance_t *instance, uint8_t byte) 85 88 { 86 while (!( _read(instance, NS16550_REG_LSR) & LSR_TH_READY))89 while (!(ns16550_reg_read(instance, NS16550_REG_LSR) & LSR_TH_READY)) 87 90 ; 88 _write(instance, NS16550_REG_THR, byte);91 ns16550_reg_write(instance, NS16550_REG_THR, byte); 89 92 } 90 93 … … 122 125 * 123 126 */ 124 ns16550_instance_t *ns16550_init(ioport8_t *dev, intreg_shift, inr_t inr,127 ns16550_instance_t *ns16550_init(ioport8_t *dev, unsigned reg_shift, inr_t inr, 125 128 cir_t cir, void *cir_arg, outdev_t **output) 126 129 { … … 176 179 177 180 /* Enable interrupts */ 178 _write(instance, NS16550_REG_IER, IER_ERBFI);179 _write(instance, NS16550_REG_MCR, MCR_OUT2);181 ns16550_reg_write(instance, NS16550_REG_IER, IER_ERBFI); 182 ns16550_reg_write(instance, NS16550_REG_MCR, MCR_OUT2); 180 183 } 181 184
Note:
See TracChangeset
for help on using the changeset viewer.