drivers/interrupt_controller: Make VT-D remap generic and handle flags

This will not only be used by MSI remapping but by all relevant
interrupts.

Fix also IRTE settings:
- handle x2apic for destination id
- destination mode is always logical (as for IOAPIC)

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-12-16 11:10:21 +01:00 committed by Anas Nashif
commit 1a1bc0d242
4 changed files with 23 additions and 8 deletions

View file

@ -16,7 +16,9 @@ typedef uint32_t (*vtd_remap_msi_f)(const struct device *dev,
uint8_t n_vector);
typedef int (*vtd_remap_f)(const struct device *dev,
msi_vector_t *vector);
uint8_t irte_idx,
uint16_t vector,
uint32_t flags);
struct vtd_driver_api {
vtd_alloc_entries_f allocate_entries;
@ -66,17 +68,21 @@ static inline uint32_t vtd_remap_msi(const struct device *dev,
* @brief Remap the given vector
*
* @param dev Pointer to the device structure for the driver instance
* @param vector A valid allocated MSI vector
* @param irte_idx A previoulsy allocated irte entry index number
* @param vector An allocated interrupt vector
* @param flags interrupt flags
*
* @return 0 on success, a negative errno otherwise
*/
static inline int vtd_remap(const struct device *dev,
msi_vector_t *vector)
uint8_t irte_idx,
uint16_t vector,
uint32_t flags)
{
const struct vtd_driver_api *api =
(const struct vtd_driver_api *)dev->api;
return api->remap(dev, vector);
return api->remap(dev, irte_idx, vector, flags);
}

View file

@ -27,6 +27,7 @@ extern "C" {
#define IOAPIC_HIGH 0x00000000
#define IOAPIC_LOGICAL 0x00000800
#define IOAPIC_PHYSICAL 0x00000000
#define IOAPIC_DELIVERY_MODE_MASK 0x00000700
#define IOAPIC_FIXED 0x00000000
#define IOAPIC_LOWEST 0x00000100
#define IOAPIC_SMI 0x00000200