Sourcecode 16550A.c
Hello Jan,
could you explain me the meaning of the variable in_nwait, in_tail and in_npend of the rt_16550_context structure? Especially i´ll try to find out the functionality of the if statements behind the while in rt_16650_interrupt(...).
Or, do you have a more commented Version?
Axel
Quoted 8 lines · Axel Beierlein
Hello Jan,
could you explain me the meaning of the variable
in_nwait,in_tailandin_npendof thert_16550_contextstructure?
Especially i?ll try to find out the functionality of the if statements behind the while inrt_16650_interrupt(...).Or, do you have a more commented Version?
struct rt_16550_context {
struct rtser_config config; /* current device configuration */
rtdm_irq_t irq_handle; /* device IRQ handle */
rtdm_lock_t lock; /* lock to protect context struct */
unsigned long base_addr; /* hardware IO base address */
#ifdef CONFIG_XENO_DRIVERS_16550A_ANY
int io_mode; /* hardware IO-access mode */
#endif
int tx_fifo; /* cached global tx_fifo[<device>] */
int in_head; /* RX ring buffer, head pointer */
int in_tail; /* RX ring buffer, tail pointer */
size_t in_npend; /* pending bytes in RX ring */
int in_nwait; /* bytes the user waits for */
rtdm_event_t in_event; /* raised to unblock reader */
char in_buf[IN_BUFFER_SIZE]; /* RX ring buffer */
volatile unsigned long in_lock; /* single-reader lock */
uint64_t *in_history; /* RX timestamp buffer */
int out_head; /* TX ring buffer, head pointer */
int out_tail; /* TX ring buffer, tail pointer */
size_t out_npend; /* pending bytes in TX ring */
rtdm_event_t out_event; /* raised to unblock writer */
char out_buf[OUT_BUFFER_SIZE]; /* TX ring buffer */
rtdm_mutex_t out_lock; /* single-writer mutex */
uint64_t last_timestamp; /* timestamp of last event */
int ioc_events; /* recorded events */
rtdm_event_t ioc_event; /* raised to unblock event waiter */
volatile unsigned long ioc_event_lock; /* single-waiter lock */
int ier_status; /* IER cache */
int mcr_status; /* MCR cache */
int status; /* cache for LSR + soft-states */
int saved_errors; /* error cache for RTIOC_GET_STATUS */
};
There are a few "volatiles" less in the above version. For in_nwait becoming truely non-volatile, some code changes to rt_16550_read() are pending (need more review). Will commit later.
[Sometimes it's good to be forced to look at old code again and rethink if everything is already/still perfect...]
Jan
Quoted 49 lines · Jan Kiszka
Quoted 8 lines · Axel Beierlein
Hello Jan,
could you explain me the meaning of the variable
in_nwait,in_tailandin_npendof thert_16550_contextstructure?
Especially i?ll try to find out the functionality of the if statements behind the while inrt_16650_interrupt(...).Or, do you have a more commented Version?
struct
rt_16550_context{
structrtser_configconfig; /* current device configuration */
rtdm_irq_tirq_handle; /* device IRQ handle */
rtdm_lock_tlock; /* lock to protect context struct */unsigned long
base_addr; /* hardware IO base address */
#ifdefCONFIG_XENO_DRIVERS_16550A_ANY
intio_mode; /* hardware IO-access mode */
#endif
inttx_fifo; /* cached global tx_fifo[<device>] */int
in_head; /* RX ring buffer, head pointer */
intin_tail; /* RX ring buffer, tail pointer */
size_tin_npend; /* pending bytes in RX ring */
intin_nwait; /* bytes the user waits for */
rtdm_event_tin_event; /* raised to unblock reader */
char in_buf[IN_BUFFER_SIZE]; /* RX ring buffer */
volatile unsigned longin_lock; /* single-reader lock */
uint64_t*in_history; /* RX timestamp buffer */int
out_head; /* TX ring buffer, head pointer */
intout_tail; /* TX ring buffer, tail pointer */
size_tout_npend; /* pending bytes in TX ring */
rtdm_event_tout_event; /* raised to unblock writer */
char out_buf[OUT_BUFFER_SIZE]; /* TX ring buffer */
rtdm_mutex_tout_lock; /* single-writer mutex */
uint64_tlast_timestamp; /* timestamp of last event */
intioc_events; /* recorded events */
rtdm_event_tioc_event; /* raised to unblock event waiter */
volatile unsigned longioc_event_lock; /* single-waiter lock */int
ier_status; /* IER cache */
intmcr_status; /* MCR cache */
int status; /* cache for LSR + soft-states */
intsaved_errors; /* error cache forRTIOC_GET_STATUS*/
};
Quoted 6 lines
There are a few "volatiles" less in the above version. For
in_nwaitbecoming truely non-volatile, some code changes tort_16550_read()are pending (need more review). Will commit later.[Sometimes it's good to be forced to look at old code again and rethink if everything is already/still perfect...]
The new version is online:
http://svn.gna.org/viewcvs/xenomai?rev=2902&view=rev
As you are currently deep into the code as well, please keep me informed about potential quirks you spot and/or continue to ask about how things are supposed to work. This driver is clearly "under-commented"...
Jan