/home/hillier_g/checkout/most4linux/most-kernel/rt-nrt.h File Reference

Common interface for RT / NRT issues. More...

Go to the source code of this file.

Data Structures

struct  rtnrt_memcopy_desc

Spinlocks

In some situations, if compiled with real-time support there should be used RTDM spinlocks and if compiled on Linux there should be used Linux spinlocks.

This makes sense in two cases:

  • Linux: The code path is used in task context and interrupt context.
    RTDM: The code path is used in Linux task context and RTDM interrupt context.
  • Linux: The code path is used in task context and interrupt context.
    RTDM: The code path is used in RTDM task context and RTDM interrupt context.

In these two cases the _irqsave() functions are used in task context Because Linux cannot be preemted if interrupts are stalled, there's no need to disable preemption in that case.

#define RTNRT_LSPINLOCK_UNLOCKED(lock)   SPIN_LOCK_UNLOCKED(lock)
#define RTNRT_LOCK_UNLOCKED(lock)   RTDM_LOCK_UNLOCKED
#define rtnrt_lock_init(lock)   rtdm_lock_init(lock)
#define rtnrt_lock_get(lock)   rtdm_lock_get(lock)
#define rtnrt_lock_put(lock)   rtdm_lock_put(lock)
#define rtnrt_lock_get_irqsave(lock, flags)   rtdm_lock_get_irqsave(lock, flags)
#define rtnrt_lock_put_irqrestore(lock, flags)   rtdm_lock_put_irqrestore(lock, flags)
typedef rtdm_lock_t rtnrt_lock_t
typedef rtdm_lockctx_t rtnrt_lockctx_t

Sequence Locks

Because sequence locks are based on spinlocks it makes also sense to provide sequence locks in the RTNRT framework. The usage condition is the same as for the spinlocks above.

#define RTNRT_SEQLOCK_UNLOCKED   RT_SEQLOCK_UNLOCKED
#define rtnrt_seqlock_init(x)   rt_seqlock_init(x)
#define rtnrt_write_seqlock(sl)   rt_write_seqlock(seqlock_t *sl)
#define rtnrt_write_sequnlock(sl)   rt_write_sequnlock(seqlock_t *sl)
#define rtnrt_read_seqbegin(sl)   rt_read_seqbegin(sl)
#define rtnrt_read_seqretry(sl, iv)   rt_read_seqretry(sl, iv)
#define rtnrt_write_seqlock_irqsave(sl, flags)   rt_write_seqlock_irqsave(sl, flags)
#define rtnrt_write_sequnlock_irqrestore(sl, flags)   rt_write_sequnlock_irqrestore(sl, flags)
typedef rt_seqlock_t rtnrt_seqlock_t

Clock Services

This service provides a relative nano-seconds timestamp on both platforms -- Linux and RTDM. However, the value returned if compiled with RT_RTDM is not comparable to the value compiled without RTDM.

If compiled with RT_RTDM, the function can be called also in Linux context. See also taskservices.

#define NSEC_PER_MSEC   1000000L
typedef uint64_t nanosecs_abs_t
typedef uint64_t nanosecs_rel_t
static nanosecs_abs_t rtnrt_clock_read (void)

Task Services

Services for managing tasks such as creation, waiting, etc. It also includes a sleeping function and a function for busy waiting.

#define rtnrt_ndelay(delay_nsecs)   rtdm_task_busy_sleep(delay_nsecs)
#define rtnrt_udelay(delay_usecs)   rtdm_task_busy_sleep((delay_usecs) * NSEC_PER_USEC)
#define rtnrt_mdelay(delay_msecs)   rtdm_task_busy_sleep((delay_msecs) * NSEC_PER_MSEC)
static int rtnrt_task_sleep (unsigned int millisecs)

Memory Copying

Memory copying functions that work

  • in Linux
  • in RTDM called from userspace
  • in RTDM called from kernelspace

These functions are used in the buffer implementation of the MOST driver.

