Catch up with ACPI-CA 20070320 import.

This commit is contained in:
Jung-uk Kim 2007-03-22 18:16:43 +00:00
parent df6b852a3a
commit 2be4e4713a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167814
47 changed files with 778 additions and 803 deletions

View File

@ -32,10 +32,12 @@ __FBSDID("$FreeBSD$");
* 6.1 : Environmental support
*/
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/linker_set.h>
#include <sys/sysctl.h>
#include <contrib/dev/acpica/acpi.h>
#include <contrib/dev/acpica/actables.h>
static u_long amd64_acpi_root;
@ -54,25 +56,16 @@ AcpiOsTerminate(void)
return(0);
}
ACPI_STATUS
AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *RsdpPhysicalAddress)
ACPI_PHYSICAL_ADDRESS
AcpiOsGetRootPointer(void)
{
ACPI_POINTER ptr;
ACPI_STATUS status;
u_long ptr;
if (amd64_acpi_root == 0) {
/*
* The loader passes the physical address at which it found the
* RSDP in a hint. We could recover this rather than searching
* manually here.
*/
status = AcpiFindRootPointer(Flags, &ptr);
if (status == AE_OK)
amd64_acpi_root = ptr.Pointer.Physical;
} else
status = AE_OK;
if (amd64_acpi_root == 0 &&
(resource_long_value("acpi", 0, "rsdp", (long *)&ptr) == 0 ||
AcpiFindRootPointer((ACPI_NATIVE_UINT *)&ptr) == AE_OK) &&
ptr != 0)
amd64_acpi_root = ptr;
RsdpPhysicalAddress->PointerType = ACPI_PHYSICAL_POINTER;
RsdpPhysicalAddress->Pointer.Physical = amd64_acpi_root;
return (status);
return (amd64_acpi_root);
}

View File

