InterruptQuery(), InterruptQuery_r()
Obtain data about an interrupt source or Interrupt Service Thread (IST)
Synopsis:
#include <sys/neutrino.h>
int InterruptQuery( unsigned type,
int id,
unsigned long extra,
struct interrupt_query_data *data);
int InterruptQuery_r( unsigned type,
int id,
unsigned long extra,
struct interrupt_query_data *data);
Arguments:
- type
- The query type; defines whether id is an interrupt source
or IST. One of:
- _NTO_INTR_QUERY_HANDLER
- _NTO_INTR_QUERY_SOURCE
- id
- The query's unique identifier; either the interrupt vector number given to, or unique interrupt ID returned by InterruptAttach*().
- extra
- Specifies additional parameters based on the query type (refer to the Description below for details). For example, you can use the _NTO_INTR_QUERY_SOURCE query type to specify which core to use for per-core interrupts.
- data
- A pointer to the interrupt_query_data structure, which provides data about the interrupt source or IST.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The InterruptQuery() and InterruptQuery_r()
functions obtain data about an interrupt source or IST depending on the query type
you set. These functions are identical except in the way they indicate errors. See
the Returns
section for details.
The usage of the extra parameter depends on the query type that you set. If you set the _NTO_INTR_QUERY_SOURCE type, the extra parameter specifies which core to use for per-core interrupts. Otherwise, if you set the _NTO_INTR_QUERY_HANDLER type, the query ignores the extra parameter.
If you set _NTO_INTR_QUERY_SOURCE as the query type, then the process must have the PROCMGR_AID_INTERRUPT ability enabled. For more information, refer to procmgr_ability().
The interrupt_query_data structure
The interrupt_query_data structure holds the data of an interrupt source or IST:
struct interrupt_query_data {
uint32_t type;
uint32_t vector;
uint64_t deliver_time;
uint64_t deliver_count;
union {
struct {
uint16_t startup_flags;
uint16_t startup_config;
uint32_t num_handlers;
uint32_t mask_count;
uint32_t flags;
uint64_t route;
} source;
struct {
pid_t ist_pid;
pthread_t ist_tid;
uint64_t ist_runmask;
int32_t attach_id;
uint32_t attach_flags;
uint32_t mask_count;
struct sigevent event;
} handler;
} data;
};
This structure includes the following members:
- type
- The type of interrupt query. One of the following:
- A value of _NTO_INTR_QUERY_HANDLER indicates that the
handler
structure was filled in thedata
union. This structure holds the data of an IST. - A value of _NTO_INTR_QUERY_SOURCE indicates that the
source
structure was filled in thedata
union. This structure holds the data of an interrupt source.
- A value of _NTO_INTR_QUERY_HANDLER indicates that the
- vector
- The interrupt vector number.
- deliver_time
- The timestamp, in clock cycles, of the last delivered interrupt.
- deliver_count
- The number of times the kernel has received the interrupt. Note:Currently, the delivery count isn't tracked, so this field is always zero.
Specifying _NTO_INTR_QUERY_SOURCE as the query type provides the following data about an interrupt source:
- startup_flags
- The flags provided by startup for the interrupt source.
- startup_config
- The config provided by startup for the interrupt source.
- num_handlers
- The number of ISTs attached to the interrupt.
- mask_count
- The mask count of the interrupt source.
- flags
- Controller-specific flags.
- route
- Controller-specific destination the process routed the interrupt to.
Specifying _NTO_INTR_QUERY_HANDLER as the query type provides the following data about an IST:
- ist_pid
- The IST's process ID.
- ist_tid
- The IST's thread ID.
- ist_runmask
- The IST's runmask.
- attach_id
- The ID the process assigned to this handler when it called InterruptAttach*().
- attach_flags
- The _NTO_INTR_FLAGS_* defined in InterruptAttach*().
- mask_count
- The mask count of the handler.
- event
- A copy of the sigevent provided to InterruptAttachEvent*().
Returns:
The only difference between these functions is the way they indicate errors:
- InterruptQuery()
- If an error occurs, -1 is returned and errno is set. Any other value returned indicates success.
- InterruptQuery_r()
- EOK is returned on success. This function does NOT set errno. If an error occurs, the negative of a value in the Errors section may be returned.
Errors:
- EINVAL
- One of the following errors occurred:
- You didn't specify a valid query type.
- You set _NTO_INTR_QUERY_SOURCE as the query type, but the ID doesn't correspond to an interrupt source.
- EPERM
- You set _NTO_INTR_QUERY_SOURCE as the query type, but the caller doesn't have the PROCMGR_AID_INTERRUPT ability enabled.
- ESRCH
- You set _NTO_INTR_QUERY_HANDLER as the query type, but the specified ID doesn't match the ID of an attached IST.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |