|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "common/stdint.h"Go to the source code of this file.
Typedefs | |
| typedef struct trap_frame | trap_frame_t |
| arch-neutral hardware-interrupt (IRQ) interface. | |
| typedef void(*) | irq_handler_fn(uint32_t irq, trap_frame_t *frame) |
| IRQ handler function type. | |
| typedef void(*) | device_irq_handler_t(void *context) |
| a device interrupt handler (a message-signalled interrupt, or a PCI interrupt line). | |
Functions | |
| bool | arch_frame_is_user (const trap_frame_t *frame) |
| true if the interrupt came while user code ran (CPU time accounting). | |
| int | arch_irq_register (uint32_t irq, irq_handler_fn handler) |
| register a handler for a hardware IRQ line. | |
| void | arch_irq_enable (uint32_t irq) |
| unmask (enable) a hardware IRQ line so it can be delivered. | |
| void | arch_irq_disable (uint32_t irq) |
| mask (disable) a hardware IRQ line. | |
| void | arch_irq_ack (uint32_t irq) |
| acknowledge an IRQ (end-of-interrupt) at the interrupt controller. | |
| bool | arch_msi_alloc (device_irq_handler_t handler, void *context, uint64_t *address, uint32_t *data) |
| allocate an interrupt vector for a message-signalled interrupt (PCI MSI or MSI-X) and give the message that the device must write to raise it. | |
| void | arch_irq_set_level (uint32_t irq) |
| make an ISA IRQ line level-triggered, for a PCI interrupt line that the firmware routed to it. | |
| bool | arch_irq_set_cpu (uint32_t irq, uint32_t cpu) |
| send the interrupts of an ISA IRQ line to a core. | |
| uint64_t | arch_msi_address (uint32_t cpu) |
| the message address that sends a message-signalled interrupt to a core. | |
| typedef struct trap_frame trap_frame_t |
arch-neutral hardware-interrupt (IRQ) interface.
portable drivers register their line handlers through this API instead of reaching into the x86 PIC/IDT/ISR machinery. each architecture provides its own implementation that wraps whatever interrupt controller it has (8259A PIC on x86, GIC on ARM, PLIC on RISC-V). opaque saved-state handle passed to an IRQ handler.
the concrete layout is architecture-specific (on x86 it is the register dump built by the ISR stubs). portable code treats it as opaque; only arch code that knows the layout may dereference it. handlers that just need to service a device can ignore it entirely.
| typedef void(*) irq_handler_fn(uint32_t irq, trap_frame_t *frame) |
IRQ handler function type.
| irq | the hardware IRQ line that fired. |
| frame | opaque saved state at the point of interruption (may be NULL to a handler that does not need it). |
| typedef void(*) device_irq_handler_t(void *context) |
a device interrupt handler (a message-signalled interrupt, or a PCI interrupt line).
it runs with interrupts off, after the end of interrupt is sent, so it must clear the cause in the device.
| context | the value given when the handler was attached. |
| bool arch_frame_is_user | ( | const trap_frame_t * | frame | ) |
true if the interrupt came while user code ran (CPU time accounting).
| frame | the frame a handler was given. |
| int arch_irq_register | ( | uint32_t | irq, |
| irq_handler_fn | handler ) |
register a handler for a hardware IRQ line.
| irq | the IRQ line to handle. |
| handler | the function to call when the line fires. |
| void arch_irq_enable | ( | uint32_t | irq | ) |
unmask (enable) a hardware IRQ line so it can be delivered.
| irq | the IRQ line to enable. |
| void arch_irq_disable | ( | uint32_t | irq | ) |
mask (disable) a hardware IRQ line.
| irq | the IRQ line to disable. |
| void arch_irq_ack | ( | uint32_t | irq | ) |
acknowledge an IRQ (end-of-interrupt) at the interrupt controller.
| irq | the IRQ line to acknowledge. |
| bool arch_msi_alloc | ( | device_irq_handler_t | handler, |
| void * | context, | ||
| uint64_t * | address, | ||
| uint32_t * | data ) |
allocate an interrupt vector for a message-signalled interrupt (PCI MSI or MSI-X) and give the message that the device must write to raise it.
| handler | the function to call when the message arrives. |
| context | passed to the handler. |
| address | receives the message address. |
| data | receives the message data. |
| void arch_irq_set_level | ( | uint32_t | irq | ) |
make an ISA IRQ line level-triggered, for a PCI interrupt line that the firmware routed to it.
does nothing when the line is already level or when the 8259 PICs are in use (the firmware sets their trigger mode).
| irq | the IRQ line (0 to 15). |
send the interrupts of an ISA IRQ line to a core.
the vector does not change, so an interrupt that comes during the change goes to the old core or to the new one, and both handle it.
| irq | the IRQ line (0 to 15). |
| cpu | the index of the core (cpu_t.index). |
the message address that sends a message-signalled interrupt to a core.
the message data (the vector) is the same on each core.
| cpu | the index of the core (cpu_t.index). |