@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
#define NIOAPICS 32 /* Max number of I/O APICs */
#define NLAPICS 32 /* Max number of local APICs */
typedef void madt_entry_handler(APIC_HEADER *entry, void *arg);
typedef void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
/* These two arrays are indexed by APIC IDs. */
struct ioapic_info {
@ -70,26 +70,29 @@ struct lapic_info {
} lapics[NLAPICS];
static int madt_found_sci_override;
static MULTIPLE_APIC_TABLE *madt;
static ACPI_TABLE_MADT *madt;
static vm_paddr_t madt_physaddr;
static vm_offset_t madt_length;
MALLOC_DEFINE(M_MADT, "madt_table", "ACPI MADT Table Items");
static enum intr_polarity interrupt_polarity(UINT16 Polarity, UINT8 Source);
static enum intr_trigger interrupt_trigger(UINT16 TriggerMode, UINT8 Source);
static enum intr_polarity interrupt_polarity(UINT16 IntiFlags, UINT8 Source);
static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
static int madt_find_cpu(u_int acpi_id, u_int *apic_id);
static int madt_find_interrupt(int intr, void **apic, u_int *pin);
static void *madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
static void *madt_map_table(vm_paddr_t pa, int offset, const char *sig);
static void madt_parse_apics(APIC_HEADER *entry, void *arg);
static void madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr);
static void madt_parse_ints(APIC_HEADER *entry, void *arg __unused);
static void madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi);
static void madt_parse_nmi(MADT_NMI_SOURCE *nmi);
static void madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
static void madt_parse_interrupt_override(
ACPI_MADT_INTERRUPT_OVERRIDE *intr);
static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry,
void *arg __unused);
static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi);
static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi);
static int madt_probe(void);
static int madt_probe_cpus(void);
static void madt_probe_cpus_handler(APIC_HEADER *entry, void *arg __unused);
static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
void *arg __unused);
static int madt_probe_table(vm_paddr_t address);
static void madt_register(void *dummy);
static int madt_setup_local(void);
@ -161,14 +164,14 @@ madt_map_table(vm_paddr_t pa, int offset, const char *sig)
void *table;
header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
if (strncmp(header->Signature, sig, 4) != 0) {
if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
return (NULL);
}
length = header->Length;
madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
table = madt_map(pa, offset, length);
if (ACPI_FAILURE(AcpiTbVerifyTableChecksum(table))) {
if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
if (bootverbose)
printf("MADT: Failed checksum for table %s\n", sig);
madt_unmap(table, length);
@ -192,10 +195,10 @@ madt_unmap_table(void *table)
static int
madt_probe(void)
{
ACPI_POINTER rsdp_ptr;
RSDP_DESCRIPTOR *rsdp;
RSDT_DESCRIPTOR *rsdt;
XSDT_DESCRIPTOR *xsdt;
ACPI_PHYSICAL_ADDRESS rsdp_ptr;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_RSDT *rsdt;
ACPI_TABLE_XSDT *xsdt;
int i, count;
if (resource_disabled("acpi", 0))
@ -206,12 +209,9 @@ madt_probe(void)
* calls pmap_mapbios() to find the RSDP, we assume that we can use
* pmap_mapbios() to map the RSDP.
*/
if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK)
if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
return (ENXIO);
#ifdef __i386__
KASSERT(rsdp_ptr.Pointer.Physical < KERNLOAD, ("RSDP too high"));
#endif
rsdp = pmap_mapbios(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR));
rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
if (rsdp == NULL) {
if (bootverbose)
printf("MADT: Failed to map RSDP\n");
@ -230,38 +230,40 @@ madt_probe(void)
* the version 1.0 portion of the RSDP. Version 2.0 has
* an additional checksum that we verify first.
*/
if (AcpiTbGenerateChecksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
if (bootverbose)
printf("MADT: RSDP failed extended checksum\n");
return (ENXIO);
}
xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, XSDT_SIG);
xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1,
ACPI_SIG_XSDT);
if (xsdt == NULL) {
if (bootverbose)
printf("MADT: Failed to map XSDT\n");
return (ENXIO);
}
count = (xsdt->Length - sizeof(ACPI_TABLE_HEADER)) /
count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
sizeof(UINT64);
for (i = 0; i < count; i++)
if (madt_probe_table(xsdt->TableOffsetEntry[i]))
break;
madt_unmap_table(xsdt);
} else {
rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, RSDT_SIG);
rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1,
ACPI_SIG_RSDT);
if (rsdt == NULL) {
if (bootverbose)
printf("MADT: Failed to map RSDT\n");
return (ENXIO);
}
count = (rsdt->Length - sizeof(ACPI_TABLE_HEADER)) /
count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
sizeof(UINT32);
for (i = 0; i < count; i++)
if (madt_probe_table(rsdt->TableOffsetEntry[i]))
break;
madt_unmap_table(rsdt);
}
pmap_unmapbios((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR));
pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
if (madt_physaddr == 0) {
if (bootverbose)
printf("MADT: No MADT table found\n");
@ -275,7 +277,7 @@ madt_probe(void)
* Verify that we can map the full table and that its checksum is
* correct, etc.
*/
madt = madt_map_table(madt_physaddr, 0, APIC_SIG);
madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
if (madt == NULL)
return (ENXIO);
madt_unmap_table(madt);
@ -303,7 +305,7 @@ madt_probe_table(vm_paddr_t address)
printf("Table '%.4s' at 0x%jx\n", table->Signature,
(uintmax_t)address);
if (strncmp(table->Signature, APIC_SIG, 4) != 0) {
if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) {
madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
return (0);
}
@ -320,7 +322,7 @@ static int
madt_probe_cpus(void)
{
madt = madt_map_table(madt_physaddr, 0, APIC_SIG);
madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
KASSERT(madt != NULL, ("Unable to re-map MADT"));
madt_walk_table(madt_probe_cpus_handler, NULL);
madt_unmap_table(madt);
@ -336,10 +338,10 @@ madt_setup_local(void)
{
madt = pmap_mapbios(madt_physaddr, madt_length);
lapic_init(madt->LocalApicAddress);
lapic_init(madt->Address);
printf("ACPI APIC Table: <%.*s %.*s>\n",
(int)sizeof(madt->OemId), madt->OemId,
(int)sizeof(madt->OemTableId), madt->OemTableId);
(int)sizeof(madt->Header.OemId), madt->Header.OemId,
(int)sizeof(madt->Header.OemTableId), madt->Header.OemTableId);
/*
* We ignore 64-bit local APIC override entries. Should we
@ -378,10 +380,10 @@ madt_setup_io(void)
* force it to use level trigger and active-low polarity.
*/
if (!madt_found_sci_override) {
if (madt_find_interrupt(AcpiGbl_FADT->SciInt, &ioapic, &pin)
!= 0)
printf("MADT: Could not find APIC for SCI IRQ %d\n",
AcpiGbl_FADT->SciInt);
if (madt_find_interrupt(AcpiGbl_FADT.SciInterrupt, &ioapic,
&pin) != 0)
printf("MADT: Could not find APIC for SCI IRQ %u\n",
AcpiGbl_FADT.SciInterrupt);
else {
printf(
"MADT: Forcing active-low polarity and level trigger for SCI\n");
@ -416,46 +418,46 @@ SYSINIT(madt_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST,
static void
madt_walk_table(madt_entry_handler *handler, void *arg)
{
APIC_HEADER *entry;
ACPI_SUBTABLE_HEADER *entry;
u_char *p, *end;
end = (u_char *)(madt) + madt->Length;
end = (u_char *)(madt) + madt->Header.Length;
for (p = (u_char *)(madt + 1); p < end; ) {
entry = (APIC_HEADER *)p;
entry = (ACPI_SUBTABLE_HEADER *)p;
handler(entry, arg);
p += entry->Length;
}
}
static void
madt_probe_cpus_handler(APIC_HEADER *entry, void *arg)
madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
{
MADT_PROCESSOR_APIC *proc;
ACPI_MADT_LOCAL_APIC *proc;
struct lapic_info *la;
switch (entry->Type) {
case APIC_PROCESSOR:
case ACPI_MADT_TYPE_LOCAL_APIC:
/*
* The MADT does not include a BSP flag, so we have to
* let the MP code figure out which CPU is the BSP on
* its own.
*/
proc = (MADT_PROCESSOR_APIC *)entry;
proc = (ACPI_MADT_LOCAL_APIC *)entry;
if (bootverbose)
printf("MADT: Found CPU APIC ID %d ACPI ID %d: %s\n",
proc->LocalApicId, proc->ProcessorId,
proc->ProcessorEnabled ? "enabled" : "disabled");
if (!proc->ProcessorEnabled)
printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n",
proc->Id, proc->ProcessorId,
(proc->LapicFlags & ACPI_MADT_ENABLED) ?
"enabled" : "disabled");
if (!(proc->LapicFlags & ACPI_MADT_ENABLED))
break;
if (proc->LocalApicId >= NLAPICS)
panic("%s: CPU ID %d too high", __func__,
proc->LocalApicId);
la = &lapics[proc->LocalApicId];
if (proc->Id >= NLAPICS)
panic("%s: CPU ID %u too high", __func__, proc->Id);
la = &lapics[proc->Id];
KASSERT(la->la_enabled == 0,
("Duplicate local APIC ID %d", proc->LocalApicId));
("Duplicate local APIC ID %u", proc->Id));
la->la_enabled = 1;
la->la_acpi_id = proc->ProcessorId;
lapic_create(proc->LocalApicId, 0);
lapic_create(proc->Id, 0);
break;
}
}
@ -465,26 +467,26 @@ madt_probe_cpus_handler(APIC_HEADER *entry, void *arg)
* Add an I/O APIC from an entry in the table.
*/
static void
madt_parse_apics(APIC_HEADER *entry, void *arg __unused)
madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg __unused)
{
MADT_IO_APIC *apic;
ACPI_MADT_IO_APIC *apic;
switch (entry->Type) {
case APIC_IO:
apic = (MADT_IO_APIC *)entry;
case ACPI_MADT_TYPE_IO_APIC:
apic = (ACPI_MADT_IO_APIC *)entry;
if (bootverbose)
printf("MADT: Found IO APIC ID %d, Interrupt %d at %p\n",
apic->IoApicId, apic->Interrupt,
printf(
"MADT: Found IO APIC ID %u, Interrupt %u at %p\n",
apic->Id, apic->GlobalIrqBase,
(void *)(uintptr_t)apic->Address);
if (apic->IoApicId >= NIOAPICS)
panic("%s: I/O APIC ID %d too high", __func__,
apic->IoApicId);
if (ioapics[apic->IoApicId].io_apic != NULL)
panic("%s: Double APIC ID %d", __func__,
apic->IoApicId);
ioapics[apic->IoApicId].io_apic = ioapic_create(apic->Address,
apic->IoApicId, apic->Interrupt);
ioapics[apic->IoApicId].io_vector = apic->Interrupt;
if (apic->Id >= NIOAPICS)
panic("%s: I/O APIC ID %u too high", __func__,
apic->Id);
if (ioapics[apic->Id].io_apic != NULL)
panic("%s: Double APIC ID %u", __func__, apic->Id);
ioapics[apic->Id].io_apic = ioapic_create(apic->Address,
apic->Id, apic->GlobalIrqBase);
ioapics[apic->Id].io_vector = apic->GlobalIrqBase;
break;
default:
break;
@ -498,18 +500,18 @@ madt_parse_apics(APIC_HEADER *entry, void *arg __unused)
* SCI for which we use Active Lo, Level Triggered.
*/
static enum intr_polarity
interrupt_polarity(UINT16 Polarity, UINT8 Source)
interrupt_polarity(UINT16 IntiFlags, UINT8 Source)
{
switch (Polarity) {
case POLARITY_CONFORMS:
if (Source == AcpiGbl_FADT->SciInt)
switch (IntiFlags & ACPI_MADT_POLARITY_MASK) {
case ACPI_MADT_POLARITY_CONFORMS:
if (Source == AcpiGbl_FADT.SciInterrupt)
return (INTR_POLARITY_LOW);
else
return (INTR_POLARITY_HIGH);
case POLARITY_ACTIVE_HIGH:
case ACPI_MADT_POLARITY_ACTIVE_HIGH:
return (INTR_POLARITY_HIGH);
case POLARITY_ACTIVE_LOW:
case ACPI_MADT_POLARITY_ACTIVE_LOW:
return (INTR_POLARITY_LOW);
default:
panic("Bogus Interrupt Polarity");
@ -517,18 +519,18 @@ interrupt_polarity(UINT16 Polarity, UINT8 Source)
}
static enum intr_trigger
interrupt_trigger(UINT16 TriggerMode, UINT8 Source)
interrupt_trigger(UINT16 IntiFlags, UINT8 Source)
{
switch (TriggerMode) {
case TRIGGER_CONFORMS:
if (Source == AcpiGbl_FADT->SciInt)
switch (IntiFlags & ACPI_MADT_TRIGGER_MASK) {
case ACPI_MADT_TRIGGER_CONFORMS:
if (Source == AcpiGbl_FADT.SciInterrupt)
return (INTR_TRIGGER_LEVEL);
else
return (INTR_TRIGGER_EDGE);
case TRIGGER_EDGE:
case ACPI_MADT_TRIGGER_EDGE:
return (INTR_TRIGGER_EDGE);
case TRIGGER_LEVEL:
case ACPI_MADT_TRIGGER_LEVEL:
return (INTR_TRIGGER_LEVEL);
default:
panic("Bogus Interrupt Trigger Mode");
@ -586,7 +588,7 @@ madt_find_interrupt(int intr, void **apic, u_int *pin)
* Parse an interrupt source override for an ISA interrupt.
*/
static void
madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr)
{
void *new_ioapic, *old_ioapic;
u_int new_pin, old_pin;
@ -594,20 +596,19 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
enum intr_polarity pol;
char buf[64];
if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->Source == 0 &&
intr->Interrupt == 2) {
if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 &&
intr->GlobalIrq == 2) {
if (bootverbose)
printf("MADT: Skipping timer override\n");
return;
}
if (bootverbose)
printf("MADT: Interrupt override: source %u, irq %u\n",
intr->Source, intr->Interrupt);
intr->SourceIrq, intr->GlobalIrq);
KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero"));
if (madt_find_interrupt(intr->Interrupt, &new_ioapic,
&new_pin) != 0) {
printf("MADT: Could not find APIC for vector %d (IRQ %d)\n",
intr->Interrupt, intr->Source);
if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) {
printf("MADT: Could not find APIC for vector %u (IRQ %u)\n",
intr->GlobalIrq, intr->SourceIrq);
return;
}
@ -615,15 +616,15 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
* Lookup the appropriate trigger and polarity modes for this
* entry.
*/
trig = interrupt_trigger(intr->TriggerMode, intr->Source);
pol = interrupt_polarity(intr->Polarity, intr->Source);
trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq);
pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq);
/*
* If the SCI is identity mapped but has edge trigger and
* active-hi polarity or the force_sci_lo tunable is set,
* force it to use level/lo.
*/
if (intr->Source == AcpiGbl_FADT->SciInt) {
if (intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) {
madt_found_sci_override = 1;
if (getenv_string("hw.acpi.sci.trigger", buf, sizeof(buf))) {
if (tolower(buf[0]) == 'e')
@ -652,23 +653,24 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
}
/* Remap the IRQ if it is mapped to a different interrupt vector. */
if (intr->Source != intr->Interrupt) {
if (intr->SourceIrq != intr->GlobalIrq) {
/*
* If the SCI is remapped to a non-ISA global interrupt,
* then override the vector we use to setup and allocate
* the interrupt.
*/
if (intr->Interrupt > 15 &&
intr->Source == AcpiGbl_FADT->SciInt)
acpi_OverrideInterruptLevel(intr->Interrupt);
if (intr->GlobalIrq > 15 &&
intr->SourceIrq == AcpiGbl_FADT.SciInterrupt)
acpi_OverrideInterruptLevel(intr->GlobalIrq);
else
ioapic_remap_vector(new_ioapic, new_pin, intr->Source);
if (madt_find_interrupt(intr->Source, &old_ioapic,
ioapic_remap_vector(new_ioapic, new_pin,
intr->SourceIrq);
if (madt_find_interrupt(intr->SourceIrq, &old_ioapic,
&old_pin) != 0)
printf("MADT: Could not find APIC for source IRQ %d\n",
intr->Source);
printf("MADT: Could not find APIC for source IRQ %u\n",
intr->SourceIrq);
else if (ioapic_get_vector(old_ioapic, old_pin) ==
intr->Source)
intr->SourceIrq)
ioapic_disable_pin(old_ioapic, old_pin);
}
@ -681,31 +683,31 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
* Parse an entry for an NMI routed to an IO APIC.
*/
static void
madt_parse_nmi(MADT_NMI_SOURCE *nmi)
madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi)
{
void *ioapic;
u_int pin;
if (madt_find_interrupt(nmi->Interrupt, &ioapic, &pin) != 0) {
printf("MADT: Could not find APIC for vector %d\n",
nmi->Interrupt);
if (madt_find_interrupt(nmi->GlobalIrq, &ioapic, &pin) != 0) {
printf("MADT: Could not find APIC for vector %u\n",
nmi->GlobalIrq);
return;
}
ioapic_set_nmi(ioapic, pin);
if (nmi->TriggerMode != TRIGGER_CONFORMS)
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
ioapic_set_triggermode(ioapic, pin,
interrupt_trigger(nmi->TriggerMode, 0));
if (nmi->Polarity != TRIGGER_CONFORMS)
interrupt_trigger(nmi->IntiFlags, 0));
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
ioapic_set_polarity(ioapic, pin,
interrupt_polarity(nmi->Polarity, 0));
interrupt_polarity(nmi->IntiFlags, 0));
}
/*
* Parse an entry for an NMI routed to a local APIC LVT pin.
*/
static void
madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi)
{
u_int apic_id, pin;
@ -713,8 +715,8 @@ madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
apic_id = APIC_ID_ALL;
else if (madt_find_cpu(nmi->ProcessorId, &apic_id) != 0) {
if (bootverbose)
printf("MADT: Ignoring local NMI routed to ACPI CPU %u\n",
nmi->ProcessorId);
printf("MADT: Ignoring local NMI routed to "
"ACPI CPU %u\n", nmi->ProcessorId);
return;
}
if (nmi->Lint == 0)
@ -722,31 +724,31 @@ madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
else
pin = LVT_LINT1;
lapic_set_lvt_mode(apic_id, pin, APIC_LVT_DM_NMI);
if (nmi->TriggerMode != TRIGGER_CONFORMS)
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
lapic_set_lvt_triggermode(apic_id, pin,
interrupt_trigger(nmi->TriggerMode, 0));
if (nmi->Polarity != POLARITY_CONFORMS)
interrupt_trigger(nmi->IntiFlags, 0));
if (!(nmi->IntiFlags & ACPI_MADT_POLARITY_CONFORMS))
lapic_set_lvt_polarity(apic_id, pin,
interrupt_polarity(nmi->Polarity, 0));
interrupt_polarity(nmi->IntiFlags, 0));
}
/*
* Parse interrupt entries.
*/
static void
madt_parse_ints(APIC_HEADER *entry, void *arg __unused)
madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused)
{
switch (entry->Type) {
case APIC_XRUPT_OVERRIDE:
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
madt_parse_interrupt_override(
(MADT_INTERRUPT_OVERRIDE *)entry);
(ACPI_MADT_INTERRUPT_OVERRIDE *)entry);
break;
case APIC_NMI:
madt_parse_nmi((MADT_NMI_SOURCE *)entry);
case ACPI_MADT_TYPE_NMI_SOURCE:
madt_parse_nmi((ACPI_MADT_NMI_SOURCE *)entry);
break;
case APIC_LOCAL_NMI:
madt_parse_local_nmi((MADT_LOCAL_APIC_NMI *)entry);
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
madt_parse_local_nmi((ACPI_MADT_LOCAL_APIC_NMI *)entry);
break;
}
}
@ -767,7 +769,7 @@ madt_set_ids(void *dummy)
if (CPU_ABSENT(i))
continue;
pc = pcpu_find(i);
KASSERT(pc != NULL, ("no pcpu data for CPU %d", i));
KASSERT(pc != NULL, ("no pcpu data for CPU %u", i));
la = &lapics[pc->pc_apic_id];
if (!la->la_enabled)
panic("APIC: CPU with APIC ID %u is not enabled",

View File

@ -278,18 +278,10 @@ device tdfx # Enable 3Dfx Voodoo support
# defined when it is built).
#
# ACPI_NO_SEMAPHORES makes the AcpiOs*Semaphore routines a no-op.
#
# ACPICA_PEDANTIC enables strict checking of AML. Our default is to
# relax these checks to allow code generated by the Microsoft compiler
# to still execute.
#
# Note that building ACPI into the kernel is deprecated; the module is
# normally loaded automatically by the loader.
device acpi
options ACPI_DEBUG
#!options ACPI_NO_SEMAPHORES
#!options ACPICA_PEDANTIC
# The cpufreq(4) driver provides support for non-ACPI CPU frequency control
device cpufreq

View File

@ -34,7 +34,7 @@
*****************************************************************************/
#ifndef __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#ifdef _KERNEL
/*
@ -45,33 +45,35 @@
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
*/
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
/* Asm macros */
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_FLUSH_CPU_CACHE() wbinvd()
#define ACPI_FLUSH_CPU_CACHE() wbinvd()
/* Section 5.2.9.1: global lock acquire/release functions */
extern int acpi_acquire_global_lock(uint32_t *lock);
extern int acpi_release_global_lock(uint32_t *lock);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_acquire_global_lock(GLptr))
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_release_global_lock(GLptr))
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_acquire_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_release_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
#endif /* _KERNEL */
#define ACPI_MACHINE_WIDTH 64
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
#define ACPI_MACHINE_WIDTH 64
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
void acpi_SetDefaultIntrModel(int model);
void acpi_cpu_c1(void);

View File

@ -44,15 +44,15 @@ __FBSDID("$FreeBSD$");
* environment.
*/
static RSDP_DESCRIPTOR *biosacpi_find_rsdp(void);
static RSDP_DESCRIPTOR *biosacpi_search_rsdp(char *base, int length);
static ACPI_TABLE_RSDP *biosacpi_find_rsdp(void);
static ACPI_TABLE_RSDP *biosacpi_search_rsdp(char *base, int length);
#define RSDP_CHECKSUM_LENGTH 20
void
biosacpi_detect(void)
{
RSDP_DESCRIPTOR *rsdp;
ACPI_TABLE_RSDP *rsdp;
char buf[24];
int revision;
@ -63,6 +63,8 @@ biosacpi_detect(void)
return;
/* export values from the RSDP */
sprintf(buf, "%p", VTOP(rsdp));
setenv("hint.acpi.0.rsdp", buf, 1);
revision = rsdp->Revision;
if (revision == 0)
revision = 1;
@ -88,10 +90,10 @@ biosacpi_detect(void)
/*
* Find the RSDP in low memory. See section 5.2.2 of the ACPI spec.
*/
static RSDP_DESCRIPTOR *
static ACPI_TABLE_RSDP *
biosacpi_find_rsdp(void)
{
RSDP_DESCRIPTOR *rsdp;
ACPI_TABLE_RSDP *rsdp;
uint16_t *addr;
/* EBDA is the 1 KB addressed by the 16 bit pointer at 0x40E. */
@ -106,19 +108,19 @@ biosacpi_find_rsdp(void)
return (NULL);
}
static RSDP_DESCRIPTOR *
static ACPI_TABLE_RSDP *
biosacpi_search_rsdp(char *base, int length)
{
RSDP_DESCRIPTOR *rsdp;
ACPI_TABLE_RSDP *rsdp;
u_int8_t *cp, sum;
int ofs, idx;
/* search on 16-byte boundaries */
for (ofs = 0; ofs < length; ofs += 16) {
rsdp = (RSDP_DESCRIPTOR *)PTOV(base + ofs);
rsdp = (ACPI_TABLE_RSDP *)PTOV(base + ofs);
/* compare signature, validate checksum */
if (!strncmp(rsdp->Signature, RSDP_SIG, strlen(RSDP_SIG))) {
if (!strncmp(rsdp->Signature, ACPI_SIG_RSDP, strlen(ACPI_SIG_RSDP))) {
cp = (u_int8_t *)rsdp;
sum = 0;
for (idx = 0; idx < RSDP_CHECKSUM_LENGTH; idx++)

View File

@ -36,38 +36,38 @@ __FBSDID("$FreeBSD$");
typedef struct /* LOCAL SAPIC */
{
APIC_HEADER Header;
UINT8 ProcessorId; /* ACPI processor id */
UINT8 LocalSapicId; /* Processor local SAPIC id */
UINT8 LocalSapicEid; /* Processor local SAPIC eid */
UINT8 Reserved[3];
UINT32 ProcessorEnabled: 1;
UINT32 FlagsReserved: 31;
ACPI_SUBTABLE_HEADER Header;
UINT8 ProcessorId; /* ACPI processor id */
UINT8 LocalSapicId; /* Processor local SAPIC id */
UINT8 LocalSapicEid; /* Processor local SAPIC eid */
UINT8 Reserved[3];
UINT32 ProcessorEnabled: 1;
UINT32 FlagsReserved: 31;
} LOCAL_SAPIC;
typedef struct /* IO SAPIC */
{
APIC_HEADER Header;
UINT8 IoSapicId; /* I/O SAPIC ID */
UINT8 Reserved; /* reserved - must be zero */
UINT32 Vector; /* interrupt base */
UINT64 IoSapicAddress; /* SAPIC's physical address */
ACPI_SUBTABLE_HEADER Header;
UINT8 IoSapicId; /* I/O SAPIC ID */
UINT8 Reserved; /* reserved - must be zero */
UINT32 Vector; /* interrupt base */
UINT64 IoSapicAddress; /* SAPIC's physical address */
} IO_SAPIC;
/*
*/
struct {
MULTIPLE_APIC_TABLE Header;
MADT_LOCAL_SAPIC cpu0;
MADT_LOCAL_SAPIC cpu1;
MADT_LOCAL_SAPIC cpu2;
MADT_LOCAL_SAPIC cpu3;
MADT_IO_SAPIC sapic;
ACPI_TABLE_MADT MADT;
ACPI_MADT_LOCAL_SAPIC cpu0;
ACPI_MADT_LOCAL_SAPIC cpu1;
ACPI_MADT_LOCAL_SAPIC cpu2;
ACPI_MADT_LOCAL_SAPIC cpu3;
ACPI_MADT_IO_SAPIC sapic;
} apic = {
/* Header. */
{
APIC_SIG, /* Signature. */
ACPI_SIG_MADT, /* Signature. */
sizeof(apic), /* Length of table. */
0, /* ACPI minor revision. */
0, /* Checksum. */
@ -134,7 +134,7 @@ struct {
UINT64 apic_tbl;
} xsdt = {
{
XSDT_SIG, /* Signature. */
ACPI_SIG_XSDT, /* Signature. */
sizeof(xsdt), /* Length of table. */
0, /* ACPI minor revision. */
0, /* XXX checksum. */
@ -147,8 +147,8 @@ struct {
0UL /* XXX APIC table address. */
};
RSDP_DESCRIPTOR acpi_root = {
RSDP_SIG,
ACPI_TABLE_RSDP acpi_root = {
ACPI_SIG_RSDP,
0, /* XXX checksum. */
"FBSD",
2, /* ACPI Rev 2.0. */
@ -177,7 +177,7 @@ acpi_stub_init(void)
cksum(&acpi_root, 20, &acpi_root.Checksum);
cksum(&acpi_root, sizeof(acpi_root), &acpi_root.ExtendedChecksum);
cksum(&apic, sizeof(apic), &apic.Header.Checksum);
cksum(&apic, sizeof(apic), &apic.MADT.Header.Checksum);
xsdt.apic_tbl = (UINT32)&apic;
cksum(&xsdt, sizeof(xsdt), &xsdt.Header.Checksum);
}

View File

@ -226,17 +226,14 @@ contrib/dev/acpica/rsmemory.c optional acpi
contrib/dev/acpica/rsmisc.c optional acpi
contrib/dev/acpica/rsutils.c optional acpi
contrib/dev/acpica/rsxface.c optional acpi
contrib/dev/acpica/tbconvrt.c optional acpi
contrib/dev/acpica/tbget.c optional acpi
contrib/dev/acpica/tbgetall.c optional acpi
contrib/dev/acpica/tbfadt.c optional acpi
contrib/dev/acpica/tbfind.c optional acpi
contrib/dev/acpica/tbinstal.c optional acpi
contrib/dev/acpica/tbrsdt.c optional acpi
contrib/dev/acpica/tbutils.c optional acpi
contrib/dev/acpica/tbxface.c optional acpi
contrib/dev/acpica/tbxfroot.c optional acpi
contrib/dev/acpica/utalloc.c optional acpi
contrib/dev/acpica/utcache.c optional acpi \
compile-with "${NORMAL_C} -DACPI_USE_LOCAL_CACHE"
contrib/dev/acpica/utcache.c optional acpi
contrib/dev/acpica/utclib.c optional acpi
contrib/dev/acpica/utcopy.c optional acpi
contrib/dev/acpica/utdebug.c optional acpi
@ -248,6 +245,7 @@ contrib/dev/acpica/utmath.c optional acpi
contrib/dev/acpica/utmisc.c optional acpi
contrib/dev/acpica/utmutex.c optional acpi
contrib/dev/acpica/utobject.c optional acpi
contrib/dev/acpica/utresrc.c optional acpi
contrib/dev/acpica/utstate.c optional acpi
contrib/dev/acpica/utxface.c optional acpi
contrib/ipfilter/netinet/fil.c optional ipfilter inet \

View File

@ -649,7 +649,6 @@ WITNESS_SKIPSPIN opt_witness.h
ACPI_DEBUG opt_acpi.h
ACPI_MAX_THREADS opt_acpi.h
ACPI_NO_SEMAPHORES opt_acpi.h
ACPICA_PEDANTIC opt_acpi.h
# ISA support
DEV_ISA opt_isa.h

View File

@ -443,7 +443,7 @@ acpi_asus_probe(device_t dev)
ACPI_STATUS status;
ACPI_TABLE_HEADER th;
status = AcpiGetTableHeader(ACPI_TABLE_DSDT, 1, &th);
status = AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &th);
if (ACPI_FAILURE(status)) {
device_printf(dev, "Unsupported (Samsung?) laptop\n");
AcpiOsFree(Buf.Pointer);
@ -720,8 +720,7 @@ acpi_asus_led(struct acpi_asus_led *led, int state)
led->busy = 1;
led->state = state;
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
(void *)acpi_asus_led_task, led);
AcpiOsExecute(OSL_NOTIFY_HANDLER, (void *)acpi_asus_led_task, led);
}
static int

View File

@ -320,7 +320,7 @@ acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context)
switch (notify) {
case ACPI_NOTIFY_STATUS_CHANGED:
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
AcpiOsExecute(OSL_NOTIFY_HANDLER,
acpi_fujitsu_notify_status_changed, sc);
break;
default:

View File

@ -300,8 +300,7 @@ ibm_led(void *softc, int onoff)
sc->led_busy = 1;
sc->led_state = onoff;
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
(void *)ibm_led_task, sc);
AcpiOsExecute(OSL_NOTIFY_HANDLER, (void *)ibm_led_task, sc);
}
static void

View File

@ -62,14 +62,6 @@ AcpiOsGetLine(char *Buffer)
#endif /* DDB */
}
void
AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber,
char *Message)
{
printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
printf("ACPI: assertion %s\n", (char *)FailedAssertion);
}
ACPI_STATUS
AcpiOsSignal(UINT32 Function, void *Info)
{

View File

@ -54,14 +54,10 @@ AcpiOsFree(void *Memory)
free(Memory, M_ACPICA);
}
ACPI_STATUS
AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
void **LogicalAddress)
void *
AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_NATIVE_UINT Length)
{
*LogicalAddress = pmap_mapbios((vm_offset_t)PhysicalAddress, Length);
if (*LogicalAddress == NULL)
return (AE_BAD_ADDRESS);
return (AE_OK);
return (pmap_mapbios((vm_offset_t)PhysicalAddress, Length));
}
void
@ -78,10 +74,23 @@ AcpiOsGetPhysicalAddress(void *LogicalAddress,
return (AE_BAD_ADDRESS);
}
ACPI_STATUS
AcpiOsValidateInterface (char *Interface)
{
return (AE_SUPPORT);
}
/*
* There is no clean way to do this. We make the charitable assumption
* that callers will not pass garbage to us.
*/
ACPI_STATUS
AcpiOsValidateAddress (UINT8 SpaceId, ACPI_PHYSICAL_ADDRESS Address,
ACPI_SIZE Length)
{
return (AE_OK);
}
BOOLEAN
AcpiOsReadable (void *Pointer, ACPI_SIZE Length)
{
@ -99,7 +108,8 @@ AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 *Value, UINT32 Width)
{
void *LogicalAddress;
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
if (LogicalAddress == NULL)
return (AE_NOT_EXIST);
switch (Width) {
@ -130,7 +140,8 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width)
{
void *LogicalAddress;
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
if (LogicalAddress == NULL)
return (AE_NOT_EXIST);
switch (Width) {

View File

@ -87,7 +87,7 @@ acpi_task_execute(void *context, int pending)
* We allocate and queue a task for one of our taskqueue threads to process.
*/
ACPI_STATUS
AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
void *Context)
{
struct acpi_task_ctx *at;
@ -104,18 +104,20 @@ AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
at->at_function = Function;
at->at_context = Context;
switch (Priority) {
case OSD_PRIORITY_GPE:
pri = 4;
switch (Type) {
case OSL_GPE_HANDLER:
pri = 10;
break;
case OSD_PRIORITY_HIGH:
case OSL_GLOBAL_LOCK_HANDLER:
case OSL_EC_POLL_HANDLER:
case OSL_EC_BURST_HANDLER:
pri = 5;
break;
case OSL_NOTIFY_HANDLER:
pri = 3;
break;
case OSD_PRIORITY_MED:
pri = 2;
break;
case OSD_PRIORITY_LO:
pri = 1;
case OSL_DEBUGGER_THREAD:
pri = 0;
break;
default:
free(at, M_ACPITASK);
@ -178,7 +180,7 @@ AcpiOsStall(UINT32 Microseconds)
return_VOID;
}
UINT32
ACPI_THREAD_ID
AcpiOsGetThreadId(void)
{
struct proc *p;

View File

@ -62,10 +62,12 @@ struct acpi_semaphore {
UINT32 as_timeouts;
};
/* Default number of maximum pending threads. */
#ifndef ACPI_NO_SEMAPHORES
#ifndef ACPI_SEMAPHORES_MAX_PENDING
#define ACPI_SEMAPHORES_MAX_PENDING 4
#endif
static int acpi_semaphore_debug = 0;
TUNABLE_INT("debug.acpi_semaphore_debug", &acpi_semaphore_debug);
SYSCTL_DECL(_debug_acpi);
@ -195,7 +197,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout)
break;
}
/* limit number of pending treads */
/* limit number of pending threads */
if (as->as_pendings >= ACPI_SEMAPHORES_MAX_PENDING) {
result = AE_TIME;
break;

View File

@ -40,26 +40,22 @@ __FBSDID("$FreeBSD$");
#include <contrib/dev/acpica/actables.h>
#undef _COMPONENT
#define _COMPONENT ACPI_TABLES
#define _COMPONENT ACPI_TABLES
static char acpi_osname[128];
TUNABLE_STR("hw.acpi.osname", acpi_osname, sizeof(acpi_osname));
static struct {
ACPI_TABLE_HEADER_DEF
uint32_t no_op;
} __packed fake_ssdt;
ACPI_STATUS
AcpiOsPredefinedOverride (
const ACPI_PREDEFINED_NAMES *InitVal,
ACPI_STRING *NewVal)
AcpiOsPredefinedOverride(const ACPI_PREDEFINED_NAMES *InitVal,
ACPI_STRING *NewVal)
{
if (InitVal == NULL || NewVal == NULL)
return (AE_BAD_PARAMETER);
*NewVal = NULL;
if (strncmp(InitVal->Name, "_OS_", 4) == 0 && strlen(acpi_osname) > 0) {
if (strncmp(InitVal->Name, "_OS_", ACPI_NAME_SIZE) == 0 &&
strlen(acpi_osname) > 0) {
printf("ACPI: Overriding _OS definition with \"%s\"\n", acpi_osname);
*NewVal = acpi_osname;
}
@ -68,9 +64,8 @@ AcpiOsPredefinedOverride (
}
ACPI_STATUS
AcpiOsTableOverride (
ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable)
AcpiOsTableOverride(ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable)
{
caddr_t acpi_dsdt, p;
@ -78,37 +73,11 @@ AcpiOsTableOverride (
return (AE_BAD_PARAMETER);
/* If we're not overriding the DSDT, just return. */
*NewTable = NULL;
if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) == NULL)
return (AE_OK);
if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) == NULL)
return (AE_OK);
/*
* Override the DSDT with the user's custom version. Override the
* contents of any SSDTs with a simple no-op table since the user's
* DSDT is expected to contain their contents as well.
*/
if (strncmp(ExistingTable->Signature, "DSDT", 4) == 0) {
printf("ACPI: overriding DSDT/SSDT with custom table\n");
*NewTable = *(void **)p;
} else if (strncmp(ExistingTable->Signature, "SSDT", 4) == 0) {
if (fake_ssdt.Length == 0) {
sprintf(fake_ssdt.Signature, "%.4s", "SSDT");
fake_ssdt.Length = htole32(sizeof(fake_ssdt));
fake_ssdt.Revision = 2;
fake_ssdt.Checksum = 0;
sprintf(fake_ssdt.OemId, "%.6s", "FBSD ");
sprintf(fake_ssdt.OemTableId, "%.8s", "NullSSDT");
fake_ssdt.OemRevision = htole32(1);
sprintf(fake_ssdt.AslCompilerId, "%.4s", "FBSD");
fake_ssdt.AslCompilerRevision = htole32(1);
fake_ssdt.no_op = htole32(0x005c0310); /* Scope(\) */
fake_ssdt.Checksum -= AcpiTbGenerateChecksum(&fake_ssdt,
sizeof(fake_ssdt));
}
*NewTable = (void *)&fake_ssdt;
}
if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) == NULL ||
(p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) == NULL) {
*NewTable = NULL;
} else
*NewTable = *(ACPI_TABLE_HEADER **)p;
return (AE_OK);
}

View File

@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pci_private.h>
#include <vm/vm_param.h>
MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices");
/* Hooks for the ACPI CA debugging infrastructure */
@ -273,39 +275,28 @@ ACPI_STATUS
acpi_Startup(void)
{
static int started = 0;
int error, val;
ACPI_STATUS status;
int val;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/* Only run the startup code once. The MADT driver also calls this. */
if (started)
return_VALUE (0);
return_VALUE (AE_OK);
started = 1;
/* Initialise the ACPI mutex */
mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
/*
* Set the globals from our tunables. This is needed because ACPI-CA
* uses UINT8 for some values and we have no tunable_byte.
* Pre-allocate space for RSDT/XSDT and DSDT tables and allow resizing
* if more tables exist.
*/
AcpiGbl_AllMethodsSerialized = acpi_serialize_methods;
AcpiGbl_EnableInterpreterSlack = TRUE;
/* Start up the ACPI CA subsystem. */
if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) {
printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error));
return_VALUE (error);
}
if (ACPI_FAILURE(error = AcpiLoadTables())) {
printf("ACPI: table load failed: %s\n", AcpiFormatException(error));
AcpiTerminate();
return_VALUE (error);
if (ACPI_FAILURE(status = AcpiInitializeTables(NULL, 2, TRUE))) {
printf("ACPI: Table initialisation failed: %s\n",
AcpiFormatException(status));
return_VALUE (status);
}
/* Set up any quirks we have for this system. */
if (acpi_quirks == 0)
if (acpi_quirks == ACPI_Q_OK)
acpi_table_quirks(&acpi_quirks);
/* If the user manually set the disabled hint to 0, force-enable ACPI. */
@ -313,11 +304,10 @@ acpi_Startup(void)
acpi_quirks &= ~ACPI_Q_BROKEN;
if (acpi_quirks & ACPI_Q_BROKEN) {
printf("ACPI disabled by blacklist. Contact your BIOS vendor.\n");
AcpiTerminate();
return_VALUE (AE_ERROR);
status = AE_SUPPORT;
}
return_VALUE (AE_OK);
return_VALUE (status);
}
/*
@ -341,9 +331,11 @@ acpi_identify(driver_t *driver, device_t parent)
if (device_find_child(parent, "acpi", 0) != NULL)
return_VOID;
/* Initialize ACPI-CA. */
if (ACPI_FAILURE(acpi_Startup()))
/* Initialize root tables. */
if (ACPI_FAILURE(acpi_Startup())) {
printf("ACPI: Try disabling either ACPI or apic support.\n");
return_VOID;
}
snprintf(acpi_ca_version, sizeof(acpi_ca_version), "%x", ACPI_CA_VERSION);
@ -360,11 +352,11 @@ acpi_identify(driver_t *driver, device_t parent)
static int
acpi_probe(device_t dev)
{
ACPI_TABLE_HEADER th;
char buf[20];
int error;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_HEADER *rsdt;
ACPI_PHYSICAL_ADDRESS paddr;
char buf[ACPI_OEM_ID_SIZE + ACPI_OEM_TABLE_ID_SIZE + 2];
struct sbuf sb;
ACPI_STATUS status;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@ -374,30 +366,36 @@ acpi_probe(device_t dev)
return_VALUE (ENXIO);
}
if (ACPI_FAILURE(status = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th))) {
device_printf(dev, "couldn't get XSDT header: %s\n",
AcpiFormatException(status));
error = ENXIO;
} else {
sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
sbuf_bcat(&sb, th.OemId, 6);
sbuf_trim(&sb);
sbuf_putc(&sb, ' ');
sbuf_bcat(&sb, th.OemTableId, 8);
sbuf_trim(&sb);
sbuf_finish(&sb);
device_set_desc_copy(dev, sbuf_data(&sb));
sbuf_delete(&sb);
error = 0;
}
if ((paddr = AcpiOsGetRootPointer()) == 0 ||
(rsdp = AcpiOsMapMemory(paddr, sizeof(ACPI_TABLE_RSDP))) == NULL)
return_VALUE (ENXIO);
if (rsdp->Revision > 1 && rsdp->XsdtPhysicalAddress != 0)
paddr = (ACPI_PHYSICAL_ADDRESS)rsdp->XsdtPhysicalAddress;
else
paddr = (ACPI_PHYSICAL_ADDRESS)rsdp->RsdtPhysicalAddress;
AcpiOsUnmapMemory(rsdp, sizeof(ACPI_TABLE_RSDP));
return_VALUE (error);
if ((rsdt = AcpiOsMapMemory(paddr, sizeof(ACPI_TABLE_HEADER))) == NULL)
return_VALUE (ENXIO);
sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
sbuf_bcat(&sb, rsdt->OemId, ACPI_OEM_ID_SIZE);
sbuf_trim(&sb);
sbuf_putc(&sb, ' ');
sbuf_bcat(&sb, rsdt->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
sbuf_trim(&sb);
sbuf_finish(&sb);
device_set_desc_copy(dev, sbuf_data(&sb));
sbuf_delete(&sb);
AcpiOsUnmapMemory(rsdt, sizeof(ACPI_TABLE_HEADER));
return_VALUE (0);
}
static int
acpi_attach(device_t dev)
{
struct acpi_softc *sc;
ACPI_TABLE_FACS *facs;
ACPI_STATUS status;
int error, state;
UINT32 flags;
@ -409,6 +407,8 @@ acpi_attach(device_t dev)
sc = device_get_softc(dev);
sc->acpi_dev = dev;
error = ENXIO;
/* Initialize resource manager. */
acpi_rman_io.rm_type = RMAN_ARRAY;
acpi_rman_io.rm_start = 0;
@ -423,8 +423,33 @@ acpi_attach(device_t dev)
if (rman_init(&acpi_rman_mem) != 0)
panic("acpi rman_init memory failed");
/* Initialise the ACPI mutex */
mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
/*
* Set the globals from our tunables. This is needed because ACPI-CA
* uses UINT8 for some values and we have no tunable_byte.
*/
AcpiGbl_AllMethodsSerialized = acpi_serialize_methods;
AcpiGbl_EnableInterpreterSlack = TRUE;
/* Start up the ACPI CA subsystem. */
status = AcpiInitializeSubsystem();
if (ACPI_FAILURE(status)) {
device_printf(dev, "Could not initialize Subsystem: %s\n",
AcpiFormatException(status));
goto out;
}
/* Load ACPI name space. */
status = AcpiLoadTables();
if (ACPI_FAILURE(status)) {
device_printf(dev, "Could not load Namespace: %s\n",
AcpiFormatException(status));
goto out;
}
/* Install the default address space handlers. */
error = ENXIO;
status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(status)) {
@ -541,7 +566,14 @@ acpi_attach(device_t dev)
}
/* Only enable S4BIOS by default if the FACS says it is available. */
if (AcpiGbl_FACS->S4Bios_f != 0)
status = AcpiGetTable(ACPI_SIG_FACS, 0, (ACPI_TABLE_HEADER **)&facs);
if (ACPI_FAILURE(status)) {
device_printf(dev, "couldn't get FACS: %s\n",
AcpiFormatException(status));
error = ENXIO;
goto out;
}
if (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT)
sc->acpi_s4bios = 1;
/*
@ -1103,7 +1135,7 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas,
return (EINVAL);
/* We only support memory and IO spaces. */
switch (gas->AddressSpaceId) {
switch (gas->SpaceId) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
res_type = SYS_RES_MEMORY;
break;
@ -1118,15 +1150,15 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas,
* If the register width is less than 8, assume the BIOS author means
* it is a bit field and just allocate a byte.
*/
if (gas->RegisterBitWidth && gas->RegisterBitWidth < 8)
gas->RegisterBitWidth = 8;
if (gas->BitWidth && gas->BitWidth < 8)
gas->BitWidth = 8;
/* Validate the address after we're sure we support the space. */
if (!ACPI_VALID_ADDRESS(gas->Address) || gas->RegisterBitWidth == 0)
if (gas->Address == 0 || gas->BitWidth == 0)
return (EINVAL);
bus_set_resource(dev, res_type, *rid, gas->Address,
gas->RegisterBitWidth / 8);
gas->BitWidth / 8);
*res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE | flags);
if (*res != NULL) {
*type = res_type;
@ -1645,12 +1677,13 @@ acpi_shutdown_final(void *arg, int howto)
DELAY(1000000);
printf("ACPI power-off failed - timeout\n");
}
} else if ((howto & RB_HALT) == 0 && AcpiGbl_FADT->ResetRegSup &&
} else if ((howto & RB_HALT) == 0 &&
(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) &&
sc->acpi_handle_reboot) {
/* Reboot using the reset register. */
status = AcpiHwLowLevelWrite(
AcpiGbl_FADT->ResetRegister.RegisterBitWidth,
AcpiGbl_FADT->ResetValue, &AcpiGbl_FADT->ResetRegister);
AcpiGbl_FADT.ResetRegister.BitWidth,
AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister);
if (ACPI_FAILURE(status)) {
printf("ACPI reset failed - %s\n", AcpiFormatException(status));
} else {
@ -1673,14 +1706,14 @@ acpi_enable_fixed_events(struct acpi_softc *sc)
static int first_time = 1;
/* Enable and clear fixed events and install handlers. */
if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->PwrButton == 0) {
if ((AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) == 0) {
AcpiClearEvent(ACPI_EVENT_POWER_BUTTON);
AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON,
acpi_event_power_button_sleep, sc);
if (first_time)
device_printf(sc->acpi_dev, "Power Button (fixed)\n");
}
if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->SleepButton == 0) {
if ((AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON);
AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON,
acpi_event_sleep_button_sleep, sc);
@ -1832,10 +1865,10 @@ acpi_TimerDelta(uint32_t end, uint32_t start)
if (end >= start)
delta = end - start;
else if (AcpiGbl_FADT->TmrValExt == 0)
delta = ((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF;
else
else if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
delta = ((0xFFFFFFFF - start) + end + 1);
else
delta = ((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF;
return (delta);
}
@ -2252,13 +2285,11 @@ int
acpi_wake_set_enable(device_t dev, int enable)
{
struct acpi_prw_data prw;
ACPI_HANDLE handle;
ACPI_STATUS status;
int flags;
/* Make sure the device supports waking the system and get the GPE. */
handle = acpi_get_handle(dev);
if (acpi_parse_prw(handle, &prw) != 0)
if (acpi_parse_prw(acpi_get_handle(dev), &prw) != 0)
return (ENXIO);
flags = acpi_get_flags(dev);

View File

@ -128,7 +128,7 @@ acpi_acad_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
case ACPI_NOTIFY_DEVICE_CHECK:
case ACPI_POWERSOURCE_STAT_CHANGE:
/* Temporarily. It is better to notify policy manager */
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_get_status, context);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_acad_get_status, context);
break;
default:
device_printf(dev, "unknown notify %#x\n", notify);
@ -181,7 +181,7 @@ acpi_acad_attach(device_t dev)
*/
AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
acpi_acad_notify_handler, dev);
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_init_acline, dev);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_acad_init_acline, dev);
return (0);
}