#define rtnrt_copy(desc, to, from, count)   (desc)->function(to, from, count, (desc)->cookie)
typedef unsigned long(*) rtnrt_memcopy_func (void *to, const void *from, unsigned long count, void *cookie)
static unsigned long rtnrt_memmove (void *to, const void *from, unsigned long count, void *cookie)
static unsigned long rtnrt_copy_to_user (void *to, const void *from, unsigned long count, void *cookie)
static unsigned long rtnrt_copy_from_user (void *to, const void *from, unsigned long count, void *cookie)
static unsigned long rtnrt_copy_to_user_rt (void *to, const void *from, unsigned long count, void *cookie)
static unsigned long rtnrt_copy_from_user_rt (void *to, const void *from, unsigned long count, void *cookie)

Non real-time signalling services

Non real-time signalling services are used in RTDM to propagate events from real-time to non real-time. This is especially handy when a interrupt service routine runs in real-time context but needs to trigger Linux services.

This macros are provided to use this meachnism in RT and NRT. This is done in following way:

  • In Linux, the variable the inisialisation function and the cleanup function do noting. The handler gets called immediately where the event is triggered (the function is just inlined).

  • In RTDM, all function expand to their RTDM counterparts. The handler gets called normally after Linux is scheduled.

The handler should look like

 static inline void nrt_handler(rtnrt_nrtsig_t arg)
 {
     // arg is not usable
     // do actions
 }


#define DEFINE_NRTSIG(name)   static rtdm_nrtsig_t name
#define rtnrt_nrtsig_init(nrt_sig, handler)   rtdm_nrtsig_init(nrt_sig, handler)
#define rtnrt_nrtsig_destroy(nrt_sig)   rtdm_nrtsig_destroy(nrt_sig)
#define rtnrt_nrtsig_action(nrt_sig, handler)   rtdm_nrtsig_pend(nrt_sig)
typedef rtdm_nrtsig_t rtnrt_nrtsig_t

Interrupt Handling

Interrupt handling is important in Linux and real-time drivers. These macros provide some simplification for code that uses a common interrupt handler which should be registered by RTDM if RTDM is used and by Linux if Linux is used

#define RTDM_IRQTYPE_SHARED   0
#define RTDM_IRQ_NONE   0
#define RTDM_IRQ_HANDLED   0
#define RTDM_IRQ_ENABLE   0
#define DECLARE_IRQ_PROXY(proxy_name, calling_function, arg_type)
#define RTNRT_IRQ_HANDLED   (RTDM_IRQ_HANDLED | RTDM_IRQ_ENABLE)
#define RTNRT_IRQ_NONE   (RTDM_IRQ_NONE | RTDM_IRQ_ENABLE)
#define rtnrt_register_interrupt_handler(rtdm_irq_handle,interrupt_line,interrupt_handler,shared,device_name,cookie)
#define rtnrt_irq_enable(rtdm_irq_handle)   rtdm_irq_enable(rtdm_irq_handle)
#define rtnrt_free_interrupt_handler(rtdm_irq_handle,interrupt_line,device_name)   rtdm_irq_free(rtdm_irq_handle);
typedef int rtnrt_irqreturn_t

Defines

Utilities

This functions don't belong in another category.

#define rt_nrt_exec(rt, nrt)   rt
#define rtnrt_start_timer_oneshot()   rt_timer_set_mode(TM_ONESHOT)
Debug Messages Service

These functions provide debug messages that use rtdm_printk() if compiled with RT_RTDM and printk() otherwise.

Because it's safe to call rtdm_printk() if available also from Linux context, it is possible to implement that this way.

#define rtnrt_printk(fmt, arg...)   rtdm_printk(fmt, ##arg)
#define rtnrt_debug(fmt, arg...)   rtnrt_printk(KERN_DEBUG fmt, ##arg)
#define rtnrt_info(fmt, arg...)   rtnrt_printk(KERN_INFO fmt, ##arg)
#define rtnrt_notice(fmt, arg...)   rtnrt_printk(KERN_NOTICE fmt,##arg)
#define rtnrt_warn(fmt, arg...)   rtnrt_printk(KERN_WARNING "- " fmt,##arg)
#define rtnrt_err(fmt, arg...)   rtnrt_printk(KERN_ERR "* " fmt,##arg)
#define rtnrt_crit(fmt, arg...)   rtnrt_printk(KERN_CRIT "# " fmt,##arg)
#define rtnrt_alert(fmt, arg...)   rtnrt_printk(KERN_ALERT "!!!! " fmt,##arg)
#define rtnrt_emeg(fmt, arg...)   rtnrt_printk(KERN_EMERG "***!!!!*** " fmt,##arg)


