Home | History | Annotate | only in /src/sys/dev/acpi
History log of /src/sys/dev/acpi
RevisionDateAuthorComments
 1.5 19-Oct-2008  apb Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.4 11-Dec-2005  christos branches: 1.4.70; 1.4.74; 1.4.80;
merge ktrace-lwp.
 1.3 12-Dec-2003  jmc Just use the default field separator
 1.2 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.1 05-Jan-2003  christos branches: 1.1.2; 1.1.4;
Infrastucture for ACPIVERBOSE
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 05-Jan-2003  thorpej file Makefile.acpidevs was added on branch nathanw_sa on 2003-01-07 21:33:56 +0000
 1.4.80.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.74.1 04-May-2009  yamt sync with head.
 1.4.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.13 23-Jun-2011  jruoho Note some long-term difficult goals.
 1.12 08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.11 21-Dec-2005  sekiya branches: 1.11.74; 1.11.96; 1.11.98;
I fixed the cardbus bus enumeration problem awhile back, but the interrupt
fixup problems remain. Adjust TODO comments to match, and add a link to
cube's comments.
 1.10 09-Jun-2004  kochi branches: 1.10.2; 1.10.14;
The "implicit return" problem is already fixed since when I imported
ACPICA_PEDANTIC changes from FreeBSD.
Added one item (processor driver).
 1.9 07-Jun-2004  kochi Remove the first one (split _REG initialization path into two phases;
which has been done since post-20031203 version of ACPI-CA).
Pointed out by mycroft.
 1.8 05-Jun-2004  mycroft Remove a couple of items that are done now. XXX Is the first one also done?
 1.7 30-Mar-2004  wiz Fix date in previous (shouldn't the entry just be removed?).
 1.6 30-Mar-2004  kochi ECDT support is complete.
 1.5 03-Nov-2003  mycroft Remove acpiec locking from the list.
 1.4 03-Nov-2003  mycroft Add another item, and some comments on particular machines affected.
 1.3 02-Nov-2003  mycroft Add another one.
 1.2 01-Nov-2003  mycroft Dropped a word...
 1.1 01-Nov-2003  mycroft A small list of things needed here.
 1.10.14.1 21-Jun-2006  yamt sync with head.
 1.10.2.2 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 09-Jun-2004  skrll file TODO was added on branch ktrace-lwp on 2004-08-03 10:45:03 +0000
 1.11.98.1 05-Mar-2011  rmind sync with head
 1.11.96.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.74.1 11-Aug-2010  yamt sync with head.
 1.303 25-Feb-2025  christos fix aarch64 kernel build (Tobias Nygren)
 1.302 30-Dec-2024  jmcneill acpi: Ensure that non-child I2C HID devices are properly claimed.
 1.301 19-Dec-2024  riastradh acpi(4): Nix trailing whitespace.

No functional change intended.
 1.300 18-Dec-2024  jmcneill acpi: Honour device dependencies ("_DEP" method).

When creating acpi_devnode devices, build a list of devnodes that are
direct dependencies of this node. The list of dependencies are parent
device nodes (if present), along with all devices returned by the _DEP
method.

When rescanning devices, make sure that all dependencies have been
scanned first. This ensures that drivers attach in the correct order.
 1.299 20-Mar-2024  riastradh branches: 1.299.2;
acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.

Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046
 1.298 31-May-2022  mrg branches: 1.298.4;
allow ACPI to compile without PCI support. fixes ia64 build.
 1.297 27-Feb-2022  riastradh acpi: Assert acpi_register_notify is not called twice.
 1.296 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.295 31-Dec-2021  riastradh acpi(9): Fix memory ordering and completion bugs in notifiers.

1. Guarantee everything which happened before acpi_register_notify
has also happened before the notifier is actually called.

2. On acpi_deregister_notify, don't return until the notifier is
definitely not running any more on any CPU, using
AcpiOsWaitEventsComplete.
 1.294 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.293 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.292 12-May-2021  thorpej branches: 1.292.4;
- 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.291 24-Apr-2021  thorpej branches: 1.291.2; 1.291.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.290 05-Feb-2021  thorpej branches: 1.290.2;
Assign device handles to "at acpi" and "at pci" devices in
acpi_device_register().
 1.289 04-Feb-2021  thorpej Add acpi_device_register(). Just a placeholder for now.
 1.288 13-Dec-2020  jmcneill Add MI support for attaching drivers to arbitrary System Description
Tables.
 1.287 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.286 08-Nov-2020  jmcneill Ignore PNP0001 (EISA interrupt controller) and PNP0C02 (motherboard
resources) when enumerating devices.
 1.285 22-Jun-2020  maxv branches: 1.285.2;
Fix memory leak. Found by kLSan.
 1.284 09-Apr-2020  jmcneill Stop walking MADT / GTDT subtables if we hit a header with length 0
 1.283 17-Jan-2020  jmcneill branches: 1.283.4;
Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.282 31-Dec-2019  jmcneill branches: 1.282.2;
Fetch bus_dma tags when acpi devnodes are created. They do not change
and this allows MD code to create more complex tags without being
concerned with the tag being destroyed later. While here, capture
translations offsets for address32/address64 resources.
 1.281 30-Dec-2019  jmcneill Hide ACPI0004 devices on aarch64
 1.280 30-Dec-2019  jmcneill MD code may allocate a new dma tag for attach args, so destroy it if the device node is not claimed
 1.279 29-Dec-2019  jmcneill Allow MD code to provide custom bus_dma tags on a per-node basis. On Arm
this is required to return non-coherent bus_dma tags for device nodes with
_CCA=0
 1.278 21-Oct-2018  jmcneill branches: 1.278.4;
Add ACPI PCI link devices to ignored ids on arm64
 1.277 16-Oct-2018  jmcneill Ignore SCI and don't try to setup ACPI fixed hardware interfaces in HW-reduced mode
 1.276 16-Oct-2018  jmcneill Rename options ACPI_REDUCED_HARDWARE to ACPI_REDUCED_HW. The former is
a boolean in the acpica build, so use the latter to select the correct
value.
 1.275 16-Oct-2018  jmcneill Add ACPI_REDUCED_HARDWARE defflag (used by ACPICA) and fix acpi build with this option set.
 1.274 12-Oct-2018  jmcneill Ignore ACPI0007 (CPU device) nodes on aarch64.
 1.273 12-Oct-2018  jmcneill Add helper functions for walking GTDT subtables.
 1.272 11-Oct-2018  jmcneill Fix button type print; "type" is one of PSWITCH_TYPE_*, not ACPI_EVENT_*_BUTTON.
 1.271 25-May-2018  ryoon branches: 1.271.2;
If fixed feature buttons exist, print detection messages.
 1.270 05-May-2018  christos introduce acpi_device_present() to replace the previous _STA checks.
 1.269 07-Apr-2018  christos Merge conflicts; STA methods and fields are not present anymore.
 1.268 04-Mar-2018  scole branches: 1.268.2;
Use "#if NPCI > 0" instead of "#ifdef NPCI" for compiling kernels with acpi, without pci.
 1.267 03-Mar-2018  maya include correct header for NPCI to be defined when necessary.
Now acpi.o has a call for acpimcfg_probe.

heads by paulg, sorry for breakage.
 1.266 01-Mar-2018  maya Limit building & calling ACPI MCFG to kernels with PCI and ACPI.

pci_quirks.c requires pci
acpi_mcfg.c was recently changed to use pci_quirks.c functions.

as a result, ia64 kernels with acpi but no pci failed to link.

tested an ia64 and amd64 kernels build.
 1.265 23-Nov-2017  jmcneill Add FALLTHROUGH comment in acpi_make_devnode ACPI_TYPE_DEVICE case.
 1.264 28-Oct-2017  riastradh Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.263 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.262 21-Jun-2016  nonaka Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.
 1.261 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.260 18-Aug-2015  christos add extra argument to method.
 1.259 25-Oct-2014  christos branches: 1.259.2;
adjust for newer acpica
 1.258 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.257 25-Jan-2014  christos fix unused
 1.256 16-Oct-2013  christos remove unused variable
 1.255 23-Sep-2012  chs branches: 1.255.2;
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.254 14-Aug-2012  jruoho branches: 1.254.2;
Use KM_SLEEP.
 1.253 10-Apr-2012  jruoho Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.
 1.252 14-Nov-2011  jmcneill branches: 1.252.4; 1.252.6;
add a machdep.dmi sysctl tree with the following read-only keys:
system-vendor, system-product, system-version, system-serial, system-uuid
bios-vendor, bios-version
board-vendor, board-product, board-version, board-serial
the *-serial and *-uuid keys are marked with CTLFLAG_PRIVATE

a few of the pmf platform key names changed so update callers to match
 1.251 18-Oct-2011  jmcneill branches: 1.251.2;
clear fixed events and disable GPEs before re-enabling interrupts on resume
from S1
 1.250 05-Aug-2011  jakllsch Turns out all we need is AcpiClearEvent in the right place,
and we don't really care if it fails. Pointed out by jmcneill.
 1.249 05-Aug-2011  jakllsch As we add a handler for the ACPI fixed feature button events,
ensure they aren't going to trigger as soon as we enable interrupts,
furthermore ensure that the event is unmasked.
 1.248 01-Aug-2011  jmcneill add support for reset registers in PCI config space
 1.247 17-Jul-2011  jakllsch "successfully" spell "succesfully" in a comment.
 1.246 21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.245 14-Jun-2011  jruoho Try to attach hpet(4) also via a specific HPET table. Fixes PR kern/43702.
 1.244 13-Jun-2011  jruoho Call _PDC only after AcpiInitializeObjects(ACPI_FULL_INITIALIZATION).
 1.243 12-Jun-2011  jruoho Move the evaluation of the _PDC control method out from the acpicpu(4)
driver to the main acpi(4) stack. Follow Linux and evaluate it early.
Should fix PR port-amd64/42895, possibly also PR kern/42583, and many
other comparable bugs.

A common sense explanation is that Intel supplies additional CPU tables to
OEMs. BIOS writers do not bother to modify their DSDTs, but instead load
these extra tables dynamically as secondary SSDT tables. The actual Load()
happens when the _PDC method is invoked, and thus namespace errors occur
when the CPU-specific ACPI methods are not yet present but referenced in the
AML by various drivers, including, but not limited to, acpitz(4).
 1.242 03-Jun-2011  jruoho Flush CPU caches before entering S1, as noted in the specifications.
 1.241 31-May-2011  jruoho branches: 1.241.2;
Fix a bug where the S1 state was exited via AcpiLeaveSleepState() with
interrupts being off at machine-level. Also add some comments.
 1.240 27-Feb-2011  jruoho Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".
 1.239 20-Feb-2011  jruoho Use kmem(9). Also retire ACPI_PCI_FIXUP and PCI_INTR_FIXUP_DISABLED #ifdefs.
 1.238 20-Feb-2011  jruoho Add quirk support for _OSI strings introduced in ACPICA 20110211. While
here, clean up acpi_probe() and the quirk code. Remove #ifdef ACPI_DEBUGGER.
 1.237 19-Feb-2011  jruoho Revisit the wake-device code once more.

1. Remove the AcpiEnableGpe() call. This was wrong.

2. Only call _PSW or _DSW for devices that are scheduled for wake.
This was an old bug.

3. Only enable wake GPEs during suspend. Disabling these for
devices not setup for wake was causing problems.

4. No wake GPEs should be enabled at runtime.
Unconditionally disable these during resume.

This should make the wake-device code work again. Note that waking via
pckbd(4) has always been unreliable; the _PRW object is not typically located
under the PC keyboard object, but in the parent of it (e.g. the LPC bridge).
 1.236 17-Feb-2011  jruoho As explained in the new ACPICA documentation, as of ACPICA 20101207, the
_PRW methods are no longer automatically executed as part of the ACPICA
initialization. Refactor and rewrite the wake-device code to account this.
 1.235 15-Feb-2011  jruoho Reset the firmware waking vector on resume. Adapted from FreeBSD and Linux.
No functional change intended.
 1.234 17-Jan-2011  jmcneill branches: 1.234.2;
Add a driver for ACPI "Watchdog Resource Table" devices.

acpiwdrt0 at acpi0: mem 0xfed01000,0xfed01004
acpiwdrt0: PCI 0:000:00:0 vendor 0x1106 product 0x3337
acpiwdrt0: watchdog interval 1-1023 sec.
 1.233 13-Jan-2011  jruoho branches: 1.233.2;
Clean-up acpi_print(). XXX: The 'acpiverbose' module is still broken...
 1.232 13-Jan-2011  jruoho Scan for docking stations.
 1.231 13-Jan-2011  jruoho Do not try to attach more ACPI CPUs than the amount of "real" CPUs.
 1.230 11-Jan-2011  jruoho Disable all GPEs when entering S5. Also add a comment that the function
acpi_enter_sleep_state() must be called with interrupts enabled.
 1.229 06-Jan-2011  jruoho Split the code that makes a string from ACPI_DEVICE_INFO::Name to a function.
 1.228 06-Jan-2011  jruoho Move the ACPI_ACTIVATE_DEV block around for clarity.
 1.227 05-Jan-2011  jruoho Adjust previous slightly.
 1.226 05-Jan-2011  jruoho Make a two-pass scan for acpinodebus. This should ensure that devices such
as acpiec(4) are attached before anything else. Numerous bugs are expected
to be fixed with this change.
 1.225 03-Jan-2011  jruoho Scan for devices that are "hot-pluggable".
 1.224 02-Jan-2011  jruoho Use "real" device names for the hw.acpi.wake and hw.acpi.power sysctl(8)
trees. For instance, instead of hw.acpi.wake.DURT, we have hw.acpi.wake.wm0
for wm(4). This is a temporary solution, but without solving the big
abstraction questions, this is the best we can do.
 1.223 31-Dec-2010  jruoho Move the ACPI sleep-specific sysctl variables to hw.acpi.sleep. The old
machdep-variables are provided for backwards compatibility (eventually these
should be removed). All ACPI sysctl variables are now under hw.acpi.
 1.222 24-Oct-2010  jruoho Simplify acpi_enter_sleep_state() and guard it against NULL pointer
dereferences. Try to avoid referencing the global acpi_softc, which should
really be static or at least internal to acpi(4).
 1.221 12-Oct-2010  gsutre Merge ACPI display driver. Provides generic support for brightness
control and output switching, through ACPI video extensions.

TODO: use wsconsctl(8) instead of sysctl(8) for brightness control.

ok jruoho@
also discussed with cegger@ and jmcneill@
 1.220 02-Oct-2010  gsutre Drop _HID requirement for attachment under acpi(4). From now on,
drivers attaching to the acpinodebus interface should not assume
that the passed acpi_devnode has a valid _HID.

ok jruoho@
 1.219 06-Sep-2010  jmcneill Add support for blacklisting ACPI BIOS implementations by year. By default,
don't use ACPI on BIOS which advertise release years <= 2000. This
can be changed by setting option ACPI_BLACKLIST_YEAR=0 or by setting
acpi_force_load=1.
 1.218 24-Aug-2010  pgoyette Initialize acpi_force_load so that it gets allocated in the data segment
rather than BSS. This lets you change its value with 'gdb --write'.

OK jruoho@
 1.217 22-Aug-2010  jmcneill Don't put devices in the ignored IDs list just because no driver exists.
 1.216 21-Aug-2010  pgoyette Update the various xxx_verbose modules to conform to the module subsystem's
new locking protocol.
 1.215 09-Aug-2010  gsutre acpi_pcidev_scan: attach PCI information only to working devices.

ok jruoho@
 1.214 07-Aug-2010  jruoho Do not try to disable ACPI if we can not enter to legacy mode. While it is
safe to call AcpiDisable() even if a system operates only in ACPI mode, this
leads to unpleasantly verbose error messages in ACPICA.
 1.213 07-Aug-2010  jruoho Fix build failure.
 1.212 07-Aug-2010  jruoho Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.
 1.211 06-Aug-2010  jruoho Simplify the acpiverbose module.
 1.210 06-Aug-2010  jruoho Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.209 06-Aug-2010  jruoho Fix prototypes; SYSCTLFN_ARGS -> SYSCTLFN_PROTO.
(These things really only obscure the code.)
 1.208 25-Jul-2010  pgoyette Move setting of acpi_verbose_loaded flag into the module's init routine.
This ensures that the flag is set even if the module was manually loaded
by the user rather than just auto-loaded.
 1.207 18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.206 10-Jul-2010  jruoho Export the wrapper functions that read from the ACPI PM timer.
Needed for ACPI CPUs. Also KNF, cosmetics. No functional change.
 1.205 02-Jul-2010  jruoho Remove PNP0C01 and PNP0C02 from the list of ignored HIDs (and CIDs).

Fixes PR kern/42937 from Ryo Onodera.

As acpi_match_hid() matches also "compatible IDs" (CIDs), we must be careful
when adding devices to this list. For example, the above PR revealed that
the following is a fairly typical way to define the HPET device:

Device (HPET)
{
Name (_HID, EisaId ("PNP0103"))
Name (_CID, EisaId ("PNP0C01"))
...

Arguably this is a BIOS bug, given that PNP0C01 and PNP0C02 should uniquely
identify a device (or a resource template) that has nothing to do with HPET.
 1.204 02-Jul-2010  jruoho Simplify a little by removing the redundant acpi_rescan1().
 1.203 10-Jun-2010  jruoho A small nit from the spec: _PSW should be called after _PTS. Thus call the
wakedev routine after AcpiEnterSleepStatePrep(). Unlikely to make any
difference whatsoever, but there might always be a BIOS writer who disagrees.
 1.202 07-Jun-2010  jruoho Use the new ACPICA functions AcpiAttachData() and AcpiGetData() to associate
all "struct acpi_devnodes" to their corresponding ACPI_HANDLEs. Anywhere in
the acpi(4) subtree, the node-structure can be obtained from a handle via
acpi_get_node(). The idea is similar to e.g. device_private().

Benefits: (a) simplifies code, (b) avoids issues with locking as ACPICA does
the serialization for us, (c) avoids the need to access the glocal softc, and
(d) avoids the O(n) loop required to search for a handle from the node queue.
 1.201 07-Jun-2010  jruoho Build the power resource queue dynamically. This eliminates the need to call
acpi_power_res_add() in the main scan function, also saving few bytes of
memory.
 1.200 07-Jun-2010  pgoyette Update acpiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.199 06-Jun-2010  jruoho Although sysmon_pswitch_unregister(9) does not currently do anything, in
order to be ready for possible future API changes, call it if we failed to
install the fixed event handlers. Also small ACPI_DEBUG_PRINT clarifications.
 1.198 05-Jun-2010  jruoho Remove trailing white space.
 1.197 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.196 23-May-2010  christos no need for double the newlines!
 1.195 12-May-2010  jruoho When scanning the device "capabilities" (power, wake-up, etc.),
include all device nodes, regardless of the status of the device.

XXX: It is known that some systems implement the _STA method incorrectly.
If needed in the future, attachment based on the values from this
method may need revisiting. Same goes for ACPI_ACTIVATE_DEV.
 1.194 27-Apr-2010  jruoho Make acpi_enter_sleep_state() not to return. No one cared what it returned.
 1.193 27-Apr-2010  jruoho Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.
 1.192 26-Apr-2010  jruoho Move the ACPIVERBOSE blocks to a single place.

Also print non-devices in the EISAID/HID/UID/ADR-block
 1.191 25-Apr-2010  jruoho Return instead of breaking out if the sleep state is not available.
 1.190 25-Apr-2010  jruoho As noted by jmcneill@, the specifications specifically mention that the _TTS
should be invoked before the system has notified any native mode device
drivers. Thus, do the call before pmf_system_suspend(9).
 1.189 25-Apr-2010  jruoho Evaluate _TTS on sleep state transitions. This is mainly to pro-actively
support some weird BIOS, which may require the evaluation. Ok jmcneill@.
 1.188 25-Apr-2010  jruoho Add a note about AcpiEnterSleepStatePrep().
 1.187 24-Apr-2010  jruoho Embarrassing typos: _PI_ -> _SI_, _PB_ -> _SB_.
 1.186 24-Apr-2010  jruoho Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it).
 1.185 24-Apr-2010  jruoho Fix a bug involving acpitz(4) accidentally attaching to the _TZ_ scope.

This in turn was caused by a bug in ACPICA, which reports the types of _SB_
and _TZ_ scopes incorrectly for its own internal reasons (utglobal.c):

/*
* Predefined ACPI Names (Built-in to the Interpreter)
*
* NOTES:
* 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
* during the initialization sequence.
* 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
* perform a Notify() operation on it.
*/

Thanks to cegger@ for noticing the bug and testing a fix.
 1.184 23-Apr-2010  jruoho Add hw.acpi.power sysctl-node.
 1.183 23-Apr-2010  jruoho Make the ACPIVERBOSE output even prettier by removing cruft.
 1.182 22-Apr-2010  jruoho Some pretty printing for ACPIVERBOSE.
 1.181 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.180 22-Apr-2010  jruoho From Gregoire Sutre: rework the ACPI PCI support. This makes ACPI to
correctly pick PCI segment groups, PCI bus numbers, PCI root bridges,
PCI-to-PCI bridges, and PCI devices, among other things. In short: it is
more robust than the old code or anything in sys/arch/x86/x86/mpacpi.c.

ok cegger@, jmcneill@
 1.179 20-Apr-2010  jruoho Remove the block where the default address space handlers were manually
installed via AcpiInstallAddressSpaceHandler(). This was already commented
out because ACPICA does this for us when ACPI_NO_ADDRESS_SPACE_INIT is not
specified when calling AcpiEnableSubsystem().
 1.178 20-Apr-2010  jruoho Instruct ACPICA to dynamically allocate the table descriptions in
AcpiInitializeTables() instead of pushing 128 statically allocated
descriptors. This will eliminate also the need to call
AcpiReallocateRootTable().

The rationale for the statically allocated table descriptors is to allow
initialization without virtual/dynamic memory. Later these should be copied
to dynamic memory via AcpiReallocateRootTable(). But since in NetBSD both
functions were called in the very same acpi_probe(), this dance was
completely unnecessary.
 1.177 18-Apr-2010  jruoho Remove a duplicate variable assignment.
 1.176 18-Apr-2010  jruoho From Gregoire Sutre:

Modify the main ACPI namespace scan by including a parent-child
relationship for each node. The result is a bi-directional tree.

ok jmcneill@
 1.175 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.174 15-Apr-2010  jruoho Arrange some comments.
 1.173 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.172 14-Apr-2010  jruoho Simplify error reporting, remove casts, KNF.
 1.171 14-Apr-2010  jruoho Remove the code that was copy-pasted to acpi_detach() from the attachment
routine. Add a note that the detachment is incomplete.
 1.170 14-Apr-2010  jruoho Remove the #if 0'ed acpi_disable().
 1.169 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.168 14-Apr-2010  jruoho Refactor the fixed-event handlers.

Also provide a detachment routine for these and fix a trivial bug;
a wrong structure was used when registering a sysmon_pswitch(9) switch.
 1.167 12-Apr-2010  jruoho Scan the namespace from the root object instead of scanning from separate
scopes. Also raise the namespace walk from 100 (per scope) to UINT32_MAX.

ok jmcneill@
 1.166 12-Apr-2010  jruoho Remove some unused and global variables. Make the code more readable. Deny
invalid writes to machdep.sleep_state. Cosmetics. No functional change.
 1.165 12-Apr-2010  jruoho Rework the sysctl-support.

Changes:

hw.wake -> hw.acpi.wake
hw.acpi.debug_layer -> hw.acpi.debug.layer
hw.acpi.debug_level -> hw.acpi.debug.level

Additions:

hw.acpi.stat.gpe # Number of dispatched GPEs
hw.acpi.stat.sci # Number of SCI interrupts
hw.acpi.stat.fixed # Number of fixed events
hw.acpi.stat.method # Number of executed methods

ok jmcneill@
 1.164 08-Apr-2010  jruoho ACPICA 20091112:

Implemented a post-order callback to AcpiWalkNamespace. The existing
interface only has a pre-order callback. This change adds an
additional parameter for a post-order callback which will be more
useful for bus scans. ACPICA BZ 779. Lin Ming. Updated the ACPICA
Programmer Reference.

We will use the old "pre-order callback" for the time being.
 1.163 29-Mar-2010  dyoung Attach acpiecdt with acpibus_attach_args. Sverre Froyen reports that
this helps his Thinkpad boot again.
 1.162 22-Mar-2010  jruoho Add IFX0102 and PNP0C15. Fix INT0800.

Observed from the dmesg of njoly@'s Sony VAIO VGN-BZ12VN.
 1.161 16-Mar-2010  jruoho Remove the call to AcpiGetType() in acpi_make_devnode(). This is the same
information as ACPI_DEVICE_INFO::Type, obtained later by AcpiGetObjectInfo().
 1.160 16-Mar-2010  jruoho With the intent of making 'struct acpi_devnode' as the central place for
information related to ACPI device nodes: (a) introduce a generic scan
function for ACPI device driver "capabilities", and (b) eliminate local data
structures from ACPI wake-devices. Discussed with jmcneill@.
 1.159 10-Mar-2010  jruoho branches: 1.159.2;
Move the ACPI_ACTIVATE_DEV block to one place. While there, provide missing
prototype for a function, try to make the code more simple, guard against a
potential NULL pointer dereference, and improve printing.

No functional change intended.
 1.158 10-Mar-2010  jruoho Some pretty printing for ACPIVERBOSE.
 1.157 09-Mar-2010  jruoho Remove the namespace scopes.

These are neither used nor useful beyond the parser and interpreter.

ok jmcneill@, joerg@
 1.156 05-Mar-2010  jruoho Preparing a device for wakeup involves:

(a) turning on all power resources required by the device; and
(b) executing _DSW (or _PSW) control method.

This implements (b). Ok jmcneill@.
 1.155 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.154 04-Mar-2010  jruoho Remove ACPI_BUT_DEBUG by using ACPI_DEBUG_PRINT(x) instead.
 1.153 04-Mar-2010  jruoho Fix ACPI_DEBUG build failures reported by Greg A. Woods.
 1.152 03-Mar-2010  jruoho Convert the single instance of ACPI_EXTRA_DEBUG to ACPIVERBOSE.
 1.151 03-Mar-2010  jruoho Refactor acpi_make_devnode() to make it a little more readable.

No functional change intended.
 1.150 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.149 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.148 31-Jan-2010  jruoho branches: 1.148.2;
Add dynamic debug options for ACPI_DEBUG kernels.

ok jmcneill@, pooka@, pgoyette@
 1.147 18-Jan-2010  jruoho Fix and improve several comments.
 1.146 18-Jan-2010  jruoho Introduce acpi_eval_reference_handle() --

an utility function to evaluate reference handles from package elements.

ok jmcneill@, pgoyette@
 1.145 18-Jan-2010  jruoho Ensure that the return string is NUL-terminated in acpi_eval_string().

ok jmcneill@, pgoyette@
 1.144 12-Jan-2010  jruoho Properly evaluate the _PRW object in case we have a package inside a
package.

ok jmcneill@
 1.143 09-Jan-2010  jruoho Add "ACPI fans" to the list of ignored HIDs, as discussed on port-i386@.
 1.142 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.141 08-Jan-2010  dyoung Move all copies of ifattr_match() to sys/kern/subr_autoconf.c.
 1.140 05-Jan-2010  jruoho Use acpi_eval_struct() to simplify code.

ok pgoyette@, jmcneill@
 1.139 31-Dec-2009  jruoho Remove unused locking variables.

ok pgoyette@, jmcneill@
 1.138 31-Dec-2009  jruoho Add Intel HW Random Number Generator to the list of ignored HIDs.

ok pgoyette@, jmcneill@
 1.137 03-Dec-2009  cegger Enumerate ACPI PCI devices. Allows to link PCI with ACPI devices.
Patch presented on tech-kern@
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

'nice work' Jukka Ruohonen
 1.136 29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.135 28-Nov-2009  cegger initialise -> initialize
unabled -> unable
wrap long line
 1.134 14-Nov-2009  cegger use __arraycount
 1.133 16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.132 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.131 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.130 23-Aug-2009  jmcneill When ACPI is not present, free any resources used by the ACPICA. Also,
no need to complain (unless we're debugging) that ACPI is not present.
 1.129 18-Aug-2009  cegger Update for API changes with new ACPICA.
Makes i386 ALL kernel build.
 1.128 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.127 04-Aug-2009  jmcneill add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.126 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.125 08-Apr-2009  joerg sprintf -> snprintf
 1.124 08-Apr-2009  dyoung Refactor slightly to create acpi_rescan(), a hook for rescanning the
devices that attach at acpi(4).

Begin deriving an acpi(4) device-detachment hook, acpi_detach(), from
acpi_attach(). The code between #if 0 and #endif still needs to be
turned to the opposite calls (enables to disables, maps to unmaps,
attaches to detaches), which should be run in the opposite order.
Somebody with deep ACPI knowledge can probably finish this off without
too much trouble.
 1.123 30-Jan-2009  jmcneill branches: 1.123.2;
PR# kern/38817: regression in acpi sleep on lifebook S6510

Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.122 03-Jan-2009  yamt remove extra semicolons.
 1.121 07-Dec-2008  mlelstv Handle printing of _STR attribute with non-string data type gracefully.
 1.120 19-Sep-2008  jmcneill branches: 1.120.2; 1.120.4;
Revert previous.
 1.119 10-Sep-2008  jmcneill PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.
 1.118 15-Jul-2008  dyoung Introduce acpi_clear_wake_gpe() to undo acpi_set_wake_gpe().
Extract common code from acpi_clear_wake_gpe() and acpi_set_wake_gpe(),
creating acpi_wake_gpe_helper().
 1.117 01-Jun-2008  joerg branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.
 1.116 17-May-2008  jmcneill For device nodes that we handle internally, do not bother calling
config_found_ia on the node to save a bunch of useless 'device NNN
not configured' messages at startup. While here, condense ACPI printfs
at attach time.
 1.115 28-Apr-2008  martin branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses
 1.114 20-Apr-2008  jmcneill branches: 1.114.2;
Improve error reporting when we fail to enter a sleep state, eg:

acpi0: entering state 1
acpi0: ACPI S1 not available on this platform
 1.113 27-Mar-2008  jmcneill branches: 1.113.2;
Split device_t and softc
 1.112 12-Mar-2008  dyoung Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.111 10-Mar-2008  dyoung Use device_t and accessors. Use aprint_*_dev().

Add a method for detaching children. XXX acpi(4) may leak some
resources for each child detached. Needs attention from someone
who understands acpi(4).
 1.110 09-Mar-2008  jmcneill shutdownhook_establish is deprecated, but instead of converting to pmf,
just delete it as acpi_shutdown was empty.
 1.109 13-Feb-2008  jmcneill branches: 1.109.2; 1.109.6;
Add hw.acpi.supported_states sysctl node:
$ sysctl hw.acpi.supported_states
hw.acpi.supported_states = S0 S3 S4 S5
 1.108 16-Dec-2007  jmcneill Now that ACPI-CA doesn't parse the X/RSDT for us, we need to map it
ourselves.

Before:
acpi0: X/RSDT: OemId < , ,00000000>, AslId < ,00000000>
After:
acpi0: X/RSDT: OemId <LENOVO,TP-7L ,00001260>, AslId < LTP,00000000>

ACPI can now access the X/RSDT using 'acpi_map_rsdt' and 'acpi_unmap_rsdt'.
 1.107 15-Dec-2007  jmcneill Restore acpi_quirk functionality, lost in the latest ACPI-CA update.
 1.106 14-Dec-2007  jmcneill Introduce pmf_system_bus_resume. In the ACPI S3 resume path, use this to
separate powering up devices from restoring their state. This is required
on some machines where AcpiLeaveSleepState can fail due to an attempt to
access a powered off device.
 1.105 10-Dec-2007  reinoud Add missing \n and remove surplus .
 1.104 09-Dec-2007  jmcneill branches: 1.104.2;
Merge jmcneill-pm branch.
 1.103 05-Dec-2007  ad branches: 1.103.2;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.102 08-Aug-2007  cube branches: 1.102.2; 1.102.8; 1.102.10;
Print ACPI device name in a way that Jared McNeill and I find prettier.
I like it better because I get to see the name of the device as it appears
in the DSDT, which sometimes makes sense and that way it's easier to locate
the relevant code when debugging.

E.g.:

PIC (PNP0000) [AT Interrupt Controller] at acpipcib0 not configured
DMAD (PNP0200) [AT DMA Controller] at acpipcib0 not configured
attimer0 at acpipcib0 (TMR, PNP0100): AT Timer
RTC0 (PNP0B00) [AT Real-Time Clock] at acpipcib0 not configured
pckbc0 at acpipcib0 (PS2K, PNP0303): kbd port
acpibat0 at acpi0 (BAT0, PNP0C0A-0): ACPI Battery (Control Method)
 1.101 19-Feb-2007  ad branches: 1.101.4; 1.101.12; 1.101.16;
Initialize acpi_interrupt_list_mtx in acpi_probe().
 1.100 18-Feb-2007  xtraeme Replace a simple_lock with a mutex, reviewed by ad@.
 1.99 09-Feb-2007  ad branches: 1.99.2;
Merge newlock2 to head.
 1.98 26-Nov-2006  cube Introduce acpi_check() to inform the caller whether the acpi driver is
still enabled, as it could have been disabled through USERCONF.

Use it in amd64 and i386 mainbus code and skip all ACPI processing in case
it is disabled.
 1.97 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.96 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.95 26-Sep-2006  jmcneill When resuming from S1 standby, don't try to release a mutex that we hadn't
previously acquired.
 1.94 06-Aug-2006  christos branches: 1.94.4; 1.94.6;
PR/34116: Takuya SHIOZAKI: acpiapm(4) misuses config(9)
acpiapm(4) always matches the first node of AML, which is unrelated
with acpiapm. Separate acpi(4)'s children into two individual interface
attributes.
 1.93 04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.92 01-Jul-2006  christos - use aprint instead of printf.
- centralize all the suspend/resume glue in one function.
 1.91 24-Jun-2006  tsarna fix typo: idicator -> indicator
 1.90 21-Jun-2006  drochner First cut on an implementation of an ACPI power management counter
backend for timecounters.
Due to known bugs in some chipsets, always read until we get 3 successive
samples which are monotonic, as FreeBSD does in its "safe" variant.
This can be refined later, either by chipset quirks or by a test (as
FreeBSD does).
 1.89 20-Jun-2006  cube When we consume a resource definition from _PRS, advance to the next one.
Otherwise, if there are two resources definitions of the same type in _CRS,
the same one from _PRS will be used twice, which of course leads to errors.

Note: _PRS is Possible Resources Set
_CRS is Current Resources Set

XXX acpi_allocate_resources is still very weak, e.g. it completely ignores
StartDependentFn entries which are kind of a switch. But at least it's
slightly better that way.

Tested by jmcneill@.
 1.88 19-Jun-2006  jmcneill acpi_pci_fixup didn't work as well as I had hoped; don't bother for now.
 1.87 19-Jun-2006  jmcneill Fixup PCI interrupt routing using ACPI tables on return from S3 sleep.
Requires options PCI_INTR_FIXUP in your kernel.
 1.86 15-Jun-2006  jmcneill EXPERIMENTAL: Add sysctl for triggering ACPI sleep. This interface is not
stable, so do not depend on it!

To trigger sleep:
# sysctl -w machdep.sleep_state=<n>
Where <n> is typically 1 (standby), 3 (suspend), or 4 (hibernate).
 1.85 26-Feb-2006  cube branches: 1.85.2; 1.85.8; 1.85.10;
Resource lists end with END_TAG, not END_DEPENDENT. Makes the
PCI_INTR_FIXUP code "work" again.

Most of the time it will produce a warning about a misaligned resource
pointer, but it's harmless, and the warning was removed in the next version
of the ACPI-CA code.
 1.84 23-Feb-2006  wiz Fix typo in aprint argument.
 1.83 20-Feb-2006  kochi use aprint_*
 1.82 16-Feb-2006  kochi define acpi_dbgr as static
 1.81 31-Jan-2006  kochi branches: 1.81.2; 1.81.4;
remove ACPI_DISABLE_ON_POWEROFF option, which was there just for
compatibility of our old driver behavior, which is not necessary.
 1.80 29-Jan-2006  kochi adapt for ACPI-CA 20060113
 1.79 13-Dec-2005  cube branches: 1.79.2;
machdep.acpi_root -> hw.acpi.root, as discussed on source-changes.
 1.78 12-Dec-2005  cube Move the (one liner) logic of AcpiOsGetRootPointer() out of acpica/Osd to
acpi.c and take the opportunity to create a sysctl node that contains the
address of the main ACPI table.

The name of the node, "machdep.acpi_root", is questionable but matches the
one FreeBSD has, which will make it easier to port their acpidump(8)
program.
 1.77 11-Dec-2005  christos merge ktrace-lwp.
 1.76 30-Jun-2005  sekiya branches: 1.76.2;
Fix up interrupt line when line == 0. Discussed with christos@
 1.75 30-Jun-2005  christos There is an error when we return -1, not < 1.
 1.74 21-Jun-2005  sekiya Likewise, ACPI_PCI_FIXUP has been replaced by PCI_INTR_FIXUP, and we should
notify when an old kernel config is used. Recommended by wiz@
 1.73 21-Jun-2005  sekiya Rework the configuration scheme for PCI fixups:

* bus enumeration fixups are not PCIBIOS-specific, interrupt fixups are done
by both PCIBIOS and ACPI. The redundancy is very redundant. Therefore,
rename PCIBIOS_*_FIXUP to PCI_*_FIXUP, use PCI_INTR_FIXUP in place of
ACPI_PCI_FIXUP, and change code refences to match.

* move the fixup defines from opt_pcibios.h to opt_pcifixup.h to reflect
the above.

* fix up the PCI bus numbering in mainbus_attach(), right after we detect the
configuration mode. This probably renders the fixup in pcibios.c
redundant -- but it should be harmless.

These changes make cardbus work in ACPI-only machines, when PCI_BUS_FIXUP
and PCI_INTR_FIXUP are defined.
 1.72 20-Jun-2005  sekiya Also fix up interrupt line if interrupt is zero, as well as 255. Fixes
interrupt issues on two of my laptops that lack PCIBIOS.
 1.71 31-May-2005  drochner lots of cast-qual fallout
 1.70 29-May-2005  christos Sprinkle const freely and delete unnecessary casts.
 1.69 02-May-2005  kochi Merge changes for ACPI-CA 20050408
 1.68 27-Feb-2005  perry nuke trailing whitespace
 1.67 30-Aug-2004  drochner branches: 1.67.4; 1.67.6;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.66 07-Jun-2004  kochi Add ACPI_DISABLE_ON_POWEROFF option.
Note: the default behavior is changed. Now we don't disable the ACPI
subsystem on power off (halt -p) by default.
'options ACPI_DISABLE_ON_POWEROFF' in a kernel config file makes the kernel
behave the way we used to be.
 1.65 26-May-2004  kochi ThermalZone improvement work by lha at stacken.kth.se, inspired from
FreeBSD thermal zone code. Minor style fixes and bugfixes by me.
 1.64 01-May-2004  kochi specify static where appropriate.
 1.63 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.62 10-Apr-2004  kochi whitespace nit
 1.61 31-Mar-2004  tron Only call acpiec_early_attach() in "acpi.c" if the kernel is configured
to include the "acpiec" device.
 1.60 30-Mar-2004  kochi Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.59 23-Mar-2004  drochner branches: 1.59.2;
some int->ACPI_INTEGER to make it compile on amd64 again
 1.58 23-Mar-2004  kochi Don't use ACPI CA internal functions
 1.57 03-Nov-2003  mycroft Use pmatch() so that we can use patterns.
 1.56 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.55 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.54 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.53 01-Nov-2003  mycroft One more spot for a structure change.
 1.52 01-Nov-2003  yamt make this compilable again with ACPI_DEBUG.
 1.51 01-Nov-2003  mycroft Do not install address handlers before calling AcpiEnableSubsystem() -- this
is done by AcpiInitializeObjects() anyway.
 1.50 01-Nov-2003  mycroft Update copyright.
 1.49 01-Nov-2003  mycroft Move a declaration.
 1.48 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.47 31-Oct-2003  mycroft We were passing flags to AcpiEnableSubsystem() that aren't even used there.
Call AcpiInitializeObjects() to create global variables and run _INI methods.
 1.46 30-Oct-2003  mycroft Use AcpiEvulateObjectTyped() to simplify some code.
 1.45 30-Oct-2003  mycroft Check to see if we have valid status info before looking at it.
 1.44 30-Oct-2003  mycroft Remove another extra AcpiGetObjectInfo().
 1.43 30-Oct-2003  mycroft Minor tweaks:
* Only fetch the object info a second time if we activated the device.
* Do not attempt to activate a device with no HID.
 1.42 17-Aug-2003  kochi check return value of AcpiEnterSleepStatePrep() to catch
any failure
 1.41 06-Jul-2003  kochi make bootup messages prettier
 1.40 06-Jul-2003  kochi o cleanup usage of ACPI_ACTIVATE_DEV/ACPI_PCI_FIXUP
o delete usage of ENABLE_DEBUGGER

As ACPI_ACTIVATE_DEV/ACPI_PCI_FIXUP are defflag'ed in files.acpi,
these options don't have to have a value.
 1.39 03-Jul-2003  kochi Cleanup usage of ENABLE_DEBUGGER/ACPI_DEBUGGER/DDB.

By this change, ACPI debugger/disassembler are only
compiled when both DDB and ACPI_DEBUG options are
specified. This change also reduces the kernel size
a little when ACPI_DEBUG is not specified.
 1.38 02-Jul-2003  kochi cleanup usage of ACPI_ALLOCATE_BUFFER/AcpiOsFree combination
 1.37 02-Jul-2003  kochi print ACPI CA version
 1.36 15-May-2003  fvdl branches: 1.36.2;
Add quirk handling to ACPI. First quirk entry is "PTLTD " rev 0x06040000,
which gives problems with PCI bus finding; the object hierarchy doesn't
match the real world for some systems, most notably SuperMicro boards.
Linux has this one blacklisted as well.
 1.35 18-Apr-2003  thorpej * Add a generic power management event API, defined in <sys/power.h>.
Right now, only power switch state change events are supported. This
is a work-in-progress.
* Add support to sysmon for delivering power mangement events to userland.
Add poll, kqueue, and read entry points to sysmon.
* Adapt ACPI to use the new generic <sys/power.h> event types.

This provides the kernel support for a forthcoming powerd(8) which can
do nice things like gracefully shut the system down when an ACPI power
button is pressed.
 1.34 17-Apr-2003  thorpej * Don't do the ACPI_PCI_FIXUP unless it is explicitly enabled in
the kernel config file. That code makes a total mess of any
system with multiple PCI busses.
* Rework the way buttons are handled; register them with sysmon,
and let it take the appropriate action. This lets us gracefully
shut down when the power button is pressed.
 1.33 05-Mar-2003  christos use M_ACPI where appropriate.
 1.32 14-Feb-2003  tshiozak - add acpi_acquire_global_lock()/acpi_release_global_lock()/
acpi_is_global_locked() functions.
AcpiGlobalLock() API should be used to acquire lock between BIOS and OS.
This API cannot be used to lock between threads of the OS side,
because this function immediately returns if the lock is already acquired
by the OS. c.f. AcpiEvAcquireGlobalLock()@evmisc.c

- make sure that acpiec driver uses above functions.

- use ACPI_ALLOCATE_BUFFER instead of twice calls of AcpiEvaluateObject(),
in acpi_eval_string()/acpi_eval_struct().
Twice AcpiEvaluateObject() calls may cause twice side effects
to ACPI machine / hardware and this may be wrong in some cases.
 1.31 13-Jan-2003  fvdl Use 'int' in the SCI interrupt message, not 'irq'. The number in question
is a global ACPI interrupt number.
 1.30 09-Jan-2003  jdolecek use AcpiUtGetTypeName() to print object type name in acpi_print()
 1.29 08-Jan-2003  fvdl Print some OEM version info for the R/XSDT. Can be used to help identify
buggy ACPI implementations.
 1.28 07-Jan-2003  fvdl * Add aux argument to functions called from apic_madt_walk
* Improve acpi interrupt fixup a bit
* Source is an array, don't compare it to NULL, instead
look for an empty string to denote a link-device-less
entry.
* For root PCI busses, try to use the _BBN method to get
numbering right.
* Add acpi_md_callback() function for MD handling after the init,
but before * at acpi probing.
 1.27 05-Jan-2003  christos add ACPIVERBOSE; while I am there, fix the eval_string function so it does
not leak.
 1.26 05-Jan-2003  jmcneill Print something a bit more informative when displaying 'not configured'
messages for objects without a valid HID.
 1.25 04-Jan-2003  jmcneill Attempt to attach drivers to devices without a valid HID so long as they're
not of type ACPI_TYPE_DEVICE.
 1.24 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.23 31-Dec-2002  augustss Fix some messages and some formatting.
 1.22 31-Dec-2002  jmcneill If we have a valid UID but it's a null string, display '<null>' rather than
nothing at all.
 1.21 30-Dec-2002  matt Print out the pnpname that was matched.
 1.20 30-Dec-2002  jmcneill Allow ACPI_EXTRA_DEBUG without ACPI_DEBUG
 1.19 28-Dec-2002  jmcneill Pass ISA chipset information through to ACPI devices, to allow for porting
of pnpbios(4) glue to acpi(4).
 1.18 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.17 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.16 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.15 29-Jul-2002  augustss Add code to activate devices that are no active.
 1.14 29-Jul-2002  augustss Only be very verbose with ACPI_EXTRA_DEBUG set.
 1.13 29-Jul-2002  augustss Add code to perform PCI interrupt routing fixup.
 1.12 18-Jul-2002  kanaoka - Disable Interrput before execute AcpiEnterSleepState().
- Add acpi_md_OsDisableInterrupt() for this.
 1.11 18-Jun-2002  drochner make it compile with ACPI_DEBUG
 1.10 18-Jun-2002  tshiozak add MI part of ACPI sleep state transition code.
However, we have no interface to use it, and we also need device driver
support. (e.g. D2/D3 support for PCI)
 1.9 17-Jun-2002  kanaoka - Show SCI interrupt information.
- Remove ACPI_STA_DEV_SHOW from device check in acpi_build_tree().
 1.8 15-Jun-2002  thorpej Update for acpica-unix-20020612. From Takayoshi Kochi.
 1.7 24-Mar-2002  sommerfeld branches: 1.7.2;
Add acpi_eval_struct, to evaluate a complex data structure.

#if 0-out a half-fixed acpi_eval_string() and #if 0 the only call to it.
(Previous code referenced an uninitialized local variable and couldn't
have possibly worked).
 1.6 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.5 13-Nov-2001  lukem branches: 1.5.2;
add RCSID
 1.4 29-Sep-2001  thorpej branches: 1.4.2; 1.4.4;
- Add an acpi_evaluate_string() to evaluate string objects.
- In acpi_print(), try to evaluate the _STR object, and print
it if the device is not configured.
- Make this compile without ACPI_DEBUG, from Masanori Kanaoka.
 1.3 29-Sep-2001  thorpej Don't install a single system notify handler.
 1.2 29-Sep-2001  thorpej Add code to parse ACPI bus resources.
 1.1 28-Sep-2001  thorpej Add some basic ACPI probing framework. This is far from complete,
it is merely a work in progress.
 1.4.4.13 15-Jan-2003  thorpej Sync with HEAD.
 1.4.4.12 08-Jan-2003  thorpej Sync with HEAD.
 1.4.4.11 07-Jan-2003  thorpej Sync with HEAD.
 1.4.4.10 03-Jan-2003  thorpej Sync with HEAD.
 1.4.4.9 29-Dec-2002  thorpej Sync with HEAD.
 1.4.4.8 18-Oct-2002  nathanw Catch up to -current.
 1.4.4.7 01-Aug-2002  nathanw Catch up to -current.
 1.4.4.6 20-Jun-2002  nathanw Catch up to -current.
 1.4.4.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.4.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.4.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.4.4.1 29-Sep-2001  nathanw file acpi.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.4.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.4.2.1 29-Sep-2001  fvdl file acpi.c was added on branch thorpej-devvp on 2001-10-01 12:44:14 +0000
 1.5.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.5.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.1 13-Nov-2001  thorpej file acpi.c was added on branch kqueue on 2002-01-10 19:52:51 +0000
 1.7.2.4 29-Aug-2002  gehenna catch up with -current.
 1.7.2.3 20-Jul-2002  gehenna catch up with -current.
 1.7.2.2 15-Jul-2002  gehenna catch up with -current.
 1.7.2.1 20-Jun-2002  gehenna catch up with -current.
 1.36.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.36.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.36.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.36.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.36.2.2 03-Sep-2004  skrll Sync with HEAD
 1.36.2.1 03-Aug-2004  skrll Sync with HEAD
 1.59.2.3 14-Jun-2004  jmc Pullup patch (requested by kochi in ticket #463)

Add ACPI_DISABLE_ON_POWEROFF option. PR#24869
 1.59.2.2 28-Apr-2004  jmc Pullup rev 1.61 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.59.2.1 28-Apr-2004  jmc Pullup rev 1.60 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.67.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.67.4.1 29-Apr-2005  kent sync with -current
 1.76.2.8 17-Mar-2008  yamt sync with head.
 1.76.2.7 27-Feb-2008  yamt sync with head.
 1.76.2.6 21-Jan-2008  yamt sync with head
 1.76.2.5 07-Dec-2007  yamt sync with head
 1.76.2.4 03-Sep-2007  yamt sync with head.
 1.76.2.3 26-Feb-2007  yamt sync with head.
 1.76.2.2 30-Dec-2006  yamt sync with head.
 1.76.2.1 21-Jun-2006  yamt sync with head.
 1.79.2.3 01-Mar-2006  yamt sync with head.
 1.79.2.2 18-Feb-2006  yamt sync with head.
 1.79.2.1 01-Feb-2006  yamt sync with head.
 1.81.4.1 22-Apr-2006  simonb Sync with head.
 1.81.2.1 09-Sep-2006  rpaulo sync with head
 1.85.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.85.8.1 19-Jun-2006  chap Sync with head.
 1.85.2.2 11-Aug-2006  yamt sync with head
 1.85.2.1 26-Jun-2006  yamt sync with head.
 1.94.6.2 10-Dec-2006  yamt sync with head.
 1.94.6.1 22-Oct-2006  yamt sync with head
 1.94.4.3 06-Feb-2007  ad Quieten noisy boot messages.
 1.94.4.2 12-Jan-2007  ad Sync with head.
 1.94.4.1 18-Nov-2006  ad Sync with head.
 1.99.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.101.16.27 09-Dec-2007  jmcneill Sync with HEAD.
 1.101.16.26 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.101.16.25 02-Dec-2007  joerg Don't wait one second before suspend, drivers should wait as long as
they have to themselve.
 1.101.16.24 14-Nov-2007  joerg Introduce pnp_system_shutdown which just complains if drivers don't
support the PNP framework, give the user 2 seconds to worry about that
and runs the class and driver suspend functions. Keep all devices
powered e.g. to allow deciphering messages from the screen.
Drop the argument to pnp_system_suspend now that the use for it is gone.
 1.101.16.23 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.101.16.22 28-Oct-2007  joerg Non-device nodes (e.g. Thermal Zones, Processors) can be valid without
HID, don't skip them.
 1.101.16.21 13-Oct-2007  joerg Move ACPI_EVENT_POWER_BUTTON reset into acpi_md_sleep. Add splhigh
guards around the x86_disable_intr/x86_enable_intr calls for the moment
until it is clear where the interrupts are incorrectly reenabled.
 1.101.16.20 04-Oct-2007  joerg Require the HID only for normal devices. Other types can be used without
HID easily, e.g. Thermal Zones.
 1.101.16.19 03-Oct-2007  jmcneill Fix merge botch from acpica update.
 1.101.16.18 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.101.16.17 02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.101.16.16 30-Sep-2007  joerg Change ACPI and IOAPIC initialisation to better deal with early
interrupts.

(a) Split the ACPI subsystem initialisation into the hardware init and
ACPI enabling on the one side and the event and SCI setup on the other
side. Process the ACPI interrupt tables in between. Strictly speaking is
this a violation of the ACPI specs as the switch to APIC mode requires
evaluation of an ACPI object and that could depend on the SCI. In
practise, the SCI never worked at this point and before the removal of
the defered setup it wasn't even created.

(b) Always write entries to all IOAPIC pins. The first 16 pins are
threated as ISA IRQs by default, the others like PCI IRQs. This avoids
inconsistencies based on incomplete BIOS setups. This resulted in early
ACPI SCI notifications to be lost, effectively breaking the Embedded
Controller on cold start on many notebooks.

Don't special case the IOAPIC setup between ioapic_attach and
ioapic_enable, always setup the correct redirections. Depend on
splhigh/disable_intr to stop interrupts and don't keep them masked in the
IOAPIC. This avoids unacknowleged edge interrupts and fixing the problem
of broken PS/2 keyboard when hitting keys during early boot.
 1.101.16.15 25-Sep-2007  joerg Make this code a bit easier to follow by duplicating the LeaveSleepState
and merging the !S1 cases of the ifs. Reduce the spl protection to
exactly what it is intended to protect, the race against the power
button.
 1.101.16.14 25-Sep-2007  jmcneill Call AcpiLeaveSleepState before running power handlers again, and wrap
acpi_md_sleep call with splhigh.
 1.101.16.13 24-Sep-2007  joerg Revert previous and expect power handler to do the right thing as
requested by jmcneill@.
 1.101.16.12 24-Sep-2007  joerg Until the various drivers are fixed to handle interrupts correctly,
restore original splhigh during state transitions.
 1.101.16.11 10-Sep-2007  christos Move the call to AcpiLeaveSleepState after pnp_global_transition as suggested
by jmcneill. This makes my vgn-t250p resume properly.
 1.101.16.10 09-Sep-2007  christos Re-order some calls that got mixed up on the previous merge. This makes
my VGN-T250P boot again.
XXX: Might need to be reverted when we merge the new acpica.
 1.101.16.9 07-Sep-2007  joerg Expect acpi_md_sleep to protect itself against interrupts.
This avoids DIAGNOSTIC assertions from within pmap.
 1.101.16.8 23-Aug-2007  joerg From FreeBSD: explicitly load regions first to allow acpi_md_callback
to actually query the routing tables.

Drop the argment to acpi_md_callback, passing around singletons is not
that helpful.
 1.101.16.7 14-Aug-2007  joerg Call the MD ACPI callback before enabling ACPI. This allows
the MD layer to scan the MADT table and in turn allows the
retiring of defering the interrupt setup.
 1.101.16.6 12-Aug-2007  jmcneill * Run suspend power handlers earlier in suspend path, and later on
resume path.
* Give ACPI device drivers a chance to attach to nodes of type
ACPI_TYPE_DEVICE where there is not a valid HID, and silence autoconf
'not configured' messages for ACPI_TYPE_DEVICE nodes where a driver
does not attach and no valid HID is present.
 1.101.16.5 09-Aug-2007  jmcneill Sync with HEAD.
 1.101.16.4 05-Aug-2007  jmcneill Use pnp_generic_power
 1.101.16.3 05-Aug-2007  jmcneill Make sure that we clear fixed power button events on resume. ACPI 3.0 says
we should do this, presumably to work around buggy firmware. Fixes issues
on some machines where when waking with the power button, a power button
event is received by the kernel after resume and the machine will enter
S5 (poweroff) automatically. Fix confirmed by Jukka Salmi on current-users
on a Thinkpad X40.
 1.101.16.2 04-Aug-2007  jmcneill Don't run resume hooks on failure, and certainly don't run them twice.
 1.101.16.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.101.12.1 15-Aug-2007  skrll Sync with HEAD.
 1.101.4.1 20-Aug-2007  ad Sync with HEAD.
 1.102.10.2 26-Dec-2007  ad Sync with head.
 1.102.10.1 08-Dec-2007  ad Sync with head.
 1.102.8.3 18-Feb-2008  mjf Sync with HEAD.
 1.102.8.2 27-Dec-2007  mjf Sync with HEAD.
 1.102.8.1 08-Dec-2007  mjf Sync with HEAD.
 1.102.2.2 23-Mar-2008  matt sync with HEAD
 1.102.2.1 09-Jan-2008  matt sync with HEAD
 1.103.2.1 11-Dec-2007  yamt sync with head.
 1.104.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.104.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.109.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.109.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.109.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.109.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.109.2.1 24-Mar-2008  keiichi sync with head.
 1.113.2.2 04-Jun-2008  yamt sync with head
 1.113.2.1 18-May-2008  yamt sync with head.
 1.114.2.8 09-Oct-2010  yamt sync with head
 1.114.2.7 11-Aug-2010  yamt sync with head.
 1.114.2.6 11-Mar-2010  yamt sync with head
 1.114.2.5 16-Sep-2009  yamt sync with head
 1.114.2.4 19-Aug-2009  yamt sync with head.
 1.114.2.3 16-May-2009  yamt sync with head
 1.114.2.2 04-May-2009  yamt sync with head.
 1.114.2.1 16-May-2008  yamt sync with head.
 1.115.2.4 10-Oct-2008  skrll Sync with HEAD.
 1.115.2.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.115.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.115.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.117.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.117.4.1 19-Oct-2008  haad Sync with HEAD.
 1.117.2.1 18-Jul-2008  simonb Sync with head.
 1.120.4.2 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.120.4.1 02-Feb-2009  snj branches: 1.120.4.1.4;
Pull up following revision(s) (requested by jmcneill in ticket #381):
sys/dev/acpi/acpi.c: revision 1.123
sys/dev/acpi/acpica/OsdSchedule.c: revision 1.9
sys/dev/acpi/acpica/OsdSynch.c: revision 1.11
PR# kern/38817: regression in acpi sleep on lifebook S6510
Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.120.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.120.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.120.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.120.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.123.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.148.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.148.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.148.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.148.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.159.2.4 12-Jun-2011  rmind sync with head
 1.159.2.3 05-Mar-2011  rmind sync with head
 1.159.2.2 03-Jul-2010  rmind sync with head
 1.159.2.1 30-May-2010  rmind sync with head
 1.233.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.234.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.234.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.241.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.251.2.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.251.2.2 30-Oct-2012  yamt sync with head
 1.251.2.1 17-Apr-2012  yamt sync with head
 1.252.6.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.252.4.1 29-Apr-2012  mrg sync to latest -current.
 1.254.2.4 03-Dec-2017  jdolecek update from HEAD
 1.254.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.254.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.254.2.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.255.2.1 18-May-2014  rmind sync with head
 1.259.2.4 28-Aug-2017  skrll Sync with HEAD
 1.259.2.3 09-Jul-2016  skrll Sync with HEAD
 1.259.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.259.2.1 22-Sep-2015  skrll Sync with HEAD
 1.268.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.268.2.4 20-Oct-2018  pgoyette Sync with head
 1.268.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.268.2.2 21-May-2018  pgoyette Sync with HEAD
 1.268.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.271.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.271.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.271.2.1 10-Jun-2019  christos Sync with HEAD
 1.278.4.1 27-Nov-2023  martin Pull up following revision(s) (requested by abs in ticket #1765):

sys/dev/acpi/acpi.c: revision 1.284

Stop walking MADT / GTDT subtables if we hit a header with length 0
 1.282.2.1 17-Jan-2020  ad Sync with head.
 1.283.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.285.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.285.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.290.2.3 03-Apr-2021  thorpej Pass CFARG_DEVHANDLE to config_found(), rather than setting the device
handle in acpi_device_register().
 1.290.2.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.290.2.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.291.4.1 31-May-2021  cjep sync with head
 1.291.2.1 13-May-2021  thorpej Sync with HEAD.
 1.292.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.298.4.1 25-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #639):

sys/dev/acpi/acpivar.h: revision 1.90
sys/dev/acpi/files.acpi: revision 1.129
sys/dev/acpi/acpi.c: revision 1.299
sys/dev/acpi/files.acpi: revision 1.130

acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.
Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046

acpi(4): Make apeibus actually work as an iattr.
PR kern/58046
 1.299.2.1 02-Aug-2025  perseant Sync with HEAD
 1.52 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.51 23-Apr-2015  pgoyette branches: 1.51.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.50 03-Jun-2011  jruoho branches: 1.50.12; 1.50.30;
Remove unnecessary (due SME_DISABLE_REFRESH) locking.
 1.49 16-Feb-2011  jruoho branches: 1.49.2;
Use ioconf for the module declarations.
 1.48 04-Jan-2011  jruoho branches: 1.48.2; 1.48.4;
Revert the changes made in the commit:

"Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module."

Queueing the checks in the resume hooks was observed to improve the resume
time by several seconds (!) on a system with poorly implemented AML code.
The observed race condition is a wider issue related to modules; things like
sysmon_taskq(9) should be modified to allow cancelling of queued functions.
 1.47 28-Oct-2010  jruoho Be silent if we get a notification to tell us that we woke up the system.
 1.46 25-Oct-2010  jruoho Bump WARNS to 4.
 1.45 14-Aug-2010  jruoho Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module.
 1.44 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.43 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.42 05-Mar-2010  jruoho branches: 1.42.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.41 28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.40 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.39 31-Jan-2010  jruoho branches: 1.39.2;
Simplify and clean:

* Semantics.
* Remove ACPI_ACAD_DEBUG.
* Reduce the amount of error reporting.
* Remove the internal bookkeeping flags and variables;
instead operate only with a single state variable.
* Trust that the notify handler is doing its job;
remove the refresh routine from the sensor.
* Queue a status check upon resume; we want to know
if the status has changed when in suspend (and it
is unclear if a notify is sent to us).
 1.38 31-Jan-2010  jruoho Add detachment routine.
 1.37 30-Jan-2010  jruoho Add the _COMPONENT definition for ACPI_DEBUG.
 1.36 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.35 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.34 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.33 23-Mar-2008  xtraeme branches: 1.33.4; 1.33.18;
acpiacad_get_status: move sc_notifysent to the correct place, otherwise
the notify might not be sent.
 1.32 23-Mar-2008  xtraeme Register a resume pmf(9) handler that clears the status. It is needed
to always fetch new status after resuming, otherwise if AACAD_F_AVAILABLE
is set, acpiacad_get_status() won't be called.

Also use the SME_INIT_REFRESH flag to fetch sensor data once in the
autoconf(9) process.

Ok'ed by <jmcneill>.
 1.31 09-Dec-2007  jmcneill branches: 1.31.10;
Merge jmcneill-pm branch.
 1.30 05-Dec-2007  ad branches: 1.30.2;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.29 16-Nov-2007  xtraeme branches: 1.29.2;
Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.28 02-Nov-2007  plunky branches: 1.28.2;
do not embed acpi device names in the sensor names
fake it in the compat code for the old envsys API
 1.27 18-Oct-2007  joerg Convert to device_t/softc split. Use aprint API.
 1.26 10-Oct-2007  xtraeme branches: 1.26.2;
Fix the problems described in:
http://mail-index.netbsd.org/current-users/2007/07/16/0012.html

- Introduce sme_class into the sysmon_envsys struct to specify a
class; currently there are two classes: SME_CLASS_ACADAPTER and
SME_CLASS_BATTERY.

- Add a new envsys event: PENVSYS_EVENT_LOW_POWER that is reached when
all SME_CLASS_BATTERY devices are in CRITICAL/LOW state and there's not
any SME_CLASS_ACADAPTER connected.

- Add the 'low-power' event into the sensor_battery script that will
shutdown the system gracefully via 'shutdown -p'. If powerd(8) is
not running, cpu_reboot(9) with RB_POWERDOWN is used.

- Make acpiacad(4) a SME_CLASS_ACADAPTER device and acpibat(4) a
SME_CLASS_BATTERY device.

Update the documentation accordingly to these changes.
 1.25 05-Jul-2007  xtraeme branches: 1.25.6; 1.25.8; 1.25.10;
Final round, after more comments from yamt and cube:

For indicators, if sensor is valid but it should report that it is
in disabled state (OFF), just set value_cur to 0 without changing its
state.
 1.24 05-Jul-2007  xtraeme Use only one sensor to report if the AC Adapter is connected or not,
rather than using two: one when is connected and another one is
disconnected.
 1.23 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.22 27-Jun-2007  jmcneill Sony firmware strikes again!

The Sony VAIO VGN-N250E (and probably others) sends BatteryInformationChanged
on AC adapter state change. Handle that here.
 1.21 16-Nov-2006  christos branches: 1.21.8; 1.21.10;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 30-Apr-2006  rpaulo branches: 1.19.8; 1.19.10;
My laptop sends DeviceCheck instead of PowerSourceStatusChanged.
 1.18 20-Feb-2006  kochi branches: 1.18.2; 1.18.4; 1.18.6;
use aprint_*
 1.17 11-Dec-2005  christos branches: 1.17.2; 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 03-May-2004  kochi branches: 1.16.12;
Add sysmon pswitch hook so that powerd(8) can monitor
AC adapter online/offline events.
 1.15 01-May-2004  kochi specify static where appropriate.
 1.14 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.13 24-Mar-2004  kanaoka Make it compile (int -> ACPI_INTEGER)
 1.12 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.11 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.10 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.9 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.8 19-Feb-2003  yamt branches: 1.8.2;
initialize a simple_lock in softc.
 1.7 16-Feb-2003  tshiozak - reduce the frequency of updating informations on the power sources;
it is very slow to access to EC on some machines (i.e. CASIO FIVA 2xx).
- clean the flags up.
- add locks while updating informations.
- some cosmetic changes.
 1.6 31-Dec-2002  explorer add envsys support to acpi A/C adapter and batteries. This is still a work
in progress, much like the rest of ACPI.
 1.5 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem branches: 1.2.2;
add RCSID
 1.1 29-Sep-2001  thorpej branches: 1.1.2; 1.1.4;
Skeleton ACPI AC Adapter driver.
 1.1.4.5 03-Jan-2003  thorpej Sync with HEAD.
 1.1.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 29-Sep-2001  nathanw file acpi_acad.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 29-Sep-2001  fvdl file acpi_acad.c was added on branch thorpej-devvp on 2001-10-01 12:44:14 +0000
 1.2.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 13-Nov-2001  thorpej file acpi_acad.c was added on branch kqueue on 2002-01-10 19:52:52 +0000
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.12.8 24-Mar-2008  yamt sync with head.
 1.16.12.7 21-Jan-2008  yamt sync with head
 1.16.12.6 07-Dec-2007  yamt sync with head
 1.16.12.5 15-Nov-2007  yamt sync with head.
 1.16.12.4 27-Oct-2007  yamt sync with head.
 1.16.12.3 03-Sep-2007  yamt sync with head.
 1.16.12.2 30-Dec-2006  yamt sync with head.
 1.16.12.1 21-Jun-2006  yamt sync with head.
 1.17.6.2 01-Jun-2006  kardel Sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 01-Mar-2006  yamt sync with head.
 1.18.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.18.4.1 11-May-2006  elad sync with head
 1.18.2.1 24-May-2006  yamt sync with head.
 1.19.10.2 10-Dec-2006  yamt sync with head.
 1.19.10.1 22-Oct-2006  yamt sync with head
 1.19.8.1 18-Nov-2006  ad Sync with head.
 1.21.10.1 11-Jul-2007  mjf Sync with head.
 1.21.8.3 23-Oct-2007  ad Sync with head.
 1.21.8.2 12-Oct-2007  ad Sync with head.
 1.21.8.1 15-Jul-2007  ad Sync with head.
 1.25.10.1 14-Oct-2007  yamt sync with head.
 1.25.8.2 09-Jan-2008  matt sync with HEAD
 1.25.8.1 06-Nov-2007  matt sync with HEAD
 1.25.6.8 09-Dec-2007  jmcneill Sync with HEAD.
 1.25.6.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.25.6.6 21-Nov-2007  joerg Sync with HEAD.
 1.25.6.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.25.6.4 04-Nov-2007  jmcneill Sync with HEAD.
 1.25.6.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.25.6.2 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.25.6.1 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.26.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.26.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.26.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.28.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.28.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.28.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.29.2.2 26-Dec-2007  ad Sync with head.
 1.29.2.1 08-Dec-2007  ad Sync with head.
 1.30.2.1 11-Dec-2007  yamt sync with head.
 1.31.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.33.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.4.5 09-Oct-2010  yamt sync with head
 1.33.4.4 11-Aug-2010  yamt sync with head.
 1.33.4.3 11-Mar-2010  yamt sync with head
 1.33.4.2 16-Sep-2009  yamt sync with head
 1.33.4.1 16-May-2009  yamt sync with head
 1.39.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.39.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.39.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.3 12-Jun-2011  rmind sync with head
 1.42.2.2 05-Mar-2011  rmind sync with head
 1.42.2.1 30-May-2010  rmind sync with head
 1.48.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.48.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.50.30.1 06-Jun-2015  skrll Sync with HEAD
 1.50.12.1 03-Dec-2017  jdolecek update from HEAD
 1.51.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 14-Mar-2007  xtraeme branches: 1.2.2;
Rename acpi_aiboost to aiboost, suggested by cube.
 1.1 13-Mar-2007  xtraeme ASUS AI Booster ACPI driver, ported from FreeBSD.

This driver will report values from the Super I/O chip via ACPI.
It should be possible to overclock the system with this driver, but
it's not implemented yet.

All newer ASUS motherboards probably will work with this driver
(device ATK0110).

[juan@nocturno][~]> envstat -r
CPU Temperature: 30.000 degC
MB Temperature: 38.000 degC
Vcore Voltage: 1.240 V
+3.3 Voltage: 3.264 V
+5 Voltage: 4.992 V
+12 Voltage: 12.091 V
CPU FAN Speed: 1454 RPM
[juan@nocturno][~]>
 1.2.2.2 10-Apr-2007  ad Fix cvs screwup. Pointed out by xtraeme@.
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.20 24-Oct-2010  jruoho Simplify acpi_enter_sleep_state() and guard it against NULL pointer
dereferences. Try to avoid referencing the global acpi_softc, which should
really be static or at least internal to acpi(4).
 1.19 27-Apr-2010  jruoho Include the new prototype for acpi_enter_sleep_state().
 1.18 12-Apr-2010  skrll Spello in comment.
 1.17 28-Mar-2010  pgoyette Update acpiapm_get_powstat() to adjust for the recent changes to
acpi_bat(4). (The warn_cap and low_cap sensors were removed, and the
values are now stored as the alarm limits of the charge sensor.)
 1.16 24-Mar-2010  pgoyette Only set the APM_BATT_FLAG_NO_SYSTEM_BATTERY if _all_ batteries are
not_present.
 1.15 05-Mar-2010  jruoho branches: 1.15.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.14 28-Apr-2008  martin branches: 1.14.20;
Remove clause 3 and 4 from TNF licenses
 1.13 07-Mar-2008  cube branches: 1.13.2; 1.13.4;
Split device_t/softc for i386's apm(4), and other related cosmetic changes.
 1.12 09-Dec-2007  jmcneill branches: 1.12.6; 1.12.10;
Merge jmcneill-pm branch.
 1.11 27-Oct-2007  plunky branches: 1.11.4; 1.11.6;
When no estimate of battery minutes_left can be made, apm should
return a value of 0.
 1.10 05-Jul-2007  xtraeme branches: 1.10.6; 1.10.8; 1.10.12;
Adapt to the recent changes to the acpiacad(4) and acpibat(4) drivers.
 1.9 11-Mar-2007  christos branches: 1.9.2;
open and close envsys; from Cherry.
 1.8 16-Nov-2006  christos branches: 1.8.2; 1.8.4; 1.8.6; 1.8.10; 1.8.12;
__unused removal on arguments; approved by core.
 1.7 12-Oct-2006  xtraeme Use __unused in function arguments where appropiate. (hi christos)
 1.6 11-Oct-2006  gdt Aggregate discharge rate over all batteries. Makes time remaining
reasonable when battery 0 is in use and battery 1 is fully discharged.
 1.5 11-Oct-2006  gdt Aggregate current charge level and lastcap over all batteries, rather
than taking values from the last battery checked. Solves problem of
apm showing status of 2nd battery in a 2-battery system.
 1.4 06-Aug-2006  christos branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
PR/34117: Takuya SHIOZAKI: enhancement for acpiapm(4)
- make sleep state corresponding to standby/suspend changeable by using sysctl,
- make sure to generate APM events appropriately.
- arrange the code for getting power status.
 1.3 12-Jul-2006  hira branches: 1.3.2;
Fix typo (discarge -> discharge).
 1.2 12-Jul-2006  christos Prevent zerodivide (from Kouichirou Hiratsuka)
 1.1 08-Jul-2006  christos Add acpi apm attachment based on sysmon hooks.
 1.3.2.2 13-Jul-2006  gdamore Merge from HEAD.
 1.3.2.1 12-Jul-2006  gdamore file acpi_apm.c was added on branch gdamore-uart on 2006-07-13 17:49:17 +0000
 1.4.10.2 10-Dec-2006  yamt sync with head.
 1.4.10.1 22-Oct-2006  yamt sync with head
 1.4.8.2 09-Sep-2006  rpaulo sync with head
 1.4.8.1 06-Aug-2006  rpaulo file acpi_apm.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:28 +0000
 1.4.6.1 18-Nov-2006  ad Sync with head.
 1.4.4.2 11-Aug-2006  yamt sync with head
 1.4.4.1 06-Aug-2006  yamt file acpi_apm.c was added on branch yamt-pdpolicy on 2006-08-11 15:43:59 +0000
 1.8.12.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.8.10.2 15-Jul-2007  ad Sync with head.
 1.8.10.1 13-Mar-2007  ad Sync with head.
 1.8.6.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.4.6 17-Mar-2008  yamt sync with head.
 1.8.4.5 21-Jan-2008  yamt sync with head
 1.8.4.4 15-Nov-2007  yamt sync with head.
 1.8.4.3 03-Sep-2007  yamt sync with head.
 1.8.4.2 30-Dec-2006  yamt sync with head.
 1.8.4.1 16-Nov-2006  yamt file acpi_apm.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:54 +0000
 1.8.2.1 29-Oct-2007  pavel Pull up following revisions (requested by plunky in ticket #956):
usr.sbin/apm/apm.c: revision 1.18
sys/dev/acpi/acpi_apm.c: revision 1.11
When no estimate of battery minutes_left can be made, apm should
return a value of 0.
 1.9.2.1 11-Jul-2007  mjf Sync with head.
 1.10.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.10.8.3 23-Mar-2008  matt sync with HEAD
 1.10.8.2 09-Jan-2008  matt sync with HEAD
 1.10.8.1 06-Nov-2007  matt sync with HEAD
 1.10.6.2 28-Oct-2007  joerg Sync with HEAD.
 1.10.6.1 09-Sep-2007  jmcneill Fix battery counting by ignoring the 'charge state' value from acpibat.
 1.11.6.1 11-Dec-2007  yamt sync with head.
 1.11.4.1 26-Dec-2007  ad Sync with head.
 1.12.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.6.1 24-Mar-2008  keiichi sync with head.
 1.13.4.3 11-Aug-2010  yamt sync with head.
 1.13.4.2 11-Mar-2010  yamt sync with head
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.20.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.14.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.2.2 05-Mar-2011  rmind sync with head
 1.15.2.1 30-May-2010  rmind sync with head
 1.123 27-Apr-2024  christos Remove 0 initializations (since the softc is zalloc'ed) and the initial
refresh which will have no data.
 1.122 26-Apr-2024  christos PR/58201: Malte Dehling: re-order sysmon initialization before acpi
registration, to avoid needing to call to acpi_deregister_notify on sysmon
failure.
 1.121 07-Jan-2022  riastradh branches: 1.121.4;
acpibat(4): Fix race in detach with AcpiOsExecute deferred call.
 1.120 31-Dec-2021  riastradh acpibat(4): Print ACPI error when _STA fails.
 1.119 31-Dec-2021  riastradh acpibat(4): Delete excessive blank lines.

Makes it hard to follow when there is a big gap between everything
even when there is a tight logical coupling, like setting and testing
an error code.
 1.118 31-Dec-2021  riastradh acpibat(4): Fix attach and detach ordering.

On attach: Don't register acpibat_resume handler with pmf or
acpibat_notify_handler with acpi until it is safe to call
acpibat_update_info and acpibat_update_status.
=> This requires the sc->sc_sensor array to be allocated, so allocate
that first.
=> This requires sc->sc_sme to be created, so defer them to
config_interrupts after sysmon_envsys_register.
=> Make sure to register the notify handler before initially polling
the info and status.

On detach: Deregister pmf handler and acpi notifier before we destroy
anything.
 1.117 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.116 10-Aug-2018  riastradh branches: 1.116.14;
Don't hold up boot: defer acpibat(4) inquiry until threads are running.

ok jmcneill@
 1.115 23-Apr-2015  pgoyette branches: 1.115.16; 1.115.18;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.114 31-Dec-2014  mlelstv handle unknown values. Also BIF_UNIT is an enum, not a bitmask.
 1.113 02-Oct-2014  riastradh branches: 1.113.2;
Don't kdassert about crap provided by the firmware.
 1.112 14-Aug-2012  jruoho branches: 1.112.2;
Collect rnd(9) entropy from coretemp(4), acpibat(4), aibs(4), hpacel(4),
thinkpad(4), and aps(4).
 1.111 13-Jul-2011  jruoho branches: 1.111.2;
In revision 1.103 the serial number was used to determine whether the
battery was changed to another one. However, this is unreliable as many
vendors hardcode the serial number string in the DSDT. Thus, use the design
capacity and voltage instead; these are likely read from the battery itself.
 1.110 20-Jun-2011  pgoyette Initialize battery capacity sensor value before registering.
 1.109 16-Feb-2011  jruoho branches: 1.109.2;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.108 13-Jan-2011  jruoho branches: 1.108.2; 1.108.4;
Upon request from jmcneill@, put the check back that prevents unnecessary
readings during the sysmon_envsys(9) poll cycle. Some systems (notably,
Asus EeePC) have so badly implemented AML that reading the values via
envstat(8) alone can cause considerable delays.
 1.107 09-Jan-2011  jruoho Print a message if ACPI 4.0 functionality is present (in which case the
driver should be updated).
 1.106 04-Jan-2011  jruoho Revert the changes made in the commit:

"Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module."

Queueing the checks in the resume hooks was observed to improve the resume
time by several seconds (!) on a system with poorly implemented AML code.
The observed race condition is a wider issue related to modules; things like
sysmon_taskq(9) should be modified to allow cancelling of queued functions.
 1.105 25-Oct-2010  jruoho Bump WARNS to 4.
 1.104 14-Aug-2010  jruoho Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module.
 1.103 30-Jun-2010  jruoho Only aprint*() the battery information if the battery has changed. Based on
suggestion from mrg@. The used serial number is hopefully unique enough as
an identifier. Should fix PR kern/43505 by David Demelier.
 1.102 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.101 16-Apr-2010  christos fix dmesg printing.
 1.100 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.99 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.98 03-Apr-2010  jruoho Update the limits when a change from absent to present is detected.
 1.97 26-Mar-2010  pooka Catch up with cosmetic changes to output from config(1)
 1.96 26-Mar-2010  pooka Convert to config_init/fini_component.

tested by jruoho
 1.95 24-Mar-2010  pgoyette Set the SME_INIT_REFRESH flag so that the sensors' values (including
charge's max_value) are available when the event monitors are created.
 1.94 22-Mar-2010  jruoho Fix the previous commit properly: we need to set all sensor-flags during the
initialization of sysmon_envsys(9), otherwise, if _STA does not return true
during the attachment of the driver, it is possible that a flag is never
set. This flaw has always been present, but it only got exposed after the
conversion to use the sysmon-limits.
 1.93 22-Mar-2010  jruoho Set the capacity flags already in the acpibat_get_info(),
instead of acpibat_get_status().
 1.92 21-Mar-2010  pooka Convert acpibat to use ioconf instead of homerolled config glue.

Note, config whines about things like:
files.acpi:30: attaching undefined device `apm'

I intentionally was a lazy boy and didn't include a ton of dirt to
keep the hot napalm and riot blasts in the config thread rolling ;)

tested by jruoho (thanks!)
 1.91 17-Mar-2010  jruoho Print also the so-called "granularity" values when the _BIF is evaluated.
These refer to the smallest increment in capacity that the battery is
capable of measuring.
 1.90 17-Mar-2010  jruoho Remove the technology "sensor" (a fixed constant). Report this information
in an improved output when the battery information changes (i.e. device
attachment or battery removal/insertion).
 1.89 17-Mar-2010  jruoho Remove the timer-based check in the sensor refresh routine. We henceforth
trust that the sysmon_envsys(9)'s polling is functioning properly. Discussed
with drochner@, jmcneill@, and pgoyette@.
 1.88 17-Mar-2010  jruoho Fix the testing of temporarily unknown values.
 1.87 17-Mar-2010  jruoho Move the low and warning capacity sensors to the limits framework provided
by sysmon_envsys(9).
 1.86 14-Mar-2010  pgoyette branches: 1.86.2;
Remove setting of edata->monitor since that member no longer exists.
 1.85 08-Mar-2010  jruoho Use the predefined ACPI_STA_BATTERY_PRESENT instead of defining a local one.
 1.84 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.83 28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.82 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.81 31-Jan-2010  jruoho branches: 1.81.2;
Allocate the sensor structures dynamically.
 1.80 31-Jan-2010  jruoho Add detachment routines.
 1.79 27-Jan-2010  drochner the "Battery Present Rate" is only required to be valid if the battery
is discharging; it might make sense when charging, but it doesn't
make sense if neither is the case -- remove a wrong assertion and
arrange the code to make this obvious
(actually, the ACPI spec says that the requirement is only for
rechargeable batteries)
 1.78 24-Jan-2010  jruoho * Reintroduce a state variable. From njoly@.
* Always mark the charge state sensor as valid.
 1.77 23-Jan-2010  jruoho Cleanup:

* Remove ACPI_BAT_DEBUG.
* Reduce the amount of error reporting.
* Remove the internal bookkeeping flags.
* Remove the debugging functions used to print status and information
changes. This information is fully conveyed in the output of envstat(8).
* Always evaluate _STA. If it fails or the battery is not present, mark
all remaining sensors as invalid. This will eliminate the convoluted
update routine.
* Semantics.

Over 200 LOC was eliminated, but functional change should again be minimal.

ok jmcneill@, pgoyette@
 1.76 21-Jan-2010  jruoho In preparation for upcoming changes:

* Provide proper definitions and use these.
* Clarify the evaluation of _STA.
* Mark the state of a sensor according to the return value from _STA.
* Share the basic object evaluation in _BIF and _BST.
* Verify the object types before using the objects.
* Be aware of bogus values from _BIF and _BST, as noted in the
specification.

Despite of the list, functional change should be minimal. Ok pgoyette@.
 1.75 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.74 29-Sep-2009  jmcneill If the driver thinks a battery is not present, poll for present status.
Workaround for firmware that doesn't report battery present status
immediately at boot and doesn't issue a subsequent notify when the
information becomes available.
 1.73 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.72 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.71 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.70 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.69 03-Jun-2008  jmcneill branches: 1.69.8; 1.69.12; 1.69.16;
Reintroduce acpibat_refresh, only have it refresh battery status (not info,
we will get notified for changes there). Use SME_POLL_ONLY so applications
that use GTREDATA don't cause trouble, and don't use SME_INIT_REFRESH as it
appears to be completely broken.
 1.68 03-Jun-2008  jmcneill Refresh battery info/status on resume.
 1.67 03-Jun-2008  jmcneill Simplify SME usage within acpibat:

* No need for sme_refresh callback; GPE handler will tell us when the
device status changed (otherwise we can refresh data up to once a second,
and that can take time!)
* Since sme_refresh callback is gone, mutex is no longer required to
synchronize GPE handlers and refresh thread, so nuke it.
* Don't do any more work in GPE handler than required; use AcpiOsExecute
to clear battery status/information in the sysmon_task_queue along with
the refresh.

With these changes running GNOME's battstat-applet-2 no longer causes
my mouse to stutter once a second, and significantly reduces its CPU usage.
 1.66 28-Apr-2008  martin branches: 1.66.2;
Remove clause 3 and 4 from TNF licenses
 1.65 23-Mar-2008  xtraeme branches: 1.65.2; 1.65.4;
Use the SME_INIT_REFRESH flag to fetch sensor data once in the
autoconf(9) process.
 1.64 09-Dec-2007  jmcneill branches: 1.64.10;
Merge jmcneill-pm branch.
 1.63 05-Dec-2007  ad branches: 1.63.2;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.62 16-Nov-2007  xtraeme branches: 1.62.2;
Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.61 03-Nov-2007  xtraeme branches: 1.61.2;
- Rename ENVSYS_BATTERY_STATE units to ENVSYS_BATTERY_CAPACITY and
introduce ENVSYS_BATTERY_CHARGE, which is the same than an Indicator and
it's used to know if the battery is currently charging or discharging.

- Require two sensors at least for SME_CLASS_BATTERY to make the low-power
condition work: a ENVSYS_BATTERY_CAPACITY plus ENVSYS_BATTERY_CHARGE.

- Simplify sme_event_check_lowpower() and make it check the required
sensors in the SME_CLASS_ACADAPTER and SME_CLASS_BATTERY classes.
If the acadapter is not ready, trust the state returned by the battery
device.

Based on suggestion from joerg@.
 1.60 02-Nov-2007  plunky do not embed acpi device names in the sensor names
fake it in the compat code for the old envsys API
 1.59 18-Oct-2007  joerg Convert to device_t/softc split. Use aprint API.
 1.58 17-Oct-2007  joerg Separate softc and device_t. Convert to aprint API and make the driver
less verbose by default.
 1.57 10-Oct-2007  xtraeme branches: 1.57.2;
Fix the problems described in:
http://mail-index.netbsd.org/current-users/2007/07/16/0012.html

- Introduce sme_class into the sysmon_envsys struct to specify a
class; currently there are two classes: SME_CLASS_ACADAPTER and
SME_CLASS_BATTERY.

- Add a new envsys event: PENVSYS_EVENT_LOW_POWER that is reached when
all SME_CLASS_BATTERY devices are in CRITICAL/LOW state and there's not
any SME_CLASS_ACADAPTER connected.

- Add the 'low-power' event into the sensor_battery script that will
shutdown the system gracefully via 'shutdown -p'. If powerd(8) is
not running, cpu_reboot(9) with RB_POWERDOWN is used.

- Make acpiacad(4) a SME_CLASS_ACADAPTER device and acpibat(4) a
SME_CLASS_BATTERY device.

Update the documentation accordingly to these changes.
 1.56 04-Sep-2007  xtraeme branches: 1.56.2;
- Use a ENVSYS_BATTERY_STATE sensor rather than ENVSYS_GSTRING.
- Use ENVSYS_FMONSTCHANGED on the ENVSYS_BATTERY_STATE sensor to monitor
state changes.
 1.55 02-Sep-2007  xtraeme Add a new sensor of type ENVSYS_GSTRING. This is useful to print
the current battery charge state.

$ envstat -dacpibat0 -s"acpibat0 charge state"
acpibat0 charge state: NORMAL
$

It will show WARNING, CRITICAL, LOW or NORMAL depending on the
state it is.
 1.54 26-Aug-2007  xtraeme branches: 1.54.2;
Set ENVSYS_FMONNOTSUPP in the last two missing sensors, forgot in previous.
 1.53 26-Aug-2007  xtraeme Only assing the monitoring flags once in acpibat_init_envsys() before
registering the driver.
 1.52 08-Aug-2007  cube Fix a few minor envsys2 bugs/oddities in acpi_bat(4).

- mark (DIS)CHARGERATE as invalid when (DIS)CHARGING so that envstat
doesn't print some weird stats where the system appears to be doing
both
- handle the case when it's doing neither by marking *RATE as invalid
and setting CHARGING to OFF (because we're not charging, even though
we're not discharging)
- fix print_stats to print correct values in those cases, and a real
percentage (i.e., computed against LFCCAPACITY)
 1.51 16-Jul-2007  xtraeme branches: 1.51.2; 1.51.6;
Disable monitoring in the ACPIBAT_TECHNOLOGY sensor, which is just
informative.
 1.50 05-Jul-2007  xtraeme Final round, after more comments from yamt and cube:

For indicators, if sensor is valid but it should report that it is
in disabled state (OFF), just set value_cur to 0 without changing its
state.
 1.49 05-Jul-2007  xtraeme acpibat_print_stat(): in the 'charging' indicator sensor, check its state
to select the correct string rather than using value_cur.
 1.48 05-Jul-2007  xtraeme Use only one Indicator sensor when the battery is connected/disconnected
and another one only for charging/discharging.
 1.47 03-Jul-2007  xtraeme Rather than using two AcpiInstallNotifyHandler() with ACPI_DEVICE_NOTIFY
and ACPI_SYSTEM_NOTIFY, use ACPI_ALL_NOTIFY and remove a redundant
call.
 1.46 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.45 16-Nov-2006  christos branches: 1.45.8; 1.45.10;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 20-Feb-2006  kochi branches: 1.43.14; 1.43.16;
use aprint_*
 1.42 16-Feb-2006  kochi prototypes don't need argument names
 1.41 11-Dec-2005  christos branches: 1.41.2; 1.41.4; 1.41.6;
merge ktrace-lwp.
 1.40 25-Jun-2004  mycroft branches: 1.40.12;
Handle a "device check" message by reloading battery information.
 1.39 01-May-2004  kochi specify static where appropriate.
 1.38 12-Apr-2004  kochi minor space nit from Alexander Yurchenko.
 1.37 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.36 24-Mar-2004  kanaoka branches: 1.36.2;
Make it compile (int -> ACPI_INTEGER)
 1.35 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.34 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.33 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.32 01-Nov-2003  mycroft Don't bothering reinitializing the sensor name strings when the battery info
is updated. Do print out the battery manufacturer info, though. (It's too
bad we can't return this through envsys........)
 1.31 01-Nov-2003  mycroft Provide percentages for the threshold values too.
 1.30 01-Nov-2003  mycroft Whoops, made a typo there.
 1.29 01-Nov-2003  mycroft Split "load" into "charge rate" and "discharge rate", depending on the state
of the battery.
 1.28 01-Nov-2003  mycroft Small change to use the "last full capacity" as the capacity maximum.
 1.27 01-Nov-2003  mycroft There's no need to clear the data_s fields now that the VALID bits are correct.
 1.26 01-Nov-2003  mycroft Remove some unused #defines.
 1.25 31-Oct-2003  mycroft Remove an outdated comment.
 1.24 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.23 30-Oct-2003  mycroft Use ratecheck() to prevent envstat(1) doing many ACPI calls at once. Now my
MP3 player doesn't skip...
 1.22 31-Aug-2003  gson The unit displayed when printing battery capacities and
charge/discharge rates was incorrect - the value printed is actually
in A, W, Ah, or Wh, not in mA, mW, mAh, or mWh (assuming as we must
that the period is interpreted as a decimal point, not a thousands
separator).
 1.21 29-May-2003  gson branches: 1.21.2;
The remaining capacity percentage was incorrect for batteries larger than
21.47 Wh becaue of integer overflow.
 1.20 22-May-2003  kochi * make use of NetBSD ACPI APIs (acpi_eval_{struct,integer})
* minor cleanups
 1.19 26-Apr-2003  yamt this doesn't need to include callout.h anymore.
 1.18 24-Feb-2003  christos back-out previous; it was wrong.
 1.17 24-Feb-2003  christos fix memory leaks.
 1.16 17-Feb-2003  tshiozak fix a few problems in the last commit:
- make sure that the driver checks the battery presence at acpibat_update()
if the battery has been not present, because the driver sometimes
(i.e. boot time or resuming time) miss to sense the presence.
- make sure that the driver always update the status at acpibat_gtredata();
I misunderstood about ACPI_NOTIFY_BatteryStatusChanged event.
 1.15 16-Feb-2003  tshiozak - reduce the frequency of updating informations on the power sources;
it is very slow to access to EC on some machines (i.e. CASIO FIVA 2xx).
- clean the flags up.
- add locks while updating informations.
- some cosmetic changes.
 1.14 31-Dec-2002  explorer add envsys support to acpi A/C adapter and batteries. This is still a work
in progress, much like the rest of ACPI.
 1.13 30-Dec-2002  explorer When a battery isn't present, display that rather than bogus values.
 1.12 30-Dec-2002  chris Fix build break..
 1.11 30-Dec-2002  explorer clean up printing of battery info. This includes other changes I've toyed with, #if 0'd out
 1.10 30-Dec-2002  jmcneill Again, in acpibat_get_status, bail rather than continuing if the package
we receive contains less elements than expected.
 1.9 30-Dec-2002  jmcneill Oops, I didn't mean for that commented out verbose flag to make it into the
last commit -- uncomment it again.
 1.8 30-Dec-2002  jmcneill If we receive a battery information package with less than 13 elements,
cleanup and return rather than trying to continue anyway.
 1.7 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 20-Aug-2002  christos Fix battery support (Masanori Kanaoka).
XXX: ToDo: Still the battery charge is 96% when the battery is
fully charged on my libretto because of the estimated total charge offset.
 1.3 18-Aug-2002  kanaoka - Fix typo in a message.
- Avoid to divide by 0.
When booting without battery, sc->sc_design_capacity become 0.
 1.2 02-Aug-2002  explorer display the V, W, and Wh rather than mV, mW, and mWh
 1.1 24-Mar-2002  sommerfeld branches: 1.1.2; 1.1.4; 1.1.8;
Prototype ACPI Control Method Battery driver.

ACPI defines two different battery device interfaces: "Control Method"
batteries, in which AML methods are defined in order to get battery
status and set battery alarm thresholds, and a "Smart Battery" device,
which is an SMbus device accessed through the ACPI Embedded Controller
device; this driver knows how to attach to the former sort of device.

As a total kludge, since we haven't wired things up to sysmon/envsys
yet, we report battery status through a once-per-minute kernel printf,
so don't use this driver yet if you want your disk to spin down.

Motivated by and tested on Sony PCG-R505TL laptop, which has
nonfunctional APM.

configure as:

acpibat* at acpi ?

Sample output:

acpibat0 at acpi0: ACPI Battery
acpibat0: Sony Corp. LION
acpibat0: Design 38480mWh, Predicted 38480mWh Warn 120mWh Low 0mWh
acpibat0: discharging: 15112mV cap 25480mWh (66%) rate 16849mW
...
acpibat0: discharging: 15224mV cap 25070mWh (65%) rate 18405mW
...
acpibat0: discharging: 15200mV cap 24310mWh (63%) rate 13771mW
...
acpibat0: charging: 15768mV cap 23330mWh (60%) rate 20388mW
 1.1.8.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.8.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 24-Mar-2002  jdolecek file acpi_bat.c was added on branch kqueue on 2002-06-23 17:45:02 +0000
 1.1.4.1 29-Aug-2002  gehenna catch up with -current.
 1.1.2.6 03-Jan-2003  thorpej Sync with HEAD.
 1.1.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.3 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 24-Mar-2002  nathanw file acpi_bat.c was added on branch nathanw_sa on 2002-04-01 07:45:06 +0000
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.2.1 02-Jul-2004  he Pull up revision 1.40 (requested by mycroft in ticket #572):
Handle a ``device check'' message by reloading battery
information.
 1.40.12.8 24-Mar-2008  yamt sync with head.
 1.40.12.7 21-Jan-2008  yamt sync with head
 1.40.12.6 07-Dec-2007  yamt sync with head
 1.40.12.5 15-Nov-2007  yamt sync with head.
 1.40.12.4 27-Oct-2007  yamt sync with head.
 1.40.12.3 03-Sep-2007  yamt sync with head.
 1.40.12.2 30-Dec-2006  yamt sync with head.
 1.40.12.1 21-Jun-2006  yamt sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.41.2.2 01-Mar-2006  yamt sync with head.
 1.41.2.1 18-Feb-2006  yamt sync with head.
 1.43.16.2 10-Dec-2006  yamt sync with head.
 1.43.16.1 22-Oct-2006  yamt sync with head
 1.43.14.1 18-Nov-2006  ad Sync with head.
 1.45.10.1 11-Jul-2007  mjf Sync with head.
 1.45.8.5 23-Oct-2007  ad Sync with head.
 1.45.8.4 12-Oct-2007  ad Sync with head.
 1.45.8.3 09-Oct-2007  ad Sync with head.
 1.45.8.2 20-Aug-2007  ad Sync with HEAD.
 1.45.8.1 15-Jul-2007  ad Sync with head.
 1.51.6.11 09-Dec-2007  jmcneill Sync with HEAD.
 1.51.6.10 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.51.6.9 21-Nov-2007  joerg Sync with HEAD.
 1.51.6.8 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.51.6.7 04-Nov-2007  jmcneill Sync with HEAD.
 1.51.6.6 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.51.6.5 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.51.6.4 02-Oct-2007  joerg Sync with HEAD.
 1.51.6.3 03-Sep-2007  jmcneill Sync with HEAD.
 1.51.6.2 09-Aug-2007  jmcneill Sync with HEAD.
 1.51.6.1 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.51.2.3 10-Sep-2007  skrll Sync with HEAD.
 1.51.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.51.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.54.2.2 09-Jan-2008  matt sync with HEAD
 1.54.2.1 06-Nov-2007  matt sync with HEAD
 1.56.2.2 18-Oct-2007  yamt sync with head.
 1.56.2.1 14-Oct-2007  yamt sync with head.
 1.57.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.57.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.57.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.61.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.61.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.61.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.62.2.2 26-Dec-2007  ad Sync with head.
 1.62.2.1 08-Dec-2007  ad Sync with head.
 1.63.2.1 11-Dec-2007  yamt sync with head.
 1.64.10.3 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.64.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.64.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.65.4.7 09-Oct-2010  yamt sync with head
 1.65.4.6 11-Aug-2010  yamt sync with head.
 1.65.4.5 11-Mar-2010  yamt sync with head
 1.65.4.4 16-Sep-2009  yamt sync with head
 1.65.4.3 16-May-2009  yamt sync with head
 1.65.4.2 04-May-2009  yamt sync with head.
 1.65.4.1 16-May-2008  yamt sync with head.
 1.65.2.2 04-Jun-2008  yamt sync with head
 1.65.2.1 18-May-2008  yamt sync with head.
 1.66.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.69.16.1 21-Apr-2010  matt sync to netbsd-5
 1.69.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.69.8.1 05-Oct-2009  sborrill Pull up revision 1.74 (requested by jmcneill in ticket #1067)

If the driver thinks a battery is not present, poll for present status.
Workaround for firmware that doesn't report battery present status
immediately at boot and doesn't issue a subsequent notify when the
information becomes available.
 1.81.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.81.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.81.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.86.2.3 05-Mar-2011  rmind sync with head
 1.86.2.2 03-Jul-2010  rmind sync with head
 1.86.2.1 30-May-2010  rmind sync with head
 1.108.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.108.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.109.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.111.2.1 30-Oct-2012  yamt sync with head
 1.112.2.1 03-Dec-2017  jdolecek update from HEAD
 1.113.2.2 06-Jun-2015  skrll Sync with HEAD
 1.113.2.1 06-Apr-2015  skrll Sync with HEAD
 1.115.18.1 10-Jun-2019  christos Sync with HEAD
 1.115.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.116.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.121.4.1 12-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #844):

sys/dev/acpi/acpi_bat.c: revision 1.122
sys/dev/acpi/acpi_bat.c: revision 1.123

PR/58201: Malte Dehling: re-order sysmon initialization before acpi
registration, to avoid needing to call to acpi_deregister_notify on sysmon
failure.

Remove 0 initializations (since the softc is zalloc'ed) and the initial
refresh which will have no data.
 1.43 29-Jan-2021  thorpej Use acpi_compatible_match() / acpi_compatible_lookup().
 1.42 23-Apr-2015  pgoyette branches: 1.42.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.41 20-Feb-2011  jruoho branches: 1.41.14; 1.41.32;
Always explicitly enable the wake GPE for acpibut(4). This follows FreeBSD
and Linux, although it is somewhat unclear why this is necessary. But better
safe than sorry.
 1.40 16-Feb-2011  jruoho Use ioconf for the module declarations.
 1.39 25-Oct-2010  jruoho branches: 1.39.2; 1.39.4;
Bump WARNS to 4.
 1.38 24-Aug-2010  jruoho Bypass ACPI_NOTIFY_DEVICE_WAKE also in acpilid(4). Use aprint_debug_dev(9)
for an unknown notify. (The ACPI drivers should really not print anything
as we now have a global notify handler that can catch the debug information.)
 1.37 21-Aug-2010  jmcneill in acpibut_notify_handler, suppress 'unknown event' messages for
ACPI_NOTIFY_DEVICE_WAKE. Control method power and sleep buttons can
generate this event upon waking from G1 sleep to indicate that it was
responsible for waking the system.
 1.36 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.35 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.34 05-Mar-2010  jruoho branches: 1.34.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.33 04-Mar-2010  jruoho Add missing semicolon.
 1.32 04-Mar-2010  jruoho Cleanup:

* Semantics.
* No need for <dev/acpi/acpica.h>.
* Reduce the amount of error reporting.
* Remove ACPI_BUT_DEBUG and ACPIBUT_F_VERBOSE.

No functional change.
 1.31 28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.30 31-Jan-2010  jruoho branches: 1.30.2;
Add detachment routines.
 1.29 30-Jan-2010  jruoho Add the _COMPONENT definition for ACPI_DEBUG.
 1.28 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.27 04-Aug-2009  jmcneill add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.26 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.25 09-Dec-2007  jmcneill branches: 1.25.14; 1.25.24; 1.25.28; 1.25.32;
Merge jmcneill-pm branch.
 1.24 24-Oct-2007  joerg branches: 1.24.4; 1.24.6;
Pass correct argument to callback, botched up in the last commit.
 1.23 18-Oct-2007  joerg Convert to device_t/softc split. Use aprint API.
 1.22 16-Nov-2006  christos branches: 1.22.8; 1.22.22; 1.22.24; 1.22.28;
__unused removal on arguments; approved by core.
 1.21 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.20 20-Feb-2006  kochi branches: 1.20.14; 1.20.16;
use aprint_*
 1.19 16-Feb-2006  kochi prototypes don't need argument names
 1.18 11-Dec-2005  christos branches: 1.18.2; 1.18.4; 1.18.6;
merge ktrace-lwp.
 1.17 02-May-2005  kochi branches: 1.17.2;
Merge changes for ACPI-CA 20050408
 1.16 01-May-2004  kochi specify static where appropriate.
 1.15 11-Apr-2004  kochi split power button and sleep button HIDs so that they can be matched
against compatibility IDs.
 1.14 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.13 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.12 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.11 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.10 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.9 18-Apr-2003  thorpej branches: 1.9.2;
* Add a generic power management event API, defined in <sys/power.h>.
Right now, only power switch state change events are supported. This
is a work-in-progress.
* Add support to sysmon for delivering power mangement events to userland.
Add poll, kqueue, and read entry points to sysmon.
* Adapt ACPI to use the new generic <sys/power.h> event types.

This provides the kernel support for a forthcoming powerd(8) which can
do nice things like gracefully shut the system down when an ACPI power
button is pressed.
 1.8 17-Apr-2003  thorpej Oops, remove a debugging define.
 1.7 17-Apr-2003  thorpej * Don't do the ACPI_PCI_FIXUP unless it is explicitly enabled in
the kernel config file. That code makes a total mess of any
system with multiple PCI busses.
* Rework the way buttons are handled; register them with sysmon,
and let it take the appropriate action. This lets us gracefully
shut down when the power button is pressed.
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 10-Mar-2002  augustss Don't define ACPI_BUT_DEBUG here.
 1.2 13-Nov-2001  lukem branches: 1.2.2;
add RCSID
 1.1 28-Sep-2001  thorpej branches: 1.1.2; 1.1.4;
Add stub drivers for ACPI buttons and lid switches. These don't
really do anything yet.
 1.1.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 28-Sep-2001  nathanw file acpi_button.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 28-Sep-2001  fvdl file acpi_button.c was added on branch thorpej-devvp on 2001-10-01 12:44:14 +0000
 1.2.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 13-Nov-2001  thorpej file acpi_button.c was added on branch kqueue on 2002-01-10 19:52:52 +0000
 1.9.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.2.4 21-Jan-2008  yamt sync with head
 1.17.2.3 27-Oct-2007  yamt sync with head.
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.18.6.1 22-Apr-2006  simonb Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.2 01-Mar-2006  yamt sync with head.
 1.18.2.1 18-Feb-2006  yamt sync with head.
 1.20.16.2 10-Dec-2006  yamt sync with head.
 1.20.16.1 22-Oct-2006  yamt sync with head
 1.20.14.1 18-Nov-2006  ad Sync with head.
 1.22.28.2 13-Nov-2007  bouyer Sync with HEAD
 1.22.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.24.2 09-Jan-2008  matt sync with HEAD
 1.22.24.1 06-Nov-2007  matt sync with HEAD
 1.22.22.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.22.22.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.22.22.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.22.2 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.22.22.1 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.22.8.1 23-Oct-2007  ad Sync with head.
 1.24.6.1 11-Dec-2007  yamt sync with head.
 1.24.4.1 26-Dec-2007  ad Sync with head.
 1.25.32.1 21-Apr-2010  matt sync to netbsd-5
 1.25.28.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.24.1 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.25.14.6 09-Oct-2010  yamt sync with head
 1.25.14.5 11-Aug-2010  yamt sync with head.
 1.25.14.4 11-Mar-2010  yamt sync with head
 1.25.14.3 16-Sep-2009  yamt sync with head
 1.25.14.2 19-Aug-2009  yamt sync with head.
 1.25.14.1 16-May-2009  yamt sync with head
 1.30.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.30.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.30.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.2.2 05-Mar-2011  rmind sync with head
 1.34.2.1 30-May-2010  rmind sync with head
 1.39.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.39.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.39.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.41.32.1 06-Jun-2015  skrll Sync with HEAD
 1.41.14.1 03-Dec-2017  jdolecek update from HEAD
 1.42.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 31-Jan-2025  jmcneill acpi: cppc: Use frequency instead of performance units in sysctl interface.

When possible, use frequency instead of abstract performance units in
the sysctl interface.
 1.2 29-Jan-2021  thorpej branches: 1.2.24;
Use acpi_compatible_match().
 1.1 13-Dec-2020  jmcneill branches: 1.1.2;
acpi: Add support for Collaborative Processor Performance Control (CPPC).

CPPC is the modern replacement for processor performance controls (P-states
and T-states). The _CPC method on a processor device contains information
about supported performance levels of the device.

This driver reports the supported performance levels and allows for
setting the desired level using the machdep.cpufreq.cpuN.* sysctls. Note
that a "performance level" value is not guaranteed to represent a CPU
frequency, so treat the numbers reported as such.
 1.1.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.1.2.2 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1.2.1 13-Dec-2020  thorpej file acpi_cppc.c was added on branch thorpej-futex on 2020-12-14 14:38:05 +0000
 1.2.24.1 02-Aug-2025  perseant Sync with HEAD
 1.53 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.52 16-Mar-2020  pgoyette branches: 1.52.4;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.51 01-Jun-2017  chs branches: 1.51.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.50 25-Feb-2014  pooka branches: 1.50.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.49 27-Mar-2012  jruoho branches: 1.49.2; 1.49.4;
Fix a regression introduced during the change of the DMI naming conventions
(rev. 1.48). Also add a quirk for ASUSTeK's M2A-MX in order to allow
powernow(4) to attach (reported by bouyer@).
 1.48 14-Nov-2011  jmcneill branches: 1.48.4;
add a machdep.dmi sysctl tree with the following read-only keys:
system-vendor, system-product, system-version, system-serial, system-uuid
bios-vendor, bios-version
board-vendor, board-product, board-version, board-serial
the *-serial and *-uuid keys are marked with CTLFLAG_PRIVATE

a few of the pmf platform key names changed so update callers to match
 1.47 27-Oct-2011  jruoho branches: 1.47.2;
Revert the revision 1.5 in cpufreq(9). Instead, document that the KPI can
not be used before interrupts have been enabled. Suggested by macallan@.
 1.46 20-Oct-2011  jruoho Initialize P-states to P0 (i.e. the highest frequency).
 1.45 18-Oct-2011  jruoho Convert to use cpufreq(9).
 1.44 22-Jun-2011  jruoho Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.43 21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.42 20-Jun-2011  jruoho Use the new acpi_match_cpu_info() from acpi_util.c.
 1.41 12-Jun-2011  jruoho Move the evaluation of the _PDC control method out from the acpicpu(4)
driver to the main acpi(4) stack. Follow Linux and evaluate it early.
Should fix PR port-amd64/42895, possibly also PR kern/42583, and many
other comparable bugs.

A common sense explanation is that Intel supplies additional CPU tables to
OEMs. BIOS writers do not bother to modify their DSDTs, but instead load
these extra tables dynamically as secondary SSDT tables. The actual Load()
happens when the _PDC method is invoked, and thus namespace errors occur
when the CPU-specific ACPI methods are not yet present but referenced in the
AML by various drivers, including, but not limited to, acpitz(4).
 1.40 25-Apr-2011  jruoho branches: 1.40.2;
Add a missing case value in a switch statement.
 1.39 24-Mar-2011  jruoho Remove the "simple CPU lock" that was unnecessary.
Thanks to rmind@ for clarifications.
 1.38 19-Mar-2011  jruoho Like in rest of the acpi(4) stack, queue all resume hooks.
 1.37 05-Mar-2011  jruoho branches: 1.37.2;
Add __cpu_simple_lock_t. Use it, x86_read_psl(), and x86_disable_intr() to
disable interrupts locally and protect the access to APERF and MPERF. Also
rationalize the MD initialization sequence.
 1.36 03-Mar-2011  jruoho Add DMI quirk support via pmf_get_platform(9). If any of the listed models
are matched, the whole driver will be prevented from attaching. The first
entry is Supermicro PDSMi-LN4+ (a BIOS bug with bogus P-state entries).
 1.35 02-Mar-2011  jruoho Append Intel's Turbo Boost to the debug printfs if we detect it.
 1.34 01-Mar-2011  jruoho Detach evcnt(9) before the states.
 1.33 01-Mar-2011  jruoho Move also the evcnt(9) event counters to one place. No functional change.
 1.32 01-Mar-2011  jruoho Simplify by moving the debug printfs to one place. No functional change.
 1.31 27-Feb-2011  jruoho Provide MD wrappers for match and attach.
 1.30 27-Feb-2011  jruoho Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".
 1.29 25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.28 25-Feb-2011  jruoho Rename couple of badly named functions for consistency. No functional change.
 1.27 25-Feb-2011  jruoho Store a pointer to cpu_info rather than cpu_info::ci_acpiid alone.
 1.26 16-Feb-2011  jruoho Use ioconf for the module declarations.
 1.25 13-Jan-2011  jruoho branches: 1.25.2; 1.25.4;
Do not try to attach more ACPI CPUs than the amount of "real" CPUs.
 1.24 30-Dec-2010  jruoho Change the default behavior to enforce the maximum frequency when the
firmware requests to do so. This cures severe overhating (> 120 C) observed
on many laptops, being also on par with the specification(s). This can be
reverted by using the new "hw.acpi.cpu.dynamic" sysctl variable.
 1.23 28-Oct-2010  jruoho Fix a comment typo.
 1.22 27-Aug-2010  jruoho Fix PR kern/43765 from Scott Ellis.

Note that the solution is not optimal. If ichlpcib(4) provides SpeedStep
support, possible I/O resource conflicts may occur with acpicpu(4). Ideally,
as noted for instance in Windows design documents, ichlpcib(4) should never
expose SpeedStep when ACPI is being used. The probability for potential race
conditions is however very small, being limited to few P4-era machines and
being dependent on user actions.
 1.21 27-Aug-2010  jruoho From jmcneill@: fix and rework the obscure _OSC evaluation.
 1.20 19-Aug-2010  jruoho Deal with autoconfiguration madness by using config_defer(9) to defer
config_interrupts(9) to be executed. This is necessary because: (a) the
initialization routines must be run only once after interrupts are enabled
and (b) all ACPI CPUs have attached.
 1.19 17-Aug-2010  jruoho Add support for the optional dynamic minimum (in terms of MHz) via _PDL.
Comparable to T-states, this gives effectively a window of available
performance states for passive cooling. An example:

Init: max = 0, min = Pn.

Time j. Time j + 1.
----------- -----------
2000 MHz P0 max P0
P1 P1 max
P2 ==> P2
P3 P3 min
P4 P4
P5 min P5
500 Mhz Pn Pn
----------- -----------

Search: repeat (i = P0; i <= P5) repeat (i = P1; i <= P3)
 1.18 16-Aug-2010  jruoho branches: 1.18.2;
Two changes:

1. Initialize P-states properly to P0. It is processor-specific
what value we might get without initialization. (Some AMD CPUs
have even specific registers for the state after cold reset.)

2. Following design notes for Windows, set the lowest-power P-state
upon suspend and restore the saved state after resume.
 1.17 16-Aug-2010  jruoho Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.16 14-Aug-2010  jruoho Check the cold-flag also in the notify handler.
 1.15 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.14 11-Aug-2010  jruoho branches: 1.14.2;
Check the 'sc->sc_cold' flag also in P-state code, and set this flag once
we start the detachment routine.
 1.13 08-Aug-2010  jruoho jmcneill@: do not touch the bus_space(9) handle.
 1.12 08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.11 04-Aug-2010  jruoho Store the MADT-derived CPU ID to <x86/cpu.h>. This is required to properly
match the ACPI processor object ID with the ID available in the APIC table.
 1.10 30-Jul-2010  jruoho On second thought, rename the mutex so it can be (logically) shared. We will
not need such granularity that different states would require a different lock.
 1.9 29-Jul-2010  jruoho Add a per ACPI CPU mutex for C-states. Protect the _CST update with this:
when the idle-information is being updated (e.g. due acpiacad(4) events),
we can not enter the idle-loop. The lock must run at the same priority
(IPL_NONE) as ACPICA's mutexes obtained via AcpiOsCreateMutex() a.k.a.
AcpiOsCreateSemaphore(). Also check want_resched as the first thing and
clarify the suspend/resume path.

There is still one race condition identified: when the driver is loaded as a
module, we must gracefully kick all CPUs out from the ACPI idle-loop upon
detachment.
 1.8 26-Jul-2010  jruoho Fix wrong return value.
 1.7 25-Jul-2010  jruoho Improve comments. Move the #ifdef around.
 1.6 24-Jul-2010  jruoho Remove the currently unnecessary mutex.
 1.5 23-Jul-2010  jruoho Remove the recently added ACPICPU_FLAG_INIT and instead operate with the
existing ACPICPU_FLAG_C, as was intended. Set that flag only after the
idle-loop has been installed, so that the notify handler errors out if an
interrupt is received before the idle-loop is in place.
 1.4 21-Jul-2010  cegger ACPI enumerates cpus with 0..n.
Fixes panic reported by Patrick Welche on current-users@
Fixes panic on my own HP Pavilion laptop
 1.3 19-Jul-2010  christos XXX: If this is not correct, revert or fix.
This makes my laptop boot instead of panic:

panic: kernel diagnostic assertion "native_idle != NULL" failed: file "../../../../arch/x86/acpi/acpi_cpu_md.c", line 155
fatal breakpoint trap in supervisor mode
type 1 code 0 rip ffffffff8022e4ad cs 8 rflags 246 cr2 0 cpl 0 rsp ffff80004c37db10

trace
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
acpicpu_md_idle_stop() at netbsd:acpicpu_md_idle_stop+0x62
acpicpu_cstate_callback() at netbsd:acpicpu_cstate_callback+0x34
sysmon_task_queue_thread() at netbsd:sysmon_task_queue_thread+0x41

1. ACPI seems to define cpuids 1..n; we define 0..n-1. Adjust for that
2. My laptop is dual core, but ACPI reports 4 cpu nodes. Instead of
attaching the unmatched ones, make the match fail. Do we want to
attach and do nothing instead?
3. Create a flag, and only set it after we are completely initialized,
so the sysmon thread does not try to access unitialized state.
 1.2 18-Jul-2010  jruoho Add missing CVS identifiers.
 1.1 18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.14.2.3 09-Oct-2010  yamt sync with head
 1.14.2.2 11-Aug-2010  yamt sync with head.
 1.14.2.1 11-Aug-2010  yamt file acpi_cpu.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:15 +0000
 1.18.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.18.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.18.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.18.2.1 16-Aug-2010  uebayasi file acpi_cpu.c was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.25.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.25.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.25.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.2.5 31-May-2011  rmind sync with head
 1.37.2.4 21-Apr-2011  rmind sync with head
 1.37.2.3 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.37.2.2 05-Mar-2011  rmind sync with head
 1.37.2.1 05-Mar-2011  rmind file acpi_cpu.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.40.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.47.2.2 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.47.2.1 17-Apr-2012  yamt sync with head
 1.48.4.1 05-Apr-2012  mrg sync to latest -current.
 1.49.4.1 18-May-2014  rmind sync with head
 1.49.2.2 03-Dec-2017  jdolecek update from HEAD
 1.49.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.6.1 28-Aug-2017  skrll Sync with HEAD
 1.51.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.52.4.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.45 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.44 27-Apr-2012  jruoho branches: 1.44.54;
Remove the upper limit for the number of T-states.
 1.43 18-Oct-2011  jruoho branches: 1.43.2; 1.43.6; 1.43.8;
Convert to use cpufreq(9).
 1.42 22-Jun-2011  jruoho Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.41 12-Jun-2011  jruoho Move the evaluation of the _PDC control method out from the acpicpu(4)
driver to the main acpi(4) stack. Follow Linux and evaluate it early.
Should fix PR port-amd64/42895, possibly also PR kern/42583, and many
other comparable bugs.

A common sense explanation is that Intel supplies additional CPU tables to
OEMs. BIOS writers do not bother to modify their DSDTs, but instead load
these extra tables dynamically as secondary SSDT tables. The actual Load()
happens when the _PDC method is invoked, and thus namespace errors occur
when the CPU-specific ACPI methods are not yet present but referenced in the
AML by various drivers, including, but not limited to, acpitz(4).
 1.40 24-Mar-2011  jruoho branches: 1.40.2;
Remove the "simple CPU lock" that was unnecessary.
Thanks to rmind@ for clarifications.
 1.39 19-Mar-2011  jruoho Like in rest of the acpi(4) stack, queue all resume hooks.
 1.38 17-Mar-2011  jruoho Properly set the frequency during suspend and resume. Should fix problems
introduced in the revision 1.42. Pointed out by Taylor C. Campbell.
 1.37 05-Mar-2011  jruoho branches: 1.37.2;
Add __cpu_simple_lock_t. Use it, x86_read_psl(), and x86_disable_intr() to
disable interrupts locally and protect the access to APERF and MPERF. Also
rationalize the MD initialization sequence.
 1.36 04-Mar-2011  jruoho Rename a badly named constant. Make it correspond with <x86/specialreg.h>.
 1.35 01-Mar-2011  jruoho Move the xcall(9) that does the P- and T-state transformations from the MD
layer to the main code. Makes the caches coherent and provides consistent
vmstat(1) output. This is still not quite right, given that most of the
cross-calls are typically unnecessary with the dependency coordination.
 1.34 27-Feb-2011  jruoho Provide MD wrappers for match and attach.
 1.33 25-Feb-2011  jruoho Comment the coordination types.
 1.32 25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.31 25-Feb-2011  jruoho Rename couple of badly named functions for consistency. No functional change.
 1.30 25-Feb-2011  jruoho Add preliminary support for the IA32_APERF and IA32_MPERF frequency counters.
These are not yet used for anything and only Intel is supported at the moment.
 1.29 25-Feb-2011  jruoho Store a pointer to cpu_info rather than cpu_info::ci_acpiid alone.
 1.28 13-Jan-2011  jruoho branches: 1.28.2; 1.28.4;
Move the function that counts the CPUs from acpicpu(4) to the MD layer.
 1.27 30-Dec-2010  jruoho Change the default behavior to enforce the maximum frequency when the
firmware requests to do so. This cures severe overhating (> 120 C) observed
on many laptops, being also on par with the specification(s). This can be
reverted by using the new "hw.acpi.cpu.dynamic" sysctl variable.
 1.26 30-Nov-2010  jruoho Add AMD C1E quirk. Tested by cegger@.

(a) This should be removed once C-states are supported.

(b) As there seems to be no reliable way to detect whether C1E is present,
the quirk blindly assumes that C1E is used on families 10h and 11h.
 1.25 27-Aug-2010  jruoho Fix PR kern/43765 from Scott Ellis.

Note that the solution is not optimal. If ichlpcib(4) provides SpeedStep
support, possible I/O resource conflicts may occur with acpicpu(4). Ideally,
as noted for instance in Windows design documents, ichlpcib(4) should never
expose SpeedStep when ACPI is being used. The probability for potential race
conditions is however very small, being limited to few P4-era machines and
being dependent on user actions.
 1.24 24-Aug-2010  jruoho Add native support for AMD family 0Fh processors. This is the furthest we
will go backwards; K7 will not be supported already due doubts about
availability and reliability of ACPI during that era. Some unfortunate code
duplication is present (but not overly much). Thanks to cegger@ and jakllsch@
for patiently testing this.
 1.23 23-Aug-2010  jruoho Other entry points beyond x86_cpu_idle_halt() may use HLT as the
idle-mechanism. Send an IPI also for these in cpu_need_resched().
 1.22 21-Aug-2010  jruoho Check from CPUID 0x06 %eax (on Intel) whether we might actually have an
invariant APIC timer or an "ARAT" ("always running APIC timer"). This means
that the APIC timer may keep ticking at the same rate also in deep C-states
with some new or forthcoming Intel CPUs.
 1.21 21-Aug-2010  jruoho Detect whether TSC is invariant, which may be the case on both new AMD and
Intel processors. The invariance means that TSC runs at a constant rate
during all ACPI state changes. If it is variant, skew may occur and TSC is
generally unsuitable for wall clock services. This is especially relevant
with C-states; with variant TSC, the whole counter may be stopped with states
larger than C1. All x86 CPUs before circa mid-2000s can be assumed to have a
variant time stamp counter.
 1.20 20-Aug-2010  jruoho Add two flags that needs to be dealt with (hardware vs. software
coordination of P-state transitions, and Turbo Boost / Turbo Core).
 1.19 18-Aug-2010  jruoho Use the idea from cegger@ and fill the (X)PSS structure during initialization.
 1.18 17-Aug-2010  jruoho Add support for the optional dynamic minimum (in terms of MHz) via _PDL.
Comparable to T-states, this gives effectively a window of available
performance states for passive cooling. An example:

Init: max = 0, min = Pn.

Time j. Time j + 1.
----------- -----------
2000 MHz P0 max P0
P1 P1 max
P2 ==> P2
P3 P3 min
P4 P4
P5 min P5
500 Mhz Pn Pn
----------- -----------

Search: repeat (i = P0; i <= P5) repeat (i = P1; i <= P3)
 1.17 16-Aug-2010  jruoho branches: 1.17.2;
Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.16 16-Aug-2010  jruoho Add support for Extended PSS ACPI Method Specification from Microsoft.
This will greatly simplify supporting PowerNow! on conforming systems.
 1.15 14-Aug-2010  jruoho Move the PIIX4-quirk to the MD file and disable T-states for PIIX4.
 1.14 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.13 11-Aug-2010  jruoho branches: 1.13.2;
Use a define instead of a magic constant for the arbitrary P-state limit.
 1.12 10-Aug-2010  jruoho Use evcnt(9) for the counters.
 1.11 09-Aug-2010  jruoho Remove a redundant function.
 1.10 08-Aug-2010  jruoho jmcneill@: do not touch the bus_space(9) handle.
 1.9 08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.8 30-Jul-2010  jruoho On second thought, rename the mutex so it can be (logically) shared. We will
not need such granularity that different states would require a different lock.
 1.7 29-Jul-2010  jruoho Add a per ACPI CPU mutex for C-states. Protect the _CST update with this:
when the idle-information is being updated (e.g. due acpiacad(4) events),
we can not enter the idle-loop. The lock must run at the same priority
(IPL_NONE) as ACPICA's mutexes obtained via AcpiOsCreateMutex() a.k.a.
AcpiOsCreateSemaphore(). Also check want_resched as the first thing and
clarify the suspend/resume path.

There is still one race condition identified: when the driver is loaded as a
module, we must gracefully kick all CPUs out from the ACPI idle-loop upon
detachment.
 1.6 27-Jul-2010  jruoho Move the GAS definition to the header so it can be shared. Make a basic
sanity check before casting to the GAS. Rename the _CSD structure; the
optional "cross logical processor dependency information" is almost
identical in C, P, and T states. Add some comments to the header.
 1.5 23-Jul-2010  jruoho Add a new flag that determines whether we should check for bus master
activity (BM_STS) by reading from the PM1 register. According to the Intel
processor specification for ACPI, the FFH GAS encoding may provide a hint
that the check is not required. This may help some systems to enter C2/C3
even when e.g. usb(4) keeps the BM_STS bit always enabled.
 1.4 23-Jul-2010  jruoho Remove the recently added ACPICPU_FLAG_INIT and instead operate with the
existing ACPICPU_FLAG_C, as was intended. Set that flag only after the
idle-loop has been installed, so that the notify handler errors out if an
interrupt is received before the idle-loop is in place.
 1.3 19-Jul-2010  christos XXX: If this is not correct, revert or fix.
This makes my laptop boot instead of panic:

panic: kernel diagnostic assertion "native_idle != NULL" failed: file "../../../../arch/x86/acpi/acpi_cpu_md.c", line 155
fatal breakpoint trap in supervisor mode
type 1 code 0 rip ffffffff8022e4ad cs 8 rflags 246 cr2 0 cpl 0 rsp ffff80004c37db10

trace
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
acpicpu_md_idle_stop() at netbsd:acpicpu_md_idle_stop+0x62
acpicpu_cstate_callback() at netbsd:acpicpu_cstate_callback+0x34
sysmon_task_queue_thread() at netbsd:sysmon_task_queue_thread+0x41

1. ACPI seems to define cpuids 1..n; we define 0..n-1. Adjust for that
2. My laptop is dual core, but ACPI reports 4 cpu nodes. Instead of
attaching the unmatched ones, make the match fail. Do we want to
attach and do nothing instead?
3. Create a flag, and only set it after we are completely initialized,
so the sysmon thread does not try to access unitialized state.
 1.2 18-Jul-2010  jruoho Add missing CVS identifiers.
 1.1 18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.13.2.3 09-Oct-2010  yamt sync with head
 1.13.2.2 11-Aug-2010  yamt sync with head.
 1.13.2.1 11-Aug-2010  yamt file acpi_cpu.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:15 +0000
 1.17.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.17.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.17.2.1 16-Aug-2010  uebayasi file acpi_cpu.h was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.28.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.2.4 21-Apr-2011  rmind sync with head
 1.37.2.3 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.37.2.2 05-Mar-2011  rmind sync with head
 1.37.2.1 05-Mar-2011  rmind file acpi_cpu.h was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.40.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.43.8.1 17-Dec-2013  riz Pull up following revision(s) (requested by bouyer in ticket #984):
sys/dev/acpi/acpi_cpu.h: revision 1.44
sys/dev/acpi/acpi_cpu_tstate.c: revision 1.31
Remove the upper limit for the number of T-states.
 1.43.6.1 29-Apr-2012  mrg sync to latest -current.
 1.43.2.1 23-May-2012  yamt sync with head.
 1.44.54.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.63 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.62 04-Jun-2020  riastradh branches: 1.62.2;
Nix trailing whitespace. NFCI.
 1.61 31-May-2020  ad Disable read of the ACPI timer during idle, fixing performance degradation
observed with acpicpu. C1 (MWAIT) is the deepest sleep currently enabled so
there should be no functional change. Also, the computed nap time is run
through hztoms() which seems incorrect as the ACPI timer is running in the
MHz range.
 1.60 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.59 25-Feb-2012  jruoho branches: 1.59.40;
Set the flag for checking for PCI bus master activity only for C3.
 1.58 13-Oct-2011  jruoho branches: 1.58.2; 1.58.6; 1.58.8;
Remove bogus assertion that came with revisions 1.55-1.56.
 1.57 06-Aug-2011  jruoho Improve a comment.
 1.56 05-Aug-2011  mrg relax an assert slightly, from jmcneill.
 1.55 04-Aug-2011  jmcneill Don't treat C2 states as C1 if the _CST package doesn't have an entry
for C1. ACPI mandates C1 so if it's not present in the _CST package use
the HLT method. Fixes all sorts of performance regressions on AMD CPUs.
 1.54 13-Jul-2011  jruoho Do not disable interrupts at machine-level in the MI idle-loop entry.
 1.53 22-Jun-2011  jruoho Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.52 19-Mar-2011  jruoho Like in rest of the acpi(4) stack, queue all resume hooks.
 1.51 17-Mar-2011  jruoho Add a comment.
 1.50 04-Mar-2011  jruoho branches: 1.50.2;
Remove redundant/wrong increment of a variable.
 1.49 01-Mar-2011  jruoho Move also the evcnt(9) event counters to one place. No functional change.
 1.48 01-Mar-2011  jruoho Use __arraycount(3).
 1.47 01-Mar-2011  jruoho Simplify by moving the debug printfs to one place. No functional change.
 1.46 25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.45 25-Feb-2011  jruoho Rename couple of badly named functions for consistency. No functional change.
 1.44 23-Feb-2011  jruoho Adjust the previous and add a comment for it.
 1.43 22-Feb-2011  jruoho Fix previous. Not my day.
 1.42 22-Feb-2011  jruoho Yet another small fix to the C-state parsing. As can be seen from the _CST
object noted in the revision 1.40, there is only one C-state on the machine,
yet the BIOS define its type as C2. Thus, instead of relying on the BIOS
data, sequentially count the parsed C-states.
 1.41 22-Feb-2011  jmcneill make this build again
 1.40 22-Feb-2011  jruoho After a closer examination, remove entirely the check that was considered in
the revision 1.38. As noted in the specification (ACPI 4.0, p. 314):

The platform must expose a _CST object for either all or none of its
processors. If the _CST object exists, OSPM uses the C state information
specified in the _CST object in lieu of P_LVL2 and P_LVL3 registers
defined in P_BLK and the P_LVLx_LAT values defined in the FADT.

The _CST is seemingly valid on the system under consideration:

Name (_CST, Package (0x02)
{
0x01,
Package (0x04)
{
ResourceTemplate ()
{
Register (SystemIO,
0x08, // Bit Width
0x00, // Bit Offset
0x000000000000F800, // Address
0x01, // Access Size
)
},

0x02,
0x0064,
0x00000000
}
})

The check was also unnecessary in the sense that ACPI doesn't use bus_space(9).
 1.39 22-Feb-2011  jruoho Always declare HALT as available. If ACPI_FADT_C1_SUPPORTED is not
set in the FADT, print a warning, as it is obviously a BIOS bug.
 1.38 22-Feb-2011  jruoho Only check if the register address in _CST is valid if the ACPI processor
object address is valid. Some systems define the Processor() as:

Scope (_PR)
{
Processor (C000, 0x00, 0x00000410, 0x06) {}
Processor (C001, 0x01, 0x00000000, 0x00) {}
Processor (C002, 0x02, 0x00000000, 0x00) {}
Processor (C003, 0x03, 0x00000000, 0x00) {}
}

This may be typical to AMD systems that do not seem to use _CST, but instead
operate with HLT (and C1E for the C3-state). The same check is already done
in acpicpu_cstate_fadt(). Note that it is unclear whether this violates the
specification, given:

"PBlockAddress provides the system I/O address for the processors
register block. Each processor can supply a different such address.
PBlockLength is the length of the processor register block, in bytes and
is either 0 (for no P_BLK) or 6. With one exception, all processors are
required to have the same PBlockLength. The exception is that the boot
processor can have a non-zero PBlockLength when all other processors
have a zero PBlockLength. It is valid for every processor to have a
PBlockLength of 0. (ACPI 4.0, p. 626)"
 1.37 30-Jan-2011  jruoho Improve error reporting.
 1.36 13-Jan-2011  jruoho branches: 1.36.2; 1.36.4;
Move the function that counts the CPUs from acpicpu(4) to the MD layer.
 1.35 04-Jan-2011  jruoho Revert the changes made in the commit:

"Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module."

Queueing the checks in the resume hooks was observed to improve the resume
time by several seconds (!) on a system with poorly implemented AML code.
The observed race condition is a wider issue related to modules; things like
sysmon_taskq(9) should be modified to allow cancelling of queued functions.
 1.34 30-Nov-2010  jruoho Add AMD C1E quirk. Tested by cegger@.

(a) This should be removed once C-states are supported.

(b) As there seems to be no reliable way to detect whether C1E is present,
the quirk blindly assumes that C1E is used on families 10h and 11h.
 1.33 23-Aug-2010  jruoho Other entry points beyond x86_cpu_idle_halt() may use HLT as the
idle-mechanism. Send an IPI also for these in cpu_need_resched().
 1.32 22-Aug-2010  jruoho Use acpi_timer_read_fast() instead of acpi_timer_read_safe().
 1.31 18-Aug-2010  jruoho Fix fix of a bug: first initialize sc, check sc != NULL, then KASSERT(9).
 1.30 17-Aug-2010  cegger build fix: first initialize sc then KASSERT
 1.29 16-Aug-2010  jruoho branches: 1.29.2;
Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.28 15-Aug-2010  jruoho Add comments and raise the minimum allowed T-state duty cycle to 10 %.
 1.27 14-Aug-2010  jruoho Do not accidentally write zeros to (PSTATE_CNT and CST_CNT) registers.
 1.26 14-Aug-2010  jruoho Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module.
 1.25 14-Aug-2010  jruoho Move the PIIX4-quirk to the MD file and disable T-states for PIIX4.
 1.24 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.23 11-Aug-2010  jruoho branches: 1.23.2;
Print the state information only once. The per-CPU information was quite
pointless as identical parameters are expected across processors.
 1.22 11-Aug-2010  jruoho Pretty printing.
 1.21 10-Aug-2010  jruoho Fix xref in a comment.
 1.20 10-Aug-2010  jruoho Add a XXX-comment as a TODO. From jmcneill@:

/*
* XXX: The pci_find_device(9) function only deals with
* attached devices. Change this to use something like
* pci_device_foreach(), and implement it for IA-64.
*/
 1.19 10-Aug-2010  jruoho Use evcnt(9) for the counters.
 1.18 09-Aug-2010  jruoho Remove a redundant function.
 1.17 09-Aug-2010  jruoho Downgrade the currently supported maximum C-state to C1. There appears to be
timer-related interrupt issues also in C2. With C1 it is guaranteed that
acpicpu(4) will not cause any slowdowns due stalled local APIC timer.
 1.16 08-Aug-2010  jruoho Improve error and debug messages.
 1.15 08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.14 04-Aug-2010  jruoho Store the MADT-derived CPU ID to <x86/cpu.h>. This is required to properly
match the ACPI processor object ID with the ID available in the APIC table.
 1.13 30-Jul-2010  jruoho On second thought, rename the mutex so it can be (logically) shared. We will
not need such granularity that different states would require a different lock.
 1.12 29-Jul-2010  jruoho Add a per ACPI CPU mutex for C-states. Protect the _CST update with this:
when the idle-information is being updated (e.g. due acpiacad(4) events),
we can not enter the idle-loop. The lock must run at the same priority
(IPL_NONE) as ACPICA's mutexes obtained via AcpiOsCreateMutex() a.k.a.
AcpiOsCreateSemaphore(). Also check want_resched as the first thing and
clarify the suspend/resume path.

There is still one race condition identified: when the driver is loaded as a
module, we must gracefully kick all CPUs out from the ACPI idle-loop upon
detachment.
 1.11 27-Jul-2010  jruoho Move the GAS definition to the header so it can be shared. Make a basic
sanity check before casting to the GAS. Rename the _CSD structure; the
optional "cross logical processor dependency information" is almost
identical in C, P, and T states. Add some comments to the header.
 1.10 25-Jul-2010  jruoho Improve comments. Move the #ifdef around.
 1.9 24-Jul-2010  jruoho Remove the currently unnecessary mutex.
 1.8 23-Jul-2010  jruoho Make sure we use MWAIT with MONITOR.

Also clarify when we have interrupts disabled.
 1.7 23-Jul-2010  jruoho Add a new flag that determines whether we should check for bus master
activity (BM_STS) by reading from the PM1 register. According to the Intel
processor specification for ACPI, the FFH GAS encoding may provide a hint
that the check is not required. This may help some systems to enter C2/C3
even when e.g. usb(4) keeps the BM_STS bit always enabled.
 1.6 23-Jul-2010  jruoho Remove the recently added ACPICPU_FLAG_INIT and instead operate with the
existing ACPICPU_FLAG_C, as was intended. Set that flag only after the
idle-loop has been installed, so that the notify handler errors out if an
interrupt is received before the idle-loop is in place.
 1.5 19-Jul-2010  christos XXX: If this is not correct, revert or fix.
This makes my laptop boot instead of panic:

panic: kernel diagnostic assertion "native_idle != NULL" failed: file "../../../../arch/x86/acpi/acpi_cpu_md.c", line 155
fatal breakpoint trap in supervisor mode
type 1 code 0 rip ffffffff8022e4ad cs 8 rflags 246 cr2 0 cpl 0 rsp ffff80004c37db10

trace
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
acpicpu_md_idle_stop() at netbsd:acpicpu_md_idle_stop+0x62
acpicpu_cstate_callback() at netbsd:acpicpu_cstate_callback+0x34
sysmon_task_queue_thread() at netbsd:sysmon_task_queue_thread+0x41

1. ACPI seems to define cpuids 1..n; we define 0..n-1. Adjust for that
2. My laptop is dual core, but ACPI reports 4 cpu nodes. Instead of
attaching the unmatched ones, make the match fail. Do we want to
attach and do nothing instead?
3. Create a flag, and only set it after we are completely initialized,
so the sysmon thread does not try to access unitialized state.
 1.4 18-Jul-2010  jruoho Fix build failure in i386/ALL. Again caused by a missing _COMPONENT
declaration required for ACPI_DEBUG. Noted by cegger@ -- thanks.
 1.3 18-Jul-2010  jruoho The first bug: do not error out if the latency values supplied in _CST are
larger than the upper limit constants. Only sanity check against these
defaults when operating with FADT. This is also noted in a fine print of the
specification (ACPI 4.0, p. 314): "[...] The worst-case latency to enter and
exit the C State (in microseconds). There are no latency restrictions."
 1.2 18-Jul-2010  jruoho Add missing CVS identifiers.
 1.1 18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.23.2.3 09-Oct-2010  yamt sync with head
 1.23.2.2 11-Aug-2010  yamt sync with head.
 1.23.2.1 11-Aug-2010  yamt file acpi_cpu_cstate.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:15 +0000
 1.29.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.29.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.29.2.1 16-Aug-2010  uebayasi file acpi_cpu_cstate.c was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.36.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.36.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.50.2.3 21-Apr-2011  rmind sync with head
 1.50.2.2 05-Mar-2011  rmind sync with head
 1.50.2.1 04-Mar-2011  rmind file acpi_cpu_cstate.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.58.8.1 27-Feb-2012  riz Pull up following revision(s) (requested by jruoho in ticket #51):
sys/dev/acpi/acpi_cpu_cstate.c: revision 1.59
Set the flag for checking for PCI bus master activity only for C3.
 1.58.6.1 04-Mar-2012  mrg sync to latest -current.
 1.58.2.1 17-Apr-2012  yamt sync with head
 1.59.40.1 10-Jun-2019  christos Sync with HEAD
 1.62.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.54 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.53 15-Nov-2011  jruoho branches: 1.53.66;
Add comment.
 1.52 18-Oct-2011  jruoho branches: 1.52.2;
Convert to use cpufreq(9).
 1.51 22-Jun-2011  jruoho Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.50 22-Jun-2011  jruoho Contrary to the previous, use aprint_error(9) but suppress warnings
caused by the (optional) BIOS-based dynamic voltage and frequency scaling.
 1.49 04-Jun-2011  jruoho Change some printfs to aprint_debug(9).
 1.48 01-Apr-2011  jruoho branches: 1.48.2;
Maintain the state properly during firmware-based DVFS.
 1.47 19-Mar-2011  jruoho Like in rest of the acpi(4) stack, queue all resume hooks.
 1.46 17-Mar-2011  jruoho Properly set the frequency during suspend and resume. Should fix problems
introduced in the revision 1.42. Pointed out by Taylor C. Campbell.
 1.45 05-Mar-2011  jruoho branches: 1.45.2;
Add __cpu_simple_lock_t. Use it, x86_read_psl(), and x86_disable_intr() to
disable interrupts locally and protect the access to APERF and MPERF. Also
rationalize the MD initialization sequence.
 1.44 01-Mar-2011  jruoho Move also the evcnt(9) event counters to one place. No functional change.
 1.43 01-Mar-2011  jruoho Simplify by moving the debug printfs to one place. No functional change.
 1.42 01-Mar-2011  jruoho Move the xcall(9) that does the P- and T-state transformations from the MD
layer to the main code. Makes the caches coherent and provides consistent
vmstat(1) output. This is still not quite right, given that most of the
cross-calls are typically unnecessary with the dependency coordination.
 1.41 27-Feb-2011  jruoho Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".
 1.40 25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.39 25-Feb-2011  jruoho Add preliminary support for the IA32_APERF and IA32_MPERF frequency counters.
These are not yet used for anything and only Intel is supported at the moment.
 1.38 23-Feb-2011  jruoho Lower the worst-case latency in P- and T-state transitions to 1 usec.
The previous 10 usec was based on the Intel's Core family. It may have been
improved since that. Also provide an arbitrary upper bound for BIOS bugs.
 1.37 30-Jan-2011  jruoho Improve error reporting.
 1.36 30-Dec-2010  jruoho branches: 1.36.2; 1.36.4;
Change the default behavior to enforce the maximum frequency when the
firmware requests to do so. This cures severe overhating (> 120 C) observed
on many laptops, being also on par with the specification(s). This can be
reverted by using the new "hw.acpi.cpu.dynamic" sysctl variable.
 1.35 20-Dec-2010  jruoho Use branch annotations in couple of places. Add two comments.
 1.34 28-Oct-2010  jruoho Only override data from XPSS if the conventional _PSS did not contain the
required information. Problem found and diagnosed by jakllsch@; on some AMD
systems vendors fill _PSS correctly, but do not duplicate the data in XPSS.
 1.33 21-Aug-2010  jmcneill - don't clobber the data found by _PSS if XPSS validation fails
- XPSS spec says that Status{,Mask} and Control{,Mask} buffers are 8 bytes
- use ACPI_GET64 macros instead of memcpy when reading from buffers

This makes acpicpu work again on my VIA C7-M, whose firmware reports
malformed XPSS packages but has a working _PSS
 1.32 20-Aug-2010  jruoho Give a hint about a driver conflict.
 1.31 20-Aug-2010  jruoho Check the cached value also when setting a state.
 1.30 18-Aug-2010  jruoho Use the idea from cegger@ and fill the (X)PSS structure during initialization.
 1.29 17-Aug-2010  jruoho Adjust locking for previous.
 1.28 17-Aug-2010  jruoho Clarify the initialization of the dynamic maximums/minimums. Reset these to
defaults upon suspend. As we do not know how well the firmware maintains
state, do not run the callbacks that evaluate the maximum/minimum on resume.
 1.27 17-Aug-2010  jruoho Add support for the optional dynamic minimum (in terms of MHz) via _PDL.
Comparable to T-states, this gives effectively a window of available
performance states for passive cooling. An example:

Init: max = 0, min = Pn.

Time j. Time j + 1.
----------- -----------
2000 MHz P0 max P0
P1 P1 max
P2 ==> P2
P3 P3 min
P4 P4
P5 min P5
500 Mhz Pn Pn
----------- -----------

Search: repeat (i = P0; i <= P5) repeat (i = P1; i <= P3)
 1.26 16-Aug-2010  jruoho branches: 1.26.2;
Fix comments.
 1.25 16-Aug-2010  jruoho Two changes:

1. Initialize P-states properly to P0. It is processor-specific
what value we might get without initialization. (Some AMD CPUs
have even specific registers for the state after cold reset.)

2. Following design notes for Windows, set the lowest-power P-state
upon suspend and restore the saved state after resume.
 1.24 16-Aug-2010  jruoho Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.23 16-Aug-2010  jmcneill make it compile again
 1.22 16-Aug-2010  jruoho If XPSS is used, only invalidate P-states if the control MSR address is zero.
If the status address is zero, we will bluntly bypass the transition check.
 1.21 16-Aug-2010  jruoho Add support for Extended PSS ACPI Method Specification from Microsoft.
This will greatly simplify supporting PowerNow! on conforming systems.
 1.20 16-Aug-2010  jruoho Do not error out neither in P-states nor in T-states if the method for the
dynamic maximum is nonexistent. Unsurprisingly, there is vagueness in the
standards; in ACPI 3.0 and 4.0 it is clearly indicated that also these methods
must be present, but the earlier standards are less stringent. Without too
much effort, at least one old P4-system was located that lacks _PPC.
 1.19 14-Aug-2010  jruoho Do not accidentally write zeros to (PSTATE_CNT and CST_CNT) registers.
 1.18 14-Aug-2010  jruoho Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module.
 1.17 13-Aug-2010  jruoho Instead of packing structures that do not need to be __packed, remove two
CTASSERT(9) macros. Fixes build failure on AMD64 noted by cegger@.
 1.16 13-Aug-2010  jruoho Remove some unnecessary locking. Mainly a leftover from previous revisions
where the dynamic maximum/minimum was used also when retrieving the current
state. The state-array itself changes only in C-states.
 1.15 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.14 12-Aug-2010  jruoho Three small things: (1) fix off by one, (2) protect the cached P-state
(required for interaction with T-states), and (3) use aprint_debug(9)
instead of the ACPI_DEBUG_PRINT(x) macro for the dynamic frequency changes
(for the time being, people need easier way to observe the dynamic changes).
 1.13 11-Aug-2010  jruoho branches: 1.13.2;
Properly protect against garbage values.
 1.12 11-Aug-2010  jruoho Print the state information only once. The per-CPU information was quite
pointless as identical parameters are expected across processors.
 1.11 11-Aug-2010  jruoho Check the 'sc->sc_cold' flag also in P-state code, and set this flag once
we start the detachment routine.
 1.10 11-Aug-2010  jruoho Add a small additional check for the validity of the GAS register.
 1.9 11-Aug-2010  jruoho Use a define instead of a magic constant for the arbitrary P-state limit.
 1.8 11-Aug-2010  jruoho Pretty printing.
 1.7 10-Aug-2010  jruoho Use evcnt(9) for the counters.
 1.6 09-Aug-2010  jruoho On systems where both the existing EST code and the one provided by ACPI are
functional, the previously loaded EST code may have used frequencies that
are not present in the BIOS. This will cause failures since acpicpu(4) will
treat these unknown frequencies as errors. "Fix" this by initializing the
cached P-state to P0, regardless of what the true state might be.
 1.5 09-Aug-2010  jruoho When retrieving the current frequency, scan all available P-states.
Only use the dynamic maximum when setting a frequency.
 1.4 08-Aug-2010  jruoho Improve error and debug messages.
 1.3 08-Aug-2010  jruoho As per jmcneill@'s suggestion, improve error reporting.
 1.2 08-Aug-2010  jruoho Remove bogus check and allow all CPUs to use I/O-based P-states.
 1.1 08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.13.2.3 09-Oct-2010  yamt sync with head
 1.13.2.2 11-Aug-2010  yamt sync with head.
 1.13.2.1 11-Aug-2010  yamt file acpi_cpu_pstate.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:15 +0000
 1.26.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.26.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.26.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.26.2.1 16-Aug-2010  uebayasi file acpi_cpu_pstate.c was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.36.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.36.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.2.5 12-Jun-2011  rmind sync with head
 1.45.2.4 21-Apr-2011  rmind sync with head
 1.45.2.3 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.45.2.2 05-Mar-2011  rmind sync with head
 1.45.2.1 05-Mar-2011  rmind file acpi_cpu_pstate.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.48.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.52.2.1 17-Apr-2012  yamt sync with head
 1.53.66.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.34 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.33 01-Jun-2017  chs branches: 1.33.24;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.32 20-Nov-2013  jruoho branches: 1.32.6;
As discussed with bouyer@, fix a too eager T-state validation check to
accomodate new Intel CPUs.
 1.31 27-Apr-2012  jruoho branches: 1.31.2; 1.31.4;
Remove the upper limit for the number of T-states.
 1.30 22-Jun-2011  jruoho branches: 1.30.2; 1.30.6; 1.30.8;
Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.29 22-Jun-2011  jruoho Contrary to the previous, use aprint_error(9) but suppress warnings
caused by the (optional) BIOS-based dynamic voltage and frequency scaling.
 1.28 04-Jun-2011  jruoho Change some printfs to aprint_debug(9).
 1.27 19-Mar-2011  jruoho branches: 1.27.2;
Like in rest of the acpi(4) stack, queue all resume hooks.
 1.26 01-Mar-2011  jruoho branches: 1.26.2;
Move also the evcnt(9) event counters to one place. No functional change.
 1.25 01-Mar-2011  jruoho Simplify by moving the debug printfs to one place. No functional change.
 1.24 01-Mar-2011  jruoho Move the xcall(9) that does the P- and T-state transformations from the MD
layer to the main code. Makes the caches coherent and provides consistent
vmstat(1) output. This is still not quite right, given that most of the
cross-calls are typically unnecessary with the dependency coordination.
 1.23 25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.22 25-Feb-2011  jruoho Clarify a comment.
 1.21 23-Feb-2011  jruoho Lower the worst-case latency in P- and T-state transitions to 1 usec.
The previous 10 usec was based on the Intel's Core family. It may have been
improved since that. Also provide an arbitrary upper bound for BIOS bugs.
 1.20 18-Feb-2011  jruoho Remove the (debug) check that evaluated whether the first T-state (i.e. the
100 % duty cycle) had control value of zero, as in the IA32 clock modulation
MSR. As the access may be based on I/O, it is unclear if a strict validation
like this was correct. Should fix the problem reported by Hisashi T Fujinaka
on current users.
 1.19 30-Jan-2011  jruoho Improve error reporting.
 1.18 30-Dec-2010  jruoho branches: 1.18.2; 1.18.4;
Change the default behavior to enforce the maximum frequency when the
firmware requests to do so. This cures severe overhating (> 120 C) observed
on many laptops, being also on par with the specification(s). This can be
reverted by using the new "hw.acpi.cpu.dynamic" sysctl variable.
 1.17 20-Dec-2010  jruoho Use branch annotations in couple of places. Add two comments.
 1.16 21-Aug-2010  jruoho branches: 1.16.2;
After discussion with jakllsch@ and jmcneill@, revert the previous and only
do the status-check when the comparison value reported by BIOS is not zero.
The uncertainty noted in the previous commit still applies. But if we ever
see a timeout again, it will likely be either a firmware bug or a special
case like the Intel Turbo Boost.
 1.15 20-Aug-2010  jruoho Check the cached value also when setting a state.
 1.14 17-Aug-2010  jruoho Adjust locking for previous.
 1.13 17-Aug-2010  jruoho Clarify the initialization of the dynamic maximums/minimums. Reset these to
defaults upon suspend. As we do not know how well the firmware maintains
state, do not run the callbacks that evaluate the maximum/minimum on resume.
 1.12 17-Aug-2010  jruoho Add support for the optional dynamic minimum (in terms of MHz) via _PDL.
Comparable to T-states, this gives effectively a window of available
performance states for passive cooling. An example:

Init: max = 0, min = Pn.

Time j. Time j + 1.
----------- -----------
2000 MHz P0 max P0
P1 P1 max
P2 ==> P2
P3 P3 min
P4 P4
P5 min P5
500 Mhz Pn Pn
----------- -----------

Search: repeat (i = P0; i <= P5) repeat (i = P1; i <= P3)
 1.11 16-Aug-2010  jruoho branches: 1.11.2;
Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.10 16-Aug-2010  jruoho Do not error out neither in P-states nor in T-states if the method for the
dynamic maximum is nonexistent. Unsurprisingly, there is vagueness in the
standards; in ACPI 3.0 and 4.0 it is clearly indicated that also these methods
must be present, but the earlier standards are less stringent. Without too
much effort, at least one old P4-system was located that lacks _PPC.
 1.9 15-Aug-2010  jruoho Add comments and raise the minimum allowed T-state duty cycle to 10 %.
 1.8 15-Aug-2010  jruoho Properly deal with the previous FADT-issue.
 1.7 14-Aug-2010  jruoho Simplify the FADT-based entry by "faking" (overriding) also the address.
 1.6 14-Aug-2010  jruoho Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
There is a small and unlikely race when the drivers are loaded as modules;
suspend, resume, queue a function, and immediately unload the module.
 1.5 14-Aug-2010  jruoho Move the PIIX4-quirk to the MD file and disable T-states for PIIX4.
 1.4 13-Aug-2010  jruoho Explicitly include <sys/evcnt.h>.
 1.3 13-Aug-2010  jruoho Instead of packing structures that do not need to be __packed, remove two
CTASSERT(9) macros. Fixes build failure on AMD64 noted by cegger@.
 1.2 13-Aug-2010  jruoho Remove some unnecessary locking. Mainly a leftover from previous revisions
where the dynamic maximum/minimum was used also when retrieving the current
state. The state-array itself changes only in C-states.
 1.1 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.11.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.2.1 16-Aug-2010  uebayasi file acpi_cpu_tstate.c was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.16.2.2 09-Oct-2010  yamt sync with head
 1.16.2.1 21-Aug-2010  yamt file acpi_cpu_tstate.c was added on branch yamt-nfs-mp on 2010-10-09 03:32:04 +0000
 1.18.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.18.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.2.4 12-Jun-2011  rmind sync with head
 1.26.2.3 21-Apr-2011  rmind sync with head
 1.26.2.2 05-Mar-2011  rmind sync with head
 1.26.2.1 01-Mar-2011  rmind file acpi_cpu_tstate.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.27.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.30.8.2 17-Dec-2013  riz Pull up following revision(s) (requested by bouyer in ticket #984):
sys/dev/acpi/acpi_cpu.h: revision 1.44
sys/dev/acpi/acpi_cpu_tstate.c: revision 1.31
Remove the upper limit for the number of T-states.
 1.30.8.1 25-Nov-2013  bouyer Pull up following revision(s) (requested by jruoho in ticket #987):
sys/arch/x86/acpi/acpi_cpu_md.c: revision 1.74
sys/dev/acpi/acpi_cpu_tstate.c: revision 1.32
As discussed with bouyer@, fix a too eager T-state validation check to
accomodate new Intel CPUs.
Allow 4-bit range for MSR_THERM_CONTROL.
 1.30.6.1 29-Apr-2012  mrg sync to latest -current.
 1.30.2.2 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.30.2.1 23-May-2012  yamt sync with head.
 1.31.4.1 18-May-2014  rmind sync with head
 1.31.2.2 03-Dec-2017  jdolecek update from HEAD
 1.31.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.6.1 28-Aug-2017  skrll Sync with HEAD
 1.33.24.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.8 08-Jul-2020  thorpej Update for proplib API changes.
 1.7 23-Mar-2020  chs in acpi_debug_init(), the string we extract from the dictionary is
a normal C string, so use strlcpy() rather than memcpy() to copy it.
found by KASAN.
 1.6 05-Jan-2019  christos add normal debug level
 1.5 25-Feb-2014  pooka branches: 1.5.28; 1.5.30;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.4 27-Oct-2010  gsutre branches: 1.4.8; 1.4.18; 1.4.22;
Make acpi(4) debug aware of ACPI_DISPLAY_COMPONENT.
 1.3 30-Jun-2010  jruoho Provide a sysctl-knob for the Debug() opcode, hw.acpi.debug.object. This
prints debug-messages possibly used in the AML. Only enabled for ACPI_DEBUG
kernels.
 1.2 12-Apr-2010  jruoho Rework the sysctl-support.

Changes:

hw.wake -> hw.acpi.wake
hw.acpi.debug_layer -> hw.acpi.debug.layer
hw.acpi.debug_level -> hw.acpi.debug.level

Additions:

hw.acpi.stat.gpe # Number of dispatched GPEs
hw.acpi.stat.sci # Number of SCI interrupts
hw.acpi.stat.fixed # Number of fixed events
hw.acpi.stat.method # Number of executed methods

ok jmcneill@
 1.1 31-Jan-2010  jruoho branches: 1.1.2; 1.1.4; 1.1.6;
Add dynamic debug options for ACPI_DEBUG kernels.

ok jmcneill@, pooka@, pgoyette@
 1.1.6.3 05-Mar-2011  rmind sync with head
 1.1.6.2 03-Jul-2010  rmind sync with head
 1.1.6.1 30-May-2010  rmind sync with head
 1.1.4.3 11-Aug-2010  yamt sync with head.
 1.1.4.2 11-Mar-2010  yamt sync with head
 1.1.4.1 31-Jan-2010  yamt file acpi_debug.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.1.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.22.1 18-May-2014  rmind sync with head
 1.4.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.8.1 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.5.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.30.1 10-Jun-2019  christos Sync with HEAD
 1.5.28.1 18-Jan-2019  pgoyette Synch with HEAD
 1.4 12-Nov-2024  riastradh acpi(4): KNF

- Nix trailing whitespace.
- Fix operator spacing.
- No need to cast AcpiOsMapMemory result.

No functional change intended.

Followup commit for PR 58817.
 1.3 12-Nov-2024  martin PR 58817: allow userland access to the TCPA. Patch from Jared.
 1.2 24-Jul-2021  jmcneill branches: 1.2.16;
acpi: /dev/acpi: fix bounds check when reading tables
 1.1 06-Dec-2020  jmcneill branches: 1.1.2; 1.1.6;
acpi: add character device for accessing ACPI tables

The /dev/acpi character device gives an aperture into physical memory
that allows only read access to known ACPI tables: RSDP, XSDT/RSDT, and
the root tables. Adapt acpidump(8) to use this interface by default,
falling back to the old /dev/mem method if it is not available or if
ACPIDUMP_USE_DEVMEM=1 is set in the environment. The user visible benefit
of this change is that "options INSECURE" is no longer required to
dump ACPI tables.
 1.1.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1.2.2 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1.2.1 06-Dec-2020  thorpej file acpi_dev.c was added on branch thorpej-futex on 2020-12-14 14:38:05 +0000
 1.2.16.1 02-Aug-2025  perseant Sync with HEAD
 1.25 18-Aug-2024  riastradh acpi_display.c: Nix trailing whitespace.

No functional change intended.

Followup to fix for:

PR kern/57825: Malfunctioning screen brightness keys and sysctl
 1.24 10-May-2024  maya branches: 1.24.2;
Add quirk for machines were the getting the brightness value always
returns the same result by keeping a local copy of the last set value.

This makes the brightness buttons work on my Thinkpad T450s, and will
probably fix PR kern/57825 as well.
 1.23 17-Mar-2023  andvar s/Brigthness/Brightness/ in comment.
 1.22 27-Feb-2022  riastradh branches: 1.22.4;
acpivga(4): Provide hooks for ACPI display notifications.

The Intel i915 graphics driver needs to receive ACPI VGA 0x80
notifications, but with NetBSD's ACPI API, each ACPI node -- such as
the VGA node -- can only have one notifier attached, and acpivga(4)
already uses it.
 1.21 30-Dec-2021  riastradh acpiout(4): Work around firmware that doesn't like some brightnesses.

Instead of just asking for cur - 5 or cur + 5, repeatedly ask for
that increment, check whether we actually made progress in that
direction, and if not keep going with another increment, until we hit
the bounds of brightness levels.

I can't find anything in the ACPI spec about this, but my laptop
seems to have trouble with certain levels: 15, 75, 85, 95. It goes
in all other increments of 5 from 5 to 100, just not those ones --
acts as if the change just never happened, so with the old logic the
brightness up/down would get stuck unable to move in either
direction.

This should have no impact on machines where the first increment
actually takes.
 1.20 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.19 24-Apr-2021  thorpej branches: 1.19.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.18 30-Jun-2020  sborrill branches: 1.18.4;
Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.
Thanks to jmcneill@
 1.17 28-Apr-2020  jmcneill Demote "unknown output device" message from error to debug, and change
the wording to reflect what is really happening -- the display output is
not connected.
 1.16 01-Jun-2017  chs branches: 1.16.2; 1.16.16;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.15 03-Apr-2016  mlelstv Add comments.
 1.14 18-Feb-2016  riastradh Avoid reading one byte past end of array.

Fixes

acpiout0: brightness levels: [20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,uvm_fault(0xffffffff8133d200, 0xffff80000c1d8000, 1) -> e
fatal page fault in supervisor mode
trap type 6 code 0 rip ffffffff803b63d7 cs 8 rflags 10212 cr2 ffff80000c1d8000 ilevel 8 rsp ffffffff816a1b00
 1.13 06-Jan-2016  christos PR/50626: Vicente Chaves de Melo: acpi_display.c erroneously sends character
to console during boot
 1.12 14-Oct-2014  christos branches: 1.12.2;
summarize levels instead of printing dozens of them.
 1.11 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.10 02-Jun-2012  dsl branches: 1.10.2; 1.10.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.9 16-Feb-2011  jruoho branches: 1.9.2; 1.9.6;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.8 10-Jan-2011  jruoho branches: 1.8.2; 1.8.4;
Small clean-up in the match and attach functions. Namely, use the attach
args instead of referencing the global softc. No functional change.
 1.7 07-Nov-2010  gsutre Replace ACPI_UINT64 by ACPICA's ACPI_INTEGER. Remove superfluous casts.
No functional change.
 1.6 04-Nov-2010  jruoho Initialize pointers to NULL to avoid accidentally free(9)'ing garbage.
Should address the panic reported by Alan Bueno in PR # 44042. The root
cause (an empty _DOD) is yet to be determined.
 1.5 29-Oct-2010  gsutre Lock the _DGS values (desired output state) during the display
output switch.

ok jruoho@
 1.4 28-Oct-2010  gsutre Simplify the sysctl variable for BIOS switch policy, and document it
in acpivga(4). The previous hw.acpi.acpivga0.policy variable is
renamed into bios_policy for consistency, and is for ACPI_DEBUG only.

ok jruoho@
 1.3 26-Oct-2010  gsutre An _ADR object is not required for PCI root bridges. To solve
this, the structure acpi_pciinfo now tells whether the ACPI
device node is a PCI bridge, a regular PCI device, or both.

Problem reported by jmcneill@, who also suggested the solution.

ok jmcneill@, jruoho@
 1.2 25-Oct-2010  jruoho Add support for module(9).
 1.1 12-Oct-2010  gsutre branches: 1.1.2;
Merge ACPI display driver. Provides generic support for brightness
control and output switching, through ACPI video extensions.

TODO: use wsconsctl(8) instead of sysctl(8) for brightness control.

ok jruoho@
also discussed with cegger@ and jmcneill@
 1.1.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.2.1 12-Oct-2010  uebayasi file acpi_display.c was added on branch uebayasi-xip on 2010-10-22 07:21:52 +0000
 1.8.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.6.2 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.9.6.1 30-Oct-2012  yamt sync with head
 1.9.2.2 05-Mar-2011  rmind sync with head
 1.9.2.1 16-Feb-2011  rmind file acpi_display.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.10.4.1 18-May-2014  rmind sync with head
 1.10.2.2 03-Dec-2017  jdolecek update from HEAD
 1.10.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.3 28-Aug-2017  skrll Sync with HEAD
 1.12.2.2 22-Apr-2016  skrll Sync with HEAD
 1.12.2.1 19-Mar-2016  skrll Sync with HEAD
 1.16.16.4 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1869):

sys/dev/acpi/acpi_display.c: revision 1.24

Add quirk for machines were the getting the brightness value always
returns the same result by keeping a local copy of the last set value.

This makes the brightness buttons work on my Thinkpad T450s, and will
probably fix PR kern/57825 as well.
 1.16.16.3 20-Jan-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1399):

sys/dev/acpi/acpi_display.c: revision 1.21

acpiout(4): Work around firmware that doesn't like some brightnesses.

Instead of just asking for cur - 5 or cur + 5, repeatedly ask for
that increment, check whether we actually made progress in that
direction, and if not keep going with another increment, until we hit
the bounds of brightness levels.

I can't find anything in the ACPI spec about this, but my laptop
seems to have trouble with certain levels: 15, 75, 85, 95. It goes
in all other increments of 5 from 5 to 100, just not those ones --
acts as if the change just never happened, so with the old logic the
brightness up/down would get stuck unable to move in either
direction.

This should have no impact on machines where the first increment
actually takes.
 1.16.16.2 30-Jun-2020  martin Pull up following revision(s) (requested by sborrill in ticket #978):

sys/dev/acpi/acpi_display.c: revision 1.18

Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.

Thanks to jmcneill@
 1.16.16.1 29-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #867):

sys/dev/acpi/acpi_display.c: revision 1.17

Demote "unknown output device" message from error to debug, and change
the wording to reflect what is really happening -- the display output is
not connected.
 1.16.2.1 30-Jun-2020  martin Pull up following revision(s) (requested by sborrill in ticket #1563):

sys/dev/acpi/acpi_display.c: revision 1.18

Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.

Thanks to jmcneill@
 1.18.4.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.19.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.22.4.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #791):

sys/dev/acpi/acpi_display.c: revision 1.24

Add quirk for machines were the getting the brightness value always
returns the same result by keeping a local copy of the last set value.

This makes the brightness buttons work on my Thinkpad T450s, and will
probably fix PR kern/57825 as well.
 1.24.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 27-Feb-2022  riastradh acpivga(4): Provide hooks for ACPI display notifications.

The Intel i915 graphics driver needs to receive ACPI VGA 0x80
notifications, but with NetBSD's ACPI API, each ACPI node -- such as
the VGA node -- can only have one notifier attached, and acpivga(4)
already uses it.
 1.108 18-Jul-2023  riastradh acpiec(4): One more debug message about read/write polling timeout.
 1.107 18-Jul-2023  riastradh acpiec(4): Take a lock around acpiec_cold updates.

Otherwise we race with readers -- probably harmlessly, but let's
avoid the appearance of problems.

XXX Maybe acpiec_suspend and acpiec_shutdown should interrupt
transactions and force them to fail promptly?

XXX This looks bad because acpiec_cold is global and sc->sc_mtx
doesn't look like it's global, but we expect to have only one
acpiec(4) device anyway from what I understand. Maybe we should move
acpiec_cold into the softc?
 1.106 18-Jul-2023  riastradh acpiec(4): Factor out if (state == FREE) cv_signal(sc_cv).

In principle this could have a functional change, but at worst, it is
to signal more wakeups than needed, which should always be safe.
 1.105 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_space_handler.

Better to keep the device_t isolated to public interfaces. Simpler
internally this way.

No functional change intended.
 1.104 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_query thread.

Simpler.

No functional change intended.
 1.103 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_read/write.

Simpler, type-safer.

No functional change intended.
 1.102 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_lock/unlock.

Simpler, type-safer.

No functional change intended.
 1.101 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_handler.

Simpler.

No functional change intended.
 1.100 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_callout.

Simpler.

No functional change intended.
 1.99 18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_state_machine.

Simpler, type-safer.

No functional change intended.
 1.98 18-Jul-2023  riastradh acpiec(4): Factor wait logic out.

No functional change intended.
 1.97 18-Jul-2023  riastradh acpiec(4): Merge returns in acpiec_read/write.

No functional change intended.
 1.96 18-Jul-2023  riastradh acpiec(4): Don't touch sc->sc_state outside sc->sc_mtx.
 1.95 18-Jul-2023  riastradh acpiec(4): Fix cv_timedwait abuse in acpiec_read/write.
 1.94 18-Jul-2023  riastradh acpiec(4): Fix interrupt wait loop in acpiec_gpe_query thread.
 1.93 18-Jul-2023  riastradh acpiec(4): Fix cv_wait loop around sc->sc_got_sci.

That is, make it actually loop as required, so it gracefully handles
spurious wakeups instead of barging into invalid states.
 1.92 18-Jul-2023  riastradh acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:

PR kern/53135
PR kern/52763
PR kern/57162
 1.91 18-Jul-2023  riastradh acpiec(4): Assert state is free when we start a transaction.

No functional change intended.
 1.90 18-Jul-2023  riastradh acpiec(4): Sprinkle comments.

Note where this code is abusing cv_wait and needs a loop to handle
spurious wakeups.

No functional change intended.
 1.89 18-Jul-2023  riastradh acpiec(4): Clarify lock order and sprinkle lock assertions.

No functional change intended.
 1.88 18-Jul-2023  riastradh acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.
 1.87 18-Jul-2023  riastradh acpiec(4): Record device_t self.

Not used yet, to be used soon for device_printf and to allow making
some of the internal functions a little more type-safe later.
 1.86 31-Dec-2021  riastradh branches: 1.86.4;
acpiec(4): Make sure to fully initialize an ACPI_INTEGER on read.

Write as essay about what this is supposed to do, as far as I can
tell from reading acpica and the commit history and the relevant PR.
 1.85 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.84 15-Jun-2020  jdolecek branches: 1.84.2;
only install space handler and enable interrupt for EC if ACPI
claims the device is actually present, it's not enough when there
is entry for it in the ACPI tables

fixes interrupt storm triggered on Dell PowerEdge R220 by enabling
GPE interrupt on a non-enabled EC (for which _REG call later
fails), reported and fix tested by Dima Veselov:
http://mail-index.netbsd.org/netbsd-users/2020/03/02/msg024166.html

XXX pullup netbsd-9
 1.83 04-May-2020  jdolecek constify
 1.82 28-Apr-2020  jmcneill kern/55206: acpibat reporting broken by acpi_ec.c r1.81

Assume byte instead of qword alignment of the buffer passed to the EC
space handler.
 1.81 12-Apr-2020  riastradh Reject overly large widths, from mlelstv.

We are returning an ACPI_INTEGER (= uint64_t), so it doesn't make
sense to handle more than 64 bits.

Apparently there are some ACPIs out there that ask for unreasonably
large widths here. Just reject those requests, rather than writing
past the caller's stack buffer.

Previously we attempted to fix this by copying byte by byte as large
as the caller asked, in order to avoid the undefined behaviour of
shifting past the size of ACPI_INTEGER, but that just turned a shift
(which might have been harmless on real machines) into a stack buffer
overflow (!).

ok msaitoh
 1.80 12-Apr-2020  riastradh KNF
 1.79 12-Apr-2020  riastradh Revert acpi_ec.c 1.76.

We will do this another way, and separate KNF fixes from the critical
functional change.

ok msaitoh
 1.78 12-Apr-2020  riastradh Revert acpi_ec.c 1.77.

We will do this another way.

ok msaitoh
 1.77 06-Aug-2019  msaitoh branches: 1.77.6;
- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.
- Change "switch" to "if" for simplify.
 1.76 05-Aug-2019  msaitoh - Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:

UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.
The error message was:
 1.75 11-Mar-2017  tsutsui branches: 1.75.6; 1.75.14; 1.75.20;
Remove extra newline during attach.

> acpiec0 at acpi0 (EC, PNP0C09)
> : io 0x62,0x66
> acpiec0: using global ACPI lock

acpi_resource_parse() with &acpi_resource_parse_ops_default prints
resouce info and newline. Found and tested on ThinkPad X21.
 1.74 08-Dec-2014  msaitoh branches: 1.74.2; 1.74.4;
Add missing newlines...
 1.73 06-Jul-2014  riastradh branches: 1.73.2; 1.73.4;
Register a null power handler if acpiec fails to attach.

On one of my machines, there's no _GPE method, so
acpiec_parse_gpe_package fails, and the only function acpiec(4)
serves is to inhibit suspend/resume.

XXX We should really put the power handlers in the cfattach so that
it's not necessary to register a null power handler in every error
branch of every device's attach routine...
 1.72 16-Oct-2013  christos branches: 1.72.2;
remove unused variable
 1.71 24-Jul-2011  jakllsch branches: 1.71.2; 1.71.8; 1.71.12; 1.71.16;
Fix off-by-one in validation of EmbeddedControl OperationRegion handler.
 1.70 19-Feb-2011  jruoho After the GPE handler has finished, inform ACPICA that the interrupt has
been handled and it is safe to re-enable the GPE. Should fix all problems
introduced during the merge of ACPICA 20110211.
 1.69 17-Feb-2011  jruoho ACPICA 20101209:

Completed the major overhaul of the GPE support code that was begun in July
2010. Major features include: removal of _PRW execution in ACPICA (host
executes _PRWs anyway), cleanup of "wake" GPE interfaces and processing,
changes to existing interfaces, simplification of GPE handler operation, and
a handful of new interfaces:

AcpiUpdateAllGpes
AcpiFinishGpe
AcpiSetupGpeForWake
AcpiSetGpeWakeMask

ACPICA 20100702:

Implemented several updates to the recently added GPE reference count
support. The model for "wake" GPEs is changing to give the host OS complete
control of these GPEs. Eventually, the ACPICA core will not execute any _PRW
methods, since the host already must execute them. Also, additional changes
were made to help ensure that the reference counts are kept in proper
synchronization with reality. Rafael J. Wysocki.

1) Ensure that GPEs are not enabled twice during initialization.
2) Ensure that GPE enable masks stay in sync with the reference count.
3) Do not inadvertently enable GPEs when writing GPE registers.
4) Remove the internal wake reference counter and add new AcpiGpeWakeup
interface. This interface will set or clear individual GPEs for wakeup.
5) Remove GpeType argument from AcpiEnable and AcpiDisable. These interfaces
are now used for "runtime" GPEs only.
 1.68 07-Jan-2011  cegger branches: 1.68.2; 1.68.4;
use aprint_error_dev
 1.67 06-Jun-2010  jruoho We can no longer explicitly clear a GPE by calling AcpiClearGpe() in the
interrupt handler. However, all edge-triggered GPEs should already be
cleared before our GPE handler has a chance to run.

The reason can be found from the changes in the locking primitives of
ACPICA. All GPE operations now use a spin mutex on AcpiGbl_GpeLock, acquired
via AcpiOsAcquireLock(). This same lock is now acquired unconditionally in
the AcpiClearGpe() function. This causes a deadlock of the following form:

...

AcpiEvGpeDetect() : acquire AcpiGbl_GpeLock;

-> AcpiEvGpeDispatch();

-> acpiec_gpe_handler();

-> AcpiClearGpe() : acquire AcpiGbl_GpeLock;

-> panic.
 1.66 06-Jun-2010  jruoho ACPICA 20100331:

Completed a major update for the GPE support in order to improve
support for shared GPEs and to simplify both host OS and ACPICA
code. Added a reference count mechanism to support shared GPEs that
require multiple device drivers. Several external interfaces have
changed. One external interface has been removed. One new external
interface was added. Most of the GPE external interfaces now use the
GPE spinlock instead of the events mutex (and the Flags parameter
for many GPE interfaces has been removed.) See the updated ACPICA
Programmer Reference for details. Matthew Garrett, Bob Moore, Rafael
Wysocki. ACPICA BZ 831.

Changed:
AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus
Removed:
AcpiSetGpeType
New:
AcpiSetGpe
 1.65 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.64 29-Mar-2010  dyoung Attach acpiecdt with acpibus_attach_args. Sverre Froyen reports that
this helps his Thinkpad boot again.
 1.63 24-Mar-2010  dyoung Do not use unitialized bus_space_tag_t's. Use the tag(s) from the
attachment arguments.
 1.62 05-Mar-2010  jruoho branches: 1.62.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.61 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.60 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.59 18-Jan-2010  jruoho branches: 1.59.2;
Use acpi_eval_reference_handle() to simplify code. No functional change.

ok jmcneill@, pgoyette@
 1.58 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.57 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.56 06-Jul-2009  alc Add a pmf(9) shutdown hook to acpiec(4) to use polling on shutdown.

This fixes DIAGNOSTIC's assertion failure:

cpu_switchto(): switching above IPL_SCHED

during ACPI shutdown.

OK'd by joerg@
 1.55 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.54 28-Feb-2009  jmcneill Change a confusing attach message; if the embedded controller was attached
via ECDT, we would print:
acpiec0 at acpi0 (EC, PHP0C09-0): ACPI Embedded Controller (disabled)
The embedded controller isn't actually disabled, but instead this driver
instance, so change the message to read:
acpiec0 at acpi0 (EC, PHP0C09-0): using acpiecdt0
 1.53 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.52 03-Jun-2008  joerg branches: 1.52.6; 1.52.8; 1.52.12; 1.52.16;
Before 1.46, the EC driver would try to send a command again to the EC
after a timeout. This was removed, but the loops remained, so fix them
up as well.
 1.51 29-Feb-2008  dyoung branches: 1.51.2; 1.51.4; 1.51.6;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.50 18-Jan-2008  jmcneill branches: 1.50.2; 1.50.6;
Don't be so aggressive in polling the EC when cold, port-i386/37790.
 1.49 18-Jan-2008  jmcneill If we are in polling mode, do not try to spin forever in the state machine
waiting for a read or write to complete. Workaround an issue on my VAIO,
but we really need to figure out why it is failing in the first place.
 1.48 21-Dec-2007  jmcneill Add acpiec_bus_{read,write} and acpiec_get_handle, for use in other
device drivers.
 1.47 19-Dec-2007  joerg It seems like ACPICA can't deal with GPEs being handled before the GPE
handler is called, so clear the GPE bit in the callout as well.
This fixes the EC issues on T42 models.
 1.46 15-Dec-2007  joerg Don't retry to post a command if the EC doesn't answer for a second.
It seems to create more issues than it fixes. Try to defend against
lost/late GPEs by using a callout to kick the state machine regulary.
Add some notes about the purpose and working of the driver.
 1.45 12-Dec-2007  jmcneill Rename acpiec_gpe_state_maschine -> acpiec_gpe_state_machine
 1.44 09-Dec-2007  jmcneill branches: 1.44.2;
Merge jmcneill-pm branch.
 1.43 05-Dec-2007  ad branches: 1.43.2;
lockmgr -> mutex
 1.42 19-Oct-2007  ad branches: 1.42.2; 1.42.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.41 26-Jun-2007  jmcneill branches: 1.41.6; 1.41.8; 1.41.12;
Don't be quite so aggressive in EcWaitEvent; makes acpiec work on the
Sony VAIO VGN-N250E, and possibly others.
 1.40 16-Nov-2006  christos branches: 1.40.8; 1.40.10;
__unused removal on arguments; approved by core.
 1.39 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38 14-May-2006  dogcow branches: 1.38.8; 1.38.10;
gcc4: 'Data' may be used uninitialized in this function
 1.37 20-Feb-2006  kochi branches: 1.37.2; 1.37.6;
use aprint_*
 1.36 16-Feb-2006  kochi prototypes don't need argument names
 1.35 24-Dec-2005  perry branches: 1.35.2; 1.35.4; 1.35.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.34 11-Dec-2005  christos merge ktrace-lwp.
 1.33 02-May-2005  kochi branches: 1.33.2;
Merge changes for ACPI-CA 20050408
 1.32 25-Jun-2004  yamt don't rely on the value of hz.
 1.31 01-May-2004  kochi specify static where appropriate.
 1.30 24-Apr-2004  yamt EcGpeHandler: in the case that the ec is EcLock'ed, always set
EC_F_PENDQUERY flag so that AcpiClearGpe() will be called later.
 1.29 22-Apr-2004  itojun sprintf -> snprintf
 1.28 11-Apr-2004  kochi - don't evaluate _UID, reuse ACPI_DEVINFO
- move acpi_resources from acpi_ec_softc to stack
 1.27 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.26 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.25 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.24 10-Apr-2004  kochi whitespace nit
 1.23 30-Mar-2004  kochi Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.22 24-Mar-2004  kanaoka branches: 1.22.2;
Set sc->sc_glk,if acpi_eval_integer() evaluate _GLK in acpiec_attach.
 1.21 24-Mar-2004  kanaoka Make it compile (int -> ACPI_INTEGER)
 1.20 12-Nov-2003  yamt - fix deadlocks due to using lock_status() from interrupt context.
- process pending queries in EcUnlock() to close a race window.
now there's no need to do polling for EcQuery().
- reorder inline functions and other prototypes so that
the formers can get needed prototypes.
- add missing prototypes.
 1.19 12-Nov-2003  yamt use snprintf("%X") instead of "%x" + strupr().
 1.18 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.17 03-Nov-2003  mycroft Fix locking protocol, and use _GLK appropriately. From kochi, with some
modifications.
 1.16 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.15 01-Nov-2003  mycroft sc_lockhandle is garbage.
 1.14 01-Nov-2003  mycroft Remove an unnecessary call to AcpiGlearGpe().
 1.13 01-Nov-2003  mycroft Correct arguments to AcpiClearGpe().
 1.12 01-Nov-2003  mycroft Correct arguments to AcpiInstallGpeHandler, as per Linux and FreeBSD.
 1.11 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.10 03-Aug-2003  kochi Fix a wrong handling of clearing a flag
 1.9 14-Feb-2003  tshiozak branches: 1.9.2;
- add acpi_acquire_global_lock()/acpi_release_global_lock()/
acpi_is_global_locked() functions.
AcpiGlobalLock() API should be used to acquire lock between BIOS and OS.
This API cannot be used to lock between threads of the OS side,
because this function immediately returns if the lock is already acquired
by the OS. c.f. AcpiEvAcquireGlobalLock()@evmisc.c

- make sure that acpiec driver uses above functions.

- use ACPI_ALLOCATE_BUFFER instead of twice calls of AcpiEvaluateObject(),
in acpi_eval_string()/acpi_eval_struct().
Twice AcpiEvaluateObject() calls may cause twice side effects
to ACPI machine / hardware and this may be wrong in some cases.
 1.8 15-Oct-2002  tshiozak fix a simple, but wicked bug in EcSpaceHandler().
this bug causes EcWrite via EcSpaceHandler to always write 0 as the data byte.
 1.7 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 15-Jun-2002  thorpej Update for acpica-unix-20020612. From Takayoshi Kochi.
 1.3 13-Nov-2001  lukem branches: 1.3.2; 1.3.10;
add RCSID
 1.2 12-Oct-2001  enami Fix printf format.
 1.1 29-Sep-2001  thorpej branches: 1.1.2; 1.1.4;
ACPI Embedded Controller driver.
 1.1.4.6 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.5 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.4 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.3 22-Oct-2001  nathanw Catch up to -current.
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 29-Sep-2001  nathanw file acpi_ec.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 29-Sep-2001  fvdl file acpi_ec.c was added on branch thorpej-devvp on 2001-10-01 12:44:15 +0000
 1.3.10.1 20-Jun-2002  gehenna catch up with -current.
 1.3.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 13-Nov-2001  thorpej file acpi_ec.c was added on branch kqueue on 2002-01-10 19:52:52 +0000
 1.9.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.2 29-Apr-2004  jmc Pullup rev 1.30 (requested by yamt in ticket #221)

EcGpeHandler: in the case that the ec is EcLock'ed, always set
EC_F_PENDQUERY flag so that AcpiClearGpe() will be called later.
 1.22.2.1 28-Apr-2004  jmc Pullup rev 1.23 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.33.2.7 17-Mar-2008  yamt sync with head.
 1.33.2.6 21-Jan-2008  yamt sync with head
 1.33.2.5 07-Dec-2007  yamt sync with head
 1.33.2.4 27-Oct-2007  yamt sync with head.
 1.33.2.3 03-Sep-2007  yamt sync with head.
 1.33.2.2 30-Dec-2006  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.35.6.2 01-Jun-2006  kardel Sync with head.
 1.35.6.1 22-Apr-2006  simonb Sync with head.
 1.35.4.1 09-Sep-2006  rpaulo sync with head
 1.35.2.2 01-Mar-2006  yamt sync with head.
 1.35.2.1 18-Feb-2006  yamt sync with head.
 1.37.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.2.1 24-May-2006  yamt sync with head.
 1.38.10.2 10-Dec-2006  yamt sync with head.
 1.38.10.1 22-Oct-2006  yamt sync with head
 1.38.8.1 18-Nov-2006  ad Sync with head.
 1.40.10.1 11-Jul-2007  mjf Sync with head.
 1.40.8.2 23-Oct-2007  ad Sync with head.
 1.40.8.1 15-Jul-2007  ad Sync with head.
 1.41.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.41.8.3 23-Mar-2008  matt sync with HEAD
 1.41.8.2 09-Jan-2008  matt sync with HEAD
 1.41.8.1 06-Nov-2007  matt sync with HEAD
 1.41.6.14 09-Dec-2007  jmcneill Sync with HEAD.
 1.41.6.13 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.41.6.12 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.41.6.11 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.41.6.10 04-Oct-2007  joerg When failing to acquire or release the global lock, print the error
message.
 1.41.6.9 04-Oct-2007  joerg Fix thinko: if acpiec_cold is set, the device is in D3, not D0.
This fixes the timeouts on resume.
 1.41.6.8 04-Oct-2007  joerg Explicitly initialise variable written to via or.
 1.41.6.7 04-Oct-2007  joerg Random undocumented fact #741:
The ACPI Embedded Controller will generally only except new commands if
the input buffer is not full.

Push the command write into acpiec_gpe_state_machine and start the
processing with a few busy iterations in
acpiec_write/acpiec_read/acpiec_gpe_query. Also move the read of data
into the state machine to keep all register access in one place.

This fixes random read/write errors that occured with a chance of 10% or
so. It is unclear why the old code didn't hit it more often.
 1.41.6.6 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.41.6.5 02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.41.6.4 26-Sep-2007  joerg Merge EcWaitEvent and EcWaitEventIntr. I don't see a good reason to wait
0.99s for the EC, just use 1sec.
 1.41.6.3 26-Sep-2007  joerg Reorder slightly to make clear that EcRead and EcWrite are used only by
EcTransaction.
 1.41.6.2 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.41.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.42.4.2 26-Dec-2007  ad Sync with head.
 1.42.4.1 08-Dec-2007  ad Sync with head.
 1.42.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.42.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.42.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.43.2.2 13-Dec-2007  yamt sync with head.
 1.43.2.1 11-Dec-2007  yamt sync with head.
 1.44.2.3 19-Jan-2008  bouyer Sync with HEAD
 1.44.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.44.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.50.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.50.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.50.2.1 24-Mar-2008  keiichi sync with head.
 1.51.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.4.5 11-Aug-2010  yamt sync with head.
 1.51.4.4 11-Mar-2010  yamt sync with head
 1.51.4.3 18-Jul-2009  yamt sync with head.
 1.51.4.2 16-May-2009  yamt sync with head
 1.51.4.1 04-May-2009  yamt sync with head.
 1.51.2.1 04-Jun-2008  yamt sync with head
 1.52.16.1 21-Apr-2010  matt sync to netbsd-5
 1.52.12.2 23-Jul-2009  jym Sync with HEAD.
 1.52.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.52.8.2 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #535):
sys/dev/acpi/acpi_ec.c: revision 1.54
Change a confusing attach message; if the embedded controller was attached
via ECDT, we would print:
acpiec0 at acpi0 (EC, PHP0C09-0): ACPI Embedded Controller (disabled)
The embedded controller isn't actually disabled, but instead this driver
instance, so change the message to read:
acpiec0 at acpi0 (EC, PHP0C09-0): using acpiecdt0
 1.52.8.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.52.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.59.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.59.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.62.2.3 05-Mar-2011  rmind sync with head
 1.62.2.2 03-Jul-2010  rmind sync with head
 1.62.2.1 30-May-2010  rmind sync with head
 1.68.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.68.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.68.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.16.1 18-May-2014  rmind sync with head
 1.71.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.8.1 29-Sep-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1122):
sys/dev/acpi/acpi_ec.c: revision 1.73
Register a null power handler if acpiec fails to attach.
On one of my machines, there's no _GPE method, so
acpiec_parse_gpe_package fails, and the only function acpiec(4)
serves is to inhibit suspend/resume.
XXX We should really put the power handlers in the cfattach so that
it's not necessary to register a null power handler in every error
branch of every device's attach routine...
 1.71.2.1 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.72.2.1 10-Aug-2014  tls Rebase.
 1.73.4.2 28-Aug-2017  skrll Sync with HEAD
 1.73.4.1 06-Apr-2015  skrll Sync with HEAD
 1.73.2.1 08-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #392):
sys/dev/acpi/acpi_ec.c: revision 1.74
sys/dev/isa/pcppi.c: revision 1.43
Add missing newlines...
 1.74.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.74.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.75.20.4 20-Jun-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #959):

sys/dev/acpi/acpi_ec.c: revision 1.84

only install space handler and enable interrupt for EC if ACPI

claims the device is actually present, it's not enough when there
is entry for it in the ACPI tables
fixes interrupt storm triggered on Dell PowerEdge R220 by enabling
GPE interrupt on a non-enabled EC (for which _REG call later
fails), reported and fix tested by Dima Veselov:
http://mail-index.netbsd.org/netbsd-users/2020/03/02/msg024166.html

XXX pullup netbsd-9
 1.75.20.3 29-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #866):

sys/dev/acpi/acpi_ec.c: revision 1.82

kern/55206: acpibat reporting broken by acpi_ec.c r1.81

Assume byte instead of qword alignment of the buffer passed to the EC
space handler.
 1.75.20.2 12-Apr-2020  martin Pull up following revision(s) (requested by riastradh in ticket #829):

sys/dev/acpi/acpi_ec.c: revision 1.78
sys/dev/acpi/acpi_ec.c: revision 1.79
sys/dev/acpi/acpi_ec.c: revision 1.80
sys/dev/acpi/acpi_ec.c: revision 1.81

Revert acpi_ec.c 1.77.
We will do this another way.
ok msaitoh

Revert acpi_ec.c 1.76.
We will do this another way, and separate KNF fixes from the critical
functional change.
ok msaitoh

KNF

Reject overly large widths, from mlelstv.
We are returning an ACPI_INTEGER (= uint64_t), so it doesn't make
sense to handle more than 64 bits.

Apparently there are some ACPIs out there that ask for unreasonably
large widths here. Just reject those requests, rather than writing
past the caller's stack buffer.

Previously we attempted to fix this by copying byte by byte as large
as the caller asked, in order to avoid the undefined behaviour of
shifting past the size of ACPI_INTEGER, but that just turned a shift
(which might have been harmless on real machines) into a stack buffer
overflow (!).

ok msaitoh
 1.75.20.1 09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #38):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.

- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.

- Change "switch" to "if" for simplify.
 1.75.14.2 21-Apr-2020  martin Sync with HEAD
 1.75.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.75.6.1 16-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1337):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'
- KNF.
- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.
- Change "switch" to "if" for simplify.
 1.77.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.84.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.86.4.1 30-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #259):

sys/dev/acpi/acpi_ec.c: revision 1.102
sys/dev/acpi/acpi_ec.c: revision 1.103
sys/dev/acpi/acpi_ec.c: revision 1.104
sys/dev/acpi/acpi_ec.c: revision 1.105
sys/dev/acpi/acpi_ec.c: revision 1.106
sys/dev/acpi/acpi_ec.c: revision 1.107
sys/dev/acpi/acpi_ec.c: revision 1.108
sys/dev/acpi/acpi_ec.c: revision 1.90
sys/dev/acpi/acpi_ec.c: revision 1.91
sys/dev/acpi/acpi_ec.c: revision 1.92
sys/dev/acpi/acpi_ec.c: revision 1.93
sys/dev/acpi/acpi_ec.c: revision 1.94
sys/dev/acpi/files.acpi: revision 1.128
sys/dev/acpi/acpi_ec.c: revision 1.95
sys/dev/acpi/acpi_ec.c: revision 1.96
sys/dev/acpi/acpi_ec.c: revision 1.97
sys/arch/amd64/conf/ALL: revision 1.179
sys/dev/acpi/acpi_ec.c: revision 1.98
sys/dev/acpi/acpi_ec.c: revision 1.99
sys/dev/acpi/acpi_ec.c: revision 1.87
sys/dev/acpi/acpi_ec.c: revision 1.88
sys/dev/acpi/acpi_ec.c: revision 1.89
sys/arch/i386/conf/ALL: revision 1.511
sys/dev/acpi/acpi_ec.c: revision 1.100
sys/dev/acpi/acpi_ec.c: revision 1.101

acpiec(4): Record device_t self.

Not used yet, to be used soon for device_printf and to allow making
some of the internal functions a little more type-safe later.
acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.

acpiec(4): Clarify lock order and sprinkle lock assertions.
No functional change intended.

acpiec(4): Sprinkle comments.
Note where this code is abusing cv_wait and needs a loop to handle
spurious wakeups.
No functional change intended.

acpiec(4): Assert state is free when we start a transaction.
No functional change intended.

acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:
PR kern/53135
PR kern/52763
PR kern/57162

acpiec(4): Fix cv_wait loop around sc->sc_got_sci.

That is, make it actually loop as required, so it gracefully handles
spurious wakeups instead of barging into invalid states.

acpiec(4): Fix interrupt wait loop in acpiec_gpe_query thread.

acpiec(4): Fix cv_timedwait abuse in acpiec_read/write.

acpiec(4): Don't touch sc->sc_state outside sc->sc_mtx.

acpiec(4): Merge returns in acpiec_read/write.
No functional change intended.

acpiec(4): Factor wait logic out.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_state_machine.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_callout.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_handler.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_lock/unlock.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_read/write.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_query thread.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_space_handler.
Better to keep the device_t isolated to public interfaces. Simpler
internally this way.
No functional change intended.

acpiec(4): Factor out if (state == FREE) cv_signal(sc_cv).

In principle this could have a functional change, but at worst, it is
to signal more wakeups than needed, which should always be safe.
acpiec(4): Take a lock around acpiec_cold updates.

Otherwise we race with readers -- probably harmlessly, but let's
avoid the appearance of problems.
XXX Maybe acpiec_suspend and acpiec_shutdown should interrupt
transactions and force them to fail promptly?
XXX This looks bad because acpiec_cold is global and sc->sc_mtx
doesn't look like it's global, but we expect to have only one
acpiec(4) device anyway from what I understand. Maybe we should move
acpiec_cold into the softc?

acpiec(4): One more debug message about read/write polling timeout.
 1.5 11-Dec-2007  jmcneill No longer required after jmcneill-pm merge.
 1.4 09-Dec-2007  jmcneill branches: 1.4.2;
Merge jmcneill-pm branch.
 1.3 11-Dec-2005  christos branches: 1.3.44; 1.3.46; 1.3.52; 1.3.56; 1.3.58;
merge ktrace-lwp.
 1.2 10-Apr-2004  kochi branches: 1.2.12;
whitespace nit
 1.1 29-Sep-2001  thorpej branches: 1.1.2; 1.1.4; 1.1.8; 1.1.24;
ACPI Embedded Controller driver.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 29-Sep-2001  thorpej file acpi_ecreg.h was added on branch kqueue on 2002-01-10 19:52:52 +0000
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 29-Sep-2001  nathanw file acpi_ecreg.h was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 29-Sep-2001  fvdl file acpi_ecreg.h was added on branch thorpej-devvp on 2001-10-01 12:44:15 +0000
 1.2.12.1 21-Jan-2008  yamt sync with head
 1.3.58.2 13-Dec-2007  yamt sync with head.
 1.3.58.1 11-Dec-2007  yamt sync with head.
 1.3.56.1 26-Dec-2007  ad Sync with head.
 1.3.52.1 27-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 23-Mar-2008  matt sync with HEAD
 1.3.44.1 02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.4.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.2 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.1 21-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.20; 1.1.40;
Add acpiec_bus_{read,write} and acpiec_get_handle, for use in other
device drivers.
 1.1.40.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.20.1 11-Mar-2010  yamt sync with head
 1.1.10.2 21-Jan-2008  yamt sync with head
 1.1.10.1 21-Dec-2007  yamt file acpi_ecvar.h was added on branch yamt-lazymbuf on 2008-01-21 09:42:30 +0000
 1.1.8.2 09-Jan-2008  matt sync with HEAD
 1.1.8.1 21-Dec-2007  matt file acpi_ecvar.h was added on branch matt-armv6 on 2008-01-09 01:52:18 +0000
 1.1.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.6.1 21-Dec-2007  bouyer file acpi_ecvar.h was added on branch bouyer-xeni386 on 2008-01-02 21:53:49 +0000
 1.1.4.2 26-Dec-2007  ad Sync with head.
 1.1.4.1 21-Dec-2007  ad file acpi_ecvar.h was added on branch vmlocking2 on 2007-12-26 19:17:19 +0000
 1.1.2.2 21-Dec-2007  jmcneill Add acpiec_bus_{read,write} and acpiec_get_handle, for use in other
device drivers.
 1.1.2.1 21-Dec-2007  jmcneill file acpi_ecvar.h was added on branch mjf-devfs on 2007-12-21 21:22:55 +0000
 1.2 11-Jan-2022  jmcneill acpi: ged: Mask interrupts before dispatching handler

For the benefit of GEDs backed by level interrupts, mask the interrupt
source before dispatching the handler to a worker thread and unmask it
after it has been handled.
 1.1 22-Oct-2018  jmcneill branches: 1.1.2; 1.1.6;
Factor out common ACPI event code into a shared module.
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 22-Oct-2018  christos file acpi_event.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 22-Oct-2018  pgoyette file acpi_event.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.3 17-Dec-2024  riastradh acpi_event.h: Add missing includes and forward declarations.

No functional change intended, other than to make potential users
build when they previously wouldn't.
 1.2 11-Jan-2022  jmcneill branches: 1.2.10;
acpi: ged: Mask interrupts before dispatching handler

For the benefit of GEDs backed by level interrupts, mask the interrupt
source before dispatching the handler to a worker thread and unmask it
after it has been handled.
 1.1 22-Oct-2018  jmcneill branches: 1.1.2; 1.1.6;
Factor out common ACPI event code into a shared module.
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 22-Oct-2018  christos file acpi_event.h was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 22-Oct-2018  pgoyette file acpi_event.h was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.2.10.1 02-Aug-2025  perseant Sync with HEAD
 1.9 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.8 23-Apr-2015  pgoyette branches: 1.8.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.7 22-Jul-2011  jruoho branches: 1.7.12; 1.7.30;
Do not unnecessarily maintain a state between suspend and resume.
 1.6 21-Jun-2011  jruoho Revert the previous commit as it was wrong/redundant.
 1.5 20-Jun-2011  pgoyette Initialize sensors states before registering.
 1.4 16-Feb-2011  jruoho branches: 1.4.2; 1.4.4;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.3 13-Jan-2011  jruoho branches: 1.3.2; 1.3.4;
Postpone the sensor update with sysmon_taskq(9).
 1.2 09-Jan-2011  jruoho After consulting jmcneill@, set the state to D0 ("on") upon shutdown and
detach. A safety measure so that we do not accidentally fry anything.
 1.1 09-Jan-2011  jruoho Add a dummy-driver for ACPI fans.
 1.3.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 16-Feb-2011  rmind file acpi_fan.c was added on branch rmind-uvmplock on 2011-03-05 20:53:03 +0000
 1.7.30.1 06-Jun-2015  skrll Sync with HEAD
 1.7.12.1 03-Dec-2017  jdolecek update from HEAD
 1.8.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 11-Jan-2022  jmcneill acpi: ged: Mask interrupts before dispatching handler

For the benefit of GEDs backed by level interrupts, mask the interrupt
source before dispatching the handler to a worker thread and unmask it
after it has been handled.
 1.3 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.2 23-Oct-2020  jmcneill branches: 1.2.2;
Use MI acpi_intr_establish_irq instead of MD intr_establish
 1.1 22-Oct-2018  jmcneill branches: 1.1.2; 1.1.6;
Add driver for ACPI Generic Event Device
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 22-Oct-2018  christos file acpi_ged.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 22-Oct-2018  pgoyette file acpi_ged.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.2.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 15-Dec-2024  hannken branches: 1.5.4;
Add _COMPONENT and ACPI_MODULE_NAME for debug.

Kernels ALL/i386 and ALL/amd64 compile again.
 1.4 13-Dec-2024  jmcneill Attempt to fix build for kernels w/o i2c or gpio.
 1.3 11-Dec-2024  jmcneill acpi: gpio: Add GeneralPurposeIo address space handler for GPIO controllers
 1.2 09-Dec-2024  jmcneill acpi: gpio: Pass the full ACPI_RESOURCE_GPIO to the translate callback.
 1.1 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.5.4.2 02-Aug-2025  perseant Sync with HEAD
 1.5.4.1 15-Dec-2024  perseant file acpi_gpio.c was added on branch perseant-exfatfs on 2025-08-02 05:56:31 +0000
 1.4 17-Dec-2024  riastradh branches: 1.4.4;
acpi_gpio.h: Add missing includes and forward declarations.

No functional change intended, other than to make potential users
build when they previously wouldn't.
 1.3 11-Dec-2024  jmcneill acpi: gpio: Add GeneralPurposeIo address space handler for GPIO controllers
 1.2 09-Dec-2024  jmcneill acpi: gpio: Pass the full ACPI_RESOURCE_GPIO to the translate callback.
 1.1 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.4.4.2 02-Aug-2025  perseant Sync with HEAD
 1.4.4.1 17-Dec-2024  perseant file acpi_gpio.h was added on branch perseant-exfatfs on 2025-08-02 05:56:31 +0000
 1.1 21-Mar-2024  riastradh branches: 1.1.4;
acpihed(4): New driver for PNP0C33 to notify apei(4).

PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 21-Mar-2024  martin file acpi_hed.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.23 23-Sep-2025  thorpej Enumerate i2c devices directly from the ACPI device tree.
 1.22 18-Sep-2025  thorpej In the "i2c-child-devices" array, don't pass in a "cookie" and "cookietype".
Instead, just create the appropriate devhandle and pass that along as a
data object.
 1.21 15-Sep-2025  thorpej Register the I2C controller with the ACPI subsystem centrally in
iic_attach().
 1.20 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.19 11-Jan-2025  jmcneill acpi: i2c: only claim child devices with a _CRS or _ADR method

acpi_enter_i2c_devs is too aggressive with claiming child device nodes.
Restrict it to devices with either a _CRS or _ADR method. A driver is
free to claim more if appropriate.

Fixes missing HKEY (LEN0268) device on Thinkpad T14s Gen 6 (X1E).
 1.18 30-Dec-2024  jmcneill acpi: Ensure that non-child I2C HID devices are properly claimed.
 1.17 14-Dec-2024  jmcneill acpi: i2c: Honour accessor type attribute in GSB handler.

The accessor type attribute in a GSB field defines how the I2C
transaction should look. Add support for AttribQuick, AttribSendReceive,
AttribByte, AttribWord, AttribBlock, and AttribBytes.
 1.16 13-Dec-2024  jmcneill Attempt to fix build for kernels w/o i2c or gpio.
 1.15 09-Dec-2024  jmcneill Remove some debug printfs
 1.14 09-Dec-2024  jmcneill acpi: i2c: Support GenericSerialBus address space handlers.

Add support for I2C controllers to install GSB address space handlers.
 1.13 08-Dec-2024  jmcneill acpi: find I2C devices that are not children of the controller node

An I2C device does not necessarily have to be a child of an I2C controller
device node. It may be defined elsewhere in the device tree, with a
I2cSerialBusV2 resource that points to the I2C bus that it sits on.

For the simple case of I2C HID devices, we know that they have exactly
one I2C bus resource. When a controller calls acpi_enter_i2c_devs,
search for unclaimed device nodes with a resource that points to this
controller, and add any I2C HID devices found.
 1.12 23-Jul-2022  thorpej branches: 1.12.10;
- Handle dtlink in acpi_pack_compat_list().
- Don't pass the _HID value as the device name; always use the ACPI
node name.
 1.11 26-Jan-2021  thorpej branches: 1.11.4; 1.11.14;
Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.
 1.10 26-Jan-2021  jmcneill Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.9 25-Jan-2021  jmcneill Add "cookietype" to i2c attach args, so the consumer knows if ia_cookie
is either an OF phandle or an ACPI_HANDLE. Add NXP0002 compatible mapping
while here.
 1.8 24-Aug-2020  msaitoh branches: 1.8.2;
s/ressource/resource/. No functional change.
 1.7 11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.6 08-Jun-2020  thorpej Update for proplib(3) API changes.
 1.5 28-Sep-2019  bouyer joshua stein, PR kern/54493: acpi_i2c uses incorrect arguments for _DSM call

The last argument to the _DSM call has to be ACPI_TYPE_PACKAGE, as defined in in
clude/acpredef.h for _DSM.

Avoids an ACPI warning at boot.
 1.4 05-May-2018  christos branches: 1.4.2; 1.4.8;
introduce acpi_device_present() to replace the previous _STA checks.
 1.3 07-Apr-2018  christos Merge conflicts; STA methods and fields are not present anymore.
 1.2 11-Dec-2017  bouyer branches: 1.2.2;
Define _COMPONENT and ACPI_MODULE_NAME; fix ACPI_DEBUG kernels
 1.1 10-Dec-2017  bouyer Implement a ACPI helper to fill the property array expected from our I2C
framework from the ACPI tables.
Also implement acpi_intr_establish(), acpi_intr_disestablish() and
acpi_intr_string().
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.2.2.2 21-May-2018  pgoyette Sync with HEAD
 1.2.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.4.8.1 28-Sep-2019  martin Pull up following revision(s) (requested by bouyer in ticket #265):

sys/dev/acpi/acpi_i2c.c: revision 1.5

joshua stein, PR kern/54493: acpi_i2c uses incorrect arguments for _DSM call

The last argument to the _DSM call has to be ACPI_TYPE_PACKAGE, as defined in in
clude/acpredef.h for _DSM.

Avoids an ACPI warning at boot.
 1.4.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.11.14.2 10-Sep-2021  thorpej Remove unnecessary references to i2c_attach_args::ia_prop and mark the ones
that remain as XXX.
 1.11.14.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.11.4.2 08-May-2021  thorpej There are no more consumers of i2c attach args "cookie" and "cookietype",
so garbage-collect them.
 1.11.4.1 25-Apr-2021  thorpej Implement "i2c-enumerate-devices" for ACPI.
 1.12.10.1 02-Aug-2025  perseant Sync with HEAD
 1.8 23-Sep-2025  thorpej Enumerate i2c devices directly from the ACPI device tree.
 1.7 15-Sep-2025  thorpej Register the I2C controller with the ACPI subsystem centrally in
iic_attach().
 1.6 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.5 09-Dec-2024  jmcneill acpi: i2c: Support GenericSerialBus address space handlers.

Add support for I2C controllers to install GSB address space handlers.
 1.4 09-Aug-2021  thorpej branches: 1.4.10;
Fix CVS eff-up.
 1.3 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.2 26-Jan-2021  jmcneill branches: 1.2.4;
Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.1 10-Dec-2017  bouyer branches: 1.1.18;
Implement a ACPI helper to fill the property array expected from our I2C
framework from the ACPI tables.
Also implement acpi_intr_establish(), acpi_intr_disestablish() and
acpi_intr_string().
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.18.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.4.1 25-Apr-2021  thorpej Implement "i2c-enumerate-devices" for ACPI.
 1.4.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 17-Dec-2024  riastradh acpi_intr.h: Add missing includes and forward declarations.

Nix spurious parameter name in prototype.

No functional change intended, other than to make potential users
build when they previously wouldn't.
 1.5 23-Oct-2020  jmcneill branches: 1.5.26;
Add acpi_intr_establish_irq, which is like acpi_intr_establish except
it takes a struct acpi_irq * instead of ACPI_HANDLE. Useful if a device
has more than one IRQ resource (acpi_intr_establish always picks the
first).
 1.4 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.3 16-Nov-2018  jmcneill Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.
 1.2 20-Mar-2018  bouyer branches: 1.2.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.1 10-Dec-2017  bouyer branches: 1.1.2;
Implement a ACPI helper to fill the property array expected from our I2C
framework from the ACPI tables.
Also implement acpi_intr_establish(), acpi_intr_disestablish() and
acpi_intr_string().
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.2.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.2.1 10-Jun-2019  christos Sync with HEAD
 1.5.26.1 02-Aug-2025  perseant Sync with HEAD
 1.45 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.44 23-Apr-2015  pgoyette branches: 1.44.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.43 16-Feb-2011  jruoho branches: 1.43.14; 1.43.32;
Use ioconf for the module declarations.
 1.42 25-Oct-2010  jruoho branches: 1.42.2; 1.42.4;
Bump WARNS to 4.
 1.41 24-Aug-2010  jruoho Bypass ACPI_NOTIFY_DEVICE_WAKE also in acpilid(4). Use aprint_debug_dev(9)
for an unknown notify. (The ACPI drivers should really not print anything
as we now have a global notify handler that can catch the debug information.)
 1.40 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.39 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.38 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.37 05-Mar-2010  jruoho branches: 1.37.2;
Preparing a device for wakeup involves:

(a) turning on all power resources required by the device; and
(b) executing _DSW (or _PSW) control method.

This implements (b). Ok jmcneill@.
 1.36 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.35 28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.34 28-Feb-2010  jruoho Cleanup:

* Semantics.
* Remove ACPI_LID_DEBUG.
* Reduce the amount of error reporting.
* As the status of the lid (open/closed) is known upon suspend, move the
state variable to the softc, and avoid one object evaluation this way.
 1.33 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.32 30-Jan-2010  jruoho branches: 1.32.2;
Add the _COMPONENT definition for ACPI_DEBUG.
 1.31 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.30 31-Dec-2009  jruoho As the _PSW control method was deprecated in ACPI 3.0, augment the wake
event call with the newer _DSW control method.

ok pgoyette@, jmcneill@
 1.29 29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.28 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.27 04-Aug-2009  jmcneill add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.26 15-Jul-2008  dyoung branches: 1.26.4; 1.26.12;
Make acpilid(4) detachable.
 1.25 26-Mar-2008  xtraeme branches: 1.25.4; 1.25.6; 1.25.8; 1.25.10;
Split device_t/softc and related cosmetic changes.
 1.24 23-Mar-2008  xtraeme Add missing acpilid_wake_event() proto.
 1.23 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.22 09-Dec-2007  jmcneill branches: 1.22.6; 1.22.10;
Merge jmcneill-pm branch.
 1.21 16-Nov-2006  christos branches: 1.21.22; 1.21.24; 1.21.34; 1.21.36;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 20-Feb-2006  kochi branches: 1.19.14; 1.19.16;
use aprint_*
 1.18 16-Feb-2006  kochi prototypes don't need argument names
 1.17 11-Dec-2005  christos branches: 1.17.2; 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 02-May-2005  kochi branches: 1.16.2;
Merge changes for ACPI-CA 20050408
 1.15 01-May-2004  kochi specify static where appropriate.
 1.14 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.13 24-Mar-2004  kanaoka Make it compile (int -> ACPI_INTEGER)
 1.12 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.11 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.10 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.9 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.8 18-Apr-2003  thorpej branches: 1.8.2;
* Add a generic power management event API, defined in <sys/power.h>.
Right now, only power switch state change events are supported. This
is a work-in-progress.
* Add support to sysmon for delivering power mangement events to userland.
Add poll, kqueue, and read entry points to sysmon.
* Adapt ACPI to use the new generic <sys/power.h> event types.

This provides the kernel support for a forthcoming powerd(8) which can
do nice things like gracefully shut the system down when an ACPI power
button is pressed.
 1.7 17-Apr-2003  thorpej Adapt to the sysmon_pswitch interface.
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem branches: 1.3.2;
add RCSID
 1.2 29-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Don't be DEBUG by default, but still be noisy about lid status
changes until such time as we actually do something with them.
 1.1 28-Sep-2001  thorpej Add stub drivers for ACPI buttons and lid switches. These don't
really do anything yet.
 1.2.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.4.1 29-Sep-2001  nathanw file acpi_lid.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.2.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 29-Sep-2001  fvdl file acpi_lid.c was added on branch thorpej-devvp on 2001-10-01 12:44:16 +0000
 1.3.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 13-Nov-2001  thorpej file acpi_lid.c was added on branch kqueue on 2002-01-10 19:52:53 +0000
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.2.5 24-Mar-2008  yamt sync with head.
 1.16.2.4 17-Mar-2008  yamt sync with head.
 1.16.2.3 21-Jan-2008  yamt sync with head
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.2 01-Mar-2006  yamt sync with head.
 1.17.2.1 18-Feb-2006  yamt sync with head.
 1.19.16.2 10-Dec-2006  yamt sync with head.
 1.19.16.1 22-Oct-2006  yamt sync with head
 1.19.14.1 18-Nov-2006  ad Sync with head.
 1.21.36.1 11-Dec-2007  yamt sync with head.
 1.21.34.1 26-Dec-2007  ad Sync with head.
 1.21.24.2 23-Mar-2008  matt sync with HEAD
 1.21.24.1 09-Jan-2008  matt sync with HEAD
 1.21.22.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.21.22.4 21-Nov-2007  joerg Iff the lid is closed at suspend time, make it a wake event.
 1.21.22.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.21.22.2 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.21.22.1 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.22.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.22.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.6.1 24-Mar-2008  keiichi sync with head.
 1.25.10.1 19-Oct-2008  haad Sync with HEAD.
 1.25.8.1 18-Jul-2008  simonb Sync with head.
 1.25.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.25.4.6 09-Oct-2010  yamt sync with head
 1.25.4.5 11-Aug-2010  yamt sync with head.
 1.25.4.4 11-Mar-2010  yamt sync with head
 1.25.4.3 16-Sep-2009  yamt sync with head
 1.25.4.2 19-Aug-2009  yamt sync with head.
 1.25.4.1 04-May-2009  yamt sync with head.
 1.26.12.1 21-Apr-2010  matt sync to netbsd-5
 1.26.4.1 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.32.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.32.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.32.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.2.2 05-Mar-2011  rmind sync with head
 1.37.2.1 30-May-2010  rmind sync with head
 1.42.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.42.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.43.32.1 06-Jun-2015  skrll Sync with HEAD
 1.43.14.1 03-Dec-2017  jdolecek update from HEAD
 1.44.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.22 07-Aug-2010  jruoho Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.
 1.21 05-Mar-2010  jruoho branches: 1.21.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.20 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.19 07-Jan-2008  tnn branches: 1.19.10; 1.19.30;
Make the ACPI_MADT_DEBUG code compile again.
 1.18 09-Dec-2007  jmcneill branches: 1.18.2;
Merge jmcneill-pm branch.
 1.17 16-Nov-2006  christos branches: 1.17.22; 1.17.24; 1.17.30; 1.17.34; 1.17.36;
__unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 16-Feb-2006  kochi branches: 1.15.14; 1.15.16;
use ACPI_FAILURE() macro instead of directly check AE_OK
 1.14 11-Dec-2005  christos branches: 1.14.2; 1.14.4; 1.14.6;
merge ktrace-lwp.
 1.13 01-May-2004  kochi branches: 1.13.12;
specify static where appropriate.
 1.12 24-Mar-2004  kochi Don't include unnecessary header (acpi_osd.h)
 1.11 24-Mar-2004  kochi - Don't use ACPI CA internal functions
- make MADT table pointer static
 1.10 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.9 11-Dec-2003  christos make this compile again.
 1.8 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.7 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.6 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.5 11-May-2003  fvdl branches: 1.5.2;
Avoid a strict-alias warning.
 1.4 08-Jan-2003  fvdl Define ACPI_MADT_DEBUG externally.
 1.3 07-Jan-2003  fvdl Deal correctly with an MADT that is not found, or was already found
in acpi_madt_{un}map.
 1.2 07-Jan-2003  fvdl branches: 1.2.2;
* Add aux argument to functions called from apic_madt_walk
* Improve acpi interrupt fixup a bit
* Source is an array, don't compare it to NULL, instead
look for an empty string to denote a link-device-less
entry.
* For root PCI busses, try to use the _BBN method to get
numbering right.
* Add acpi_md_callback() function for MD handling after the init,
but before * at acpi probing.
 1.1 05-Jan-2003  fvdl Add some code to deal with the MADT.
 1.2.2.3 08-Jan-2003  thorpej Sync with HEAD.
 1.2.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 07-Jan-2003  thorpej file acpi_madt.c was added on branch nathanw_sa on 2003-01-07 21:33:57 +0000
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.2 21-Jan-2008  yamt sync with head
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 18-Feb-2006  yamt sync with head.
 1.15.16.2 10-Dec-2006  yamt sync with head.
 1.15.16.1 22-Oct-2006  yamt sync with head
 1.15.14.1 18-Nov-2006  ad Sync with head.
 1.17.36.1 11-Dec-2007  yamt sync with head.
 1.17.34.1 26-Dec-2007  ad Sync with head.
 1.17.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.17.24.1 09-Jan-2008  matt sync with HEAD
 1.17.22.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.18.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.19.30.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.19.30.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.19.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.10.2 11-Aug-2010  yamt sync with head.
 1.19.10.1 11-Mar-2010  yamt sync with head
 1.21.2.1 05-Mar-2011  rmind sync with head
 1.9 07-Aug-2010  jruoho Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.
 1.8 05-Mar-2010  jruoho branches: 1.8.2;
Protect all header files against multiple inclusions.
 1.7 09-Dec-2007  jmcneill branches: 1.7.14; 1.7.34;
Merge jmcneill-pm branch.
 1.6 11-Dec-2005  christos branches: 1.6.44; 1.6.46; 1.6.56; 1.6.58;
merge ktrace-lwp.
 1.5 24-Mar-2004  kochi branches: 1.5.16;
- Don't use ACPI CA internal functions
- make MADT table pointer static
 1.4 14-Feb-2004  kochi Merge ACPI-CA 20040211.
 1.3 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.2 07-Jan-2003  fvdl branches: 1.2.2; 1.2.4;
* Add aux argument to functions called from apic_madt_walk
* Improve acpi interrupt fixup a bit
* Source is an array, don't compare it to NULL, instead
look for an empty string to denote a link-device-less
entry.
* For root PCI busses, try to use the _BBN method to get
numbering right.
* Add acpi_md_callback() function for MD handling after the init,
but before * at acpi probing.
 1.1 05-Jan-2003  fvdl Add some code to deal with the MADT.
 1.2.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.1 03-Aug-2004  skrll Sync with HEAD
 1.2.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 07-Jan-2003  thorpej file acpi_madt.h was added on branch nathanw_sa on 2003-01-07 21:33:57 +0000
 1.5.16.1 21-Jan-2008  yamt sync with head
 1.6.58.1 11-Dec-2007  yamt sync with head.
 1.6.56.1 26-Dec-2007  ad Sync with head.
 1.6.46.1 09-Jan-2008  matt sync with HEAD
 1.6.44.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.7.34.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.7.34.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.7.34.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.14.2 11-Aug-2010  yamt sync with head.
 1.7.14.1 11-Mar-2010  yamt sync with head
 1.8.2.1 05-Mar-2011  rmind sync with head
 1.32 03-Mar-2025  riastradh acpimcfg(4): Use bus ranges set in _CRS if available.

Use the MCFG bus range only as a fallback. The _CRS should tell us
what ranges are available for us to use, which may not even be
contiguous (which pci_resource(9) currently doesn't handle but we'll
deal with that in a separate commit).

ok jmcneill@

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.31 03-Mar-2025  riastradh pci_resource(9): Handle multiple ranges of the same type.

Rather than having the caller fill in an array indexed by range type
of a single start/end pair for each type, the caller will now do:

struct pci_resource_info info;

memset(&info, 0, sizeof(info));

pci_resource_add_range(&info, PCI_RANGE_MEM, mstart1, mend1);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart2, mend2);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart3, mend3);
pci_resource_add_range(&info, PCI_RANGE_PMEM, pstart1, pend1);
pci_resource_add_range(&info, PCI_RANGE_IO, iostart1, ioend1);
...

While here, fix a format string -- 0x% or %# is enough to say that
the output is hexadecimal; we don't need to belabour the point by
printing a `0x0x' prefix!

XXX While this handles multiple io/mem/prefetchable-mem ranges, it
doesn't yet handle multiple bus ranges, which we have seen in
practice, e.g. on orion o6. TBD.

ok jmcneill@

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.30 10-Nov-2024  mlelstv Debug output.
Ignore an address range of size zero.
 1.29 23-Jun-2024  riastradh branches: 1.29.2;
pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.
 1.28 20-May-2024  riastradh Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.
 1.27 20-May-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
 1.26 14-Oct-2022  jmcneill branches: 1.26.2;
Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.25 27-Feb-2022  riastradh acpi: Nix conditional pci_get_segment use.

New MI default of 0 serves.
 1.24 07-Aug-2021  jmcneill acpi: expose acpimcfg_configure_bus_cb
 1.23 26-Jan-2021  skrll Trailing whitespace
 1.22 26-Jan-2021  skrll KNF
 1.21 06-Dec-2020  jmcneill Fix typo in comment
 1.20 07-Jul-2020  thorpej branches: 1.20.2;
Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:

==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.

This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.19 13-Apr-2020  jmcneill Work around a compiler issue when building on aarch64 with KUBSAN.
 1.18 02-Feb-2020  jmcneill branches: 1.18.4;
Add acpimcfg_conf_valid helper for pcie controllers with nonstandard
config space layouts.
 1.17 14-Oct-2019  jmcneill branches: 1.17.2;
The MCFG base address field is the physical address of the base of mmio
space relative to bus 0, not the start bus number specified in the table
entry.
 1.16 20-Dec-2018  jmcneill branches: 1.16.4;
An ACPI MCFG allocation with start bus number = end bus number is valid,
so do not skip it. An entry like this defines MCFG space for a single bus.
 1.15 08-Dec-2018  jmcneill acpimcfg_configure_bus_cb can support 16-bit addresses now
 1.14 03-Dec-2018  cherry Define macro before using it. This macro is used as a compile time
"plugin" mechanism to use various platform specific enumeration
functions. It is currently separately defined for 'native' and XEN,
but the mechanism is not exported globally as it should be.

XXX: fix this.
 1.13 02-Nov-2018  jmcneill Do not ignore non-zero segment numbers in MCFG if __HAVE_PCI_GET_SEGMENT
is defined.
 1.12 02-Nov-2018  jmcneill Add support for multiple PCI segments.
 1.11 19-Oct-2018  jmcneill Fix table offset when walking MCFG allocation subtables
 1.10 17-Oct-2018  jmcneill Allow access to PCI configuration space for devices without extended
config support.

ok nonaka@
 1.9 15-Oct-2018  jmcneill Fix signature for acpimcfg_configure_bus in non-PCI_NETBSD_CONFIGURE case
 1.8 15-Oct-2018  jmcneill Add acpimcfg_configure_bus, which can be used by MD code to implement
PCI_NETBSD_CONFIGURE using ACPI MCFG tables.
 1.7 13-Oct-2018  jmcneill acpimcfg_scan_bus: Assign the pci_softc's sc_pc to the passed in PCI
chipset tag -- pci_enumerate_bus depends on this being initialized. This
happened to work on x86 because the pci_* md code allows for NULL pc.
 1.6 06-Apr-2018  maxv branches: 1.6.2;
Change the iteration, to make sure the ACPI_MCFG_ALLOCATION structure we're
reading fits the table we allocated. Linux does the same.

I have a laptop which, for some reason, reports a table size of 62 bytes.
Clearly that's incorrect, it should be 60 (44 + 16). Because of the stray
+2, here the kernel reads past the end of the allocated buffer, hits an
unmapped VA, and panics at boot time. So the laptop can't boot.

Now it boots fine.
 1.5 28-Feb-2018  msaitoh branches: 1.5.2;
- Add new PCI quirk PCI_QUIRK_HASEXTCNF and PCI_QUIRK_NOEXTCNF. Some devices'
extended configuration area may be broken or violate spec. If an extended
configuration space is strange but it really exist, use PCI_QUIRK_HASEXTCNF.
If an extended configuration space is plausible to exist but it really
doesn't exist, use PCI_QUIRK_NOEXTCNF.
- Add PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_1(0x6fa8) and
PCI_PRODUCT_INTEL_COREI76K_IMC_0(0x6f68) with PCI_QUIRK_HASEXTCNF. The
document clearly states they violate spec and it support the extended
configuration space.
 1.4 12-Jul-2016  hannken branches: 1.4.10; 1.4.16;
According to "PCI Express Base Specification Revision 3.0" from
November 10, 2010, section 7.9.1 an Extended Capability header
with value 0:0:0 represents the absence of Extended Capabilities.
 1.3 12-Jul-2016  hannken On an Intel E7520 temporarily disable Enhanced Config Access error
detection and reporting during bus scan.

Fixes PR kern/51251: ACPI device probe raises NMI
 1.2 11-Oct-2015  christos branches: 1.2.2;
add missing debugging attributes
 1.1 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.2.2.3 05-Oct-2016  skrll Sync with HEAD
 1.2.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.2.1 11-Oct-2015  skrll file acpi_mcfg.c was added on branch nick-nhusb on 2015-12-27 12:09:48 +0000
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 12-Jul-2016  jdolecek file acpi_mcfg.c was added on branch tls-maxphys on 2017-12-03 11:36:58 +0000
 1.4.10.1 08-Apr-2018  snj Pull up following revision(s) (requested by nonaka in ticket #700):
sys/dev/acpi/acpi_mcfg.c: 1.6
Change the iteration, to make sure the ACPI_MCFG_ALLOCATION structure we're
reading fits the table we allocated. Linux does the same.
I have a laptop which, for some reason, reports a table size of 62 bytes.
Clearly that's incorrect, it should be 60 (44 + 16). Because of the stray
+2, here the kernel reads past the end of the allocated buffer, hits an
unmapped VA, and panics at boot time. So the laptop can't boot.
Now it boots fine.
 1.5.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.5.2.2 20-Oct-2018  pgoyette Sync with head
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.6.2.4 21-Apr-2020  martin Sync with HEAD
 1.6.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.2.1 10-Jun-2019  christos Sync with HEAD
 1.16.4.1 15-Oct-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #333):

sys/dev/acpi/acpi_mcfg.c: revision 1.17

The MCFG base address field is the physical address of the base of mmio
space relative to bus 0, not the start bus number specified in the table
entry.
 1.17.2.1 29-Feb-2020  ad Sync with head.
 1.18.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.20.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.20.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.26.2.1 04-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #928):

sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.25
sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h: revision 1.6
sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.49
sys/external/bsd/drm2/include/linux/mxm-wmi.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c: revision 1.13
sys/external/bsd/common/include/linux/bitops.h: revision 1.17
sys/external/bsd/drm2/nouveau/files.nouveau: revision 1.40
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.30
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.12
sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_sorgm200.c: revision 1.3
sys/external/bsd/common/include/linux/printk.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_gk20a.c: revision 1.10
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c: revision 1.4
sys/external/bsd/drm2/include/linux/acpi.h: revision 1.11
sys/external/bsd/drm2/drm/drm_cdevsw.c: revision 1.31
sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h: revision 1.5
sys/external/bsd/drm2/include/acpi/video.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h: revision 1.4
sys/arch/sparc64/include/pci_machdep.h: revision 1.31
sys/arch/sparc64/dev/pci_machdep.c: revision 1.83
sys/external/bsd/drm2/include/linux/kref.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c: revision 1.12
sys/external/bsd/drm2/linux/linux_dma_buf.c: revision 1.17
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c: revision 1.4
sys/external/bsd/drm2/drm/drm_module.c: revision 1.32
sys/external/bsd/drm2/dist/drm/i915/i915_gem.h: revision 1.8
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c: revision 1.7
sys/external/bsd/drm2/include/linux/smp.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.20
sys/arch/x86/x86/bus_dma.c: revision 1.91
sys/external/bsd/drm2/radeon/files.radeon: revision 1.40
sys/external/bsd/drm2/include/acpi/acpi_bus.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.21
sys/external/bsd/common/include/asm/barrier.h: revision 1.20
sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h: revision 1.2
sys/external/bsd/common/include/asm/barrier.h: revision 1.21
sys/modules/drmkms/drmkms_pci.h: revision 1.1
sys/external/bsd/drm2/dist/drm/drm_dp_helper.c: revision 1.17
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.23
sys/external/bsd/drm2/linux/linux_xa.c: revision 1.4
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.23
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.25
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.26
sys/dev/pci/pcivar.h: revision 1.120
sys/arch/xen/include/pci_machdep.h: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.26
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.27
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.27
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.28
sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c: revision 1.8
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.28
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.29
sys/external/bsd/drm2/include/linux/pci.h: revision 1.57
sys/external/bsd/drm2/include/linux/pci.h: revision 1.58
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c: revision 1.6
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c: revision 1.3
sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c: revision 1.3
share/man/man9/bus_dma.9: revision 1.69
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c: revision 1.15
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon.h: revision 1.12
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c: revision 1.7
sys/dev/acpi/acpi_mcfg.c: revision 1.29
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c: revision 1.7
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.13
sys/modules/amdgpu/Makefile: revision 1.9
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.14
sys/external/bsd/common/linux/linux_tasklet.c: revision 1.12
sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h: revision 1.10
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.23
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h: revision 1.9
sys/external/bsd/drm2/include/linux/interval_tree.h: revision 1.14
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.26
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c: revision 1.5
sys/dev/pci/pci.c: revision 1.168
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.27
sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c: revision 1.9
sys/external/bsd/drm2/pci/files.drmkms_pci: revision 1.18
sys/external/bsd/drm2/linux/linux_sync_file.c: revision 1.3
sys/external/bsd/drm2/amdgpu/files.amdgpu: revision 1.31
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c: revision 1.4
sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.24
sys/arch/xen/xen/xpci_xenbus.c: revision 1.29

drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

linux asm/barrier.h: Fix !MULTIPROCESSOR build.

remove "nouveau" from a comment. noted by jmcneill.

drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.

nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.
found by GCC 12.

avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical. as these indexes will always both
be 0, the only valid index, the condition is always false. GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.
amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
470 | stream->writeback_info[j] = stream->writeback_info[i];

convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.

drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled. (Might not be very useful, but it'll
build. Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)

drmkms: Fix module build.
avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.

drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.
this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed". for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus. add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)
tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].
this still does not quite work on nvidia cards. there are two problems
that remain:
- the call to set the link speed is skipped because the speed is set
to the default value of "-1". nvkm_pcie_set_link() will actually
determine the right value for this and for some cards, calling this
function if the current speed is -1 helps set the link speed. it
may be that on linux other paths we don't have enabled properly
would set this (there's one via debugfs, and a jetson specific one,
though perhaps setting either AC or DC speed values as boot options
(after hooking up these for netbsd) would currently work.
- worse, cards newer than kepler - geforce 900, 1000, and newer, are
all lacking the backing support to set pcie link speed. the GT 1030
card i have been testing with remains at pcie 1.0.

radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)
XXX amdgpu should get the same treatment.

drm: put_cpu() should enable preemption, not disable it again

drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).

drm: Set CONFIG_ACPI in linux/acpi.h and make it build.

Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.

radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.

drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.
PR kern/58180

linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.
PR kern/58210

ttm: Sync ttm_bo_uvm_fault_idle better with Linux.
PR xsrc/58133
ttm: Undo mistake in previous.

PR xsrc/58133
linux: Add a few more cases to pci_get_class.
Should fix crash on boot with amdgpu now that the ACPI business is
enabled.

i915: Fix dmabuf mmap object.

drm: Fix missing bounds checks in dma buf mmap.

drm_gem.c: Fix sense of assertion.
This is the opposite of WARN_ON.
Noted by rjs@.

drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.

i915_gem_mman.c: Apply mmap types via pmap flags.
This way, userland gets buffers mapped write-combining or uncached as
needed.
PR xsrc/58307

x86: Teach bus_dmamem_map about BUS_DMA_PREFETCHABLE.
PR port-amd64/58308

bus_dma(9): Document BUS_DMA_PREFETCHABLE.
Like BUS_DMA_NOCACHE. Doesn't absolve you of the need for
bus_dmamap_sync, but if you later pass the vaddr to bus_dmamap_load,
the DMA map might notice the mapping is write-combining and use this
to make bus_dmamap_sync cheaper.
PR kern/58309

nouveau_nvkm_subdev_instmem_gk20a.c: Use BUS_DMA_PREFETCHABLE.
Matches Linux's pgprot_writecombine.
Unclear where the appropriate bus_dmamap_sync happens, or is supposed
to happen -- not using it would be wrong, but asking for a
prefetchable mapping may paper over symptoms, at least!

ttm: Sync more with Linux.
Add the original copyright and attribution since this is now,
intentionally, a modified copy of the original and not just roughly
the same algorithm.

ttm: Respect PGO_ALLPAGES.
Not sure this is useful but it reduces XXX's and makes this match
udv_fault better so it's easier to understand.

ttm: Sync cacheability flag logic with Linux.

ttm: Add XXX about readahead fault failures.

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.
New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.
This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).
This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
Take 2: Make sure to handle NULL match function.
linux_pci: Nix pci enumeration kludges.
Now that we can pass a cookie through, this stuff will be a little
less fragile.

i915: Omit needless i915_gem_object_pin/unpin_pages cycle in fault.
vm_fault_cpu and vm_fault_gtt, called by i915_gem_fault, already do
the pinning and unpinning internally, so there is no need for
i915_gem_fault to do it.
No functional change intended, except that the transient pin count
will be one lower than before during the fault routine (but it will
still be positive).

i915: Match Linux fault routine return code actions.
Omit needless EINTR interception -- this is now handled by
i915_error_to_vmf_fault.
Earlier revert was over a false alarm -- bisection shows the new
warnings arose from linux_pci.c 1.29 here:
https://mail-index.netbsd.org/source-changes/2024/06/23/msg151929.html

linux_pci: Fix shifto in pci_get_class.
It looks like Linux's pci_get_class also matches the interface part
of the PCI class register (but not the revision part), and I hadn't
noticed that in the previous shim structured differently.

With GCC12 kernel ALL/amd64 triggers "'sor' may be used uninitialized".
If "sublinks & 3" is zero GCC is right and sor[1] may be returned unitialized.
Fix by initializing "sor" to zero to return -1 instead of uninitialized value.
Ok: Taylor R Campbell <riastradh@>

amdgpu: Map BAR 2, not BAR 5, on pre-bonaire chips.
PR kern/58384

amdgpu: Map consecutive pages, not the same one over and over again.
PR kern/58385

linux/bitops: Fix overestimate for BITS_TO_LONGS(9)
Fortunately, this seems harmless except for allocating
excessive buffer memory.
Pointed out by nonaka@, OK riastradh@.
 1.29.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 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.5 14-Oct-2022  jmcneill branches: 1.5.10;
Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.4 07-Aug-2021  jmcneill acpi: expose acpimcfg_configure_bus_cb
 1.3 02-Feb-2020  jmcneill Add acpimcfg_conf_valid helper for pcie controllers with nonstandard
config space layouts.
 1.2 15-Oct-2018  jmcneill branches: 1.2.6;
Add acpimcfg_configure_bus, which can be used by MD code to implement
PCI_NETBSD_CONFIGURE using ACPI MCFG tables.
 1.1 02-Oct-2015  msaitoh branches: 1.1.2; 1.1.18; 1.1.20; 1.1.22;
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.1.22.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 20-Oct-2018  pgoyette Sync with head
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 02-Oct-2015  jdolecek file acpi_mcfg.h was added on branch tls-maxphys on 2017-12-03 11:36:58 +0000
 1.1.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.1 02-Oct-2015  skrll file acpi_mcfg.h was added on branch nick-nhusb on 2015-12-27 12:09:48 +0000
 1.2.6.1 29-Feb-2020  ad Sync with head.
 1.5.10.1 20-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #66):

sys/arch/x86/include/mpacpi.h: revision 1.12
sys/arch/x86/x86/mpacpi.c: revision 1.112
sys/arch/amd64/conf/ALL: revision 1.194
sys/arch/i386/conf/ALL: revision 1.524
sys/arch/x86/acpi/acpi_machdep.c: revision 1.40
sys/arch/i386/conf/GENERIC: revision 1.1261
sys/dev/acpi/acpi_mcfg.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.618

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.3 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.2 23-Aug-2009  jmcneill branches: 1.2.2;
When ACPI is not present, free any resources used by the ACPICA. Also,
no need to complain (unless we're debugging) that ACPI is not present.
 1.1 28-Sep-2001  thorpej branches: 1.1.2; 1.1.4; 1.1.8; 1.1.126;
Add some basic ACPI probing framework. This is far from complete,
it is merely a work in progress.
 1.1.126.2 11-Mar-2010  yamt sync with head
 1.1.126.1 16-Sep-2009  yamt sync with head
 1.1.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 28-Sep-2001  thorpej file acpi_osd.h was added on branch kqueue on 2002-01-10 19:52:53 +0000
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 28-Sep-2001  nathanw file acpi_osd.h was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 28-Sep-2001  fvdl file acpi_osd.h was added on branch thorpej-devvp on 2001-10-01 12:44:16 +0000
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1 13-Dec-2020  jmcneill branches: 1.1.2;
acpi: Add support for ACPI Platform Communications Channel (PCC).
 1.1.2.2 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1.2.1 13-Dec-2020  thorpej file acpi_pcc.c was added on branch thorpej-futex on 2020-12-14 14:38:05 +0000
 1.1 13-Dec-2020  jmcneill branches: 1.1.2;
acpi: Add support for ACPI Platform Communications Channel (PCC).
 1.1.2.2 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1.2.1 13-Dec-2020  thorpej file acpi_pcc.h was added on branch thorpej-futex on 2020-12-14 14:38:05 +0000
 1.2 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.1 07-Dec-2020  jmcneill branches: 1.1.2;
acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.1.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.1.2.2 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1.2.1 07-Dec-2020  thorpej file acpi_pcd.c was added on branch thorpej-futex on 2020-12-14 14:38:05 +0000
 1.37 14-Oct-2022  jmcneill Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.36 27-Feb-2022  riastradh acpi: Nix conditional pci_get_segment use.

New MI default of 0 serves.
 1.35 11-Feb-2022  riastradh acpi(9): No need to test dv_locators.

It is always initialized by config_devalloc before config_devlink
makes it visible to device iteration. No need to reach into private
autoconf internals.
 1.34 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.33 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.32 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.31 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.30 14-Jan-2021  thorpej branches: 1.30.4; 1.30.6;
In acpi_pci_ignore_boot_config(), use acpi_dsm() and add some comments
describing the (somewhat confusing) semantics of the _DSM method used
here.
 1.29 08-May-2020  jmcneill branches: 1.29.2;
expose acpi_pcidev_pciroot_bus
 1.28 18-Jan-2020  jmcneill Ignore PCI boot config unless the _DSM for ignoring PCI boot config is
explicitly set to 0.
 1.27 17-Jan-2020  jmcneill Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.26 01-Mar-2019  msaitoh branches: 1.26.6;
- Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.25 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.24 21-Oct-2018  jmcneill Add a function to report whether the operating system may ignore the boot
configuration of PCI resources for a given bus.
 1.23 15-Oct-2018  jmcneill Add a function to find a PCI root bridge by segment and bus number.
 1.22 05-May-2018  christos branches: 1.22.2;
introduce acpi_device_present() to replace the previous _STA checks.
 1.21 07-Apr-2018  christos Merge conflicts; STA methods and fields are not present anymore.
 1.20 01-Jun-2017  chs branches: 1.20.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.19 13-Apr-2015  christos sync with new acpica struct shuffling.
 1.18 31-Dec-2010  jruoho branches: 1.18.18; 1.18.36;
acpi_pcidev_find_dev(): take struct acpi_devnode as a parameter.
 1.17 31-Dec-2010  jruoho Move the function that finds a device_t for the corresponding ACPI device
node from ACPIVERBOSE to the ACPI PCI code.
 1.16 26-Oct-2010  gsutre An _ADR object is not required for PCI root bridges. To solve
this, the structure acpi_pciinfo now tells whether the ACPI
device node is a PCI bridge, a regular PCI device, or both.

Problem reported by jmcneill@, who also suggested the solution.

ok jmcneill@, jruoho@
 1.15 24-Sep-2010  gsutre Do not discard ACPI PCI addresses with function number 0xFFFF: the
ACPI specification allows them (ACPI 4.0a, p. 200).

ok jruoho@
 1.14 09-Aug-2010  gsutre acpi_pcidev_scan: attach PCI information only to working devices.

ok jruoho@
 1.13 08-Aug-2010  gsutre acpi_pcidev_scan: discard invalid PCI addresses.
 1.12 09-Jun-2010  mrg pci_chipset_tag_t is opaque - don't compare it to NULL, just use it.
shouldn't be a problem because "acpi_softc" variable isn't setup until
the "sc_pc" member is set.

fixes ia64 build. tested on amd64. ok jruoho.
 1.11 26-Apr-2010  jruoho Improve and rearrange comments.
 1.10 23-Apr-2010  jruoho Simplify acpi_pcidev_find(): directly return a pointer to the device node.
 1.9 22-Apr-2010  jruoho Some pretty printing for ACPIVERBOSE.
 1.8 22-Apr-2010  jruoho Wrap long lines, add some white space for readability, remove unnecessary
variable assignments, misc KNF. No functional change.
 1.7 22-Apr-2010  jruoho Shorten the long lines with two custom macros.
 1.6 22-Apr-2010  jruoho From Gregoire Sutre: rework the ACPI PCI support. This makes ACPI to
correctly pick PCI segment groups, PCI bus numbers, PCI root bridges,
PCI-to-PCI bridges, and PCI devices, among other things. In short: it is
more robust than the old code or anything in sys/arch/x86/x86/mpacpi.c.

ok cegger@, jmcneill@
 1.5 18-Apr-2010  jruoho From Gregoire Sutre:

Modify the main ACPI namespace scan by including a parent-child
relationship for each node. The result is a bi-directional tree.

ok jmcneill@
 1.4 09-Mar-2010  jruoho branches: 1.4.2; 1.4.4;
Remove the namespace scopes.

These are neither used nor useful beyond the parser and interpreter.

ok jmcneill@, joerg@
 1.3 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 03-Dec-2009  cegger Enumerate ACPI PCI devices. Allows to link PCI with ACPI devices.
Patch presented on tech-kern@
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

'nice work' Jukka Ruohonen
 1.2.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.2.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.4.3 05-Mar-2011  rmind sync with head
 1.4.4.2 03-Jul-2010  rmind sync with head
 1.4.4.1 30-May-2010  rmind sync with head
 1.4.2.4 09-Oct-2010  yamt sync with head
 1.4.2.3 11-Aug-2010  yamt sync with head.
 1.4.2.2 11-Mar-2010  yamt sync with head
 1.4.2.1 09-Mar-2010  yamt file acpi_pci.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.18.36.2 28-Aug-2017  skrll Sync with HEAD
 1.18.36.1 06-Jun-2015  skrll Sync with HEAD
 1.18.18.1 03-Dec-2017  jdolecek update from HEAD
 1.20.8.4 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.20.8.3 20-Oct-2018  pgoyette Sync with head
 1.20.8.2 21-May-2018  pgoyette Sync with HEAD
 1.20.8.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.22.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.6.2 25-Jan-2020  ad Sync with head.
 1.26.6.1 17-Jan-2020  ad Sync with head.
 1.29.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.30.6.1 31-May-2021  cjep sync with head
 1.30.4.1 13-May-2021  thorpej Sync with HEAD.
 1.13 14-Oct-2022  jmcneill Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.12 08-May-2020  jmcneill expose acpi_pcidev_pciroot_bus
 1.11 17-Jan-2020  jmcneill Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.10 21-Oct-2018  jmcneill branches: 1.10.6;
Add a function to report whether the operating system may ignore the boot
configuration of PCI resources for a given bus.
 1.9 15-Oct-2018  jmcneill Add a function to find a PCI root bridge by segment and bus number.
 1.8 31-Dec-2010  jruoho branches: 1.8.58; 1.8.60;
acpi_pcidev_find_dev(): take struct acpi_devnode as a parameter.
 1.7 31-Dec-2010  jruoho Move the function that finds a device_t for the corresponding ACPI device
node from ACPIVERBOSE to the ACPI PCI code.
 1.6 23-Apr-2010  jruoho Simplify acpi_pcidev_find(): directly return a pointer to the device node.
 1.5 22-Apr-2010  jruoho Some pretty printing for ACPIVERBOSE.
 1.4 22-Apr-2010  jruoho From Gregoire Sutre: rework the ACPI PCI support. This makes ACPI to
correctly pick PCI segment groups, PCI bus numbers, PCI root bridges,
PCI-to-PCI bridges, and PCI devices, among other things. In short: it is
more robust than the old code or anything in sys/arch/x86/x86/mpacpi.c.

ok cegger@, jmcneill@
 1.3 05-Mar-2010  jruoho branches: 1.3.2; 1.3.4;
Protect all header files against multiple inclusions.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 03-Dec-2009  cegger Enumerate ACPI PCI devices. Allows to link PCI with ACPI devices.
Patch presented on tech-kern@
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

'nice work' Jukka Ruohonen
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.4.2 05-Mar-2011  rmind sync with head
 1.3.4.1 30-May-2010  rmind sync with head
 1.3.2.3 11-Aug-2010  yamt sync with head.
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 05-Mar-2010  yamt file acpi_pci.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.8.60.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8.60.1 10-Jun-2019  christos Sync with HEAD
 1.8.58.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.8.58.1 20-Oct-2018  pgoyette Sync with head
 1.10.6.1 17-Jan-2020  ad Sync with head.
 1.29 20-Dec-2021  skrll KNF. Same binary before and after.
 1.28 19-Dec-2021  skrll Tweak comments.
 1.27 19-Dec-2021  skrll Trailing whitespace
 1.26 17-Jan-2020  jmcneill Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.25 13-Jan-2020  chs apply FreeBSD revs r214848 and r214849:

r214849 | jkim | 2010-11-05 13:24:26 -0700 (Fri, 05 Nov 2010) | 2 lines

Add a forgotten change from the previous commit.

r214848 | jkim | 2010-11-05 12:50:09 -0700 (Fri, 05 Nov 2010) | 13 lines

Fix a use-after-free bug for extended IRQ resource[1]. When _PRS buffer is
copied as a template for _SRS, a string pointer for descriptor name is also
copied and it becomes stale as soon as it gets de-allocated[2]. Now _CRS is
used as a template for _SRS as ACPI specification suggests if it is usable.
The template from _PRS is still utilized but only when _CRS is not available
or broken. To avoid use-after-free the problem in this case, however, only
mandatory fields are copied, optional data is removed, and structure length
is adjusted accordingly.

Reported by: hps[1]
Analyzed by: avg[2]
Tested by: hps

This also fixes reading past the end of a structure as detected by KASAN.
 1.24 06-Dec-2019  maxv branches: 1.24.2;
Minor changes, reported by the LGTM bot.
 1.23 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.22 14-Sep-2014  mrg branches: 1.22.20; 1.22.26;
introduce a new option: ACPI__DIS_IS_BROKEN. this is a hack to
avoid calling the "_DIS" method during acpi interrupt link setup,
which hangs various nforce4 based motherboards.

when the problem is properly fixed, remove this hack. for now,
it allows someone (me) to have a valid kernel config that doesn't
require a source hack every new tree.

ok chs@
 1.21 14-Apr-2014  jakllsch branches: 1.21.2;
don't run off the end of the source resource buffer
 1.20 16-Oct-2013  christos branches: 1.20.2;
print a warning if we failed.
 1.19 23-Sep-2012  chs branches: 1.19.2;
re-enable the code to disable link devices at startup, ie. revert rev 1.3.
this fixes PCI interrupts on some systems (eg. HP XW9400) and we suspect that
the problems which led to the original change were caused by buggy early
implementations of ACPI, which are now ignored by date.
 1.18 23-Apr-2010  jruoho branches: 1.18.8; 1.18.14; 1.18.18; 1.18.20;
One malloc(9) type is enough for ACPI; use M_ACPI.
 1.17 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.16 05-Mar-2010  jruoho branches: 1.16.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.15 16-Sep-2009  mlelstv branches: 1.15.2;
Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.14 17-Nov-2008  joerg On resum-from-RAM explicitly restore PCI link device state before
reenabling interrupts. At least one BIOS doesn't do this automatically
as reported by Christoph Egger.
 1.13 04-Jun-2008  jmcneill branches: 1.13.4; 1.13.6; 1.13.8;
Fix a mis-tabbed brace, no functional change.
 1.12 31-May-2008  jmcneill Remove powerhook_establish calls; this functionality has been broken since
4.99.42 and nobody has complained. Newer systems with ioapic shouldn't
need this, and older non-ioapic systems should properly restore PCI IRQ
routing within their PCI-ISA bridge drivers.
 1.11 16-Dec-2007  jmcneill branches: 1.11.6; 1.11.8; 1.11.10; 1.11.12;
acpi_pci_link_route_interrupt: if we're going to return a valid IRQ, we
need to fill in irq, pol, and trig arguments.
 1.10 09-Dec-2007  jmcneill branches: 1.10.2;
Merge jmcneill-pm branch.
 1.9 07-Nov-2007  joerg branches: 1.9.2; 1.9.4;
When assigning an IRQ for classic PIC routing to an ACPI link dev,
make sure to update the PCI Interrupt Register of all PCI devices using
it. This fixes interrupt with ACPI and w/o IOAPIC, when the BIOS didn't
route all interrupts correctly.

Reported by sborill@ and by Mathias De Belder in PR 37001, fix tested
by sborill@.
 1.8 05-Nov-2007  joerg branches: 1.8.2;
Use the fallback to ACPI SCI as PCI interrupt only as a last resort
if no other entry could be used.
 1.7 24-Sep-2006  dogcow branches: 1.7.4; 1.7.24; 1.7.26; 1.7.30;
blah blah discard pointer qualifier blah.
 1.6 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.5 23-Sep-2006  fvdl In acpi_pci_link_dump, print out polarity and trigger for the link device
properties.
 1.4 20-Aug-2006  christos branches: 1.4.2; 1.4.4; 1.4.6;
PR/34241: Dave Sainty: Bound a memcpy to the sizeof the buffer where we
are trying to save the contents, instead of trying to copy what the lenght
of the acpi resource tells us.
 1.3 10-Jul-2006  fvdl branches: 1.3.2; 1.3.6;
Do not try to disable link devices (using _DIS) at startup. This causes
problems on some systems. Leave the code commented out, we might want
to revisit this at some point in the future.
 1.2 05-Jul-2006  xtraeme Repeat after me, use __KERNEL_RCSID.
 1.1 04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.3.6.3 03-Sep-2006  yamt sync with head.
 1.3.6.2 11-Aug-2006  yamt sync with head
 1.3.6.1 10-Jul-2006  yamt file acpi_pci_link.c was added on branch yamt-pdpolicy on 2006-08-11 15:43:59 +0000
 1.3.2.2 13-Jul-2006  gdamore Merge from HEAD.
 1.3.2.1 10-Jul-2006  gdamore file acpi_pci_link.c was added on branch gdamore-uart on 2006-07-13 17:49:17 +0000
 1.4.6.1 22-Oct-2006  yamt sync with head
 1.4.4.2 09-Sep-2006  rpaulo sync with head
 1.4.4.1 20-Aug-2006  rpaulo file acpi_pci_link.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:28 +0000
 1.4.2.1 18-Nov-2006  ad Sync with head.
 1.7.30.1 13-Nov-2007  bouyer Sync with HEAD
 1.7.26.3 09-Jan-2008  matt sync with HEAD
 1.7.26.2 08-Nov-2007  matt sync with -HEAD
 1.7.26.1 06-Nov-2007  matt sync with HEAD
 1.7.24.3 11-Nov-2007  joerg Sync with HEAD.
 1.7.24.2 06-Nov-2007  joerg Sync with HEAD.
 1.7.24.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.7.4.4 21-Jan-2008  yamt sync with head
 1.7.4.3 15-Nov-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 24-Sep-2006  yamt file acpi_pci_link.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:54 +0000
 1.8.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.8.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.9.4.1 11-Dec-2007  yamt sync with head.
 1.9.2.1 26-Dec-2007  ad Sync with head.
 1.10.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.10.3 11-Aug-2010  yamt sync with head.
 1.11.10.2 11-Mar-2010  yamt sync with head
 1.11.10.1 04-May-2009  yamt sync with head.
 1.11.8.2 17-Jun-2008  yamt sync with head.
 1.11.8.1 04-Jun-2008  yamt sync with head
 1.11.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.11.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.8.1 25-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #125):
sys/arch/x86/acpi/acpi_wakeup.c: revision 1.11
sys/dev/acpi/acpi_pci_link.c: revision 1.14
sys/dev/acpi/acpivar.h: revision 1.34
On resum-from-RAM explicitly restore PCI link device state before
reenabling interrupts. At least one BIOS doesn't do this automatically
as reported by Christoph Egger.
 1.13.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.1 30-May-2010  rmind sync with head
 1.18.20.2 10-Dec-2012  riz Back out ticket #682; it's causing some systems to fail to boot.
 1.18.20.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #682):
sys/dev/acpi/acpi_pci_link.c: revision 1.19
re-enable the code to disable link devices at startup, ie. revert rev 1.3.
this fixes PCI interrupts on some systems (eg. HP XW9400) and we suspect that
the problems which led to the original change were caused by buggy early
implementations of ACPI, which are now ignored by date.
 1.18.18.3 03-Dec-2017  jdolecek update from HEAD
 1.18.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.14.2 10-Dec-2012  riz Back out ticket #682; it's causing some systems to fail to boot.
 1.18.14.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #682):
sys/dev/acpi/acpi_pci_link.c: revision 1.19
re-enable the code to disable link devices at startup, ie. revert rev 1.3.
this fixes PCI interrupts on some systems (eg. HP XW9400) and we suspect that
the problems which led to the original change were caused by buggy early
implementations of ACPI, which are now ignored by date.
 1.18.8.2 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.18.8.1 30-Oct-2012  yamt sync with head
 1.19.2.1 18-May-2014  rmind sync with head
 1.20.2.1 10-Aug-2014  tls Rebase.
 1.21.2.1 22-Sep-2014  martin Pull up following revision(s) (requested by mrg in ticket #111):
sys/dev/acpi/files.acpi: revision 1.95
share/man/man4/acpi.4: revision 1.78
sys/dev/acpi/acpi_pci_link.c: revision 1.22
introduce a new option: ACPI__DIS_IS_BROKEN. this is a hack to
avoid calling the "_DIS" method during acpi interrupt link setup,
which hangs various nforce4 based motherboards.
when the problem is properly fixed, remove this hack. for now,
it allows someone (me) to have a valid kernel config that doesn't
require a source hack every new tree.
ok chs@
 1.22.26.1 08-Mar-2020  martin Pull up following revision(s) (requested by chs in ticket #765):

sys/dev/acpi/acpi_pci_link.c: revision 1.25

apply FreeBSD revs r214848 and r214849:

r214849 | jkim | 2010-11-05 13:24:26 -0700 (Fri, 05 Nov 2010) | 2 lines
Add a forgotten change from the previous commit.
r214848 | jkim | 2010-11-05 12:50:09 -0700 (Fri, 05 Nov 2010) | 13 lines

Fix a use-after-free bug for extended IRQ resource[1]. When _PRS buffer is
copied as a template for _SRS, a string pointer for descriptor name is also
copied and it becomes stale as soon as it gets de-allocated[2]. Now _CRS is
used as a template for _SRS as ACPI specification suggests if it is usable.

The template from _PRS is still utilized but only when _CRS is not available
or broken. To avoid use-after-free the problem in this case, however, only
mandatory fields are copied, optional data is removed, and structure length
is adjusted accordingly.

Reported by: hps[1]
Analyzed by: avg[2]
Tested by: hps

This also fixes reading past the end of a structure as detected by KASAN.
 1.22.20.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.20.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.24.2.1 17-Jan-2020  ad Sync with head.
 1.9 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.8 23-Apr-2015  pgoyette branches: 1.8.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.7 21-Jun-2011  jruoho branches: 1.7.12; 1.7.30;
Revert the previous commit as it was wrong/redundant.
 1.6 21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.5 20-Jun-2011  pgoyette Initialize sensors states before registering.
 1.4 03-Jun-2011  jruoho Add locking to account improbable but possible race between the notify
handler and sysmon_envsys(9)'s refresh routine.
 1.3 16-Feb-2011  jruoho branches: 1.3.2; 1.3.4;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.2 14-Feb-2011  jruoho Fix small negligence mistake.
 1.1 05-Jan-2011  jruoho branches: 1.1.2; 1.1.4;
Add a driver for ACPI power meters.
 1.1.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.3 12-Jun-2011  rmind sync with head
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 16-Feb-2011  rmind file acpi_pmtr.c was added on branch rmind-uvmplock on 2011-03-05 20:53:03 +0000
 1.7.30.1 06-Jun-2015  skrll Sync with HEAD
 1.7.12.1 03-Dec-2017  jdolecek update from HEAD
 1.8.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.38 25-Aug-2025  christos More explicit asserts and comment fix (thanks Rillig)
 1.37 24-Aug-2025  christos D3 constant changed
 1.36 31-May-2022  mrg allow ACPI to compile without PCI support. fixes ia64 build.
 1.35 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.34 25-Feb-2014  pooka branches: 1.34.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.33 02-Jun-2012  dsl branches: 1.33.2; 1.33.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.32 21-Jun-2011  jruoho branches: 1.32.2;
Rename acpi_get_node() to acpi_match_node() for consistency.
 1.31 22-May-2011  joerg branches: 1.31.2;
Let's not be silly. Use a fancy "if else" to decide behavior of a bool
and hope cosmic radition doesn't create a third state.
 1.30 14-Apr-2011  jruoho Simplify by using a static array for the reference counting.
 1.29 09-Jan-2011  jruoho branches: 1.29.2;
Convert aprint_error(9) to ACPI_DEBUG_PRINT.
 1.28 09-Jan-2011  jruoho Remove also rest of the ACPI_DEVICE_POWER checks.
 1.27 09-Jan-2011  jruoho We use config_defer(9) now when scanning power resource and wake-up
capabilities, so do not fail in acpi_power_register() if ACPI_DEVICE_POWER is
not set in struct acpi_devnode::ad_flags.
 1.26 06-Jan-2011  jruoho Fix a comment.
 1.25 02-Jan-2011  jruoho Adjust error messages for the previous commit.
 1.24 02-Jan-2011  jruoho Use "real" device names for the hw.acpi.wake and hw.acpi.power sysctl(8)
trees. For instance, instead of hw.acpi.wake.DURT, we have hw.acpi.wake.wm0
for wm(4). This is a temporary solution, but without solving the big
abstraction questions, this is the best we can do.
 1.23 08-Oct-2010  gsutre Store sysctl MIBs instead of a pointer to the root of the sysctl
sub-tree (because the pointer may be invalid at the time we use it).

ok jruoho@
 1.22 06-Aug-2010  jruoho branches: 1.22.2;
Fix prototypes; SYSCTLFN_ARGS -> SYSCTLFN_PROTO.
(These things really only obscure the code.)
 1.21 01-Jul-2010  jruoho Fix a carelessness bug introduced in the revision 1.17; acpi_power_get() now
takes a handle instead of node as a parameter. (The compiler did not catch
this as ACPI_HANDLE is a pointer to void.)
 1.20 08-Jun-2010  jruoho Only check the parent's power state if the parent has power management
capabilities. Based on a short DSDT survey, not all systems adhere to the
model noted in the comment.
 1.19 08-Jun-2010  jruoho Fix a comment and some debug printing.
 1.18 08-Jun-2010  jruoho Error out if we try to set power to a higher-power state than the parent's
state. This follows the "bus power state" -logic noted in the spec:

bus: D1
device A : D1 -> D0 -> error
device B : D1 -> D2 -> success

-> bus must remain in D1 due device A

Following this scheme, it is easy to derive the "bus power state" now that
we have the device nodes in a tree-like structure. If required, separate
acpi_power_get_bus() and acpi_power_set_bus() can be added in the future.
 1.17 07-Jun-2010  jruoho Now that we have 1:1 mapping between handles and nodes, use the former for
all power resource operations. Eliminates the wrapper functions.
 1.16 07-Jun-2010  jruoho Refactor slightly: we need to expose the function that turns individual
power resource on or off.
 1.15 07-Jun-2010  jruoho Build the power resource queue dynamically. This eliminates the need to call
acpi_power_res_add() in the main scan function, also saving few bytes of
memory.
 1.14 05-Jun-2010  jruoho Convert an aprint_error_dev() to ACPI_DEBUG_PRINT in acpi_power_set().

This "fixes" the issue observed by dyoung@. Since the AML may not keep any
state by itself, it is possible that the firmware tries to continuously put
a device into a power state where the device already is (e.g. D3 -> D3).

XXX: The code (like the old power resource code) rests on the assumption
that it is possible to reliably obtain the power state of a device
either directly via _PSC or indirectly via _STA. However, because there
is some evidence that few broken systems implement these methods
incorrectly (e.g. always returns D0 as a constant, even if the state
would be D3 in reality), we may need to revisit this by always setting
the power state, even if it is impossible to get the power state.
 1.13 31-May-2010  jruoho Silently return if a power state transition is requested for a device that
has no support for it. For example, in Kurt Schreiner's Shuttle G61:

Device (FAN)
{
Name (_HID, EisaId ("PNP0C0B"))
Method (_INI, 0, NotSerialized)
{
Store (TP1H, CTOS)
Store (TP1L, CTHY)
}
}

Obviously acpitz(4) has little use for a device that only contains _INI.
(The handle of this device is referenced incorrectly in _AL0.)
 1.12 12-May-2010  jruoho branches: 1.12.2;
Initial pass for issues observed by dyoung@ on HP Pavilion N3270. In this
laptop there is a PNP0C0B ("ACPI fan") with the following properties:

_PSC : Power state for D3 (alone).
_PR0 : Power resources for D0.
_PSx : Power state switch for D0 and D3.

Thus, it is impossible to get or set the D3 power state via power resources
alone; there is only a single PowerResource() and it is for D0.

To tackle this:

1. Evaluate the direct _PSC control method if and only if there is no
given _PRx. The order is important; it is known that some other
systems implement the _PSC method (like _STA) incorrectly.

2. If no _PRx is available (and thus no _ON or _OFF), do not error out.
Instead, if we have AE_NOT_FOUND, continue to evaluate the power state
switch method, _PSx, which (on this laptop) should alone suffice for
the D0 -> D3 transition.
 1.11 27-Apr-2010  jruoho branches: 1.11.2;
Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.
 1.10 26-Apr-2010  jruoho Fix typo. Doh.
 1.9 26-Apr-2010  jruoho AE_CTRL_TERMINATE -> AE_CTRL_FALSE.
 1.8 24-Apr-2010  jruoho Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it).
 1.7 24-Apr-2010  jruoho Add utility function acpi_get_node().

This retrieves a struct acpi_devnode from a handle. Since this requires
accessing the global softc, it is better to do it in one place alone. The
same goes for possible locking of the node-queue; it is better not to
publicize such a lock for generic device drivers.
 1.6 24-Apr-2010  jruoho Now that we are able to remove references to power resources, provide a
detachment routine for acpitz(4). Add comments explaining the relationship
between power resources and active cooling. Also some improvements to code
readability.
 1.5 23-Apr-2010  jruoho Forgot that the firmware may change the power state behind our back,
so actively query the state when the sysctl(8) is invoked.
 1.4 23-Apr-2010  jruoho Add hw.acpi.power sysctl-node.
 1.3 23-Apr-2010  jruoho Cosmetics: be pedantic and use AE_CTRL_TERMINATE instead of AE_ABORT_METHOD
as a condition to break out of a loop.
 1.2 23-Apr-2010  jruoho When setting the power, always mark the state as invalid on failure, even if
going to D0. Also fix a potential NULL pointer dereference in an aprint_().
 1.1 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.11.2.4 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.1 27-Apr-2010  uebayasi file acpi_power.c was added on branch uebayasi-xip on 2010-04-30 14:43:05 +0000
 1.12.2.6 31-May-2011  rmind sync with head
 1.12.2.5 21-Apr-2011  rmind sync with head
 1.12.2.4 05-Mar-2011  rmind sync with head
 1.12.2.3 03-Jul-2010  rmind sync with head
 1.12.2.2 30-May-2010  rmind sync with head
 1.12.2.1 12-May-2010  rmind file acpi_power.c was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.22.2.2 11-Aug-2010  yamt sync with head.
 1.22.2.1 06-Aug-2010  yamt file acpi_power.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.29.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.31.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.32.2.2 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.32.2.1 30-Oct-2012  yamt sync with head
 1.33.4.1 18-May-2014  rmind sync with head
 1.33.2.2 03-Dec-2017  jdolecek update from HEAD
 1.33.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.6.1 28-Aug-2017  skrll Sync with HEAD
 1.6 07-Jun-2010  jruoho branches: 1.6.2;
Now that we have 1:1 mapping between handles and nodes, use the former for
all power resource operations. Eliminates the wrapper functions.
 1.5 07-Jun-2010  jruoho Refactor slightly: we need to expose the function that turns individual
power resource on or off.
 1.4 07-Jun-2010  jruoho Build the power resource queue dynamically. This eliminates the need to call
acpi_power_res_add() in the main scan function, also saving few bytes of
memory.
 1.3 24-Apr-2010  jruoho branches: 1.3.2; 1.3.4;
Now that we are able to remove references to power resources, provide a
detachment routine for acpitz(4). Add comments explaining the relationship
between power resources and active cooling. Also some improvements to code
readability.
 1.2 23-Apr-2010  jruoho Add hw.acpi.power sysctl-node.
 1.1 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.3.4.3 03-Jul-2010  rmind sync with head
 1.3.4.2 30-May-2010  rmind sync with head
 1.3.4.1 24-Apr-2010  rmind file acpi_power.h was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.3.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.1 24-Apr-2010  uebayasi file acpi_power.h was added on branch uebayasi-xip on 2010-04-30 14:43:05 +0000
 1.6.2.2 11-Aug-2010  yamt sync with head.
 1.6.2.1 07-Jun-2010  yamt file acpi_power.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.13 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.12 10-Apr-2010  jruoho Remove unnecessary casts.
 1.11 05-Mar-2010  jruoho branches: 1.11.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.10 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.9 18-Jan-2010  jruoho branches: 1.9.2;
Use acpi_eval_reference_handle() to simplify code. No functional change.

ok jmcneill@, pgoyette@
 1.8 05-Jan-2010  jruoho Use acpi_eval_struct() to simplify code.

ok pgoyette@, jmcneill@
 1.7 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.6 14-Apr-2008  jmcneill branches: 1.6.4;
Compatibility with ACPICA 20080321; from the release notes:

All Reference Objects returned via the AcpiEvaluateObject interface are now
marked as type "REFERENCE" instead of "ANY". The type ANY is now reserved for
NULL objects - either NULL package elements or unresolved named references.
 1.5 15-Dec-2007  perry branches: 1.5.6;
__FUNCTION__ -> __func__
 1.4 16-Feb-2006  kochi branches: 1.4.40; 1.4.50; 1.4.54;
prototypes don't need argument names
 1.3 11-Dec-2005  christos branches: 1.3.2; 1.3.4; 1.3.6;
merge ktrace-lwp.
 1.2 29-May-2005  christos branches: 1.2.2;
Sprinkle const freely and delete unnecessary casts.
 1.1 26-May-2004  kochi branches: 1.1.2;
ThermalZone improvement work by lha at stacken.kth.se, inspired from
FreeBSD thermal zone code. Minor style fixes and bugfixes by me.
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 26-May-2004  skrll file acpi_powerres.c was added on branch ktrace-lwp on 2004-08-03 10:45:03 +0000
 1.2.2.2 21-Jan-2008  yamt sync with head
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.1 18-Feb-2006  yamt sync with head.
 1.4.54.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.50.1 26-Dec-2007  ad Sync with head.
 1.4.40.1 09-Jan-2008  matt sync with HEAD
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.4.2 11-Aug-2010  yamt sync with head.
 1.6.4.1 11-Mar-2010  yamt sync with head
 1.9.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.1 30-May-2010  rmind sync with head
 1.22 06-Dec-2020  jmcneill acpi: remove unused acpi_quirks_osi_* functions
 1.21 04-May-2020  jdolecek branches: 1.21.2;
constify
 1.20 14-Nov-2011  jmcneill add a machdep.dmi sysctl tree with the following read-only keys:
system-vendor, system-product, system-version, system-serial, system-uuid
bios-vendor, bios-version
board-vendor, board-product, board-version, board-serial
the *-serial and *-uuid keys are marked with CTLFLAG_PRIVATE

a few of the pmf platform key names changed so update callers to match
 1.19 20-Feb-2011  jruoho branches: 1.19.4;
Add quirk support for _OSI strings introduced in ACPICA 20110211. While
here, clean up acpi_probe() and the quirk code. Remove #ifdef ACPI_DEBUGGER.
 1.18 06-Sep-2010  jmcneill branches: 1.18.2; 1.18.4;
Add support for blacklisting ACPI BIOS implementations by year. By default,
don't use ACPI on BIOS which advertise release years <= 2000. This
can be changed by setting option ACPI_BLACKLIST_YEAR=0 or by setting
acpi_force_load=1.
 1.17 06-Sep-2010  jakllsch Remove quirk added in rev 1.14. Even after the change of 1.16, it
still matches more boards that just the one with the problem.

Interrupts from the SATA controllers on my MSI K8N Neo3 boards
(which both versions of this quirk matched) are broken when ACPI
is disabled. My board does not exhibit AE_AML_INFINITE_LOOP
problems.

If we want to avoid manually specifying RB_MD2 in boothowto on
pgoyette@'s board, we're going to have to find another way; perhaps
with the DMI strings available from pmf(9).

Anyhow, some boards needing RB_MD2 during boot(8) is in my opinion
better than others needing to set acpi_force_load in ddb or gdb.
 1.16 04-Sep-2010  jruoho Use FADT instead of DSDT in the quirk added in the revision 1.14.
 1.15 27-Jul-2010  pgoyette Use __arraycount(). No functional change.
 1.14 27-Jul-2010  jruoho Add a quirk for pgoyette@'s old (ACPI 1.0) NVIDIA board.

It was analyzed that this DSDT busy-loops some unknown PCI memory regions in
several places. Because the regions are apparently almost constant, this
causes several conditions where the interpreter might enter into an infinite
loop. Luckily ACPICA detects this and rightly spams AE_AML_INFINITE_LOOP
warnings.

Not much we can do. Declare as broken beyond repair. Set acpi_force_load=1
to use ACPI or use a custom DSDT.
 1.13 28-Apr-2010  jruoho Add ASUS CUV4X-D. From Pierre Pronchery in PR #41351.
 1.12 12-Apr-2010  jruoho Remove some unused and global variables. Make the code more readable. Deny
invalid writes to machdep.sleep_state. Cosmetics. No functional change.
 1.11 05-Mar-2010  jruoho branches: 1.11.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.10 25-Jan-2009  christos branches: 1.10.4;
PR/40471: Pierre Pronchery: ASUS CUR-DLS board found on HP NetServer E800 box
has broken ACPI BIOS. Disable it.
 1.9 09-Dec-2007  jmcneill branches: 1.9.14; 1.9.22; 1.9.24;
Merge jmcneill-pm branch.
 1.8 23-Sep-2006  fvdl branches: 1.8.22; 1.8.24; 1.8.34; 1.8.36;
Define the "broken IRQ0 override" quirk, and add it for one type of ACPI
BIOS.
 1.7 04-Jul-2006  christos branches: 1.7.4; 1.7.6;
Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8; 1.6.16;
merge ktrace-lwp.
 1.5 10-Apr-2004  kochi branches: 1.5.12;
whitespace nit
 1.4 24-Mar-2004  kochi Don't include unnecessary header (acpi_osd.h)
 1.3 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.2 02-Oct-2003  christos Add a Quirk for my Appro, where it does not find all its busses in ACPI
 1.1 15-May-2003  fvdl branches: 1.1.2;
Add quirk handling to ACPI. First quirk entry is "PTLTD " rev 0x06040000,
which gives problems with PCI bus finding; the object hierarchy doesn't
match the real world for some systems, most notably SuperMicro boards.
Linux has this one blacklisted as well.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.12.2 21-Jan-2008  yamt sync with head
 1.5.12.1 30-Dec-2006  yamt sync with head.
 1.6.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.8.1 11-Aug-2006  yamt sync with head
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.6.1 22-Oct-2006  yamt sync with head
 1.7.4.1 18-Nov-2006  ad Sync with head.
 1.8.36.1 11-Dec-2007  yamt sync with head.
 1.8.34.1 26-Dec-2007  ad Sync with head.
 1.8.24.1 09-Jan-2008  matt sync with HEAD
 1.8.22.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.9.24.1 24-Feb-2009  snj Pull up following revision(s) (requested by christos in ticket #476):
sys/dev/acpi/acpi_quirks.c: revision 1.10
PR/40471: Pierre Pronchery: ASUS CUR-DLS board found on HP NetServer E800 box
has broken ACPI BIOS. Disable it.
 1.9.22.1 03-Mar-2009  skrll Sync with HEAD.
 1.9.14.4 09-Oct-2010  yamt sync with head
 1.9.14.3 11-Aug-2010  yamt sync with head.
 1.9.14.2 11-Mar-2010  yamt sync with head
 1.9.14.1 04-May-2009  yamt sync with head.
 1.10.4.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.2 05-Mar-2011  rmind sync with head
 1.11.2.1 30-May-2010  rmind sync with head
 1.18.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.1 17-Apr-2012  yamt sync with head
 1.21.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.44 02-Jan-2025  andvar acpi(4): validate IO/FixedIO resource base address and length.

Ensure that the base address and length of an IO/FixedIO resource reported by
ACPI do not exceed a 16-bit value plus one (to account for the length).
If an ACPI resource reports a base address of 0xFFFF, it likely indicates that
the device is inoperable or invalid for some reason.

This can cause a kernel with DIAGNOSTIC enabled to panic with the error:
extent_alloc_region: region lies outside extent, even on an otherwise fully
functional system.

In my case, the mpu(4) driver reported a 0xFFFF base address, likely due to
a missing MIDI port or the absence of an actual MIDI UART device,
despite the device being defined as an ACPI resource.

Since this issue affects only DIAGNOSTIC enabled kernels and appears to be rare
(likely caused by a buggy BIOS), I believe that pullups are unnecessary.

lgtm jmcneill
 1.43 30-Jun-2024  jmcneill acpi: Ignore producer/consumer bit for fixed memory resources.

The requirement to honour the producer/consumer bit in fixed memory
resource descriptors was dropped at some point in a revision to the ACPI
2.0 specification because too many firmware implementations got it wrong.
 1.42 07-Aug-2021  jmcneill branches: 1.42.6; 1.42.12;
acpi: Add acpi_resource_parse_any().

Like acpi_resource_parse(), but doesn't exclude "produced" resources.
 1.41 31-Dec-2019  jmcneill Rely on 32/64-bit overflow to calculate translation offsets. Store this
as a separate ar_xbase field in acpi_mem instead of having separate
ar_offset and ar_decode fields.
 1.40 31-Dec-2019  jmcneill Include device decoding type in acpi_mem resources
 1.39 31-Dec-2019  jmcneill Fetch bus_dma tags when acpi devnodes are created. They do not change
and this allows MD code to create more complex tags without being
concerned with the tag being destroyed later. While here, capture
translations offsets for address32/address64 resources.
 1.38 25-Oct-2018  jmcneill Add support for 64-bit memory resources.
 1.37 27-Jul-2015  msaitoh branches: 1.37.16; 1.37.18;
Add ACPI_RESOURCE_TYPE_END_TAG and ACPI_RESOURCE_TYPE_ADDRESS64.
 1.36 13-Apr-2015  christos sync with new acpica struct shuffling.
 1.35 30-Jun-2011  wiz branches: 1.35.12; 1.35.30;
dependant -> dependent
 1.34 15-Jun-2011  jruoho Do not entirely bypass the printfs during resource parsing, as many drivers
rely on those for their autoconf(9) messages. Instead add a "quiet" option.
 1.33 15-Jun-2011  jruoho Remove printouts that mess with the autoconf(9).
 1.32 05-Mar-2010  jruoho branches: 1.32.8;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.31 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.30 16-Sep-2009  mlelstv branches: 1.30.2;
Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.29 13-Jul-2009  kiyohara ACPI resource supports Extended IRQ From FreeBSD.
 1.28 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.27 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.26 07-Apr-2008  jmcneill branches: 1.26.4; 1.26.12; 1.26.14; 1.26.18; 1.26.22;
Cosmetic aprintification fix, as noted by Thomas Klausner on current-users
 1.25 05-Apr-2008  cegger use aprint_*_dev and device_xname
 1.24 15-Dec-2007  perry branches: 1.24.6;
__FUNCTION__ -> __func__
 1.23 01-Dec-2007  jmcneill branches: 1.23.2; 1.23.6;
aprintify
 1.22 28-Sep-2007  njoly branches: 1.22.4;
Add ACPI address32 resource type support (DWord Address Space
Descriptor), for fixed size io and mem.

Fix hpet@acpi attachement on Dell Poweredge 860.
Tested by Wouter Schoot, thanks.

While here:
- Update some indentation
- Correct function check
- Add missing break
- Update wrong debug message

Reviewed by cube.
 1.21 16-Nov-2006  christos branches: 1.21.8; 1.21.22; 1.21.24; 1.21.26;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 29-Jan-2006  kochi branches: 1.19.18; 1.19.20;
adapt for ACPI-CA 20060113
 1.18 11-Dec-2005  christos branches: 1.18.2;
merge ktrace-lwp.
 1.17 29-May-2005  christos branches: 1.17.2;
Sprinkle const freely and delete unnecessary casts.
 1.16 27-Feb-2005  perry nuke trailing whitespace
 1.15 12-Apr-2004  kochi branches: 1.15.4; 1.15.6;
fix compilation when ACPI_DEBUG is not set.
pointed out by Sverre Froyen.
 1.14 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.13 11-Apr-2004  kochi + add prototype
+ designated initializers
+ call callback functions only when defined
 1.12 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.11 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.10 10-Apr-2004  kochi whitespace nit
 1.9 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.8 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.7 02-Nov-2003  jdolecek acpi_res_parse_ioport(): if the added entry is next to a previous I/O port
entry, just expand the previous entry instead of adding separate mapping

apparently some BIOSes make separate I/O port entries like this, and
some drivers then fail to attach; this change fixes mappings like

fdc0: io 0x3f2-0x3f3,0x3f4-0x3f5,0x3f7 irq 6 drq 2

to

fdc0: io 0x3f2-0x3f5,0x3f7 irq 6 drq 2

change tested by Bernd Ernesti
 1.6 05-Mar-2003  christos branches: 1.6.2;
use M_ACPI where appropriate.
 1.5 28-Dec-2002  matt Make sure we record the type of irq as well as its number.
 1.4 15-Jun-2002  thorpej Update for acpica-unix-20020612. From Takayoshi Kochi.
 1.3 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.2 13-Nov-2001  lukem branches: 1.2.2; 1.2.10;
add RCSID
 1.1 29-Sep-2001  thorpej branches: 1.1.2; 1.1.4;
Add code to parse ACPI bus resources.
 1.1.4.5 29-Dec-2002  thorpej Sync with HEAD.
 1.1.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 29-Sep-2001  nathanw file acpi_resource.c was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 29-Sep-2001  fvdl file acpi_resource.c was added on branch thorpej-devvp on 2001-10-01 12:44:16 +0000
 1.2.10.1 20-Jun-2002  gehenna catch up with -current.
 1.2.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 13-Nov-2001  thorpej file acpi_resource.c was added on branch kqueue on 2002-01-10 19:52:53 +0000
 1.6.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.4.1 29-Apr-2005  kent sync with -current
 1.17.2.5 21-Jan-2008  yamt sync with head
 1.17.2.4 07-Dec-2007  yamt sync with head
 1.17.2.3 27-Oct-2007  yamt sync with head.
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 01-Feb-2006  yamt sync with head.
 1.19.20.2 10-Dec-2006  yamt sync with head.
 1.19.20.1 22-Oct-2006  yamt sync with head
 1.19.18.1 18-Nov-2006  ad Sync with head.
 1.21.26.1 06-Oct-2007  yamt sync with head.
 1.21.24.2 09-Jan-2008  matt sync with HEAD
 1.21.24.1 06-Nov-2007  matt sync with HEAD
 1.21.22.2 01-Dec-2007  jmcneill Sync with HEAD.
 1.21.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.21.8.1 09-Oct-2007  ad Sync with head.
 1.22.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.22.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.23.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.24.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.22.1 21-Apr-2010  matt sync to netbsd-5
 1.26.18.2 23-Jul-2009  jym Sync with HEAD.
 1.26.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.26.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.26.4.4 11-Mar-2010  yamt sync with head
 1.26.4.3 18-Jul-2009  yamt sync with head.
 1.26.4.2 16-May-2009  yamt sync with head
 1.26.4.1 04-May-2009  yamt sync with head.
 1.30.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.35.30.2 22-Sep-2015  skrll Sync with HEAD
 1.35.30.1 06-Jun-2015  skrll Sync with HEAD
 1.35.12.1 03-Dec-2017  jdolecek update from HEAD
 1.37.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.37.18.1 10-Jun-2019  christos Sync with HEAD
 1.37.16.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.42.12.2 02-Aug-2025  perseant Sync with HEAD
 1.42.12.1 01-Jul-2024  perseant Sync with HEAD.
 1.42.6.1 03-Jul-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #735):

sys/dev/pci/pci_resource.c: revision 1.5
sys/arch/arm/pci/pci_msi_machdep.c: revision 1.10
sys/arch/aarch64/include/vmparam.h: revision 1.21
sys/dev/acpi/acpi_resource.c: revision 1.43

pci_resource: Make unexpected bus numbers in bridges non-fatal.

Firmware bugs happen. Log a warning and continue instead of panicing.
acpi: Ignore producer/consumer bit for fixed memory resources.

The requirement to honour the producer/consumer bit in fixed memory
resource descriptors was dropped at some point in a revision to the ACPI
2.0 specification because too many firmware implementations got it wrong.

aarch64: Bump VM_PHYSSEG_MAX to match DRAM_BANKS / FDT_MEMORY_RANGES.

On aarch64 there is a single free list, so VM_PHYSSEG_MAX needs to be
the same as FDT_MEMORY_RANGES (which needs to be the same as DRAM_BANKS).

Future cleanup should be done to fold these into a single define.

arm: pci: Fix ITS ID lookup for MSIs.
pci_get_frameid expects a BDF requestor ID as input, not a Device ID.

Fixes MSI/MSI-X support on Ampere Altra systems.
 1.3 05-Mar-2010  jruoho branches: 1.3.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 25-Nov-2009  cegger Add ACPI SLIT parser. This is part of NUMA support.
Tested on a 8-node machine.

Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 05-Mar-2010  yamt file acpi_slit.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.3 05-Mar-2010  jruoho branches: 1.3.2;
Protect all header files against multiple inclusions.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 25-Nov-2009  cegger Add ACPI SLIT parser. This is part of NUMA support.
Tested on a 8-node machine.

Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 05-Mar-2010  yamt file acpi_slit.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.9 30-Jun-2024  jmcneill acpi: Parse GICC SRAT entries.
 1.8 27-Dec-2019  ad branches: 1.8.32;
Redo the page allocator to perform better, especially on multi-core and
multi-socket systems. Proposed on tech-kern. While here:

- add rudimentary NUMA support - needs more work.
- remove now unused "listq" from vm_page.
 1.7 22-Dec-2019  ad Avoid doing zero sized allocations if we get bad data.
 1.6 01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.5 28-Dec-2017  maxv branches: 1.5.4;
Style, export struct acpisrat_node, and add acpisrat_get_node.
 1.4 31-Aug-2017  msaitoh If _ENABLED flag of ACPI_SRAT_TYPE_CPU_AFFINITY, ACPI_SRAT_TYPE_MEMORY_AFFINITY
or ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY isn't set, don't use the table.
 1.3 05-Mar-2010  jruoho branches: 1.3.2; 1.3.22;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 25-Nov-2009  cegger Add ACPI SRAT parser. This is a part of NUMA support.
Tested on 1-node, 2-node and 8-node machines.
Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.22.1 03-Dec-2017  jdolecek update from HEAD
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 05-Mar-2010  yamt file acpi_srat.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.5.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.32.1 01-Jul-2024  perseant Sync with HEAD.
 1.5 27-Dec-2019  ad Redo the page allocator to perform better, especially on multi-core and
multi-socket systems. Proposed on tech-kern. While here:

- add rudimentary NUMA support - needs more work.
- remove now unused "listq" from vm_page.
 1.4 28-Dec-2017  maxv branches: 1.4.4;
Style, export struct acpisrat_node, and add acpisrat_get_node.
 1.3 05-Mar-2010  jruoho branches: 1.3.2;
Protect all header files against multiple inclusions.
 1.2 04-Dec-2009  njoly branches: 1.2.2;
Fix NetBSD keyword expansion.
 1.1 25-Nov-2009  cegger Add ACPI SRAT parser. This is a part of NUMA support.
Tested on 1-node, 2-node and 8-node machines.
Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 05-Mar-2010  yamt file acpi_srat.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:22 +0000
 1.4.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.27 25-Jul-2021  jmcneill acpi_timer: use ACPI-Fast if WAET timer one read flag is set

The Windows ACPI Emulated Devices Table (WAET) has a hint to inform the OS
that a single read of the PM timer is reliable. Honour this flag.
 1.26 29-May-2020  rin branches: 1.26.6;
For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.25 16-Oct-2018  jmcneill Rename options ACPI_REDUCED_HARDWARE to ACPI_REDUCED_HW. The former is
a boolean in the acpica build, so use the latter to select the correct
value.
 1.24 16-Oct-2018  jmcneill Add ACPI_REDUCED_HARDWARE defflag (used by ACPICA) and fix acpi build with this option set.
 1.23 15-Oct-2018  jmcneill Do not attach a timecounter when PM_TMR_LEN is 0. According to ACPI 6.2
section 5.2.9 ("Fixed ACPI Description Table (FADT)"), a value of zero
here means that the PM timer is not supported.
 1.22 27-Dec-2013  christos branches: 1.22.28; 1.22.30;
constant changed name
 1.21 08-Aug-2011  jmcneill branches: 1.21.2; 1.21.12; 1.21.16;
The absence of USE_PLATFORM_CLOCK does not imply that the PM Timer is
unreliable; in fact, the PM Timer has to be reliable by definition! Remove
the incorrect warning message that was added in r1.19
 1.20 04-Jan-2011  jruoho Fix previous.
 1.19 02-Jan-2011  jruoho Print a warning if the BIOS thinks that the timer is unreliable. However, do
not touch the quality of the timecounter(9) based on this information.
 1.18 10-Jul-2010  jruoho Export also the delta function.
 1.17 10-Jul-2010  jruoho Export the wrapper functions that read from the ACPI PM timer.
Needed for ACPI CPUs. Also KNF, cosmetics. No functional change.
 1.16 05-Mar-2010  jruoho branches: 1.16.2;
Add missing license.

ok drochner@
 1.15 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.14 08-Apr-2009  dyoung branches: 1.14.2;
Add acpitimer_detach() to eventually support acpi(4) detachment.
 1.13 15-Mar-2009  cegger ansify function definitions
 1.12 14-Mar-2009  jmcneill Don't assume ACPI == x86, from kiyohara@kk.iij4u.or.jp
 1.11 11-May-2008  ad branches: 1.11.6; 1.11.12;
Noisy printf.
 1.10 20-Jan-2008  joerg branches: 1.10.6; 1.10.8; 1.10.10; 1.10.12;
Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.9 26-Sep-2007  ad branches: 1.9.4; 1.9.10;
x86 changes for pcc and LKMs.

- Replace most inline assembly with proper functions. As a side effect
this reduces the size of amd64 GENERIC by about 120kB, and i386 by a
smaller amount. Nearly all of the inlines did something slow, or something
that does not need to be fast.
- Make curcpu() and curlwp functions proper, unless __GNUC__ && _KERNEL.
In that case make them inlines. Makes curlwp LKM and preemption safe.
- Make bus_space and bus_dma more LKM friendly.
- Share a few more files between the ports.
- Other minor changes.
 1.8 16-Nov-2006  christos branches: 1.8.4; 1.8.10; 1.8.24; 1.8.26; 1.8.28;
__unused removal on arguments; approved by core.
 1.7 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.6 27-Aug-2006  christos branches: 1.6.2; 1.6.4; 1.6.6;
Complete the declaration.
 1.5 02-Jul-2006  bouyer branches: 1.5.2;
Move acpi_timer.h outside of __HAVE_TIMECOUNTER, as we need acpitimer_init()
for the non-timecounter case too.
 1.4 30-Jun-2006  xtraeme Add __KERNEL_RCSID().
 1.3 30-Jun-2006  xtraeme Remove a debug printf.
 1.2 26-Jun-2006  drochner branches: 1.2.2;
test the PM timer for glitches (using the algorithm from FreeBSD)
and use a single read if the timer looks good,
patch from Juan RP, with minor simplification by me
 1.1 21-Jun-2006  drochner First cut on an implementation of an ACPI power management counter
backend for timecounters.
Due to known bugs in some chipsets, always read until we get 3 successive
samples which are monotonic, as FreeBSD does in its "safe" variant.
This can be refined later, either by chipset quirks or by a test (as
FreeBSD does).
 1.2.2.4 03-Sep-2006  yamt sync with head.
 1.2.2.3 11-Aug-2006  yamt sync with head
 1.2.2.2 26-Jun-2006  yamt sync with head.
 1.2.2.1 26-Jun-2006  yamt file acpi_timer.c was added on branch yamt-pdpolicy on 2006-06-26 12:50:37 +0000
 1.5.2.2 13-Jul-2006  gdamore Merge from HEAD.
 1.5.2.1 02-Jul-2006  gdamore file acpi_timer.c was added on branch gdamore-uart on 2006-07-13 17:49:17 +0000
 1.6.6.2 10-Dec-2006  yamt sync with head.
 1.6.6.1 22-Oct-2006  yamt sync with head
 1.6.4.2 09-Sep-2006  rpaulo sync with head
 1.6.4.1 27-Aug-2006  rpaulo file acpi_timer.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.6.2.1 18-Nov-2006  ad Sync with head.
 1.8.28.1 06-Oct-2007  yamt sync with head.
 1.8.26.2 23-Mar-2008  matt sync with HEAD
 1.8.26.1 06-Nov-2007  matt sync with HEAD
 1.8.24.1 02-Oct-2007  joerg Sync with HEAD.
 1.8.10.1 09-Oct-2007  ad Sync with head.
 1.8.4.4 21-Jan-2008  yamt sync with head
 1.8.4.3 27-Oct-2007  yamt sync with head.
 1.8.4.2 30-Dec-2006  yamt sync with head.
 1.8.4.1 16-Nov-2006  yamt file acpi_timer.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:54 +0000
 1.9.10.1 23-Jan-2008  bouyer Sync with HEAD.
 1.9.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.10.4 11-Aug-2010  yamt sync with head.
 1.10.10.3 11-Mar-2010  yamt sync with head
 1.10.10.2 04-May-2009  yamt sync with head.
 1.10.10.1 16-May-2008  yamt sync with head.
 1.10.8.1 18-May-2008  yamt sync with head.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.14.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.1 05-Mar-2011  rmind sync with head
 1.21.16.1 18-May-2014  rmind sync with head
 1.21.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 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.22.30.1 10-Jun-2019  christos Sync with HEAD
 1.22.28.1 20-Oct-2018  pgoyette Sync with head
 1.26.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.6 10-Jul-2010  jruoho Export also the delta function.
 1.5 10-Jul-2010  jruoho Export the wrapper functions that read from the ACPI PM timer.
Needed for ACPI CPUs. Also KNF, cosmetics. No functional change.
 1.4 05-Mar-2010  jruoho branches: 1.4.2;
Add missing license.

ok drochner@
 1.3 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.2 08-Apr-2009  dyoung branches: 1.2.2;
Add acpitimer_detach() to eventually support acpi(4) detachment.
 1.1 21-Jun-2006  drochner branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.66; 1.1.76; 1.1.82;
First cut on an implementation of an ACPI power management counter
backend for timecounters.
Due to known bugs in some chipsets, always read until we get 3 successive
samples which are monotonic, as FreeBSD does in its "safe" variant.
This can be refined later, either by chipset quirks or by a test (as
FreeBSD does).
 1.1.82.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.76.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.66.3 11-Aug-2010  yamt sync with head.
 1.1.66.2 11-Mar-2010  yamt sync with head
 1.1.66.1 04-May-2009  yamt sync with head.
 1.1.16.2 30-Dec-2006  yamt sync with head.
 1.1.16.1 21-Jun-2006  yamt file acpi_timer.h was added on branch yamt-lazymbuf on 2006-12-30 20:47:54 +0000
 1.1.10.2 09-Sep-2006  rpaulo sync with head
 1.1.10.1 21-Jun-2006  rpaulo file acpi_timer.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.4.2 13-Jul-2006  gdamore Merge from HEAD.
 1.1.4.1 21-Jun-2006  gdamore file acpi_timer.h was added on branch gdamore-uart on 2006-07-13 17:49:17 +0000
 1.1.2.2 26-Jun-2006  yamt sync with head.
 1.1.2.1 21-Jun-2006  yamt file acpi_timer.h was added on branch yamt-pdpolicy on 2006-06-26 12:50:37 +0000
 1.2.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.2.1 05-Mar-2011  rmind sync with head
 1.91 22-May-2022  andvar fix various small typos, mainly in comments.
 1.90 21-Apr-2019  mrg use cpu_name() on a struct cpu_info *. don't assume it has a ci_dev
member that is valid input to device_xname().

fixes build on arm64.
 1.89 01-Jun-2017  chs branches: 1.89.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.88 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.87 29-Jul-2012  pgoyette branches: 1.87.2; 1.87.16;
Replace local handling of entropy gathering with the new common code
recently introduced into sysmon_envsys(4).

Thanks to jruoho@ for testing.
 1.86 19-Jul-2012  christos Treat empty package returned from _AL<n> method the same as non-existent.
From jmcneill.
 1.85 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.84 02-Oct-2011  jmcneill branches: 1.84.2; 1.84.6;
_ACx is for active cooling policy, using it for envsys temp 'warn max' doesn't
make sense
 1.83 16-Jul-2011  jmcneill If there are CPUs associated with this thermal zone, use their names to
create the temperature sensor name:

[acpitz0]
cpu0 temperature: 53.000 105.000 41.800 degC
 1.82 20-Jun-2011  pgoyette Initialize sensors states before registering.
 1.81 20-Jun-2011  jruoho Use the new acpi_match_cpu_handle() from acpi_util.c.
 1.80 06-Jun-2011  pgoyette Don't set the FVALID_{MAX,MIN} flags since these values are not
min/max legal values. The values are alarms limits, and they're
already being tracked properly with the flag settings in *props
 1.79 16-Feb-2011  jruoho branches: 1.79.2;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.78 18-Jan-2011  jmcneill branches: 1.78.2;
If the thermal zone has a _PSL method, print a list of processors
associated with the zone at attach time.

acpitz0 at acpi0 (THM0)
acpitz0: levels: critical 127.0 C, passive cooling
acpitz1 at acpi0 (THM1): cpu0 cpu1
acpitz1: levels: critical 100.0 C, passive 95.5 C, passive cooling
 1.77 09-Jan-2011  jruoho branches: 1.77.2;
Use acpi_power_register() for consistency. No functional change.
 1.76 26-Oct-2010  jruoho Bump WARNS to 4.
 1.75 25-Oct-2010  jruoho Add support for module(9).
 1.74 07-Jun-2010  jruoho Now that we have 1:1 mapping between handles and nodes, use the former for
all power resource operations. Eliminates the wrapper functions.
 1.73 01-Jun-2010  plunky adjust autoconfig output: this item is part of a verbose line
 1.72 31-May-2010  plunky fix up autoconfig output
 1.71 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.70 24-Apr-2010  jruoho Remove retrieving the zone name via something called "REGN".

We really should not add code that aims to satisfy some oddball firmware,
not in the generic drivers that aim to comply with the specifications.
In the long-term this is even worse than quirk tables.
 1.69 24-Apr-2010  jruoho Some purely cosmetic editing in the name of readability: clean up the softc
and remove unused variables therein, remove unused constants, use
ACPI_DEBUG_PRINT, add more detailed comments, et cetera.
 1.68 24-Apr-2010  jruoho Now that we are able to remove references to power resources, provide a
detachment routine for acpitz(4). Add comments explaining the relationship
between power resources and active cooling. Also some improvements to code
readability.
 1.67 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.66 16-Apr-2010  christos fix dmesg printing.
 1.65 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.64 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.63 17-Mar-2010  jruoho Silence errors from the integer evaluations in case the objects are not found.
(This was too verbose even for ACPI_DEBUG.) Also fit the status messages to
one line during boot by using aprint_verbose() for extra information.
 1.62 14-Mar-2010  pgoyette branches: 1.62.2;
Remove setting of edata->monitor since that member no longer exists.
 1.61 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.60 05-Mar-2010  pgoyette As pointed out by Rhialto, "degrees Kelvin" is redundant. So fix a
couple of comments related to converstion between Kelvin and degC.
 1.59 18-Feb-2010  pgoyette Print correct temperature value, and properly display negative temperatures.

Resolves PR kern/36615
 1.58 14-Feb-2010  pgoyette Adapt to changes in sysmon's limit structure.
 1.57 01-Feb-2010  jruoho branches: 1.57.2;
Fix incorrect notify handler type (ACPI_SYSTEM_NOTIFY -> ACPI_DEVICE_NOTIFY).
 1.56 18-Jan-2010  jruoho Use acpi_eval_reference_handle() to simplify code. No functional change.

ok jmcneill@, pgoyette@
 1.55 18-Jan-2010  jruoho Fix a minor bug where a reference handle is used for error reporting even
though it may not be present. While here, convert few lines to aprint_*().

ok pgoyette@
 1.54 05-Jan-2010  jruoho Fix a memory leak/corruption by commenting out the evaluation of the _PSL
control method. If it is needed in the future, the output buffer must be
freed after use.

ok pgoyette@, jmcneill@
 1.53 01-Jan-2010  pgoyette Don't set sensor state to SWARNOVER here. Doing so based only on the
device's active cooling levels prevents the user from overriding these
limits with his own values.

XXX We should probably also change setting SCRITOVER state to SCRITICAL,
XXX but right now that just confuses things. We currently don't have a
XXX way for a sensor to be both SCRITICAL and SCRITOVER.
 1.52 24-Dec-2009  pgoyette In ATZ_F_VERBOSE mode, log a message whenever the active cooling level
changes, even when the new level is ATZ_ACTIVE_NONE
 1.51 23-Dec-2009  pgoyette Since we're using the active cooling levels as warning threshold, we
should store the value in the correct location. We're already setting
the correct flag bit.

Should resolve problem reported by Frank Wille on current-users...
 1.50 29-Nov-2009  uebayasi Remove a debug printf().
 1.49 25-Nov-2009  cegger By reading the ACPI dump I figured out that my
HP Pavillion dv9700 laptop features a fan sensor
in the ACPI Thermal Zone which is beyond of the ACPI
Spec.

envstat shows
[acpitz0]
Processor Thermal Zone: 56.000 95.000 degC
FAN: 2840 RPM

envstat -W shows the limits
[acpitz0]
Processor Thermal Zone: 55.000 degC
FAN: 2570 4500 2000 RPM

Patch presented on tech-kern@.

No comments.
 1.48 23-Nov-2009  cegger evaluate _RTV as preparation for passive cooling.
 1.47 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.46 25-Aug-2009  jmcneill PR# kern/41179: Incorrect return values from AcpiOsExecute()

ACPICA functions return ACPI_STATUS instead of int, so use it for
consistency.
 1.45 04-Jul-2009  pgoyette Use a macro to define the conversion between ACPI temperatures and those
used by sysmon_envsys(4).

No functional change.
 1.44 03-Jul-2009  pgoyette Remove an unused mutex. This was left-over from two years ago when
driver was updated to sysmon_envsys V2; a simple_lock was turned into
a mutex. But the only code that ever used the simple_lock was removed
so the mutex can also be removed.

Noticed by njoly@
 1.43 03-Jul-2009  pgoyette Properly convert ACPI zone values to uKelvins.

Patch from njoly@
 1.42 30-Jun-2009  pgoyette Change acpi_tz sensor behavior as follows:

1. ENVSYS_WARNOVER event is generated whenever any active cooling level
is exceeded.

2. ENVSYS_CRITOVER event is generated whenever _HOT limit is exceeded;
if the _HOT limit is not defined, then ENVSYS_CRITOVER will be
generated when the _CRT limit is exceeded.

3. For Passive Cooling Only mode, there will be no change in behavior.

Additionally, since there are specific actions taken at each of the Active
Cooling Levels (powering parts of a zone on or off), and the limits are not
user-programmable,

4. The {warn,crit}{min,max} threshold levels will be specified only
by the device itself; event reporting thresholds may not be set
from userland.

No comments received for two weeks after proposing these changes on both
current-users@ and tech-kern@
 1.41 03-Jun-2009  pgoyette Explicitly set sensor's units to ENVSYS_STEMP rather than having
it work only because ENVSYS_STEMP is #defined to 0
 1.40 01-Jun-2009  pgoyette Since we no longer have individual events for each sensor value limit,
we don't need individual flag bits. Clean up extra bit definitions.
Bump kernel version - welcome to 5.99.13
 1.39 09-Nov-2008  pgoyette branches: 1.39.4;
Leave the task of displaying sensor states to envsys_sysmon() unless we
are in debug mode.
 1.38 09-Nov-2008  pgoyette Temp sensor should report a critical-overtemp condition (ENVSYS_SCRITOVER)
not a simple critical (ENVSYS_SCRITICAL) condition.
 1.37 28-Jul-2008  jmcneill branches: 1.37.2; 1.37.4;
Clarify some printfs in error cases so we at least know what subsystem
reported them.
 1.36 14-Apr-2008  jmcneill branches: 1.36.4; 1.36.6; 1.36.8; 1.36.10;
Compatibility with ACPICA 20080321; from the release notes:

All Reference Objects returned via the AcpiEvaluateObject interface are now
marked as type "REFERENCE" instead of "ANY". The type ANY is now reserved for
NULL objects - either NULL package elements or unresolved named references.
 1.35 29-Mar-2008  jmcneill Fix printf in ACPI_DEBUG case, pointed out by mlelstv@
 1.34 26-Mar-2008  xtraeme acpitz_get_zone expects now a device_t not a softc.
 1.33 26-Mar-2008  xtraeme Split device_t/softc and related cosmetic changes.
 1.32 09-Dec-2007  jmcneill branches: 1.32.10;
Merge jmcneill-pm branch.
 1.31 08-Dec-2007  jmcneill branches: 1.31.2;
kern/37501: cosmetic error in acpi_tz probe messages
 1.30 05-Dec-2007  ad Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.29 02-Dec-2007  jmcneill branches: 1.29.2;
No need to waste more than one line of output at attach time.
 1.28 01-Dec-2007  jmcneill aprintify
 1.27 16-Nov-2007  xtraeme Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.26 02-Nov-2007  plunky branches: 1.26.2;
do not embed acpi device names in the sensor names
fake it in the compat code for the old envsys API
 1.25 18-Oct-2007  joerg Use callout_setfunc/callout_schedule.
 1.24 07-Oct-2007  xtraeme branches: 1.24.2;
Set the monitor value only once in the acpitz_init_envsys(),
not multiple times in the callout handler.
 1.23 09-Jul-2007  ad branches: 1.23.6; 1.23.8; 1.23.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.22 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.21 23-Jun-2007  jmcneill Don't complain if we can't evaluate _ALn.
 1.20 16-Nov-2006  christos branches: 1.20.8; 1.20.10;
__unused removal on arguments; approved by core.
 1.19 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18 20-Feb-2006  kochi branches: 1.18.14; 1.18.16;
use aprint_*
 1.17 11-Dec-2005  christos branches: 1.17.2; 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 29-May-2005  christos branches: 1.16.2;
Sprinkle const freely and delete unnecessary casts.
 1.15 02-May-2005  kochi Merge changes for ACPI-CA 20050408
 1.14 06-Jun-2004  martin In acpitz_get_zone only print verbose temperature thresholds when called
from acpitz_attach. This removes strange (and possibly scaring) messages
described in PR kern/25747.
 1.13 26-May-2004  kochi ThermalZone improvement work by lha at stacken.kth.se, inspired from
FreeBSD thermal zone code. Minor style fixes and bugfixes by me.
 1.12 16-May-2004  kochi Fix typo in variable name.
 1.11 01-May-2004  kochi specify static where appropriate.
 1.10 10-Apr-2004  kochi whitespace nit
 1.9 24-Mar-2004  martin Make it compile (int -> ACPI_INTEGER)
 1.8 02-Feb-2004  soren As pointed out by Dave Huang, revert back to using 273.15 rather than 273.16
when converting between kelvin and celsius.
 1.7 02-Feb-2004  soren Within the scope of the ACPI spec, K = C + 273.2; correct for it.
 1.6 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.5 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.4 31-Oct-2003  mycroft Whoops, forgot the /10 in the default case.
 1.3 31-Oct-2003  mycroft Print out the polling interval, and display a less confusing message if _TZP
is not defined.
 1.2 05-Jan-2003  jdolecek branches: 1.2.2; 1.2.4;
it's sufficient to install notify handler once
fix a typo in error printf in acpitz_get_integer()
#if 0 the warning when there is no _TZP
 1.1 04-Jan-2003  jmcneill Initial support for ACPI Thermal Zones. For now, we only export the zone
temperature to sysmon; in the near future we should be associating devices
in this thermal zone with this device so we can do active or passive
cooling on a zone-by-zone basis.
 1.2.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.1 03-Aug-2004  skrll Sync with HEAD
 1.2.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 05-Jan-2003  thorpej file acpi_tz.c was added on branch nathanw_sa on 2003-01-07 21:33:58 +0000
 1.16.2.7 21-Jan-2008  yamt sync with head
 1.16.2.6 07-Dec-2007  yamt sync with head
 1.16.2.5 15-Nov-2007  yamt sync with head.
 1.16.2.4 27-Oct-2007  yamt sync with head.
 1.16.2.3 03-Sep-2007  yamt sync with head.
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 01-Mar-2006  yamt sync with head.
 1.18.16.2 10-Dec-2006  yamt sync with head.
 1.18.16.1 22-Oct-2006  yamt sync with head
 1.18.14.1 18-Nov-2006  ad Sync with head.
 1.20.10.1 11-Jul-2007  mjf Sync with head.
 1.20.8.4 23-Oct-2007  ad Sync with head.
 1.20.8.3 09-Oct-2007  ad Sync with head.
 1.20.8.2 15-Jul-2007  ad Sync with head.
 1.20.8.1 01-Jul-2007  ad Adapt to callout API change.
 1.23.10.2 18-Oct-2007  yamt sync with head.
 1.23.10.1 14-Oct-2007  yamt sync with head.
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.13 09-Dec-2007  jmcneill Sync with HEAD.
 1.23.6.12 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.23.6.11 04-Dec-2007  jmcneill Fix merge botch.
 1.23.6.10 03-Dec-2007  joerg Sync with HEAD.
 1.23.6.9 02-Dec-2007  jmcneill Sync with HEAD.
 1.23.6.8 01-Dec-2007  jmcneill Sync with HEAD.
 1.23.6.7 21-Nov-2007  joerg Sync with HEAD.
 1.23.6.6 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.23.6.5 04-Nov-2007  jmcneill Sync with HEAD.
 1.23.6.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.23.6.3 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.23.6.2 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.23.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.24.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.24.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.24.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.26.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.26.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.29.2.2 26-Dec-2007  ad Sync with head.
 1.29.2.1 08-Dec-2007  ad Sync with head.
 1.31.2.1 11-Dec-2007  yamt sync with head.
 1.32.10.4 17-Jan-2009  mjf Sync with HEAD.
 1.32.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.32.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.32.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.36.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.36.10.1 19-Oct-2008  haad Sync with HEAD.
 1.36.8.1 28-Jul-2008  simonb Sync with head.
 1.36.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.4.6 11-Aug-2010  yamt sync with head.
 1.36.4.5 11-Mar-2010  yamt sync with head
 1.36.4.4 16-Sep-2009  yamt sync with head
 1.36.4.3 18-Jul-2009  yamt sync with head.
 1.36.4.2 20-Jun-2009  yamt sync with head
 1.36.4.1 04-May-2009  yamt sync with head.
 1.37.4.2 11-Nov-2008  snj Pull up following revision(s) (requested by pgoyette in ticket #41):
sys/dev/acpi/acpi_tz.c: revision 1.39
Leave the task of displaying sensor states to envsys_sysmon() unless we
are in debug mode.
 1.37.4.1 11-Nov-2008  snj Pull up following revision(s) (requested by pgoyette in ticket #41):
sys/dev/acpi/acpi_tz.c: revision 1.38
Temp sensor should report a critical-overtemp condition (ENVSYS_SCRITOVER)
not a simple critical (ENVSYS_SCRITICAL) condition.
 1.37.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.39.4.1 23-Jul-2009  jym Sync with HEAD.
 1.57.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.57.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.57.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.62.2.4 12-Jun-2011  rmind sync with head
 1.62.2.3 05-Mar-2011  rmind sync with head
 1.62.2.2 03-Jul-2010  rmind sync with head
 1.62.2.1 30-May-2010  rmind sync with head
 1.77.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.78.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.79.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.84.6.1 18-Feb-2012  mrg merge to -current.
 1.84.2.2 30-Oct-2012  yamt sync with head
 1.84.2.1 17-Apr-2012  yamt sync with head
 1.87.16.2 28-Aug-2017  skrll Sync with HEAD
 1.87.16.1 06-Jun-2015  skrll Sync with HEAD
 1.87.2.1 03-Dec-2017  jdolecek update from HEAD
 1.89.10.1 10-Jun-2019  christos Sync with HEAD
 1.2 14-Jan-2021  thorpej Use acpi_dsm() in acpi_usb_post_reset().
 1.1 26-Oct-2018  jmcneill branches: 1.1.2; 1.1.6; 1.1.16;
Add xhci at acpi glue
 1.1.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 26-Oct-2018  christos file acpi_usb.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 26-Oct-2018  pgoyette file acpi_usb.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.1 26-Oct-2018  jmcneill branches: 1.1.2; 1.1.6;
Add xhci at acpi glue
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 26-Oct-2018  christos file acpi_usb.h was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 26-Oct-2018  pgoyette file acpi_usb.h was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.37 04-Oct-2025  thorpej Add a platform device tree passthrough for device properties. First,
the device's properties dictionary is consulted, and if it doesn't have
what we're looking for, we go ask the platform device tree. The upshot
is that we can g/c (or not have to add) code that duplicates values from
the device tree into the properties dictionary (either in something like
device_register() or in a driver attachment front-end -- there are multiple
example of both in the system, currently), and everyone gets to use a
consistent interface (which will, over time, allow more code to de-duplicated).

Implement back-ends for ACPI, Sun OpenBoot, and OpenFirmware (including FDT).
 1.36 03-Oct-2025  thorpej Add a device_register() hook for the platform device tree. For ACPI and
OpenFirmware (including FDT), use this to record the firmware path to
the device in the "device-path" property.
 1.35 11-Jan-2025  jmcneill acpi: i2c: only claim child devices with a _CRS or _ADR method

acpi_enter_i2c_devs is too aggressive with claiming child device nodes.
Restrict it to devices with either a _CRS or _ADR method. A driver is
free to claim more if appropriate.

Fixes missing HKEY (LEN0268) device on Thinkpad T14s Gen 6 (X1E).
 1.34 30-Dec-2024  jmcneill acpi_match_cpu_info: Skip test for 'acpi_active'.

This allows us to call this function from acpi_md_callback, which is
when CPUs are attached on Arm.
 1.33 23-Jul-2022  thorpej branches: 1.33.10;
- Handle dtlink in acpi_pack_compat_list().
- Don't pass the _HID value as the device name; always use the ACPI
node name.
 1.32 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.31 15-Jan-2022  jmcneill acpi: Add helper for querying DSM function 0.
 1.30 09-Jan-2022  jmcneill acpi: Add acpi_dsd_bool helper
 1.29 31-Dec-2021  jmcneill acpi: Support DT link compat string lists

A "compatible" DSD property may either be a string, or a package of
strings. Support both variants in acpi_compatible_match.
 1.28 26-Dec-2021  jmcneill acpi: Support DT link device ID

The PRP0001 device ID is used to tell the OS to match a driver against
the "compatible" _DSD property. Make acpi_compatible_match aware of this
special device ID and match device compatible entries against the
compatible property when applicable.
 1.27 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.26 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.25 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.24 05-Feb-2021  thorpej ACPI device handle implementation.
 1.23 27-Jan-2021  thorpej Introduce weighted matching for ACPI autoconfiguration, and provide
acpi_compatible_match() based around device_compatible_entry. Matches
against _HID score big, matches against _CID are weighted in the
standard most-to-least-specific ordering, less than _HID.

Also provide a maching value for _CLS, that's always less than _HID
and _CID matches, and use that in acpi_match_class().

Also provide acpi_compatible_lookup(), that returing the matching
entry based on the same criteria.
 1.22 26-Jan-2021  jmcneill build fix
 1.21 26-Jan-2021  jmcneill Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.20 14-Jan-2021  thorpej - Add a new routine, acpi_pack_compat_list(), that packs the _HID
and _CID device ID strings into an OpenFirmware-like string list,
analogous to how the "compatible" property is represented in
OpenFirmware and the Device Tree specifications.
- Add generic routines for evaluating Device Specific Methods (_DSM).
 1.19 23-Oct-2020  jmcneill branches: 1.19.2;
Add acpi_intr_establish_irq, which is like acpi_intr_establish except
it takes a struct acpi_irq * instead of ACPI_HANDLE. Useful if a device
has more than one IRQ resource (acpi_intr_establish always picks the
first).
 1.18 31-Dec-2019  mlelstv Free buffers only when allocated.
 1.17 29-Dec-2019  jmcneill Add support for reading _DSD string property values.
 1.16 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.15 21-Dec-2018  jmcneill Add acpi_dsd_integer, which reads an integer value from an ACPI 5.0 _DSD
key/value package list.
 1.14 16-Nov-2018  jmcneill Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.
 1.13 12-Oct-2018  jmcneill Add helper function to match a PCI-defined class/subclass/interface
against a _CLS object.
 1.12 12-Oct-2018  jmcneill Pull in sys/cpu.h for struct cpu_info and CPU_INFO_ITERATOR.
 1.11 20-Mar-2018  bouyer branches: 1.11.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.10 10-Dec-2017  bouyer branches: 1.10.2;
Cast to uintptr_t before casting to void *; fix a warning on i386
 1.9 10-Dec-2017  bouyer Implement a ACPI helper to fill the property array expected from our I2C
framework from the ACPI tables.
Also implement acpi_intr_establish(), acpi_intr_disestablish() and
acpi_intr_string().
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.8 21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.7 20-Jun-2011  jruoho Add two new functions, acpi_match_cpu_info() and acpi_match_cpu_handle(),
which will match a given struct cpu_info with the corresponding ACPI handle,
and vice versa.
 1.6 02-Nov-2010  gsutre branches: 1.6.6;
acpi_eval_integer: check that the evaluation produced a result.

ok jruoho@
 1.5 07-Jun-2010  jruoho branches: 1.5.2;
Use the new ACPICA functions AcpiAttachData() and AcpiGetData() to associate
all "struct acpi_devnodes" to their corresponding ACPI_HANDLEs. Anywhere in
the acpi(4) subtree, the node-structure can be obtained from a handle via
acpi_get_node(). The idea is similar to e.g. device_private().

Benefits: (a) simplifies code, (b) avoids issues with locking as ACPICA does
the serialization for us, (c) avoids the need to access the glocal softc, and
(d) avoids the O(n) loop required to search for a handle from the node queue.
 1.4 27-Apr-2010  jruoho branches: 1.4.2; 1.4.4;
Be consistent with the returned exception codes. Check for NULL pointers.
 1.3 24-Apr-2010  jruoho Add utility function acpi_get_node().

This retrieves a struct acpi_devnode from a handle. Since this requires
accessing the global softc, it is better to do it in one place alone. The
same goes for possible locking of the node-queue; it is better not to
publicize such a lock for generic device drivers.
 1.2 15-Apr-2010  jruoho Arrange some comments.
 1.1 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.4.4.4 05-Mar-2011  rmind sync with head
 1.4.4.3 03-Jul-2010  rmind sync with head
 1.4.4.2 30-May-2010  rmind sync with head
 1.4.4.1 27-Apr-2010  rmind file acpi_util.c was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.4.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.4.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.2.1 27-Apr-2010  uebayasi file acpi_util.c was added on branch uebayasi-xip on 2010-04-30 14:43:06 +0000
 1.5.2.2 11-Aug-2010  yamt sync with head.
 1.5.2.1 07-Jun-2010  yamt file acpi_util.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.6.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.10.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10.2.2 20-Oct-2018  pgoyette Sync with head
 1.10.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.11.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.2.1 10-Jun-2019  christos Sync with HEAD
 1.19.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.33.10.1 02-Aug-2025  perseant Sync with HEAD
 1.16 11-Jan-2025  jmcneill acpi: i2c: only claim child devices with a _CRS or _ADR method

acpi_enter_i2c_devs is too aggressive with claiming child device nodes.
Restrict it to devices with either a _CRS or _ADR method. A driver is
free to claim more if appropriate.

Fixes missing HKEY (LEN0268) device on Thinkpad T14s Gen 6 (X1E).
 1.15 23-Jul-2022  thorpej branches: 1.15.10;
- Handle dtlink in acpi_pack_compat_list().
- Don't pass the _HID value as the device name; always use the ACPI
node name.
 1.14 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.13 15-Jan-2022  jmcneill acpi: Add helper for querying DSM function 0.
 1.12 09-Jan-2022  jmcneill acpi: Add acpi_dsd_bool helper
 1.11 05-Feb-2021  thorpej ACPI device handle implementation.
 1.10 26-Jan-2021  jmcneill Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.9 14-Jan-2021  thorpej - Add a new routine, acpi_pack_compat_list(), that packs the _HID
and _CID device ID strings into an OpenFirmware-like string list,
analogous to how the "compatible" property is represented in
OpenFirmware and the Device Tree specifications.
- Add generic routines for evaluating Device Specific Methods (_DSM).
 1.8 29-Dec-2019  jmcneill branches: 1.8.8;
Add support for reading _DSD string property values.
 1.7 21-Dec-2018  jmcneill Add acpi_dsd_integer, which reads an integer value from an ACPI 5.0 _DSD
key/value package list.
 1.6 12-Oct-2018  jmcneill Add helper function to match a PCI-defined class/subclass/interface
against a _CLS object.
 1.5 21-Jun-2011  jruoho branches: 1.5.52; 1.5.54;
Rename acpi_get_node() to acpi_match_node() for consistency.
 1.4 20-Jun-2011  jruoho Add two new functions, acpi_match_cpu_info() and acpi_match_cpu_handle(),
which will match a given struct cpu_info with the corresponding ACPI handle,
and vice versa.
 1.3 07-Jun-2010  jruoho branches: 1.3.2; 1.3.8;
Use the new ACPICA functions AcpiAttachData() and AcpiGetData() to associate
all "struct acpi_devnodes" to their corresponding ACPI_HANDLEs. Anywhere in
the acpi(4) subtree, the node-structure can be obtained from a handle via
acpi_get_node(). The idea is similar to e.g. device_private().

Benefits: (a) simplifies code, (b) avoids issues with locking as ACPICA does
the serialization for us, (c) avoids the need to access the glocal softc, and
(d) avoids the O(n) loop required to search for a handle from the node queue.
 1.2 24-Apr-2010  jruoho branches: 1.2.2; 1.2.4;
Add utility function acpi_get_node().

This retrieves a struct acpi_devnode from a handle. Since this requires
accessing the global softc, it is better to do it in one place alone. The
same goes for possible locking of the node-queue; it is better not to
publicize such a lock for generic device drivers.
 1.1 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.2.4.3 03-Jul-2010  rmind sync with head
 1.2.4.2 30-May-2010  rmind sync with head
 1.2.4.1 24-Apr-2010  rmind file acpi_util.h was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.2.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.2.1 24-Apr-2010  uebayasi file acpi_util.h was added on branch uebayasi-xip on 2010-04-30 14:43:06 +0000
 1.3.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.2 11-Aug-2010  yamt sync with head.
 1.3.2.1 07-Jun-2010  yamt file acpi_util.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.5.54.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.54.1 10-Jun-2019  christos Sync with HEAD
 1.5.52.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5.52.1 20-Oct-2018  pgoyette Sync with head
 1.8.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15.10.1 02-Aug-2025  perseant Sync with HEAD
 1.22 02-Jun-2022  rin Localize one more variable to NPCI > 0 block. Fix ia64 build.
 1.21 31-May-2022  mrg allow ACPI to compile without PCI support. fixes ia64 build.
 1.20 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.19 07-Apr-2018  christos Merge conflicts; STA methods and fields are not present anymore.
 1.18 14-Oct-2016  nonaka branches: 1.18.14;
Dump more FADT fields from ACPI 6.1.
 1.17 20-Oct-2013  christos branches: 1.17.6; 1.17.10;
fix unused variable warnings
 1.16 03-Jan-2011  jruoho branches: 1.16.8; 1.16.18; 1.16.22;
Scan for devices that are "hot-pluggable".
 1.15 31-Dec-2010  jruoho Include <dev/acpi/acpi_pci.h>.
 1.14 31-Dec-2010  jruoho acpi_pcidev_find_dev(): take struct acpi_devnode as a parameter.
 1.13 31-Dec-2010  jruoho Move the function that finds a device_t for the corresponding ACPI device
node from ACPIVERBOSE to the ACPI PCI code.
 1.12 26-Oct-2010  gsutre An _ADR object is not required for PCI root bridges. To solve
this, the structure acpi_pciinfo now tells whether the ACPI
device node is a PCI bridge, a regular PCI device, or both.

Problem reported by jmcneill@, who also suggested the solution.

ok jmcneill@, jruoho@
 1.11 24-Sep-2010  gsutre Do not discard ACPI PCI addresses with function number 0xFFFF: the
ACPI specification allows them (ACPI 4.0a, p. 200).

ok jruoho@
 1.10 11-Aug-2010  gsutre branches: 1.10.2; 1.10.4;
acpi_print_tree: print ACPI and PCI autoconf(9) device names.

ok jruoho@
 1.9 07-Aug-2010  jruoho Allow to dump the basic information at runtime with a flag to modload(8).
This can help when dealing with problem reports, as the user does not need
to reboot nor compile a kernel. Instead: 'modload -b dump=true acpiverbose'.
 1.8 07-Aug-2010  jruoho Dump MADT in ACPIVERBOSE.
 1.7 07-Aug-2010  jruoho Dump the whole FADT in ACPIVERBOSE.
 1.6 06-Aug-2010  jruoho Simplify the acpiverbose module.
 1.5 06-Aug-2010  jruoho Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.4 25-Jul-2010  pgoyette Move setting of acpi_verbose_loaded flag into the module's init routine.
This ensures that the flag is set even if the module was manually loaded
by the user rather than just auto-loaded.
 1.3 07-Jun-2010  pgoyette branches: 1.3.2;
Update acpiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.2 05-Jun-2010  jruoho Remove trailing white space.
 1.1 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.3.2.3 05-Mar-2011  rmind sync with head
 1.3.2.2 03-Jul-2010  rmind sync with head
 1.3.2.1 07-Jun-2010  rmind file acpi_verbose.c was added on branch rmind-uvmplock on 2010-07-03 01:19:34 +0000
 1.10.4.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.10.4.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.4.1 11-Aug-2010  uebayasi file acpi_verbose.c was added on branch uebayasi-xip on 2010-08-17 06:46:01 +0000
 1.10.2.3 09-Oct-2010  yamt sync with head
 1.10.2.2 11-Aug-2010  yamt sync with head.
 1.10.2.1 11-Aug-2010  yamt file acpi_verbose.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.16.22.1 18-May-2014  rmind sync with head
 1.16.18.2 03-Dec-2017  jdolecek update from HEAD
 1.16.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.8.1 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.17.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.17.6.1 05-Dec-2016  skrll Sync with HEAD
 1.18.14.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.3 27-Aug-2024  riastradh branches: 1.3.2; 1.3.6;
entropy(9): Merge entropy_consolidate, entropy_consolidate_sig.

entropy_consolidate can already be interrupted by a signal -- it just
doesn't tell the caller this happened. So make it return the error
code, and delete entropy_consolidate_sig.

NOTE: This changes the semantics of an existing symbol, so it can't
be pulled up. (It might in principle be ABI-compatible because the
old symbol returned void and the new one returns int, so the caller
can just ignore the return value register in most if not all ABIs,
but I organized the relevant changes so we can pull up bug fixes
without thinking about this.) This is just tidying the kernel API
after all the previous fixes which can be pulled up.

PR kern/58646: /dev/random, kern.entropy.*: signal bugs
 1.2 26-Aug-2024  riastradh acpivmgenid(4): Reset and gather entropy on VM clone notification.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.1 26-Aug-2024  riastradh acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.

TBD: Add to all ACPI-supporting GENERIC kernels.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.3.6.2 02-Aug-2025  perseant Sync with HEAD
 1.3.6.1 27-Aug-2024  perseant file acpi_vmgenid.c was added on branch perseant-exfatfs on 2025-08-02 05:56:32 +0000
 1.3.2.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.3.2.1 27-Aug-2024  martin file acpi_vmgenid.c was added on branch netbsd-10 on 2024-10-09 13:25:12 +0000
 1.30 09-Dec-2024  jmcneill Don't setup GPEs on HW reduced platforms
 1.29 31-May-2022  mrg branches: 1.29.10;
allow ACPI to compile without PCI support. fixes ia64 build.
 1.28 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.27 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.26 25-Feb-2014  pooka branches: 1.26.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.25 14-Aug-2012  jruoho branches: 1.25.2; 1.25.4;
Use KM_SLEEP.
 1.24 19-Feb-2011  jruoho branches: 1.24.4;
Revisit the wake-device code once more.

1. Remove the AcpiEnableGpe() call. This was wrong.

2. Only call _PSW or _DSW for devices that are scheduled for wake.
This was an old bug.

3. Only enable wake GPEs during suspend. Disabling these for
devices not setup for wake was causing problems.

4. No wake GPEs should be enabled at runtime.
Unconditionally disable these during resume.

This should make the wake-device code work again. Note that waking via
pckbd(4) has always been unreliable; the _PRW object is not typically located
under the PC keyboard object, but in the parent of it (e.g. the LPC bridge).
 1.23 18-Feb-2011  jruoho A small cleanup for the previous; use kmem(9), add assertions, etc.
 1.22 17-Feb-2011  jruoho As explained in the new ACPICA documentation, as of ACPICA 20101207, the
_PRW methods are no longer automatically executed as part of the ACPICA
initialization. Refactor and rewrite the wake-device code to account this.
 1.21 17-Feb-2011  jruoho ACPICA 20101209:

Completed the major overhaul of the GPE support code that was begun in July
2010. Major features include: removal of _PRW execution in ACPICA (host
executes _PRWs anyway), cleanup of "wake" GPE interfaces and processing,
changes to existing interfaces, simplification of GPE handler operation, and
a handful of new interfaces:

AcpiUpdateAllGpes
AcpiFinishGpe
AcpiSetupGpeForWake
AcpiSetGpeWakeMask

ACPICA 20100702:

Implemented several updates to the recently added GPE reference count
support. The model for "wake" GPEs is changing to give the host OS complete
control of these GPEs. Eventually, the ACPICA core will not execute any _PRW
methods, since the host already must execute them. Also, additional changes
were made to help ensure that the reference counts are kept in proper
synchronization with reality. Rafael J. Wysocki.

1) Ensure that GPEs are not enabled twice during initialization.
2) Ensure that GPE enable masks stay in sync with the reference count.
3) Do not inadvertently enable GPEs when writing GPE registers.
4) Remove the internal wake reference counter and add new AcpiGpeWakeup
interface. This interface will set or clear individual GPEs for wakeup.
5) Remove GpeType argument from AcpiEnable and AcpiDisable. These interfaces
are now used for "runtime" GPEs only.
 1.20 02-Jan-2011  jruoho branches: 1.20.2; 1.20.4;
Adjust error messages for the previous commit.
 1.19 02-Jan-2011  jruoho Use "real" device names for the hw.acpi.wake and hw.acpi.power sysctl(8)
trees. For instance, instead of hw.acpi.wake.DURT, we have hw.acpi.wake.wm0
for wm(4). This is a temporary solution, but without solving the big
abstraction questions, this is the best we can do.
 1.18 08-Oct-2010  gsutre Store sysctl MIBs instead of a pointer to the root of the sysctl
sub-tree (because the pointer may be invalid at the time we use it).

ok jruoho@
 1.17 07-Jun-2010  jruoho Fix a bug: the last elements in the _PRW package are direct references to
power resources, not devices. Thus, we can not use the function that sets
the power state of a device.
 1.16 07-Jun-2010  jruoho Instead of disabling all GPEs for non-wakedevs, set both runtime and wake
GPEs, but unset only wake GPEs. The old behavior was questionable, as the
intention was only to disable a device's ability to wake the system.
Maintaining the runtime GPE generation is more important now as ACPICA
supports sharing a single GPE across multiple devices.

Discussed with jmcneill@.
 1.15 06-Jun-2010  jruoho ACPICA 20100331:

Completed a major update for the GPE support in order to improve
support for shared GPEs and to simplify both host OS and ACPICA
code. Added a reference count mechanism to support shared GPEs that
require multiple device drivers. Several external interfaces have
changed. One external interface has been removed. One new external
interface was added. Most of the GPE external interfaces now use the
GPE spinlock instead of the events mutex (and the Flags parameter
for many GPE interfaces has been removed.) See the updated ACPICA
Programmer Reference for details. Matthew Garrett, Bob Moore, Rafael
Wysocki. ACPICA BZ 831.

Changed:
AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus
Removed:
AcpiSetGpeType
New:
AcpiSetGpe
 1.14 05-Jun-2010  jruoho Switch the third argument to the _DSW method from 3 to 0. This means that
devices should be placed in the D0 state ("fully on") after resume. We were
not prepared to handle the previous value as it implied that devices could
be placed in an arbitrary power state once in S0.

Minimal functional change, given that the _DSW is seldom seen in the field.
 1.13 05-Jun-2010  jruoho Complete the support for wakeup devices. As imposed by the standard, all
power resources should be turned on for wakeup devices. This follows common
sense: a device cannot wake if the power of it is turned off.

ok jmcneill@
 1.12 18-Apr-2010  jruoho branches: 1.12.2;
From Gregoire Sutre:

Modify the main ACPI namespace scan by including a parent-child
relationship for each node. The result is a bi-directional tree.

ok jmcneill@
 1.11 14-Apr-2010  jruoho Simplify the setting of the GPEs. Add a debug-printf.
 1.10 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.9 12-Apr-2010  jruoho Rework the sysctl-support.

Changes:

hw.wake -> hw.acpi.wake
hw.acpi.debug_layer -> hw.acpi.debug.layer
hw.acpi.debug_level -> hw.acpi.debug.level

Additions:

hw.acpi.stat.gpe # Number of dispatched GPEs
hw.acpi.stat.sci # Number of SCI interrupts
hw.acpi.stat.fixed # Number of fixed events
hw.acpi.stat.method # Number of executed methods

ok jmcneill@
 1.8 16-Mar-2010  jruoho Remove unused headers.
 1.7 16-Mar-2010  jruoho With the intent of making 'struct acpi_devnode' as the central place for
information related to ACPI device nodes: (a) introduce a generic scan
function for ACPI device driver "capabilities", and (b) eliminate local data
structures from ACPI wake-devices. Discussed with jmcneill@.
 1.6 09-Mar-2010  jruoho branches: 1.6.2;
Remove the namespace scopes.

These are neither used nor useful beyond the parser and interpreter.

ok jmcneill@, joerg@
 1.5 05-Mar-2010  jruoho Add the _COMPONENT definition and missing prototypes. Some related cosmetics.
 1.4 05-Mar-2010  jruoho Preparing a device for wakeup involves:

(a) turning on all power resources required by the device; and
(b) executing _DSW (or _PSW) control method.

This implements (b). Ok jmcneill@.
 1.3 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.2 04-Aug-2009  jmcneill branches: 1.2.2; 1.2.4; 1.2.6;
remove extra semicolon, spotted by snj
 1.1 04-Aug-2009  jmcneill add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.2.6.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.6.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.6.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.4.2 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.2.4.1 04-Aug-2009  bouyer file acpi_wakedev.c was added on branch netbsd-5 on 2009-09-05 11:34:26 +0000
 1.2.2.4 11-Aug-2010  yamt sync with head.
 1.2.2.3 11-Mar-2010  yamt sync with head
 1.2.2.2 19-Aug-2009  yamt sync with head.
 1.2.2.1 04-Aug-2009  yamt file acpi_wakedev.c was added on branch yamt-nfs-mp on 2009-08-19 18:47:03 +0000
 1.6.2.3 05-Mar-2011  rmind sync with head
 1.6.2.2 03-Jul-2010  rmind sync with head
 1.6.2.1 30-May-2010  rmind sync with head
 1.12.2.2 21-Apr-2010  matt sync to netbsd-5
 1.12.2.1 18-Apr-2010  matt file acpi_wakedev.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:33 +0000
 1.20.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.20.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.20.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.4.2 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.24.4.1 30-Oct-2012  yamt sync with head
 1.25.4.1 18-May-2014  rmind sync with head
 1.25.2.2 03-Dec-2017  jdolecek update from HEAD
 1.25.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.6.1 28-Aug-2017  skrll Sync with HEAD
 1.29.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 19-Feb-2011  jruoho Revisit the wake-device code once more.

1. Remove the AcpiEnableGpe() call. This was wrong.

2. Only call _PSW or _DSW for devices that are scheduled for wake.
This was an old bug.

3. Only enable wake GPEs during suspend. Disabling these for
devices not setup for wake was causing problems.

4. No wake GPEs should be enabled at runtime.
Unconditionally disable these during resume.

This should make the wake-device code work again. Note that waking via
pckbd(4) has always been unreliable; the _PRW object is not typically located
under the PC keyboard object, but in the parent of it (e.g. the LPC bridge).
 1.5 17-Feb-2011  jruoho As explained in the new ACPICA documentation, as of ACPICA 20101207, the
_PRW methods are no longer automatically executed as part of the ACPICA
initialization. Refactor and rewrite the wake-device code to account this.
 1.4 16-Mar-2010  jruoho branches: 1.4.2; 1.4.4; 1.4.6;
With the intent of making 'struct acpi_devnode' as the central place for
information related to ACPI device nodes: (a) introduce a generic scan
function for ACPI device driver "capabilities", and (b) eliminate local data
structures from ACPI wake-devices. Discussed with jmcneill@.
 1.3 05-Mar-2010  jruoho branches: 1.3.2;
Preparing a device for wakeup involves:

(a) turning on all power resources required by the device; and
(b) executing _DSW (or _PSW) control method.

This implements (b). Ok jmcneill@.
 1.2 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.1 04-Aug-2009  jmcneill branches: 1.1.2; 1.1.4; 1.1.6;
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.1.6.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.4.2 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.1.4.1 04-Aug-2009  bouyer file acpi_wakedev.h was added on branch netbsd-5 on 2009-09-05 11:34:26 +0000
 1.1.2.4 11-Aug-2010  yamt sync with head.
 1.1.2.3 11-Mar-2010  yamt sync with head
 1.1.2.2 19-Aug-2009  yamt sync with head.
 1.1.2.1 04-Aug-2009  yamt file acpi_wakedev.h was added on branch yamt-nfs-mp on 2009-08-19 18:47:03 +0000
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 30-May-2010  rmind sync with head
 1.4.6.1 05-Mar-2011  bouyer Sync with HEAD
 1.4.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.2.2 21-Apr-2010  matt sync to netbsd-5
 1.4.2.1 16-Mar-2010  matt file acpi_wakedev.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:33 +0000
 1.5 06-May-2023  andvar s/regster/register/ in comments and error messages.
 1.4 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.3 27-Dec-2013  christos branches: 1.3.6;
function argument changed width
 1.2 17-Jan-2011  jmcneill branches: 1.2.4; 1.2.8; 1.2.10; 1.2.20; 1.2.24;
use PRIx64 instead of llx, fixes build on amd64
 1.1 17-Jan-2011  jmcneill Add a driver for ACPI "Watchdog Resource Table" devices.

acpiwdrt0 at acpi0: mem 0xfed01000,0xfed01004
acpiwdrt0: PCI 0:000:00:0 vendor 0x1106 product 0x3337
acpiwdrt0: watchdog interval 1-1023 sec.
 1.2.24.1 18-May-2014  rmind sync with head
 1.2.20.2 03-Dec-2017  jdolecek update from HEAD
 1.2.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 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.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 17-Jan-2011  jruoho file acpi_wdrt.c was added on branch jruoho-x86intr on 2011-06-06 09:07:42 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 17-Jan-2011  rmind file acpi_wdrt.c was added on branch rmind-uvmplock on 2011-03-05 20:53:03 +0000
 1.3.6.1 06-Jun-2015  skrll Sync with HEAD
 1.7 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.6 20-Mar-2018  bouyer 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.5 17-Feb-2011  jruoho branches: 1.5.54;
Switch acpi(4) to use the new location of ACPICA.
 1.4 05-Mar-2010  jruoho branches: 1.4.2; 1.4.4; 1.4.6;
Protect all header files against multiple inclusions.
 1.3 18-Aug-2009  jmcneill branches: 1.3.2;
Switch to ACPICA 20090730, and update for API changes.
 1.2 23-Mar-2006  kochi branches: 1.2.62;
Change header location in accordance with moving ACPI-CA to sys/dist/acpica
 1.1 28-Sep-2001  thorpej branches: 1.1.2; 1.1.4; 1.1.8; 1.1.40; 1.1.54; 1.1.56; 1.1.58; 1.1.60; 1.1.62;
Glue header file to pull in the ACPICA headers.
 1.1.62.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.60.1 19-Apr-2006  elad sync with head.
 1.1.58.1 01-Apr-2006  yamt sync with head.
 1.1.56.1 22-Apr-2006  simonb Sync with head.
 1.1.54.1 09-Sep-2006  rpaulo sync with head
 1.1.40.1 21-Jun-2006  yamt sync with head.
 1.1.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 28-Sep-2001  thorpej file acpica.h was added on branch kqueue on 2002-01-10 19:52:54 +0000
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 28-Sep-2001  nathanw file acpica.h was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 28-Sep-2001  fvdl file acpica.h was added on branch thorpej-devvp on 2001-10-01 12:44:17 +0000
 1.2.62.2 11-Mar-2010  yamt sync with head
 1.2.62.1 19-Aug-2009  yamt sync with head.
 1.3.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.6.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.2.1 05-Mar-2011  rmind sync with head
 1.5.54.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.36 28-May-2019  msaitoh s/recieve/receive/
 1.35 22-Jun-2011  jruoho branches: 1.35.54;
Add SMO8800.
 1.34 20-Jun-2011  jruoho Add ENE0100, a KB3924-based cir(4) chip.

From dmesg supplied by hasina rakotoarisoa on gnats.
 1.33 10-Jan-2011  jruoho branches: 1.33.6;
Add SMO1200 (yet another TPM chip). From ThinkPad x201i.
 1.32 09-Jan-2011  jruoho Rearrange (use two tabs).
 1.31 09-Jan-2011  jruoho Add INTC0102 (Intel TPM chip). From ThinkPad T500.
 1.30 30-Dec-2010  jruoho Add IBM0079.
 1.29 22-Dec-2010  jruoho Add IPI0001, an identifier for ipmi(4). From Dell M710.
 1.28 26-Oct-2010  jruoho Add LEN0014. (And to the previous commit; a driver for this, not PNP0C32, is
possibly coming.)
 1.27 26-Oct-2010  jruoho Add more identifiers for ATM chips.

Also add PNP0C32 for "quickstart buttons". A driver for this comes later.
 1.26 25-Jul-2010  jruoho Add PNP0B01 and PNP0B02, both variants of the PC/AT RTC. From the spec.
 1.25 18-Jul-2010  jruoho Shorten some of the descriptions.
 1.24 01-Jul-2010  jruoho Add HPQ0004, the HP-branded device for the LIS3LV02DL-based accelerometers.
 1.23 16-Jun-2010  jruoho Add CSC0000, CSC0003, CSC0010. Observed from jnemeth@'s ThinkPad 380Z.
 1.22 08-Jun-2010  jruoho Add PNP0C33, "a hardware error device". Part of APEI.
 1.21 08-Jun-2010  jruoho Use the same notation with the PNP identifiers. Specifically note that
PNP0C80 is the device that is required for memory hot-plug on x86.
 1.20 26-May-2010  jruoho Split the IrDA devices to their own section. Add HWPC224 and IBM0071,
both for the PC8738x-family of SuperIO chips from NSC (or Winbond).
 1.19 18-Apr-2010  jruoho Add ATM1200. From ThinkPad X60s.
 1.18 10-Apr-2010  jruoho Add NSC1100. From ThinkPad T43p.
 1.17 10-Apr-2010  jruoho Add ITE8708. From Dell Studio XPS 16.
 1.16 09-Apr-2010  jruoho Add SYN013B. Observed from the dmesg of cegger@'s HP Pavilion dv9700.
 1.15 22-Mar-2010  jruoho Add IFX0102 and PNP0C15. Fix INT0800.

Observed from the dmesg of njoly@'s Sony VAIO VGN-BZ12VN.
 1.14 18-Jan-2010  jruoho branches: 1.14.2; 1.14.4;
Add some ACPI 4.0 devices.

ok jmcneill@, pgoyette@
 1.13 27-Sep-2009  jmcneill Add PNP0C14 (WMI mapper device)
 1.12 21-Jan-2009  jnemeth add a comment explaining how to regenerate acpidevs_data.h
 1.11 09-Jul-2006  christos branches: 1.11.58; 1.11.68;
url for M$ file changed.
 1.10 01-Mar-2006  cube branches: 1.10.2; 1.10.10;
Add INT0800 (Intel FWH RNG). Make tabulation consistent.
 1.9 17-Feb-2006  kochi Correct some existing device names (PCI bridges, ACPI buses) according
to the up-to-date specs (ACPI 3.0a/PCI Firmware spec 3.0).
Add some ACPI specific devices (ACPI000x).
 1.8 12-Nov-2005  rpaulo branches: 1.8.4; 1.8.6; 1.8.8;
Add ACPI Three-wire Device Bus.
 1.7 11-Nov-2005  kochi add HPET timer PNP ID.
reported in PR32040 by Nicolas Joly
 1.6 10-Nov-2005  rpaulo Add NSC IrDA Fast Infrared Port.
 1.5 10-Nov-2005  rpaulo Add Synaptics PS/2-style Touchpad.
 1.4 27-Feb-2005  perry branches: 1.4.4;
nuke trailing whitespace
 1.3 04-Feb-2003  perry branches: 1.3.2; 1.3.10; 1.3.12;
Add a comment noting the origin of the list
XXX We need to make it easier to import this list
XXX We also need to find a more comprehensive list
 1.2 04-Feb-2003  perry Correct an obvious syntax error (a comment without a # in front of it)
 1.1 05-Jan-2003  christos branches: 1.1.2;
Infrastucture for ACPIVERBOSE
 1.1.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 05-Jan-2003  thorpej file acpidevs was added on branch nathanw_sa on 2003-01-07 21:33:58 +0000
 1.3.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.10.1 29-Apr-2005  kent sync with -current
 1.3.2.2 11-Dec-2005  christos Sync with head.
 1.3.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.2 30-Dec-2006  yamt sync with head.
 1.4.4.1 21-Jun-2006  yamt sync with head.
 1.8.8.1 22-Apr-2006  simonb Sync with head.
 1.8.6.1 09-Sep-2006  rpaulo sync with head
 1.8.4.1 18-Feb-2006  yamt sync with head.
 1.10.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.10.2.1 11-Aug-2006  yamt sync with head
 1.11.68.1 03-Mar-2009  skrll Sync with HEAD.
 1.11.58.3 11-Aug-2010  yamt sync with head.
 1.11.58.2 11-Mar-2010  yamt sync with head
 1.11.58.1 04-May-2009  yamt sync with head.
 1.14.4.3 05-Mar-2011  rmind sync with head
 1.14.4.2 03-Jul-2010  rmind sync with head
 1.14.4.1 30-May-2010  rmind sync with head
 1.14.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.14.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.33.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.35.54.1 10-Jun-2019  christos Sync with HEAD
 1.27 08-Feb-2024  andvar Regen with typo fixed.

Regeneration script doesn't seem to react to description changes only, thus
regenerated it twice by changing device name locally and putting it back
to original value.
 1.26 22-Jun-2011  jruoho Regen.
 1.25 20-Jun-2011  jruoho Regen.
 1.24 10-Jan-2011  jruoho branches: 1.24.6;
Regen.
 1.23 09-Jan-2011  jruoho Regen.
 1.22 30-Dec-2010  jruoho Regen.
 1.21 22-Dec-2010  jruoho Regen.
 1.20 26-Oct-2010  jruoho Regen.
 1.19 16-Jun-2010  jruoho Regen.
 1.18 26-May-2010  jruoho Regen.
 1.17 18-Apr-2010  jruoho Regen.
 1.16 10-Apr-2010  jruoho Add NSC1100. From ThinkPad T43p.
 1.15 10-Apr-2010  jruoho Regen
 1.14 09-Apr-2010  jruoho Regen.
 1.13 22-Mar-2010  jruoho Regen.
 1.12 18-Jan-2010  jruoho branches: 1.12.2; 1.12.4;
regen.
 1.11 27-Sep-2009  jmcneill regen for PNP0C14
 1.10 01-Mar-2006  cube branches: 1.10.68;
Regen.
 1.9 17-Feb-2006  kochi regen.
 1.8 12-Nov-2005  rpaulo branches: 1.8.4; 1.8.6; 1.8.8;
regen
 1.7 11-Nov-2005  kochi regen.
 1.6 10-Nov-2005  rpaulo regen
 1.5 10-Nov-2005  rpaulo regen
 1.4 27-Feb-2005  perry branches: 1.4.4;
regen
 1.3 12-Dec-2003  jmc branches: 1.3.8; 1.3.10;
Regen (picks up PNP8389 after devlist2h.awk changes
 1.2 04-Feb-2003  perry branches: 1.2.2;
pro forma -- no actual changes but the source file did change version
 1.1 05-Jan-2003  christos branches: 1.1.2;
Regen, err. Gen.
 1.1.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 05-Jan-2003  thorpej file acpidevs_data.h was added on branch nathanw_sa on 2003-01-07 21:33:59 +0000
 1.2.2.5 11-Dec-2005  christos Sync with head.
 1.2.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.8.1 29-Apr-2005  kent sync with -current
 1.4.4.1 21-Jun-2006  yamt sync with head.
 1.8.8.1 22-Apr-2006  simonb Sync with head.
 1.8.6.1 09-Sep-2006  rpaulo sync with head
 1.8.4.1 18-Feb-2006  yamt sync with head.
 1.10.68.2 11-Aug-2010  yamt sync with head.
 1.10.68.1 11-Mar-2010  yamt sync with head
 1.12.4.3 05-Mar-2011  rmind sync with head
 1.12.4.2 03-Jul-2010  rmind sync with head
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.12.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.24.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12 01-Aug-2011  jmcneill add support for reset registers in PCI config space
 1.11 12-Oct-2010  gsutre Merge ACPI display driver. Provides generic support for brightness
control and output switching, through ACPI video extensions.

TODO: use wsconsctl(8) instead of sysctl(8) for brightness control.

ok jruoho@
also discussed with cegger@ and jmcneill@
 1.10 27-Aug-2010  jruoho From jmcneill@: fix and rework the obscure _OSC evaluation.
 1.9 27-Apr-2010  jruoho Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
 1.8 27-Apr-2010  jruoho Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.
 1.7 05-Mar-2010  jruoho branches: 1.7.2;
Protect all header files against multiple inclusions.
 1.6 16-Sep-2009  mlelstv branches: 1.6.2;
Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.5 11-Dec-2005  christos branches: 1.5.74;
merge ktrace-lwp.
 1.4 29-Jan-2005  jmcneill Fix typo (Capabiltites -> Capabilities).
 1.3 15-Jun-2002  thorpej branches: 1.3.6; 1.3.14; 1.3.16;
Update for acpica-unix-20020612. From Takayoshi Kochi.
 1.2 29-Sep-2001  thorpej branches: 1.2.2; 1.2.4; 1.2.8; 1.2.16;
Flesh out w/ some comments from the spec, and add some _ADR decoding
macros.
 1.1 28-Sep-2001  thorpej Add some basic ACPI probing framework. This is far from complete,
it is merely a work in progress.
 1.2.16.1 20-Jun-2002  gehenna catch up with -current.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.1 29-Sep-2001  thorpej file acpireg.h was added on branch kqueue on 2002-01-10 19:52:54 +0000
 1.2.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.4.1 29-Sep-2001  nathanw file acpireg.h was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.2.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 29-Sep-2001  fvdl file acpireg.h was added on branch thorpej-devvp on 2001-10-01 12:44:17 +0000
 1.3.16.1 12-Feb-2005  yamt sync with head.
 1.3.14.1 29-Apr-2005  kent sync with -current
 1.3.6.1 04-Feb-2005  skrll Sync with HEAD.
 1.5.74.3 09-Oct-2010  yamt sync with head
 1.5.74.2 11-Aug-2010  yamt sync with head.
 1.5.74.1 11-Mar-2010  yamt sync with head
 1.6.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.2.2 05-Mar-2011  rmind sync with head
 1.7.2.1 30-May-2010  rmind sync with head
 1.93 18-Dec-2024  jmcneill acpi: Honour device dependencies ("_DEP" method).

When creating acpi_devnode devices, build a list of devnodes that are
direct dependencies of this node. The list of dependencies are parent
device nodes (if present), along with all devices returned by the _DEP
method.

When rescanning devices, make sure that all dependencies have been
scanned first. This ensures that drivers attach in the correct order.
 1.92 09-Dec-2024  jmcneill acpi: gpio: Pass the full ACPI_RESOURCE_GPIO to the translate callback.
 1.91 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.90 20-Mar-2024  riastradh branches: 1.90.2;
acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.

Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046
 1.89 26-Dec-2021  jmcneill branches: 1.89.4;
acpi: Support DT link device ID

The PRP0001 device ID is used to tell the OS to match a driver against
the "compatible" _DSD property. Make acpi_compatible_match aware of this
special device ID and match device compatible entries against the
compatible property when applicable.
 1.88 20-Dec-2021  skrll Fix struct member prefix to be consistent. same code before and after.
 1.87 07-Aug-2021  jmcneill acpi: Add acpi_resource_parse_any().

Like acpi_resource_parse(), but doesn't exclude "produced" resources.
 1.86 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.85 04-Feb-2021  thorpej branches: 1.85.4; 1.85.6;
Add acpi_device_register(). Just a placeholder for now.
 1.84 27-Jan-2021  thorpej Introduce weighted matching for ACPI autoconfiguration, and provide
acpi_compatible_match() based around device_compatible_entry. Matches
against _HID score big, matches against _CID are weighted in the
standard most-to-least-specific ordering, less than _HID.

Also provide a maching value for _CLS, that's always less than _HID
and _CID matches, and use that in acpi_match_class().

Also provide acpi_compatible_lookup(), that returing the matching
entry based on the same criteria.
 1.83 06-Dec-2020  jmcneill acpi: remove unused acpi_quirks_osi_* functions
 1.82 17-Jan-2020  jmcneill branches: 1.82.6;
Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.81 31-Dec-2019  jmcneill branches: 1.81.2;
Rely on 32/64-bit overflow to calculate translation offsets. Store this
as a separate ar_xbase field in acpi_mem instead of having separate
ar_offset and ar_decode fields.
 1.80 31-Dec-2019  jmcneill Include device decoding type in acpi_mem resources
 1.79 31-Dec-2019  jmcneill Fetch bus_dma tags when acpi devnodes are created. They do not change
and this allows MD code to create more complex tags without being
concerned with the tag being destroyed later. While here, capture
translations offsets for address32/address64 resources.
 1.78 29-Dec-2019  jmcneill Allow MD code to provide custom bus_dma tags on a per-node basis. On Arm
this is required to return non-coherent bus_dma tags for device nodes with
_CCA=0
 1.77 25-Oct-2018  jmcneill Add support for 64-bit memory resources.
 1.76 12-Oct-2018  jmcneill Add helper functions for walking GTDT subtables.
 1.75 05-May-2018  christos branches: 1.75.2;
introduce acpi_device_present() to replace the previous _STA checks.
 1.74 21-Jun-2016  nonaka branches: 1.74.16;
Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.
 1.73 01-Aug-2011  jmcneill branches: 1.73.12; 1.73.30;
add support for reset registers in PCI config space
 1.72 21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.71 15-Jun-2011  jruoho Do not entirely bypass the printfs during resource parsing, as many drivers
rely on those for their autoconf(9) messages. Instead add a "quiet" option.
 1.70 14-Jun-2011  jruoho Try to attach hpet(4) also via a specific HPET table. Fixes PR kern/43702.
 1.69 20-Feb-2011  jruoho branches: 1.69.2;
Add quirk support for _OSI strings introduced in ACPICA 20110211. While
here, clean up acpi_probe() and the quirk code. Remove #ifdef ACPI_DEBUGGER.
 1.68 17-Feb-2011  jruoho As explained in the new ACPICA documentation, as of ACPICA 20101207, the
_PRW methods are no longer automatically executed as part of the ACPICA
initialization. Refactor and rewrite the wake-device code to account this.
 1.67 17-Jan-2011  jmcneill branches: 1.67.2;
Add a driver for ACPI "Watchdog Resource Table" devices.

acpiwdrt0 at acpi0: mem 0xfed01000,0xfed01004
acpiwdrt0: PCI 0:000:00:0 vendor 0x1106 product 0x3337
acpiwdrt0: watchdog interval 1-1023 sec.
 1.66 13-Jan-2011  jruoho branches: 1.66.2;
Scan for docking stations.
 1.65 26-Oct-2010  gsutre An _ADR object is not required for PCI root bridges. To solve
this, the structure acpi_pciinfo now tells whether the ACPI
device node is a PCI bridge, a regular PCI device, or both.

Problem reported by jmcneill@, who also suggested the solution.

ok jmcneill@, jruoho@
 1.64 24-Oct-2010  jruoho Simplify acpi_enter_sleep_state() and guard it against NULL pointer
dereferences. Try to avoid referencing the global acpi_softc, which should
really be static or at least internal to acpi(4).
 1.63 24-Sep-2010  gsutre Do not discard ACPI PCI addresses with function number 0xFFFF: the
ACPI specification allows them (ACPI 4.0a, p. 200).

ok jruoho@
 1.62 06-Sep-2010  jmcneill Add support for blacklisting ACPI BIOS implementations by year. By default,
don't use ACPI on BIOS which advertise release years <= 2000. This
can be changed by setting option ACPI_BLACKLIST_YEAR=0 or by setting
acpi_force_load=1.
 1.61 07-Aug-2010  jruoho Do not try to disable ACPI if we can not enter to legacy mode. While it is
safe to call AcpiDisable() even if a system operates only in ACPI mode, this
leads to unpleasantly verbose error messages in ACPICA.
 1.60 07-Aug-2010  jruoho Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.
 1.59 06-Aug-2010  jruoho Simplify the acpiverbose module.
 1.58 06-Aug-2010  jruoho Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.57 08-Jun-2010  jruoho Add and organize some comments. Add also ACPI_DEVICE_EJECT constant to
indicate "ejectable" devices such as docking stations.
 1.56 07-Jun-2010  pgoyette Update acpiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.55 05-Jun-2010  jruoho Remove trailing white space.
 1.54 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.53 27-Apr-2010  jruoho Include the new prototype for acpi_enter_sleep_state().
 1.52 22-Apr-2010  jruoho Remove a redundant prototype. A leftover from the previous commit.
 1.51 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.50 22-Apr-2010  jruoho From Gregoire Sutre: rework the ACPI PCI support. This makes ACPI to
correctly pick PCI segment groups, PCI bus numbers, PCI root bridges,
PCI-to-PCI bridges, and PCI devices, among other things. In short: it is
more robust than the old code or anything in sys/arch/x86/x86/mpacpi.c.

ok cegger@, jmcneill@
 1.49 18-Apr-2010  jruoho From Gregoire Sutre:

Modify the main ACPI namespace scan by including a parent-child
relationship for each node. The result is a bi-directional tree.

ok jmcneill@
 1.48 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.47 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.46 12-Apr-2010  jruoho Remove some unused and global variables. Make the code more readable. Deny
invalid writes to machdep.sleep_state. Cosmetics. No functional change.
 1.45 12-Apr-2010  jruoho Rework the sysctl-support.

Changes:

hw.wake -> hw.acpi.wake
hw.acpi.debug_layer -> hw.acpi.debug.layer
hw.acpi.debug_level -> hw.acpi.debug.level

Additions:

hw.acpi.stat.gpe # Number of dispatched GPEs
hw.acpi.stat.sci # Number of SCI interrupts
hw.acpi.stat.fixed # Number of fixed events
hw.acpi.stat.method # Number of executed methods

ok jmcneill@
 1.44 16-Mar-2010  jruoho With the intent of making 'struct acpi_devnode' as the central place for
information related to ACPI device nodes: (a) introduce a generic scan
function for ACPI device driver "capabilities", and (b) eliminate local data
structures from ACPI wake-devices. Discussed with jmcneill@.
 1.43 10-Mar-2010  jruoho branches: 1.43.2;
Move the ACPI_ACTIVATE_DEV block to one place. While there, provide missing
prototype for a function, try to make the code more simple, guard against a
potential NULL pointer dereference, and improve printing.

No functional change intended.
 1.42 09-Mar-2010  jruoho Remove the namespace scopes.

These are neither used nor useful beyond the parser and interpreter.

ok jmcneill@, joerg@
 1.41 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.40 31-Jan-2010  jruoho branches: 1.40.2;
Add dynamic debug options for ACPI_DEBUG kernels.

ok jmcneill@, pooka@, pgoyette@
 1.39 18-Jan-2010  jruoho Introduce acpi_eval_reference_handle() --

an utility function to evaluate reference handles from package elements.

ok jmcneill@, pgoyette@
 1.38 29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.37 28-Nov-2009  cegger u_int32_t -> uint32_t
struct device * -> device_t
 1.36 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.35 08-Apr-2009  dyoung Refactor slightly to create acpi_rescan(), a hook for rescanning the
devices that attach at acpi(4).

Begin deriving an acpi(4) device-detachment hook, acpi_detach(), from
acpi_attach(). The code between #if 0 and #endif still needs to be
turned to the opposite calls (enables to disables, maps to unmaps,
attaches to detaches), which should be run in the opposite order.
Somebody with deep ACPI knowledge can probably finish this off without
too much trouble.
 1.34 17-Nov-2008  joerg branches: 1.34.4;
On resum-from-RAM explicitly restore PCI link device state before
reenabling interrupts. At least one BIOS doesn't do this automatically
as reported by Christoph Egger.
 1.33 15-Jul-2008  dyoung branches: 1.33.2; 1.33.4;
Introduce acpi_clear_wake_gpe() to undo acpi_set_wake_gpe().
Extract common code from acpi_clear_wake_gpe() and acpi_set_wake_gpe(),
creating acpi_wake_gpe_helper().
 1.32 27-Mar-2008  jmcneill branches: 1.32.4; 1.32.6; 1.32.8; 1.32.10;
Split device_t and softc
 1.31 09-Dec-2007  jmcneill branches: 1.31.10;
Merge jmcneill-pm branch.
 1.30 19-Oct-2007  ad branches: 1.30.4; 1.30.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.29 08-Aug-2007  cube branches: 1.29.2; 1.29.6;
Print ACPI device name in a way that Jared McNeill and I find prettier.
I like it better because I get to see the name of the device as it appears
in the DSDT, which sometimes makes sense and that way it's easier to locate
the relevant code when debugging.

E.g.:

PIC (PNP0000) [AT Interrupt Controller] at acpipcib0 not configured
DMAD (PNP0200) [AT DMA Controller] at acpipcib0 not configured
attimer0 at acpipcib0 (TMR, PNP0100): AT Timer
RTC0 (PNP0B00) [AT Real-Time Clock] at acpipcib0 not configured
pckbc0 at acpipcib0 (PS2K, PNP0303): kbd port
acpibat0 at acpi0 (BAT0, PNP0C0A-0): ACPI Battery (Control Method)
 1.28 26-Nov-2006  cube branches: 1.28.8; 1.28.18; 1.28.22;
Introduce acpi_check() to inform the caller whether the acpi driver is
still enabled, as it could have been disabled through USERCONF.

Use it in amd64 and i386 mainbus code and skip all ACPI processing in case
it is disabled.
 1.27 23-Sep-2006  fvdl Define the "broken IRQ0 override" quirk, and add it for one type of ACPI
BIOS.
 1.26 04-Jul-2006  christos branches: 1.26.4; 1.26.6;
Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.25 12-Dec-2005  cube branches: 1.25.4; 1.25.8; 1.25.16;
Move the (one liner) logic of AcpiOsGetRootPointer() out of acpica/Osd to
acpi.c and take the opportunity to create a sysctl node that contains the
address of the main ACPI table.

The name of the node, "machdep.acpi_root", is questionable but matches the
one FreeBSD has, which will make it easier to port their acpidump(8)
program.
 1.24 11-Dec-2005  christos merge ktrace-lwp.
 1.23 01-Jun-2005  drochner branches: 1.23.2;
kill the "busname" attach arg, it is not really needed
 1.22 29-May-2005  christos Sprinkle const freely and delete unnecessary casts.
 1.21 02-May-2005  kochi Merge changes for ACPI-CA 20050408
 1.20 26-May-2004  kochi ThermalZone improvement work by lha at stacken.kth.se, inspired from
FreeBSD thermal zone code. Minor style fixes and bugfixes by me.
 1.19 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.18 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.17 31-Mar-2004  tron Only call acpiec_early_attach() in "acpi.c" if the kernel is configured
to include the "acpiec" device.
 1.16 30-Mar-2004  kochi Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.15 23-Mar-2004  drochner branches: 1.15.2;
some int->ACPI_INTEGER to make it compile on amd64 again
 1.14 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.13 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.12 08-Jul-2003  itojun function prototype must not have variable name
 1.11 15-May-2003  fvdl branches: 1.11.2;
Add quirk handling to ACPI. First quirk entry is "PTLTD " rev 0x06040000,
which gives problems with PCI bus finding; the object hierarchy doesn't
match the real world for some systems, most notably SuperMicro boards.
Linux has this one blacklisted as well.
 1.10 17-Apr-2003  thorpej * Don't do the ACPI_PCI_FIXUP unless it is explicitly enabled in
the kernel config file. That code makes a total mess of any
system with multiple PCI busses.
* Rework the way buttons are handled; register them with sysmon,
and let it take the appropriate action. This lets us gracefully
shut down when the power button is pressed.
 1.9 14-Feb-2003  tshiozak - add acpi_acquire_global_lock()/acpi_release_global_lock()/
acpi_is_global_locked() functions.
AcpiGlobalLock() API should be used to acquire lock between BIOS and OS.
This API cannot be used to lock between threads of the OS side,
because this function immediately returns if the lock is already acquired
by the OS. c.f. AcpiEvAcquireGlobalLock()@evmisc.c

- make sure that acpiec driver uses above functions.

- use ACPI_ALLOCATE_BUFFER instead of twice calls of AcpiEvaluateObject(),
in acpi_eval_string()/acpi_eval_struct().
Twice AcpiEvaluateObject() calls may cause twice side effects
to ACPI machine / hardware and this may be wrong in some cases.
 1.8 28-Dec-2002  matt Make sure we record the type of irq as well as its number.
 1.7 28-Dec-2002  jmcneill Pass ISA chipset information through to ACPI devices, to allow for porting
of pnpbios(4) glue to acpi(4).
 1.6 29-Jul-2002  augustss Another part of the PCI fixup change.
 1.5 18-Jun-2002  tshiozak add MI part of ACPI sleep state transition code.
However, we have no interface to use it, and we also need device driver
support. (e.g. D2/D3 support for PCI)
 1.4 24-Mar-2002  sommerfeld branches: 1.4.2;
Add acpi_eval_struct, to evaluate a complex data structure.

#if 0-out a half-fixed acpi_eval_string() and #if 0 the only call to it.
(Previous code referenced an uninitialized local variable and couldn't
have possibly worked).
 1.3 29-Sep-2001  thorpej branches: 1.3.2; 1.3.4; 1.3.8;
- Add an acpi_evaluate_string() to evaluate string objects.
- In acpi_print(), try to evaluate the _STR object, and print
it if the device is not configured.
- Make this compile without ACPI_DEBUG, from Masanori Kanaoka.
 1.2 29-Sep-2001  thorpej Add code to parse ACPI bus resources.
 1.1 28-Sep-2001  thorpej Add some basic ACPI probing framework. This is far from complete,
it is merely a work in progress.
 1.3.8.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.8.1 29-Sep-2001  thorpej file acpivar.h was added on branch kqueue on 2002-01-10 19:52:54 +0000
 1.3.4.6 29-Dec-2002  thorpej Sync with HEAD.
 1.3.4.5 01-Aug-2002  nathanw Catch up to -current.
 1.3.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.3.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.3.4.1 29-Sep-2001  nathanw file acpivar.h was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.3.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.3.2.1 29-Sep-2001  fvdl file acpivar.h was added on branch thorpej-devvp on 2001-10-01 12:44:17 +0000
 1.4.2.2 29-Aug-2002  gehenna catch up with -current.
 1.4.2.1 15-Jul-2002  gehenna catch up with -current.
 1.11.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.2.2 28-Apr-2004  jmc Pullup rev 1.17 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.15.2.1 28-Apr-2004  jmc Pullup rev 1.16 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.23.2.5 21-Jan-2008  yamt sync with head
 1.23.2.4 27-Oct-2007  yamt sync with head.
 1.23.2.3 03-Sep-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.25.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.25.8.1 11-Aug-2006  yamt sync with head
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.6.2 10-Dec-2006  yamt sync with head.
 1.26.6.1 22-Oct-2006  yamt sync with head
 1.26.4.2 12-Jan-2007  ad Sync with head.
 1.26.4.1 18-Nov-2006  ad Sync with head.
 1.28.22.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.28.22.3 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.28.22.2 02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.28.22.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.28.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.28.8.2 23-Oct-2007  ad Sync with head.
 1.28.8.1 20-Aug-2007  ad Sync with HEAD.
 1.29.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.29.2.2 09-Jan-2008  matt sync with HEAD
 1.29.2.1 06-Nov-2007  matt sync with HEAD
 1.30.6.1 11-Dec-2007  yamt sync with head.
 1.30.4.1 26-Dec-2007  ad Sync with head.
 1.31.10.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.31.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.32.10.1 19-Oct-2008  haad Sync with HEAD.
 1.32.8.1 18-Jul-2008  simonb Sync with head.
 1.32.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.4.5 09-Oct-2010  yamt sync with head
 1.32.4.4 11-Aug-2010  yamt sync with head.
 1.32.4.3 11-Mar-2010  yamt sync with head
 1.32.4.2 16-May-2009  yamt sync with head
 1.32.4.1 04-May-2009  yamt sync with head.
 1.33.4.1 25-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #125):
sys/arch/x86/acpi/acpi_wakeup.c: revision 1.11
sys/dev/acpi/acpi_pci_link.c: revision 1.14
sys/dev/acpi/acpivar.h: revision 1.34
On resum-from-RAM explicitly restore PCI link device state before
reenabling interrupts. At least one BIOS doesn't do this automatically
as reported by Christoph Egger.
 1.33.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.33.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.40.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.40.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.40.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.40.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.43.2.3 05-Mar-2011  rmind sync with head
 1.43.2.2 03-Jul-2010  rmind sync with head
 1.43.2.1 30-May-2010  rmind sync with head
 1.66.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.67.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.69.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.73.30.1 09-Jul-2016  skrll Sync with HEAD
 1.73.12.1 03-Dec-2017  jdolecek update from HEAD
 1.74.16.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.74.16.2 20-Oct-2018  pgoyette Sync with head
 1.74.16.1 21-May-2018  pgoyette Sync with HEAD
 1.75.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.75.2.1 10-Jun-2019  christos Sync with HEAD
 1.81.2.1 17-Jan-2020  ad Sync with head.
 1.82.6.2 03-Apr-2021  thorpej Sync with HEAD.
 1.82.6.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.85.6.1 31-May-2021  cjep sync with head
 1.85.4.1 13-May-2021  thorpej Sync with HEAD.
 1.89.4.1 25-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #639):

sys/dev/acpi/acpivar.h: revision 1.90
sys/dev/acpi/files.acpi: revision 1.129
sys/dev/acpi/acpi.c: revision 1.299
sys/dev/acpi/files.acpi: revision 1.130

acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.
Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046

acpi(4): Make apeibus actually work as an iattr.
PR kern/58046
 1.90.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 07-Dec-2020  jmcneill Fix 32-bit build.
 1.5 15-Apr-2020  jmcneill branches: 1.5.2;
Use 64-bit DMA if available
 1.4 16-Nov-2018  jmcneill branches: 1.4.4; 1.4.12;
Use acpi_intr_establish
 1.3 15-Oct-2018  jdolecek branches: 1.3.2;
revert previous, arm doesn't have intr_establish_xname()

pointed out by jmcneill
 1.2 15-Oct-2018  jdolecek use intr_establish_xname()
 1.1 12-Oct-2018  jmcneill Add ahcisata at acpi glue
 1.3.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.3.2.2 20-Oct-2018  pgoyette Sync with head
 1.3.2.1 15-Oct-2018  pgoyette file ahcisata_acpi.c was added on branch pgoyette-compat on 2018-10-20 06:58:30 +0000
 1.4.12.1 20-Apr-2020  bouyer Sync with HEAD
 1.4.4.3 21-Apr-2020  martin Sync with HEAD
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 16-Nov-2018  christos file ahcisata_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.5.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.31 19-Mar-2010  cnst Remove aiboost(4) as obsolete and redundant since the introduction of aibs(4).

http://mail-index.netbsd.org/tech-kern/2010/03/06/msg007458.html

Reviewed by <pgoyette>, <cegger>, <jruoho>, <tech-kern>.
 1.30 05-Mar-2010  jruoho branches: 1.30.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.29 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.28 18-Feb-2010  pgoyette Enhance DPRINTF to use AcpiFormatException as suggested in PR kern/40130
 1.27 16-Sep-2009  mlelstv branches: 1.27.2;
Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.26 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.25 20-May-2008  cegger branches: 1.25.12;
correct wrong comment: envsys(4) wants uK
 1.24 21-Apr-2008  xtraeme branches: 1.24.2; 1.24.4;
Misc cleanups from Geoff Wing.
 1.23 17-Apr-2008  xtraeme branches: 1.23.2;
Make this work again, now that ACPI_TYPE_ANY returns NULL objects
after recent ACPICA update.

Applied patch from Geoff Wing on current-users@.
 1.22 01-Feb-2008  xtraeme branches: 1.22.6;
aiboost_getcomp: use Package.Count to allocate and iterate over
the elements rather than Integer.Value, which sometimes doesn't
match and gives unexpected results on the error path.

This fixes the kmem_poison_check on DEBUG kernels (finally). Patch
by Fukumoto Atsushi. Thanks!
 1.21 29-Jan-2008  xtraeme Pass the same size to kmem_alloc(9) and kmem_free(9), this fixes
the kmem_poison_check panic on DEBUG kernels.
 1.20 13-Dec-2007  xtraeme Check return value of pmf_device_register(), pointed out by joerg.

Looks like the pmf(9) manpage declared it as void and not bool...
 1.19 10-Dec-2007  xtraeme Register to the pmf(9) framework and fix an error path.
 1.18 16-Nov-2007  xtraeme branches: 1.18.2; 1.18.4; 1.18.6;
Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.17 05-Nov-2007  xtraeme Missed a struct device -> device_t, found by joerg.
 1.16 04-Nov-2007  xtraeme branches: 1.16.2;
- Allocate the envsys_data_t structures dynamically, removing the
max limit.
- Use kmem(9) to allocate the memory.
 1.15 03-Nov-2007  xtraeme Follow plunky's changes:

- Use CFATTACH_DECL_NEW and remove struct device from the softc.
- Use aprint_*_dev().
- Use aiboost_refresh_sensors() for sme_gtredata.
 1.14 13-Oct-2007  xtraeme branches: 1.14.2;
Use a mutex(9) rather than a rwlock(9), it's cheaper.
 1.13 30-Aug-2007  xtraeme branches: 1.13.2; 1.13.4;
Use a rwlock(9) to protect access while refreshing data in
aiboost_get_value().
 1.12 29-Jul-2007  xtraeme branches: 1.12.4; 1.12.6; 1.12.8;
Fix up some comments.
 1.11 16-Jul-2007  xtraeme branches: 1.11.2;
aiboost_refresh_sensors: if value returned is 0, invalidate the sensor too.
 1.10 12-Jul-2007  xtraeme If the method returned invalid data mark the sensor as invalid and
return, but if next time data is ok mark the sensor again as valid.
 1.9 02-Jul-2007  xtraeme branches: 1.9.2;
aiboost_refresh_sensors: initialize j before using it, to make this
build with AIBOOST_DEBUG.
 1.8 02-Jul-2007  xtraeme aiboost_refresh_sensors:

- use the edata pointer rather than using the softc's edata array.
- if aiboost_get_value() couldn't get a proper value, invalidate the sensor.
 1.7 01-Jul-2007  xtraeme aiboost_refresh_sensors: when refreshing a fan sensor, use the sum
of aitemp->num + aivolt->num sensors as index.

Closes PR kern/36589.
 1.6 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.5 19-Apr-2007  xtraeme Cosmetics: remove useless comments, unneded headers, wrap a long line.
 1.4 26-Mar-2007  xtraeme branches: 1.4.2;
Fix a typo getting the fan values, it was using incorrect uid.
 1.3 26-Mar-2007  xtraeme aiboost_getcomp: fix memcpy and use the length provided by the ACPI Object.
aiboost_refresh_sensors: fix a debugging printf.
 1.2 18-Mar-2007  xtraeme branches: 1.2.2;
typo.
 1.1 14-Mar-2007  xtraeme branches: 1.1.2;
Rename acpi_aiboost to aiboost, suggested by cube.
 1.1.2.1 29-Mar-2007  reinoud Pullup to -current
 1.2.2.4 07-May-2007  yamt sync with head.
 1.2.2.3 15-Apr-2007  yamt sync with head.
 1.2.2.2 24-Mar-2007  yamt sync with head.
 1.2.2.1 18-Mar-2007  yamt file aiboost.c was added on branch yamt-idlelwp on 2007-03-24 14:55:19 +0000
 1.4.2.7 23-Oct-2007  ad Sync with head.
 1.4.2.6 09-Oct-2007  ad Sync with head.
 1.4.2.5 20-Aug-2007  ad Sync with HEAD.
 1.4.2.4 15-Jul-2007  ad Sync with head.
 1.4.2.3 27-May-2007  ad Sync with head.
 1.4.2.2 10-Apr-2007  ad Sync with head.
 1.4.2.1 26-Mar-2007  ad file aiboost.c was added on branch vmlocking on 2007-04-10 13:24:21 +0000
 1.9.2.2 11-Jul-2007  mjf Sync with head.
 1.9.2.1 02-Jul-2007  mjf file aiboost.c was added on branch mjf-ufs-trans on 2007-07-11 20:05:09 +0000
 1.11.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.11.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.12.8.2 29-Jul-2007  xtraeme Fix up some comments.
 1.12.8.1 29-Jul-2007  xtraeme file aiboost.c was added on branch matt-mips64 on 2007-07-29 15:44:25 +0000
 1.12.6.3 23-Mar-2008  matt sync with HEAD
 1.12.6.2 09-Jan-2008  matt sync with HEAD
 1.12.6.1 06-Nov-2007  matt sync with HEAD
 1.12.4.5 21-Nov-2007  joerg Sync with HEAD.
 1.12.4.4 06-Nov-2007  joerg Sync with HEAD.
 1.12.4.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.12.4.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.4.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.13.4.1 14-Oct-2007  yamt sync with head.
 1.13.2.7 04-Feb-2008  yamt sync with head.
 1.13.2.6 21-Jan-2008  yamt sync with head
 1.13.2.5 07-Dec-2007  yamt sync with head
 1.13.2.4 15-Nov-2007  yamt sync with head.
 1.13.2.3 27-Oct-2007  yamt sync with head.
 1.13.2.2 03-Sep-2007  yamt sync with head.
 1.13.2.1 30-Aug-2007  yamt file aiboost.c was added on branch yamt-lazymbuf on 2007-09-03 14:33:20 +0000
 1.14.2.2 18-Nov-2007  bouyer Sync with HEAD
 1.14.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.16.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.16.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.16.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.18.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.18.4.1 11-Dec-2007  yamt sync with head.
 1.18.2.1 26-Dec-2007  ad Sync with head.
 1.22.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.2.2 04-Jun-2008  yamt sync with head
 1.23.2.1 18-May-2008  yamt sync with head.
 1.24.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.2.4 11-Aug-2010  yamt sync with head.
 1.24.2.3 11-Mar-2010  yamt sync with head
 1.24.2.2 16-May-2009  yamt sync with head
 1.24.2.1 04-May-2009  yamt sync with head.
 1.25.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.30.2.1 30-May-2010  rmind sync with head
 1.7 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.6 01-Jun-2017  chs branches: 1.6.24;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.5 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.4 14-Aug-2012  jruoho branches: 1.4.2; 1.4.16;
Collect rnd(9) entropy from coretemp(4), acpibat(4), aibs(4), hpacel(4),
thinkpad(4), and aps(4).
 1.3 06-Aug-2011  jruoho branches: 1.3.2;
If both the new and the old methods are available, prefer the old ones, as
the new ones may not be functional in this case.
 1.2 20-Jun-2011  pgoyette branches: 1.2.2;
Initialize sensors states before registering.
 1.1 12-Jun-2011  jruoho Rewrite the aibs(4) driver in order to support new models. Draws from the
revision 1.6 (claudio@) of the OpenBSD's equivalent driver. Tested by mrg@.
 1.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 20-Jun-2011  cherry file aibs_acpi.c was added on branch cherry-xenmp on 2011-06-23 14:19:57 +0000
 1.3.2.1 30-Oct-2012  yamt sync with head
 1.4.16.2 28-Aug-2017  skrll Sync with HEAD
 1.4.16.1 06-Jun-2015  skrll Sync with HEAD
 1.4.2.1 03-Dec-2017  jdolecek update from HEAD
 1.6.24.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 18-Dec-2022  reinoud Add amdsmn(4) and amdccp(4) power management stubs.
 1.5 29-Jan-2021  thorpej branches: 1.5.18;
Use acpi_compatible_match().
 1.4 07-Dec-2020  jmcneill Fix 32-bit build.
 1.3 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.2 21-Oct-2018  jmcneill branches: 1.2.4; 1.2.14;
Fix boot messages
 1.1 19-Oct-2018  jakllsch branches: 1.1.2;
Add amdccp(4) driver for AMD Cryptographic Coprocessor, as found on the
A11xx Opterons. Driver currently provides RNG service only.
 1.1.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.2 20-Oct-2018  pgoyette Sync with head
 1.1.2.1 19-Oct-2018  pgoyette file amdccp_acpi.c was added on branch pgoyette-compat on 2018-10-20 06:58:30 +0000
 1.2.14.2 03-Apr-2021  thorpej Sync with HEAD.
 1.2.14.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 21-Oct-2018  christos file amdccp_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.5.18.1 19-Dec-2022  martin Pull up following revision(s) (requested by reinoud in ticket #3):

sys/dev/pci/amdccp_pci.c: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.15
sys/dev/acpi/amdccp_acpi.c: revision 1.6
sys/dev/fdt/amdccp_fdt.c: revision 1.7

Add amdsmn(4) and amdccp(4) power management stubs.
 1.3 02-Mar-2025  riastradh branches: 1.3.4;
amdgpio(4): Fix whitespace nits.

No functional change intended.
 1.2 26-Feb-2025  jmcneill amdgpio: Support GPIO_INTR_POS_EDGE
 1.1 26-Feb-2025  ryoon Add amdgpio(4) device driver for AMD GPIO found on some HP laptops

This device driver enables power button and trackpad on
HP Envy 13 ay1000 and HP Envy 14 fa0000.
Touchscreen and stylus have no decodable HID descriptors and not enabled.

Based on qcomgpio(4) and OpenBSD's amdgpio(4).

Add the following to your kernel configuration file:

amdgpio* at acpi?
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 02-Mar-2025  perseant file amdgpio.c was added on branch perseant-exfatfs on 2025-08-02 05:56:32 +0000
 1.1 26-Feb-2025  ryoon branches: 1.1.4;
Add amdgpio(4) device driver for AMD GPIO found on some HP laptops

This device driver enables power button and trackpad on
HP Envy 13 ay1000 and HP Envy 14 fa0000.
Touchscreen and stylus have no decodable HID descriptors and not enabled.

Based on qcomgpio(4) and OpenBSD's amdgpio(4).

Add the following to your kernel configuration file:

amdgpio* at acpi?
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 26-Feb-2025  perseant file amdgpioreg.h was added on branch perseant-exfatfs on 2025-08-02 05:56:32 +0000
 1.9 27-Oct-2024  riastradh apei(4): Print non-fatal uncorrectable PCIe AER errors as intended.

Noted by rillig@.

PR kern/58775: apei(4) spamming console
 1.8 27-Oct-2024  riastradh apei(4): Print PCIe cap and AER extcap registers in 32-bit chunks.

PR kern/58775: apei(4) spamming console
 1.7 27-Oct-2024  riastradh apei(4): Print PCIe errors.

PR kern/58775: apei(4) spamming console
 1.6 27-Oct-2024  riastradh apei(4): Add section numbering in comments on error types.

This will make it easier to keep the sections sorted by the spec's
section numbers when we add more.

Preparation for:

PR kern/58775: apei(4) spamming console
 1.5 27-Oct-2024  riastradh apei(4): Rate-limit error reports to console.

For each severity level (corrected, uncorrectable/recoverable,
uncorrectable/fatal, other), print at most one report per minute,
and, if any reports were suppressed, the number of reports that had
been suppressed since the last one, up to a maximum of 2^32 - 1.

PR kern/58775: apei(4) spamming console
 1.4 27-Oct-2024  riastradh apei(4): Fix format of CPER UUID strings to match UEFI spec.

PR kern/58775: apei(4) spamming console
 1.3 26-Mar-2024  rillig branches: 1.3.2; 1.3.4;
apei: fix typos in comments
 1.2 23-Mar-2024  riastradh apei(4): Make sure to initialize *fatalp in apei_gesb_report.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.3.4.3 01-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #994):

sys/dev/acpi/apei_cper.h: revision 1.3
sys/dev/acpi/apei_cper.h: revision 1.4
sys/dev/acpi/apei_cper.h: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.4
sys/dev/acpi/apei_hest.c: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.4
sys/dev/acpi/apei.c: revision 1.5
sys/dev/acpi/apei.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.7
sys/dev/acpi/apei.c: revision 1.8
sys/dev/acpi/apei.c: revision 1.9

apei(4): Paranoia: Clamp multiplication to SIZE_MAX too.

This makes it clear that the result is guaranteed not to overflow
size_t. Previously it was only implied because on all NetBSD ports,
SIZE_MAX > INT32_MAX, but let's make it clearer instead of relying on
tacitly on that assumption.

No functional change intended.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Use __SIMPLELOCK_UNLOCKED to initialize __cpu_simple_lock_t.
Zero-initialization is wrong on some architectures. While it happens
to work on x86 (and this is under ifdef x86), let's just do the right
thing to make it clearer.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Paranoia: Don't schedule callout if poll interval is zero.
Prompted by making sure there isn't a runaway callout in:
PR kern/58775: apei(4) spamming console


apei(4): Fix format of CPER UUID strings to match UEFI spec.
PR kern/58775: apei(4) spamming console
apei(4): Rate-limit error reports to console.

For each severity level (corrected, uncorrectable/recoverable,
uncorrectable/fatal, other), print at most one report per minute,
and, if any reports were suppressed, the number of reports that had
been suppressed since the last one, up to a maximum of 2^32 - 1.
PR kern/58775: apei(4) spamming console


apei(4): Fix comments citing structure member names.
No functional change intended.
In preparation for further changes for:
PR kern/58775: apei(4) spamming console


apei(4): Add section numbering in comments on error types.
This will make it easier to keep the sections sorted by the spec's
section numbers when we add more.
Preparation for:
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe errors.
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe cap and AER extcap registers in 32-bit chunks.
PR kern/58775: apei(4) spamming console


apei(4): Print non-fatal uncorrectable PCIe AER errors as intended.
Noted by rillig@.
PR kern/58775: apei(4) spamming console
 1.3.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.3.4.1 26-Mar-2024  martin file apei.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_bert.c was added on branch netbsd-10 on 2024-10-09 13:00:10 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_bertvar.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.5 27-Oct-2024  riastradh apei(4): Print PCIe errors.

PR kern/58775: apei(4) spamming console
 1.4 27-Oct-2024  riastradh apei(4): Add section numbering in comments on error types.

This will make it easier to keep the sections sorted by the spec's
section numbers when we add more.

Preparation for:

PR kern/58775: apei(4) spamming console
 1.3 27-Oct-2024  riastradh apei(4): Fix comments citing structure member names.

No functional change intended.

In preparation for further changes for:

PR kern/58775: apei(4) spamming console
 1.2 26-Mar-2024  rillig branches: 1.2.2; 1.2.4;
apei: fix typos in comments and snprintb bitfmt
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.2.4.3 01-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #994):

sys/dev/acpi/apei_cper.h: revision 1.3
sys/dev/acpi/apei_cper.h: revision 1.4
sys/dev/acpi/apei_cper.h: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.4
sys/dev/acpi/apei_hest.c: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.4
sys/dev/acpi/apei.c: revision 1.5
sys/dev/acpi/apei.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.7
sys/dev/acpi/apei.c: revision 1.8
sys/dev/acpi/apei.c: revision 1.9

apei(4): Paranoia: Clamp multiplication to SIZE_MAX too.

This makes it clear that the result is guaranteed not to overflow
size_t. Previously it was only implied because on all NetBSD ports,
SIZE_MAX > INT32_MAX, but let's make it clearer instead of relying on
tacitly on that assumption.

No functional change intended.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Use __SIMPLELOCK_UNLOCKED to initialize __cpu_simple_lock_t.
Zero-initialization is wrong on some architectures. While it happens
to work on x86 (and this is under ifdef x86), let's just do the right
thing to make it clearer.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Paranoia: Don't schedule callout if poll interval is zero.
Prompted by making sure there isn't a runaway callout in:
PR kern/58775: apei(4) spamming console


apei(4): Fix format of CPER UUID strings to match UEFI spec.
PR kern/58775: apei(4) spamming console
apei(4): Rate-limit error reports to console.

For each severity level (corrected, uncorrectable/recoverable,
uncorrectable/fatal, other), print at most one report per minute,
and, if any reports were suppressed, the number of reports that had
been suppressed since the last one, up to a maximum of 2^32 - 1.
PR kern/58775: apei(4) spamming console


apei(4): Fix comments citing structure member names.
No functional change intended.
In preparation for further changes for:
PR kern/58775: apei(4) spamming console


apei(4): Add section numbering in comments on error types.
This will make it easier to keep the sections sorted by the spec's
section numbers when we add more.
Preparation for:
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe errors.
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe cap and AER extcap registers in 32-bit chunks.
PR kern/58775: apei(4) spamming console


apei(4): Print non-fatal uncorrectable PCIe AER errors as intended.
Noted by rillig@.
PR kern/58775: apei(4) spamming console
 1.2.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.2.4.1 26-Mar-2024  martin file apei_cper.h was added on branch netbsd-10 on 2024-10-09 13:00:10 +0000
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 28-Mar-2024  riastradh branches: 1.7.4;
apei(4): Fix uninitialized stack access in error branch.

PR kern/58046
 1.6 26-Mar-2024  rillig apei: fix typos in comments
 1.5 22-Mar-2024  riastradh apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.

PR kern/58046
 1.4 22-Mar-2024  riastradh apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.3 21-Mar-2024  riastradh apei(4): Note some TODOs for EINJ and HEST.

No functional change intended, comments only.

PR kern/58046
 1.2 21-Mar-2024  riastradh apei(4): Fix parsing checks for TRIGGER_ERROR action table.

The TableSize is size of the header plus the body, not just the body.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.7.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.7.4.1 28-Mar-2024  martin file apei_einj.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_einjvar.h was added on branch netbsd-10 on 2024-10-09 13:00:10 +0000
 1.4 09-Oct-2025  rillig acpi: print symbolic constants for error log attributes

In NetBSD 10, snprintb silently skipped the invalid conversions.

https://uefi.org/specs/ACPI/6.6/18_Platform_Error_Interfaces.html
 1.3 22-Mar-2024  riastradh branches: 1.3.4;
apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.

PR kern/58046
 1.2 22-Mar-2024  riastradh apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.3.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.3.4.1 22-Mar-2024  martin file apei_erst.c was added on branch netbsd-10 on 2024-10-09 13:00:12 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_erstvar.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_hed.h was added on branch netbsd-10 on 2024-10-09 13:00:12 +0000
 1.7 05-Jan-2025  andvar fix various typos in comments.
 1.6 27-Oct-2024  riastradh apei(4): Paranoia: Don't schedule callout if poll interval is zero.

Prompted by making sure there isn't a runaway callout in:

PR kern/58775: apei(4) spamming console
 1.5 27-Oct-2024  riastradh apei(4): Use __SIMPLELOCK_UNLOCKED to initialize __cpu_simple_lock_t.

Zero-initialization is wrong on some architectures. While it happens
to work on x86 (and this is under ifdef x86), let's just do the right
thing to make it clearer.

Noticed while preparing for:

PR kern/58775: apei(4) spamming console
 1.4 27-Oct-2024  riastradh apei(4): Paranoia: Clamp multiplication to SIZE_MAX too.

This makes it clear that the result is guaranteed not to overflow
size_t. Previously it was only implied because on all NetBSD ports,
SIZE_MAX > INT32_MAX, but let's make it clearer instead of relying on
tacitly on that assumption.

No functional change intended.

Noticed while preparing for:

PR kern/58775: apei(4) spamming console
 1.3 21-Mar-2024  riastradh branches: 1.3.2; 1.3.4;
apei(4): Note some TODOs for EINJ and HEST.

No functional change intended, comments only.

PR kern/58046
 1.2 20-Mar-2024  riastradh apei(4): Pacify -Wsign-compare.

Assert that the parsing made forward progress too while here.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.3.4.3 01-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #994):

sys/dev/acpi/apei_cper.h: revision 1.3
sys/dev/acpi/apei_cper.h: revision 1.4
sys/dev/acpi/apei_cper.h: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.4
sys/dev/acpi/apei_hest.c: revision 1.5
sys/dev/acpi/apei_hest.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.4
sys/dev/acpi/apei.c: revision 1.5
sys/dev/acpi/apei.c: revision 1.6
sys/dev/acpi/apei.c: revision 1.7
sys/dev/acpi/apei.c: revision 1.8
sys/dev/acpi/apei.c: revision 1.9

apei(4): Paranoia: Clamp multiplication to SIZE_MAX too.

This makes it clear that the result is guaranteed not to overflow
size_t. Previously it was only implied because on all NetBSD ports,
SIZE_MAX > INT32_MAX, but let's make it clearer instead of relying on
tacitly on that assumption.

No functional change intended.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Use __SIMPLELOCK_UNLOCKED to initialize __cpu_simple_lock_t.
Zero-initialization is wrong on some architectures. While it happens
to work on x86 (and this is under ifdef x86), let's just do the right
thing to make it clearer.

Noticed while preparing for:
PR kern/58775: apei(4) spamming console


apei(4): Paranoia: Don't schedule callout if poll interval is zero.
Prompted by making sure there isn't a runaway callout in:
PR kern/58775: apei(4) spamming console


apei(4): Fix format of CPER UUID strings to match UEFI spec.
PR kern/58775: apei(4) spamming console
apei(4): Rate-limit error reports to console.

For each severity level (corrected, uncorrectable/recoverable,
uncorrectable/fatal, other), print at most one report per minute,
and, if any reports were suppressed, the number of reports that had
been suppressed since the last one, up to a maximum of 2^32 - 1.
PR kern/58775: apei(4) spamming console


apei(4): Fix comments citing structure member names.
No functional change intended.
In preparation for further changes for:
PR kern/58775: apei(4) spamming console


apei(4): Add section numbering in comments on error types.
This will make it easier to keep the sections sorted by the spec's
section numbers when we add more.
Preparation for:
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe errors.
PR kern/58775: apei(4) spamming console


apei(4): Print PCIe cap and AER extcap registers in 32-bit chunks.
PR kern/58775: apei(4) spamming console


apei(4): Print non-fatal uncorrectable PCIe AER errors as intended.
Noted by rillig@.
PR kern/58775: apei(4) spamming console
 1.3.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.3.4.1 21-Mar-2024  martin file apei_hest.c was added on branch netbsd-10 on 2024-10-09 13:00:10 +0000
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_hestvar.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.4 22-Mar-2024  riastradh branches: 1.4.4;
apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.3 22-Mar-2024  riastradh apei(4): Plug memory leak on teardown of instruction interpreter.

PR kern/58046
 1.2 20-Mar-2024  riastradh apei(4): Tweak some comments about the APEI interpreter language.

No functional change intended.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.4.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.4.4.1 22-Mar-2024  martin file apei_interp.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.2 22-Mar-2024  riastradh branches: 1.2.4;
apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.2.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.2.4.1 22-Mar-2024  martin file apei_interp.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.4 22-Mar-2024  riastradh branches: 1.4.4;
apei(4): Allow pre-mapping I/O registers too.

PR kern/58046
 1.3 22-Mar-2024  riastradh apei(4): Fix register chunk counting.

Now it will actually read and write the registers!

Have been updating and reloading the wrong module to test this, oops.

PR kern/58046
 1.2 22-Mar-2024  riastradh apei(4): Fix indexing of multi-unit register access.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.4.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.4.4.1 22-Mar-2024  martin file apei_mapreg.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apei_mapreg.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.3 22-Mar-2024  riastradh branches: 1.3.4;
apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.

PR kern/58046
 1.2 22-Mar-2024  riastradh apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.3.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.3.4.1 22-Mar-2024  martin file apei_reg.c was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.3 22-Mar-2024  riastradh branches: 1.3.4;
apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.

PR kern/58046
 1.2 22-Mar-2024  riastradh apei(4): Pre-map registers when compiling interpreter.

This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.

Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.

PR kern/58046
 1.1 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.3.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.3.4.1 22-Mar-2024  martin file apei_reg.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.1 20-Mar-2024  riastradh branches: 1.1.4;
apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.1.4.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.1.4.1 20-Mar-2024  martin file apeivar.h was added on branch netbsd-10 on 2024-10-09 13:00:11 +0000
 1.5 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.4 22-May-2017  riastradh branches: 1.4.24;
Reassign my copyright to TNF.
 1.3 01-Apr-2014  riastradh branches: 1.3.4; 1.3.6; 1.3.10; 1.3.12;
Fix unused variable warning in non-modular apple_smc build.
 1.2 01-Apr-2014  riastradh Rework Apple SMC attachment goo and split into multiple modules.

The four modules are apple_smc for the core functions, apple_smc_acpi
for attachment at acpi, and apple_smc_fan & apple_smc_temp for stuff
on the SMC.

Seems like there's a lot more bookkeeping necessary to maintain
children of an applesmc device implemented by loadable modules.
Maybe there's a better way I just haven't figured out yet.
 1.1 01-Apr-2014  riastradh First draft of drivers for the Apple System Management Controller.

Device interface derived by reading the Linux driver source code and
<http:///www.parhelia.ch/blog/statics/k3_keys.html> as of 2012-12-05.

Includes support for attaching fan and temperature sensors to sysmon.
No accelerometer yet.

Compile-tested only, based on some run-testing of experiments from
userland. Module attachment is not quite finished, so it won't work
yet.
 1.3.12.1 28-Aug-2017  skrll Sync with HEAD
 1.3.10.3 03-Dec-2017  jdolecek update from HEAD
 1.3.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.10.1 01-Apr-2014  tls file apple_smc_acpi.c was added on branch tls-maxphys on 2014-08-20 00:03:35 +0000
 1.3.6.2 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.3.6.1 01-Apr-2014  yamt file apple_smc_acpi.c was added on branch yamt-pagecache on 2014-05-22 11:40:19 +0000
 1.3.4.2 18-May-2014  rmind sync with head
 1.3.4.1 01-Apr-2014  rmind file apple_smc_acpi.c was added on branch rmind-smpnet on 2014-05-18 17:45:35 +0000
 1.4.24.1 03-Apr-2021  thorpej Sync with HEAD.
 1.27 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.26 23-Apr-2015  pgoyette branches: 1.26.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.25 25-Feb-2014  pooka branches: 1.25.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.24 02-Jun-2012  dsl branches: 1.24.2; 1.24.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.23 21-Jan-2012  jmcneill branches: 1.23.2;
initialize fan sensor state to ENVSYS_SINVALID, should fix:

asus0 at acpi0 (ATKD, ASUS010-16843008)
sme_update_sensor_dictionary: can not update sensor state 0 unknown
asus0: couldn't register with envsys
 1.22 16-Feb-2011  jruoho branches: 1.22.4; 1.22.8;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.21 26-Oct-2010  jruoho branches: 1.21.2; 1.21.4;
Add support for module(9).
 1.20 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.19 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.18 05-Mar-2010  jruoho branches: 1.18.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.17 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.16 31-Jan-2010  jruoho branches: 1.16.2;
Also remove the ACPI notify handler upon detach.
 1.15 29-Jan-2010  jruoho If we failed to obtain the brightness level during suspend, do not try to
restore it with a possible garbage value during resume.
 1.14 29-Jan-2010  jruoho Replace all AcpiEvaluateObject() calls with acpi_eval_set_integer().

(As the return buffers are not used for anything, no need to make
unnecessary temporary allocations.)

Compile tested only.

ok jmcneill@
 1.13 29-Jan-2010  jruoho Fix a memory leak in the resume handler.
 1.12 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.11 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.10 04-Aug-2009  jmcneill Reading the fan speed is expensive, so set the undocumented SME_POLL_ONLY
flag on this sensor to ensure that the data is only refreshed on demand.
 1.9 03-Aug-2009  jmcneill don't call asus_sysctl_setup from asus_init because that is called from
the resume handler, instead call it directly from asus_attach
 1.8 03-Aug-2009  jmcneill add missing return, silences 'failed to add sysctl nodes. (0)' message when
setup was successful
 1.7 03-Aug-2009  jmcneill - add experimental cpu fan/voltage switching support (sysctl hw.asus0.*)
- add fan sensor
- rename asus_softc_t -> struct asus_softc
- add detach method
- update copyright for 2009
 1.6 21-Sep-2008  jmcneill branches: 1.6.4; 1.6.12;
Remember previous display brightness across suspend/resume; now we don't
need X to restore the display for us.
 1.5 14-May-2008  jmcneill branches: 1.5.4;
Fix memory leak on attach/resume.
 1.4 05-May-2008  jmcneill branches: 1.4.2;
Use 2-clause license.
 1.3 23-Apr-2008  jmcneill branches: 1.3.2;
s/struct cfdata */cfdata_t/
 1.2 31-Mar-2008  xtraeme branches: 1.2.2; 1.2.4;
Remove useless returns at the end of void functions.
 1.1 31-Mar-2008  jmcneill Add ASUS ACPI hotkey driver, as found in the Eee PC.
 1.2.4.1 18-May-2008  yamt sync with head.
 1.2.2.4 28-Sep-2008  mjf Sync with HEAD.
 1.2.2.3 02-Jun-2008  mjf Sync with HEAD.
 1.2.2.2 03-Apr-2008  mjf Sync with HEAD.
 1.2.2.1 31-Mar-2008  mjf file asus_acpi.c was added on branch mjf-devfs2 on 2008-04-03 12:42:37 +0000
 1.3.2.5 11-Aug-2010  yamt sync with head.
 1.3.2.4 11-Mar-2010  yamt sync with head
 1.3.2.3 19-Aug-2009  yamt sync with head.
 1.3.2.2 04-May-2009  yamt sync with head.
 1.3.2.1 16-May-2008  yamt sync with head.
 1.4.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.4.1 19-Oct-2008  haad Sync with HEAD.
 1.6.12.1 21-Apr-2010  matt sync to netbsd-5
 1.6.4.4 30-Aug-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #891):
sys/dev/acpi/asus_acpi.c: revision 1.10
Reading the fan speed is expensive, so set the undocumented SME_POLL_ONLY
flag on this sensor to ensure that the data is only refreshed on demand.
 1.6.4.3 30-Aug-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #891):
sys/dev/acpi/asus_acpi.c: revision 1.9
don't call asus_sysctl_setup from asus_init because that is called from
the resume handler, instead call it directly from asus_attach
 1.6.4.2 30-Aug-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #891):
sys/dev/acpi/asus_acpi.c: revision 1.8
add missing return, silences 'failed to add sysctl nodes. (0)' message when
setup was successful
 1.6.4.1 30-Aug-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #891):
sys/dev/acpi/asus_acpi.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.54
- add experimental cpu fan/voltage switching support (sysctl hw.asus0.*)
- add fan sensor
- rename asus_softc_t -> struct asus_softc
- add detach method
- update copyright for 2009
 1.16.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.2.2 05-Mar-2011  rmind sync with head
 1.18.2.1 30-May-2010  rmind sync with head
 1.21.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.21.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.22.8.1 18-Feb-2012  mrg merge to -current.
 1.22.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.22.4.2 30-Oct-2012  yamt sync with head
 1.22.4.1 17-Apr-2012  yamt sync with head
 1.23.2.1 12-Jun-2012  riz Pull up following revision(s) (requested by dsl in ticket #306):
sys/kern/vfs_bio.c: revision 1.238
sys/dev/bluetooth/bcsp.c: revision 1.21
sys/dev/acpi/asus_acpi.c: revision 1.24
sys/miscfs/syncfs/sync_subr.c: revision 1.48
Some calls to sysctl_createv() have mismatches betwwen the data type
and the CTLTYPE_xxx flags.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
The vm.bufmem_lowater (etc) sysctls needs to be processed with a
64bit temporary value on 64bit systems.
Fixes PR kern/46536.
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.2 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.6.1 06-Jun-2015  skrll Sync with HEAD
 1.26.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17 12-Jun-2011  jruoho Rewrite the aibs(4) driver in order to support new models. Draws from the
revision 1.6 (claudio@) of the OpenBSD's equivalent driver. Tested by mrg@.
 1.16 16-Feb-2011  jruoho branches: 1.16.2;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.15 26-Oct-2010  jruoho branches: 1.15.2; 1.15.4;
Use kmem(9) instead of malloc(9).
 1.14 26-Oct-2010  jruoho Refactor slightly and bump WARNS to 4.
 1.13 25-Oct-2010  jruoho Add support for module(9).
 1.12 28-Jul-2010  jruoho Remove leftovers from the aiboost(4) removal.
 1.11 14-Mar-2010  pgoyette branches: 1.11.2; 1.11.4;
Remove setting of edata->monitor since that member no longer exists.
 1.10 08-Mar-2010  cnst branches: 1.10.2;
register aibs(4) with pmf(9) to quiet the latter down; reported Dieter Roelants
 1.9 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.8 04-Mar-2010  jruoho Fix ACPI_DEBUG build failures reported by Greg A. Woods.
 1.7 04-Mar-2010  jruoho Provide the _COMPONENT definition and use ACPI_FREE(x) instead of
AcpiOsFree(). If the memory tracking of ACPICA is enabled, the latter is
guaranteed to leak memory, possibly also corrupting kernel memory.
 1.6 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.5 14-Feb-2010  pgoyette Adapt to changes in sysmon's limit structure.
 1.4 11-Feb-2010  cnst remove unnecessary AIBS_MONLIMITS ifdefs, no binary change; ok pgoyette
 1.3 09-Feb-2010  cnst * s/misformed/malformed/;

* don't change .status to anything other than SVALID and SINVALID in refresh();

suggested by <pgoyette>
 1.2 09-Feb-2010  cnst use ACPI_INTEGER and PRIx64, and check success of sensor_attach; suggested by jruoho (Jukka Ruohonen)
 1.1 09-Feb-2010  cnst New aibs(4) driver for ASUSTeK AI Booster (ACPI ATK0110) hardware monitor
with limit support.

http://thread.gmane.org/gmane.os.netbsd.devel.kernel/35654

Reviewed by <pgoyette>, <jruoho> and <tech-kern>.
 1.10.2.3 11-Aug-2010  yamt sync with head.
 1.10.2.2 11-Mar-2010  yamt sync with head
 1.10.2.1 08-Mar-2010  yamt file atk0110.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:23 +0000
 1.11.4.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.11.4.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.4.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.4.1 14-Mar-2010  uebayasi file atk0110.c was added on branch uebayasi-xip on 2010-04-30 14:43:06 +0000
 1.11.2.1 05-Mar-2011  rmind sync with head
 1.15.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.21 13-Dec-2020  martin Add missing include
 1.20 11-Dec-2020  martin Fix editor mishap in r1.18
 1.19 07-Dec-2020  jmcneill Fix 32-bit build.
 1.18 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.17 05-Mar-2010  jruoho branches: 1.17.76;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.16 17-Feb-2009  jmcneill branches: 1.16.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.15 01-Nov-2008  hans branches: 1.15.4;
Initialize sc->sc_dev before using it, and use it as argument for the
interrupt handler. Makes this work again. OK by christos.
 1.14 28-Apr-2008  martin branches: 1.14.6; 1.14.8; 1.14.10;
Remove clause 3 and 4 from TNF licenses
 1.13 16-Apr-2008  cegger branches: 1.13.2; 1.13.4;
device_t / softc split. From Hans Rosenfeld.
 1.12 15-Apr-2008  cegger device_t / softc split. From Hans Rosenfeld
 1.11 05-Apr-2008  cegger use aprint_*_dev and device_xname
 1.10 19-Oct-2007  ad branches: 1.10.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 04-Mar-2007  christos branches: 1.9.2; 1.9.14; 1.9.16; 1.9.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.8 10-Jan-2007  cube branches: 1.8.2;
Fix typoed function name. I guess not a lot of people use that driver.
 1.7 20-Feb-2006  kochi branches: 1.7.14;
use aprint_*
 1.6 11-Dec-2005  christos branches: 1.6.2; 1.6.4; 1.6.6;
merge ktrace-lwp.
 1.5 01-May-2004  kochi branches: 1.5.2; 1.5.14;
specify static where appropriate.
 1.4 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.3 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.2 10-Apr-2004  kochi whitespace nit
 1.1 25-Jan-2004  jdolecek add ACPI atppc(4) attachment; probes properly, DMA and actual transfer
not tested yet
 1.5.14.4 27-Oct-2007  yamt sync with head.
 1.5.14.3 03-Sep-2007  yamt sync with head.
 1.5.14.2 26-Feb-2007  yamt sync with head.
 1.5.14.1 21-Jun-2006  yamt sync with head.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 01-May-2004  skrll file atppc_acpi.c was added on branch ktrace-lwp on 2004-08-03 10:45:03 +0000
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 01-Mar-2006  yamt sync with head.
 1.7.14.1 12-Jan-2007  ad Sync with head.
 1.8.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.9.16.1 06-Nov-2007  matt sync with HEAD
 1.9.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.9.2.1 23-Oct-2007  ad Sync with head.
 1.10.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.10.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.3 11-Mar-2010  yamt sync with head
 1.13.4.2 04-May-2009  yamt sync with head.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.10.2 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.14.10.1 20-Nov-2008  snj branches: 1.14.10.1.4;
Pull up following revision(s) (requested by hans in ticket #91):
sys/dev/acpi/atppc_acpi.c: revision 1.15
Initialize sc->sc_dev before using it, and use it as argument for the
interrupt handler. Makes this work again. OK by christos.
 1.14.10.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.14.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.14.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.17.76.2 03-Apr-2021  thorpej Sync with HEAD.
 1.17.76.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.15 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.14 05-Mar-2010  jruoho branches: 1.14.76;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.13 07-Apr-2009  dyoung branches: 1.13.2;
During shutdown, detach attimer at acpi.
 1.12 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.11 28-Apr-2008  martin branches: 1.11.8; 1.11.10; 1.11.14; 1.11.18;
Remove clause 3 and 4 from TNF licenses
 1.10 04-Mar-2008  cube branches: 1.10.2; 1.10.4;
- Split device_t and softc for pcppi(4) and attimer(4)
- Change the attimer <-> pcppi communication using device_t so that
pcppi(4) doesn't have to know about the contents of struct attimer_softc.

XXX pcppi's childdet function is completely wrong. This has to be
XXX revisited later.
 1.9 03-Jan-2008  dyoung branches: 1.9.2; 1.9.6;
Detach attimer at acpi, attimer at isa.
 1.8 02-Jan-2008  dyoung Use device_t, device_private().
 1.7 19-Oct-2007  ad branches: 1.7.2; 1.7.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 06-Oct-2007  xtraeme branches: 1.6.2;
Use a two clause license for all the code I contributed.

The envsys code will be changed later.
 1.5 16-Nov-2006  christos branches: 1.5.8; 1.5.22; 1.5.24; 1.5.26;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 20-Feb-2006  kochi branches: 1.3.14; 1.3.16;
use aprint_*
 1.2 11-Dec-2005  christos branches: 1.2.2; 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 25-Mar-2005  cube branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add attimer(4) driver, with ISA and ACPI attachments.

attimer(4) is the new body of the part of pcppi(4) that mapped the TIMER1
register to set the pitch of the bell. It was necessary to separate them
in order to have a working ACPI attachment (as the two appear as different
devices in the ACPI structures).
 1.1.8.5 17-Mar-2008  yamt sync with head.
 1.1.8.4 21-Jan-2008  yamt sync with head
 1.1.8.3 27-Oct-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 21-Jun-2006  yamt sync with head.
 1.1.6.2 29-Apr-2005  kent sync with -current
 1.1.6.1 25-Mar-2005  kent file attimer_acpi.c was added on branch kent-audio2 on 2005-04-29 11:28:45 +0000
 1.1.4.2 01-Apr-2005  skrll Sync with HEAD.
 1.1.4.1 25-Mar-2005  skrll file attimer_acpi.c was added on branch ktrace-lwp on 2005-04-01 14:29:52 +0000
 1.1.2.2 26-Mar-2005  yamt sync with head.
 1.1.2.1 25-Mar-2005  yamt file attimer_acpi.c was added on branch yamt-km on 2005-03-26 18:19:18 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 01-Mar-2006  yamt sync with head.
 1.3.16.2 10-Dec-2006  yamt sync with head.
 1.3.16.1 22-Oct-2006  yamt sync with head
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.5.26.1 14-Oct-2007  yamt sync with head.
 1.5.24.3 23-Mar-2008  matt sync with HEAD
 1.5.24.2 09-Jan-2008  matt sync with HEAD
 1.5.24.1 06-Nov-2007  matt sync with HEAD
 1.5.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.22.1 07-Oct-2007  joerg Sync with HEAD.
 1.5.8.2 23-Oct-2007  ad Sync with head.
 1.5.8.1 09-Oct-2007  ad Sync with head.
 1.6.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.7.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.2.1 24-Mar-2008  keiichi sync with head.
 1.10.4.3 11-Mar-2010  yamt sync with head
 1.10.4.2 04-May-2009  yamt sync with head.
 1.10.4.1 16-May-2008  yamt sync with head.
 1.10.2.1 18-May-2008  yamt sync with head.
 1.11.18.1 21-Apr-2010  matt sync to netbsd-5
 1.11.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.10.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.11.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.11.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.13.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.14.76.1 03-Apr-2021  thorpej Sync with HEAD.
 1.44 23-Oct-2021  jmcneill Poll only if we don't have an IRQ resource.
 1.43 21-Oct-2021  jmcneill acpi: com: Honour the reg-shift property
 1.42 25-Mar-2021  rin Introduce sc_poll_ticks and obsolete COM_HW_POLL bit in sc_hwflags.
Polling is scheduled at every sc_poll_ticks ticks.

This is useful to work around H/W bug, by which interrupts are lost
*sometimes*; interrupt-based I/O mostly works and no need for polling
every counter ticks.
 1.41 29-Jan-2021  thorpej branches: 1.41.2;
Use acpi_compatible_match() / acpi_compatible_lookup().
 1.40 01-Mar-2019  mlelstv branches: 1.40.12;
Fix build for i386.

The acpi_intr_establish function should really take an AD_HANDLE parameter.
 1.39 26-Feb-2019  mlelstv Cast to same type as parameter. NFCI.
 1.38 24-Dec-2018  christos - fix compilation on 32 bit systems.
- wrap long lines
 1.37 21-Dec-2018  jmcneill Support Designware APB UART
 1.36 08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.35 05-May-2018  ryoon branches: 1.35.2;
Insert a whitespace after comma
 1.34 29-Mar-2017  jdolecek branches: 1.34.12;
provide intr xname
 1.33 11-Jul-2016  msaitoh branches: 1.33.2; 1.33.4;
KNF. No functional change.
 1.32 22-Jul-2010  pgoyette branches: 1.32.18; 1.32.36;
Even if there's an error in attaching the device (failure to find IRQ
resource, or I/O mapping), set-up a power management handler so we can
sleep later on.
 1.31 05-Mar-2010  jruoho branches: 1.31.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.30 12-Nov-2009  dyoung branches: 1.30.2;
Don't use com_activate(), it's going away.
 1.29 13-Jul-2009  kiyohara com@acpi supports memory space.
It tested on HP zx6000(ia64).
 1.28 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.27 14-Mar-2008  cube branches: 1.27.4; 1.27.12; 1.27.14; 1.27.18; 1.27.22;
Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend). Use proper types and ansify where appropriate.
 1.26 29-Feb-2008  dyoung Use pmf_device_register1() instead of shutdownhook_establish() to
register com_cleanup() as the shutdown hook.

Add a generic suspend routine. Suspend and resume com@isa.

Protect against dereferencing a NULL softc in comioctl().

Destroy both a mutex and a callout in com_detach().

Cosmetic: use aprint_*_dev(). Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.25 21-Dec-2007  xtraeme branches: 1.25.2; 1.25.6;
Register a pmf(9) power handler... ok jmcneill@.
 1.24 19-Oct-2007  ad branches: 1.24.4; 1.24.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 04-May-2007  christos branches: 1.23.6; 1.23.8; 1.23.12;
PR/36273: Ryo ONODERA: com_acpi.c lacks a entry for Fujitsu Serial Pen Tablet
 1.22 16-Nov-2006  christos branches: 1.22.4; 1.22.8; 1.22.10;
__unused removal on arguments; approved by core.
 1.21 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.20 14-Jul-2006  xtraeme branches: 1.20.4; 1.20.6;
Make this build again and fix the bus_space_tag_t member of the softc,
it's defined in the com_regs struct now.
 1.19 13-Jul-2006  gdamore Add an option COM_REGMAP to allow com(4) to use an array of register indices.
This allows us to convert aucom to just another com attachment, and cleanup
some code in the com_arbus.c.

Additionally, we use a common com_cleanup routine rather than having a
zillion copies of it in the attachment points.

This has been tested on a number architectures, and it has been shown to get
close to comparable performance when COM_REGMAP is defined, and comparable
when it is not defined.

Approved by core@. Fixes PR port-evbmips/32362.
 1.18 20-Feb-2006  kochi branches: 1.18.2; 1.18.10;
use aprint_*
 1.17 11-Dec-2005  rpaulo branches: 1.17.2; 1.17.4; 1.17.6;
Add NSC (NSC6001) IRDA device.
 1.16 11-Dec-2005  christos merge ktrace-lwp.
 1.15 01-May-2004  kochi branches: 1.15.12;
specify static where appropriate.
 1.14 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.13 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.12 03-Nov-2003  mycroft Add a SMC ID.
 1.11 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.10 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.9 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.8 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.7 09-Jan-2003  jdolecek branches: 1.7.2;
need to select proper IST for interrupt - IST_NONE is almost certainly not
right

this makes fdc@acpi and com@acpi actually work on my machine; lpt@acpi
change untested, but should be same as fdc and com
 1.6 28-Dec-2002  jmcneill branches: 1.6.2;
Add IBM0071, until we have access to the Compat Ids.
 1.5 28-Dec-2002  jmcneill In com_acpi_attach, set sc->sc_iot unconditionally.
 1.4 28-Dec-2002  matt Fix an uninitialized variable.
 1.3 28-Dec-2002  matt make id const, and use it for the strcmp since we went to the trouble
of remembering it.
 1.2 28-Dec-2002  matt const the pnpid array.
 1.1 28-Dec-2002  jmcneill Add 'com at acpi' and 'wss at acpi' glue. These are both working great on
my ThinkPad 600E.

XXX isa_dmainit isn't called early enough for the 'audio at wss' attachment
XXX to work, so I'm deferring the call to 'wssattach' until later on. This
XXX should be fixed soon.
 1.6.2.3 15-Jan-2003  thorpej Sync with HEAD.
 1.6.2.2 29-Dec-2002  thorpej Sync with HEAD.
 1.6.2.1 28-Dec-2002  thorpej file com_acpi.c was added on branch nathanw_sa on 2002-12-29 20:45:31 +0000
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.12.6 17-Mar-2008  yamt sync with head.
 1.15.12.5 21-Jan-2008  yamt sync with head
 1.15.12.4 27-Oct-2007  yamt sync with head.
 1.15.12.3 03-Sep-2007  yamt sync with head.
 1.15.12.2 30-Dec-2006  yamt sync with head.
 1.15.12.1 21-Jun-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 01-Mar-2006  yamt sync with head.
 1.18.10.3 17-Jun-2006  gdamore Undo the undo. Restore COM_INIT_REGS.
 1.18.10.2 17-Jun-2006  gdamore Revert COM_INIT_REGS.
 1.18.10.1 15-Jun-2006  gdamore Adapt to new com framework.
 1.18.2.1 11-Aug-2006  yamt sync with head
 1.20.6.2 10-Dec-2006  yamt sync with head.
 1.20.6.1 22-Oct-2006  yamt sync with head
 1.20.4.1 18-Nov-2006  ad Sync with head.
 1.22.10.1 11-Jul-2007  mjf Sync with head.
 1.22.8.2 23-Oct-2007  ad Sync with head.
 1.22.8.1 27-May-2007  ad Sync with head.
 1.22.4.1 07-May-2007  yamt sync with head.
 1.23.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.8.3 23-Mar-2008  matt sync with HEAD
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.24.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.24.4.1 26-Dec-2007  ad Sync with head.
 1.25.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.2.1 24-Mar-2008  keiichi sync with head.
 1.27.22.1 21-Apr-2010  matt sync to netbsd-5
 1.27.18.2 23-Jul-2009  jym Sync with HEAD.
 1.27.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.27.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.27.4.4 11-Aug-2010  yamt sync with head.
 1.27.4.3 11-Mar-2010  yamt sync with head
 1.27.4.2 18-Jul-2009  yamt sync with head.
 1.27.4.1 04-May-2009  yamt sync with head.
 1.30.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.30.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.31.2.1 05-Mar-2011  rmind sync with head
 1.32.36.2 28-Aug-2017  skrll Sync with HEAD
 1.32.36.1 05-Oct-2016  skrll Sync with HEAD
 1.32.18.1 03-Dec-2017  jdolecek update from HEAD
 1.33.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.34.12.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.34.12.1 21-May-2018  pgoyette Sync with HEAD
 1.35.2.1 10-Jun-2019  christos Sync with HEAD
 1.40.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.41.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.19 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.18 23-Apr-2015  pgoyette branches: 1.18.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.17 16-Feb-2011  jruoho branches: 1.17.14; 1.17.32;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.16 25-Oct-2010  jruoho branches: 1.16.2; 1.16.4;
Add support for module(9).
 1.15 24-Apr-2010  jruoho Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it).
 1.14 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.13 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.12 10-Apr-2010  jruoho Remove unnecessary casts.
 1.11 09-Apr-2010  jruoho Use ACPI_DEBUG_PRINT instead of a local DPRINTF.
 1.10 08-Mar-2010  jruoho branches: 1.10.2;
Remove unused struct sysctllog from the softc.
 1.9 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.8 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.7 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.6 31-Jan-2010  jruoho branches: 1.6.2;
Add a detachment routine.
 1.5 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.4 05-Jan-2010  jruoho Use acpi_eval_struct() to simplify code.

ok pgoyette@, jmcneill@
 1.3 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.2 01-Jun-2008  jmcneill branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22;
Don't reload usageid on resume, this should never change.
 1.1 18-May-2008  cegger acpidalb(4): Driver for PNP0C32 Hotkeys aka "Direct Application Launch Buttons".
"awesome" jmcneill
 1.2.22.4 11-Aug-2010  yamt sync with head.
 1.2.22.3 11-Mar-2010  yamt sync with head
 1.2.22.2 04-May-2009  yamt sync with head.
 1.2.22.1 01-Jun-2008  yamt file dalb_acpi.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:34 +0000
 1.2.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.2.8.1 01-Jun-2008  wrstuden file dalb_acpi.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.2.4.2 04-Jun-2008  yamt sync with head
 1.2.4.1 01-Jun-2008  yamt file dalb_acpi.c was added on branch yamt-pf42 on 2008-06-04 02:05:10 +0000
 1.2.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.2.1 01-Jun-2008  mjf file dalb_acpi.c was added on branch mjf-devfs2 on 2008-06-02 13:23:13 +0000
 1.6.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.2.2 05-Mar-2011  rmind sync with head
 1.10.2.1 30-May-2010  rmind sync with head
 1.16.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.16.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.32.1 06-Jun-2015  skrll Sync with HEAD
 1.17.14.1 03-Dec-2017  jdolecek update from HEAD
 1.18.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.6 11-Dec-2005  christos branches: 1.6.70; 1.6.72; 1.6.74;
merge ktrace-lwp.
 1.5 27-Feb-2005  perry remove trailing whitespace from the "generated from:" line
 1.4 15-Dec-2003  jmc branches: 1.4.8; 1.4.10;
Fixes from PR#23177. Various lint/logic fixes:
Fix some non-initialized variables
close the output files when done
Redo the printing for RCS strings so they don't expand in the awk script too
Do proper tests for variables existance before accessing

Verified output from all scripts is identical to original versions
 1.3 12-Dec-2003  jmc Fix from PR#23177. Pass lint and while here use a regular field separator
and shift off the first entry to get the description. This fixes one that
was getting missed and prevents future errors
 1.2 04-Feb-2003  perry branches: 1.2.2;
Add explicit comment handling.
Handle any [A-Z]{3} preceded value, not just "PNP".
 1.1 05-Jan-2003  christos branches: 1.1.2;
Infrastucture for ACPIVERBOSE
 1.1.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 05-Jan-2003  thorpej file devlist2h.awk was added on branch nathanw_sa on 2003-01-07 21:33:59 +0000
 1.2.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.8.1 29-Apr-2005  kent sync with -current
 1.6.74.1 16-May-2008  yamt sync with head.
 1.6.72.1 18-May-2008  yamt sync with head.
 1.6.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 09-Feb-2024  skrll Trailing whitespace.
 1.2 06-Feb-2022  jmcneill acpi: dwcmmc: Honour broken-cd and non-removable DSD properties
 1.1 09-Jan-2022  jmcneill dwcmmc: Add ACPI attach support
 1.1 16-Apr-2023  jmcneill DesignWare watchdog ACPI attach glue
 1.12 15-Sep-2025  thorpej No longer need to include acpi_i2c.h here.
 1.11 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.10 19-Oct-2022  riastradh dwiic(4): Don't try to attach children if dwiic_attach failed.

PR kern/57063
 1.9 07-Aug-2021  thorpej branches: 1.9.2;
Merge thorpej-cfargs2.
 1.8 24-Apr-2021  thorpej branches: 1.8.2; 1.8.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.7 04-Feb-2021  thorpej branches: 1.7.2;
Use acpi_compatible_match().
 1.6 26-Jan-2021  jmcneill Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.5 24-Jan-2021  jmcneill Attach dwiic(4) to AMD FCH I2C controllers. These busses are separate
from the SMBus that we attach to piixpm(4) today, and support direct
config via ACPI.
 1.4 07-Dec-2020  jmcneill Fix 32-bit build.
 1.3 23-Sep-2019  jmcneill branches: 1.3.8;
Match APMC0D0F compatible string.
 1.2 16-Nov-2018  jmcneill branches: 1.2.4; 1.2.6;
Use acpi_intr_establish
 1.1 17-Oct-2018  jmcneill branches: 1.1.2;
Add ACPI glue for DesignWare I2C controller.
 1.1.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.2 20-Oct-2018  pgoyette Sync with head
 1.1.2.1 17-Oct-2018  pgoyette file dwiic_acpi.c was added on branch pgoyette-compat on 2018-10-20 06:58:30 +0000
 1.2.6.1 23-Sep-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #233):

sys/dev/acpi/dwiic_acpi.c: revision 1.3

Match APMC0D0F compatible string.
 1.2.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 16-Nov-2018  christos file dwiic_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.3.8.2 03-Apr-2021  thorpej Sync with HEAD.
 1.3.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.7.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.8.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.8.2.2 25-Apr-2021  thorpej - Don't use acpi_enter_i2c_devs() -- it no longer exists.
- Pass along our devhandle to the i2c bus instance.
 1.8.2.1 25-Apr-2021  thorpej acpi_i2c.h is no more.
 1.9.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.10 11-Jan-2025  jmcneill acpi: i2c: only claim child devices with a _CRS or _ADR method

acpi_enter_i2c_devs is too aggressive with claiming child device nodes.
Restrict it to devices with either a _CRS or _ADR method. A driver is
free to claim more if appropriate.

Fixes missing HKEY (LEN0268) device on Thinkpad T14s Gen 6 (X1E).
 1.9 24-Dec-2021  jmcneill branches: 1.9.10;
acpi: ehci: Don't assume that a transaction translator is available.

Look for companion controllers using the rules in ACPI 6.3 section 9.14.1
"USB 2.0 Host Controllers and _UPC and _PLD", and only assume TT is
present if we can't find a USB 1.1 companion.
 1.8 22-Dec-2021  skrll Three fixes

- pass the 64bit DMA tag if the HCCPARAMS says ehci supports it and the
64bit DMA tag is available/valid. This should help with the
"cannot create xfer" error on 64bit systems.

- restrict the control structure memory allocation to the low 4GB
(CTRLDSSEGMENT was always set to zero anyway)

- if ehci_init fails then tidyup before returning the error.
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.5 29-Jan-2021  thorpej branches: 1.5.2;
Use acpi_compatible_match().
 1.4 07-Dec-2020  jmcneill Fix 32-bit build.
 1.3 16-Nov-2018  jmcneill branches: 1.3.2; 1.3.6; 1.3.16;
Use acpi_intr_establish
 1.2 26-Oct-2018  jmcneill Add xhci at acpi glue
 1.1 26-Oct-2018  jmcneill Add ehci at acpi glue
 1.3.16.2 03-Apr-2021  thorpej Sync with HEAD.
 1.3.16.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.3.6.2 10-Jun-2019  christos Sync with HEAD
 1.3.6.1 16-Nov-2018  christos file ehci_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.3.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.3.2.1 16-Nov-2018  pgoyette file ehci_acpi.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.5.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 24-Dec-2023  skrll eqos(4): MP improvements

Remove the non-MP-safe scaffolding and pass MP safe flags for callout
and interrupt handlers.

Where we had #ifndef EQOS_MPSAFE splnet(), we also had EQOS_LOCK,
which implies splnet, so just remove the conditional splnet.
 1.1 03-Jan-2022  jmcneill Add driver for DesignWare Ethernet Quality-of-Service controller.
 1.47 15-Oct-2021  jmcneill Convert some debug messages to aprint_debug
 1.46 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.45 07-Dec-2020  jmcneill Fix 32-bit build.
 1.44 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.43 13-Apr-2015  riastradh branches: 1.43.32;
Convert sys/dev to use <sys/rndsource.h>.
 1.42 02-Feb-2012  tls branches: 1.42.6; 1.42.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.41 07-Aug-2010  jruoho branches: 1.41.8; 1.41.12;
Remove the last ACPI driver -specific #ifdef, ACPI_FDC_DEBUG.
 1.40 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.39 10-Apr-2010  jruoho Remove unnecessary casts.
 1.38 05-Mar-2010  jruoho branches: 1.38.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.37 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.36 16-Sep-2009  mlelstv branches: 1.36.2;
Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.35 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.34 16-Mar-2008  yamt branches: 1.34.4; 1.34.12; 1.34.14; 1.34.18; 1.34.22;
fix compilation
 1.33 16-Mar-2008  cube Split device_t and softc for the ... wait for it ... [air quotes] MI
variant of fdc(4)/fd(4). Other cosmetic changes as appropriate.
 1.32 18-Feb-2008  dyoung branches: 1.32.2; 1.32.6;
Use aprint_*_dev(), device_t and accessors. Constify a bit.
 1.31 19-Oct-2007  ad branches: 1.31.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.30 16-Nov-2006  christos branches: 1.30.8; 1.30.22; 1.30.24; 1.30.28;
__unused removal on arguments; approved by core.
 1.29 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.28 20-Feb-2006  kochi branches: 1.28.14; 1.28.16;
use aprint_*
 1.27 11-Dec-2005  christos branches: 1.27.2; 1.27.4; 1.27.6;
merge ktrace-lwp.
 1.26 11-Jul-2005  drochner reduce the last commit to its essence; the rest was
not so helpful
 1.25 11-Jul-2005  christos PR/30720: Nicolas Joly: compilation failure with ACPI_FDC_DEBUG
 1.24 29-May-2005  christos branches: 1.24.2;
Sprinkle const freely and delete unnecessary casts.
 1.23 28-Oct-2004  yamt move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.22 01-May-2004  kochi specify static where appropriate.
 1.21 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.20 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.19 10-Apr-2004  kochi whitespace nit
 1.18 03-Nov-2003  mycroft Match all PNP07?? IDs.
 1.17 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.16 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.15 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.14 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.13 25-Sep-2003  christos imake this compile again.
 1.12 25-Sep-2003  mycroft Modify the fdcattach() interface again, splitting it into two parts, so that
DRQ allocation is done earlier.
 1.11 25-Sep-2003  mycroft Update for new attach method.
 1.10 15-Aug-2003  kochi 'struct acpi_resources' will have references to malloc'ed memory.
So it's better to not to allocate on stack.
 1.9 18-Jun-2003  drochner branches: 1.9.2;
don't #include <sys/dkstat.h> where it is (appearently) unused
 1.8 21-May-2003  christos size_t != unsigned int all the time.
 1.7 13-Jan-2003  jmcneill Why do I always think 'evaluate' and type 'evalulate'?
 1.6 09-Jan-2003  jdolecek need to select proper IST for interrupt - IST_NONE is almost certainly not
right

this makes fdc@acpi and com@acpi actually work on my machine; lpt@acpi
change untested, but should be same as fdc and com
 1.5 09-Jan-2003  jdolecek _FDE is optional, so don't print warning messages about it failing
unless ACPI_FDC_DEBUG
array returned from _FDE contains UINT32 values, not UINT8; also change
the magic number '14' to '5 * sizeof(UINT32)' for clarity
remove XXX for the tape presence comment; it's Just Okay to not use the info
fdc_acpi_getknownfds(): if fdc_acpi_nvtotype() returns NULL, don't
attempt to attach the drive at all

XXX not tested
 1.4 09-Jan-2003  jmcneill A few fallbacks:
1. If _FDE fails, fall-back to the old-style of drive probing.
2. If _FDI fails on a drive, assume a 1.44MB 3.5" floppy drive.
 1.3 09-Jan-2003  jmcneill Enumerate floppy disk drives via ACPI (mmm, faster booting). Known to work
with one floppy drive; not quite sure if the logic handling _FDI is right.
 1.2 28-Dec-2002  jmcneill branches: 1.2.2;
Correctly pass the proper DRQ down to the common fdc driver.
 1.1 28-Dec-2002  jmcneill Add an fdc at acpi(4) attachment
 1.2.2.3 15-Jan-2003  thorpej Sync with HEAD.
 1.2.2.2 29-Dec-2002  thorpej Sync with HEAD.
 1.2.2.1 28-Dec-2002  thorpej file fdc_acpi.c was added on branch nathanw_sa on 2002-12-29 20:45:31 +0000
 1.9.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.24.2.5 17-Mar-2008  yamt sync with head.
 1.24.2.4 27-Feb-2008  yamt sync with head.
 1.24.2.3 27-Oct-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.27.6.1 22-Apr-2006  simonb Sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.27.2.1 01-Mar-2006  yamt sync with head.
 1.28.16.2 10-Dec-2006  yamt sync with head.
 1.28.16.1 22-Oct-2006  yamt sync with head
 1.28.14.1 18-Nov-2006  ad Sync with head.
 1.30.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.30.24.2 23-Mar-2008  matt sync with HEAD
 1.30.24.1 06-Nov-2007  matt sync with HEAD
 1.30.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.30.8.1 23-Oct-2007  ad Sync with head.
 1.31.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.32.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.2.1 24-Mar-2008  keiichi sync with head.
 1.34.22.1 21-Apr-2010  matt sync to netbsd-5
 1.34.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.34.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.34.4.3 11-Aug-2010  yamt sync with head.
 1.34.4.2 11-Mar-2010  yamt sync with head
 1.34.4.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.38.2.2 05-Mar-2011  rmind sync with head
 1.38.2.1 30-May-2010  rmind sync with head
 1.41.12.1 18-Feb-2012  mrg merge to -current.
 1.41.8.1 17-Apr-2012  yamt sync with head
 1.42.24.1 06-Jun-2015  skrll Sync with HEAD
 1.42.6.1 03-Dec-2017  jdolecek update from HEAD
 1.43.32.2 03-Apr-2021  thorpej Sync with HEAD.
 1.43.32.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.2 05-Mar-2010  jruoho Protect all header files against multiple inclusions.
 1.1 09-Jan-2003  jmcneill branches: 1.1.2; 1.1.106; 1.1.128;
Enumerate floppy disk drives via ACPI (mmm, faster booting). Known to work
with one floppy drive; not quite sure if the logic handling _FDI is right.
 1.1.128.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.106.1 11-Mar-2010  yamt sync with head
 1.1.2.2 15-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 09-Jan-2003  thorpej file fdc_acpireg.h was added on branch nathanw_sa on 2003-01-15 18:44:14 +0000
 1.140 19-Sep-2025  mrg avoid various seemingly bogus warnings with GCC 14.

i couldn't see any real case for any of these issues. it seems like
the "maybe uninit" checker has gotten worse.

additionally, the "dangling pointer" checker also failing.
 1.139 26-Feb-2025  ryoon Add amdgpio(4) device driver for AMD GPIO found on some HP laptops

This device driver enables power button and trackpad on
HP Envy 13 ay1000 and HP Envy 14 fa0000.
Touchscreen and stylus have no decodable HID descriptors and not enabled.

Based on qcomgpio(4) and OpenBSD's amdgpio(4).

Add the following to your kernel configuration file:

amdgpio* at acpi?
 1.138 09-Jan-2025  jmcneill qcompep: add scmi dependency
 1.137 03-Jan-2025  imil Fix MMIO support for VirtIO ACPI: virtio_acpi.c already depends on
virtio_mmio.c, it worked only by accident on Arm kernels which already had
virtio_mmio pulled in
 1.136 30-Dec-2024  jmcneill arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.135 13-Dec-2024  martin Only compile acpi_i2c.c if the kernel has I2C support
 1.134 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.133 26-Aug-2024  riastradh acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.

TBD: Add to all ACPI-supporting GENERIC kernels.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.132 21-Mar-2024  riastradh branches: 1.132.2;
acpihed(4): New driver for PNP0C33 to notify apei(4).

PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.

PR kern/58046
 1.131 20-Mar-2024  riastradh apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.

PR kern/58046
 1.130 20-Mar-2024  riastradh acpi(4): Make apeibus actually work as an iattr.

PR kern/58046
 1.129 20-Mar-2024  riastradh acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.

Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046
 1.128 18-Jul-2023  riastradh acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.
 1.127 16-Apr-2023  jmcneill DesignWare watchdog ACPI attach glue
 1.126 26-May-2022  mrg branches: 1.126.4;
only link acpi_pci*.c if acpi & pci, not just acpi.
 1.125 24-Mar-2022  manu Add initial support for Intel GPIO chips
 1.124 16-Feb-2022  riastradh sys: Include files.acpica unconditionally.

This way acpica.h always exists unconditionally, so MI code can be
conditional on NACPICA.

It is not great to have such conditionals, but it's better to have

#include "acpica.h"

#ifdef NACPICA > 0

than to have

#if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
#include "acpica.h"
#endif

#ifdef NACPICA > 0

and we can still grep for NACPICA to find places that could be
factored better.
 1.123 09-Jan-2022  jmcneill dwcmmc: Add ACPI attach support
 1.122 03-Jan-2022  jmcneill Add driver for DesignWare Ethernet Quality-of-Service controller.
 1.121 24-Dec-2021  jmcneill Add ohci at acpi bindings. No known PNP IDs for this, so match using _CLS
and the PCI class/subclass/interface codes. Maybe this will take off.
 1.120 24-Jan-2021  jmcneill Add support for NXP Layerscape I2C controllers.
 1.119 13-Dec-2020  jmcneill acpi: Add support for Collaborative Processor Performance Control (CPPC).

CPPC is the modern replacement for processor performance controls (P-states
and T-states). The _CPC method on a processor device contains information
about supported performance levels of the device.

This driver reports the supported performance levels and allows for
setting the desired level using the machdep.cpufreq.cpuN.* sysctls. Note
that a "performance level" value is not guaranteed to represent a CPU
frequency, so treat the numbers reported as such.
 1.118 13-Dec-2020  jmcneill acpi: Add support for ACPI Platform Communications Channel (PCC).
 1.117 07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.116 06-Dec-2020  jmcneill acpi: add character device for accessing ACPI tables

The /dev/acpi character device gives an aperture into physical memory
that allows only read access to known ACPI tables: RSDP, XSDT/RSDT, and
the root tables. Adapt acpidump(8) to use this interface by default,
falling back to the old /dev/mem method if it is not available or if
ACPIDUMP_USE_DEVMEM=1 is set in the environment. The user visible benefit
of this change is that "options INSECURE" is no longer required to
dump ACPI tables.
 1.115 22-Feb-2020  jmcneill branches: 1.115.6;
Add ACPI glue for Broadcom GENETv5
 1.114 25-Dec-2018  mlelstv branches: 1.114.6;
Make ipmi driver available to other platforms.
Add ACPI attachment.
 1.113 26-Oct-2018  jmcneill Add xhci at acpi glue
 1.112 26-Oct-2018  jmcneill Add ehci at acpi glue
 1.111 22-Oct-2018  jmcneill Add driver for ACPI Generic Event Device
 1.110 22-Oct-2018  jmcneill Factor out common ACPI event code into a shared module.
 1.109 21-Oct-2018  jmcneill Add ACPI attach glue for virtio_mmio.
 1.108 19-Oct-2018  jakllsch Add amdccp(4) driver for AMD Cryptographic Coprocessor, as found on the
A11xx Opterons. Driver currently provides RNG service only.
 1.107 17-Oct-2018  jmcneill Add ACPI glue for DesignWare I2C controller.
 1.106 16-Oct-2018  jmcneill Rename options ACPI_REDUCED_HARDWARE to ACPI_REDUCED_HW. The former is
a boolean in the acpica build, so use the latter to select the correct
value.
 1.105 16-Oct-2018  jmcneill Add ACPI_REDUCED_HARDWARE defflag (used by ACPICA) and fix acpi build with this option set.
 1.104 15-Oct-2018  jmcneill Add ACPI glue for PL061 GPIO
 1.103 12-Oct-2018  jmcneill Add ahcisata at acpi glue
 1.102 12-Oct-2018  jmcneill Add attributes for attaching acpi(4) child devices based on SDT, GTDT, and MADT subtables.
 1.101 01-Mar-2018  maya branches: 1.101.2; 1.101.4;
Limit building & calling ACPI MCFG to kernels with PCI and ACPI.

pci_quirks.c requires pci
acpi_mcfg.c was recently changed to use pci_quirks.c functions.

as a result, ia64 kernels with acpi but no pci failed to link.

tested an ia64 and amd64 kernels build.
 1.100 10-Dec-2017  bouyer Implement a ACPI helper to fill the property array expected from our I2C
framework from the ACPI tables.
Also implement acpi_intr_establish(), acpi_intr_disestablish() and
acpi_intr_string().
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.99 25-Nov-2017  jmcneill Add driver for QEMU Firmware Configuration device.

This interface allows the host to pass various data items and files to
the guest OS.
 1.98 21-Jun-2016  nonaka Add sdhc(4) at acpi support
 1.97 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.96 21-Sep-2015  nonaka PR/50261: Added newer Toshiba hotkeys support.
 1.95 14-Sep-2014  mrg branches: 1.95.2;
introduce a new option: ACPI__DIS_IS_BROKEN. this is a hack to
avoid calling the "_DIS" method during acpi interrupt link setup,
which hangs various nforce4 based motherboards.

when the problem is properly fixed, remove this hack. for now,
it allows someone (me) to have a valid kernel config that doesn't
require a source hack every new tree.

ok chs@
 1.94 01-Apr-2014  riastradh branches: 1.94.4;
First draft of drivers for the Apple System Management Controller.

Device interface derived by reading the Linux driver source code and
<http:///www.parhelia.ch/blog/statics/k3_keys.html> as of 2012-12-05.

Includes support for attaching fan and temperature sensors to sysmon.
No accelerometer yet.

Compile-tested only, based on some run-testing of experiments from
userland. Module attachment is not quite finished, so it won't work
yet.
 1.93 22-Jan-2012  christos branches: 1.93.6; 1.93.10;
add a tpm driver from bsssd.sourceforge.net
 1.92 22-Sep-2011  jakllsch branches: 1.92.2; 1.92.6;
valz(4) is superseded entirely by acpivga(4) these days.
 1.91 13-Jul-2011  jruoho A driver for HP 3D DriverGuard; a LIS3LV02DL-based accelerometer. Tested on
HP NC4400. Like aps(4), this is commented out in the GENERIC kernels.
 1.90 14-Jun-2011  jruoho Try to attach hpet(4) also via a specific HPET table. Fixes PR kern/43702.
 1.89 12-Jun-2011  jruoho Rewrite the aibs(4) driver in order to support new models. Draws from the
revision 1.6 (claudio@) of the OpenBSD's equivalent driver. Tested by mrg@.
 1.88 27-Feb-2011  jruoho branches: 1.88.2;
Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".
 1.87 20-Feb-2011  jruoho Split fujbp(4) and fujhk(4) to separate instances from fujitsu(4). Allows
modularization and takes care of tsutsui@'s justified concern over the too
generic name "fujitsu". Ok gsutre@.
 1.86 17-Jan-2011  jmcneill branches: 1.86.2;
acpiwdrt needs sysmon_wdog
 1.85 17-Jan-2011  jmcneill Add a driver for ACPI "Watchdog Resource Table" devices.

acpiwdrt0 at acpi0: mem 0xfed01000,0xfed01004
acpiwdrt0: PCI 0:000:00:0 vendor 0x1106 product 0x3337
acpiwdrt0: watchdog interval 1-1023 sec.
 1.84 09-Jan-2011  jruoho branches: 1.84.2;
Add a dummy-driver for ACPI fans.
 1.83 05-Jan-2011  jruoho Add a driver for ACPI power meters.
 1.82 05-Nov-2010  gsutre Merge ACPI Fujitsu Driver. Provides support for hotkeys and other
built-in components through vendor-specific ACPI devices.

ok jruoho@
 1.81 12-Oct-2010  gsutre Merge ACPI display driver. Provides generic support for brightness
control and output switching, through ACPI video extensions.

TODO: use wsconsctl(8) instead of sysctl(8) for brightness control.

ok jruoho@
also discussed with cegger@ and jmcneill@
 1.80 06-Sep-2010  jmcneill Add support for blacklisting ACPI BIOS implementations by year. By default,
don't use ACPI on BIOS which advertise release years <= 2000. This
can be changed by setting option ACPI_BLACKLIST_YEAR=0 or by setting
acpi_force_load=1.
 1.79 13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.78 08-Aug-2010  jruoho Add P-states. (I blame the ease of using modules.)
 1.77 07-Aug-2010  jruoho Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.
 1.76 18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.75 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.74 22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.73 14-Apr-2010  jruoho Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In
addition, split the utility functions to a separate file.

No functional change. Ok jmcneill@.
 1.72 11-Apr-2010  jakllsch Add valz(4), a simple driver to handle the backlight keys on some
Toshiba laptops. As of yet only tested on a Satellite A135-S4527.
 1.71 10-Apr-2010  jruoho Move vald(4) to sys/dev/acpi. This is MI and should work also on amd64.

ok jmcneill@

XXX: This is broken: it calls methods with absolute pathnames (almost
guaranteed not to be portable across models), it accesses methods
that are in the domain of other drivers, it walks the namespace on
its own, it contains plenty of magic constants, it does not
integrate with existing KPIs, etc. Summa summarum: this should be
rewritten as a more generic toshiba_acpi(4).
 1.70 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.69 08-Apr-2010  jruoho Include 'files.wmi'.
 1.68 19-Mar-2010  cnst Remove aiboost(4) as obsolete and redundant since the introduction of aibs(4).

http://mail-index.netbsd.org/tech-kern/2010/03/06/msg007458.html

Reviewed by <pgoyette>, <cegger>, <jruoho>, <tech-kern>.
 1.67 09-Feb-2010  cnst branches: 1.67.2;
New aibs(4) driver for ASUSTeK AI Booster (ACPI ATK0110) hardware monitor
with limit support.

http://thread.gmane.org/gmane.os.netbsd.devel.kernel/35654

Reviewed by <pgoyette>, <jruoho> and <tech-kern>.
 1.66 06-Feb-2010  pgoyette branches: 1.66.2;
Import my experimental ACPI SMBus Control Method Interface driver

XXX Should not be enabled in any configuration file until you have
XXX disabled corresponding "native" i2c driver! Read the acpismbus(4)
XXX man page!
 1.65 31-Jan-2010  jruoho Add dynamic debug options for ACPI_DEBUG kernels.

ok jmcneill@, pooka@, pgoyette@
 1.64 03-Jan-2010  jruoho Introduce acpiwmibus, a pseudo-bus to which the child WMI devices attach.

Multiple WMI mapper devices are supported, but each one can have only one
child device.

All exposed functions now require the parent mapper device as a parameter.

ok pgoyette@, jmcneill@
 1.63 03-Dec-2009  cegger Enumerate ACPI PCI devices. Allows to link PCI with ACPI devices.
Patch presented on tech-kern@
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

'nice work' Jukka Ruohonen
 1.62 25-Nov-2009  cegger Add ACPI SLIT parser. This is part of NUMA support.
Tested on a 8-node machine.

Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.61 25-Nov-2009  cegger Add ACPI SRAT parser. This is a part of NUMA support.
Tested on 1-node, 2-node and 8-node machines.
Patch presented on tech-kern@, port-i386@ and port-amd64@.

No comments.
 1.60 02-Oct-2009  jmcneill PR# kern/42139: ACPI WMI: new driver

Import acpiwmi(4) from Jukka Ruohonen. From the PR:

Attached is a driver that implements ACPI WMI API:

http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

The WMI is used to provide a generic interface for OEMs to use certain
platform/laptop-specific additions to the standard ACPI in a somewhat
portable way. These can be hotkeys for additional buttons, different event
handlers (wireless kill switch, lid switch, etc.), and so on. At least HP
and Acer use it by default nowadays.

The benefit of this interface would be portability. For an example, instead
of hpqlb(4) that works only with certain HP models, we could have a generic
HP WMI-driver that should work in theory across all HP laptops. On many new
laptops WMI may also be the only way to access laptop/manufacturer-specific
features.
 1.59 30-Sep-2009  jmcneill Initial import of an SD/MMC driver for the Winbond W83L518D (and probably
W83L519D) Integrated Media Reader with PNP bus attachment glue.
 1.58 31-Aug-2009  cube Don't reference files that don't exist, and cvs diff before commit.
 1.57 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.56 09-Aug-2009  christos spic has moved.
 1.55 04-Aug-2009  jmcneill add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.

by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller

reviewed by: joerg
 1.54 03-Aug-2009  jmcneill - add experimental cpu fan/voltage switching support (sysctl hw.asus0.*)
- add fan sensor
- rename asus_softc_t -> struct asus_softc
- add detach method
- update copyright for 2009
 1.53 06-Jul-2009  joerg Ignore breakpoints in the DSDT even if DDB is present.
A new option ACPI_BREAKPOINT reenables them.
 1.52 18-May-2008  cegger branches: 1.52.8; 1.52.12; 1.52.16;
acpidalb(4): Driver for PNP0C32 Hotkeys aka "Direct Application Launch Buttons".
"awesome" jmcneill
 1.51 01-May-2008  cegger branches: 1.51.2;
hpqlb(4): driver for HP Quick Launch buttons - found on HP Pavilion Notebooks
 1.50 31-Mar-2008  jmcneill branches: 1.50.2; 1.50.4;
Add ASUS ACPI hotkey driver, as found in the Eee PC.
 1.49 23-Dec-2007  jmcneill branches: 1.49.6;
Move Sony Notebook Controller (sony(4)) driver from MD to MI directory,
as it can be used on amd64 as well.
 1.48 21-Dec-2007  jmcneill Add Thinkpad ACPI driver, for controlling hotkeys and display brightness.
 1.47 09-Dec-2007  jmcneill branches: 1.47.2;
Merge jmcneill-pm branch.
 1.46 23-Aug-2007  tnn branches: 1.46.2; 1.46.10; 1.46.12;
apm emulation needs envsys. From Jukka Salmi on the current-users list.
 1.45 08-May-2007  xtraeme branches: 1.45.2; 1.45.6;
Split the ug(4) driver in three components:

* dev/ic/ug.c (main code shared by the attachments)
* dev/isa/ug_isa.c (isa attachment)
* dev/acpi/ug_acpi.c (acpi attachment)

That means that ug(4) can now be attached via ACPI.

Thanks to Mihai Chelaru for the good work.
 1.44 14-Mar-2007  xtraeme Rename acpi_aiboost to aiboost, suggested by cube.
 1.43 13-Mar-2007  xtraeme ASUS AI Booster ACPI driver, ported from FreeBSD.

This driver will report values from the Super I/O chip via ACPI.
It should be possible to overclock the system with this driver, but
it's not implemented yet.

All newer ASUS motherboards probably will work with this driver
(device ATK0110).

[juan@nocturno][~]> envstat -r
CPU Temperature: 30.000 degC
MB Temperature: 38.000 degC
Vcore Voltage: 1.240 V
+3.3 Voltage: 3.264 V
+5 Voltage: 4.992 V
+12 Voltage: 12.091 V
CPU FAN Speed: 1454 RPM
[juan@nocturno][~]>
 1.42 08-Mar-2007  njoly branches: 1.42.2; 1.42.4;
High Precision Event Timer driver, following Intel specifications.

Allow attachement at both ACPI (hpet@acpi) and AMD8111 LPC Controller
(hpet@amdpcib).

Requested by xtraeme, and tested by a few users.
 1.41 09-Jan-2007  cube branches: 1.41.2;
Add a lint-only value of "/dev/null" for ACPI_DSDT_FILE.

Bump required config(1) version. Yes, it implies everybody will have to
rebuild config(1). I can live with people hating me.
 1.40 14-Aug-2006  itohy branches: 1.40.2; 1.40.6;
ACPI frontend for Yamaha OPL3-SA[23].
Derived from PR kern/33991 by jasper at pointless dot net.
 1.39 06-Aug-2006  christos PR/34116: Takuya SHIOZAKI: acpiapm(4) misuses config(9)
acpiapm(4) always matches the first node of AML, which is unrelated
with acpiapm. Separate acpi(4)'s children into two individual interface
attributes.
 1.38 08-Jul-2006  christos Add acpi apm attachment based on sysmon hooks.
 1.37 04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.36 21-Jun-2006  drochner First cut on an implementation of an ACPI power management counter
backend for timecounters.
Due to known bugs in some chipsets, always read until we get 3 successive
samples which are monotonic, as FreeBSD does in its "safe" variant.
This can be refined later, either by chipset quirks or by a test (as
FreeBSD does).
 1.35 31-Jan-2006  kochi branches: 1.35.2; 1.35.6; 1.35.14;
remove ACPI_DISABLE_ON_POWEROFF option, which was there just for
compatibility of our old driver behavior, which is not necessary.
 1.34 05-Jan-2006  rpaulo * defflag ACPI_DSDT_OVERRIDE and defparam ACPI_DSDT_FILE.
* adjust comments to reality
 1.33 11-Dec-2005  christos branches: 1.33.2;
merge ktrace-lwp.
 1.32 21-Jun-2005  sekiya branches: 1.32.2;
Rework the configuration scheme for PCI fixups:

* bus enumeration fixups are not PCIBIOS-specific, interrupt fixups are done
by both PCIBIOS and ACPI. The redundancy is very redundant. Therefore,
rename PCIBIOS_*_FIXUP to PCI_*_FIXUP, use PCI_INTR_FIXUP in place of
ACPI_PCI_FIXUP, and change code refences to match.

* move the fixup defines from opt_pcibios.h to opt_pcifixup.h to reflect
the above.

* fix up the PCI bus numbering in mainbus_attach(), right after we detect the
configuration mode. This probably renders the fixup in pcibios.c
redundant -- but it should be harmless.

These changes make cardbus work in ACPI-only machines, when PCI_BUS_FIXUP
and PCI_INTR_FIXUP are defined.
 1.31 25-Mar-2005  cube Add attimer(4) driver, with ISA and ACPI attachments.

attimer(4) is the new body of the part of pcppi(4) that mapped the TIMER1
register to set the pitch of the bell. It was necessary to separate them
in order to have a working ACPI attachment (as the two appear as different
devices in the ACPI structures).
 1.30 21-Mar-2005  xtraeme Add pcppi(4) ACPI attachment, which matches the "AT-style speaker
sound" ACPI device.

Reviewed by christos@.
 1.29 02-Dec-2004  xtraeme branches: 1.29.4; 1.29.6;
Add ACPI joy(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed and ok'ed by cube@ and martin@.
 1.28 02-Dec-2004  xtraeme Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.27 07-Jun-2004  kochi Add ACPI_DISABLE_ON_POWEROFF option.
Note: the default behavior is changed. Now we don't disable the ACPI
subsystem on power off (halt -p) by default.
'options ACPI_DISABLE_ON_POWEROFF' in a kernel config file makes the kernel
behave the way we used to be.
 1.26 27-May-2004  kochi don't compile acpi_madt.c unless options MPACPI is specified.
 1.25 26-May-2004  kochi ThermalZone improvement work by lha at stacken.kth.se, inspired from
FreeBSD thermal zone code. Minor style fixes and bugfixes by me.
 1.24 03-May-2004  kochi Add sysmon pswitch hook so that powerd(8) can monitor
AC adapter online/offline events.
 1.23 31-Mar-2004  tron Only call acpiec_early_attach() in "acpi.c" if the kernel is configured
to include the "acpiec" device.
 1.22 31-Jan-2004  jdolecek branches: 1.22.2;
add dependency on isadma for atppc attachments
add atppc_isadma.c for atppc@isapnp and atppc@ofisa, too
 1.21 25-Jan-2004  jdolecek add ACPI atppc(4) attachment; probes properly, DMA and actual transfer
not tested yet
 1.20 15-May-2003  fvdl branches: 1.20.2;
Add quirk handling to ACPI. First quirk entry is "PTLTD " rev 0x06040000,
which gives problems with PCI bus finding; the object hierarchy doesn't
match the real world for some systems, most notably SuperMicro boards.
Linux has this one blacklisted as well.
 1.19 20-Apr-2003  thorpej Use sysmon_taskq.
 1.18 17-Apr-2003  matt acpi.c needs sysmon_power too.
 1.17 17-Apr-2003  thorpej * Don't do the ACPI_PCI_FIXUP unless it is explicitly enabled in
the kernel config file. That code makes a total mess of any
system with multiple PCI busses.
* Rework the way buttons are handled; register them with sysmon,
and let it take the appropriate action. This lets us gracefully
shut down when the power button is pressed.
 1.16 12-Jan-2003  christos add some more flags used only in acpi.c
 1.15 05-Jan-2003  christos add ACPIVERBOSE; while I am there, fix the eval_string function so it does
not leak.
 1.14 05-Jan-2003  fvdl Add some code to deal with the MADT.
 1.13 04-Jan-2003  jmcneill Initial support for ACPI Thermal Zones. For now, we only export the zone
temperature to sysmon; in the near future we should be associating devices
in this thermal zone with this device so we can do active or passive
cooling on a zone-by-zone basis.
 1.12 31-Dec-2002  explorer add envsys support to acpi A/C adapter and batteries. This is still a work
in progress, much like the rest of ACPI.
 1.11 28-Dec-2002  jmcneill Add an fdc at acpi(4) attachment
 1.10 28-Dec-2002  matt Add a pckbc acpi attachment (it compiles but it untested).
 1.9 28-Dec-2002  jmcneill Add an lpt attachment to acpi(4)
 1.8 28-Dec-2002  jmcneill Add 'com at acpi' and 'wss at acpi' glue. These are both working great on
my ThinkPad 600E.

XXX isa_dmainit isn't called early enough for the 'audio at wss' attachment
XXX to work, so I'm deferring the call to 'wssattach' until later on. This
XXX should be fixed soon.
 1.7 17-Jun-2002  christos move spic_acpi to arch/i386/acpi
 1.6 22-Apr-2002  augustss branches: 1.6.2;
Attach the spic driver via ACPI.
 1.5 24-Mar-2002  sommerfeld Prototype ACPI Control Method Battery driver.

ACPI defines two different battery device interfaces: "Control Method"
batteries, in which AML methods are defined in order to get battery
status and set battery alarm thresholds, and a "Smart Battery" device,
which is an SMbus device accessed through the ACPI Embedded Controller
device; this driver knows how to attach to the former sort of device.

As a total kludge, since we haven't wired things up to sysmon/envsys
yet, we report battery status through a once-per-minute kernel printf,
so don't use this driver yet if you want your disk to spin down.

Motivated by and tested on Sony PCG-R505TL laptop, which has
nonfunctional APM.

configure as:

acpibat* at acpi ?

Sample output:

acpibat0 at acpi0: ACPI Battery
acpibat0: Sony Corp. LION
acpibat0: Design 38480mWh, Predicted 38480mWh Warn 120mWh Low 0mWh
acpibat0: discharging: 15112mV cap 25480mWh (66%) rate 16849mW
...
acpibat0: discharging: 15224mV cap 25070mWh (65%) rate 18405mW
...
acpibat0: discharging: 15200mV cap 24310mWh (63%) rate 13771mW
...
acpibat0: charging: 15768mV cap 23330mWh (60%) rate 20388mW
 1.4 28-Nov-2001  lukem branches: 1.4.2;
- convert usage of "defopt" to "defflag" where the relevant option does
not support a value (e.g., it's to be used as "options FOO" instead of
"options FOO=xxx"). options that take a value were converted to
defparam recently.
- minor whitespace & formatting cleanups
 1.3 20-Nov-2001  lukem - replace "defopt" with "defparam" for options which must take a value,
as config(8) will warn for value-less defparam options
- minor whitespace/formatting cleanup
- consolidate opt_tcp_recvspace.h and opt_tcp_sendspace.h into opt_tcp_space.h
 1.2 29-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Build acpi_resource.c, add "acpiec" and "acpiacad".
 1.1 28-Sep-2001  thorpej Add some basic ACPI probing framework. This is far from complete,
it is merely a work in progress.
 1.2.4.9 15-Jan-2003  thorpej Sync with HEAD.
 1.2.4.8 07-Jan-2003  thorpej Sync with HEAD.
 1.2.4.7 03-Jan-2003  thorpej Sync with HEAD.
 1.2.4.6 29-Dec-2002  thorpej Sync with HEAD.
 1.2.4.5 20-Jun-2002  nathanw Catch up to -current.
 1.2.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.2.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.4.1 29-Sep-2001  nathanw file files.acpi was added on branch nathanw_sa on 2001-10-08 21:18:06 +0000
 1.2.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 29-Sep-2001  fvdl file files.acpi was added on branch thorpej-devvp on 2001-10-01 12:44:18 +0000
 1.4.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 28-Nov-2001  thorpej file files.acpi was added on branch kqueue on 2002-01-10 19:52:54 +0000
 1.6.2.1 15-Jul-2002  gehenna catch up with -current.
 1.20.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.5 01-Apr-2005  skrll Sync with HEAD.
 1.20.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.2 14-Jun-2004  jmc Pullup patch (requested by kochi in ticket #463)

Add ACPI_DISABLE_ON_POWEROFF option. PR#24869
 1.22.2.1 28-Apr-2004  jmc Pullup rev 1.23 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.29.6.1 26-Mar-2005  yamt sync with head.
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.32.2.5 21-Jan-2008  yamt sync with head
 1.32.2.4 03-Sep-2007  yamt sync with head.
 1.32.2.3 26-Feb-2007  yamt sync with head.
 1.32.2.2 30-Dec-2006  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.33.2.2 01-Feb-2006  yamt sync with head.
 1.33.2.1 15-Jan-2006  yamt sync with head.
 1.35.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.35.6.3 03-Sep-2006  yamt sync with head.
 1.35.6.2 11-Aug-2006  yamt sync with head
 1.35.6.1 26-Jun-2006  yamt sync with head.
 1.35.2.1 09-Sep-2006  rpaulo sync with head
 1.40.6.1 13-May-2007  pavel Pull up patch (requested by xtraeme in ticket #633):
sys/arch/amd64/conf/GENERIC: patch
sys/arch/i386/conf/ALL: patch
sys/arch/i386/conf/GENERIC: patch
sys/conf/files: patch
sys/dev/acpi/files.acpi: patch
sys/dev/acpi/ug_acpi.c: patch
sys/dev/ic/ug.c: patch
sys/dev/ic/ugreg.h: patch
sys/dev/ic/ugvar.h: patch
sys/dev/isa/files.isa: patch
sys/dev/isa/ug_isa.c: patch
share/man/man4/ug.4: patch
doc/CHANGES: patch
sys/dev/isa/ug.c: delete
sys/dev/isa/ugvar.h: delete

Add an acpi attachement for the ug hardware monitor driver.
 1.40.2.1 12-Jan-2007  ad Sync with head.
 1.41.2.3 17-May-2007  yamt sync with head.
 1.41.2.2 24-Mar-2007  yamt sync with head.
 1.41.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.42.4.1 11-Jul-2007  mjf Sync with head.
 1.42.2.4 09-Oct-2007  ad Sync with head.
 1.42.2.3 27-May-2007  ad Sync with head.
 1.42.2.2 10-Apr-2007  ad Sync with head.
 1.42.2.1 13-Mar-2007  ad Sync with head.
 1.45.6.2 02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.45.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.45.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.46.12.1 11-Dec-2007  yamt sync with head.
 1.46.10.1 26-Dec-2007  ad Sync with head.
 1.46.2.1 09-Jan-2008  matt sync with HEAD
 1.47.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.49.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.49.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.50.4.8 09-Oct-2010  yamt sync with head
 1.50.4.7 11-Aug-2010  yamt sync with head.
 1.50.4.6 11-Mar-2010  yamt sync with head
 1.50.4.5 16-Sep-2009  yamt sync with head
 1.50.4.4 19-Aug-2009  yamt sync with head.
 1.50.4.3 18-Jul-2009  yamt sync with head.
 1.50.4.2 04-May-2009  yamt sync with head.
 1.50.4.1 16-May-2008  yamt sync with head.
 1.50.2.2 04-Jun-2008  yamt sync with head
 1.50.2.1 18-May-2008  yamt sync with head.
 1.51.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.16.1 21-Apr-2010  matt sync to netbsd-5
 1.52.12.1 23-Jul-2009  jym Sync with HEAD.
 1.52.8.3 08-Oct-2009  sborrill Pull up the following revisions(s) (requested by jmcneill in ticket #1045):
distrib/sets/lists/man/mi: revision 1.1160
share/man/man4/Makefile: revision 1.499
share/man/man4/wb.4: revision 1.1-1.2
share/man/man4/ld.4: revision 1.17
sys/arch/i386/conf/ALL: revision 1.215-1.216 + patch
sys/arch/i386/conf/GENERIC: revision 1.946-1.947 + patch
sys/arch/amd64/conf/GENERIC: revision 1.254-1.256 + patch
sys/conf/files: revision 1.958
sys/dev/acpi/files.acpi: revision 1.59
sys/dev/acpi/wb_acpi.c: revision 1.1
sys/dev/ic/w83l518d.c: revision 1.1
sys/dev/ic/w83l518d_sdmmc.c: revision 1.1
sys/dev/ic/w83l518d_sdmmc.h: revision 1.1
sys/dev/ic/w83l518dreg.h: revision 1.1
sys/dev/ic/w83l518dvar.h.c: revision 1.1

wb(4): Add a driver for Winbond W83L518D SD/MMC readers.
 1.52.8.2 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #896):
sys/dev/acpi/acpi_button.c: revision 1.27 via patch
sys/dev/acpi/acpi_wakedev.h: revision 1.1 via patch
sys/dev/acpi/acpi_wakedev.c: revision 1.1 via patch
sys/dev/acpi/files.acpi: revision 1.55 via patch
sys/dev/acpi/acpi.c: revision 1.127 via patch
sys/dev/acpi/acpi_lid.c: revision 1.27 via patch
add hw.wake.* sysctl subtree for toggling which devices are allowed to
restore the system from sleep. set/clear wake GPEs as specified before
entering sleep.
by default, the following devices are enabled for wake:
- sleep/power buttons
- lid switch
- pc kbd controller
reviewed by: joerg
 1.52.8.1 30-Aug-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #891):
sys/dev/acpi/asus_acpi.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.54
- add experimental cpu fan/voltage switching support (sysctl hw.asus0.*)
- add fan sensor
- rename asus_softc_t -> struct asus_softc
- add detach method
- update copyright for 2009
 1.66.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.66.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.66.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.66.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.67.2.3 05-Mar-2011  rmind sync with head
 1.67.2.2 03-Jul-2010  rmind sync with head
 1.67.2.1 30-May-2010  rmind sync with head
 1.84.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.86.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.88.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.92.6.1 18-Feb-2012  mrg merge to -current.
 1.92.2.2 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.92.2.1 17-Apr-2012  yamt sync with head
 1.93.10.1 18-May-2014  rmind sync with head
 1.93.6.2 03-Dec-2017  jdolecek update from HEAD
 1.93.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.94.4.1 22-Sep-2014  martin Pull up following revision(s) (requested by mrg in ticket #111):
sys/dev/acpi/files.acpi: revision 1.95
share/man/man4/acpi.4: revision 1.78
sys/dev/acpi/acpi_pci_link.c: revision 1.22
introduce a new option: ACPI__DIS_IS_BROKEN. this is a hack to
avoid calling the "_DIS" method during acpi interrupt link setup,
which hangs various nforce4 based motherboards.
when the problem is properly fixed, remove this hack. for now,
it allows someone (me) to have a valid kernel config that doesn't
require a source hack every new tree.
ok chs@
 1.95.2.3 09-Jul-2016  skrll Sync with HEAD
 1.95.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.95.2.1 22-Sep-2015  skrll Sync with HEAD
 1.101.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.101.4.1 10-Jun-2019  christos Sync with HEAD
 1.101.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.101.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.101.2.1 20-Oct-2018  pgoyette Sync with head
 1.114.6.1 29-Feb-2020  ad Sync with head.
 1.115.6.2 03-Apr-2021  thorpej Sync with HEAD.
 1.115.6.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.126.4.4 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.126.4.3 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #936):

sys/dev/acpi/apei_einjvar.h: revision 1.1
sys/dev/acpi/apei_cper.h: revision 1.2
distrib/sets/lists/debug/module.md.i386: revision 1.9
sys/dev/acpi/apei_hest.c: revision 1.1
sys/modules/apei/Makefile: revision 1.1
sys/dev/acpi/apei_hest.c: revision 1.2
distrib/sets/lists/modules/md.amd64: revision 1.101
sys/dev/acpi/apei_hest.c: revision 1.3
distrib/sets/lists/modules/md.amd64: revision 1.102
sys/modules/apei/apei.ioconf: revision 1.1
sys/dev/acpi/apei_bert.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.1785
sys/dev/acpi/apei_bertvar.h: revision 1.1
sys/dev/acpi/apei.c: revision 1.1
sys/dev/acpi/apei.c: revision 1.2
sys/dev/acpi/apei.c: revision 1.3
sys/modules/Makefile: revision 1.283
sys/modules/Makefile: revision 1.284
sys/dev/acpi/apei_reg.c: revision 1.1
sys/dev/acpi/apei_hestvar.h: revision 1.1
distrib/sets/lists/debug/module.md.i386: revision 1.10
sys/dev/acpi/apei_reg.c: revision 1.2
sys/dev/acpi/apei_reg.c: revision 1.3
sys/dev/acpi/apei_reg.h: revision 1.1
sys/dev/acpi/apei_reg.h: revision 1.2
sys/dev/acpi/apei_reg.h: revision 1.3
sys/dev/acpi/acpi_hed.c: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.1
sys/dev/acpi/apeivar.h: revision 1.1
sys/dev/acpi/apei_einj.c: revision 1.2
sys/dev/acpi/apei_einj.c: revision 1.3
sys/dev/acpi/apei_einj.c: revision 1.4
sys/dev/acpi/apei_einj.c: revision 1.5
share/man/man4/Makefile: revision 1.734
sys/dev/acpi/apei_einj.c: revision 1.6
sys/dev/acpi/apei_einj.c: revision 1.7
sys/dev/acpi/files.acpi: revision 1.131
sys/dev/acpi/files.acpi: revision 1.132
sys/dev/acpi/apei_interp.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.2
share/man/man4/acpihed.4: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.3
share/man/man4/acpihed.4: revision 1.2
distrib/sets/lists/modules/md.i386: revision 1.98
sys/dev/acpi/apei_mapreg.c: revision 1.2
sys/dev/acpi/apei_interp.h: revision 1.1
sys/dev/acpi/apei_interp.c: revision 1.4
distrib/sets/lists/modules/md.i386: revision 1.99
sys/modules/acpihed/Makefile: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.3
sys/dev/acpi/apei_interp.h: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.185
sys/dev/acpi/apei_mapreg.h: revision 1.1
sys/dev/acpi/apei_mapreg.c: revision 1.4
sys/arch/amd64/conf/ALL: revision 1.186
sys/dev/acpi/apei_erstvar.h: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.1
sys/dev/acpi/apei_erst.c: revision 1.2
sys/dev/acpi/apei_erst.c: revision 1.3
sys/arch/i386/conf/ALL: revision 1.516
share/man/man4/apei.4: revision 1.1
sys/arch/i386/conf/ALL: revision 1.517
share/man/man4/apei.4: revision 1.2
distrib/sets/lists/debug/module.md.amd64: revision 1.15
sys/modules/acpihed/acpihed.ioconf: revision 1.1
sys/dev/acpi/apei_hed.h: revision 1.1
distrib/sets/lists/debug/module.md.amd64: revision 1.16
sys/dev/acpi/apei_cper.h: revision 1.1

(all via patch)

apei(4): New driver for ACPI Platform Error Interfaces.

For now it is wired up only in x86 ALL kernels, and built as a module
for x86 and Arm. Once it gets a little more testing on machines with
APEI, I would like to flip it on by default.
PR kern/58046

apei(4): Pacify -Wsign-compare.
Assert that the parsing made forward progress too while here.
PR kern/58046

apei(4): Tweak some comments about the APEI interpreter language.
No functional change intended.
PR kern/58046

apei(4): Fix parsing checks for TRIGGER_ERROR action table.
The TableSize is size of the header plus the body, not just the body.
PR kern/58046
apei(4): Note some TODOs for EINJ and HEST.
No functional change intended, comments only.
PR kern/58046

acpihed(4): New driver for PNP0C33 to notify apei(4).
PNP0C33 denotes the ACPI Hardware Error Device, which exists only to
be a vector for event notifications.
PR kern/58046

acpihed(4): fix name in Dt, use Ql
apei(4): Plug memory leak on teardown of instruction interpreter.
PR kern/58046
apei(4): Fix indexing of multi-unit register access.
PR kern/58046

apei(4): Fix register chunk counting.
Now it will actually read and write the registers!
Have been updating and reloading the wrong module to test this, oops.
PR kern/58046

apei(4): Allow pre-mapping I/O registers too.
PR kern/58046

apei(4): Pre-map registers when compiling interpreter.
This way we don't have to worry about mapping them in nasty contexts
where access to uvm_km_alloc may not be allowed. Paves the way to
use ERST for saving dmesg on crash.
Exception: ACPI_ERST_MOVE_DATA still needs to do AcpiOsMapMemory.
We'll need to reserve a couple pages to avoid that.
PR kern/58046

apei(4): Simplify EINJ/ERST register access now that it's pre-mapped.
PR kern/58046
apei(4): Make sure to initialize *fatalp in apei_gesb_report.
PR kern/58046

apei: fix typos in comments

apei: fix typos in comments and snprintb bitfmt

apei(4): Fix uninitialized stack access in error branch.
PR kern/58046

apei(4), acpihed(4): Wire up man pages to build.
PR kern/58046: Missing APEI (ACPI Platform Error Interface) support
 1.126.4.2 25-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #639):

sys/dev/acpi/acpivar.h: revision 1.90
sys/dev/acpi/files.acpi: revision 1.129
sys/dev/acpi/acpi.c: revision 1.299
sys/dev/acpi/files.acpi: revision 1.130

acpi(4): New iattr `apeibus' for attaching an APEI driver.

APEI is the ACPI Platform Error Interface, a standard (if very
complicated) interface for reporting hardware errors to the OS.
Firmware support for APEI is presented through the ACPI tables BERT
(Boot Error Record Table), ERST (Error Record Serialization Table),
EINJ (Error Injection Table), and HEST (Hardware Error Source Table),
rather than through nodes in the ACPI device tree, so it can't just
attach through the existing acpinodebus iattr and instead requires a
special pseudo-bus like acpiwdrt(4).

No driver yet -- this is just the hook to attach one in a module.

The new member sc_apei of struct acpi_softc is placed at the end of
the structure so that this change can be safely pulled up to release
branches without risk to ABI compatibility in existing modules such
as acpiverbose.kmod which may rely on the layout (but not size) of
struct acpi_softc.

PR kern/58046

acpi(4): Make apeibus actually work as an iattr.
PR kern/58046
 1.126.4.1 30-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #259):

sys/dev/acpi/acpi_ec.c: revision 1.102
sys/dev/acpi/acpi_ec.c: revision 1.103
sys/dev/acpi/acpi_ec.c: revision 1.104
sys/dev/acpi/acpi_ec.c: revision 1.105
sys/dev/acpi/acpi_ec.c: revision 1.106
sys/dev/acpi/acpi_ec.c: revision 1.107
sys/dev/acpi/acpi_ec.c: revision 1.108
sys/dev/acpi/acpi_ec.c: revision 1.90
sys/dev/acpi/acpi_ec.c: revision 1.91
sys/dev/acpi/acpi_ec.c: revision 1.92
sys/dev/acpi/acpi_ec.c: revision 1.93
sys/dev/acpi/acpi_ec.c: revision 1.94
sys/dev/acpi/files.acpi: revision 1.128
sys/dev/acpi/acpi_ec.c: revision 1.95
sys/dev/acpi/acpi_ec.c: revision 1.96
sys/dev/acpi/acpi_ec.c: revision 1.97
sys/arch/amd64/conf/ALL: revision 1.179
sys/dev/acpi/acpi_ec.c: revision 1.98
sys/dev/acpi/acpi_ec.c: revision 1.99
sys/dev/acpi/acpi_ec.c: revision 1.87
sys/dev/acpi/acpi_ec.c: revision 1.88
sys/dev/acpi/acpi_ec.c: revision 1.89
sys/arch/i386/conf/ALL: revision 1.511
sys/dev/acpi/acpi_ec.c: revision 1.100
sys/dev/acpi/acpi_ec.c: revision 1.101

acpiec(4): Record device_t self.

Not used yet, to be used soon for device_printf and to allow making
some of the internal functions a little more type-safe later.
acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.

acpiec(4): Clarify lock order and sprinkle lock assertions.
No functional change intended.

acpiec(4): Sprinkle comments.
Note where this code is abusing cv_wait and needs a loop to handle
spurious wakeups.
No functional change intended.

acpiec(4): Assert state is free when we start a transaction.
No functional change intended.

acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:
PR kern/53135
PR kern/52763
PR kern/57162

acpiec(4): Fix cv_wait loop around sc->sc_got_sci.

That is, make it actually loop as required, so it gracefully handles
spurious wakeups instead of barging into invalid states.

acpiec(4): Fix interrupt wait loop in acpiec_gpe_query thread.

acpiec(4): Fix cv_timedwait abuse in acpiec_read/write.

acpiec(4): Don't touch sc->sc_state outside sc->sc_mtx.

acpiec(4): Merge returns in acpiec_read/write.
No functional change intended.

acpiec(4): Factor wait logic out.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_state_machine.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_callout.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_handler.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_lock/unlock.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_read/write.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_query thread.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_space_handler.
Better to keep the device_t isolated to public interfaces. Simpler
internally this way.
No functional change intended.

acpiec(4): Factor out if (state == FREE) cv_signal(sc_cv).

In principle this could have a functional change, but at worst, it is
to signal more wakeups than needed, which should always be safe.
acpiec(4): Take a lock around acpiec_cold updates.

Otherwise we race with readers -- probably harmlessly, but let's
avoid the appearance of problems.
XXX Maybe acpiec_suspend and acpiec_shutdown should interrupt
transactions and force them to fail promptly?
XXX This looks bad because acpiec_cold is global and sc->sc_mtx
doesn't look like it's global, but we expect to have only one
acpiec(4) device anyway from what I understand. Maybe we should move
acpiec_cold into the softc?

acpiec(4): One more debug message about read/write polling timeout.
 1.132.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.4 25-Feb-2014  pooka branches: 1.4.44;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.3 02-Jun-2012  dsl branches: 1.3.2; 1.3.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.2 15-Mar-2012  bouyer Do not use uninitialized level if fujitsu_bp_get_brightness() returned
an error; from gcc -O3 (completely harmless in this case though).
 1.1 20-Feb-2011  jruoho branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.14;
Split fujbp(4) and fujhk(4) to separate instances from fujitsu(4). Allows
modularization and takes care of tsutsui@'s justified concern over the too
generic name "fujitsu". Ok gsutre@.
 1.1.14.1 05-Apr-2012  mrg sync to latest -current.
 1.1.10.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.1.10.2 30-Oct-2012  yamt sync with head
 1.1.10.1 17-Apr-2012  yamt sync with head
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 20-Feb-2011  jruoho file fujbp_acpi.c was added on branch jruoho-x86intr on 2011-06-06 09:07:43 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 20-Feb-2011  rmind file fujbp_acpi.c was added on branch rmind-uvmplock on 2011-03-05 20:53:04 +0000
 1.1.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.1.2.1 20-Feb-2011  bouyer file fujbp_acpi.c was added on branch bouyer-quota2 on 2011-03-05 15:10:16 +0000
 1.3.4.1 18-May-2014  rmind sync with head
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.44.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.4 23-Apr-2015  pgoyette branches: 1.4.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.3 25-Feb-2014  pooka branches: 1.3.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.2 02-Jun-2012  dsl branches: 1.2.2; 1.2.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.1 20-Feb-2011  jruoho branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Split fujbp(4) and fujhk(4) to separate instances from fujitsu(4). Allows
modularization and takes care of tsutsui@'s justified concern over the too
generic name "fujitsu". Ok gsutre@.
 1.1.10.2 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.1.10.1 30-Oct-2012  yamt sync with head
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 20-Feb-2011  jruoho file fujhk_acpi.c was added on branch jruoho-x86intr on 2011-06-06 09:07:43 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 20-Feb-2011  rmind file fujhk_acpi.c was added on branch rmind-uvmplock on 2011-03-05 20:53:04 +0000
 1.1.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.1.2.1 20-Feb-2011  bouyer file fujhk_acpi.c was added on branch bouyer-quota2 on 2011-03-05 15:10:16 +0000
 1.2.4.1 18-May-2014  rmind sync with head
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.1 06-Jun-2015  skrll Sync with HEAD
 1.4.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 20-Feb-2011  jruoho Split fujbp(4) and fujhk(4) to separate instances from fujitsu(4). Allows
modularization and takes care of tsutsui@'s justified concern over the too
generic name "fujitsu". Ok gsutre@.
 1.2 05-Nov-2010  gsutre branches: 1.2.2; 1.2.4; 1.2.6;
Hm, the warning sign was not big enough.
 1.1 05-Nov-2010  gsutre Merge ACPI Fujitsu Driver. Provides support for hotkeys and other
built-in components through vendor-specific ACPI devices.

ok jruoho@
 1.2.6.1 05-Mar-2011  bouyer Sync with HEAD
 1.2.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.2.2.1 05-Nov-2010  uebayasi file fujitsu_acpi.c was added on branch uebayasi-xip on 2010-11-06 08:08:28 +0000
 1.6 15-Sep-2024  skrll genet(4): Remove the non-MP-safe scaffolding...

I forgot two files in the previous commit.
 1.5 03-May-2021  rin branches: 1.5.20;
genet(4): Add support for rnd(9).
 1.4 29-Jan-2021  thorpej branches: 1.4.4;
Use acpi_compatible_match().
 1.3 07-Dec-2020  jmcneill Fix 32-bit build.
 1.2 25-May-2020  jmcneill branches: 1.2.2;
Improve RGMII TX / RX delay handling, from OpenBSD.
 1.1 22-Feb-2020  jmcneill branches: 1.1.2; 1.1.6;
Add ACPI glue for Broadcom GENETv5
 1.1.6.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.6.1 22-Feb-2020  martin file genet_acpi.c was added on branch phil-wifi on 2020-04-08 14:08:02 +0000
 1.1.2.2 29-Feb-2020  ad Sync with head.
 1.1.2.1 22-Feb-2020  ad file genet_acpi.c was added on branch ad-namecache on 2020-02-29 20:19:07 +0000
 1.2.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.2.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.4.4.1 13-May-2021  thorpej Sync with HEAD.
 1.5.20.1 02-Aug-2025  perseant Sync with HEAD
 1.6 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.5 23-Apr-2015  pgoyette branches: 1.5.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.4 14-Aug-2012  jruoho branches: 1.4.2; 1.4.16;
Collect rnd(9) entropy from coretemp(4), acpibat(4), aibs(4), hpacel(4),
thinkpad(4), and aps(4).
 1.3 07-Sep-2011  cegger branches: 1.3.2;
hpacel_reg_info() wants a device_t and not an ACPI_HANDLE.
Fixes NULL pointer dereference in hpacel_reg_info().
 1.2 13-Jul-2011  jruoho Fix autoconf(9) attach message.
 1.1 13-Jul-2011  jruoho A driver for HP 3D DriverGuard; a LIS3LV02DL-based accelerometer. Tested on
HP NC4400. Like aps(4), this is commented out in the GENERIC kernels.
 1.3.2.1 30-Oct-2012  yamt sync with head
 1.4.16.1 06-Jun-2015  skrll Sync with HEAD
 1.4.2.1 03-Dec-2017  jdolecek update from HEAD
 1.5.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.12 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.11 15-Jun-2011  jruoho branches: 1.11.68;
Do not entirely bypass the printfs during resource parsing, as many drivers
rely on those for their autoconf(9) messages. Instead add a "quiet" option.
 1.10 15-Jun-2011  jruoho Modularize hpet(4). Works nicely with the multiple bus locations.
 1.9 15-Jun-2011  jruoho Use defined constants.
 1.8 15-Jun-2011  jruoho Add detach function for hpet(4) at amdpcib(4).
 1.7 14-Jun-2011  jruoho Add detach function.
 1.6 14-Jun-2011  jruoho Try to attach hpet(4) also via a specific HPET table. Fixes PR kern/43702.
 1.5 05-Mar-2010  jruoho branches: 1.5.8;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.4 17-Feb-2009  jmcneill branches: 1.4.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.3 21-Mar-2008  xtraeme branches: 1.3.4; 1.3.12; 1.3.14; 1.3.18; 1.3.22;
Split device_t/softc for all hpet consumers.
 1.2 19-Oct-2007  ad branches: 1.2.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.1 08-Mar-2007  njoly branches: 1.1.2; 1.1.4; 1.1.16; 1.1.18; 1.1.20; 1.1.24;
High Precision Event Timer driver, following Intel specifications.

Allow attachement at both ACPI (hpet@acpi) and AMD8111 LPC Controller
(hpet@amdpcib).

Requested by xtraeme, and tested by a few users.
 1.1.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.20.4 24-Mar-2008  yamt sync with head.
 1.1.20.3 27-Oct-2007  yamt sync with head.
 1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.20.1 08-Mar-2007  yamt file hpet_acpi.c was added on branch yamt-lazymbuf on 2007-09-03 14:33:21 +0000
 1.1.18.2 23-Mar-2008  matt sync with HEAD
 1.1.18.1 06-Nov-2007  matt sync with HEAD
 1.1.16.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.1.4.1 08-Mar-2007  rmind file hpet_acpi.c was added on branch yamt-idlelwp on 2007-03-12 06:14:50 +0000
 1.1.2.1 23-Oct-2007  ad Sync with head.
 1.2.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.22.1 21-Apr-2010  matt sync to netbsd-5
 1.3.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.3.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.3.4.2 11-Mar-2010  yamt sync with head
 1.3.4.1 04-May-2009  yamt sync with head.
 1.4.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11.68.1 03-Apr-2021  thorpej Sync with HEAD.
 1.11 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.10 23-Apr-2015  pgoyette branches: 1.10.32;
Update module dependencies for all the existing modules that depend on sysmon components.
 1.9 16-Feb-2011  jruoho branches: 1.9.14; 1.9.32;
Change the preprocessor defines around the module(9)'s modcmd() calls such
that the modules show in modstat(8) even though these are "builtin".
 1.8 26-Oct-2010  jruoho branches: 1.8.2; 1.8.4;
Add support for module(9).
 1.7 05-Mar-2010  jruoho branches: 1.7.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.6 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.5 30-Jan-2010  jruoho branches: 1.5.2;
Add the _COMPONENT definition for ACPI_DEBUG.
 1.4 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.3 25-Sep-2009  dyoung Use deviter_first()/deviter_next() instead of accessing alldevs
directly. Compile-tested, only.
 1.2 02-May-2008  simonb branches: 1.2.4; 1.2.6; 1.2.8;
Sprinkle a teeny bit of KNF goodness..
 1.1 01-May-2008  cegger hpqlb(4): driver for HP Quick Launch buttons - found on HP Pavilion Notebooks
 1.2.8.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.1 02-May-2008  mjf file hpqlb_acpi.c was added on branch mjf-devfs2 on 2008-06-02 13:23:13 +0000
 1.2.6.2 18-May-2008  yamt sync with head.
 1.2.6.1 02-May-2008  yamt file hpqlb_acpi.c was added on branch yamt-pf42 on 2008-05-18 12:33:34 +0000
 1.2.4.3 11-Mar-2010  yamt sync with head
 1.2.4.2 16-May-2008  yamt sync with head.
 1.2.4.1 02-May-2008  yamt file hpqlb_acpi.c was added on branch yamt-nfs-mp on 2008-05-16 02:23:53 +0000
 1.5.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.5.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.2.1 05-Mar-2011  rmind sync with head
 1.8.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.32.1 06-Jun-2015  skrll Sync with HEAD
 1.9.14.1 03-Dec-2017  jdolecek update from HEAD
 1.10.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 02-Feb-2024  andvar s/attachement/attachment/ and s/detachement/detachment/.
 1.2 27-Feb-2023  msaitoh igpio(4): Disable Baytrail and Lynxpoint support. Fixes PR kern/57225.

It seems additional code is required to support Baytrail and Lynxpoint.
Disable those support.
 1.1 24-Mar-2022  manu branches: 1.1.4;
Add initial support for Intel GPIO chips
 1.1.4.1 12-Mar-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #116):

sys/dev/acpi/igpio_acpi.c: revision 1.2
share/man/man4/igpio.4: revision 1.4

igpio(4): Disable Baytrail and Lynxpoint support. Fixes PR kern/57225.
It seems additional code is required to support Baytrail and Lynxpoint.

Disable those support.
 1.6 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.5 24-Apr-2021  thorpej branches: 1.5.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.4 29-Jan-2021  thorpej branches: 1.4.2;
Use acpi_compatible_match().
 1.3 30-Jan-2019  christos branches: 1.3.4; 1.3.14;
don't print resources twice. It is automagically done in acpi_res_parse_fini.
 1.2 26-Dec-2018  mlelstv branches: 1.2.2;
Fix 32bit build.
 1.1 25-Dec-2018  mlelstv Make ipmi driver available to other platforms.
Add ACPI attachment.
 1.2.2.3 01-Jan-2019  pgoyette Bring in some fixes from HEAD to address a couple of build breaks (in
i386 ipmi driver and sun2 rump tests). Also fix a 'resolve conflict'
from previous commit in sparc64

With this, I am able to successfully build 66 out of 67 architectures
(the same architectures as handled by the releng build server. The
only exception is evbarm64 which has a strange build failure during
the installcd step - the same failure occurs on HEAD. It seems to be
something in the build itself, perhaps a difference between handling
of -O vs -M (MAKEOBJDIR vs MAKEOBJDIRPREFIX).
 1.2.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.2.1 26-Dec-2018  pgoyette file ipmi_acpi.c was added on branch pgoyette-compat on 2018-12-26 14:01:47 +0000
 1.3.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 30-Jan-2019  christos file ipmi_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.4.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.5.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 22-Jan-2012  christos remove aborted work in progress
 1.1 22-Jan-2012  christos add a tpm driver from bsssd.sourceforge.net
 1.12 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.11 23-Nov-2011  jmcneill branches: 1.11.64;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.10 05-Mar-2010  jruoho branches: 1.10.10; 1.10.12;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.9 17-Feb-2009  jmcneill branches: 1.9.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.8 26-Mar-2008  xtraeme branches: 1.8.4; 1.8.12; 1.8.14; 1.8.16; 1.8.18; 1.8.22;
Split device_t/softc for joy(4) and all its attachments. Also
use device_lookup_private() and related cosmetic changes.

Reviewed by cube@.
 1.7 19-Oct-2007  ad branches: 1.7.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 06-Oct-2007  xtraeme branches: 1.6.2;
Use a two clause license for all the code I contributed.

The envsys code will be changed later.
 1.5 16-Nov-2006  christos branches: 1.5.8; 1.5.22; 1.5.24; 1.5.26;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 20-Feb-2006  kochi branches: 1.3.14; 1.3.16;
use aprint_*
 1.2 11-Dec-2005  christos branches: 1.2.2; 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 02-Dec-2004  xtraeme branches: 1.1.4; 1.1.14;
Add ACPI joy(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed and ok'ed by cube@ and martin@.
 1.1.14.3 27-Oct-2007  yamt sync with head.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 21-Jun-2006  yamt sync with head.
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 02-Dec-2004  skrll file joy_acpi.c was added on branch ktrace-lwp on 2004-12-18 09:31:56 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 01-Mar-2006  yamt sync with head.
 1.3.16.2 10-Dec-2006  yamt sync with head.
 1.3.16.1 22-Oct-2006  yamt sync with head
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.5.26.1 14-Oct-2007  yamt sync with head.
 1.5.24.1 06-Nov-2007  matt sync with HEAD
 1.5.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.22.1 07-Oct-2007  joerg Sync with HEAD.
 1.5.8.2 23-Oct-2007  ad Sync with head.
 1.5.8.1 09-Oct-2007  ad Sync with head.
 1.6.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.22.1 21-Apr-2010  matt sync to netbsd-5
 1.8.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.16.1 12-Dec-2008  ad Checkpoint work in progress.
 1.8.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.8.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.8.4.2 11-Mar-2010  yamt sync with head
 1.8.4.1 04-May-2009  yamt sync with head.
 1.9.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.10.10.1 17-Apr-2012  yamt sync with head
 1.11.64.1 03-Apr-2021  thorpej Sync with HEAD.
 1.23 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.22 07-Dec-2020  jmcneill Fix 32-bit build.
 1.21 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.20 24-Jun-2018  jdolecek branches: 1.20.16;
use isa_intr_establish_xname() so this passes the device name
 1.19 05-Mar-2010  jruoho branches: 1.19.60;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.18 17-Feb-2009  jmcneill branches: 1.18.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.17 31-May-2008  jmcneill branches: 1.17.6; 1.17.8; 1.17.12; 1.17.16;
lpt(4): register NULL pmf handler.
 1.16 07-Mar-2008  cube branches: 1.16.2; 1.16.4; 1.16.6;
Split the softc from the device_t for all lpt(4) variants and attachments
except the ppbus stuff (which doesn't compile) and ulpt(4) which is
unrelated and can be dealt with separately.

As usual, it comes with related cosmetic changes.
 1.15 19-Oct-2007  ad branches: 1.15.12; 1.15.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.14 16-Nov-2006  christos branches: 1.14.8; 1.14.22; 1.14.24; 1.14.28;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 20-Feb-2006  kochi branches: 1.12.14; 1.12.16;
use aprint_*
 1.11 11-Dec-2005  christos branches: 1.11.2; 1.11.4; 1.11.6;
merge ktrace-lwp.
 1.10 01-May-2004  kochi branches: 1.10.12;
specify static where appropriate.
 1.9 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.8 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.7 03-Nov-2003  mycroft Match all PNP04?? IDs.
 1.6 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.5 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.4 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.3 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.2 09-Jan-2003  jdolecek branches: 1.2.2;
need to select proper IST for interrupt - IST_NONE is almost certainly not
right

this makes fdc@acpi and com@acpi actually work on my machine; lpt@acpi
change untested, but should be same as fdc and com
 1.1 28-Dec-2002  jmcneill branches: 1.1.2;
Add an lpt attachment to acpi(4)
 1.1.2.3 15-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 29-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 28-Dec-2002  thorpej file lpt_acpi.c was added on branch nathanw_sa on 2002-12-29 20:45:31 +0000
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.12.4 17-Mar-2008  yamt sync with head.
 1.10.12.3 27-Oct-2007  yamt sync with head.
 1.10.12.2 30-Dec-2006  yamt sync with head.
 1.10.12.1 21-Jun-2006  yamt sync with head.
 1.11.6.1 22-Apr-2006  simonb Sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 01-Mar-2006  yamt sync with head.
 1.12.16.2 10-Dec-2006  yamt sync with head.
 1.12.16.1 22-Oct-2006  yamt sync with head
 1.12.14.1 18-Nov-2006  ad Sync with head.
 1.14.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.14.24.2 23-Mar-2008  matt sync with HEAD
 1.14.24.1 06-Nov-2007  matt sync with HEAD
 1.14.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.8.1 23-Oct-2007  ad Sync with head.
 1.15.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.15.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.12.1 24-Mar-2008  keiichi sync with head.
 1.16.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.16.4.2 11-Mar-2010  yamt sync with head
 1.16.4.1 04-May-2009  yamt sync with head.
 1.16.2.1 04-Jun-2008  yamt sync with head
 1.17.16.1 21-Apr-2010  matt sync to netbsd-5
 1.17.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.8.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.17.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.60.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.16.2 03-Apr-2021  thorpej Sync with HEAD.
 1.20.16.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.16 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.15 07-Dec-2020  jmcneill Fix 32-bit build.
 1.14 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.13 09-Dec-2011  mrg branches: 1.13.62;
provide a lock for mpu_attach.
 1.12 24-Nov-2011  mrg branches: 1.12.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.11 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.10 05-Mar-2010  jruoho branches: 1.10.10; 1.10.12;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.9 17-Feb-2009  jmcneill branches: 1.9.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.8 27-Mar-2008  xtraeme branches: 1.8.4; 1.8.12; 1.8.14; 1.8.16; 1.8.18; 1.8.22;
Split device_t/softc for mpu(4) and its attachments, plus other
related cosmetic changes.

Reviewed by cube@.
 1.7 19-Oct-2007  ad branches: 1.7.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 06-Oct-2007  xtraeme branches: 1.6.2;
Use a two clause license for all the code I contributed.

The envsys code will be changed later.
 1.5 16-Nov-2006  christos branches: 1.5.8; 1.5.22; 1.5.24; 1.5.26;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 20-Feb-2006  kochi branches: 1.3.14; 1.3.16;
use aprint_*
 1.2 11-Dec-2005  christos branches: 1.2.2; 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 02-Dec-2004  xtraeme branches: 1.1.4; 1.1.14;
Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.1.14.3 27-Oct-2007  yamt sync with head.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 21-Jun-2006  yamt sync with head.
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 02-Dec-2004  skrll file mpu_acpi.c was added on branch ktrace-lwp on 2004-12-18 09:31:56 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 01-Mar-2006  yamt sync with head.
 1.3.16.2 10-Dec-2006  yamt sync with head.
 1.3.16.1 22-Oct-2006  yamt sync with head
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.5.26.1 14-Oct-2007  yamt sync with head.
 1.5.24.1 06-Nov-2007  matt sync with HEAD
 1.5.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.22.1 07-Oct-2007  joerg Sync with HEAD.
 1.5.8.2 23-Oct-2007  ad Sync with head.
 1.5.8.1 09-Oct-2007  ad Sync with head.
 1.6.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.22.1 21-Apr-2010  matt sync to netbsd-5
 1.8.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.16.1 12-Dec-2008  ad Checkpoint work in progress.
 1.8.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.8.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.8.4.2 11-Mar-2010  yamt sync with head
 1.8.4.1 04-May-2009  yamt sync with head.
 1.9.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.10.10.1 17-Apr-2012  yamt sync with head
 1.12.2.1 18-Feb-2012  mrg merge to -current.
 1.13.62.2 03-Apr-2021  thorpej Sync with HEAD.
 1.13.62.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.7 15-Sep-2025  thorpej No longer need to include acpi_i2c.h here.
 1.6 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.5 22-Jul-2022  thorpej Normalize how motoi2c controllers are attached.
 1.4 29-Jan-2021  thorpej branches: 1.4.4; 1.4.6; 1.4.16;
Use acpi_compatible_match().
 1.3 26-Jan-2021  jmcneill Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.2 25-Jan-2021  jmcneill Configure clocks and enable NXP Layerscape quirks in motoi2c
 1.1 24-Jan-2021  jmcneill Add support for NXP Layerscape I2C controllers.
 1.4.16.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.4.6.2 25-Apr-2021  thorpej - Don't use acpi_enter_i2c_devs() -- it no longer exists.
- Pass along our devhandle to the i2c bus instance.
 1.4.6.1 25-Apr-2021  thorpej acpi_i2c.h is no more.
 1.4.4.2 03-Apr-2021  thorpej Sync with HEAD.
 1.4.4.1 29-Jan-2021  thorpej file nxpiic_acpi.c was added on branch thorpej-futex on 2021-04-03 22:28:43 +0000
 1.2 26-Dec-2021  jmcneill acpi: ohci: Match "generic-ohci" compatible string
 1.1 24-Dec-2021  jmcneill Add ohci at acpi bindings. No known PNP IDs for this, so match using _CLS
and the PCI class/subclass/interface codes. Maybe this will take off.
 1.40 10-Nov-2024  martin Add ELAN0501 trackpads in ps2-compat mode to the quirks table of devices
not requiring an interrupt for the aux slot.
 1.39 29-Jan-2021  thorpej branches: 1.39.24;
Use acpi_compatible_match() / acpi_compatible_lookup().
 1.38 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.37 11-Aug-2019  rin branches: 1.37.8;
Appease GCC maybe-uninitialized for optimization level -Os on amd64.
 1.36 28-Oct-2017  riastradh branches: 1.36.4;
Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.35 18-Oct-2016  jdolecek branches: 1.35.6;
provide intr xname
 1.34 17-Oct-2013  christos branches: 1.34.6; 1.34.10;
remove unused variable
 1.33 05-Mar-2010  jruoho branches: 1.33.10; 1.33.20; 1.33.24;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.32 29-Aug-2009  jmcneill branches: 1.32.2;
PR# port-i386/39671: panic while booting with an acpi kernel on a 790GX board

If the firmware describes duplicate keyboard controller nodes, don't panic
when the driver fails to map registers.
 1.31 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.30 16-Sep-2008  pgoyette branches: 1.30.2; 1.30.4; 1.30.8; 1.30.10; 1.30.12;
Add another touchpad device - this one found in my Acer2413WLCi laptop.

Tested by me.
OK garbled@
 1.29 12-Jun-2008  cegger branches: 1.29.2;
use device_lookup_private to get softc
 1.28 03-May-2008  jmcneill branches: 1.28.2; 1.28.4;
Use M_ZERO instead of malloc+memset
 1.27 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.26 16-Mar-2008  cube branches: 1.26.2; 1.26.4;
Don't assume a struct device is embedded in the softc.
 1.25 15-Mar-2008  cube Split device_t and softc for pckbc(4) and its attachments.
 1.24 04-Jan-2008  ad branches: 1.24.2; 1.24.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.23 09-Dec-2007  jmcneill branches: 1.23.2;
Merge jmcneill-pm branch.
 1.22 19-Oct-2007  ad branches: 1.22.2; 1.22.4; 1.22.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.21 05-Oct-2007  jmcneill branches: 1.21.2;
Sort IO resources before attempting to attach; resolves issues on ACPI
firmware that reports 0x64,0x60 instead of 0x60,0x64. Patch tested by
Greg A. Woods.
 1.20 09-Jul-2007  ad branches: 1.20.6; 1.20.8; 1.20.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.19 16-Nov-2006  christos branches: 1.19.2; 1.19.8; 1.19.10; 1.19.16;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 20-Feb-2006  kochi branches: 1.17.14; 1.17.16;
use aprint_*
 1.16 11-Dec-2005  christos branches: 1.16.2; 1.16.4; 1.16.6;
merge ktrace-lwp.
 1.15 01-May-2004  kochi branches: 1.15.12;
specify static where appropriate.
 1.14 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.13 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.12 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.11 03-Nov-2003  mycroft Rework slightly so we use acpi_match_hid() in pckbc_acpi_attach() too.
 1.10 03-Nov-2003  mycroft Match all PNP03?? IDs.
Also match more PNP0F?? IDs (e.g. the one the HP OmniBook reports). There's
also no need to check IBM3780 any more, as the IBM and Acer machines which
returned it also return a CID of PNP0F13.
 1.9 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.8 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.7 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.6 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.5 27-Oct-2003  christos Fix uninitialized variable warnings.
 1.4 27-Jan-2003  jmcneill branches: 1.4.2;
Attach to PNP0F03 -- makes the PS/2 mouse on this Dell work.
 1.3 28-Dec-2002  matt branches: 1.3.2;
Only remember the softc if was for the keyboard port. Only try to attach
the console to a keyboard port.
 1.2 28-Dec-2002  matt Add IBM3780 (PNP id for IBM's trackpoint). Also consider anything starting
with PNP0F as a mouse.
 1.1 28-Dec-2002  matt Add a pckbc acpi attachment (it compiles but it untested).
 1.3.2.2 29-Dec-2002  thorpej Sync with HEAD.
 1.3.2.1 28-Dec-2002  thorpej file pckbc_acpi.c was added on branch nathanw_sa on 2002-12-29 20:45:31 +0000
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.12.6 17-Mar-2008  yamt sync with head.
 1.15.12.5 21-Jan-2008  yamt sync with head
 1.15.12.4 27-Oct-2007  yamt sync with head.
 1.15.12.3 03-Sep-2007  yamt sync with head.
 1.15.12.2 30-Dec-2006  yamt sync with head.
 1.15.12.1 21-Jun-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.16.2.1 01-Mar-2006  yamt sync with head.
 1.17.16.2 10-Dec-2006  yamt sync with head.
 1.17.16.1 22-Oct-2006  yamt sync with head
 1.17.14.1 18-Nov-2006  ad Sync with head.
 1.19.16.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.19.10.1 11-Jul-2007  mjf Sync with head.
 1.19.8.3 23-Oct-2007  ad Sync with head.
 1.19.8.2 09-Oct-2007  ad Sync with head.
 1.19.8.1 01-Jul-2007  ad Adapt to callout API change.
 1.19.2.1 07-Oct-2007  xtraeme Pull up following revision(s) (requested by jmcneill in ticket #924):
sys/dev/acpi/pckbc_acpi.c: revision 1.21
Sort IO resources before attempting to attach; resolves issues on ACPI
firmware that reports 0x64,0x60 instead of 0x60,0x64. Patch tested by
Greg A. Woods.
 1.20.10.1 14-Oct-2007  yamt sync with head.
 1.20.8.3 23-Mar-2008  matt sync with HEAD
 1.20.8.2 09-Jan-2008  matt sync with HEAD
 1.20.8.1 06-Nov-2007  matt sync with HEAD
 1.20.6.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.20.6.6 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.20.6.5 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.6.4 07-Oct-2007  joerg Sync with HEAD.
 1.20.6.3 05-Oct-2007  jmcneill Sort IO resources; hopefully will help firmware that reports pckbc IO
resources in a different order than we expect.
 1.20.6.2 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.20.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.21.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.6.1 11-Dec-2007  yamt sync with head.
 1.22.4.1 26-Dec-2007  ad Sync with head.
 1.22.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.23.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.24.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.24.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.24.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.24.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.2.1 24-Mar-2008  keiichi sync with head.
 1.26.4.4 11-Mar-2010  yamt sync with head
 1.26.4.3 16-Sep-2009  yamt sync with head
 1.26.4.2 04-May-2009  yamt sync with head.
 1.26.4.1 16-May-2008  yamt sync with head.
 1.26.2.2 17-Jun-2008  yamt sync with head.
 1.26.2.1 18-May-2008  yamt sync with head.
 1.28.4.1 18-Jun-2008  simonb Sync with head.
 1.28.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.28.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.2.1 19-Oct-2008  haad Sync with HEAD.
 1.30.12.1 21-Apr-2010  matt sync to netbsd-5
 1.30.10.1 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #939):
sys/dev/acpi/pckbc_acpi.c: revision 1.32
PR# port-i386/39671: panic while booting with an acpi kernel on a 790GX board
If the firmware describes duplicate keyboard controller nodes, don't panic
when the driver fails to map registers.
 1.30.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.4.2 05-Sep-2009  bouyer Pull up following revision(s) (requested by jmcneill in ticket #939):
sys/dev/acpi/pckbc_acpi.c: revision 1.32
PR# port-i386/39671: panic while booting with an acpi kernel on a 790GX board
If the firmware describes duplicate keyboard controller nodes, don't panic
when the driver fails to map registers.
 1.30.4.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.30.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.32.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.33.24.1 18-May-2014  rmind sync with head
 1.33.20.2 03-Dec-2017  jdolecek update from HEAD
 1.33.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.10.1 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.34.10.3 04-Nov-2016  pgoyette Sync with HEAD
 1.34.10.2 26-Jul-2016  pgoyette Fix conversion to device_lookup_acquire()
 1.34.10.1 26-Jul-2016  pgoyette Sync with HEAD
 1.34.6.1 05-Dec-2016  skrll Sync with HEAD
 1.35.6.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.36.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.8.2 03-Apr-2021  thorpej Sync with HEAD.
 1.37.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.39.24.1 02-Aug-2025  perseant Sync with HEAD
 1.13 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.12 05-Mar-2010  jruoho branches: 1.12.76;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.11 17-Feb-2009  jmcneill branches: 1.11.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.10 04-Mar-2008  cube branches: 1.10.4; 1.10.12; 1.10.14; 1.10.18; 1.10.22;
- Split device_t and softc for pcppi(4) and attimer(4)
- Change the attimer <-> pcppi communication using device_t so that
pcppi(4) doesn't have to know about the contents of struct attimer_softc.

XXX pcppi's childdet function is completely wrong. This has to be
XXX revisited later.
 1.9 10-Jan-2008  dyoung branches: 1.9.2; 1.9.6;
Support pcppi(4) detachment.

Use device_t, device_private(). Get rid of a struct device * cast.
 1.8 09-Dec-2007  jmcneill branches: 1.8.2;
Merge jmcneill-pm branch.
 1.7 19-Oct-2007  ad branches: 1.7.2; 1.7.4; 1.7.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 06-Oct-2007  xtraeme branches: 1.6.2;
Use a two clause license for all the code I contributed.

The envsys code will be changed later.
 1.5 16-Nov-2006  christos branches: 1.5.8; 1.5.22; 1.5.24; 1.5.26;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 20-Feb-2006  kochi branches: 1.3.14; 1.3.16;
use aprint_*
 1.2 11-Dec-2005  christos branches: 1.2.2; 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 21-Mar-2005  xtraeme branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add pcppi(4) ACPI attachment, which matches the "AT-style speaker
sound" ACPI device.

Reviewed by christos@.
 1.1.8.5 17-Mar-2008  yamt sync with head.
 1.1.8.4 21-Jan-2008  yamt sync with head
 1.1.8.3 27-Oct-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 21-Jun-2006  yamt sync with head.
 1.1.6.2 29-Apr-2005  kent sync with -current
 1.1.6.1 21-Mar-2005  kent file pcppi_acpi.c was added on branch kent-audio2 on 2005-04-29 11:28:45 +0000
 1.1.4.2 01-Apr-2005  skrll Sync with HEAD.
 1.1.4.1 21-Mar-2005  skrll file pcppi_acpi.c was added on branch ktrace-lwp on 2005-04-01 14:29:52 +0000
 1.1.2.2 26-Mar-2005  yamt sync with head.
 1.1.2.1 21-Mar-2005  yamt file pcppi_acpi.c was added on branch yamt-km on 2005-03-26 18:19:18 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 01-Mar-2006  yamt sync with head.
 1.3.16.2 10-Dec-2006  yamt sync with head.
 1.3.16.1 22-Oct-2006  yamt sync with head
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.5.26.1 14-Oct-2007  yamt sync with head.
 1.5.24.3 23-Mar-2008  matt sync with HEAD
 1.5.24.2 09-Jan-2008  matt sync with HEAD
 1.5.24.1 06-Nov-2007  matt sync with HEAD
 1.5.22.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.5.22.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.5.22.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.22.2 07-Oct-2007  joerg Sync with HEAD.
 1.5.22.1 21-Aug-2007  joerg pcppi can use the generic NULL power handler.
 1.5.8.2 23-Oct-2007  ad Sync with head.
 1.5.8.1 09-Oct-2007  ad Sync with head.
 1.6.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.6.1 11-Dec-2007  yamt sync with head.
 1.7.4.1 26-Dec-2007  ad Sync with head.
 1.7.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.2.1 10-Jan-2008  bouyer Sync with HEAD
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.2.1 24-Mar-2008  keiichi sync with head.
 1.10.22.1 21-Apr-2010  matt sync to netbsd-5
 1.10.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.10.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.10.4.2 11-Mar-2010  yamt sync with head
 1.10.4.1 04-May-2009  yamt sync with head.
 1.11.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.12.76.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.6 07-Dec-2020  jmcneill Fix 32-bit build.
 1.5 23-Nov-2018  jmcneill branches: 1.5.4; 1.5.14;
Use acpi_intr_establish
 1.4 23-Oct-2018  jmcneill Do not complain if the _AEI method is not found, just skip installing the
interrupt handler.
 1.3 22-Oct-2018  jmcneill Factor out common ACPI event code into a shared module.
 1.2 21-Oct-2018  jmcneill Add support for GPIO interrupt signaled ACPI events.
 1.1 15-Oct-2018  jmcneill branches: 1.1.2;
Add ACPI glue for PL061 GPIO
 1.1.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.2 20-Oct-2018  pgoyette Sync with head
 1.1.2.1 15-Oct-2018  pgoyette file plgpio_acpi.c was added on branch pgoyette-compat on 2018-10-20 06:58:30 +0000
 1.5.14.2 03-Apr-2021  thorpej Sync with HEAD.
 1.5.14.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.5.4.2 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 23-Nov-2018  christos file plgpio_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.8 17-Dec-2024  riastradh branches: 1.8.4;
qcomgpio(4): KNF whitespace

No functional change intended.
 1.7 17-Dec-2024  riastradh qcomgpio(4): Sort includes.

No functional change intended.
 1.6 12-Dec-2024  jmcneill qcomgpio: Add event counters for individual interrupt pins.

arm64$ vmstat -i | grep qcomgpio
qcomgpio0 pin 126 1 0
qcomgpio0 pin 3 1 0
 1.5 12-Dec-2024  jmcneill qcomgpio: Filter some interrupts.

Virtual pin 0x140 activates a previously unused block of AML code that
triggers when the lid switch event is triggered. Execution if the AML
spins the CPU and the interrupt status is not cleared due to a missing
driver in the OS. Until that driver is added, filter this virtual pin
on X1E platforms.
 1.4 12-Dec-2024  jmcneill qcomgpio: Translate virtual GPIO numbers using ACPI table data.

The scheme used by this device node appears to follow the following
conventions for mapping ACPI virtual pin numbers to hardware pin numbers:

1) If the virtual pin number is < the number of hardware pin numbers,
it represents a hardware pin number.
2) If the virtual pin number is greater than this, divide it by 64. This
gives us an index into the Interrupt resources returned by _CRS. The
IRQ number in this resource can be used to lookup the hardware pin
number in the _DSM PDC method call "CIPR".

As an added bonus, use the _DSM GPIO method call to return the number
of pins instead of hard-coding it for X1E.
 1.3 11-Dec-2024  jmcneill qcomgpio: Add reserved pin list and add one more ACPI pin mapping
 1.2 09-Dec-2024  jmcneill acpi: gpio: Pass the full ACPI_RESOURCE_GPIO to the translate callback.
 1.1 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.8.4.2 02-Aug-2025  perseant Sync with HEAD
 1.8.4.1 17-Dec-2024  perseant file qcomgpio.c was added on branch perseant-exfatfs on 2025-08-02 05:56:32 +0000
 1.3 17-Dec-2024  riastradh branches: 1.3.4;
qcomgpioreg.h: Add missing sys/cdefs.h for __BIT/__BITS.

No functional change intended, other than to make potential users
build when they previously wouldn't.
 1.2 09-Dec-2024  jmcneill acpi: gpio: Pass the full ACPI_RESOURCE_GPIO to the translate callback.
 1.1 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 17-Dec-2024  perseant file qcomgpioreg.h was added on branch perseant-exfatfs on 2025-08-02 05:56:32 +0000
 1.6 15-Sep-2025  thorpej No longer need to include acpi_i2c.h here.
 1.5 15-Sep-2025  thorpej Register the I2C controller with the ACPI subsystem centrally in
iic_attach().
 1.4 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.3 18-Dec-2024  jmcneill branches: 1.3.4;
qcomiic: Don't defer attachment of child devices.

Now that _DEP is supported in the acpi later, remove config_defer hack.
 1.2 09-Dec-2024  jmcneill qcomiic: Register GSB address space handler.
 1.1 08-Dec-2024  jmcneill Add support for Snapdragon X Elite GPIO and I2C controllers.
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 18-Dec-2024  perseant file qcomiic.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomipcc.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomipcc.h was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcompas.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.2 08-Jan-2025  jmcneill branches: 1.2.4;
qcompep: Add CPU frequency DVFS support.

arm64$ sysctl machdep.cpufreq
machdep.cpufreq.cpu0.target = 2976
machdep.cpufreq.cpu0.current = 2976
machdep.cpufreq.cpu0.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
machdep.cpufreq.cpu4.target = 3417
machdep.cpufreq.cpu4.current = 3417
machdep.cpufreq.cpu4.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
machdep.cpufreq.cpu8.target = 3417
machdep.cpufreq.cpu8.current = 3417
machdep.cpufreq.cpu8.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
 1.1 30-Dec-2024  jmcneill arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 08-Jan-2025  perseant file qcompep.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.2 08-Jan-2025  jmcneill branches: 1.2.4;
qcompep: Add CPU frequency DVFS support.

arm64$ sysctl machdep.cpufreq
machdep.cpufreq.cpu0.target = 2976
machdep.cpufreq.cpu0.current = 2976
machdep.cpufreq.cpu0.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
machdep.cpufreq.cpu4.target = 3417
machdep.cpufreq.cpu4.current = 3417
machdep.cpufreq.cpu4.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
machdep.cpufreq.cpu8.target = 3417
machdep.cpufreq.cpu8.current = 3417
machdep.cpufreq.cpu8.available = 710 806 998 1190 1440 1670 1920 2188 2515 2707 2976 3206 3417
 1.1 30-Dec-2024  jmcneill arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 08-Jan-2025  perseant file qcompep.h was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomscm.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomscm.h was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomsmem.c was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomsmem.h was added on branch perseant-exfatfs on 2025-08-02 05:56:33 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomsmptp.c was added on branch perseant-exfatfs on 2025-08-02 05:56:34 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomsmptp.h was added on branch perseant-exfatfs on 2025-08-02 05:56:34 +0000
 1.1 30-Dec-2024  jmcneill branches: 1.1.4;
arm64: Add support for Snapdragon X1E battery and charger sensors.

This is a port of a set of drivers from OpenBSD, adapted to use ACPI
instead of FDT bindings. These drivers are required to boot firmware on
the application DSP which is required to read sensors. This is an impressive
collection of work on the OpenBSD side -- big thank you to Patrick for writing
this code and his help with this porting effort.

Firmware is signed and as a result may be board specific. The qcompas(4)
driver looks for firmware files in qcompas/<subsystem> where <subsystem> is
the string returned by the _SUB method on the ADSP device node. For example,
on Lenovo ThinkPad T14s Gen 6 the subsystem ID is "233817AA".

The files "qcadsp8380.mbn" and "adsp_dtbs.elf" must be placed in
this directory to read sensor data. These files can be obtained by
downloading the appropriate OEM drivers for Windows.

When everything is online, the sensors are reported by sysmon_envsys and
the charger creates a sysmon_pswitch of type PSWITCH_TYPE_ACADAPTER. The
goal is to match the acpiacad(4) and acpibat(4) behaviour as much as possible.

XXX Firmware loading sometimes fails, still looking into this. When this
happens, sensors are not registered.

[battery]
design voltage: 0.000 V
voltage: 12.980 V
design cap: 58.000 Wh
last full cap: 59.810 Wh
charge: 59.740 2.000% 8.998% Wh (99.88%)
charge rate: N/A
discharge rate: N/A
charging: FALSE
charge state: NORMAL
discharge cycles: 4 0 0 0 0 none
temperature: 30.230 degC
[charger]
connected: TRUE
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Dec-2024  perseant file qcomspmi.c was added on branch perseant-exfatfs on 2025-08-02 05:56:34 +0000
 1.2 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.1 25-Nov-2017  jmcneill branches: 1.1.2; 1.1.20;
Add driver for QEMU Firmware Configuration device.

This interface allows the host to pass various data items and files to
the guest OS.
 1.1.20.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 25-Nov-2017  jdolecek file qemufwcfg_acpi.c was added on branch tls-maxphys on 2017-12-03 11:36:58 +0000
 1.22 17-Aug-2024  skrll Trailing whitespace
 1.21 09-May-2024  dyoung branches: 1.21.2;
If the ACPI flag "non-removable" is present and true for an SD/MMC
slot, then set a new flag on that slot to indicate that the media
is non-removable. Make sdhc_card_detect always return true for a
slot if its non-removable media flag is set.

This change lets the kernel automatically configure the
permanently-installed MMC slot on the NXP LX2160-based HoneyComb
LX2 board.
 1.20 06-Feb-2022  jmcneill sdhc: Retire SDHC_FLAG_USE_ADMA2 flag.

ADMA2 support in sdhc is mature now, so no need for it to be opt-in.
 1.19 15-Jan-2022  jmcneill 32-bit build fix
 1.18 15-Jan-2022  jmcneill acpi: sdhc: Read caps2 even if sdhci-caps{,-mask} doesn't touch the bits

SDHC_FLAG_HOSTCAPS means that the driver has to supply both caps and caps2
values.
 1.17 15-Jan-2022  jmcneill acpi: sdhc: Add support for RK356x eMMC controller.

RK356x has a DesignWare eMMC controller that is somewhat SDHCI compliant,
with one major problem -- the clock divisor doesn't actually work. To
change the clock card on Rockchip SoCs, the clock frequency needs to be
adjusted in the Clock & Reset Unit (CRU) directly.

The RK356x UEFI implementation introduces a DSM that allows drivers to
request firmware assistance in setting the card clock rate, for instances
like this where the divisor is broken.

From the UEFI README:

Function 1: Set Card Clock

The _DSM control method parameters for the Set Card Clock function are
as follows:

Arguments

* Arg0: UUID = 434addb0-8ff3-49d5-a724-95844b79ad1f
* Arg1: Revision = 0
* Arg2: Function Index = 1
* Arg3: Target card clock rate in Hz.

Return

The actual card clock rate in Hz. Will be less than or equal to the
target clock rate. Returns 0 if the target clock rate could not be set.
 1.16 11-Jan-2022  jmcneill acpi: sdhc: Support sdhci-caps and sdhci-caps-mask properties.
 1.15 28-Dec-2021  jmcneill acpi: sdhc: Ignore clkbase register if clock-frequency property is present
 1.14 01-Feb-2020  tnn fix build
 1.13 01-Feb-2020  christos use designated initializers
 1.12 01-Feb-2020  jmcneill appease -Werror=missing-field-initializers
 1.11 01-Feb-2020  jmcneill Add NXP/Freescale ESDHC specific support
 1.10 01-Feb-2020  jmcneill Use acpi_match_hid to match both _HID and _CID
 1.9 29-Dec-2019  jmcneill branches: 1.9.2;
Read clock frequency from device properties
 1.8 15-Oct-2019  chs convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.
 1.7 17-Nov-2018  kre Attempt to appease gcc and unbreak i386 build. Should be NFC.
 1.6 16-Nov-2018  jmcneill Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.
 1.5 08-May-2018  mlelstv branches: 1.5.2;
Bail if we have a zero-length memory resource.
 1.4 17-Feb-2017  nonaka branches: 1.4.12; 1.4.14;
sdhc(4): hardware reset support for Intel eMMC controller
 1.3 11-Aug-2016  nonaka branches: 1.3.2;
Enable DMA transfer.
 1.2 22-Jun-2016  nonaka branches: 1.2.2; 1.2.4;
remove unused variable.
 1.1 21-Jun-2016  nonaka Add sdhc(4) at acpi support
 1.2.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.4 28-Aug-2017  skrll Sync with HEAD
 1.2.2.3 05-Oct-2016  skrll Sync with HEAD
 1.2.2.2 09-Jul-2016  skrll Sync with HEAD
 1.2.2.1 22-Jun-2016  skrll file sdhc_acpi.c was added on branch nick-nhusb on 2016-07-09 20:25:01 +0000
 1.3.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.14.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.4.14.1 21-May-2018  pgoyette Sync with HEAD
 1.4.12.2 03-Dec-2017  jdolecek update from HEAD
 1.4.12.1 17-Feb-2017  jdolecek file sdhc_acpi.c was added on branch tls-maxphys on 2017-12-03 11:36:58 +0000
 1.5.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.9.2.1 29-Feb-2020  ad Sync with head.
 1.21.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 24-Oct-2022  riastradh i2c(9): Nix smbus intr API.

It was introduced in 2007 for some Xbox thing which was removed in
2011. The API and the threads it spawned have been sitting around
idly for over a decade serving no purpose -- sometimes causing kernel
lock spinouts in the event of panic.

Add ic_tag_private to obviate need for future ABI changes. Not
currently used, but we can privately allocate memory in iic_tag_init
for the purpose later if need be without changing ABI.

XXX kernel revbump -- changes struct i2c_controller
 1.17 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.16 24-Apr-2021  thorpej branches: 1.16.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.15 29-Jan-2021  thorpej branches: 1.15.2;
Use acpi_compatible_match().
 1.14 22-Dec-2019  thorpej branches: 1.14.8;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.13 29-Jul-2010  jruoho branches: 1.13.60;
Refactor to make this more readable. No functional change.
 1.12 28-Jul-2010  jruoho Remove also the HIDs from previous.
 1.11 28-Jul-2010  jruoho Remove the homegrown attempt to match the parent PCI bus. This was only used
for descriptive purposes, and for such purposes the ACPIVERBOSE output is
much better.
 1.10 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.9 05-Mar-2010  jruoho branches: 1.9.2; 1.9.4;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.8 04-Mar-2010  jruoho Fix two memory leaks.
 1.7 04-Mar-2010  jruoho Fix ACPI_DEBUG build failures reported by Greg A. Woods.
 1.6 04-Mar-2010  pgoyette This really should be ACPI_BUS_COMPONENT

Maybe I should stay out the acpi stuff? :)
 1.5 04-Mar-2010  pgoyette Fix this correctly. Thanks jruoho@
 1.4 04-Mar-2010  pgoyette Replace ACPI_FREE() with AcpiOsFree() so we no longer need to define
_COMPONENT (we don't have a bit defined for SMBUS anyway). This was
uncovered by turning on ACPI_DEBUG for the i386 ALL kernel config.

Reported by Greg Woods on current-users@
 1.3 01-Mar-2010  jruoho Destroy the callout(9) when detaching. Also evaluate the removal of the
notify handler before going to demolishing business.
 1.2 01-Mar-2010  jruoho Semantics:

* Use ACPI_ADR_PCI_DEV(x) and ACPI_ADR_PCI_FUNC(x).
* !ACPI_FAILURE -> ACPI_SUCCESS, UINT32 -> uint32_t
* Remove whitespace.
 1.1 06-Feb-2010  pgoyette branches: 1.1.2;
Import my experimental ACPI SMBus Control Method Interface driver

XXX Should not be enabled in any configuration file until you have
XXX disabled corresponding "native" i2c driver! Read the acpismbus(4)
XXX man page!
 1.1.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.9.4.2 05-Mar-2011  rmind sync with head
 1.9.4.1 30-May-2010  rmind sync with head
 1.9.2.3 11-Aug-2010  yamt sync with head.
 1.9.2.2 11-Mar-2010  yamt sync with head
 1.9.2.1 05-Mar-2010  yamt file smbus_acpi.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:23 +0000
 1.13.60.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.16.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.24 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.23 07-Jul-2016  msaitoh branches: 1.23.32;
KNF. Remove extra spaces. No functional change.
 1.22 25-Feb-2014  pooka branches: 1.22.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.21 02-Jun-2012  dsl branches: 1.21.2; 1.21.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.20 02-Oct-2010  gsutre branches: 1.20.8;
Drop _HID requirement for attachment under acpi(4). From now on,
drivers attaching to the acpinodebus interface should not assume
that the passed acpi_devnode has a valid _HID.

ok jruoho@
 1.19 24-Aug-2010  jruoho Remove phony spl(9). XXX: This driver needs to be cleaned up.
 1.18 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.17 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.16 08-Apr-2010  jruoho ACPICA 20091112:

Implemented a post-order callback to AcpiWalkNamespace. The existing
interface only has a pre-order callback. This change adds an
additional parameter for a post-order callback which will be more
useful for bus scans. ACPICA BZ 779. Lin Ming. Updated the ACPICA
Programmer Reference.

We will use the old "pre-order callback" for the time being.
 1.15 05-Mar-2010  jruoho branches: 1.15.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.14 02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.13 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.12 08-Jan-2010  dyoung branches: 1.12.2;
Expand PMF_FN_* macros.
 1.11 16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.10 19-Aug-2009  christos the new acpi code seems to return NULL for the hardwareId string.
 1.9 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.8 09-Aug-2009  christos - pass unsigned char to toupper
- set snprintf did not bother to uppercase the name. Simplify and fix.
 1.7 01-May-2008  simonb Be consistent with #define<space-or-tab>.
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 26-Mar-2008  xtraeme branches: 1.5.2; 1.5.4;
Split device_t/softc and related cosmetic changes.
 1.4 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.3 06-Jan-2008  christos branches: 1.3.2; 1.3.4; 1.3.6; 1.3.10;
clamp min/max values properly.
 1.2 23-Dec-2007  jmcneill branches: 1.2.2; 1.2.4; 1.2.6;
Always enable the Fn key quirk if a device node for the Sony Programmable
Interrupt Controller (SNY6001) is not present.
 1.1 23-Dec-2007  jmcneill Move Sony Notebook Controller (sony(4)) driver from MD to MI directory,
as it can be used on amd64 as well.
 1.2.6.3 08-Jan-2008  bouyer Sync with HEAD
 1.2.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.6.1 23-Dec-2007  bouyer file sony_acpi.c was added on branch bouyer-xeni386 on 2008-01-02 21:53:51 +0000
 1.2.4.2 26-Dec-2007  ad Sync with head.
 1.2.4.1 23-Dec-2007  ad file sony_acpi.c was added on branch vmlocking2 on 2007-12-26 19:17:19 +0000
 1.2.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.2.1 23-Dec-2007  mjf file sony_acpi.c was added on branch mjf-devfs on 2008-02-18 21:05:36 +0000
 1.3.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.6.1 24-Mar-2008  keiichi sync with head.
 1.3.4.3 17-Mar-2008  yamt sync with head.
 1.3.4.2 21-Jan-2008  yamt sync with head
 1.3.4.1 06-Jan-2008  yamt file sony_acpi.c was added on branch yamt-lazymbuf on 2008-01-21 09:42:33 +0000
 1.3.2.3 23-Mar-2008  matt sync with HEAD
 1.3.2.2 09-Jan-2008  matt sync with HEAD
 1.3.2.1 06-Jan-2008  matt file sony_acpi.c was added on branch matt-armv6 on 2008-01-09 01:52:21 +0000
 1.5.4.5 09-Oct-2010  yamt sync with head
 1.5.4.4 11-Aug-2010  yamt sync with head.
 1.5.4.3 11-Mar-2010  yamt sync with head
 1.5.4.2 19-Aug-2009  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.1 18-May-2008  yamt sync with head.
 1.12.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.2.2 05-Mar-2011  rmind sync with head
 1.15.2.1 30-May-2010  rmind sync with head
 1.20.8.2 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.20.8.1 30-Oct-2012  yamt sync with head
 1.21.4.1 18-May-2014  rmind sync with head
 1.21.2.2 03-Dec-2017  jdolecek update from HEAD
 1.21.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.6.1 09-Jul-2016  skrll Sync with HEAD
 1.23.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.8 07-Dec-2020  jmcneill Fix 32-bit build.
 1.7 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.6 05-Mar-2010  jruoho branches: 1.6.76;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.5 30-Jan-2010  jruoho branches: 1.5.2;
Add the _COMPONENT definition for ACPI_DEBUG.
 1.4 09-Aug-2009  christos spic has moved.
 1.3 17-Jun-2002  christos branches: 1.3.2; 1.3.66;
move spic_acpi to arch/i386/acpi
 1.2 13-Jun-2002  augustss Add copyright notice (thanks itojun).
 1.1 22-Apr-2002  augustss branches: 1.1.2;
Attach the spic driver via ACPI.
 1.1.2.2 15-Jul-2002  gehenna catch up with -current.
 1.1.2.1 20-Jun-2002  gehenna catch up with -current.
 1.3.66.2 11-Mar-2010  yamt sync with head
 1.3.66.1 19-Aug-2009  yamt sync with head.
 1.3.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.76.2 03-Apr-2021  thorpej Sync with HEAD.
 1.6.76.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.57 27-Apr-2024  christos Expose a sysctl interface hw.acpi.thinkpad<M>.bat[<N>].<behavior> to control
some aspects of battery charging behavior on supported systems:

charge_start
threshold below which to start charging (in %, 0-99)

charge_stop
threshold above which to stop charging (in %, 1-100)

force_discharge
discharge while on AC power, e.g., for calibration

charge_inhibit
inhibit charging while on AC power

From Malte Dehling
 1.56 27-Apr-2024  christos thinkpad cosmetic patches (Malte Dehling)
 1.55 12-Aug-2022  riastradh thinkpad(4): Don't detach on shutdown.

There's no important state that needs to be recorded, or resources
that need to be relinquished, so detach-on-shutdown isn't necessary.

At the moment, detach-on-shutdown is actually harmful here: if
shutdown is triggered by a sysmon power switch event, then
config_detach will be called from the sysmon taskqueue, but
thinkpad_detach has to wait for ACPI notifiers to finish running
which means waiting for the sysmon taskqueue -> deadlock or crash.

We should maybe arrange to do config_detach from a thread other than
the sysmon taskqueue thread to avoid this class of problems -- but
for now, thinkpad(4) has no reason to detach on shutdown anyway, so
let's take the easy path.

Note: There are many drivers that set DVF_DETACH_SHUTDOWN which
probably shouldn't; the flag means the kernel _will_ detach on
shutdown, not that it _may_. Even those that do need to record state
or relinquish resources might be better served by pmf shutdown hooks
which can skip freeing software resources for faster shutdown.
 1.54 31-Dec-2021  riastradh thinkpad(4): Omit workaround for acpiec_bus_read.

acpiec_bus_read now initializes the whole ACPI_INTEGER like its
signature suggests, so we don't need to pick out the low bits of the
result or carefully avoid undefined behaviour from uninitialized
stack garbage.
 1.53 30-May-2021  riastradh thinkpad(4): Fix evaluation of MHKA on version 2 devices.

Need to pass an argument.
 1.52 29-May-2021  riastradh Add some more Thinkpad hotkeys.
 1.51 29-May-2021  riastradh thinkpad(4): Add dtrace probe for hotkey events.
 1.50 29-May-2021  riastradh thinkpad(4): Attach at LEN0268 with v2 Thinkpad hotkeys too.
 1.49 29-Jan-2021  thorpej branches: 1.49.4; 1.49.6;
Use acpi_compatible_match().
 1.48 17-May-2020  mlelstv branches: 1.48.2;
With the recent change of the EC address space handler, we no longer get
an ACPI_INTEGER in host byte order but a byte sized buffer with little
endian data.

Extract only the low 8 bits from buffer to get the fan speed again.
 1.47 05-Aug-2019  msaitoh Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.
 1.46 03-Apr-2016  mlelstv branches: 1.46.18; 1.46.24;
Split toggles for bluetooth and wwan and use specific ACPI objects
where present.
Also make driver detach on shutdown.
 1.45 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.44 30-Mar-2013  christos branches: 1.44.12;
reverse the polarity of the extra key option, always enabling them.
 1.43 30-Mar-2013  christos Define THINKPAD_EXTENDED_HOTKEYS to enable more hotkeys on ThinkPads.
This has only been tested on a T61.
XXX: Should we put THINKPAD_EXTENDED_HOTKEYS into a opt_*.h include
(defflag) or just always enable it?
 1.42 24-Nov-2012  riastradh Match LEN0068 in thinkpad(4) too, as newer Thinkpads report.

Tested on a W530. Lots of stuff is missing, though.
 1.41 14-Aug-2012  jruoho branches: 1.41.2;
Collect rnd(9) entropy from coretemp(4), acpibat(4), aibs(4), hpacel(4),
thinkpad(4), and aps(4).
 1.40 15-Jul-2012  spz add function switch to switch on/off "wireless WAN", aka GSM et al modem
not tested to actually work, extensively tested not to do any harm if you
don't have a wwan
 1.39 20-Jun-2011  pgoyette branches: 1.39.2; 1.39.8;
Initialize sensor state before trying to register.
 1.38 06-Jun-2011  pgoyette Don't update the value_{min,max} - these fields are not {low,high}-water
marks, and setting them without also updating the ENVSYS_FVALID_{MIN,MAX}
flags is quite pointless.
 1.37 14-Apr-2011  jruoho branches: 1.37.2;
Simplify a little. No functional change.
 1.36 14-Apr-2011  jruoho Use the common power resource code. Also add a comment explaining
what can happen if we do not power on the resource upon resume from S3.
 1.35 27-Mar-2011  mlelstv Use wireless function key to toggle not only bluetooth but also
telephony (GPRS/UMTS/..) like other operating systems.
 1.34 16-Feb-2011  jruoho Use ioconf for the module declarations.
 1.33 18-Jan-2011  jmcneill branches: 1.33.2;
Use AcpiOsReadPort/AcpiOsWritePort instead of inb/outb so I can get rid of
of the i386 and x86_64 ifdefs.
 1.32 31-Dec-2010  jruoho branches: 1.32.2;
Use "temperature #" and "fan speed #" rather than "TMP#" and "FAN#" for the
sensor names. Remove white space. No functional change.
 1.31 25-Oct-2010  jruoho Bump WARNS to 4.
 1.30 15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.29 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.28 05-Mar-2010  jruoho branches: 1.28.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.27 28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.26 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.25 31-Jan-2010  jruoho branches: 1.25.2;
Add a detachment routine. While here, clarify the initialization of sensors.
 1.24 30-Jan-2010  jruoho Add the _COMPONENT definition for ACPI_DEBUG.
 1.23 18-Jan-2010  jruoho Add definitions for volume keys.

ok jmcneill@
 1.22 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.21 29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.20 25-Sep-2009  dyoung Use deviter_first()/deviter_next() instead of accessing alldevs
directly. Compile-tested, only.
 1.19 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.18 17-Feb-2009  jmcneill Use aprint_debug
 1.17 01-Nov-2008  hans branches: 1.17.4;
Make the driver work (except for setting display brightness) on older
machines by removing the check for the CMOS method from thinkpad_match.
OK by jmcneill.
 1.16 18-Oct-2008  jmcneill branches: 1.16.2; 1.16.4;
Add fan sensor support, from Thomas E. Spanjaard
 1.15 05-May-2008  jmcneill branches: 1.15.6;
Use 2-clause license.
 1.14 01-May-2008  simonb Be consistent with #define<space-or-tab>.
 1.13 26-Apr-2008  jmcneill branches: 1.13.2;
Use isareg constants in thinkpad_brightness_read where possible
 1.12 29-Feb-2008  dyoung branches: 1.12.2;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.11 28-Jan-2008  jmcneill branches: 1.11.2; 1.11.6;
The Thinkpad T61/x61 family powers off the USB power resource on resume
from S3 sleep. Until we get proper ACPI power resource support, simply
call \\_SB.PCI0.LPC.EC.PUBS._ON() on resume if the method exists.

Fixes kern/37279 by Steven M Bellovin.
 1.10 09-Jan-2008  xtraeme branches: 1.10.2;
Remove useless returns at the end of void functions.
 1.9 22-Dec-2007  jmcneill branches: 1.9.2; 1.9.4; 1.9.6; 1.9.8;
Move display switching out of the kernel; deliver this (and other) events
to sysmon so a powerd script can handle them.
 1.8 22-Dec-2007  jmcneill Add experimental display switching support.
 1.7 22-Dec-2007  jmcneill Only toggle bluetooth when the wireless button is pressed, simplifies
things and it seems I forgot that my laptop has a separate wifi switch.
 1.6 21-Dec-2007  jmcneill Add support for the WLAN / Bluetooth switch.
 1.5 21-Dec-2007  jmcneill Hook Thinkpad temperature sensors into envsys:

$ envstat -d thinkpad0
TMP0: 46.000 degC
TMP1: 39.000 degC
TMP2: 32.000 degC
TMP3: N/A
TMP4: 50.000 degC
TMP5: N/A
TMP6: 29.000 degC
TMP7: N/A
 1.4 21-Dec-2007  jmcneill Handle notifications in a separate thread, and ensure that the BIOS doesn't
try to play trick with us when we are trying to manage the brightness
keys.
 1.3 21-Dec-2007  jmcneill Typo in previous.
 1.2 21-Dec-2007  jmcneill Handle key repeat, and only match if MHKV returns an HKEY version we have
a chance of supporting.
 1.1 21-Dec-2007  jmcneill Add Thinkpad ACPI driver, for controlling hotkeys and display brightness.
 1.9.8.3 23-Mar-2008  matt sync with HEAD
 1.9.8.2 09-Jan-2008  matt sync with HEAD
 1.9.8.1 22-Dec-2007  matt file thinkpad_acpi.c was added on branch matt-armv6 on 2008-01-09 01:52:21 +0000
 1.9.6.3 10-Jan-2008  bouyer Sync with HEAD
 1.9.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.9.6.1 22-Dec-2007  bouyer file thinkpad_acpi.c was added on branch bouyer-xeni386 on 2008-01-02 21:53:52 +0000
 1.9.4.2 26-Dec-2007  ad Sync with head.
 1.9.4.1 22-Dec-2007  ad file thinkpad_acpi.c was added on branch vmlocking2 on 2007-12-26 19:17:19 +0000
 1.9.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.9.2.1 22-Dec-2007  mjf file thinkpad_acpi.c was added on branch mjf-devfs on 2008-02-18 21:05:36 +0000
 1.10.2.4 17-Mar-2008  yamt sync with head.
 1.10.2.3 04-Feb-2008  yamt sync with head.
 1.10.2.2 21-Jan-2008  yamt sync with head
 1.10.2.1 09-Jan-2008  yamt file thinkpad_acpi.c was added on branch yamt-lazymbuf on 2008-01-21 09:42:34 +0000
 1.11.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.11.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.11.2.1 24-Mar-2008  keiichi sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.2.5 11-Aug-2010  yamt sync with head.
 1.13.2.4 11-Mar-2010  yamt sync with head
 1.13.2.3 16-May-2009  yamt sync with head
 1.13.2.2 04-May-2009  yamt sync with head.
 1.13.2.1 16-May-2008  yamt sync with head.
 1.15.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.6.1 19-Oct-2008  haad Sync with HEAD.
 1.16.4.1 20-Nov-2008  snj Pull up following revision(s) (requested by hans in ticket #90):
sys/dev/acpi/thinkpad_acpi.c: revision 1.17
Make the driver work (except for setting display brightness) on older
machines by removing the check for the CMOS method from thinkpad_match.
OK by jmcneill.
 1.16.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.16.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.25.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.28.2.4 12-Jun-2011  rmind sync with head
 1.28.2.3 21-Apr-2011  rmind sync with head
 1.28.2.2 05-Mar-2011  rmind sync with head
 1.28.2.1 30-May-2010  rmind sync with head
 1.32.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.33.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.37.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.8.1 11-Apr-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1039):
sys/dev/acpi/thinkpad_acpi.c: revision 1.42
Match LEN0068 in thinkpad(4) too, as newer Thinkpads report.
Tested on a W530. Lots of stuff is missing, though.
 1.39.2.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.39.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.39.2.1 30-Oct-2012  yamt sync with head
 1.41.2.3 03-Dec-2017  jdolecek update from HEAD
 1.41.2.2 23-Jun-2013  tls resync from head
 1.41.2.1 25-Feb-2013  tls resync with head
 1.44.12.2 22-Apr-2016  skrll Sync with HEAD
 1.44.12.1 06-Jun-2015  skrll Sync with HEAD
 1.46.24.2 03-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1490):

sys/dev/acpi/thinkpad_acpi.c: revision 1.48

With the recent change of the EC address space handler, we no longer get
an ACPI_INTEGER in host byte order but a byte sized buffer with little
endian data.

Extract only the low 8 bits from buffer to get the fan speed again.
 1.46.24.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #672):

sys/dev/ic/tulip.c: revision 1.198
sys/dev/pci/if_jme.c: revision 1.45
sys/dev/pci/agp.c: revision 1.86
sys/dev/pci/if_lii.c: revision 1.27
sys/dev/acpi/thinkpad_acpi.c: revision 1.47
sys/dev/scsipi/scsipi_base.c: revision 1.183
sys/dev/ic/aic6915reg.h: revision 1.6

Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.

Use unsigned when initialize the transmit completion ring to avoid undefined
behavior. Found by kUBSan.

Avoid undefined behavior when setting multicast address. found by kUBSan.

Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

Use unsigned to avoid undefined behavior in lii_setmulti().

Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag().

Found by kUBSan.
 1.46.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.48.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.49.6.1 31-May-2021  cjep sync with head
 1.49.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.14 14-Nov-2021  riastradh tpm@acpi: Require only one locality's worth of register space.

We don't actually use the registers for the other localities, and
some older TPMs only have the first locality exposed via ACPI.
 1.13 29-Jan-2021  thorpej Use acpi_compatible_match() / acpi_compatible_lookup().
 1.12 16-Jan-2021  thorpej Match PNP0C31 as a TPM 1.2 device. Works on my ThinkPad X260, and
eliminates the last of the devices that attach to "isa".
 1.11 09-Oct-2019  maxv branches: 1.11.8;
Provide a better abstraction for the TPM interface. Report it in the ioctl.
 1.10 09-Oct-2019  maxv Add suspend support for TPM 2.0 chips. Check the TPM response also for 1.2
chips. Unfortunately I cannot really test this change since ACPI suspend
does not work on any of my laptops.
 1.9 08-Oct-2019  maxv Improvements in tpm(4):
- Remove interrupt support, do polling only, avoids unnecessary trouble.
- Simplify a few things.
- Fix the suspend function, the SaveState command is 0x98, not 0x9C.
- Make the driver MP-safe.
- Sync the man page with reality.
 1.8 22-Jun-2019  maxv branches: 1.8.2;
Revamp the TPM driver

* Fix several bugs, and clean up.
* Drop the "legacy" interface, it relied on an undocumented global
variable that was never initialized. It likely had never been tested
either, so good riddance.
* Add support for TPM 2.0 chips via ACPI. For these we use the TIS1.2
interface, same as TPM 1.2.
* Provide an ioctl to fetch TPM information from the driver.

Tested on a Lenovo desktop with ACPI-TPM2.0, an HP laptop ACPI-TPM2.0, a
Dell laptop with ISA-TPM1.2.
 1.7 09-Dec-2018  jdolecek make compile on 64-bit archs after acpi_mem ar_length was changed
from uint32_t to bus_size_t in rev. 1.77 of acpivar.h
 1.6 22-Feb-2018  christos branches: 1.6.2; 1.6.4;
notyet an unused variable.
 1.5 28-Oct-2017  riastradh Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.4 01-Mar-2014  maxv Some {} are missing. The behavior is thus wrong: the code always jumps to
out1.

Spotted by my code scanner.

ok christos@
 1.3 22-Jan-2012  christos branches: 1.3.4; 1.3.6; 1.3.10; 1.3.14;
make it never match for now.
 1.2 22-Jan-2012  christos make it handle legacy devices too, although the ones in the table are not.
 1.1 22-Jan-2012  christos add a tpm driver from bsssd.sourceforge.net
 1.3.14.1 18-May-2014  rmind sync with head
 1.3.10.2 03-Dec-2017  jdolecek update from HEAD
 1.3.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.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.3.6.2 17-Apr-2012  yamt sync with head
 1.3.6.1 22-Jan-2012  yamt file tpm_acpi.c was added on branch yamt-pagecache on 2012-04-17 00:07:28 +0000
 1.3.4.2 18-Feb-2012  mrg merge to -current.
 1.3.4.1 22-Jan-2012  mrg file tpm_acpi.c was added on branch jmcneill-usbmp on 2012-02-18 07:34:08 +0000
 1.6.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.4.1 10-Jun-2019  christos Sync with HEAD
 1.6.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.8.2.2 03-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1495):

share/man/man4/tpm.4: revision 1.7
sys/dev/ic/tpm.c: revision 1.17
sys/dev/ic/tpmvar.h: revision 1.10
sys/dev/ic/tpm.c: revision 1.18
sys/dev/ic/tpm.c: revision 1.19
sys/dev/acpi/tpm_acpi.c: revision 1.14
sys/dev/ic/tpmreg.h: revision 1.10
sys/dev/ic/tpmreg.h: revision 1.11
sys/dev/ic/tpm.c: revision 1.21
sys/dev/ic/tpm.c: revision 1.22
sys/dev/ic/tpm.c: revision 1.23
sys/dev/ic/tpm.c: revision 1.24
sys/dev/ic/tpm.c: revision 1.25
sys/dev/ic/tpmreg.h: revision 1.7
sys/dev/ic/tpmreg.h: revision 1.8
sys/dev/ic/tpmreg.h: revision 1.9
sys/dev/ic/tpmvar.h: revision 1.8
sys/dev/ic/tpmvar.h: revision 1.9

dev/ic/tpm: Tidy up headers.
- Add include guards.
- Add necessary includes.
- Sort includes.
- Use _BYTE_ORDER, not BYTE_ORDER, for public header.

dev/ic/tpm: Add missing line break in attach output.

dev/ic/tpm: Take advantage of entropy source if available.

If the tpm is deactivated, though, detach the entropy source so we
don't continue to try polling it -- it can't be activated without a
reboot anyway.

Add note about enabling TPM and rnd(4) source.

tpm(4): Handle TPM 2.0 random source too, and loop on short reads.
Tested on ThinkPad T480.

tpm(4): Preserve error if any on ending commands.
This way we don't spuriously suppress an error, such as
TPM_DEACTIVATED, in a loop where we rely on it.

tpm@acpi: Require only one locality's worth of register space.
We don't actually use the registers for the other localities, and
some older TPMs only have the first locality exposed via ACPI.


tpm(4): Fix disabling of rnd source if tpm is deactivated.

Nothing prevents a second worker from being queued when the first one
is about to do rnd_detach_source. Instead, just set a flag so future
requests don't bother running a new thread; if there's a concurrent
one that's already been scheduled on another CPU, well, too bad, we
get a couple extra log messages but that's fine.

A better way to do this would probably be to detect whether the tpm
is deactivated at attach time, but that requires reading more of the
tpm spec than I care to do when there are alternative ways to
procrastinate like scrubbing the toilet.


tpm(4): Fix suspend and rework I/O transaction lock.

Use sc->sc_lock over individual I/O transactions, not open/close of
the whole device. This way there is a bounded time before the tpm is
unbusied even if userland is getting at it, so userland can't hold up
suspend indefinitely. Of course, the tpm might be suspended and
resumed in the middle of the user's session this way -- tough.

This limits the response buffer to 1024 bytes -- which is already a
bit hefty to have on the stack (but it's probably not very deep on
the stack from userland so maybe not a big deal). If it turns out we
need more, we can use kmem to allocate a buffer on the heap, with the
caveat that it might fail. This is necessary so that suspend doesn't
block indefinitely on uiomove in tpmread.


tpm(4): Nix TPM_BE16/TPM_BE32. Just use sys/endian.h.
 1.8.2.1 16-Oct-2019  martin Pull up following revision(s) (requested by maxv in ticket #336):

sys/dev/isa/tpm_isa.c: revision 1.6
sys/dev/ic/tpm.c: revision 1.16
sys/dev/isa/tpm_isa.c: revision 1.7
sys/dev/acpi/tpm_acpi.c: revision 1.10
sys/dev/acpi/tpm_acpi.c: revision 1.11
sys/dev/ic/tpmreg.h: revision 1.5
sys/dev/ic/tpmreg.h: revision 1.6
sys/dev/acpi/tpm_acpi.c: revision 1.9
sys/dev/ic/tpmvar.h: revision 1.5
sys/dev/ic/tpmvar.h: revision 1.6
sys/dev/ic/tpmvar.h: revision 1.7
sys/dev/ic/tpm.c: revision 1.14
share/man/man4/tpm.4: revision 1.5
sys/dev/isa/tpm_isa.c: revision 1.5
sys/dev/ic/tpm.c: revision 1.15

Improvements in tpm(4):
- Remove interrupt support, do polling only, avoids unnecessary trouble.
- Simplify a few things.
- Fix the suspend function, the SaveState command is 0x98, not 0x9C.
- Make the driver MP-safe.
- Sync the man page with reality.

-

Add suspend support for TPM 2.0 chips. Check the TPM response also for 1.2
chips. Unfortunately I cannot really test this change since ACPI suspend
does not work on any of my laptops.

-

Provide a better abstraction for the TPM interface. Report it in the ioctl.
 1.11.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.6 05-Mar-2010  jruoho branches: 1.6.76;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.5 17-Feb-2009  jmcneill branches: 1.5.2;
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.4 26-Mar-2008  xtraeme branches: 1.4.4; 1.4.12; 1.4.14; 1.4.18; 1.4.22;
Split device_t/softc for ug(4) and other related cosmetic changes.
 1.3 19-Oct-2007  ad branches: 1.3.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.2 08-May-2007  xtraeme branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.16; 1.2.18; 1.2.22;
Missing __KERNEL_RCSID().
 1.1 08-May-2007  xtraeme Split the ug(4) driver in three components:

* dev/ic/ug.c (main code shared by the attachments)
* dev/isa/ug_isa.c (isa attachment)
* dev/acpi/ug_acpi.c (acpi attachment)

That means that ug(4) can now be attached via ACPI.

Thanks to Mihai Chelaru for the good work.
 1.2.22.1 25-Oct-2007  bouyer Sync with HEAD.
 1.2.18.3 27-Oct-2007  yamt sync with head.
 1.2.18.2 03-Sep-2007  yamt sync with head.
 1.2.18.1 08-May-2007  yamt file ug_acpi.c was added on branch yamt-lazymbuf on 2007-09-03 14:33:22 +0000
 1.2.16.1 06-Nov-2007  matt sync with HEAD
 1.2.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.2.8.2 11-Jul-2007  mjf Sync with head.
 1.2.8.1 08-May-2007  mjf file ug_acpi.c was added on branch mjf-ufs-trans on 2007-07-11 20:05:11 +0000
 1.2.6.3 23-Oct-2007  ad Sync with head.
 1.2.6.2 09-Jun-2007  ad Sync with head.
 1.2.6.1 08-May-2007  ad file ug_acpi.c was added on branch vmlocking on 2007-06-09 21:37:11 +0000
 1.2.4.2 17-May-2007  yamt sync with head.
 1.2.4.1 08-May-2007  yamt file ug_acpi.c was added on branch yamt-idlelwp on 2007-05-17 13:41:24 +0000
 1.2.2.3 13-May-2007  pavel Fix new files from ticket #633.
 1.2.2.2 13-May-2007  pavel Pull up patch (requested by xtraeme in ticket #633):
sys/arch/amd64/conf/GENERIC: patch
sys/arch/i386/conf/ALL: patch
sys/arch/i386/conf/GENERIC: patch
sys/conf/files: patch
sys/dev/acpi/files.acpi: patch
sys/dev/acpi/ug_acpi.c: patch
sys/dev/ic/ug.c: patch
sys/dev/ic/ugreg.h: patch
sys/dev/ic/ugvar.h: patch
sys/dev/isa/files.isa: patch
sys/dev/isa/ug_isa.c: patch
share/man/man4/ug.4: patch
doc/CHANGES: patch
sys/dev/isa/ug.c: delete
sys/dev/isa/ugvar.h: delete

Add an acpi attachement for the ug hardware monitor driver.
 1.2.2.1 08-May-2007  pavel file ug_acpi.c was added on branch netbsd-4 on 2007-05-13 06:52:53 +0000
 1.3.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.4.22.1 21-Apr-2010  matt sync to netbsd-5
 1.4.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.4.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.4.4.2 11-Mar-2010  yamt sync with head
 1.4.4.1 04-May-2009  yamt sync with head.
 1.5.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.76.1 03-Apr-2021  thorpej Sync with HEAD.
 1.8 07-Dec-2021  andvar fix various typos, mainly in comments.
 1.7 01-Nov-2021  andvar fix typos, mainly in words minimum and maximum, but also few others.
 1.6 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.5 14-Jul-2016  msaitoh branches: 1.5.32;
KNF. No functional change.
 1.4 15-Apr-2010  jruoho branches: 1.4.2; 1.4.4; 1.4.6; 1.4.24; 1.4.42;
As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.3 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.2 10-Apr-2010  jruoho Remove unnecessary casts.
 1.1 10-Apr-2010  jruoho Move vald(4) to sys/dev/acpi. This is MI and should work also on amd64.

ok jmcneill@

XXX: This is broken: it calls methods with absolute pathnames (almost
guaranteed not to be portable across models), it accesses methods
that are in the domain of other drivers, it walks the namespace on
its own, it contains plenty of magic constants, it does not
integrate with existing KPIs, etc. Summa summarum: this should be
rewritten as a more generic toshiba_acpi(4).
 1.4.42.1 05-Oct-2016  skrll Sync with HEAD
 1.4.24.1 03-Dec-2017  jdolecek update from HEAD
 1.4.6.2 11-Aug-2010  yamt sync with head.
 1.4.6.1 15-Apr-2010  yamt file vald_acpi.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.4.4.2 30-May-2010  rmind sync with head
 1.4.4.1 15-Apr-2010  rmind file vald_acpi.c was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.4.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.2.1 15-Apr-2010  uebayasi file vald_acpi.c was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.5.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.8 09-Nov-2017  ryoon branches: 1.8.2; 1.8.20;
Do not emit a meaningless message when lid open/close from valz(4)
 1.7 05-Oct-2015  christos Previous code was mis-indented but correct; simplify to make the intent clear.
 1.6 26-Sep-2015  christos CID 1324963: Remove bogus NULL test
CID 1324962: This is not python, one needs braces too.
 1.5 21-Sep-2015  nonaka branches: 1.5.2;
PR/50261: Added newer Toshiba hotkeys support.
 1.4 22-Sep-2011  jakllsch valz(4) is superseded entirely by acpivga(4) these days.
 1.3 15-Apr-2010  jruoho branches: 1.3.2; 1.3.4; 1.3.6;
As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.2 14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.1 11-Apr-2010  jakllsch Add valz(4), a simple driver to handle the backlight keys on some
Toshiba laptops. As of yet only tested on a Satellite A135-S4527.
 1.3.6.2 11-Aug-2010  yamt sync with head.
 1.3.6.1 15-Apr-2010  yamt file valz_acpi.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.3.4.2 30-May-2010  rmind sync with head
 1.3.4.1 15-Apr-2010  rmind file valz_acpi.c was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.3.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.1 15-Apr-2010  uebayasi file valz_acpi.c was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.5.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.2.2 22-Sep-2015  skrll Sync with HEAD
 1.5.2.1 21-Sep-2015  skrll file valz_acpi.c was added on branch nick-nhusb on 2015-09-22 12:05:56 +0000
 1.8.20.1 03-Apr-2021  thorpej Sync with HEAD.
 1.8.2.2 03-Dec-2017  jdolecek update from HEAD
 1.8.2.1 09-Nov-2017  jdolecek file valz_acpi.c was added on branch tls-maxphys on 2017-12-03 11:36:58 +0000
 1.11 14-Jan-2025  riastradh virtio@acpi, virtio@fdt: Nix DVF_DETACH_SHUTDOWN.

There is no reason to force _all_ devices attached at the virtio bus
to detach at shutdown. This only makes sense for devices that
require detach in order to force buffered writes to persistant
storage so we don't lose them (or, in principle, require detach in
order to release hardware resources).

And the only virtio devices I found that require detach-on-shutdown,
namely scsi@virtio, already set DVF_DETACH_SHUTDOWN, so there's no
need for the bus to do it. (The only other obvious case, ld@virtio,
uses a pmf shutdown handler instead of detach, so it doesn't need
DVF_DETACH_SHUTDOWN.)
 1.10 22-Oct-2021  yamaguchi branches: 1.10.10;
rename "setup_interrupts" to "alloc_interrupts"
in virtio_mmio and virtio_acpi

This should fix build failure on evbarm.
 1.9 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.8 24-Apr-2021  thorpej branches: 1.8.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.7 29-Jan-2021  thorpej branches: 1.7.2;
Use acpi_compatible_match().
 1.6 20-Jan-2021  reinoud Remove the virtio child driver finalisation check KASSERT that, while it
should never trigger, a possible bug in a child driver shouldn't have to panic
the kernel. Instead report the internal error.
 1.5 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.4 07-Dec-2020  jmcneill Fix 32-bit build.
 1.3 24-Oct-2020  skrll branches: 1.3.2;
Use the 64bit DMA tag if its valid.

There appears to be a bug in virtio / ld_virtio and bounce buffers that
was triggered when the bus_dmatag_subregion code on arm64 was fixed to
correctly create a new tag for the 32bit tag vs the system (64bit) tag.
This change avoids the bug.

PR/55737: Apparent bug in evbarm64 DMA code causes filesystem corruption
 1.2 16-Nov-2018  jmcneill branches: 1.2.2; 1.2.6;
Use acpi_intr_establish
 1.1 21-Oct-2018  jmcneill Add ACPI attach glue for virtio_mmio.
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 16-Nov-2018  christos file virtio_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 16-Nov-2018  pgoyette file virtio_acpi.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.3.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.3.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.7.2.1 27-Mar-2021  thorpej - config_found_ia() -> config_found().
- virtio only carries a single interface attribute, so no need to
specify it explicitly.
 1.8.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.10.10.1 02-Aug-2025  perseant Sync with HEAD
 1.4 29-Jan-2021  thorpej Use acpi_compatible_match().
 1.3 24-Oct-2020  skrll branches: 1.3.2;
Test the 64bit dma tag with BUS_DMA_TAG_VALID before using it.
 1.2 24-May-2019  nonaka branches: 1.2.2;
Added drivers for Hyper-V Synthetic Keyboard and Video device.
 1.1 15-Feb-2019  nonaka branches: 1.1.2;
Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.

graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.
 1.1.2.3 12-Jun-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1280):

sys/arch/x86/x86/consinit.c: revision 1.29
sys/dev/hyperv/vmbusvar.h: revision 1.2
sys/dev/hyperv/genfb_vmbusvar.h: revision 1.1
sys/arch/x86/x86/x86_autoconf.c: revision 1.78
sys/arch/x86/x86/identcpu.c: revision 1.91
sys/arch/x86/x86/hyperv.c: revision 1.2
sys/arch/x86/x86/hyperv.c: revision 1.3
sys/arch/x86/x86/hyperv.c: revision 1.4
sys/arch/i386/conf/GENERIC: revision 1.1207
sys/dev/wscons/wsconsio.h: revision 1.123
sys/arch/x86/x86/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.528
sys/dev/hyperv/files.hyperv: revision 1.2
sys/arch/x86/include/autoconf.h: revision 1.6
sys/dev/hyperv/hyperv_common.c: revision 1.2
sys/arch/xen/x86/autoconf.c: revision 1.23
sys/arch/x86/pci/pci_machdep.c: revision 1.86
sys/dev/hyperv/hvkbd.c: revision 1.1
sys/dev/hyperv/hypervvar.h: revision 1.2
sys/dev/acpi/vmbus_acpi.c: revision 1.2
sys/dev/hyperv/vmbus.c: revision 1.3
sys/dev/hyperv/hvkbdvar.h: revision 1.1
sys/dev/hyperv/genfb_vmbus.c: revision 1.1

Added drivers for Hyper-V Synthetic Keyboard and Video device.

Avoid undefined reference to `hyperv_guid_video' without vmbus(4).

Avoid undefined reference to `hyperv_is_gen1' without hyperv(4).

Use efi_probe().
 1.1.2.2 09-Mar-2019  martin Pull up following revision(s) via patch (requested by nonaka in ticket #1210):

sys/dev/hyperv/vmbusvar.h: revision 1.1
sys/dev/hyperv/hvs.c: revision 1.1
sys/dev/hyperv/if_hvn.c: revision 1.1
sys/dev/hyperv/vmbusic.c: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.69
sys/arch/x86/isa/clock.c: revision 1.34
sys/arch/x86/include/intrdefs.h: revision 1.22
sys/arch/i386/conf/GENERIC: revision 1.1201
sys/arch/x86/x86/hyperv.c: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.105
sys/arch/x86/x86/x86_machdep.c: revision 1.124
sys/arch/i386/conf/GENERIC: revision 1.1203
sys/arch/amd64/amd64/genassym.cf: revision 1.74
sys/arch/i386/conf/GENERIC: revision 1.1204
sys/arch/amd64/conf/GENERIC: revision 1.520
sys/arch/x86/x86/hypervreg.h: revision 1.1
sys/arch/amd64/amd64/vector.S: revision 1.69
sys/dev/hyperv/hvshutdown.c: revision 1.1
sys/dev/hyperv/hvshutdown.c: revision 1.2
sys/dev/usb/if_urndisreg.h: file removal
sys/arch/x86/x86/cpu.c: revision 1.167
sys/arch/x86/conf/files.x86: revision 1.107
sys/dev/usb/if_urndis.c: revision 1.20
sys/dev/hyperv/vmbusicreg.h: revision 1.1
sys/dev/hyperv/hvheartbeat.c: revision 1.1
sys/dev/hyperv/vmbusicreg.h: revision 1.2
sys/dev/hyperv/hvheartbeat.c: revision 1.2
sys/dev/hyperv/files.hyperv: revision 1.1
sys/dev/ic/rndisreg.h: revision 1.1
sys/arch/i386/i386/genassym.cf: revision 1.111
sys/dev/ic/rndisreg.h: revision 1.2
sys/dev/hyperv/hyperv_common.c: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.1
sys/dev/hyperv/hypervreg.h: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.2
sys/dev/hyperv/vmbusicvar.h: revision 1.1
sys/dev/hyperv/if_hvnreg.h: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.70
sys/arch/amd64/amd64/vector.S: revision 1.70
sys/dev/ic/ndisreg.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.516
sys/dev/hyperv/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.518
sys/arch/amd64/conf/GENERIC: revision 1.519
sys/arch/i386/conf/files.i386: revision 1.400
sys/dev/acpi/vmbus_acpi.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.2
sys/arch/x86/x86/intr.c: revision 1.144
sys/arch/i386/i386/vector.S: revision 1.83
sys/arch/amd64/conf/files.amd64: revision 1.112

separate RNDIS definitions from urndis(4) for use with Hyper-V NetVSC.

-

Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.
graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.

-

Add __diagused.

-

PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.

-

Update Hyper-V related drivers description.

-

Remove unused definition.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
NFCI intended.

-

commented out hvkvp entry.

-

fix typo. pointed out by pgoyette@n.o.

-

Use IDTVEC instead of NENTRY for handle_hyperv_hypercall.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
 1.1.2.1 15-Feb-2019  martin file vmbus_acpi.c was added on branch netbsd-8 on 2019-03-09 17:10:21 +0000
 1.2.2.2 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 24-May-2019  christos file vmbus_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.3.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 07-Dec-2020  jmcneill Fix 32-bit build.
 1.6 06-Dec-2020  jmcneill acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.
 1.5 19-Aug-2010  jmcneill branches: 1.5.74;
pull in acpireg.h for ACPI_COMPONENT_RESOURCE
 1.4 19-Aug-2010  jmcneill define _COMPONENT and ACPI_MODULE_NAME() for ACPI_DEBUG
 1.3 19-Aug-2010  jmcneill add pmf support
 1.2 05-Mar-2010  jruoho branches: 1.2.2; 1.2.4; 1.2.6;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.1 30-Sep-2009  jmcneill branches: 1.1.2; 1.1.4;
Initial import of an SD/MMC driver for the Winbond W83L518D (and probably
W83L519D) Integrated Media Reader with PNP bus attachment glue.
 1.1.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.3 21-Nov-2010  riz Pull up following revision(s) (requested by jmcneill in ticket #1462):
sys/dev/acpi/wb_acpi.c: revision 1.3
sys/dev/ic/w83l518d_sdmmc.c: revision 1.2
sys/dev/ic/w83l518d_sdmmc.h: revision 1.2
sys/dev/ic/w83l518d.c: revision 1.2
sys/dev/ic/w83l518dvar.h: revision 1.2
add suspend/resume support
add pmf support
 1.1.2.2 08-Oct-2009  sborrill Pull up the following revisions(s) (requested by jmcneill in ticket #1045):
distrib/sets/lists/man/mi: revision 1.1160
share/man/man4/Makefile: revision 1.499
share/man/man4/wb.4: revision 1.1-1.2
share/man/man4/ld.4: revision 1.17
sys/arch/i386/conf/ALL: revision 1.215-1.216 + patch
sys/arch/i386/conf/GENERIC: revision 1.946-1.947 + patch
sys/arch/amd64/conf/GENERIC: revision 1.254-1.256 + patch
sys/conf/files: revision 1.958
sys/dev/acpi/files.acpi: revision 1.59
sys/dev/acpi/wb_acpi.c: revision 1.1
sys/dev/ic/w83l518d.c: revision 1.1
sys/dev/ic/w83l518d_sdmmc.c: revision 1.1
sys/dev/ic/w83l518d_sdmmc.h: revision 1.1
sys/dev/ic/w83l518dreg.h: revision 1.1
sys/dev/ic/w83l518dvar.h.c: revision 1.1

wb(4): Add a driver for Winbond W83L518D SD/MMC readers.
 1.1.2.1 30-Sep-2009  sborrill file wb_acpi.c was added on branch netbsd-5 on 2009-10-08 09:47:09 +0000
 1.2.6.2 21-Apr-2010  matt sync to netbsd-5
 1.2.6.1 05-Mar-2010  matt file wb_acpi.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:34 +0000
 1.2.4.1 05-Mar-2011  rmind sync with head
 1.2.2.3 09-Oct-2010  yamt sync with head
 1.2.2.2 11-Mar-2010  yamt sync with head
 1.2.2.1 05-Mar-2010  yamt file wb_acpi.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:23 +0000
 1.5.74.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.18 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.17 08-Apr-2010  jruoho Add a dummy acpi_wmi_event_deregister() to match existing conventions.
 1.16 08-Mar-2010  jruoho branches: 1.16.2; 1.16.4;
Add a detachment routine.
 1.15 05-Mar-2010  jruoho Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.14 28-Feb-2010  jruoho Use native functions instead of polluting the namespace with ACPICA-macros.
 1.13 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.12 31-Jan-2010  jruoho branches: 1.12.2;
Verify the object type before using variables from it.
In addition, use CTASSERT(9) instead of KASSERT(9).
 1.11 23-Jan-2010  jruoho Correct the type also in the WMI write method.
 1.10 23-Jan-2010  jruoho * Fix the type of the input buffer in the WMI method call.
* Do not error out if the flags field is is 0x00. Observed by cegger@.
 1.9 09-Jan-2010  jruoho Fix the casts in the event handler.
 1.8 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.7 04-Jan-2010  jruoho Update the copyright.
 1.6 04-Jan-2010  jruoho Two bug fixes:

- Use ACPI_ALL_NOTIFY instead of ACPI_DEVICE_NOTIFY.

- Fix the data query method: this fails without input.

ok pgoyette@
 1.5 04-Jan-2010  jruoho Cleanup:

- Provide the module declaration and use ACPI_FREE
as well as ACPI_ALLOCATE_LOCAL_BUFFER for ACPI_DEBUG.

- Maintain the calling conventions of existing ACPI utility
functions by initializing the output buffer for the caller
in all applicable functions.

- Remove superfluous const correctness. Additional semantics:
u_char -> char, u_int16_t -> uint16_t, and u_int64_t -> uint64_t.

- Collect the validation of input parameters to a single function.

ok pgoyette@
 1.4 03-Jan-2010  jruoho Introduce acpiwmibus, a pseudo-bus to which the child WMI devices attach.

Multiple WMI mapper devices are supported, but each one can have only one
child device.

All exposed functions now require the parent mapper device as a parameter.

ok pgoyette@, jmcneill@
 1.3 29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.2 03-Oct-2009  jmcneill from Jukka Ruohonen:

- Remove redundant assertions.
- Properly check for NULL pointers.
- No real need to keep track whether the internal event handler is installed.
- Add a missing function to pass possible extra information associated with
an event. Mentioned in the specification.
 1.1 02-Oct-2009  jmcneill PR# kern/42139: ACPI WMI: new driver

Import acpiwmi(4) from Jukka Ruohonen. From the PR:

Attached is a driver that implements ACPI WMI API:

http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

The WMI is used to provide a generic interface for OEMs to use certain
platform/laptop-specific additions to the standard ACPI in a somewhat
portable way. These can be hotkeys for additional buttons, different event
handlers (wireless kill switch, lid switch, etc.), and so on. At least HP
and Acer use it by default nowadays.

The benefit of this interface would be portability. For an example, instead
of hpqlb(4) that works only with certain HP models, we could have a generic
HP WMI-driver that should work in theory across all HP laptops. On many new
laptops WMI may also be the only way to access laptop/manufacturer-specific
features.
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.4.1 30-May-2010  rmind sync with head
 1.16.2.3 11-Aug-2010  yamt sync with head.
 1.16.2.2 11-Mar-2010  yamt sync with head
 1.16.2.1 08-Mar-2010  yamt file wmi_acpi.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:23 +0000
 1.9 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.8 08-Apr-2010  jruoho Add a dummy acpi_wmi_event_deregister() to match existing conventions.
 1.7 05-Mar-2010  jruoho branches: 1.7.2; 1.7.4;
Protect all header files against multiple inclusions.
 1.6 04-Jan-2010  jruoho branches: 1.6.2;
Update the copyright.
 1.5 04-Jan-2010  jruoho Two bug fixes:

- Use ACPI_ALL_NOTIFY instead of ACPI_DEVICE_NOTIFY.

- Fix the data query method: this fails without input.

ok pgoyette@
 1.4 04-Jan-2010  jruoho Cleanup:

- Provide the module declaration and use ACPI_FREE
as well as ACPI_ALLOCATE_LOCAL_BUFFER for ACPI_DEBUG.

- Maintain the calling conventions of existing ACPI utility
functions by initializing the output buffer for the caller
in all applicable functions.

- Remove superfluous const correctness. Additional semantics:
u_char -> char, u_int16_t -> uint16_t, and u_int64_t -> uint64_t.

- Collect the validation of input parameters to a single function.

ok pgoyette@
 1.3 03-Jan-2010  jruoho Introduce acpiwmibus, a pseudo-bus to which the child WMI devices attach.

Multiple WMI mapper devices are supported, but each one can have only one
child device.

All exposed functions now require the parent mapper device as a parameter.

ok pgoyette@, jmcneill@
 1.2 03-Oct-2009  jmcneill from Jukka Ruohonen:

- Remove redundant assertions.
- Properly check for NULL pointers.
- No real need to keep track whether the internal event handler is installed.
- Add a missing function to pass possible extra information associated with
an event. Mentioned in the specification.
 1.1 02-Oct-2009  jmcneill PR# kern/42139: ACPI WMI: new driver

Import acpiwmi(4) from Jukka Ruohonen. From the PR:

Attached is a driver that implements ACPI WMI API:

http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

The WMI is used to provide a generic interface for OEMs to use certain
platform/laptop-specific additions to the standard ACPI in a somewhat
portable way. These can be hotkeys for additional buttons, different event
handlers (wireless kill switch, lid switch, etc.), and so on. At least HP
and Acer use it by default nowadays.

The benefit of this interface would be portability. For an example, instead
of hpqlb(4) that works only with certain HP models, we could have a generic
HP WMI-driver that should work in theory across all HP laptops. On many new
laptops WMI may also be the only way to access laptop/manufacturer-specific
features.
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.4.1 30-May-2010  rmind sync with head
 1.7.2.3 11-Aug-2010  yamt sync with head.
 1.7.2.2 11-Mar-2010  yamt sync with head
 1.7.2.1 05-Mar-2010  yamt file wmi_acpivar.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:23 +0000
 1.38 07-Oct-2021  uwe Also print the device name with aprint_naive, like wss@pnpbios does.
 1.37 06-Oct-2021  uwe Don't use aprint_normal_dev("") to print the device name.

wssattach eventually calls ad1848_attach that prints the chip name
with ": %s". Usually that is a continuation of the attachment line,
e.g.

audiocs0 at ebus0 bar 14 offset 0x200000 line 3: CS4231A

but the wss? at acpi?: ... line we print is so long that we terminate
it and start a new one exclusively for ad1848_attach. Hence we do NOT
want the colon that _dev version supplies, it will be supplied by the
callee.
 1.36 06-Oct-2021  uwe Fix KASSERT triggered when attaching opl at wss.

wss has two attributes, "wss" and "audiobus", and this call didn't
specify an iattr for opl to attach to. config_search_internal asserts
that when no iattr is specified, the parent should only have one.

The same problem probably exists for other wss attachments, as opl is
not attached from wssattach, but from each wss_*_attach, so they need
a similar change.
 1.35 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.34 24-Apr-2021  thorpej branches: 1.34.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.33 04-May-2020  jdolecek branches: 1.33.4;
constify
 1.32 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.31 14-Jul-2016  msaitoh branches: 1.31.18; 1.31.22;
KNF. No functional change.
 1.30 15-Jan-2016  joerg Don't skip entries in the table, one increment per iteration is enough.
 1.29 02-Jun-2011  tsutsui branches: 1.29.12; 1.29.30;
Split device_t/softc of all ad1848 variants properly. Compile test only.

Please check all attribute users in all files.* on device_t/softc split.

XXX: not sure if gus(4) needs device_t in ad1848_isa_softc
 1.28 02-Jun-2011  nonaka fix compile failure.
 1.27 02-Oct-2010  gsutre branches: 1.27.2; 1.27.6;
Drop _HID requirement for attachment under acpi(4). From now on,
drivers attaching to the acpinodebus interface should not assume
that the passed acpi_devnode has a valid _HID.

ok jruoho@
 1.26 05-Mar-2010  jruoho branches: 1.26.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.25 18-Aug-2009  cegger branches: 1.25.2;
with new ACPICA, idstr may be NULL.
Check against NULL, this fixes a crash on my HP Pavilion dv9700 Laptop.
While here simplify the loop via __arraycount()
 1.24 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.23 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.22 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.21 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.20 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.19 05-Apr-2008  cegger branches: 1.19.4; 1.19.12; 1.19.14; 1.19.18; 1.19.22;
use aprint_*_dev and device_xname
 1.18 19-Oct-2007  ad branches: 1.18.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.17 16-Nov-2006  christos branches: 1.17.8; 1.17.22; 1.17.24; 1.17.28;
__unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 20-Feb-2006  kochi branches: 1.15.14; 1.15.16;
use aprint_*
 1.14 11-Dec-2005  christos branches: 1.14.2; 1.14.4; 1.14.6;
merge ktrace-lwp.
 1.13 01-May-2004  kochi branches: 1.13.12;
specify static where appropriate.
 1.12 11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.11 11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.10 11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.9 03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.8 03-Nov-2003  mycroft Clean up some messages:
* Use AcpiFormatException() in a bunch of places.
* acpi_resource_parse() already prints an error, so don't do it in the callers.
 1.7 03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.6 31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.5 13-Jan-2003  mrg branches: 1.5.2;
pull across the quirk table from the wss@pnpbios driver and use it identically.
now wss@acpi works on my dell inspiron 3500.
 1.4 30-Dec-2002  matt remove declaration of wss_acpi_config_interrupts since it no longer exists.
 1.3 28-Dec-2002  jmcneill branches: 1.3.2;
We no longer need to delay the call to wssprobe, so remove the disgusting
config_interrupts hack.
 1.2 28-Dec-2002  matt Fix an uninitialized variable.
 1.1 28-Dec-2002  jmcneill Add 'com at acpi' and 'wss at acpi' glue. These are both working great on
my ThinkPad 600E.

XXX isa_dmainit isn't called early enough for the 'audio at wss' attachment
XXX to work, so I'm deferring the call to 'wssattach' until later on. This
XXX should be fixed soon.
 1.3.2.4 15-Jan-2003  thorpej Sync with HEAD.
 1.3.2.3 03-Jan-2003  thorpej Sync with HEAD.
 1.3.2.2 29-Dec-2002  thorpej Sync with HEAD.
 1.3.2.1 28-Dec-2002  thorpej file wss_acpi.c was added on branch nathanw_sa on 2002-12-29 20:45:31 +0000
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.3 27-Oct-2007  yamt sync with head.
 1.13.12.2 30-Dec-2006  yamt sync with head.
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 01-Mar-2006  yamt sync with head.
 1.15.16.2 10-Dec-2006  yamt sync with head.
 1.15.16.1 22-Oct-2006  yamt sync with head
 1.15.14.1 18-Nov-2006  ad Sync with head.
 1.17.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.17.24.1 06-Nov-2007  matt sync with HEAD
 1.17.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.8.1 23-Oct-2007  ad Sync with head.
 1.18.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.22.1 21-Apr-2010  matt sync to netbsd-5
 1.19.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.19.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.19.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.19.4.5 09-Oct-2010  yamt sync with head
 1.19.4.4 11-Mar-2010  yamt sync with head
 1.19.4.3 19-Aug-2009  yamt sync with head.
 1.19.4.2 16-May-2009  yamt sync with head
 1.19.4.1 04-May-2009  yamt sync with head.
 1.25.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.25.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.26.2.2 12-Jun-2011  rmind sync with head
 1.26.2.1 05-Mar-2011  rmind sync with head
 1.27.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.30.2 05-Oct-2016  skrll Sync with HEAD
 1.29.30.1 19-Mar-2016  skrll Sync with HEAD
 1.29.12.1 03-Dec-2017  jdolecek update from HEAD
 1.31.22.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.31.18.1 10-Jun-2019  christos Sync with HEAD
 1.33.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.34.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.15 30-Jan-2025  jmcneill xhci: Always do 32-bit accesses for platform (ACPI) XHCI devices.

The XHCI IP found in the CIX CD8180 throws an serror for any access that
is not 32-bit aligned. Let's add an XHCI_32BIT_ACCESS flag and set it
unconditionally for platform devices as there are only a handful of non-
32-bit accesses at init time.
 1.14 09-Dec-2024  jmcneill acpi: xhci: Add support for generic USB role switching device nodes.

URS nodes have a child node that contains the interrupt resource for the
XHCI. Match the URS nodes and add support for obtaining the interrupt
from this child node.
 1.13 07-Aug-2021  thorpej branches: 1.13.12;
Merge thorpej-cfargs2.
 1.12 24-Apr-2021  thorpej branches: 1.12.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.11 29-Jan-2021  thorpej branches: 1.11.2;
Use acpi_compatible_match().
 1.10 07-Dec-2020  jmcneill Fix 32-bit build.
 1.9 27-Oct-2020  skrll branches: 1.9.2;
Report HW DMA capability and if the DMA tag limits it.
 1.8 24-Oct-2020  skrll Fix DMA size reporting. Previously it could report 64bit DMA when the tag
wasn't available (and it fell back to 32bit tag)
 1.7 31-Jan-2020  jmcneill Match HID 808622B7 (DesignWare USB3)
 1.6 21-Jan-2020  jmcneill Choose between dmat and dmat64, instead of relying on subregion of the 32-bit tag
 1.5 22-Jun-2019  jmcneill branches: 1.5.4;
Use bus_dmatag_subregion to get a 32-bit tag
 1.4 19-Jun-2019  jmcneill Conditionally use a 32- or 64-bit DMA tag based on HCCPARAMS
 1.3 16-Feb-2019  tron branches: 1.3.4;
Fix cut & paste error in comment
 1.2 16-Nov-2018  jmcneill branches: 1.2.2;
Use acpi_intr_establish
 1.1 26-Oct-2018  jmcneill Add xhci at acpi glue
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 16-Nov-2018  pgoyette file xhci_acpi.c was added on branch pgoyette-compat on 2018-11-26 01:52:30 +0000
 1.3.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 16-Feb-2019  christos file xhci_acpi.c was added on branch phil-wifi on 2019-06-10 22:07:05 +0000
 1.5.4.2 29-Feb-2020  ad Sync with head.
 1.5.4.1 25-Jan-2020  ad Sync with head.
 1.9.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.9.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.11.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.12.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.13.12.1 02-Aug-2025  perseant Sync with HEAD
 1.16 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.15 11-Jul-2016  msaitoh branches: 1.15.18; 1.15.22;
KNF. No functional change.
 1.14 02-Jun-2011  tsutsui branches: 1.14.12; 1.14.30;
Split device_t/softc of all ad1848 variants properly. Compile test only.

Please check all attribute users in all files.* on device_t/softc split.

XXX: not sure if gus(4) needs device_t in ad1848_isa_softc
 1.13 02-Jun-2011  nonaka fix compile failure.
 1.12 02-Oct-2010  gsutre branches: 1.12.2; 1.12.6;
Drop _HID requirement for attachment under acpi(4). From now on,
drivers attaching to the acpinodebus interface should not assume
that the passed acpi_devnode has a valid _HID.

ok jruoho@
 1.11 05-Mar-2010  jruoho branches: 1.11.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.10 19-Aug-2009  jmcneill branches: 1.10.2;
Adapt for ACPICA API changes.
 1.9 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.8 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.7 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.6 17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.5 05-Apr-2008  cegger branches: 1.5.4; 1.5.12; 1.5.14; 1.5.18; 1.5.22;
use aprint_*_dev and device_xname
 1.4 19-Oct-2007  ad branches: 1.4.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.3 16-Nov-2006  christos branches: 1.3.4; 1.3.10; 1.3.24; 1.3.26; 1.3.30;
__unused removal on arguments; approved by core.
 1.2 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.1 14-Aug-2006  itohy branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
ACPI frontend for Yamaha OPL3-SA[23].
Derived from PR kern/33991 by jasper at pointless dot net.
 1.1.8.2 10-Dec-2006  yamt sync with head.
 1.1.8.1 22-Oct-2006  yamt sync with head
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 14-Aug-2006  rpaulo file ym_acpi.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.4.1 18-Nov-2006  ad Sync with head.
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 14-Aug-2006  yamt file ym_acpi.c was added on branch yamt-pdpolicy on 2006-09-03 15:23:55 +0000
 1.3.30.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.26.1 06-Nov-2007  matt sync with HEAD
 1.3.24.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.10.1 23-Oct-2007  ad Sync with head.
 1.3.4.3 27-Oct-2007  yamt sync with head.
 1.3.4.2 30-Dec-2006  yamt sync with head.
 1.3.4.1 16-Nov-2006  yamt file ym_acpi.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:54 +0000
 1.4.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.22.1 21-Apr-2010  matt sync to netbsd-5
 1.5.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.14.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.5.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.5.4.5 09-Oct-2010  yamt sync with head
 1.5.4.4 11-Mar-2010  yamt sync with head
 1.5.4.3 19-Aug-2009  yamt sync with head.
 1.5.4.2 16-May-2009  yamt sync with head
 1.5.4.1 04-May-2009  yamt sync with head.
 1.10.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.2 12-Jun-2011  rmind sync with head
 1.11.2.1 05-Mar-2011  rmind sync with head
 1.12.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.30.1 05-Oct-2016  skrll Sync with HEAD
 1.14.12.1 03-Dec-2017  jdolecek update from HEAD
 1.15.22.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.15.18.1 10-Jun-2019  christos Sync with HEAD
 1.7 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.6 12-Jun-2011  jruoho 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.5 23-Aug-2009  jmcneill branches: 1.5.10;
When ACPI is not present, free any resources used by the ACPICA. Also,
no need to complain (unless we're debugging) that ACPI is not present.
 1.4 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.3 15-Dec-2007  perry branches: 1.3.10;
__FUNCTION__ -> __func__
 1.2 09-Dec-2007  jmcneill branches: 1.2.2;
Merge jmcneill-pm branch.
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.20; 1.1.44; 1.1.46; 1.1.56; 1.1.58;
Move from sys/dev/acpi/acpica/Osd.
 1.1.58.1 11-Dec-2007  yamt sync with head.
 1.1.56.1 26-Dec-2007  ad Sync with head.
 1.1.46.1 09-Jan-2008  matt sync with HEAD
 1.1.44.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 23-Mar-2006  rpaulo file OsdEnvironment.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdEnvironment.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdEnvironment.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdEnvironment.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdEnvironment.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdEnvironment.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.2.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.10.2 16-Sep-2009  yamt sync with head
 1.3.10.1 19-Aug-2009  yamt sync with head.
 1.5.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15 23-Jun-2024  andvar s/machinde/machine/ in comment.
 1.14 31-May-2022  mrg allow ACPI to compile without PCI support. fixes ia64 build.
 1.13 31-Dec-2021  riastradh acpi(9): Return full 64-bit object to caller in PCI config read.

The value of the object will be as small as requested, but the whole
uint64_t object will be written as the caller of a space handler
expects, instead of just part of it.
 1.12 17-Jan-2020  jmcneill Add support for Arm N1 SDP PCIe host controller.

The N1 SDP has a few bugs that we need to work around:
- PCIe root port config space lives in a non-standard location.
- Access to PCIe config space of devices that do not exist results in
an sync SError. Firmware creates a "known devices" table at a fixed
physical address that we use to filter PCI conf access to only known
devices.

This change splits the Arm ACPI PCI quirks into separate files for each
host controller, and allows per-segment quirks to be applied.

These changes exposed some bugs in the MI ACPI layer related to
multi-segment support. The MI ACPI PCI code was using a shared PCI
chipset tag to access devices, and these accesses can happen before our
PCI host bridge drivers are attached! The global chipset tag is now gone,
and an MD callback can provide a custom tag on a per-segment basis.
 1.11 15-Feb-2019  kamil branches: 1.11.6;
Avoid UB in OsdHardware.c

UBSan: Undefined Behavior in src/sys/dev/acpi/acpica/OsdHardware.c:265:17,
left shift of 255 by 24 places cannot be represented in type 'int'

This file isn't part of upstream acpica so just fix it locally.

Reported and initial patch by <Akul Pillai>
 1.10 26-Jan-2016  christos branches: 1.10.18;
The new acpi code tries to read the pci configuration registers in the
acpi_probe() phase, before acpi_softc is allocated. Detect this and use
a NULL chipset handle instead of crashing.
 1.9 27-Dec-2013  christos branches: 1.9.6;
Add new functions
 1.8 17-Feb-2011  jruoho branches: 1.8.4; 1.8.14; 1.8.18;
ACPICA 20100806:

Fixed a problem with the prototype for AcpiOsReadPciConfiguration.
The prototype in acpiosxf.h had the output value pointer as a (void *).
It should be a (UINT64 *). This may affect some host OSL code.
 1.7 17-Feb-2011  jruoho ACPICA 20100915:

Removed the AcpiOsDerivePciId OSL interface. The various host
implementations of this function were not OS-dependent and are now obsolete
and can be removed from all host OSLs. This function has been replaced by
AcpiHwDerivePciId, which is now part of the ACPICA core code.
AcpiHwDerivePciId has been implemented without recursion. Adds one new
module, hwpci.c. ACPICA BZ 857.
 1.6 10-Jul-2010  gsutre branches: 1.6.2; 1.6.4;
AcpiOsDerivePciId: make sure that we only update the PCI bus number,
and that we do so only if it was succesfully derived.

ok jruoho@, kochi@
 1.5 15-Sep-2009  drochner branches: 1.5.2; 1.5.4;
fix undefined return values of Read/WriteMemory, found by clang
static analyzer
 1.4 12-Dec-2007  jmcneill branches: 1.4.10;
Try not to pass garbage to pci_make_tag; workaround for odd ACPI DSDTs.
Fixes kern/37527.
 1.3 09-Dec-2007  jmcneill branches: 1.3.2;
Merge jmcneill-pm branch.
 1.2 14-May-2006  elad branches: 1.2.6; 1.2.12; 1.2.36; 1.2.38; 1.2.48; 1.2.50;
integrate kauth.
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Move from sys/dev/acpi/acpica/Osd.
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdHardware.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdHardware.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdHardware.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdHardware.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.2.50.2 13-Dec-2007  yamt sync with head.
 1.2.50.1 11-Dec-2007  yamt sync with head.
 1.2.48.1 26-Dec-2007  ad Sync with head.
 1.2.38.1 09-Jan-2008  matt sync with HEAD
 1.2.36.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.2.12.2 09-Sep-2006  rpaulo sync with head
 1.2.12.1 14-May-2006  rpaulo file OsdHardware.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.2.6.3 21-Jan-2008  yamt sync with head
 1.2.6.2 21-Jun-2006  yamt sync with head.
 1.2.6.1 14-May-2006  yamt file OsdHardware.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.3.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.4.10.2 11-Aug-2010  yamt sync with head.
 1.4.10.1 16-Sep-2009  yamt sync with head
 1.5.4.1 05-Mar-2011  rmind sync with head
 1.5.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.18.1 18-May-2014  rmind sync with head
 1.8.14.2 03-Dec-2017  jdolecek update from HEAD
 1.8.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.4.1 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.9.6.1 19-Mar-2016  skrll Sync with HEAD
 1.10.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.18.1 10-Jun-2019  christos Sync with HEAD
 1.11.6.1 17-Jan-2020  ad Sync with head.
 1.9 20-Mar-2018  bouyer 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.8 18-Aug-2009  jmcneill branches: 1.8.62;
Switch to ACPICA 20090730, and update for API changes.
 1.7 15-Dec-2007  perry branches: 1.7.10;
__FUNCTION__ -> __func__
 1.6 19-Feb-2007  ad branches: 1.6.18; 1.6.26; 1.6.30;
Initialize acpi_interrupt_list_mtx in acpi_probe().
 1.5 19-Feb-2007  xtraeme Forgot to initialize the mutex.
 1.4 19-Feb-2007  xtraeme Replace ACPI_INTERRUPT_LIST_{LOCK,UNLOCK} mutex_{enter,exit}
 1.3 18-Feb-2007  xtraeme Replace simple_locks with mutexes, reviewed by ad@.
 1.2 27-Aug-2006  christos branches: 1.2.4; 1.2.10;
Delete unsigned comparison with < 0
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14;
Move from sys/dev/acpi/acpica/Osd.
 1.1.14.5 21-Jan-2008  yamt sync with head
 1.1.14.4 26-Feb-2007  yamt sync with head.
 1.1.14.3 30-Dec-2006  yamt sync with head.
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdInterrupt.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdInterrupt.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdInterrupt.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.3 03-Sep-2006  yamt sync with head.
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdInterrupt.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdInterrupt.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.2.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.2.4.2 09-Sep-2006  rpaulo sync with head
 1.2.4.1 27-Aug-2006  rpaulo file OsdInterrupt.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.6.30.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.26.1 26-Dec-2007  ad Sync with head.
 1.6.18.1 09-Jan-2008  matt sync with HEAD
 1.7.10.1 19-Aug-2009  yamt sync with head.
 1.8.62.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.5 22-Apr-2012  jruoho As in Linux, prevent BIOS from trying to map addresses beyond ULONG_MAX.
 1.4 17-Feb-2011  jruoho branches: 1.4.4; 1.4.8;
ACPICA 20100806:

Obsolete Functions: AcpiOsValidateInterface - no longer used.
 1.3 18-Aug-2009  jmcneill branches: 1.3.4; 1.3.6; 1.3.8;
Switch to ACPICA 20090730, and update for API changes.
 1.2 09-Dec-2007  jmcneill branches: 1.2.14;
Merge jmcneill-pm branch.
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.20; 1.1.44; 1.1.46; 1.1.56; 1.1.58;
Move from sys/dev/acpi/acpica/Osd.
 1.1.58.1 11-Dec-2007  yamt sync with head.
 1.1.56.1 26-Dec-2007  ad Sync with head.
 1.1.46.1 09-Jan-2008  matt sync with HEAD
 1.1.44.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 23-Mar-2006  rpaulo file OsdMemory.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdMemory.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdMemory.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdMemory.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdMemory.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdMemory.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.2.14.1 19-Aug-2009  yamt sync with head.
 1.3.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 05-Mar-2011  rmind sync with head
 1.4.8.1 29-Apr-2012  mrg sync to latest -current.
 1.4.4.1 23-May-2012  yamt sync with head.
 1.16 25-Jan-2017  christos implement new interfaces
 1.15 09-Jan-2016  christos branches: 1.15.2; 1.15.4;
merge new acpica
 1.14 27-Dec-2013  christos branches: 1.14.6;
use ACPI_DEBUG not ACPI_DEBUGGER which is used internally by acpica
 1.13 27-Dec-2013  christos Add new functions
 1.12 28-Jun-2011  jruoho branches: 1.12.2; 1.12.12; 1.12.16;
Adjust a prototype due ACPICA 20110623.
 1.11 17-Feb-2011  jruoho Include acdebug.h for the ACPICA debugger.
 1.10 17-Feb-2011  jruoho Switch acpi(4) to use the new location of ACPICA.
 1.9 11-Apr-2010  jruoho branches: 1.9.2; 1.9.4;
Document "how-to override the DSDT" in the manual page instead of code.
 1.8 10-Apr-2010  jruoho Update a comment.
 1.7 18-Aug-2009  jmcneill branches: 1.7.2; 1.7.4;
Switch to ACPICA 20090730, and update for API changes.
 1.6 06-Jul-2009  joerg Ignore breakpoints in the DSDT even if DDB is present.
A new option ACPI_BREAKPOINT reenables them.
 1.5 16-Nov-2006  christos branches: 1.5.52; 1.5.68;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 13-Apr-2006  kochi branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16; 1.3.18;
NULL check for a parameter of AcpiOsSignal().
The upper layer (ACPI-CA) might call with NULL pointer.

This should resolve Coverity CID 1114.
 1.2 23-Mar-2006  kochi branches: 1.2.2; 1.2.4;
change header location in accordance with moving ACPI-CA to sys/dist
 1.1 23-Mar-2006  kochi Move from sys/dev/acpi/acpica/Osd.
 1.2.4.3 24-May-2006  yamt sync with head.
 1.2.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.2.4.1 23-Mar-2006  yamt file OsdMisc.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.2.2.3 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.2.2.1 23-Mar-2006  tron file OsdMisc.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.3.18.2 10-Dec-2006  yamt sync with head.
 1.3.18.1 22-Oct-2006  yamt sync with head
 1.3.16.2 09-Sep-2006  rpaulo sync with head
 1.3.16.1 13-Apr-2006  rpaulo file OsdMisc.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.3.10.2 21-Jun-2006  yamt sync with head.
 1.3.10.1 13-Apr-2006  yamt file OsdMisc.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.3.4.2 22-Apr-2006  simonb Sync with head.
 1.3.4.1 13-Apr-2006  simonb file OsdMisc.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.3.2.2 19-Apr-2006  elad sync with head.
 1.3.2.1 13-Apr-2006  elad file OsdMisc.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.5.68.1 23-Jul-2009  jym Sync with HEAD.
 1.5.52.3 11-Aug-2010  yamt sync with head.
 1.5.52.2 19-Aug-2009  yamt sync with head.
 1.5.52.1 18-Jul-2009  yamt sync with head.
 1.7.4.2 05-Mar-2011  rmind sync with head
 1.7.4.1 30-May-2010  rmind sync with head
 1.7.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.9.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.9.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.16.1 18-May-2014  rmind sync with head
 1.12.12.2 03-Dec-2017  jdolecek update from HEAD
 1.12.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.1 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.14.6.2 05-Feb-2017  skrll Sync with HEAD
 1.14.6.1 19-Mar-2016  skrll Sync with HEAD
 1.15.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.15.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.20 31-Dec-2021  riastradh acpi(9): Implement AcpiOsWaitEventsComplete.
 1.19 12-Nov-2017  christos Provide a primitive incrementing counter if we are call since the new
Acpi dispatcher requires us to have one when we are cold (shudder).
 1.18 09-Jan-2016  christos merge new acpica
 1.17 27-Dec-2013  christos branches: 1.17.6;
Add new functions
 1.16 17-Feb-2011  jmcneill branches: 1.16.4; 1.16.14; 1.16.18;
cast curlwp to uintptr_t before casting to ACPI_THREAD_ID, fixes i386 build
 1.15 05-Jun-2010  jruoho branches: 1.15.2; 1.15.4;
Remove also the debug-printf in case of long Stall() requests;

/*
* sleep(9) isn't safe because AcpiOsStall may be called
* with interrupt-disabled. (eg. by AcpiEnterSleepState)
* we should watch out for long stall requests.
*/

ACPICA has long printed a similar warning by itself. Moreover, this message
was never reached as the interpreter does not invoke AcpiOsStall() when a
delay longer than 255 usec is requested.
 1.14 05-Jun-2010  jruoho Remove the recently added warning about long Sleep() requests.

This is now in ACPICA (20100528):

Added support to limit the maximum time for the ASL Sleep()
operator. To prevent accidental deep sleeps, limit the maximum time
that Sleep() will actually sleep. Configurable, the default maximum
is two seconds. ACPICA bugzilla 854.
 1.13 12-May-2010  jruoho Print a warning if AcpiOsSleep() is called with a value larger than two
seconds. It is known that there are systems in the field that pass bogus AML
values to the Sleep() operation code, possibly requesting delays that could
be measured in days.

Discussed with jmcneill@.

XXX: While the used mstohz(9) is documented to round to one second if the
passed value is larger than 131072 ms, we may still need to force a
sensible upper limit if this warning starts to appear.
 1.12 23-Aug-2009  jmcneill branches: 1.12.2; 1.12.4;
When ACPI is not present, free any resources used by the ACPICA. Also,
no need to complain (unless we're debugging) that ACPI is not present.
 1.11 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.10 31-Mar-2009  drochner avoid tsleep also during shutdown (and in particular ACPI poweroff),
should fix PR kern/39141 by Takahiro Kambe and PR port-i386/41110
by Reinoud Zandijk
 1.9 30-Jan-2009  jmcneill branches: 1.9.2;
PR# kern/38817: regression in acpi sleep on lifebook S6510

Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.8 31-May-2008  jmcneill branches: 1.8.6; 1.8.8;
Don't use cv_timedwait_sig if (cold)
 1.7 24-Apr-2008  jmcneill branches: 1.7.2; 1.7.4;
Define ACPI_THREAD_ID as uintptr_t, and return curlwp instead of
curlwp->l_lid from AcpiOsGetThreadId(), as suggested by ad@
 1.6 22-Apr-2008  jmcneill AcpiOsGetThreadId should return lwpid, not pid -- otherwise we always return
the same value! Fixes the AE_AML_MUTEX_NOT_ACQUIRED issue when evaluating
_BST on ASUS Eee PC. Who knows what other mysterious bugs this has caused
over the years...
 1.5 21-Dec-2007  jmcneill branches: 1.5.6; 1.5.8;
Convert AcpiOsSleep from using tsleep to cv_timedwait_sig
 1.4 17-Dec-2007  jmcneill Fix comment before AcpiOsGetTimer, no functional change.
 1.3 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.2 09-Dec-2007  jmcneill branches: 1.2.2;
Merge jmcneill-pm branch.
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.20; 1.1.44; 1.1.46; 1.1.56; 1.1.58;
Move from sys/dev/acpi/acpica/Osd.
 1.1.58.1 11-Dec-2007  yamt sync with head.
 1.1.56.1 26-Dec-2007  ad Sync with head.
 1.1.46.1 09-Jan-2008  matt sync with HEAD
 1.1.44.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 23-Mar-2006  rpaulo file OsdSchedule.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdSchedule.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdSchedule.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdSchedule.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdSchedule.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdSchedule.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.2.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.8.2 04-Jun-2008  yamt sync with head
 1.5.8.1 18-May-2008  yamt sync with head.
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.2.4 11-Aug-2010  yamt sync with head.
 1.7.2.3 16-Sep-2009  yamt sync with head
 1.7.2.2 19-Aug-2009  yamt sync with head.
 1.7.2.1 04-May-2009  yamt sync with head.
 1.8.8.1 02-Feb-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #381):
sys/dev/acpi/acpi.c: revision 1.123
sys/dev/acpi/acpica/OsdSchedule.c: revision 1.9
sys/dev/acpi/acpica/OsdSynch.c: revision 1.11
PR# kern/38817: regression in acpi sleep on lifebook S6510
Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.8.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.8.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.9.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.3 05-Mar-2011  rmind sync with head
 1.12.4.2 03-Jul-2010  rmind sync with head
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.15.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.18.1 18-May-2014  rmind sync with head
 1.16.14.2 03-Dec-2017  jdolecek update from HEAD
 1.16.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.4.1 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.17.6.1 19-Mar-2016  skrll Sync with HEAD
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.20;
Move from sys/dev/acpi/acpica/Osd.
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 23-Mar-2006  rpaulo file OsdStream.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdStream.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdStream.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdStream.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdStream.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdStream.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.13 18-Aug-2009  jmcneill Switch to ACPICA 20090730, and update for API changes.
 1.12 31-Mar-2009  drochner avoid tsleep also during shutdown (and in particular ACPI poweroff),
should fix PR kern/39141 by Takahiro Kambe and PR port-i386/41110
by Reinoud Zandijk
 1.11 30-Jan-2009  jmcneill branches: 1.11.2;
PR# kern/38817: regression in acpi sleep on lifebook S6510

Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.10 15-Dec-2007  perry branches: 1.10.10; 1.10.18; 1.10.20;
__FUNCTION__ -> __func__
 1.9 09-Dec-2007  jmcneill branches: 1.9.2;
Merge jmcneill-pm branch.
 1.8 05-Dec-2007  ad branches: 1.8.2;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.7 19-Feb-2007  ad branches: 1.7.16; 1.7.18; 1.7.24; 1.7.26;
The ACPI locks need to run at IPL_VM, since they can be taken from
interrupt handlers.
 1.6 19-Feb-2007  xtraeme AcpiOsDelete{Lock,Semaphore}: don't forget to destroy the mutex,
otherwise mutex_init might be called multiple times.

Discussed with Andrew hours ago.
 1.5 19-Feb-2007  xtraeme * Provide same description in cv_init as we had before.
* Use cv_timedwait.

Thanks to Andrew for information.
 1.4 18-Feb-2007  xtraeme * Replace simple_locks and exclusive locks with adaptive mutexes.
* Replace ltsleep/wakeup pairs with condition variables
(cv_init/cv_wait/cv_broadcast).

Reviewed by ad@.
 1.3 16-Nov-2006  christos branches: 1.3.4;
__unused removal on arguments; approved by core.
 1.2 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.1 23-Mar-2006  kochi branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.18; 1.1.20; 1.1.22;
Move from sys/dev/acpi/acpica/Osd.
 1.1.22.2 10-Dec-2006  yamt sync with head.
 1.1.22.1 22-Oct-2006  yamt sync with head
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 23-Mar-2006  rpaulo file OsdSynch.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:49:29 +0000
 1.1.18.1 18-Nov-2006  ad Sync with head.
 1.1.14.5 21-Jan-2008  yamt sync with head
 1.1.14.4 07-Dec-2007  yamt sync with head
 1.1.14.3 26-Feb-2007  yamt sync with head.
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 23-Mar-2006  yamt file OsdSynch.c was added on branch yamt-lazymbuf on 2006-06-21 15:02:32 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 23-Mar-2006  simonb file OsdSynch.c was added on branch simonb-timecounters on 2006-04-22 11:38:49 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 23-Mar-2006  elad file OsdSynch.c was added on branch elad-kernelauth on 2006-04-19 03:24:24 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 23-Mar-2006  yamt file OsdSynch.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 23-Mar-2006  tron file OsdSynch.c was added on branch peter-altq on 2006-03-28 09:42:03 +0000
 1.3.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.7.26.2 26-Dec-2007  ad Sync with head.
 1.7.26.1 08-Dec-2007  ad Sync with head.
 1.7.24.2 27-Dec-2007  mjf Sync with HEAD.
 1.7.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.18.1 09-Jan-2008  matt sync with HEAD
 1.7.16.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.16.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.8.2.1 11-Dec-2007  yamt sync with head.
 1.9.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.20.1 02-Feb-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #381):
sys/dev/acpi/acpi.c: revision 1.123
sys/dev/acpi/acpica/OsdSchedule.c: revision 1.9
sys/dev/acpi/acpica/OsdSynch.c: revision 1.11
PR# kern/38817: regression in acpi sleep on lifebook S6510
Switch to polling mode after the acpi(4) device has been suspended as
interrupts will be disabled later on and we may still need to execute
AML that tries to sleep or wait on a semaphore.
 1.10.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.10.18.1 03-Mar-2009  skrll Sync with HEAD.
 1.10.10.2 19-Aug-2009  yamt sync with head.
 1.10.10.1 04-May-2009  yamt sync with head.
 1.11.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7 24-Feb-2025  christos mention script
 1.6 18-Jan-2014  apb branches: 1.6.68;
+ Please also update ACPI_DATE in include/acapps.h.
 1.5 27-Dec-2013  christos - remove function list that was out of date
- explain magical munging so that people are not scared to update in the future.
 1.4 24-Jul-2010  jruoho branches: 1.4.8; 1.4.18; 1.4.22;
Update and fix a typo.
 1.3 06-Feb-2003  perry branches: 1.3.104; 1.3.126; 1.3.128;
Document a URL from which you can get the ACPICA programmer reference manual.
 1.2 28-Sep-2001  thorpej branches: 1.2.2; 1.2.4; 1.2.8;
Oops, RCS ID.
 1.1 28-Sep-2001  thorpej File describing the ACPICA and how we glue it to NetBSD.
 1.2.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.1 28-Sep-2001  thorpej file README was added on branch kqueue on 2002-01-10 19:52:55 +0000
 1.2.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.4.1 28-Sep-2001  nathanw file README was added on branch nathanw_sa on 2001-10-08 21:18:07 +0000
 1.2.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 28-Sep-2001  fvdl file README was added on branch thorpej-devvp on 2001-10-01 12:44:18 +0000
 1.3.128.1 05-Mar-2011  rmind sync with head
 1.3.126.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.104.1 11-Aug-2010  yamt sync with head.
 1.4.22.1 18-May-2014  rmind sync with head
 1.4.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.8.1 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.6.68.1 02-Aug-2025  perseant Sync with HEAD
 1.7 10-May-2023  riastradh acpi(4): Fix membars in ACPI_ACQUIRE/RELEASE_GLOBAL_LOCK.

XXX pullup-8 (by patch with membar_enter/exit)
XXX pullup-9 (by patch with membar_enter/exit)
XXX pullup-10
 1.6 12-Oct-2018  jmcneill branches: 1.6.4; 1.6.30;
Implement ACPI_FLUSH_CPU_CACHE on aarch64.
 1.5 19-Apr-2018  christos branches: 1.5.2;
s/static inline/static __inline/g for consistency.
 1.4 24-Jul-2010  jruoho branches: 1.4.52; 1.4.58;
Revert the previous partially for the time being.
 1.3 24-Jul-2010  jruoho Move ACPI_FLUSH_CPU_CACHE() (a.k.a. WBINVD on x86) to MD headers where it
belongs to. Let IA-64 define its own function/instruction instead of
requiring a dummy wbinvd() to satisfy the definition in a MI header.
 1.2 08-Mar-2010  jruoho branches: 1.2.2;
Add missing (FreeBSD) license. Ok jmcneill@.
 1.1 24-May-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22; 1.1.26;
MI implementation of AcpiAcquireGlobalLock and AcpiReleaseGlobalLock.
 1.1.26.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.26.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.22.4 11-Aug-2010  yamt sync with head.
 1.1.22.3 11-Mar-2010  yamt sync with head
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 24-May-2008  yamt file acpi_func.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:34 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 24-May-2008  wrstuden file acpi_func.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 24-May-2008  yamt file acpi_func.h was added on branch yamt-pf42 on 2008-06-04 02:05:10 +0000
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 24-May-2008  mjf file acpi_func.h was added on branch mjf-devfs2 on 2008-06-02 13:23:13 +0000
 1.2.2.1 05-Mar-2011  rmind sync with head
 1.4.58.2 20-Oct-2018  pgoyette Sync with head
 1.4.58.1 22-Apr-2018  pgoyette Sync with HEAD
 1.4.52.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1873):

sys/dev/acpi/acpica/acpi_func.h: revision 1.7 (patch)

acpi(4): Fix membars in ACPI_ACQUIRE/RELEASE_GLOBAL_LOCK.
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.6.30.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #290):

sys/dev/acpi/acpica/acpi_func.h: revision 1.7

acpi(4): Fix membars in ACPI_ACQUIRE/RELEASE_GLOBAL_LOCK.
 1.6.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1692):

sys/dev/acpi/acpica/acpi_func.h: revision 1.7 (patch)

acpi(4): Fix membars in ACPI_ACQUIRE/RELEASE_GLOBAL_LOCK.
 1.15 17-Feb-2011  jruoho Switch acpi(4) to use the new location of ACPICA.
 1.14 18-Aug-2009  jmcneill branches: 1.14.4; 1.14.6; 1.14.8;
Switch to ACPICA 20090730, and update for API changes.
 1.13 09-Dec-2007  jmcneill branches: 1.13.14;
Merge jmcneill-pm branch.
 1.12 23-Mar-2006  kochi branches: 1.12.32; 1.12.34; 1.12.44; 1.12.46;
Move ACPI-CA to sys/dist/acpica.
also move ACPI-CA OS dependent sources from sys/dev/acpi/acpica/Osd to
sys/dev/acpi/acpica.
 1.11 29-Jan-2006  kochi branches: 1.11.2; 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Merge ACPI-CA 20060113
 1.10 11-Dec-2005  christos branches: 1.10.2;
merge ktrace-lwp.
 1.9 13-Dec-2003  kochi branches: 1.9.16;
Merge ACPI-CA 20031203
 1.8 26-Nov-2003  kochi Remove unused file.
 1.7 31-Oct-2003  mycroft Add a file.
 1.6 08-Jul-2003  kochi Don't compile db*.c & dm*.c unless ACPI_DEBUG and DDB are specified
 1.5 04-Mar-2003  kochi branches: 1.5.2;
Update for acpica-unix-20030228.
 1.4 13-Feb-2003  kanaoka Resolve conflict from acpica-unix-20030123.
 1.3 23-Dec-2002  kanaoka Resolve conflict from acpica-unix-20021205.
 1.2 15-Jun-2002  thorpej Update for acpica-unix-20020612.
 1.1 28-Sep-2001  thorpej branches: 1.1.2; 1.1.4; 1.1.8; 1.1.16;
config(8) files declaration for ACPICA.
 1.1.16.1 20-Jun-2002  gehenna catch up with -current.
 1.1.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 28-Sep-2001  thorpej file files.acpica was added on branch kqueue on 2002-01-10 19:52:55 +0000
 1.1.4.4 29-Dec-2002  thorpej Sync with HEAD.
 1.1.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1 28-Sep-2001  nathanw file files.acpica was added on branch nathanw_sa on 2001-10-08 21:18:07 +0000
 1.1.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1 28-Sep-2001  fvdl file files.acpica was added on branch thorpej-devvp on 2001-10-01 12:44:19 +0000
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.2 21-Jan-2008  yamt sync with head
 1.9.16.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 01-Feb-2006  yamt sync with head.
 1.11.10.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.11.8.1 19-Apr-2006  elad sync with head.
 1.11.6.1 01-Apr-2006  yamt sync with head.
 1.11.4.1 22-Apr-2006  simonb Sync with head.
 1.11.2.1 09-Sep-2006  rpaulo sync with head
 1.12.46.1 11-Dec-2007  yamt sync with head.
 1.12.44.1 26-Dec-2007  ad Sync with head.
 1.12.34.1 09-Jan-2008  matt sync with HEAD
 1.12.32.1 02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.13.14.1 19-Aug-2009  yamt sync with head.
 1.14.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.14.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.4.1 05-Mar-2011  rmind sync with head
 1.8 16-Feb-2011  jruoho Add a skeleton driver for Asus EeePC acpiwmi(4) mappings.
 1.7 24-Oct-2010  jruoho branches: 1.7.2; 1.7.4;
Add acpiwmi(4) mappings for MSI laptops.

XXX: It may be necessary to fix PR # 43659 before this works on all models.
 1.6 06-Aug-2010  jruoho branches: 1.6.2;
Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.5 19-Jul-2010  jakllsch correct an obvious typo: acpwmi -> acpiwmi
 1.4 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.3 08-Apr-2010  jruoho branches: 1.3.2; 1.3.4;
Add WMI mappings for HP laptops. Requested by cegger@.
Thanks to apb@ and cegger@ for initial testing.

XXX: This conflicts with hpqlb(4). Someone with the suitable hardware needs
to complete the list of hotkeys before -- and if -- this can replace
hpqlb(4). For now, the driver was left uncommented in the GENERICs.
 1.2 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.1 08-Apr-2010  jruoho Add WMI mappings for Dell laptops. Requested and tested by mrg@.
 1.3.4.4 05-Mar-2011  rmind sync with head
 1.3.4.3 03-Jul-2010  rmind sync with head
 1.3.4.2 30-May-2010  rmind sync with head
 1.3.4.1 08-Apr-2010  rmind file files.wmi was added on branch rmind-uvmplock on 2010-05-30 05:17:18 +0000
 1.3.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.3.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.1 08-Apr-2010  uebayasi file files.wmi was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.6.2.2 11-Aug-2010  yamt sync with head.
 1.6.2.1 06-Aug-2010  yamt file files.wmi was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.7.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.7.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.23 11-Aug-2023  riastradh acpiwmi(4): Fix abuse of char buffer for struct guid_t content.

Nothing guarantees alignment, so this is all undefined behaviour,
even if we don't touch the uninitialized members.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.22 10-Aug-2023  mrg don't assign struct pointers to smaller then structure regions of memory.

in all cases here, the later parts of the structure are not actually
accessed, so there are no existing bugs here beyond general UB. for the
ufs ones, this also removes some casts.

found by GCC 12.
 1.21 10-May-2023  riastradh acpiwmi(4): Use config_detach_children.
 1.20 12-Dec-2021  andvar fix various typos in comments.
 1.19 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.18 24-Apr-2021  thorpej branches: 1.18.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.17 29-Jan-2021  thorpej branches: 1.17.2;
Use acpi_compatible_match().
 1.16 03-Dec-2017  bouyer branches: 1.16.18;
- make sure strtoul() is called with a NULL-terminated string.
- acpi_wmi_input(): a valid data block may have flags set to 0.
 1.15 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.14 14-Aug-2012  jruoho branches: 1.14.2; 1.14.16;
Use KM_SLEEP.
 1.13 17-Jul-2011  jakllsch branches: 1.13.2;
- Fix wmieeepc(4) hotkeys on Eee PC 1215T
- Rework wmi_event_enable into appropriately seperate versions for enabling
events and collection.
- Enable all events, not just ones tagged as expensive.
 1.12 16-Feb-2011  jruoho Convert the homegrown module declarations to use ioconf.
 1.11 28-Oct-2010  jruoho branches: 1.11.2; 1.11.4;
Install EC space handler and pass everything to acpiec(4).
Should fix PR # 43659.
 1.10 25-Oct-2010  jruoho Fix build failure.
 1.9 24-Oct-2010  jmcneill add support for building as a module
 1.8 24-Oct-2010  jmcneill add rescan support
 1.7 06-Aug-2010  jruoho branches: 1.7.2;
Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.6 29-Jul-2010  jruoho Add "pnp0c14" to the list of HIDs. Required for LG X110. As valid EISA IDs
should be all upper case, leave this as a onetime quirk specific to acpiwmi(4).
 1.5 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.4 15-Apr-2010  jruoho branches: 1.4.2; 1.4.4;
As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.3 09-Apr-2010  jruoho Fix a potential NULL pointer dereference.
 1.2 08-Apr-2010  jruoho Semantics.
 1.1 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.4.4.4 05-Mar-2011  rmind sync with head
 1.4.4.3 03-Jul-2010  rmind sync with head
 1.4.4.2 30-May-2010  rmind sync with head
 1.4.4.1 15-Apr-2010  rmind file wmi_acpi.c was added on branch rmind-uvmplock on 2010-05-30 05:17:18 +0000
 1.4.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.4.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.2.1 15-Apr-2010  uebayasi file wmi_acpi.c was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.7.2.2 11-Aug-2010  yamt sync with head.
 1.7.2.1 06-Aug-2010  yamt file wmi_acpi.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.11.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.11.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.2.1 30-Oct-2012  yamt sync with head
 1.14.16.1 28-Aug-2017  skrll Sync with HEAD
 1.14.2.1 03-Dec-2017  jdolecek update from HEAD
 1.16.18.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17.2.1 24-Mar-2021  thorpej Don't filter interface attributes in rescan functions for devices that
carry only a single interface attribute. The autoconfiguration machinery
already considers interface attributes when searching for possible parents.
 1.18.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.6 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.5 28-Oct-2010  jruoho branches: 1.5.72;
Install EC space handler and pass everything to acpiec(4).
Should fix PR # 43659.
 1.4 05-Jun-2010  jruoho branches: 1.4.2;
Remove trailing white space.
 1.3 31-May-2010  pgoyette Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.2 08-Apr-2010  jruoho branches: 1.2.2; 1.2.4;
Semantics.
 1.1 08-Apr-2010  jruoho Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.2.4.4 05-Mar-2011  rmind sync with head
 1.2.4.3 03-Jul-2010  rmind sync with head
 1.2.4.2 30-May-2010  rmind sync with head
 1.2.4.1 08-Apr-2010  rmind file wmi_acpivar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:18 +0000
 1.2.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.2.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.2.1 08-Apr-2010  uebayasi file wmi_acpivar.h was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.4.2.2 11-Aug-2010  yamt sync with head.
 1.4.2.1 05-Jun-2010  yamt file wmi_acpivar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.5.72.1 20-Apr-2020  bouyer Sync with HEAD
 1.12 04-Dec-2019  bouyer Finally fix problem discussed in this old thread:
http://mail-index.netbsd.org/tech-kern/2017/12/03/msg022661.html

Dell's radio hotkey sends a PMFE_RADIO_TOGGLE event, but nothing actually
listen to it.
Turn it into a PSWITCH_HK_WIRELESS_BUTTON hotkey, similar to
what thinkpad_acpi.c does.
Add type/subtypes seen on a Dell lattitude 5480 laptop.
XXX we need a PMFE_AUDIO_MICRO_TOGGLE, and something to handle it.
 1.11 03-Dec-2017  christos branches: 1.11.4;
make this compile again and:
- remove extra space
- use alternate form %x printing
- use aprint_debug_dev instead of printf
 1.10 03-Dec-2017  bouyer Fix dell WMI mappings:
- query the descriptor to get the interface version, needed to workaround
a bug in the BIOS/ACPI
- properly decode the event buffer in type/subtype, and handle multiple events
per handler call
- record some known type/subtype in a table, with associated actions.

Informations mostly from linux. Tested on a Dell 5480 laptop.
 1.9 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.8 16-Feb-2011  jruoho branches: 1.8.14; 1.8.32;
Make the WMI modules depend on the parent mapper.
 1.7 16-Feb-2011  jruoho Convert the homegrown module declarations to use ioconf.
 1.6 25-Oct-2010  jruoho branches: 1.6.2; 1.6.4;
Bump WARNS to 4.
 1.5 24-Oct-2010  jmcneill add support for building as modules
 1.4 30-Jun-2010  jruoho branches: 1.4.2;
Initialize pointers to NULL. Otherwise we may try to free garbage.
Tries to address a panic reported by David Demelier in PR kern/43504.
 1.3 08-Apr-2010  jruoho branches: 1.3.2; 1.3.4;
Move acpiwmi(4) to the "sys/dev/acpi/wmi" -subdirectory.
 1.2 08-Apr-2010  jruoho Add a dummy acpi_wmi_event_deregister() to match existing conventions.
 1.1 08-Apr-2010  jruoho Add WMI mappings for Dell laptops. Requested and tested by mrg@.
 1.3.4.4 05-Mar-2011  rmind sync with head
 1.3.4.3 03-Jul-2010  rmind sync with head
 1.3.4.2 30-May-2010  rmind sync with head
 1.3.4.1 08-Apr-2010  rmind file wmi_dell.c was added on branch rmind-uvmplock on 2010-05-30 05:17:18 +0000
 1.3.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.3.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.1 08-Apr-2010  uebayasi file wmi_dell.c was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.4.2.2 11-Aug-2010  yamt sync with head.
 1.4.2.1 30-Jun-2010  yamt file wmi_dell.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.6.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.32.1 06-Jun-2015  skrll Sync with HEAD
 1.8.14.1 03-Dec-2017  jdolecek update from HEAD
 1.11.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 06-Aug-2010  jruoho Remove the acpiwmi(4) dump from the ACPIVERBOSE module. Instead of this
complex solution, just use aprint_debug(9) in the driver.
 1.1 31-May-2010  pgoyette branches: 1.1.2;
Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
 1.1.2.3 05-Mar-2011  rmind sync with head
 1.1.2.2 03-Jul-2010  rmind sync with head
 1.1.2.1 31-May-2010  rmind file wmi_dump.c was added on branch rmind-uvmplock on 2010-07-03 01:19:35 +0000
 1.4 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.3 22-Jul-2011  jakllsch branches: 1.3.12; 1.3.30;
Implement recognition of more wmieeepc(4) hotkey events.
 1.2 16-Feb-2011  jruoho branches: 1.2.2; 1.2.4; 1.2.8;
Make the WMI modules depend on the parent mapper.
 1.1 16-Feb-2011  jruoho Add a skeleton driver for Asus EeePC acpiwmi(4) mappings.
 1.2.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 16-Feb-2011  jruoho file wmi_eeepc.c was added on branch jruoho-x86intr on 2011-06-06 09:07:44 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 16-Feb-2011  rmind file wmi_eeepc.c was added on branch rmind-uvmplock on 2011-03-05 20:53:05 +0000
 1.2.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 16-Feb-2011  bouyer file wmi_eeepc.c was added on branch bouyer-quota2 on 2011-02-17 12:00:10 +0000
 1.3.30.1 06-Jun-2015  skrll Sync with HEAD
 1.3.12.1 03-Dec-2017  jdolecek update from HEAD
 1.11 06-Jun-2018  maya Remove duplicate ;
 1.10 01-Jun-2017  chs branches: 1.10.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.9 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.8 25-Feb-2014  pooka branches: 1.8.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.7 12-Oct-2012  cegger branches: 1.7.2;
Add support for various things:
- hddtemp sensor
- ambient light sensor on/off (via sysctl)
- display info
- docking station info
 1.6 16-Feb-2011  jruoho branches: 1.6.4; 1.6.14;
Make the WMI modules depend on the parent mapper.
 1.5 16-Feb-2011  jruoho Convert the homegrown module declarations to use ioconf.
 1.4 25-Oct-2010  jruoho branches: 1.4.2; 1.4.4;
Bump WARNS to 4.
 1.3 24-Oct-2010  jmcneill add support for building as modules
 1.2 30-Jun-2010  jruoho branches: 1.2.2;
Initialize pointers to NULL. Otherwise we may try to free garbage.
Tries to address a panic reported by David Demelier in PR kern/43504.
 1.1 08-Apr-2010  jruoho branches: 1.1.2; 1.1.4;
Add WMI mappings for HP laptops. Requested by cegger@.
Thanks to apb@ and cegger@ for initial testing.

XXX: This conflicts with hpqlb(4). Someone with the suitable hardware needs
to complete the list of hotkeys before -- and if -- this can replace
hpqlb(4). For now, the driver was left uncommented in the GENERICs.
 1.1.4.4 05-Mar-2011  rmind sync with head
 1.1.4.3 03-Jul-2010  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 08-Apr-2010  rmind file wmi_hp.c was added on branch rmind-uvmplock on 2010-05-30 05:17:18 +0000
 1.1.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 08-Apr-2010  uebayasi file wmi_hp.c was added on branch uebayasi-xip on 2010-04-30 14:43:07 +0000
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 30-Jun-2010  yamt file wmi_hp.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:17 +0000
 1.4.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.14.3 03-Dec-2017  jdolecek update from HEAD
 1.6.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.6.4.2 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.6.4.1 30-Oct-2012  yamt sync with head
 1.7.2.1 18-May-2014  rmind sync with head
 1.8.6.2 28-Aug-2017  skrll Sync with HEAD
 1.8.6.1 06-Jun-2015  skrll Sync with HEAD
 1.10.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.5 16-Feb-2011  jruoho branches: 1.5.2;
Make the WMI modules depend on the parent mapper.
 1.4 16-Feb-2011  jruoho Convert the homegrown module declarations to use ioconf.
 1.3 25-Oct-2010  jruoho branches: 1.3.2; 1.3.4; 1.3.6;
Bump WARNS to 4.
 1.2 24-Oct-2010  jmcneill add support for building as modules
 1.1 24-Oct-2010  jruoho Add acpiwmi(4) mappings for MSI laptops.

XXX: It may be necessary to fix PR # 43659 before this works on all models.
 1.3.6.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.3.2.1 25-Oct-2010  uebayasi file wmi_msi.c was added on branch uebayasi-xip on 2010-11-06 08:08:28 +0000
 1.5.2.2 05-Mar-2011  rmind sync with head
 1.5.2.1 16-Feb-2011  rmind file wmi_msi.c was added on branch rmind-uvmplock on 2011-03-05 20:53:05 +0000

RSS XML Feed