View File

@ -248,12 +248,10 @@ acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
sc = (struct acpi_button_softc *)context;
switch (notify) {
case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP:
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
acpi_button_notify_sleep, sc);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_button_notify_sleep, sc);
break;
case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP:
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
acpi_button_notify_wakeup, sc);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_button_notify_wakeup, sc);
break;
default:
device_printf(sc->button_dev, "unknown notify %#x\n", notify);

View File

@ -149,7 +149,7 @@ acpi_cmbat_attach(device_t dev)
AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
acpi_cmbat_notify_handler, dev);
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
return (0);
}
@ -169,7 +169,7 @@ static int
acpi_cmbat_resume(device_t dev)
{
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
return (0);
}
@ -197,7 +197,7 @@ acpi_cmbat_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
* Queue a callback to get the current battery info from thread
* context. It's not safe to block in a notify handler.
*/
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_get_bif_task, dev);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_get_bif_task, dev);
break;
}

View File

@ -275,8 +275,8 @@ acpi_cpu_attach(device_t dev)
pcpu_data = pcpu_find(cpu_id);
pcpu_data->pc_device = dev;
sc->cpu_pcpu = pcpu_data;
cpu_smi_cmd = AcpiGbl_FADT->SmiCmd;
cpu_cst_cnt = AcpiGbl_FADT->CstCnt;
cpu_smi_cmd = AcpiGbl_FADT.SmiCommand;
cpu_cst_cnt = AcpiGbl_FADT.CstControl;
buf.Pointer = NULL;
buf.Length = ACPI_ALLOCATE_BUFFER;
@ -310,7 +310,7 @@ acpi_cpu_attach(device_t dev)
CTLFLAG_RD, 0, "node for CPU children");
/* Queue post cpu-probing task handler */
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cpu_startup, NULL);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cpu_startup, NULL);
}
/*
@ -518,16 +518,16 @@ acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc)
return;
/* Validate and allocate resources for C2 (P_LVL2). */
gas.AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
gas.RegisterBitWidth = 8;
if (AcpiGbl_FADT->Plvl2Lat <= 100) {
gas.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
gas.BitWidth = 8;
if (AcpiGbl_FADT.C2Latency <= 100) {
gas.Address = sc->cpu_p_blk + 4;
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &sc->cpu_rid,
&gas, &cx_ptr->p_lvlx, RF_SHAREABLE);
if (cx_ptr->p_lvlx != NULL) {
sc->cpu_rid++;
cx_ptr->type = ACPI_STATE_C2;
cx_ptr->trans_lat = AcpiGbl_FADT->Plvl2Lat;
cx_ptr->trans_lat = AcpiGbl_FADT.C2Latency;
cx_ptr++;
sc->cpu_cx_count++;
}
@ -536,14 +536,14 @@ acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc)
return;
/* Validate and allocate resources for C3 (P_LVL3). */
if (AcpiGbl_FADT->Plvl3Lat <= 1000) {
if (AcpiGbl_FADT.C3Latency <= 1000) {
gas.Address = sc->cpu_p_blk + 5;
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &sc->cpu_rid, &gas,
&cx_ptr->p_lvlx, RF_SHAREABLE);
if (cx_ptr->p_lvlx != NULL) {
sc->cpu_rid++;
cx_ptr->type = ACPI_STATE_C3;
cx_ptr->trans_lat = AcpiGbl_FADT->Plvl3Lat;
cx_ptr->trans_lat = AcpiGbl_FADT.C3Latency;
cx_ptr++;
sc->cpu_cx_count++;
}
@ -863,11 +863,9 @@ acpi_cpu_idle()
* time if USB is loaded.
*/
if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
AcpiGetRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active,
ACPI_MTX_DO_NOT_LOCK);
AcpiGetRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active);
if (bm_active != 0) {
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1,
ACPI_MTX_DO_NOT_LOCK);
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1);
cx_next_idx = min(cx_next_idx, sc->cpu_non_c3);
}
}
@ -894,9 +892,8 @@ acpi_cpu_idle()
*/
if (cx_next->type == ACPI_STATE_C3) {
if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 1,
ACPI_MTX_DO_NOT_LOCK);
AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 1);
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
} else
ACPI_FLUSH_CPU_CACHE();
}
@ -907,7 +904,7 @@ acpi_cpu_idle()
* get the time very close to the CPU start/stop clock logic, this
* is the only reliable time source.
*/
AcpiHwLowLevelRead(32, &start_time, &AcpiGbl_FADT->XPmTmrBlk);
AcpiHwLowLevelRead(32, &start_time, &AcpiGbl_FADT.XPmTimerBlock);
CPU_GET_REG(cx_next->p_lvlx, 1);
/*
@ -916,14 +913,14 @@ acpi_cpu_idle()
* the processor has stopped. Doing it again provides enough
* margin that we are certain to have a correct value.
*/
AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT->XPmTmrBlk);
AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT->XPmTmrBlk);
AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
/* Enable bus master arbitration and disable bus master wakeup. */
if (cx_next->type == ACPI_STATE_C3 &&
(cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 0);
AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
}
ACPI_ENABLE_IRQS();
@ -962,8 +959,10 @@ acpi_cpu_quirks(void)
* instruction is present, flush the caches before entering C3 instead.
* Otherwise, just disable C3 completely.
*/
if (AcpiGbl_FADT->V1_Pm2CntBlk == 0 || AcpiGbl_FADT->Pm2CntLen == 0) {
if (AcpiGbl_FADT->WbInvd && AcpiGbl_FADT->WbInvdFlush == 0) {
if (AcpiGbl_FADT.Pm2ControlBlock == 0 ||
AcpiGbl_FADT.Pm2ControlLength == 0) {
if ((AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD) &&
(AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD_FLUSH) == 0) {
cpu_quirks |= CPU_QUIRK_NO_BM_CTRL;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"acpi_cpu: no BM control, using flush cache method\n"));

View File

@ -238,7 +238,7 @@ acpi_dock_insert_child(ACPI_HANDLE handle, UINT32 level, void *context,
goto out;
}
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_dock_attach_later, dev);
out:
return (AE_OK);

View File

@ -227,16 +227,6 @@ typedef UINT8 EC_EVENT;
#define EC_SET_CSR(sc, v) \
bus_space_write_1((sc)->ec_csr_tag, (sc)->ec_csr_handle, 0, (v))
/* Embedded Controller Boot Resources Table (ECDT) */
typedef struct {
ACPI_TABLE_HEADER header;
ACPI_GENERIC_ADDRESS control;
ACPI_GENERIC_ADDRESS data;
UINT32 uid;
UINT8 gpe_bit;
char ec_id[0];
} ACPI_TABLE_ECDT;
/* Additional params to pass from the probe routine */
struct acpi_ec_params {
int glk;
@ -408,7 +398,6 @@ void
acpi_ec_ecdt_probe(device_t parent)
{
ACPI_TABLE_ECDT *ecdt;
ACPI_TABLE_HEADER *hdr;
ACPI_STATUS status;
device_t child;
ACPI_HANDLE h;
@ -417,23 +406,22 @@ acpi_ec_ecdt_probe(device_t parent)
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/* Find and validate the ECDT. */
status = AcpiGetFirmwareTable("ECDT", 1, ACPI_LOGICAL_ADDRESSING, &hdr);
ecdt = (ACPI_TABLE_ECDT *)hdr;
status = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt);
if (ACPI_FAILURE(status) ||
ecdt->control.RegisterBitWidth != 8 ||
ecdt->data.RegisterBitWidth != 8) {
ecdt->Control.BitWidth != 8 ||
ecdt->Data.BitWidth != 8) {
return;
}
/* Create the child device with the given unit number. */
child = BUS_ADD_CHILD(parent, 0, "acpi_ec", ecdt->uid);
child = BUS_ADD_CHILD(parent, 0, "acpi_ec", ecdt->Uid);
if (child == NULL) {
printf("%s: can't add child\n", __func__);
return;
}
/* Find and save the ACPI handle for this device. */
status = AcpiGetHandle(NULL, ecdt->ec_id, &h);
status = AcpiGetHandle(NULL, ecdt->Id, &h);
if (ACPI_FAILURE(status)) {
device_delete_child(parent, child);
printf("%s: can't get handle\n", __func__);
@ -442,9 +430,9 @@ acpi_ec_ecdt_probe(device_t parent)
acpi_set_handle(child, h);
/* Set the data and CSR register addresses. */
bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->data.Address,
bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->Data.Address,
/*count*/1);
bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->control.Address,
bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->Control.Address,
/*count*/1);
/*
@ -456,8 +444,8 @@ acpi_ec_ecdt_probe(device_t parent)
*/
params = malloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO);
params->gpe_handle = NULL;
params->gpe_bit = ecdt->gpe_bit;
params->uid = ecdt->uid;
params->gpe_bit = ecdt->Gpe;
params->uid = ecdt->Uid;
acpi_GetInteger(h, "_GLK", &params->glk);
acpi_set_private(child, params);
acpi_set_magic(child, (int)&acpi_ec_devclass);
@ -830,8 +818,7 @@ EcGpeHandler(void *Context)
} else if (!sc->ec_sci_pend) {
/* SCI bit set and no pending query handler, so schedule one. */
CTR0(KTR_ACPI, "ec queueing gpe handler");
Status = AcpiOsQueueForExecution(OSD_PRIORITY_GPE, EcGpeQueryHandler,
Context);
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
if (ACPI_SUCCESS(Status)) {
sc->ec_sci_pend = TRUE;
query_pend = TRUE;

View File

@ -184,8 +184,8 @@ acpi_lid_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
sc = (struct acpi_lid_softc *)context;
switch (notify) {
case ACPI_NOTIFY_STATUS_CHANGED:
AcpiOsQueueForExecution(OSD_PRIORITY_LO,
acpi_lid_notify_status_changed, sc);
AcpiOsExecute(OSL_NOTIFY_HANDLER,
acpi_lid_notify_status_changed, sc);
break;
default:
device_printf(sc->lid_dev, "unknown notify %#x\n", notify);

View File

@ -384,7 +384,7 @@ link_valid_irq(struct link *link, int irq)
* For links routed via an ISA interrupt, if the SCI is routed via
* an ISA interrupt, the SCI is always treated as a valid IRQ.
*/
if (link->l_isa_irq && AcpiGbl_FADT->SciInt == irq &&
if (link->l_isa_irq && AcpiGbl_FADT.SciInterrupt == irq &&
irq < NUM_ISA_INTERRUPTS)
return (TRUE);
@ -1002,7 +1002,7 @@ acpi_pci_link_choose_irq(device_t dev, struct link *link)
* interrupt as a fallback.
*/
if (link->l_isa_irq) {
pos_irq = AcpiGbl_FADT->SciInt;
pos_irq = AcpiGbl_FADT.SciInterrupt;
pos_weight = pci_link_interrupt_weights[pos_irq];
if (pos_weight < best_weight) {
best_weight = pos_weight;
@ -1079,8 +1079,8 @@ acpi_pci_link_identify(driver_t *driver, device_t parent)
* if we are using the APIC, we also shouldn't be having any PCI
* interrupts routed via ISA IRQs, so this is probably ok.
*/
if (AcpiGbl_FADT->SciInt < NUM_ISA_INTERRUPTS)
pci_link_bios_isa_irqs |= (1 << AcpiGbl_FADT->SciInt);
if (AcpiGbl_FADT.SciInterrupt < NUM_ISA_INTERRUPTS)
pci_link_bios_isa_irqs |= (1 << AcpiGbl_FADT.SciInterrupt);
}
static device_method_t acpi_pci_link_methods[] = {

View File

@ -221,7 +221,7 @@ acpi_perf_attach(device_t dev)
sc->px_curr_state = CPUFREQ_VAL_UNKNOWN;
if (acpi_perf_evaluate(dev) != 0)
return (ENXIO);
AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_px_startup, NULL);
AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_px_startup, NULL);
if (!sc->info_only)
cpufreq_register(dev);
@ -393,10 +393,10 @@ acpi_px_startup(void *arg)
{
/* Signal to the platform that we are taking over CPU control. */
if (AcpiGbl_FADT->PstateCnt == 0)
if (AcpiGbl_FADT.PstateControl == 0)
return;
ACPI_LOCK(acpi);
AcpiOsWritePort(AcpiGbl_FADT->SmiCmd, AcpiGbl_FADT->PstateCnt, 8);
AcpiOsWritePort(AcpiGbl_FADT.SmiCommand, AcpiGbl_FADT.PstateControl, 8);
ACPI_UNLOCK(acpi);
}

View File

@ -47,10 +47,8 @@ enum val_t {
CREATOR_REV,
};
#define ACPI_TABLE_END (ACPI_TABLE_MAX + 1)
struct acpi_q_rule {
int sig; /* Table signature to match */
char sig[ACPI_NAME_SIZE]; /* Table signature to match */
enum val_t val;
union {
char *id;
@ -141,33 +139,35 @@ acpi_table_quirks(int *quirks)
{
const struct acpi_q_entry *entry;
const struct acpi_q_rule *match;
ACPI_TABLE_HEADER *hdr;
ACPI_TABLE_HEADER fadt, dsdt, xsdt, *hdr;
int done;
/* First, allow the machdep system to set its idea of quirks. */
KASSERT(quirks != NULL, ("acpi quirks ptr is NULL"));
acpi_machdep_quirks(quirks);
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_FADT, 0, &fadt)))
bzero(&fadt, sizeof(fadt));
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &dsdt)))
bzero(&fadt, sizeof(dsdt));
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_XSDT, 0, &xsdt)))
bzero(&fadt, sizeof(xsdt));
/* Then, override the quirks with any matched from table signatures. */
for (entry = acpi_quirks_table; entry->match; entry++) {
done = TRUE;
for (match = entry->match; match->sig != ACPI_TABLE_END; match++) {
switch (match->sig) {
case ACPI_TABLE_FADT:
hdr = (ACPI_TABLE_HEADER *)AcpiGbl_FADT;
break;
case ACPI_TABLE_DSDT:
hdr = (ACPI_TABLE_HEADER *)AcpiGbl_DSDT;
break;
case ACPI_TABLE_XSDT:
hdr = (ACPI_TABLE_HEADER *)AcpiGbl_XSDT;
break;
default:
for (match = entry->match; match->sig[0] != '\0'; match++) {
if (!strncmp(match->sig, "FADT", ACPI_NAME_SIZE))
hdr = &fadt;
else if (!strncmp(match->sig, ACPI_SIG_DSDT, ACPI_NAME_SIZE))
hdr = &dsdt;
else if (!strncmp(match->sig, ACPI_SIG_XSDT, ACPI_NAME_SIZE))
hdr = &xsdt;
else
panic("invalid quirk header\n");
}
/* If we don't match any, skip to the next entry. */
if (!aq_match_header(hdr, match)) {
if (aq_match_header(hdr, match) == FALSE) {
done = FALSE;
break;
}

View File

@ -169,7 +169,7 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
/* Fetch the device's current resources. */
buf.Length = ACPI_ALLOCATE_BUFFER;
if (ACPI_FAILURE((status = AcpiGetCurrentResources(handle, &buf)))) {
if (status != AE_NOT_FOUND)
if (status != AE_NOT_FOUND && status != AE_TYPE)
printf("can't fetch resources for %s - %s\n",
acpi_name(handle), AcpiFormatException(status));
return_ACPI_STATUS (status);

View File

@ -141,7 +141,7 @@ acpi_throttle_identify(driver_t *driver, device_t parent)
handle = acpi_get_handle(parent);
if (handle == NULL)
return;
if (AcpiGbl_FADT->DutyWidth == 0 ||
if (AcpiGbl_FADT.DutyWidth == 0 ||
acpi_get_type(parent) != ACPI_TYPE_PROCESSOR)
return;
@ -242,8 +242,8 @@ acpi_throttle_evaluate(struct acpi_throttle_softc *sc)
/* Get throttling parameters from the FADT. 0 means not supported. */
if (device_get_unit(sc->cpu_dev) == 0) {
cpu_duty_offset = AcpiGbl_FADT->DutyOffset;
cpu_duty_width = AcpiGbl_FADT->DutyWidth;
cpu_duty_offset = AcpiGbl_FADT.DutyOffset;
cpu_duty_width = AcpiGbl_FADT.DutyWidth;
}
if (cpu_duty_width == 0 || (thr_quirks & CPU_QUIRK_NO_THROTTLE) != 0)
return (ENXIO);
@ -295,8 +295,8 @@ acpi_throttle_evaluate(struct acpi_throttle_softc *sc)
if (sc->cpu_p_blk_len < 4)
return (ENXIO);
gas.Address = sc->cpu_p_blk;
gas.AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
gas.RegisterBitWidth = 32;
gas.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
gas.BitWidth = 32;
acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, &thr_rid,
&gas, &sc->cpu_p_cnt, 0);
if (sc->cpu_p_cnt != NULL) {

View File

@ -119,7 +119,7 @@ acpi_timer_identify(driver_t *driver, device_t parent)
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) ||
AcpiGbl_FADT == NULL || acpi_timer_dev)
acpi_timer_dev)
return_VOID;
if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
@ -129,10 +129,10 @@ acpi_timer_identify(driver_t *driver, device_t parent)
acpi_timer_dev = dev;
rid = 0;
rtype = AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId ?
rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ?
SYS_RES_IOPORT : SYS_RES_MEMORY;
rlen = AcpiGbl_FADT->PmTmLen;
rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
rlen = AcpiGbl_FADT.PmTimerLength;
rstart = AcpiGbl_FADT.XPmTimerBlock.Address;
if (bus_set_resource(dev, rtype, rid, rstart, rlen))
device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n",
(rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen);
@ -151,18 +151,18 @@ acpi_timer_probe(device_t dev)
return (ENXIO);
rid = 0;
rtype = AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId ?
rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ?
SYS_RES_IOPORT : SYS_RES_MEMORY;
acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
if (acpi_timer_reg == NULL) {
device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n",
(rtype == SYS_RES_IOPORT) ? "port" : "mem",
(u_long)AcpiGbl_FADT->XPmTmrBlk.Address);
(u_long)AcpiGbl_FADT.XPmTimerBlock.Address);
return (ENXIO);
}
acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg);
acpi_timer_bst = rman_get_bustag(acpi_timer_reg);
if (AcpiGbl_FADT->TmrValExt != 0)
if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
acpi_timer_timecounter.tc_counter_mask = 0xffffffff;
else
acpi_timer_timecounter.tc_counter_mask = 0x00ffffff;
@ -192,7 +192,7 @@ acpi_timer_probe(device_t dev)
tc_init(&acpi_timer_timecounter);
sprintf(desc, "%d-bit timer at 3.579545MHz",
AcpiGbl_FADT->TmrValExt ? 32 : 24);
(AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) ? 32 : 24);
device_set_desc_copy(dev, desc);
/* Release the resource, we'll allocate it again during attach. */
@ -208,7 +208,7 @@ acpi_timer_attach(device_t dev)
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
rid = 0;
rtype = AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId ?
rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ?
SYS_RES_IOPORT : SYS_RES_MEMORY;
acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
if (acpi_timer_reg == NULL)