Detailed Description

Common interface for RT / NRT issues.

This header provides a common interface between RTDM and Linux code. See the sections for more details. The sectioning was choosed to be the same (whenever possible and sensible) like the Xenomai API documentation.

It also includes some macros for compatiblity between different RTDM versions.

Definition in file rt-nrt.h.


Define Documentation

#define rt_nrt_exec ( rt,
nrt   )     rt

Executes rt if compiled with RT_RTDM and nrt otherwise. This could be used with NRT signalling services for example like:

Parameters:
[in] rt executed if compiled with RT_RTDM
[in] nrt executed if compiled without RT_RTDM

Definition at line 72 of file rt-nrt.h.

 
#define rtnrt_start_timer_oneshot (  )     rt_timer_set_mode(TM_ONESHOT)

Sets the timer to oneshot mode. On Linux, it does nothing. This function was developed to be able to create simple kernel modules (like using the rtnrt_clock_read() function) without calling native services.

Does following:

Returns:
0 on success or a negative error value on failure

Definition at line 89 of file rt-nrt.h.

#define rtnrt_printk ( fmt,
arg...   )     rtdm_printk(fmt, ##arg)

Debug macro usable for normal Linux drivers as well as RTDM drivers

Parameters:
[in] fmt the format string
[in] arg the arguments

Definition at line 131 of file rt-nrt.h.

#define rtnrt_debug ( fmt,
arg...   )     rtnrt_printk(KERN_DEBUG fmt, ##arg)

pr_debug replacement usable for normal Linux drivers as well as RTDM drivers

Parameters:
[in] fmt the format string
[in] arg the arguments

Definition at line 148 of file rt-nrt.h.

#define rtnrt_info ( fmt,
arg...   )     rtnrt_printk(KERN_INFO fmt, ##arg)

pr_info replacement usable for normal Linux drivers as well as RTDM drivers

Parameters:
[in] fmt the format string
[in] arg the arguments

Definition at line 162 of file rt-nrt.h.

Referenced by get_license(), most_alsa_exit(), most_alsa_init(), most_base_exit(), most_base_init(), most_nets_exit(), most_nets_init(), most_nets_open(), most_pci_exit(), most_pci_init(), most_sync_exit(), most_sync_init(), most_sync_rt_exit(), most_sync_rt_init(), probe(), remove(), and revision().

#define rtnrt_notice ( fmt,
arg...   )     rtnrt_printk(KERN_NOTICE fmt,##arg)

normal but significant condition

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 172 of file rt-nrt.h.

#define rtnrt_warn ( fmt,
arg...   )     rtnrt_printk(KERN_WARNING "- " fmt,##arg)

warning conditions

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 181 of file rt-nrt.h.

Referenced by most_sync_int_handler(), most_sync_nrt_close(), most_sync_probe(), most_sync_rt_interrupt_handler(), most_sync_rt_probe(), print_measuring_warning(), probe(), rxbuf_get(), snd_most_capture_hw_params(), snd_most_capture_open(), snd_most_capture_setup_sync_file(), snd_most_new_pcm(), snd_most_playback_hw_params(), snd_most_playback_open(), snd_most_playback_setup_sync_file(), and snd_most_playback_thread().

#define rtnrt_err ( fmt,
arg...   )     rtnrt_printk(KERN_ERR "* " fmt,##arg)

error conditions

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 190 of file rt-nrt.h.

Referenced by dma_allocate(), ioctl_irq_set(), keyctrl_reset(), loop_until_bit_is_clear(), manage_usage(), most_base_init(), most_sync_do_open(), most_sync_nrt_open(), most_sync_read(), most_sync_write(), probe(), rxbuf_alloc(), rxbuf_get(), rxbuf_put(), txbuf_alloc(), txbuf_get(), and txbuf_put().

#define rtnrt_crit ( fmt,
arg...   )     rtnrt_printk(KERN_CRIT "# " fmt,##arg)

critical conditions

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 199 of file rt-nrt.h.

#define rtnrt_alert ( fmt,
arg...   )     rtnrt_printk(KERN_ALERT "!!!! " fmt,##arg)

action must be taken immediately

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 208 of file rt-nrt.h.

#define rtnrt_emeg ( fmt,
arg...   )     rtnrt_printk(KERN_EMERG "***!!!!*** " fmt,##arg)

system is unusable

Parameters:
[in] fmt the format string
[in] arg the arguments for the format string

Definition at line 217 of file rt-nrt.h.

#define RTNRT_LSPINLOCK_UNLOCKED ( lock   )     SPIN_LOCK_UNLOCKED(lock)

Defines a spinlock statically. Used because the RT_PREEMPT patch requires an argument which containes the lock name and the normal Linux implementation doesn't. Same meaning as SPIN_LOCK_UNLOCKED.

Parameters:
[in,out] lock the name of the lock

Definition at line 253 of file rt-nrt.h.

#define RTNRT_LOCK_UNLOCKED ( lock   )     RTDM_LOCK_UNLOCKED

Static lock initialisation.

Parameters:
[in,out] lock the lock variable

Definition at line 268 of file rt-nrt.h.

#define rtnrt_lock_init ( lock   )     rtdm_lock_init(lock)

Dynamic lock initialisation.

Parameters:
[in,out] lock the lock variable

Definition at line 276 of file rt-nrt.h.

Referenced by txbuf_alloc().

#define rtnrt_lock_get ( lock   )     rtdm_lock_get(lock)

Acquire lock from non-preemptible contexts.

Parameters:
[in,out] lock the lock variable

Definition at line 284 of file rt-nrt.h.

Referenced by handle_interrupt().

#define rtnrt_lock_put ( lock   )     rtdm_lock_put(lock)

Release lock without preemption restoration.

Parameters:
[in,out] lock the lock variable

Definition at line 292 of file rt-nrt.h.

Referenced by handle_interrupt().

#define rtnrt_lock_get_irqsave ( lock,
flags   )     rtdm_lock_get_irqsave(lock, flags)

