Home | History | Annotate | Download | only in acpi
History log of /src/sys/arch/x86/acpi/acpi_machdep.c
RevisionDateAuthorComments
 1.40  06-Oct-2025  riastradh x86: Wire up PCI resource manager if enabled.

Enable in your kernel config with `options PCI_RESOURCE'.

Adapted from a patch by mlelstv@.

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.39  30-Apr-2025  imil Introduce pvh_boot boolean to identify the real hypervisor when booting in PVH
mode.

As of now, sys/arch/x86/x86/identcpu.c / identify_hypervisor() returns in the
case of vm_guest being VM_GUEST_GENPVH, yet this VM type is not an actual
hypervisor but an information recorded in locore.S to drive boot method.
We need to investigate what type of hypervisor is really running the VM in
order to apply specifics, so instead of relying on vm_guest_is_pvh() which only
checks for VM_GUEST_XENPVH || VM_GUEST_GENPVH, pvh_boot informs on the boot
method while allowing to identify the real hypervisor.

Idea ok'd by bouyer@, tested on Xen domU, Xen dom0 with GENERIC PVH and
qemu GENERIC PVH boot.
 1.38  06-Dec-2024  bouyer Introduce vm_guest_is_pvh() and use it in place of
(vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH)
 1.37  02-Dec-2024  bouyer Add support for non-Xen PVH guests to amd64. Patch from
Emile 'iMil' Heitor in PR kern/57813, with some cosmetic tweaks by me.
Tested on bare metal, Xen PV and Xen PVH by me.
 1.36  16-Oct-2023  bouyer branches: 1.36.6;
Declare
int acpi_md_vesa_modenum;
int acpi_md_vbios_reset;
struct vcons_screen x86_genfb_console_screen;

in genfb_machdep.h instead of locally as extern in various .c files.
 1.35  24-Jan-2023  riastradh x86/acpi/acpi_machdep.c: Nix trailing whitespace.

No functional change intended.
 1.34  28-Oct-2022  riastradh branches: 1.34.2;
x86/acpi: Mark acpica interrupt handlers MP-safe.

acpica has its own internal locking, and the interrupt handlers we
install with AcpiInstall*Handler (gpe, notify, &c.) also have their
own locking.
 1.33  20-Aug-2022  riastradh x86: Split most of pmap.h into pmap_private.h or vmparam.h.

This way pmap.h only contains the MD definition of the MI pmap(9)
API, which loads of things in the kernel rely on, so changing x86
pmap internals no longer requires recompiling the entire kernel every
time.

Callers needing these internals must now use machine/pmap_private.h.
Note: This is not x86/pmap_private.h because it contains three parts:

1. CPU-specific (different for i386/amd64) definitions used by...

2. common definitions, including Xenisms like xpmap_ptetomach,
further used by...

3. more CPU-specific inlines for pmap_pte_* operations

So {amd64,i386}/pmap_private.h defines 1, includes x86/pmap_private.h
for 2, and then defines 3. Maybe we should split that out into a new
pmap_pte.h to reduce this trouble.

No functional change intended, other than that some .c files must
include machine/pmap_private.h when previously uvm/uvm_pmap.h
polluted the namespace with pmap internals.

Note: This migrates part of i386/pmap.h into i386/vmparam.h --
specifically the parts that are needed for several constants defined
in vmparam.h:

VM_MAXUSER_ADDRESS
VM_MAX_ADDRESS
VM_MAX_KERNEL_ADDRESS
VM_MIN_KERNEL_ADDRESS

Since i386 needs PDP_SIZE in vmparam.h, I added it there on amd64
too, just to keep things parallel.
 1.32  12-May-2021  thorpej - Define a device call for PCI bus instances to fetch a direct child's
device handle given the device's device/function #s (extracted from
a pcitag_t). Use it to associate the handle with the child device
at config_found() time.
- Implement this device call for ACPI and OpenFirmware.
- Enable the OpenFirmware variant for evbarm FDT, macppc, ofppc, sparc64.
- Obsolete acpi_device_register(); it is no longer needed.
- Obsolete setting the OpenFirmware handle in PCI devices in the
sparc64 device_register(); it is no longer needed.
 1.31  04-Feb-2021  thorpej branches: 1.31.4; 1.31.6;
Call acpi_device_register() as appropriate.
 1.30  02-May-2020  bouyer branches: 1.30.2;
Introduce Xen PVH support in GENERIC.
This is compiled in with
options XENPVHVM
x86 changes:
- add Xen section and xen pvh entry points to locore.S. Set vm_guest
to VM_GUEST_XENPVH in this entry point.
Most of the boot procedure (especially page table setup and switch to
paged mode) is shared with native.
- change some x86_delay() to delay_func(), which points to x86_delay() for
native/HVM, and xen_delay() for PVH

Xen changes:
- remove Xen bits from init_x86_64_ksyms() and init386_ksyms()
and move to xen_init_ksyms(), used for both PV and PVH
- set ISA no-legacy-devices property for PVH
- factor out code from Xen's cpu_bootconf() to xen_bootconf()
in xen_machdep.c
- set up a specific pvh_consinit() which starts with printk()
(which uses a simple hypercall that is available early) and switch to
xencons when we can use pmap_kenter_pa().
 1.29  22-Dec-2019  thorpej Add acpi_intr_mask() and acpi_intr_unmask() which, following the pre-existing
ACPI software layering model, are wrappers around acpi_md_intr_mask() and
acpi_md_intr_unmask(), which in turn are wrappers around intr_mask() and
intr_unmask().

XXX ARM and IA64 implementations of acpi_md_intr_mask() and
acpi_md_intr_unmask() are just stubs for now.
 1.28  12-Sep-2019  martin Cast physical addresses via uintptr_t to ACPI_PHYSICAL_ADDRESS to deal
with all size variants of the types used here in different builds.
Patch from manu@.
 1.27  12-Sep-2019  manu Attempt to obtain ACPI RSDP from the hypervisor for Xen PV

There are three possible way of obtaining the ACPI RSDP
- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
SystemTable is not passed to the kernel. The only way to go is to
obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.
 1.26  01-May-2019  mlelstv branches: 1.26.2;
Handle ISA/EISA interrupts like isa_machdep.c.
 1.25  09-Mar-2019  kre In acpi_md_OsRemoveInterruptHandler() redir and mpflags are only
relevant to the NIOAPIC > 0 case (not used without that). Rearrange
#if's slightly to make that happen (avoid "set but not used" warnings
(aka errors) when NIOAPIC == 0 (or undefined)).
 1.24  09-Mar-2019  maxv Start replacing the x86 PTE bits.
 1.23  03-Mar-2019  maxv Fix bug, PG_W is 'wired', not 'writable'.
 1.22  11-Feb-2019  cherry We reorganise definitions for XEN source support as follows:

XEN - common sources required for baseline XEN support.
XENPV - sources required for support of XEN in PV mode.
XENPVHVM - sources required for support for XEN in HVM mode.
XENPVH - sources required for support for XEN in PVH mode.
 1.21  22-Nov-2018  jmcneill Apply MADT interrupt source overrides to interrupts established via
acpi_md_intr_establish.
 1.20  16-Nov-2018  jmcneill Add MD functions for establishing and disestablishing interrupt handlers.
 1.19  20-Mar-2018  bouyer branches: 1.19.2;
Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.
 1.18  14-Feb-2017  nonaka branches: 1.18.6; 1.18.12;
Handle persistent memory. Currently only debug output.
 1.17  14-Feb-2017  nonaka x86: make btinfo_memmap from btinfo_efimemmap for to reduce mem_cluster_cnt.

should fix PR/51953.
 1.16  09-Feb-2017  nonaka efi_md::md_virt always uses uint64_t.
 1.15  24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.14  15-Oct-2016  jdolecek branches: 1.14.2;
provide intr xname
 1.13  21-Sep-2016  jmcneill Set hw.acpi.sleep.vbios when a non-HW accelerated VGA driver attaches.
If the VGA_POST option is present in the kernel the default value is 2,
otherwise 1. PR kern/50781

Reviewed by: agc, mrg
 1.12  28-Jan-2016  htodd branches: 1.12.2;
Fix build break.
 1.11  28-Jan-2016  christos Add support for grub to find the ACPI root table pointer via a bootinfo entry
from grub.
From: https://mail-index.netbsd.org/tech-kern/2014/05/22/msg017119.html
 1.10  06-Oct-2015  christos CID/1325751: Avoid possible 32 bit overflow.
 1.9  02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.8  12-May-2014  joerg branches: 1.8.4;
acpi_md_findoverride is only used when NIOAPIC > 0, so don't provide it
otherwise.
 1.7  06-Oct-2013  jakllsch branches: 1.7.2;
Correct acpi_md_OsWritable() logic so that it can return TRUE.
From Masanori Kanaoka in PR 47571.
 1.6  31-Mar-2013  chs branches: 1.6.4;
yet more fixes for PR 47648 / PR 47016:
when using a temporary mp_intr_map, initialize the "flags" field
as well as "redir" since apic_set_redir() uses both. fix how
the flags field is change when applying an override, the trigger
and polarity sub-fields aren't just one bit like they are in redir.
 1.5  25-Mar-2013  chs redo the ACPI interrupt handler setup again, this time handling
MADT overrides that change the pin as well as the polarity.
fixes PR 47648.
 1.4  23-Sep-2012  chs locate PCI buses and determine their bus numbers using the info
previously extracted from ACPICA rather than trying to figure it out again.
allow PCI buses that don't have a _PRT method.
 1.3  30-Jan-2012  rmind branches: 1.3.2; 1.3.6;
acpi_md_ncpus: use kcpuset_attached instead.
 1.2  01-Jul-2011  dyoung branches: 1.2.2; 1.2.4; 1.2.8;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.1  12-Jun-2011  jruoho branches: 1.1.2;
Follow IA-64 with the x86-specific ACPI MD functions and move these where
they belong to. Remove an unused function. Minor KNF. No functional change.
 1.1.2.2  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.1  12-Jun-2011  cherry file acpi_machdep.c was added on branch cherry-xenmp on 2011-06-23 14:19:47 +0000
 1.2.8.1  18-Feb-2012  mrg merge to -current.
 1.2.4.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.2  30-Oct-2012  yamt sync with head
 1.2.4.1  17-Apr-2012  yamt sync with head
 1.2.2.2  27-Aug-2011  jym Add/remove files, like in HEAD.
 1.2.2.1  01-Jul-2011  jym file acpi_machdep.c was added on branch jym-xensuspend on 2011-08-27 15:59:49 +0000
 1.3.6.4  03-Dec-2017  jdolecek update from HEAD
 1.3.6.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.2  23-Jun-2013  tls resync from head
 1.3.6.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.3.2.2  31-Mar-2013  riz Pull up following revision(s) (requested by chs in ticket #855):
sys/arch/x86/acpi/acpi_machdep.c: revision 1.5
sys/arch/x86/acpi/acpi_machdep.c: revision 1.6
sys/arch/x86/x86/mpacpi.c: revision 1.97
redo the ACPI interrupt handler setup again, this time handling
MADT overrides that change the pin as well as the polarity.
fixes PR 47648.
yet more fixes for PR 47648 / PR 47016:
when using a temporary mp_intr_map, initialize the "flags" field
as well as "redir" since apic_set_redir() uses both. fix how
the flags field is change when applying an override, the trigger
and polarity sub-fields aren't just one bit like they are in redir.
 1.3.2.1  22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #683):
sys/arch/ia64/include/acpi_machdep.h: revision 1.6
sys/arch/x86/include/acpi_machdep.h: revision 1.11
sys/dev/acpi/acpi.c: revision 1.255
sys/arch/x86/acpi/acpi_machdep.c: revision 1.4
sys/arch/x86/x86/mpacpi.c: revision 1.95
sys/arch/x86/x86/mpacpi.c: revision 1.96
sys/arch/ia64/acpi/acpi_machdep.c: revision 1.6
locate PCI buses and determine their bus numbers using the info
previously extracted from ACPICA rather than trying to figure it out again.
allow PCI buses that don't have a _PRT method.
as a workaround for PR 47016, call ioapic_reenable() at the end of
ACPI interrupt routing to fix the settings for the SCI interrupt.
the problem is that after my recent changes, the SCI handler is
installed before the MADT info is parsed, so we don't know what
polarity it should have. the real fix for this will be to rearrange
the ACPI initialization so that everything is done in a more sensible
order, but that will take some more time.
 1.6.4.1  18-May-2014  rmind sync with head
 1.7.2.1  10-Aug-2014  tls Rebase.
 1.8.4.6  28-Aug-2017  skrll Sync with HEAD
 1.8.4.5  05-Feb-2017  skrll Sync with HEAD
 1.8.4.4  05-Dec-2016  skrll Sync with HEAD
 1.8.4.3  05-Oct-2016  skrll Sync with HEAD
 1.8.4.2  19-Mar-2016  skrll Sync with HEAD
 1.8.4.1  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.12.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.12.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.14.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.18.12.2  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.18.12.1  22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.18.6.2  23-Sep-2019  martin Apply patch, requested by manu in ticket #1380: add EFI specific guids
here locally for XEN (solved differently in HEAD by including more efi
support code in XEN kernels for PVHVM).
 1.18.6.1  18-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #1380):

sys/arch/x86/acpi/acpi_machdep.c: revision 1.27,1.28 (patch)

Attempt to obtain ACPI RSDP from the hypervisor for Xen PV
There are three possible way of obtaining the ACPI RSDP

- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
SystemTable is not passed to the kernel. The only way to go is to
obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.

Cast physical addresses via uintptr_t to ACPI_PHYSICAL_ADDRESS to deal
with all size variants of the types used here in different builds.
 1.19.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.19.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.19.2.1  10-Jun-2019  christos Sync with HEAD
 1.26.2.1  17-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #204):

sys/arch/x86/acpi/acpi_machdep.c: revision 1.27
sys/arch/x86/acpi/acpi_machdep.c: revision 1.28

Attempt to obtain ACPI RSDP from the hypervisor for Xen PV

There are three possible way of obtaining the ACPI RSDP

- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
SystemTable is not passed to the kernel. The only way to go is to
obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.

Cast physical addresses via uintptr_t to ACPI_PHYSICAL_ADDRESS to deal
with all size variants of the types used here in different builds.
 1.30.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.31.6.1  31-May-2021  cjep sync with head
 1.31.4.1  13-May-2021  thorpej Sync with HEAD.
 1.34.2.2  29-Mar-2025  martin Pull up following revision(s) (requested by imil in ticket #1074):

sys/arch/x86/x86/x86_machdep.c: revision 1.155
sys/arch/x86/include/cpu.h: revision 1.137
sys/arch/x86/x86/x86_machdep.c: revision 1.156
sys/arch/x86/include/cpu.h: revision 1.138
sys/arch/x86/x86/consinit.c: revision 1.40
sys/arch/x86/acpi/acpi_machdep.c: revision 1.37
sys/arch/x86/acpi/acpi_machdep.c: revision 1.38
sys/arch/amd64/amd64/machdep.c: revision 1.370
sys/arch/xen/xen/hypervisor.c: revision 1.97
sys/arch/xen/xen/hypervisor.c: revision 1.98
sys/arch/amd64/amd64/genassym.cf: revision 1.98
sys/arch/x86/x86/x86_autoconf.c: revision 1.88
sys/arch/x86/x86/x86_autoconf.c: revision 1.89
sys/arch/amd64/amd64/locore.S: revision 1.226
sys/arch/amd64/amd64/locore.S: revision 1.227
sys/arch/x86/x86/identcpu.c: revision 1.131

Add support for non-Xen PVH guests to amd64. Patch from
Emile 'iMil' Heitor in PR kern/57813, with some cosmetic tweaks by me.
Tested on bare metal, Xen PV and Xen PVH by me.

Get one more change from PR kern/57813, needed for non-Xen PVH.

Introduce vm_guest_is_pvh() and use it in place of
(vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH)
 1.34.2.1  18-Oct-2023  martin Pull up following revision(s) (requested by bouyer in ticket #425):

sys/arch/x86/pci/pci_machdep.c: revision 1.96
sys/arch/x86/acpi/acpi_machdep.c: revision 1.36
sys/arch/x86/x86/hyperv.c: revision 1.16
sys/arch/x86/x86/genfb_machdep.c: revision 1.21
sys/arch/x86/acpi/acpi_wakeup.c: revision 1.56
sys/arch/x86/include/genfb_machdep.h: revision 1.6

Declare
int acpi_md_vesa_modenum;
int acpi_md_vbios_reset;
struct vcons_screen x86_genfb_console_screen;

in genfb_machdep.h instead of locally as extern in various .c files.
 1.36.6.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed