/*
* Copyright 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef XENPV
/*
* Obtain the ACPI RSDP from the hypervisor.
* This is the only way to go if Xen booted from EFI: the
* Extended BIOS Data Area (EBDA) is not mapped, and Xen
* does not pass an EFI SystemTable to the kernel.
*/
struct xen_platform_op op = {
.cmd = XENPF_firmware_info,
.u.firmware_info = {
.type = XEN_FW_EFI_INFO,
.index = XEN_FW_EFI_CONFIG_TABLE
}
};
union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
if (HYPERVISOR_platform_op(&op) == 0) {
struct efi_cfgtbl *ct;
int i;
for (i = 0; i < info->cfg.nent; i++) {
if (memcmp(&ct[i].ct_uuid,
&EFI_UUID_ACPI20, sizeof(EFI_UUID_ACPI20)) == 0) {
PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
(uintptr_t)ct[i].ct_data;
if (PhysicalAddress)
goto out;
}
}
for (i = 0; i < info->cfg.nent; i++) {
if (memcmp(&ct[i].ct_uuid,
&EFI_UUID_ACPI10, sizeof(EFI_UUID_ACPI10)) == 0) {
PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
(uintptr_t)ct[i].ct_data;
if (PhysicalAddress)
goto out;
if (PhysicalAddress)
return PhysicalAddress;
}
#else
#ifdef XEN
if (pvh_boot) {
PhysicalAddress = hvm_start_info->rsdp_paddr;
if (PhysicalAddress)
return PhysicalAddress;
}
#endif
/*
* Get the ACPI RSDP from EFI SystemTable. This works when the
* kernel was loaded from EFI bootloader.
*/
if (efi_probe()) {
PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20);
if (!PhysicalAddress)
PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI10);
if (PhysicalAddress)
return PhysicalAddress;
}
#endif
/*
* Find ACPI RSDP from Extended BIOS Data Area (EBDA). This
* works when the kernel was started from BIOS bootloader,
* or for Xen PV when Xen was started from BIOS bootloader.
*/
Status = AcpiFindRootPointer(&PhysicalAddress);
if (ACPI_FAILURE(Status))
PhysicalAddress = 0;
return PhysicalAddress;
}
struct acpi_md_override {
int irq;
int pin;
int flags;
};
/*
* If the interrupt is handled via IOAPIC, update the map.
* If the map isn't set up yet, install a temporary one.
* Identify ISA & EISA interrupts
*/
if (mp_busses != NULL) {
if (intr_find_mpmapping(mp_isa_bus, irq, &mpih) == 0 ||
intr_find_mpmapping(mp_eisa_bus, irq, &mpih) == 0) {
if (!APIC_IRQ_ISLEGACY(mpih)) {
pin = APIC_IRQ_PIN(mpih);
ioapic = ioapic_find(APIC_IRQ_APIC(mpih));
if (ioapic != NULL)
pic = &ioapic->sc_pic;
}
}
}
if (pic == NULL) {
/*
* If the interrupt is handled via IOAPIC, update the map.
* If the map isn't set up yet, install a temporary one.
*/
ioapic = ioapic_find_bybase(irq);
if (ioapic != NULL) {
pic = &ioapic->sc_pic;