Acquire lock and disable preemption.

Parameters:
[in,out] lock the lock variable
[out] flags the context, should be type rtnrt_lockctx_t

Definition at line 301 of file rt-nrt.h.

Referenced by most_deregister_high_driver(), most_register_high_driver(), txbuf_get(), and txbuf_put().

#define rtnrt_lock_put_irqrestore ( lock,
flags   )     rtdm_lock_put_irqrestore(lock, flags)

Release lock and restore preemption state.

Parameters:
[in,out] lock the lock variable
[in] flags the context, should be type rtnrt_lockctx_t

Definition at line 310 of file rt-nrt.h.

Referenced by most_deregister_high_driver(), most_register_high_driver(), txbuf_get(), and txbuf_put().

#define RTNRT_SEQLOCK_UNLOCKED   RT_SEQLOCK_UNLOCKED

Initialises a sequence lock statically.

Definition at line 369 of file rt-nrt.h.

#define rtnrt_seqlock_init (  )     rt_seqlock_init(x)

Initialises a sequence lock dynamically.

Definition at line 375 of file rt-nrt.h.

#define rtnrt_write_seqlock ( sl   )     rt_write_seqlock(seqlock_t *sl)

Locks out other writers and updates the count.

Parameters:
[in,out] sl the sequence lock

Definition at line 383 of file rt-nrt.h.

#define rtnrt_write_sequnlock ( sl   )     rt_write_sequnlock(seqlock_t *sl)

Unlocks other writers and updates the count again.

Parameters:
[in,out] sl the sequence lock

Definition at line 391 of file rt-nrt.h.

#define rtnrt_read_seqbegin ( sl   )     rt_read_seqbegin(sl)

Start of read calculation -- fetch last complete writer token

Parameters:
[in,out] sl the sequence lock

Definition at line 399 of file rt-nrt.h.

#define rtnrt_read_seqretry ( sl,
iv   )     rt_read_seqretry(sl, iv)

Test if reader processed invalid data.

Parameters:
[in,out] sl the sequence lock
[in,out] iv the value that was fetched

Definition at line 408 of file rt-nrt.h.

