Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/iommu/intel_drv.c
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
#include <x86/iommu/intel_reg.h> | #include <x86/iommu/intel_reg.h> | ||||
#include <x86/iommu/busdma_dmar.h> | #include <x86/iommu/busdma_dmar.h> | ||||
#include <x86/iommu/intel_dmar.h> | #include <x86/iommu/intel_dmar.h> | ||||
#include <dev/pci/pcireg.h> | #include <dev/pci/pcireg.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#ifdef DEV_APIC | #ifdef DEV_APIC | ||||
#include "pcib_if.h" | #include "pcib_if.h" | ||||
#include <machine/intr_machdep.h> | |||||
#include <x86/apicreg.h> | |||||
#include <x86/apicvar.h> | |||||
#endif | #endif | ||||
#define DMAR_FAULT_IRQ_RID 0 | #define DMAR_FAULT_IRQ_RID 0 | ||||
#define DMAR_QI_IRQ_RID 1 | #define DMAR_QI_IRQ_RID 1 | ||||
#define DMAR_REG_RID 2 | #define DMAR_REG_RID 2 | ||||
static devclass_t dmar_devclass; | static devclass_t dmar_devclass; | ||||
static device_t *dmar_devs; | static device_t *dmar_devs; | ||||
▲ Show 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | |||||
dmar_find_nonpci(u_int id, u_int entry_type, uint16_t *rid) | dmar_find_nonpci(u_int id, u_int entry_type, uint16_t *rid) | ||||
{ | { | ||||
device_t dmar_dev; | device_t dmar_dev; | ||||
struct dmar_unit *unit; | struct dmar_unit *unit; | ||||
ACPI_DMAR_HARDWARE_UNIT *dmarh; | ACPI_DMAR_HARDWARE_UNIT *dmarh; | ||||
ACPI_DMAR_DEVICE_SCOPE *devscope; | ACPI_DMAR_DEVICE_SCOPE *devscope; | ||||
ACPI_DMAR_PCI_PATH *path; | ACPI_DMAR_PCI_PATH *path; | ||||
char *ptr, *ptrend; | char *ptr, *ptrend; | ||||
int i; | int error, i; | ||||
for (i = 0; i < dmar_devcnt; i++) { | for (i = 0; i < dmar_devcnt; i++) { | ||||
dmar_dev = dmar_devs[i]; | dmar_dev = dmar_devs[i]; | ||||
if (dmar_dev == NULL) | if (dmar_dev == NULL) | ||||
continue; | continue; | ||||
unit = (struct dmar_unit *)device_get_softc(dmar_dev); | unit = (struct dmar_unit *)device_get_softc(dmar_dev); | ||||
dmarh = dmar_find_by_index(i); | dmarh = dmar_find_by_index(i); | ||||
if (dmarh == NULL) | if (dmarh == NULL) | ||||
continue; | continue; | ||||
ptr = (char *)dmarh + sizeof(*dmarh); | ptr = (char *)dmarh + sizeof(*dmarh); | ||||
ptrend = (char *)dmarh + dmarh->Header.Length; | ptrend = (char *)dmarh + dmarh->Header.Length; | ||||
for (;;) { | for (;;) { | ||||
if (ptr >= ptrend) | if (ptr >= ptrend) | ||||
break; | break; | ||||
devscope = (ACPI_DMAR_DEVICE_SCOPE *)ptr; | devscope = (ACPI_DMAR_DEVICE_SCOPE *)ptr; | ||||
ptr += devscope->Length; | ptr += devscope->Length; | ||||
if (devscope->EntryType != entry_type) | if (devscope->EntryType != entry_type) | ||||
continue; | continue; | ||||
if (devscope->EnumerationId != id) | if (devscope->EnumerationId != id) | ||||
continue; | continue; | ||||
#ifdef DEV_APIC | |||||
if (entry_type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) { | |||||
error = ioapic_get_rid(id, rid); | |||||
/* | |||||
* If our IOAPIC has PCI bindings then | |||||
* use the PCI device rid. | |||||
*/ | |||||
if (error == 0) | |||||
return (unit); | |||||
} | |||||
#else | |||||
&error; | |||||
emaste: If this is to eliminate the unused variable warning I think `(void)error;` is more conventional… | |||||
kibAuthorUnsubmitted Not Done Inline ActionsI did not wanted the #ifdef clutter in the declaration section. But ok, redid it. kib: I did not wanted the #ifdef clutter in the declaration section. But ok, redid it. | |||||
#endif | |||||
if (devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE) | if (devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE) | ||||
== 2) { | == 2) { | ||||
if (rid != NULL) { | if (rid != NULL) { | ||||
path = (ACPI_DMAR_PCI_PATH *) | path = (ACPI_DMAR_PCI_PATH *) | ||||
(devscope + 1); | (devscope + 1); | ||||
*rid = PCI_RID(devscope->Bus, | *rid = PCI_RID(devscope->Bus, | ||||
path->Device, path->Function); | path->Device, path->Function); | ||||
} | } | ||||
return (unit); | return (unit); | ||||
} else { | } | ||||
/* XXXKIB */ | |||||
printf( | printf( | ||||
"dmar_find_nonpci: id %d type %d path length != 2\n", | "dmar_find_nonpci: id %d type %d path length != 2\n", | ||||
id, entry_type); | id, entry_type); | ||||
} | break; | ||||
} | } | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
struct dmar_unit * | struct dmar_unit * | ||||
dmar_find_hpet(device_t dev, uint16_t *rid) | dmar_find_hpet(device_t dev, uint16_t *rid) | ||||
▲ Show 20 Lines • Show All 461 Lines • Show Last 20 Lines |
If this is to eliminate the unused variable warning I think (void)error; is more conventional, but why not just eliminate the variable?