Rev 1911 | Rev 2071 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1911 | Rev 1921 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | 48 | ||
49 | #define IER_ERBFI 0x01 /** Enable Receive Buffer Full Interrupt. */ |
49 | #define IER_ERBFI 0x01 /** Enable Receive Buffer Full Interrupt. */ |
50 | 50 | ||
51 | #define LCR_DLAB 0x80 /** Divisor Latch Access bit. */ |
51 | #define LCR_DLAB 0x80 /** Divisor Latch Access bit. */ |
52 | 52 | ||
- | 53 | /** Structure representing the ns16550 device. */ |
|
- | 54 | typedef struct { |
|
- | 55 | devno_t devno; |
|
- | 56 | volatile uint8_t *reg; /** Memory mapped registers of the ns16550. */ |
|
- | 57 | } ns16550_t; |
|
- | 58 | ||
53 | static inline uint8_t ns16550_rbr_read(void) |
59 | static inline uint8_t ns16550_rbr_read(ns16550_t *dev) |
54 | { |
60 | { |
55 | return kbd_virt_address[RBR_REG]; |
61 | return dev->reg[RBR_REG]; |
56 | } |
62 | } |
57 | 63 | ||
58 | static inline uint8_t ns16550_ier_read(void) |
64 | static inline uint8_t ns16550_ier_read(ns16550_t *dev) |
59 | { |
65 | { |
60 | return kbd_virt_address[IER_REG]; |
66 | return dev->reg[IER_REG]; |
61 | } |
67 | } |
62 | 68 | ||
63 | static inline void ns16550_ier_write(uint8_t v) |
69 | static inline void ns16550_ier_write(ns16550_t *dev, uint8_t v) |
64 | { |
70 | { |
65 | kbd_virt_address[IER_REG] = v; |
71 | dev->reg[IER_REG] = v; |
66 | } |
72 | } |
67 | 73 | ||
68 | static inline uint8_t ns16550_iir_read(void) |
74 | static inline uint8_t ns16550_iir_read(ns16550_t *dev) |
69 | { |
75 | { |
70 | return kbd_virt_address[IIR_REG]; |
76 | return dev->reg[IIR_REG]; |
71 | } |
77 | } |
72 | 78 | ||
73 | static inline void ns16550_fcr_write(uint8_t v) |
79 | static inline void ns16550_fcr_write(ns16550_t *dev, uint8_t v) |
74 | { |
80 | { |
75 | kbd_virt_address[FCR_REG] = v; |
81 | dev->reg[FCR_REG] = v; |
76 | } |
82 | } |
77 | 83 | ||
78 | static inline uint8_t ns16550_lcr_read(void) |
84 | static inline uint8_t ns16550_lcr_read(ns16550_t *dev) |
79 | { |
85 | { |
80 | return kbd_virt_address[LCR_REG]; |
86 | return dev->reg[LCR_REG]; |
81 | } |
87 | } |
82 | 88 | ||
83 | static inline void ns16550_lcr_write(uint8_t v) |
89 | static inline void ns16550_lcr_write(ns16550_t *dev, uint8_t v) |
84 | { |
90 | { |
85 | kbd_virt_address[LCR_REG] = v; |
91 | dev->reg[LCR_REG] = v; |
86 | } |
92 | } |
87 | 93 | ||
88 | static inline uint8_t ns16550_lsr_read(void) |
94 | static inline uint8_t ns16550_lsr_read(ns16550_t *dev) |
89 | { |
95 | { |
90 | return kbd_virt_address[LSR_REG]; |
96 | return dev->reg[LSR_REG]; |
91 | } |
97 | } |
92 | 98 | ||
93 | #endif |
99 | #endif |
94 | 100 | ||
95 | /** @} |
101 | /** @} |