#define rtnrt_write_seqlock_irqsave ( sl,
flags   )     rt_write_seqlock_irqsave(sl, flags)

Same as rtnrt_write_seqlock() but with IRQ protection.

Parameters:
[in,out] sl the sequence lock
[out] flags the flags of type rtdm_lockctx_t that are safed

Definition at line 417 of file rt-nrt.h.

#define rtnrt_write_sequnlock_irqrestore ( sl,
flags   )     rt_write_sequnlock_irqrestore(sl, flags)

Same as rtnrt_write_sequnlock() but with IRQ protection.

Parameters:
[in,out] sl the sequence lock
[in] flags the flags of type rtdm_lockctx_t that are safed

Definition at line 426 of file rt-nrt.h.

#define NSEC_PER_MSEC   1000000L

This constant is missing in the kernel sources. Maybe it'll be added in future, so make this optional. Name should be obvious. :)

Definition at line 485 of file rt-nrt.h.

Referenced by rtnrt_task_sleep().

#define rtnrt_ndelay ( delay_nsecs   )     rtdm_task_busy_sleep(delay_nsecs)

Busy-wait a specified amount of time

Implemented as macro because the Linux implementation can check the delay (if it's a constant) at compile-time.

Note:
The caller must not be migratable to different CPUs while executing. this service. Otherwise, the actual delay will be undefined.
This service can be called from:

Parameters:
[in] delay_nsecs the delay time in nanoseconds

Definition at line 607 of file rt-nrt.h.

#define rtnrt_udelay ( delay_usecs   )     rtdm_task_busy_sleep((delay_usecs) * NSEC_PER_USEC)

Same as rtnrt_ndelay() but with microseconds. Usage of this function should be preferred over using rtnrt_ndelay() * 1000 because Linux provides different implementations and if compiled without RT_RTDM.

Parameters:
[in] delay_usecs the delay time in microseconds

Definition at line 617 of file rt-nrt.h.

#define rtnrt_mdelay ( delay_msecs   )     rtdm_task_busy_sleep((delay_msecs) * NSEC_PER_MSEC)

Same as rtnrt_ndelay() but with microseconds. Usage of this function should be preferred over using rtnrt_ndelay() * 1000 because Linux provides different implementations and if compiled without RT_RTDM.

Parameters:
[in] delay_msecs the delay time in milliseconds

Definition at line 627 of file rt-nrt.h.

#define rtnrt_copy ( desc,
to,
from,
count   )     (desc)->function(to, from, count, (desc)->cookie)

Macro to call the function from a struct rtnrt_memcopy_desc.

Parameters:
[out] desc the pointer to struct rtnrt_memcopy_desc
[in] to the destination
[in] from the source
[in] count the number of bytes to copy
Returns:
the number of bytes that not have been copied successfully, so on success the function returns 0, on total failure count and in other cases a value between 0 and count exclusively.

Definition at line 823 of file rt-nrt.h.

Referenced by rxbuf_get(), and txbuf_put().

#define DEFINE_NRTSIG ( name   )     static rtdm_nrtsig_t name

Defines a non-real-time signalling service if compiled with RTDM. If not, expands to an empty statement. It will be defined as static.

Parameters:
[in] name the variable name

Definition at line 867 of file rt-nrt.h.

#define rtnrt_nrtsig_init ( nrt_sig,
handler   )     rtdm_nrtsig_init(nrt_sig, handler)

If compiled with RT_RTDM, registers a non-real-time signal handler. If not, does nothing.

Parameters:
[in] nrt_sig Signal handler
[in] handler Non-real-time signal handler
Returns:
0 on success, otherwise -EAGAIN is returned if no free signal slot is available.

Definition at line 879 of file rt-nrt.h.

Referenced by most_nets_init().

#define rtnrt_nrtsig_destroy ( nrt_sig   )     rtdm_nrtsig_destroy(nrt_sig)

If compiled with RT_RTDM, registers a non-real-time signal handler. If not, does nothing.

Parameters:
[in] nrt_sig Signal handler

Definition at line 888 of file rt-nrt.h.

Referenced by most_nets_exit().

#define rtnrt_nrtsig_action ( nrt_sig,
handler   )     rtdm_nrtsig_pend(nrt_sig)

