All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Sourcecode 16550A.c
@ 2007-08-09 11:34 Axel Beierlein
  2007-08-09 12:24 ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Beierlein @ 2007-08-09 11:34 UTC (permalink / raw)
  To: Xenomai-help@domain.hid

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai-help] Sourcecode 16550A.c
  2007-08-09 11:34 [Xenomai-help] Sourcecode 16550A.c Axel Beierlein
@ 2007-08-09 12:24 ` Jan Kiszka
  2007-08-09 13:11   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2007-08-09 12:24 UTC (permalink / raw)
  To: Axel Beierlein; +Cc: Xenomai-help@domain.hid

[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]

Axel Beierlein wrote:
> 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?

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai-help] Sourcecode 16550A.c
  2007-08-09 12:24 ` Jan Kiszka
@ 2007-08-09 13:11   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2007-08-09 13:11 UTC (permalink / raw)
  To: Axel Beierlein; +Cc: Xenomai-help@domain.hid

[-- Attachment #1: Type: text/plain, Size: 2658 bytes --]

Jan Kiszka wrote:
> Axel Beierlein wrote:
>> 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?
> 
> 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...]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-09 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-09 11:34 [Xenomai-help] Sourcecode 16550A.c Axel Beierlein
2007-08-09 12:24 ` Jan Kiszka
2007-08-09 13:11   ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.