History log of /netbsd-current/sys/dev/acpi/acpi.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.299 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


Revision tags: netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.298 31-May-2022 mrg

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.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

branches: 1.278.4;
Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.298 31-May-2022 mrg

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.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.294 20-Dec-2021 skrll

Fix struct member prefix to be consistent. same code before and after.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.293 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_staticlib_x-base
# 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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: thorpej-i2c-spi-conf-base
# 1.292 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.


Revision tags: cjep_staticlib_x-base
# 1.291 24-Apr-2021 thorpej

branches: 1.291.2;
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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.291 24-Apr-2021 thorpej

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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.290 05-Feb-2021 thorpej

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.


Revision tags: thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.289 04-Feb-2021 thorpej

Add acpi_device_register(). Just a placeholder for now.


Revision tags: thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: thorpej-futex-newbase
# 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.


Revision tags: thorpej-futex-base
# 1.285 22-Jun-2020 maxv

branches: 1.285.2;
Fix memory leak. Found by kLSan.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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.


Revision tags: thorpej-futex-base
# 1.285 22-Jun-2020 maxv

Fix memory leak. Found by kLSan.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.286 08-Nov-2020 jmcneill

Ignore PNP0001 (EISA interrupt controller) and PNP0C02 (motherboard
resources) when enumerating devices.


Revision tags: thorpej-futex-base
# 1.285 22-Jun-2020 maxv

Fix memory leak. Found by kLSan.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.285 22-Jun-2020 maxv

Fix memory leak. Found by kLSan.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411
# 1.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.284 09-Apr-2020 jmcneill

Stop walking MADT / GTDT subtables if we hit a header with length 0


Revision tags: bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.283 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: ad-namecache-base1
# 1.283 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.


Revision tags: ad-namecache-base
# 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


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.282 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.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


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

branches: 1.271.2;
If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.278 21-Oct-2018 jmcneill

Add ACPI PCI link devices to ignored ids on arm64


Revision tags: pgoyette-compat-1020
# 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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.271 25-May-2018 ryoon

If fixed feature buttons exist, print detection messages.


Revision tags: pgoyette-compat-0521
# 1.270 05-May-2018 christos

introduce acpi_device_present() to replace the previous _STA checks.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.269 07-Apr-2018 christos

Merge conflicts; STA methods and fields are not present anymore.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.264 28-Oct-2017 riastradh

Kill some more extern struct cfdriver declarations.

Down with externs in .c!


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.262 21-Jun-2016 nonaka

Pass bus_dma(9) tag to allow for porting sdhc(4) at acpi.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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


Revision tags: nick-nhusb-base-20150921
# 1.260 18-Aug-2015 christos

add extra argument to method.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.259 25-Oct-2014 christos

branches: 1.259.2;
adjust for newer acpica


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 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.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.253 10-Apr-2012 jruoho

Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base
# 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


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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).


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.242 03-Jun-2011 jruoho

Flush CPU caches before entering S1, as noted in the specifications.


Revision tags: cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase
# 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.


Revision tags: bouyer-quota2-base
# 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.


Revision tags: jruoho-x86intr-base
# 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".


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4
# 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).


Revision tags: uebayasi-xip-base3
# 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@


Revision tags: yamt-nfs-mp-base11
# 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.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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@


Revision tags: matt-premerge-20091211
# 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


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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.


Revision tags: yamt-nfs-mp-base7
# 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


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.126 12-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 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.


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: mjf-devfs2-base
# 1.122 03-Jan-2009 yamt

remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.121 07-Dec-2008 mlelstv

Handle printing of _STR attribute with non-string data type gracefully.


Revision tags: netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4
# 1.120 19-Sep-2008 jmcneill

branches: 1.120.2; 1.120.4;
Revert previous.


Revision tags: wrstuden-revivesa-base-3
# 1.119 10-Sep-2008 jmcneill

PR# 38683 - T61 cannot suspend with recent kernels

Don't restore spl until after AcpiLeaveSleepState.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 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().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.117 01-Jun-2008 joerg

branches: 1.117.2; 1.117.4;
Fix compilation with ACPI_EXTRA_DEBUG.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2
# 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.


Revision tags: yamt-nfs-mp-base2
# 1.115 28-Apr-2008 martin

branches: 1.115.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 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


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.113 27-Mar-2008 jmcneill

branches: 1.113.2;
Split device_t and softc


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 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.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 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)


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base
# 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@.


Revision tags: post-newlock2-merge
# 1.99 09-Feb-2007 ad

branches: 1.99.2;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 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.


Revision tags: yamt-splraiseipl-base2
# 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.


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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@.


Revision tags: chap-midi-nbase chap-midi-base
# 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).


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 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


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.68 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 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.


Revision tags: fvdl_fs64_base
# 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).


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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).


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 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.