Triggers the NRT event if compiled with real-time support. In non realtime, it just executes handler.

Parameters:
[in] nrt_sig the event which was used as nrt_sig in rtnrt_nrtsig_init()
[in] handler the handler function which was used as handler in rtnrt_nrtsig_init().

Definition at line 899 of file rt-nrt.h.

Referenced by nets_int_handler().

#define RTDM_IRQTYPE_SHARED   0

Define RTDM_IRQTYPE_SHARED if not defined. It's defined in new versions of RTDM, such as the version included with Xenomai 2.1.

Shared interrupt. Used as flag while registering the rt-ISR.

Definition at line 947 of file rt-nrt.h.

#define RTDM_IRQ_NONE   0

Define RTDM_IRQ_NONE if not defined. It's defined in new versions of RTDM, such as the version included with Xenomai 2.1.

Unhandled interrupt. (This is only needed when interrupt sharing is activated an therefore not necessary in RTAI 3.3.)

Definition at line 959 of file rt-nrt.h.

#define RTDM_IRQ_HANDLED   0

Define RTDM_IRQ_HANDLED if not defined. It's defined in new versions of RTDM, such as the version included with Xenomai 2.1.

Denote handled interrupt. (This is only needed when interrupt sharing is activated an therefore not necessary in RTAI 3.3.)

Definition at line 970 of file rt-nrt.h.

#define RTDM_IRQ_ENABLE   0

Define RTDM_IRQ_ENABLE if not defined. In RTDM 4, this is not needed any more because re-enabling interrupts is not necessary.

Definition at line 978 of file rt-nrt.h.

#define DECLARE_IRQ_PROXY ( proxy_name,
calling_function,
arg_type   ) 

Value:

static int proxy_name(rtdm_irq_t *irq_handle)                         \
    {                                                                     \
        return calling_function(rtdm_irq_get_arg(irq_handle, arg_type));  \
    }
Desclares a proxy function which can registered by Linux if compiled without RT_RTDM or by RTDM if compiled with RT_RTDM. The proxy function has the name proxy_name and calls calling_function internally. The argument type (the type of the "cookie") which is supplied by Linux and RTDM subsystems can be specified in arg_type.

The function will be static.

Parameters:
[in] proxy_name the name of the proxy, mostly int_handler or something like this
[in] calling_function the function which will be called inside the proxy. It must have the return type rtnrt_irqreturn_t and takes one parameter of type arg_type *. It must return RTNRT_IRQ_HANDLED if the interrupt has been handled or RTNRT_IRQ_NONE if the interrupt could not be handled.
[in] arg_type the type of the argument that is supplied by the IRQ subsystems (the "cookie"). This type must be a normal type, no pointer. Where a pointer is required, it will be casted to a pointer automatically.

Definition at line 1005 of file rt-nrt.h.

#define RTNRT_IRQ_HANDLED   (RTDM_IRQ_HANDLED | RTDM_IRQ_ENABLE)

This macro must be returned by the interrupt proxy if the interrupt could be handled (i.e. the card issued an interrupt). Important because of shared IRQ handlers.

Definition at line 1016 of file rt-nrt.h.

Referenced by handle_interrupt().

#define RTNRT_IRQ_NONE   (RTDM_IRQ_NONE | RTDM_IRQ_ENABLE)

This macro must be returned by the interrupt proxy if the interrupt could not be handed (i.e. the card issued no interrupt). Important because of shared IRQ handlers.

Definition at line 1024 of file rt-nrt.h.

Referenced by handle_interrupt().

#define rtnrt_register_interrupt_handler ( rtdm_irq_handle,
interrupt_line,
interrupt_handler,
shared,
device_name,
cookie   ) 

Value:

rtdm_irq_request(rtdm_irq_handle, interrupt_line, int_handler,        \
            shared, device_name, cookie)
Registers an interrupt handler at RTDM if the code was compiled with RT_RTDM or at Linux if not.

