-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers,uart: small improvements and cleanup #258
Changes from 1 commit
2cafbe2
a6f7976
5afc7b8
919e3f4
100ee3e
d128431
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -148,6 +148,24 @@ union interrupt_enable_register { | ||||||||||
}; | |||||||||||
typedef union interrupt_enable_register ier_t; | |||||||||||
|
|||||||||||
union interrupt_identification_register { | |||||||||||
uint8_t reg; | |||||||||||
struct __packed { | |||||||||||
uint8_t no_int_pend : 1, event : 3, rsvd : 1, fifo_64b : 1, fifo_status : 2; | |||||||||||
}; | |||||||||||
}; | |||||||||||
typedef union interrupt_identification_register iir_t; | |||||||||||
|
|||||||||||
#define UART_IIR_EVENT_MSR_CHANGE 0x0 | |||||||||||
#define UART_IIR_EVENT_THR_EMPTY 0x1 | |||||||||||
#define UART_IIR_EVENT_RXD_AVAIL 0x2 | |||||||||||
#define UART_IIR_EVENT_LSR_CHANGE 0x3 | |||||||||||
#define UART_IIR_EVENT_CHAR_TIMEOUT 0x6 | |||||||||||
|
|||||||||||
#define UART_IIR_FIFO_NO_FIFO 0x0 | |||||||||||
#define UART_IIR_FIFO_UNUSABLE_FIFO 0x1 | |||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm reading this: https://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming#Interrupt_Identification_Register Shouldn't this be 0x2?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm other sources seem to disagree: http://www.larvierinehart.com/serial/serialadc/serial.htm#16 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested this or do we just trust either? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I tested my variant on many different devices and it works. |
|||||||||||
#define UART_IIR_FIFO_ENABLED 0x3 | |||||||||||
|
|||||||||||
enum com_irq { | |||||||||||
COM1_IRQ = 4, /* IRQ 4 */ | |||||||||||
COM2_IRQ = 3, /* IRQ 3 */ | |||||||||||
|
@@ -172,9 +190,6 @@ typedef enum com_irq com_irq_t; | ||||||||||
#define UART_MSR_REG_OFFSET 0x06 | |||||||||||
#define UART_SCR_REG_OFFSET 0x07 | |||||||||||
|
|||||||||||
#define UART_IIR_STATUS_MASK 0x0E /* bits 3, 2, 1 */ | |||||||||||
#define UART_IIR_RBR_READY 0x04 | |||||||||||
|
|||||||||||
/* External declarations */ | |||||||||||
|
|||||||||||
extern io_port_t com_ports[4]; | |||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of bit field members in C is implementation defined and for gcc it's defined by the ABI.
I'm fine with that, but we probably want a block like this?:
Not that it matters now, but in case someone wants to add Aarch64 support or the like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this is a very good point and IMO deserves a dedicated issue not to forget about it. We use similar bit-fields (where order would matter) in several other places too.