The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
msi.c File Reference
#include "arch/arch_irq.h"
#include "apic.h"
#include "isr.h"
#include "irq.h"
#include "kernel/cpu/cpu.h"

Macros

#define DEVICE_VECTOR_FIRST   0x30
 message-signalled interrupts on x86 (Intel SDM volume 3, section 11.11).
#define DEVICE_VECTOR_LAST   0x7F
#define DEVICE_VECTOR_COUNT   (DEVICE_VECTOR_LAST - DEVICE_VECTOR_FIRST + 1)
#define MSI_ADDRESS_BASE   0xFEE00000u

Functions

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.
uint64_t arch_msi_address (uint32_t cpu)
 the message address that sends a message-signalled interrupt to a core.
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.

Macro Definition Documentation

◆ DEVICE_VECTOR_FIRST

#define DEVICE_VECTOR_FIRST   0x30

message-signalled interrupts on x86 (Intel SDM volume 3, section 11.11).

a device raises an MSI by a memory write: the address selects the local APIC (0xFEE00000 with the APIC id in bits 12 to 19), and the data is the vector (fixed delivery, edge). each allocation takes one vector from the device range below. the vector handler sends the end of interrupt first, like the IRQ path does, and then calls the device handler.

◆ DEVICE_VECTOR_LAST

#define DEVICE_VECTOR_LAST   0x7F

◆ DEVICE_VECTOR_COUNT

#define DEVICE_VECTOR_COUNT   (DEVICE_VECTOR_LAST - DEVICE_VECTOR_FIRST + 1)

◆ MSI_ADDRESS_BASE

#define MSI_ADDRESS_BASE   0xFEE00000u

Function Documentation

◆ arch_msi_alloc()

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.

Parameters
handlerthe function to call when the message arrives.
contextpassed to the handler.
addressreceives the message address.
datareceives the message data.
Returns
false if the CPU cannot take messages (no local APIC in use) or all device vectors are in use.

◆ arch_msi_address()

uint64_t arch_msi_address ( uint32_t cpu)

the message address that sends a message-signalled interrupt to a core.

the message data (the vector) is the same on each core.

Parameters
cputhe index of the core (cpu_t.index).
Returns
the address for the MSI or MSI-X capability of a device.

◆ arch_irq_set_level()

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).

Parameters
irqthe IRQ line (0 to 15).