Parameters:
[in] rtdm_irq_handle a handle of type rtdm_irq_handler_t *
[in] interrupt_line the interrupt line that should be requested
[in] interrupt_handler a function pointer to the function which gets executed. This should be declared with DECLARE_IRQ_PROXY. Otherwise, the signature must follow the Linux/RTDM conventions for interrupt handlers.
[in] shared true if the interrupt line should be shared. This is only possible between Linux handlers or between RTDM handlers (only Xenomai) but not across domains
[in] device_name the device name -- must be unique because it's needed for identification
[in] cookie the cookie that is passed to the interrupt handler to determine the interrupt -- can also be NULLL
Returns:
0 or a negative number which indicates an error

Definition at line 1057 of file rt-nrt.h.

Referenced by probe().

#define rtnrt_irq_enable ( rtdm_irq_handle   )     rtdm_irq_enable(rtdm_irq_handle)

Enables the interrupt. This call is only needed in RTDM, not in Linux. It expands to zero which means success.

Parameters:
[in] rtdm_irq_handle a handle of type rtdm_irq_handler_t *
Returns:
0 or a negative number which indicates an error

Definition at line 1068 of file rt-nrt.h.

Referenced by probe().

#define rtnrt_free_interrupt_handler ( rtdm_irq_handle,
interrupt_line,
device_name   )     rtdm_irq_free(rtdm_irq_handle);

Frees the interrupt handler on Linux if compiled with RT_RTDM not defined or in RTDM if RT_RTDM defined.