View File

@ -423,7 +423,9 @@ int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type,
ACPI_HANDLE acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj);
/* Default number of task queue threads to start. */
#ifndef ACPI_MAX_THREADS
#define ACPI_MAX_THREADS 3
#endif
/* Use the device logging level for ktr(4). */
#define KTR_ACPI KTR_DEV

View File

@ -32,10 +32,12 @@ __FBSDID("$FreeBSD$");
* 6.1 : Environmental support
*/
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/linker_set.h>
#include <sys/sysctl.h>
#include <contrib/dev/acpica/acpi.h>
#include <contrib/dev/acpica/actables.h>
static u_long i386_acpi_root;
@ -54,25 +56,16 @@ AcpiOsTerminate(void)
return(0);
}
ACPI_STATUS
AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *RsdpPhysicalAddress)
ACPI_PHYSICAL_ADDRESS
AcpiOsGetRootPointer(void)
{
ACPI_POINTER ptr;
ACPI_STATUS status;
u_long ptr;
if (i386_acpi_root == 0) {
/*
* The loader passes the physical address at which it found the
* RSDP in a hint. We could recover this rather than searching
* manually here.
*/
status = AcpiFindRootPointer(Flags, &ptr);
if (status == AE_OK)
i386_acpi_root = ptr.Pointer.Physical;
} else
status = AE_OK;
if (i386_acpi_root == 0 &&
(resource_long_value("acpi", 0, "rsdp", (long *)&ptr) == 0 ||
AcpiFindRootPointer((ACPI_NATIVE_UINT *)&ptr) == AE_OK) &&
ptr != 0)
i386_acpi_root = ptr;
RsdpPhysicalAddress->PointerType = ACPI_PHYSICAL_POINTER;
RsdpPhysicalAddress->Pointer.Physical = i386_acpi_root;
return (status);
return (i386_acpi_root);
}

