Home | History | Annotate | Download | only in acpi
History log of /src/sys/dev/acpi/acpi.c
RevisionDateAuthorComments
 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

RSS XML Feed