Parameters:
[in] rtdm_irq_handle a handle of type rtdm_irq_handler_t * that was used when calling rtnrt_register_interrupt_handler()
[in] interrupt_line the interrupt line (the same which was used when calling rtnrt_register_interrupt_handler()
[in] device_name the device name -- must be unique because it's needed for identification (the same which was used in rtnrt_register_interrupt_handler())
Returns:
0 or a negative number which indicates an error

Definition at line 1086 of file rt-nrt.h.

Referenced by probe(), and remove().


Typedef Documentation

typedef rtdm_lock_t rtnrt_lock_t

Lock variable.

Definition at line 316 of file rt-nrt.h.

typedef rtdm_lockctx_t rtnrt_lockctx_t

Variable to save the context

Definition at line 321 of file rt-nrt.h.

typedef rt_seqlock_t rtnrt_seqlock_t

Basic type for sequence locks.

Definition at line 432 of file rt-nrt.h.

typedef uint64_t nanosecs_abs_t

RTDM type for representing absolute dates. Its base type is a 64 bit. unsigned integer. The unit is 1 nanosecond.

RTDM_API_VER 5 already defines this type.

Definition at line 496 of file rt-nrt.h.

typedef uint64_t nanosecs_rel_t

TDM type for representing relative intervals. Its base type is a 64 bit. signed integer. The unit is 1 nanosecond. Relative intervals can also. encode the special timeouts "infinite" and "non-blocking", see RTDM_TIMEOUT_xxx.

RTDM_API_VER 5 already defines this type.

Definition at line 506 of file rt-nrt.h.

typedef unsigned long(*) rtnrt_memcopy_func(void *to, const void *from, unsigned long count, void *cookie)

Function that copies memory from one place to another. This function must be provided by the caller of this function. Normally, it's some sort of "glue" function that calls copy_to_user(), copy_from_user() or memcpy() internally.

Parameters:
[out] to destination (kernel space or user space)
[in] from source (kernel space or user space)
[in] count number of bytes to copy
[in] cookie an additional pointer which can be used if the real memcopy function requires an additional argument
Returns:
the number of bytes that not have been copied successfully, so on success the function returns 0, on total failure count and in other cases a value between 0 and count exclusively.

Definition at line 676 of file rt-nrt.h.

typedef rtdm_nrtsig_t rtnrt_nrtsig_t

Type of the argument used in the NRT handler. Expands to void * if not realtime and to rtdm_nrtsig_t in realtime.

Definition at line 906 of file rt-nrt.h.

typedef int rtnrt_irqreturn_t

This is the return type of the interrupt handler. It expands to irqreturn_t in Linux and to int in RTDM.

Definition at line 1031 of file rt-nrt.h.


Function Documentation

static nanosecs_abs_t rtnrt_clock_read ( void   )  [inline, static]

Get a system timestamp in nanoseconds. Uses getnstimeofday() on Linux so the precision is only microseconds.

It's important that timers have been startet if using in real-time mode. On RTAI, the timers must run in oneshot mode to give precise timing information. If running in periodic mode, the timestamp returned by this function is only as accurate as the time periods are. So if your timers are running in a period of one second, the precision of this function is is only one second even if the number is nanosecond.

The function rtnrt_start_timer_oneshot() can be used. It works on all three platforms (RTAI, Xenomai, Linux).

Returns:
the system time of type nanoseconds_ab

Definition at line 528 of file rt-nrt.h.

Referenced by rtnrt_task_sleep().

static int rtnrt_task_sleep ( unsigned int  millisecs  )  [inline, static]

Suspends the current task until millisecs are elapsed. The sleeping can be interrupted by a signal.

Parameters:
[in] millisecs the time unit in milli seconds to sleep
Returns:
0 on success, otherwise
  • -EPERM may be returned if an illegal invocation environment is. detected..
  • a postive integer value is returned if the task was interrupted. It holds the number of milliseconds remaining in the originally expected sleep period.

Definition at line 570 of file rt-nrt.h.

References NSEC_PER_MSEC, and rtnrt_clock_read().

static unsigned long rtnrt_memmove ( void *  to,
const void *  from,
unsigned long  count,
void *  cookie 
) [inline, static]

Wrapper for memmove to be compinant to the rtnrt_memcopy_func signature.

Parameters:
[out] to the destination (must be in kernel space)
[in] from the source (must be in kernel space)
[in] count the number of bytes to copy
[in] cookie ignored here
Returns:
always 0

Definition at line 702 of file rt-nrt.h.

Referenced by snd_most_capture_thread(), and snd_most_playback_thread().

static unsigned long rtnrt_copy_to_user ( void *  to,
const void *  from,
unsigned long  count,
void *  cookie 
) [inline, static]

Wrapper for copy_to_user to be compinant to the rtnrt_memcopy_func signature.

Parameters:
[out] to the destination (must be in kernel space)
[in] from the source (must be in kernel space)
[in] count the number of bytes to copy
[in] cookie ignored here
Returns:
always 0

Definition at line 720 of file rt-nrt.h.

Referenced by most_sync_do_read().

static unsigned long rtnrt_copy_from_user ( void *  to,
const void *  from,
unsigned long  count,
void *  cookie 
) [inline, static]

Wrapper for copy_from_user to be compinant to the rtnrt_memcopy_func signature.

Parameters:
[out] to the destination (must be in kernel space)
[in] from the source (must be in kernel space)
[in] count the number of bytes to copy
[in] cookie ignored here
Returns:
the number of bytes that not have been copied successfully, so on success the function returns 0, on total failure count and in other cases a value between 0 and count exclusively

Definition at line 740 of file rt-nrt.h.

Referenced by most_sync_do_write().

static unsigned long rtnrt_copy_to_user_rt ( void *  to,
const void *  from,
unsigned long  count,
void *  cookie 
) [inline, static]

Wrapper for rtnrt_copy_to_user to be compinant to the rtnrt_memcopy_func signature. Only available if RT_RTDM is defined.

Parameters:
[out] to the destination (must be in kernel space)
[in] from the source (must be in kernel space)
[in] count the number of bytes to copy
[in] cookie ignored here
Returns:
the number of bytes that not have been copied successfully, so on success the function returns 0, on total failure count and in other cases a value between 0 and count exclusively

Definition at line 762 of file rt-nrt.h.

Referenced by most_sync_rt_read().

static unsigned long rtnrt_copy_from_user_rt ( void *  to,
const void *  from,
unsigned long  count,
void *  cookie 
) [inline, static]

Wrapper for rtdm_copy_from_user to be compinant to the rtnrt_memcopy_func signature. Only available if RT_RTDM is defined.

Parameters:
[out] to the destination (must be in kernel space)
[in] from the source (must be in kernel space)
[in] count the number of bytes to copy
[in] cookie ignored here
Returns:
the number of bytes that not have been copied successfully, so on success the function returns 0, on total failure count and in other cases a value between 0 and count exclusively

Definition at line 792 of file rt-nrt.h.

Referenced by most_sync_rt_write().


Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0