View File

@ -319,8 +319,8 @@ acpi_machdep_init(device_t dev)
acpi_install_wakeup_handler(sc);
if (intr_model == ACPI_INTR_PIC)
BUS_CONFIG_INTR(dev, AcpiGbl_FADT->SciInt, INTR_TRIGGER_LEVEL,
INTR_POLARITY_LOW);
BUS_CONFIG_INTR(dev, AcpiGbl_FADT.SciInterrupt,
INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
else
acpi_SetIntrModel(intr_model);

View File

@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
#define NIOAPICS 32 /* Max number of I/O APICs */
#define NLAPICS 32 /* Max number of local APICs */
typedef void madt_entry_handler(APIC_HEADER *entry, void *arg);
typedef void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
/* These two arrays are indexed by APIC IDs. */
struct ioapic_info {
@ -70,26 +70,29 @@ struct lapic_info {
} lapics[NLAPICS];
static int madt_found_sci_override;
static MULTIPLE_APIC_TABLE *madt;
static ACPI_TABLE_MADT *madt;
static vm_paddr_t madt_physaddr;
static vm_offset_t madt_length;
MALLOC_DEFINE(M_MADT, "madt_table", "ACPI MADT Table Items");
static enum intr_polarity interrupt_polarity(UINT16 Polarity, UINT8 Source);
static enum intr_trigger interrupt_trigger(UINT16 TriggerMode, UINT8 Source);
static enum intr_polarity interrupt_polarity(UINT16 IntiFlags, UINT8 Source);
static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
static int madt_find_cpu(u_int acpi_id, u_int *apic_id);
static int madt_find_interrupt(int intr, void **apic, u_int *pin);
static void *madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
static void *madt_map_table(vm_paddr_t pa, int offset, const char *sig);
static void madt_parse_apics(APIC_HEADER *entry, void *arg);
static void madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr);
static void madt_parse_ints(APIC_HEADER *entry, void *arg __unused);
static void madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi);
static void madt_parse_nmi(MADT_NMI_SOURCE *nmi);
static void madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
static void madt_parse_interrupt_override(
ACPI_MADT_INTERRUPT_OVERRIDE *intr);
static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry,
void *arg __unused);
static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi);
static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi);
static int madt_probe(void);
static int madt_probe_cpus(void);
static void madt_probe_cpus_handler(APIC_HEADER *entry, void *arg __unused);
static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
void *arg __unused);
static int madt_probe_table(vm_paddr_t address);
static void madt_register(void *dummy);
static int madt_setup_local(void);
@ -161,14 +164,14 @@ madt_map_table(vm_paddr_t pa, int offset, const char *sig)
void *table;
header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
if (strncmp(header->Signature, sig, 4) != 0) {
if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
return (NULL);
}
length = header->Length;
madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
table = madt_map(pa, offset, length);
if (ACPI_FAILURE(AcpiTbVerifyTableChecksum(table))) {
if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
if (bootverbose)
printf("MADT: Failed checksum for table %s\n", sig);
madt_unmap(table, length);
@ -192,10 +195,10 @@ madt_unmap_table(void *table)
static int
madt_probe(void)
{
ACPI_POINTER rsdp_ptr;
RSDP_DESCRIPTOR *rsdp;
RSDT_DESCRIPTOR *rsdt;
XSDT_DESCRIPTOR *xsdt;
ACPI_PHYSICAL_ADDRESS rsdp_ptr;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_RSDT *rsdt;
ACPI_TABLE_XSDT *xsdt;
int i, count;
if (resource_disabled("acpi", 0))
@ -206,12 +209,9 @@ madt_probe(void)
* calls pmap_mapbios() to find the RSDP, we assume that we can use
* pmap_mapbios() to map the RSDP.
*/
if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK)
if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
return (ENXIO);
#ifdef __i386__
KASSERT(rsdp_ptr.Pointer.Physical < KERNLOAD, ("RSDP too high"));
#endif
rsdp = pmap_mapbios(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR));
rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
if (rsdp == NULL) {
if (bootverbose)
printf("MADT: Failed to map RSDP\n");
@ -230,38 +230,40 @@ madt_probe(void)
* the version 1.0 portion of the RSDP. Version 2.0 has
* an additional checksum that we verify first.
*/
if (AcpiTbGenerateChecksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
if (bootverbose)
printf("MADT: RSDP failed extended checksum\n");
return (ENXIO);
}
xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, XSDT_SIG);
xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1,
ACPI_SIG_XSDT);
if (xsdt == NULL) {
if (bootverbose)
printf("MADT: Failed to map XSDT\n");
return (ENXIO);
}
count = (xsdt->Length - sizeof(ACPI_TABLE_HEADER)) /
count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
sizeof(UINT64);
for (i = 0; i < count; i++)
if (madt_probe_table(xsdt->TableOffsetEntry[i]))
break;
madt_unmap_table(xsdt);
} else {
rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, RSDT_SIG);
rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1,
ACPI_SIG_RSDT);
if (rsdt == NULL) {
if (bootverbose)
printf("MADT: Failed to map RSDT\n");
return (ENXIO);
}
count = (rsdt->Length - sizeof(ACPI_TABLE_HEADER)) /
count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
sizeof(UINT32);
for (i = 0; i < count; i++)
if (madt_probe_table(rsdt->TableOffsetEntry[i]))
break;
madt_unmap_table(rsdt);
}
pmap_unmapbios((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR));
pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
if (madt_physaddr == 0) {
if (bootverbose)
printf("MADT: No MADT table found\n");
@ -275,7 +277,7 @@ madt_probe(void)
* Verify that we can map the full table and that its checksum is
* correct, etc.
*/
madt = madt_map_table(madt_physaddr, 0, APIC_SIG);
madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
if (madt == NULL)
return (ENXIO);
madt_unmap_table(madt);
@ -303,7 +305,7 @@ madt_probe_table(vm_paddr_t address)
printf("Table '%.4s' at 0x%jx\n", table->Signature,
(uintmax_t)address);
if (strncmp(table->Signature, APIC_SIG, 4) != 0) {
if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) {
madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
return (0);
}
@ -320,7 +322,7 @@ static int
madt_probe_cpus(void)
{
madt = madt_map_table(madt_physaddr, 0, APIC_SIG);
madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
KASSERT(madt != NULL, ("Unable to re-map MADT"));
madt_walk_table(madt_probe_cpus_handler, NULL);
madt_unmap_table(madt);
@ -336,10 +338,10 @@ madt_setup_local(void)
{
madt = pmap_mapbios(madt_physaddr, madt_length);
lapic_init(madt->LocalApicAddress);
lapic_init(madt->Address);
printf("ACPI APIC Table: <%.*s %.*s>\n",
(int)sizeof(madt->OemId), madt->OemId,
(int)sizeof(madt->OemTableId), madt->OemTableId);
(int)sizeof(madt->Header.OemId), madt->Header.OemId,
(int)sizeof(madt->Header.OemTableId), madt->Header.OemTableId);
/*
* We ignore 64-bit local APIC override entries. Should we
@ -378,10 +380,10 @@ madt_setup_io(void)
* force it to use level trigger and active-low polarity.
*/
if (!madt_found_sci_override) {
if (madt_find_interrupt(AcpiGbl_FADT->SciInt, &ioapic, &pin)
!= 0)
printf("MADT: Could not find APIC for SCI IRQ %d\n",
AcpiGbl_FADT->SciInt);
if (madt_find_interrupt(AcpiGbl_FADT.SciInterrupt, &ioapic,
&pin) != 0)
printf("MADT: Could not find APIC for SCI IRQ %u\n",
AcpiGbl_FADT.SciInterrupt);
else {
printf(
"MADT: Forcing active-low polarity and level trigger for SCI\n");
@ -415,46 +417,46 @@ SYSINIT(madt_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, madt_register, NULL)
static void
madt_walk_table(madt_entry_handler *handler, void *arg)
{
APIC_HEADER *entry;
ACPI_SUBTABLE_HEADER *entry;
u_char *p, *end;
end = (u_char *)(madt) + madt->Length;
end = (u_char *)(madt) + madt->Header.Length;
for (p = (u_char *)(madt + 1); p < end; ) {
entry = (APIC_HEADER *)p;
entry = (ACPI_SUBTABLE_HEADER *)p;
handler(entry, arg);
p += entry->Length;
}
}
static void
madt_probe_cpus_handler(APIC_HEADER *entry, void *arg)
madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
{
MADT_PROCESSOR_APIC *proc;
ACPI_MADT_LOCAL_APIC *proc;
struct lapic_info *la;
switch (entry->Type) {
case APIC_PROCESSOR:
case ACPI_MADT_TYPE_LOCAL_APIC:
/*
* The MADT does not include a BSP flag, so we have to
* let the MP code figure out which CPU is the BSP on
* its own.
*/
proc = (MADT_PROCESSOR_APIC *)entry;
proc = (ACPI_MADT_LOCAL_APIC *)entry;
if (bootverbose)
printf("MADT: Found CPU APIC ID %d ACPI ID %d: %s\n",
proc->LocalApicId, proc->ProcessorId,
proc->ProcessorEnabled ? "enabled" : "disabled");
if (!proc->ProcessorEnabled)
printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n",
proc->Id, proc->ProcessorId,
(proc->LapicFlags & ACPI_MADT_ENABLED) ?
"enabled" : "disabled");
if (!(proc->LapicFlags & ACPI_MADT_ENABLED))
break;
if (proc->LocalApicId >= NLAPICS)
panic("%s: CPU ID %d too high", __func__,
proc->LocalApicId);
la = &lapics[proc->LocalApicId];
if (proc->Id >= NLAPICS)
panic("%s: CPU ID %u too high", __func__, proc->Id);
la = &lapics[proc->Id];
KASSERT(la->la_enabled == 0,
("Duplicate local APIC ID %d", proc->LocalApicId));
("Duplicate local APIC ID %u", proc->Id));
la->la_enabled = 1;
la->la_acpi_id = proc->ProcessorId;
lapic_create(proc->LocalApicId, 0);
lapic_create(proc->Id, 0);
break;
}
}
@ -464,26 +466,26 @@ madt_probe_cpus_handler(APIC_HEADER *entry, void *arg)
* Add an I/O APIC from an entry in the table.
*/
static void
madt_parse_apics(APIC_HEADER *entry, void *arg __unused)
madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg __unused)
{
MADT_IO_APIC *apic;
ACPI_MADT_IO_APIC *apic;
switch (entry->Type) {
case APIC_IO:
apic = (MADT_IO_APIC *)entry;
case ACPI_MADT_TYPE_IO_APIC:
apic = (ACPI_MADT_IO_APIC *)entry;
if (bootverbose)
printf("MADT: Found IO APIC ID %d, Interrupt %d at %p\n",
apic->IoApicId, apic->Interrupt,
printf(
"MADT: Found IO APIC ID %u, Interrupt %u at %p\n",
apic->Id, apic->GlobalIrqBase,
(void *)(uintptr_t)apic->Address);
if (apic->IoApicId >= NIOAPICS)
panic("%s: I/O APIC ID %d too high", __func__,
apic->IoApicId);
if (ioapics[apic->IoApicId].io_apic != NULL)
panic("%s: Double APIC ID %d", __func__,
apic->IoApicId);
ioapics[apic->IoApicId].io_apic = ioapic_create(apic->Address,
apic->IoApicId, apic->Interrupt);
ioapics[apic->IoApicId].io_vector = apic->Interrupt;
if (apic->Id >= NIOAPICS)
panic("%s: I/O APIC ID %u too high", __func__,
apic->Id);
if (ioapics[apic->Id].io_apic != NULL)
panic("%s: Double APIC ID %u", __func__, apic->Id);
ioapics[apic->Id].io_apic = ioapic_create(apic->Address,
apic->Id, apic->GlobalIrqBase);
ioapics[apic->Id].io_vector = apic->GlobalIrqBase;
break;
default:
break;
@ -497,18 +499,18 @@ madt_parse_apics(APIC_HEADER *entry, void *arg __unused)
* SCI for which we use Active Lo, Level Triggered.
*/
static enum intr_polarity
interrupt_polarity(UINT16 Polarity, UINT8 Source)
interrupt_polarity(UINT16 IntiFlags, UINT8 Source)
{
switch (Polarity) {
case POLARITY_CONFORMS:
if (Source == AcpiGbl_FADT->SciInt)
switch (IntiFlags & ACPI_MADT_POLARITY_MASK) {
case ACPI_MADT_POLARITY_CONFORMS:
if (Source == AcpiGbl_FADT.SciInterrupt)
return (INTR_POLARITY_LOW);
else
return (INTR_POLARITY_HIGH);
case POLARITY_ACTIVE_HIGH:
case ACPI_MADT_POLARITY_ACTIVE_HIGH:
return (INTR_POLARITY_HIGH);
case POLARITY_ACTIVE_LOW:
case ACPI_MADT_POLARITY_ACTIVE_LOW:
return (INTR_POLARITY_LOW);
default:
panic("Bogus Interrupt Polarity");
@ -516,18 +518,18 @@ interrupt_polarity(UINT16 Polarity, UINT8 Source)
}
static enum intr_trigger
interrupt_trigger(UINT16 TriggerMode, UINT8 Source)
interrupt_trigger(UINT16 IntiFlags, UINT8 Source)
{
switch (TriggerMode) {
case TRIGGER_CONFORMS:
if (Source == AcpiGbl_FADT->SciInt)
switch (IntiFlags & ACPI_MADT_TRIGGER_MASK) {
case ACPI_MADT_TRIGGER_CONFORMS:
if (Source == AcpiGbl_FADT.SciInterrupt)
return (INTR_TRIGGER_LEVEL);
else
return (INTR_TRIGGER_EDGE);
case TRIGGER_EDGE:
case ACPI_MADT_TRIGGER_EDGE:
return (INTR_TRIGGER_EDGE);
case TRIGGER_LEVEL:
case ACPI_MADT_TRIGGER_LEVEL:
return (INTR_TRIGGER_LEVEL);
default:
panic("Bogus Interrupt Trigger Mode");
@ -585,7 +587,7 @@ madt_find_interrupt(int intr, void **apic, u_int *pin)
* Parse an interrupt source override for an ISA interrupt.
*/
static void
madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr)
{
void *new_ioapic, *old_ioapic;
u_int new_pin, old_pin;
@ -593,20 +595,19 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
enum intr_polarity pol;
char buf[64];
if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->Source == 0 &&
intr->Interrupt == 2) {
if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 &&
intr->GlobalIrq == 2) {
if (bootverbose)
printf("MADT: Skipping timer override\n");
return;
}
if (bootverbose)
printf("MADT: Interrupt override: source %u, irq %u\n",
intr->Source, intr->Interrupt);
intr->SourceIrq, intr->GlobalIrq);
KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero"));
if (madt_find_interrupt(intr->Interrupt, &new_ioapic,
&new_pin) != 0) {
printf("MADT: Could not find APIC for vector %d (IRQ %d)\n",
intr->Interrupt, intr->Source);
if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) {
printf("MADT: Could not find APIC for vector %u (IRQ %u)\n",
intr->GlobalIrq, intr->SourceIrq);
return;
}
@ -614,15 +615,15 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
* Lookup the appropriate trigger and polarity modes for this
* entry.
*/
trig = interrupt_trigger(intr->TriggerMode, intr->Source);
pol = interrupt_polarity(intr->Polarity, intr->Source);
trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq);
pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq);
/*
* If the SCI is identity mapped but has edge trigger and
* active-hi polarity or the force_sci_lo tunable is set,
* force it to use level/lo.
*/
if (intr->Source == AcpiGbl_FADT->SciInt) {
if (intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) {
madt_found_sci_override = 1;
if (getenv_string("hw.acpi.sci.trigger", buf, sizeof(buf))) {
if (tolower(buf[0]) == 'e')
@ -651,23 +652,24 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
}
/* Remap the IRQ if it is mapped to a different interrupt vector. */
if (intr->Source != intr->Interrupt) {
if (intr->SourceIrq != intr->GlobalIrq) {
/*
* If the SCI is remapped to a non-ISA global interrupt,
* then override the vector we use to setup and allocate
* the interrupt.
*/
if (intr->Interrupt > 15 &&
intr->Source == AcpiGbl_FADT->SciInt)
acpi_OverrideInterruptLevel(intr->Interrupt);
if (intr->GlobalIrq > 15 &&
intr->SourceIrq == AcpiGbl_FADT.SciInterrupt)
acpi_OverrideInterruptLevel(intr->GlobalIrq);
else
ioapic_remap_vector(new_ioapic, new_pin, intr->Source);
if (madt_find_interrupt(intr->Source, &old_ioapic,
ioapic_remap_vector(new_ioapic, new_pin,
intr->SourceIrq);
if (madt_find_interrupt(intr->SourceIrq, &old_ioapic,
&old_pin) != 0)
printf("MADT: Could not find APIC for source IRQ %d\n",
intr->Source);
printf("MADT: Could not find APIC for source IRQ %u\n",
intr->SourceIrq);
else if (ioapic_get_vector(old_ioapic, old_pin) ==
intr->Source)
intr->SourceIrq)
ioapic_disable_pin(old_ioapic, old_pin);
}
@ -680,31 +682,31 @@ madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr)
* Parse an entry for an NMI routed to an IO APIC.
*/
static void
madt_parse_nmi(MADT_NMI_SOURCE *nmi)
madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi)
{
void *ioapic;
u_int pin;
if (madt_find_interrupt(nmi->Interrupt, &ioapic, &pin) != 0) {
printf("MADT: Could not find APIC for vector %d\n",
nmi->Interrupt);
if (madt_find_interrupt(nmi->GlobalIrq, &ioapic, &pin) != 0) {
printf("MADT: Could not find APIC for vector %u\n",
nmi->GlobalIrq);
return;
}
ioapic_set_nmi(ioapic, pin);
if (nmi->TriggerMode != TRIGGER_CONFORMS)
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
ioapic_set_triggermode(ioapic, pin,
interrupt_trigger(nmi->TriggerMode, 0));
if (nmi->Polarity != TRIGGER_CONFORMS)
interrupt_trigger(nmi->IntiFlags, 0));
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
ioapic_set_polarity(ioapic, pin,
interrupt_polarity(nmi->Polarity, 0));
interrupt_polarity(nmi->IntiFlags, 0));
}
/*
* Parse an entry for an NMI routed to a local APIC LVT pin.
*/
static void
madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi)
{
u_int apic_id, pin;
@ -712,8 +714,8 @@ madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
apic_id = APIC_ID_ALL;
else if (madt_find_cpu(nmi->ProcessorId, &apic_id) != 0) {
if (bootverbose)
printf("MADT: Ignoring local NMI routed to ACPI CPU %u\n",
nmi->ProcessorId);
printf("MADT: Ignoring local NMI routed to "
"ACPI CPU %u\n", nmi->ProcessorId);
return;
}
if (nmi->Lint == 0)
@ -721,31 +723,31 @@ madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi)
else
pin = LVT_LINT1;
lapic_set_lvt_mode(apic_id, pin, APIC_LVT_DM_NMI);
if (nmi->TriggerMode != TRIGGER_CONFORMS)
if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
lapic_set_lvt_triggermode(apic_id, pin,
interrupt_trigger(nmi->TriggerMode, 0));
if (nmi->Polarity != POLARITY_CONFORMS)
interrupt_trigger(nmi->IntiFlags, 0));
if (!(nmi->IntiFlags & ACPI_MADT_POLARITY_CONFORMS))
lapic_set_lvt_polarity(apic_id, pin,
interrupt_polarity(nmi->Polarity, 0));
interrupt_polarity(nmi->IntiFlags, 0));
}
/*
* Parse interrupt entries.
*/
static void
madt_parse_ints(APIC_HEADER *entry, void *arg __unused)
madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused)
{
switch (entry->Type) {
case APIC_XRUPT_OVERRIDE:
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
madt_parse_interrupt_override(
(MADT_INTERRUPT_OVERRIDE *)entry);
(ACPI_MADT_INTERRUPT_OVERRIDE *)entry);
break;
case APIC_NMI:
madt_parse_nmi((MADT_NMI_SOURCE *)entry);
case ACPI_MADT_TYPE_NMI_SOURCE:
madt_parse_nmi((ACPI_MADT_NMI_SOURCE *)entry);
break;
case APIC_LOCAL_NMI:
madt_parse_local_nmi((MADT_LOCAL_APIC_NMI *)entry);
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
madt_parse_local_nmi((ACPI_MADT_LOCAL_APIC_NMI *)entry);
break;
}
}
@ -766,7 +768,7 @@ madt_set_ids(void *dummy)
if (CPU_ABSENT(i))
continue;
pc = pcpu_find(i);
KASSERT(pc != NULL, ("no pcpu data for CPU %d", i));
KASSERT(pc != NULL, ("no pcpu data for CPU %u", i));
la = &lapics[pc->pc_apic_id];
if (!la->la_enabled)
panic("APIC: CPU with APIC ID %u is not enabled",

View File

@ -506,17 +506,12 @@ device tdfx_linux # Enable Linuxulator support
#
# ACPI_NO_SEMAPHORES makes the AcpiOs*Semaphore routines a no-op.
#
# ACPICA_PEDANTIC enables strict checking of AML. Our default is to
# relax these checks to allow code generated by the Microsoft compiler
# to still execute.
#
# Note that building ACPI into the kernel is deprecated; the module is
# normally loaded automatically by the loader.
device acpi
options ACPI_DEBUG
#!options ACPI_NO_SEMAPHORES
#!options ACPICA_PEDANTIC
# ACPI Asus Desktop Extras. (voltage, temp, fan)
device acpi_aiboost

View File

@ -34,7 +34,7 @@
*****************************************************************************/
#ifndef __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#ifdef _KERNEL
/*
@ -45,41 +45,43 @@
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
*/
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
/* Asm macros */
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_FLUSH_CPU_CACHE() wbinvd()
#define ACPI_FLUSH_CPU_CACHE() wbinvd()
/* Section 5.2.9.1: global lock acquire/release functions */
extern int acpi_acquire_global_lock(uint32_t *lock);
extern int acpi_release_global_lock(uint32_t *lock);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_acquire_global_lock(GLptr))
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_release_global_lock(GLptr))
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_acquire_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_release_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
/*! [Begin] no source code translation
*
* Math helper asm macros
*/
#define asm __asm
#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
#define asm __asm
#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
asm("divl %2;" \
:"=a"(q32), "=d"(r32) \
:"r"(d32), \
"0"(n_lo), "1"(n_hi))
#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
asm("shrl $1,%2;" \
"rcrl $1,%3;" \
:"=r"(n_hi), "=r"(n_lo) \
@ -88,10 +90,10 @@ extern int acpi_release_global_lock(uint32_t *lock);
/*! [End] no source code translation !*/
#endif /* _KERNEL */
#define ACPI_MACHINE_WIDTH 32
#define COMPILER_DEPENDENT_INT64 long long
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#define ACPI_USE_NATIVE_DIVIDE
#define ACPI_MACHINE_WIDTH 32
#define COMPILER_DEPENDENT_INT64 long long
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#define ACPI_USE_NATIVE_DIVIDE
void acpi_SetDefaultIntrModel(int model);
void acpi_cpu_c1(void);

View File

@ -56,19 +56,17 @@ AcpiOsTerminate(void)
return(AE_OK);
}
ACPI_STATUS
AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *RsdpAddress)
ACPI_PHYSICAL_ADDRESS
AcpiOsGetRootPointer(void)
{
void *acpi_root;
if (acpi_root_phys == 0) {
acpi_root = efi_get_table(&acpi_root_uuid);
if (acpi_root == NULL)
return (AE_NOT_FOUND);
return (0);
acpi_root_phys = IA64_RR_MASK((u_long)acpi_root);
}
RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER;
RsdpAddress->Pointer.Physical = acpi_root_phys;
return (AE_OK);
return (acpi_root_phys);
}

View File

@ -36,69 +36,71 @@ extern u_int64_t ia64_lapic_address;
struct sapic *sapic_create(int, int, u_int64_t);
static void
print_entry(APIC_HEADER *entry)
print_entry(ACPI_SUBTABLE_HEADER *entry)
{
switch (entry->Type) {
case APIC_XRUPT_OVERRIDE: {
MADT_INTERRUPT_OVERRIDE *iso =
(MADT_INTERRUPT_OVERRIDE *)entry;
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: {
ACPI_MADT_INTERRUPT_OVERRIDE *iso =
(ACPI_MADT_INTERRUPT_OVERRIDE *)entry;
printf("\tInterrupt source override entry\n");
printf("\t\tBus=%d, Source=%d, Irq=0x%x\n", iso->Bus,
iso->Source, iso->Interrupt);
printf("\t\tBus=%u, Source=%u, Irq=0x%x\n", iso->Bus,
iso->SourceIrq, iso->GlobalIrq);
break;
}
case APIC_IO:
case ACPI_MADT_TYPE_IO_APIC:
printf("\tI/O APIC entry\n");
break;
case APIC_IO_SAPIC: {
MADT_IO_SAPIC *sapic = (MADT_IO_SAPIC *)entry;
case ACPI_MADT_TYPE_IO_SAPIC: {
ACPI_MADT_IO_SAPIC *sapic = (ACPI_MADT_IO_SAPIC *)entry;
printf("\tI/O SAPIC entry\n");
printf("\t\tId=0x%x, InterruptBase=0x%x, Address=0x%lx\n",
sapic->IoSapicId, sapic->InterruptBase, sapic->Address);
sapic->Id, sapic->GlobalIrqBase, sapic->Address);
break;
}
case APIC_LOCAL_NMI:
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
printf("\tLocal APIC NMI entry\n");
break;
case APIC_ADDRESS_OVERRIDE: {
MADT_ADDRESS_OVERRIDE *lapic = (MADT_ADDRESS_OVERRIDE *)entry;
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: {
ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic =
(ACPI_MADT_LOCAL_APIC_OVERRIDE *)entry;
printf("\tLocal APIC override entry\n");
printf("\t\tLocal APIC address=0x%jx\n", lapic->Address);
break;
}
case APIC_LOCAL_SAPIC: {
MADT_LOCAL_SAPIC *sapic = (MADT_LOCAL_SAPIC *)entry;
case ACPI_MADT_TYPE_LOCAL_SAPIC: {
ACPI_MADT_LOCAL_SAPIC *sapic = (ACPI_MADT_LOCAL_SAPIC *)entry;
printf("\tLocal SAPIC entry\n");
printf("\t\tProcessorId=0x%x, Id=0x%x, Eid=0x%x",
sapic->ProcessorId, sapic->LocalSapicId,
sapic->LocalSapicEid);
if (!sapic->ProcessorEnabled)
sapic->ProcessorId, sapic->Id, sapic->Eid);
if (!(sapic->LapicFlags & ACPI_MADT_ENABLED))
printf(" (disabled)");
printf("\n");
break;
}
case APIC_NMI:
case ACPI_MADT_TYPE_NMI_SOURCE:
printf("\tNMI entry\n");
break;
case APIC_XRUPT_SOURCE: {
MADT_INTERRUPT_SOURCE *pis = (MADT_INTERRUPT_SOURCE *)entry;
case ACPI_MADT_TYPE_INTERRUPT_SOURCE: {
ACPI_MADT_INTERRUPT_SOURCE *pis =
(ACPI_MADT_INTERRUPT_SOURCE *)entry;
printf("\tPlatform interrupt entry\n");
printf("\t\tPolarity=%d, TriggerMode=%d, Id=0x%x, "
printf("\t\tPolarity=%u, TriggerMode=%u, Id=0x%x, "
"Eid=0x%x, Vector=0x%x, Irq=%d\n",
pis->Polarity, pis->TriggerMode, pis->ProcessorId,
pis->ProcessorEid, pis->IoSapicVector, pis->Interrupt);
pis->IntiFlags & ACPI_MADT_POLARITY_MASK,
(pis->IntiFlags & ACPI_MADT_TRIGGER_MASK) >> 2,
pis->Id, pis->Eid, pis->IoSapicVector, pis->GlobalIrq);
break;
}
case APIC_PROCESSOR:
case ACPI_MADT_TYPE_LOCAL_APIC:
printf("\tLocal APIC entry\n");
break;
@ -111,73 +113,76 @@ print_entry(APIC_HEADER *entry)
void
ia64_probe_sapics(void)
{
ACPI_POINTER rsdp_ptr;
APIC_HEADER *entry;
MULTIPLE_APIC_TABLE *table;
RSDP_DESCRIPTOR *rsdp;
XSDT_DESCRIPTOR *xsdt;
ACPI_PHYSICAL_ADDRESS rsdp_ptr;
ACPI_SUBTABLE_HEADER *entry;
ACPI_TABLE_MADT *table;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_XSDT *xsdt;
char *end, *p;
int t, tables;
if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK)
if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
return;
rsdp = (RSDP_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp_ptr.Pointer.Physical);
xsdt = (XSDT_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr);
xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
tables = (UINT64 *)((char *)xsdt + xsdt->Length) -
tables = (UINT64 *)((char *)xsdt + xsdt->Header.Length) -
xsdt->TableOffsetEntry;
for (t = 0; t < tables; t++) {
table = (MULTIPLE_APIC_TABLE *)
table = (ACPI_TABLE_MADT *)
IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[t]);
if (bootverbose)
printf("Table '%c%c%c%c' at %p\n",
table->Signature[0], table->Signature[1],
table->Signature[2], table->Signature[3], table);
table->Header.Signature[0],
table->Header.Signature[1],
table->Header.Signature[2],
table->Header.Signature[3], table);
if (strncmp(table->Signature, APIC_SIG, 4) != 0 ||
ACPI_FAILURE(AcpiTbVerifyTableChecksum((void *)table)))
if (strncmp(table->Header.Signature, ACPI_SIG_MADT,
ACPI_NAME_SIZE) != 0 ||
ACPI_FAILURE(AcpiTbChecksum((void *)table,
table->Header.Length)))
continue;
/* Save the address of the processor interrupt block. */
if (bootverbose)
printf("\tLocal APIC address=0x%x\n",
table->LocalApicAddress);
ia64_lapic_address = table->LocalApicAddress;
printf("\tLocal APIC address=0x%x\n", table->Address);
ia64_lapic_address = table->Address;
end = (char *)table + table->Length;
end = (char *)table + table->Header.Length;
p = (char *)(table + 1);
while (p < end) {
entry = (APIC_HEADER *)p;
entry = (ACPI_SUBTABLE_HEADER *)p;
if (bootverbose)
print_entry(entry);
switch (entry->Type) {
case APIC_IO_SAPIC: {
MADT_IO_SAPIC *sapic = (MADT_IO_SAPIC *)entry;
sapic_create(sapic->IoSapicId,
sapic->InterruptBase, sapic->Address);
case ACPI_MADT_TYPE_IO_SAPIC: {
ACPI_MADT_IO_SAPIC *sapic =
(ACPI_MADT_IO_SAPIC *)entry;
sapic_create(sapic->Id, sapic->GlobalIrqBase,
sapic->Address);
break;
}
case APIC_ADDRESS_OVERRIDE: {
MADT_ADDRESS_OVERRIDE *lapic =
(MADT_ADDRESS_OVERRIDE*)entry;
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: {
ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic =
(ACPI_MADT_LOCAL_APIC_OVERRIDE *)entry;
ia64_lapic_address = lapic->Address;
break;
}
#ifdef SMP
case APIC_LOCAL_SAPIC: {
MADT_LOCAL_SAPIC *sapic =
(MADT_LOCAL_SAPIC *)entry;
if (sapic->ProcessorEnabled)
case ACPI_MADT_TYPE_LOCAL_SAPIC: {
ACPI_MADT_LOCAL_SAPIC *sapic =
(ACPI_MADT_LOCAL_SAPIC *)entry;
if (sapic->LapicFlags & ACPI_MADT_ENABLED)
cpu_mp_add(sapic->ProcessorId,
sapic->LocalSapicId,
sapic->LocalSapicEid);
sapic->Id, sapic->Eid);
break;
}
#endif
@ -198,43 +203,45 @@ ia64_probe_sapics(void)
int
ia64_count_cpus(void)
{
ACPI_POINTER rsdp_ptr;
MULTIPLE_APIC_TABLE *table;
MADT_LOCAL_SAPIC *entry;
RSDP_DESCRIPTOR *rsdp;
XSDT_DESCRIPTOR *xsdt;
ACPI_PHYSICAL_ADDRESS rsdp_ptr;
ACPI_MADT_LOCAL_SAPIC *entry;
ACPI_TABLE_MADT *table;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_XSDT *xsdt;
char *end, *p;
int cpus, t, tables;
if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK)
if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
return (0);
rsdp = (RSDP_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp_ptr.Pointer.Physical);
xsdt = (XSDT_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr);
xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
tables = (UINT64 *)((char *)xsdt + xsdt->Length) -
tables = (UINT64 *)((char *)xsdt + xsdt->Header.Length) -
xsdt->TableOffsetEntry;
cpus = 0;
for (t = 0; t < tables; t++) {
table = (MULTIPLE_APIC_TABLE *)
table = (ACPI_TABLE_MADT *)
IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[t]);
if (strncmp(table->Signature, APIC_SIG, 4) != 0 ||
ACPI_FAILURE(AcpiTbVerifyTableChecksum((void *)table)))
if (strncmp(table->Header.Signature, ACPI_SIG_MADT,
ACPI_NAME_SIZE) != 0 ||
ACPI_FAILURE(AcpiTbChecksum((void *)table,
table->Header.Length)))
continue;
end = (char *)table + table->Length;
end = (char *)table + table->Header.Length;
p = (char *)(table + 1);
while (p < end) {
entry = (MADT_LOCAL_SAPIC *)p;
entry = (ACPI_MADT_LOCAL_SAPIC *)p;
if (entry->Type == APIC_LOCAL_SAPIC &&
entry->ProcessorEnabled)
if (entry->Header.Type == ACPI_MADT_TYPE_LOCAL_SAPIC &&
(entry->LapicFlags & ACPI_MADT_ENABLED))
cpus++;
p += entry->Length;
p += entry->Header.Length;
}
}

View File

@ -34,10 +34,10 @@
*****************************************************************************/
#ifndef __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#define __ACPICA_MACHDEP_H__
#ifdef _KERNEL
#define _IA64
#define _IA64
/*
* Calling conventions:
@ -47,33 +47,35 @@
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
*/
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
/* Asm macros */
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() disable_intr()
#define ACPI_ENABLE_IRQS() enable_intr()
#define ACPI_FLUSH_CPU_CACHE() /* XXX ia64_fc()? */
#define ACPI_FLUSH_CPU_CACHE() /* XXX ia64_fc()? */
/* Section 5.2.9.1: global lock acquire/release functions */
extern int acpi_acquire_global_lock(uint32_t *lock);
extern int acpi_release_global_lock(uint32_t *lock);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_acquire_global_lock(GLptr))
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
((Acq) = acpi_release_global_lock(GLptr))
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_acquire_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) do { \
(Acq) = acpi_release_global_lock(&((GLptr)->GlobalLock)); \
} while (0)
#endif /* _KERNEL */
#define ACPI_MACHINE_WIDTH 64
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
#define ACPI_MACHINE_WIDTH 64
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
void acpi_cpu_c1(void);

View File

@ -453,7 +453,7 @@ _snc= snc
.if ${MACHINE_ARCH} == "amd64"
_aac= aac
_acpi= acpi
_acpi= acpi
_agp= agp
_an= an
_arcmsr= arcmsr

View File

@ -1,10 +1,11 @@
# $FreeBSD$
.if ${MACHINE} == "i386"
SUBDIR= acpi
SUBDIR= acpi
.endif
SUBDIR+= acpi_aiboost acpi_asus acpi_fujitsu acpi_ibm \
acpi_panasonic acpi_sony acpi_toshiba acpi_video acpi_dock
SUBDIR+= acpi_aiboost acpi_asus acpi_fujitsu acpi_ibm \
acpi_panasonic acpi_sony acpi_toshiba acpi_video \
acpi_dock
.include <bsd.subdir.mk>

View File

@ -1,10 +1,13 @@
# $FreeBSD$
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64"
.error "ACPI can only be compiled into the kernel on the amd64 and ia64 platforms"
.endif
.if ${MACHINE} != "i386"
.error "The ACPI module is only for i386"
.endif
.PATH: ${.CURDIR}/../../../contrib/dev/acpica \
${.CURDIR}/../../../pci \
${.CURDIR}/../../../dev/acpica \
@ -15,47 +18,42 @@ KMOD= acpi
# ACPI CA sources
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica
SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c
SRCS+= dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c
SRCS+= dswscope.c dswstate.c evevent.c evgpe.c evgpeblk.c
SRCS+= evmisc.c evregion.c evrgnini.c evsci.c evxface.c
SRCS+= evxfevnt.c evxfregn.c exconfig.c exconvrt.c excreate.c
SRCS+= exdump.c exfield.c exfldio.c exmisc.c exmutex.c
SRCS+= exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c
SRCS+= exprep.c exregion.c exresnte.c exresolv.c exresop.c
SRCS+= exstore.c exstoren.c exstorob.c exsystem.c exutils.c
SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c dsopcode.c
SRCS+= dsutils.c dswexec.c dswload.c dswscope.c dswstate.c
SRCS+= evevent.c evgpe.c evgpeblk.c evmisc.c evregion.c evrgnini.c evsci.c
SRCS+= evxface.c evxfevnt.c evxfregn.c
SRCS+= exconfig.c exconvrt.c excreate.c exdump.c exfield.c exfldio.c exmisc.c
SRCS+= exmutex.c exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c
SRCS+= exprep.c exregion.c exresnte.c exresolv.c exresop.c exstore.c
SRCS+= exstoren.c exstorob.c exsystem.c exutils.c
SRCS+= hwacpi.c hwgpe.c hwregs.c hwsleep.c hwtimer.c
SRCS+= nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c
SRCS+= nsload.c nsnames.c nsobject.c nsparse.c nssearch.c
SRCS+= nsutils.c nswalk.c nsxfeval.c nsxfname.c nsxfobj.c
SRCS+= psargs.c psloop.c psopcode.c psparse.c psscope.c
SRCS+= pstree.c psutils.c pswalk.c psxface.c
SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c rsio.c
SRCS+= rsirq.c rslist.c rsmemory.c rsmisc.c rsutils.c
SRCS+= rsxface.c tbconvrt.c tbget.c tbgetall.c tbinstal.c
SRCS+= tbrsdt.c tbutils.c tbxface.c tbxfroot.c utalloc.c
SRCS+= utcache.c utclib.c utcopy.c utdebug.c utdelete.c
SRCS+= uteval.c utglobal.c utinit.c utmath.c utmisc.c
SRCS+= utmutex.c utobject.c utstate.c utxface.c
SRCS+= nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c nsload.c nsnames.c
SRCS+= nsobject.c nsparse.c nssearch.c nsutils.c nswalk.c nsxfeval.c
SRCS+= nsxfname.c nsxfobj.c
SRCS+= psargs.c psloop.c psopcode.c psparse.c psscope.c pstree.c psutils.c
SRCS+= pswalk.c psxface.c
SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c rsio.c rsirq.c rslist.c
SRCS+= rsmemory.c rsmisc.c rsutils.c rsxface.c
SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c tbxfroot.c
SRCS+= utalloc.c utcache.c utclib.c utcopy.c utdebug.c utdelete.c uteval.c
SRCS+= utglobal.c utinit.c utmath.c utmisc.c utmutex.c utobject.c utresrc.c
SRCS+= utstate.c utxface.c
# OSPM layer and core hardware drivers
SRCS+= acpi.c acpi_button.c acpi_isab.c
SRCS+= acpi_package.c acpi_pci.c acpi_pcib.c acpi_pcib_acpi.c
SRCS+= acpi_pcib_pci.c acpi_powerres.c acpi_quirk.c acpi_resource.c
SRCS+= acpi_timer.c acpi_pci_link.c acpi_thermal.c
SRCS+= acpi.c acpi_button.c acpi_isab.c acpi_package.c acpi_pci.c acpi_pcib.c
SRCS+= acpi_pcib_acpi.c acpi_pcib_pci.c acpi_powerres.c acpi_quirk.c
SRCS+= acpi_resource.c acpi_timer.c acpi_pci_link.c acpi_thermal.c
# ACPI hardware drivers, mostly used for mobile systems.
SRCS+= acpi_acad.c acpi_battery.c acpi_cmbat.c acpi_cpu.c
SRCS+= acpi_ec.c acpi_hpet.c acpi_lid.c acpi_perf.c acpi_smbat.c
SRCS+= acpi_throttle.c
SRCS+= acpi_acad.c acpi_battery.c acpi_cmbat.c acpi_cpu.c acpi_ec.c
SRCS+= acpi_hpet.c acpi_lid.c acpi_perf.c acpi_smbat.c acpi_throttle.c
# OSD layer
SRCS+= OsdDebug.c
SRCS+= OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c
SRCS+= OsdStream.c OsdSynch.c OsdTable.c OsdEnvironment.c
SRCS+= opt_acpi.h opt_bus.h opt_ddb.h
SRCS+= acpi_if.h acpi_quirks.h bus_if.h cpufreq_if.h device_if.h
SRCS+= isa_if.h pci_if.h pcib_if.h
SRCS+= OsdDebug.c
SRCS+= OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c OsdStream.c
SRCS+= OsdSynch.c OsdTable.c OsdEnvironment.c
SRCS+= opt_acpi.h opt_bus.h opt_ddb.h acpi_if.h acpi_quirks.h bus_if.h
SRCS+= cpufreq_if.h device_if.h isa_if.h pci_if.h pcib_if.h
# XXX ACPI should not depend on the following headers but this is currently
# needed for the build of assym.s.
@ -63,12 +61,11 @@ SRCS+= isa_if.h pci_if.h pcib_if.h
SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_compat.h
# Debugging support
DBSRC= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c
DBSRC+= dbinput.c dbstats.c dbutils.c dbxface.c
DBSRC= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c dbinput.c dbstats.c
DBSRC+= dbutils.c dbxface.c
DBSRC+= dmbuffer.c dmnames.c dmopcode.c dmobject.c dmresrc.c dmresrcl.c
DBSRC+= dmresrcs.c dmutils.c dmwalk.c
CFLAGS+=-DACPI_USE_LOCAL_CACHE
.if !defined(KERNBUILDDIR)
.if ACPI_MAX_THREADS
CFLAGS+=-DACPI_MAX_THREADS=${ACPI_MAX_THREADS}

View File

@ -78,7 +78,7 @@ $1 == "oem:" {
M = match (REMAINDER, /\"[^\"]*\"/);
OEM_TABLE_ID = substr(REMAINDER, M, RLENGTH);
printf("\t{ ACPI_TABLE_%s, OEM, {%s}, {%s} },\n",
printf("\t{ \"%s\", OEM, {%s}, {%s} },\n",
TABLE, OEM_ID, OEM_TABLE_ID) > OUTPUT;
}
@ -92,7 +92,7 @@ $1 == "creator:" {
M = match ($0, /\"[^\"]*\"/);
CREATOR = substr($0, M, RLENGTH);
printf("\t{ ACPI_TABLE_%s, CREATOR, {%s} },\n",
printf("\t{ \"%s\", CREATOR, {%s} },\n",
TABLE, CREATOR) > OUTPUT;
}
@ -107,7 +107,7 @@ $1 == "oem_rev:" {
# Parse operand
OPERAND = trans_sign(SIGN);
printf("\t{ ACPI_TABLE_%s, OEM_REV, {.op = %s}, {.rev = %s} },\n",
printf("\t{ \"%s\", OEM_REV, {.op = %s}, {.rev = %s} },\n",
TABLE, OPERAND, VALUE) > OUTPUT;
}
@ -122,7 +122,7 @@ $1 == "creator_rev:" {
# Parse operand
OPERAND = trans_sign(SIGN);
printf("\t{ ACPI_TABLE_%s, CREATOR_REV, {.op = %s}, {.rev = %s} },\n",
printf("\t{ \"%s\", CREATOR_REV, {.op = %s}, {.rev = %s} },\n",
TABLE, OPERAND, VALUE) > OUTPUT;
}
@ -130,7 +130,7 @@ $1 == "creator_rev:" {
# QUIRKS field: This is the last line of every entry
#
$1 == "quirks:" {
printf("\t{ ACPI_TABLE_END }\n};\n\n") > OUTPUT;
printf("\t{ \"\" }\n};\n\n") > OUTPUT;
QUIRKS = $0;
sub(/^quirks:[ ]*/ , "", QUIRKS);

View File

@ -46,21 +46,18 @@ SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c \
rsutils.c rsxface.c
# tables
SRCS+= tbconvrt.c tbget.c tbgetall.c tbinstal.c tbrsdt.c \
tbutils.c tbxface.c tbxfroot.c
# tools/acpiexec
SRCS+= aeexec.c
SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c \
tbxfroot.c
# utilities
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
uteval.c utglobal.c utinit.c utmath.c utmisc.c \
utmutex.c utobject.c utstate.c utxface.c
utmutex.c utobject.c utresrc.c utstate.c uttrack.c \
utxface.c
MAN= acpidb.8
WARNS?= 2
CFLAGS+= -DACPI_APPLICATION -DACPI_DEBUG_OUTPUT -DACPI_DEBUGGER \
-DACPI_DISASSEMBLER
CFLAGS+= -DACPI_EXEC_APP
.include <bsd.prog.mk>

View File

@ -30,6 +30,7 @@
#include <sys/queue.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/stdint.h>
#include <sys/types.h>
#include <assert.h>
@ -85,6 +86,13 @@ static ACPI_INTEGER aml_simulate_prompt(char *msg, ACPI_INTEGER def_val);
static void aml_simulation_regload(const char *dumpfile);
static void aml_simulation_regdump(const char *dumpfile);
/* Stubs to simplify linkage to the ACPI CA core subsystem. */
ACPI_STATUS
AeLocalGetRootPointer(void)
{
return AE_ERROR;
}
static void
aml_simulation_init(void)
{
@ -239,7 +247,7 @@ aml_simulation_regdump(const char *dumpfile)
while (!TAILQ_EMPTY(&RegionContentList)) {
rc = TAILQ_FIRST(&RegionContentList);
fprintf(fp, "%d 0x%jx 0x%x\n",
rc->regtype, rc->addr, rc->value);
rc->regtype, (uintmax_t)rc->addr, rc->value);
TAILQ_REMOVE(&RegionContentList, rc, links);
free(rc);
}
@ -283,7 +291,8 @@ aml_vm_space_handler(
*Value = value;
if (Prompt) {
sprintf(msg, "[read (%s, %2d, 0x%jx)]",
space_names[SpaceID], BitWidth, Address);
space_names[SpaceID], BitWidth,
(uintmax_t)Address);
*Value = aml_simulate_prompt(msg, value);
if (*Value != value) {
return(aml_vm_space_handler(SpaceID,
@ -297,7 +306,8 @@ aml_vm_space_handler(
value = *Value;
if (Prompt) {
sprintf(msg, "[write(%s, %2d, 0x%jx)]",
space_names[SpaceID], BitWidth, Address);
space_names[SpaceID], BitWidth,
(uintmax_t)Address);
value = aml_simulate_prompt(msg, *Value);
}
*Value = value;
@ -339,16 +349,14 @@ DECLARE_VM_SPACE_HANDLER(pci_bar_target,ACPI_ADR_SPACE_PCI_BAR_TARGET);
* Load DSDT data file and invoke debugger
*/
static UINT32 DummyGlobalLock;
static int
load_dsdt(const char *dsdtfile)
{
char filetmp[PATH_MAX];
u_int8_t *code;
struct stat sb;
int fd, fd2;
int error;
struct stat sb;
int fd, fd2;
int error;
fd = open(dsdtfile, O_RDONLY, 0);
if (fd == -1) {
@ -441,17 +449,7 @@ load_dsdt(const char *dsdtfile)
return (-1);
}
AcpiGbl_FACS = malloc(sizeof (ACPI_COMMON_FACS));
if (AcpiGbl_FACS == NULL) {
fprintf(stderr, "could not allocate memory for FACS\n");
return (-1);
}
DummyGlobalLock = 0;
AcpiGbl_CommonFACS.GlobalLock = &DummyGlobalLock;
AcpiGbl_GlobalLockPresent = TRUE;
AcpiDbGetTableFromFile(filetmp, NULL);
AcpiUtSetIntegerWidth (AcpiGbl_DSDT->Revision);
AcpiDbInitialize();
AcpiGbl_DebuggerConfiguration = 0;

View File

@ -35,12 +35,14 @@
#include <err.h>
#include <fcntl.h>
#include <kenv.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "acpidump.h"
static char hint_acpi_0_rsdp[] = "hint.acpi.0.rsdp";
static char machdep_acpi_root[] = "machdep.acpi_root";
static int acpi_mem_fd = -1;
@ -124,7 +126,7 @@ acpi_get_rsdp(u_long addr)
static struct ACPIrsdp *
acpi_scan_rsd_ptr(void)
{
#if defined(__i386__)
#if defined(__amd64__) || defined(__i386__)
struct ACPIrsdp *rsdp;
u_long addr, end;
@ -147,7 +149,7 @@ acpi_scan_rsd_ptr(void)
for (; addr < end; addr += 16)
if ((rsdp = acpi_get_rsdp(addr)) != NULL)
return (rsdp);
#endif /* __i386__ */
#endif /* __amd64__ || __i386__ */
return (NULL);
}
@ -158,20 +160,22 @@ struct ACPIrsdp *
acpi_find_rsd_ptr(void)
{
struct ACPIrsdp *rsdp;
char buf[20];
u_long addr;
size_t len;
acpi_user_init();
/* Attempt to use sysctl to find RSD PTR record. */
len = sizeof(addr);
if (sysctlbyname(machdep_acpi_root, &addr, &len, NULL, 0) == 0) {
if ((rsdp = acpi_get_rsdp(addr)) != NULL)
return (rsdp);
else
warnx("sysctl %s does not point to RSDP",
machdep_acpi_root);
/* Attempt to use kenv or sysctl to find RSD PTR record. */
if (kenv(KENV_GET, hint_acpi_0_rsdp, buf, 20) == 0)
addr = strtoul(buf, NULL, 0);
if (addr == 0) {
len = sizeof(addr);
if (sysctlbyname(machdep_acpi_root, &addr, &len, NULL, 0) != 0)
addr = 0;
}
if (addr != 0 && (rsdp = acpi_get_rsdp(addr)) != NULL)
return (rsdp);
return (acpi_scan_rsd_ptr());
}

View File

@ -1,11 +1,11 @@
# $FreeBSD$
PROG= iasl
SRCS= adisasm.c
SRCS= adfile.c adisasm.c adwalk.c
SRCS+= osunixxf.c
# common
SRCS+= getopt.c
SRCS+= dmrestag.c dmtable.c dmtbdump.c dmtbinfo.c getopt.c
# compiler
SRCS+= aslanalyze.c aslcodegen.c aslcompile.c aslcompiler.y.h \
@ -42,12 +42,12 @@ SRCS+= nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \
nsparse.c nssearch.c nsutils.c nswalk.c nsxfobj.c
# tables
SRCS+= tbinstal.c tbutils.c
SRCS+= tbfadt.c tbinstal.c tbutils.c tbxface.c
# utilities
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
utglobal.c utmath.c utmisc.c utmutex.c utobject.c \
utstate.c
utresrc.c utstate.c
MAN= iasl.8