History log of /freebsd-current/sys/dev/acpica/acpi.c
Revision Date Author Comments
# 9dbf5b0e 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE

The public bus_release_resource() API still accepts both forms, but
the internal kobj method no longer passes the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44131


# 2baed46e 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCE

The public bus_activate/deactivate_resource() API still accepts both
forms, but the internal kobj methods no longer pass the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44130


# d77f2092 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCE

The public bus_map/unmap_resource() API still accepts both forms, but
the internal kobj methods no longer pass the argument.
Implementations which need the type now use rman_get_type() to fetch
the value from the allocated resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44129


# fef01f04 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCE

The public bus_adjust_resource() API still accepts both forms, but the
internal kobj method no longer passes the argument. Implementations
which need the type now use rman_get_type() to fetch the value from
the allocated resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44128


# 0ecee160 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Use rman_get_type in acpi_is_resource_managed

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44125


# f2fcb680 22-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Defer reserving resources for ACPI devices

The goal of reserving firmware-assigned resources is to ensure that
"wildcard" resource allocation requests will not claim an address
range that is actually in use even if no attached driver is actively
using that range. However, the current approach can break in some
cases.

In particular, ACPI can enumerate devices behind PCI bridges that
don't show up in a normal PCI scan, but those device_t objects can end
up as direct children of acpi0. Reserving resources for those devices
directly from acpi0 ends up conflicting with later attempts to reserve
the PCI bridge windows.

As a workaround, defer reserving unclaimed resources until after the
initial probe and attach scan. Eventually this pass of reserving
unclaimed resources can be moved earlier, but it requires changes to
other drivers in the tree to permit enumerating devices and reserving
firmware-assigned resources in a depth-first traversal before
attaching devices whose drivers request wildcard allocations.

PR: 272507
Reported by: Justin Tocci <justin@tocci.org>
Reported by: john@feith.com, many others
Tested by: Oleg Sidorkin <osidorkin@gmail.com>, dch


# 055c1fe2 14-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Allow child drivers to use bus_set_resource for more resources

acpi_set_resource excludes certain types of resources for certain
devices. The intention of this is to avoid adding resource entries
for bogus resources enumerated via _CRS. However, this also prevents
drivers from adding those resources explicitly if needed. To fix
this, move the logic to exclude these resources into an ignore hook
used when parsing _CRS to create the initial set of resources for each
device.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43892


# e05436d5 14-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Don't assume a resource is reserved in acpi_delete_resource

This fixes a panic if a driver uses bus_set_resource to add a resource
that fails to reserve and then deletes the resource via
bus_delete_resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43891


# 0e1246e3 09-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Cleanup handling of suballocated resources

For resources suballocated from the system resource rmans, handle
those in the ACPI bus driver without passing them up to the parent.
This means using bus_generic_rman_* for several bus methods for
operations on suballocated resources. For bus_map/unmap_resource,
find the system resource allocated from the parent bus (nexus) that
contains the range being mapped and request a mapping of that parent
resource.

This avoids a layering violation where nexus drivers were previously
asked to manage the activation and mapping of resources created
belonging to the ACPI resource managers.

Note that this does require passing RF_ACTIVE (with RF_UNMAPPED) when
allocating system resources from the parent.

While here, don't assume that the parent bus (nexus) provides a
resource list that sysres resources are placed on. Instead, create a
dedicated resource_list in the ACPI bus driver's softc to hold sysres
resources.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43687


# 1fb54452 09-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Use bus_generic_alloc_resource instead of duplicating it

No functional change, but it is cleaner to use the existing generic
wrappers rather than KOBJ methods directly.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43686


# 0e72b8d3 09-Feb-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Use kobj typedefs for new-bus method prototypes

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43685


# 9cdf326b 20-Dec-2021 Andriy Gapon <avg@FreeBSD.org>

run acpi_shutdown_final later to give other handlers a chance

For example, shutdown_panic wants to produce some output and maybe take
some input before a system is actually reset.

The change should only make difference for the case of system reset
(reboot), poweroff and halt should not be affected.

The change makes difference only if hw.acpi.handle_reboot is set. It
used to default to zero until r213755 / ac731af5670c7.


# c6a48851 09-Jan-2024 John Baldwin <jhb@FreeBSD.org>

acpi: Only reserve resources enumerated via _CRS

In particular, don't reserve resources added by drivers via other
means (e.g. acpi_bus_alloc_gas which calls bus_alloc_resource
right after adding the resource).

The intention of reserved resources is to ensure that a resource range
that a bus driver knows is assigned to a device is reserved by the
system even if no driver is attached to the device. This prevents
other "wildcard" resource requests from conflicting with these
resources. For ACPI, the only resources the bus driver knows about
for unattached devices are the resources returned from _CRS. All of
these resources are already reserved now via acpi_reserve_resources
called from acpi_probe_children.

As such, remove the logic from acpi_set_resource to try to reserve
resources when they are set. This permits RF_SHAREABLE to work with
acpi_bus_alloc_gas without requiring hacks like the current one for
CPU device resources in acpi_set_resource.

Reported by: gallatin (RF_SHAREABLE not working)
Diagnosed by: jrtc27


# f54a3890 29-Nov-2023 John Baldwin <jhb@FreeBSD.org>

x86: Support multiple PCI MCFG regions

In particular, this enables support for PCI config access for domains
(segments) other than 0.

Reported by: cperciva
Tested by: cperciva (m7i.metal-48xl AWS instance)
Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42828


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 99e6980f 28-Sep-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

device_get_property: add a HANDLE case

This will resolve a reference and return the appropriate handle, a node
on the simplebus or an ACPI_HANDLE for ACPI. For now we do not try to
further abstract the return type.

MFC after: 2 weeks
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D36793


# cc538081 07-Aug-2022 Gordon Bergling <gbe@FreeBSD.org>

acpi(4): Fix two typos in a source code comments

- s/paramater/parameter/

MFC after: 3 days


# 945eaca1 22-Jun-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

ACPI: change arguments to internal acpi_find_dsd()

acpi_find_dsd() is not a bus function and we only need the acpi_device (ad).
The only caller has already looked up the ad (from ivars) for us.
Directly pass the ad to acpi_find_dsd() instead of bus, dev and remove
the extra call to device_get_ivars(); the changed argument also means we
now call AcpiEvaluateObject directly on the handle.

This optimisation was done a while ago while debugging a driver which
ended up with a bad bus, dev combination making the old version fail.

MFC after: 2 weeks
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D35558


# 916a5d8a 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

acpi: Remove unused devclass arguments to DRIVER_MODULE.


# b344de4d 28-Jan-2022 Kornel Duleba <mindal@semihalf.com>

Extend device_get_property API

In order to support various types of data stored in device
tree properties or ACPI _DSD packages, create a new enum so
the caller can specify the expected type of a property they
want to read, according to the binding. The bus logic will use
that information to process the underlying data.

For example in DT all integer properties are stored in BE format.
In order to get constant results across different platforms we
need to convert its endianness to match the host.

Another example are ACPI_TYPE_INTEGER properties stored
as uint64_t. Before this patch the ACPI logic would refuse
to read them if the provided buffer was smaller than 8 bytes.
Now this can be handled by using DEVICE_PROP_UINT32 type.

Modify the existing consumers of this API to reflect the changes
and update the man pages accordingly.

Reviewed by: mw
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33457


# dbee7944 28-Feb-2022 Warner Losh <imp@FreeBSD.org>

acpi: Allow matching based on locators

Allow wiring of unit numbers based any of the standard locators that
match.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D32787


# 6837d9d7 28-Feb-2022 Warner Losh <imp@FreeBSD.org>

acpi hints: Abstract out acpi_hint_device_matches_resources

Abstract out acpi_hint_device_matches_resources from
acpi_hint_device_unit to simplify that code. Continue matching like
we've always matched: no functional change.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D32786


# 3278bf92 28-Feb-2022 Warner Losh <imp@FreeBSD.org>

acpi_hint_device_unit: matches is a bool, make it one

"matches" is used as a bool and doesn't need to count anything. Convert
it to a bool.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D32785


# d0a20e40 28-Feb-2022 Warner Losh <imp@FreeBSD.org>

Add UEFI locator for bus_get_device_path, pci acpi

Add a UEFI locator type. It prints the UEFI device names for a FreeBSD
device_t name. It works with PCI and ACPI device nodes. USB forthcoming.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D32749


# cae7d9ec 28-Feb-2022 Warner Losh <imp@FreeBSD.org>

bus: Add ACPI locator support

Add support for printing ACPI paths. This is a bit of a degenerate case
for this interface since it's always just the device handle if the
device has one. But it is illustrtive of how to do this for a few nodes
in the tree.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D32748


# 5c69be70 20-Jan-2022 Takanori Watanabe <takawata@FreeBSD.org>

acpi: Ignore _STA and never disable AT RTC devices

atrtc(4) should always install a SystemCMOS address space handler unless
the RTC Not Present bit is not set in IAPC_BOOT_ARCH in the FADT.
The atrtc(4) driver already checks this bit, but _STA can return not-present
even when this bit is clear.

Reviewed by : jhb
Differential Revision: https://reviews.freebsd.org/D33891


# e2650af1 29-Dec-2021 Stefan Eßer <se@FreeBSD.org>

Make CPU_SET macros compliant with other implementations

The introduction of <sched.h> improved compatibility with some 3rd
party software, but caused the configure scripts of some ports to
assume that they were run in a GLIBC compatible environment.

Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being
added to ports, but there still were compatibility issues due to
invalid assumptions made in autoconfigure scripts.

The differences between the FreeBSD version of macros like CPU_AND,
CPU_OR, etc. and the GLIBC versions was in the number of arguments:
FreeBSD used a 2-address scheme (one source argument is also used as
the destination of the operation), while GLIBC uses a 3-adderess
scheme (2 source operands and a separately passed destination).

The GLIBC scheme provides a super-set of the functionality of the
FreeBSD macros, since it does not prevent passing the same variable
as source and destination arguments. In code that wanted to preserve
both source arguments, the FreeBSD macros required a temporary copy of
one of the source arguments.

This patch set allows to unconditionally provide functions and macros
expected by 3rd party software written for GLIBC based systems, but
breaks builds of externally maintained sources that use any of the
following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR.

One contributed driver (contrib/ofed/libmlx5) has been patched to
support both the old and the new CPU_OR signatures. If this commit
is merged to -STABLE, the version test will have to be extended to
cover more ranges.

Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do
no longer require that option.

The FreeBSD version has been bumped to 1400046 to reflect this
incompatible change.

Reviewed by: kib
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D33451


# 3e68d2c5 26-Dec-2021 Alexander Motin <mav@FreeBSD.org>

acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.

MFC after: 2 weeks


# d14bc723 09-Dec-2021 Warner Losh <imp@FreeBSD.org>

newbus: add bus_topo_assert

Add bus_topo_assert() and implmement it as GIANT_REQUIRED for the
moment. This will allow us to change more easily to a newbus-specific
lock int he future.

Sponsored by: Netflix
Reviewed by: wulf, mav, jhb
Differential Revision: https://reviews.freebsd.org/D31833


# c6df6f53 09-Dec-2021 Warner Losh <imp@FreeBSD.org>

Create wrapper for Giant taken for newbus

Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D31831


# d9ed1dcc 22-Nov-2021 Bartlomiej Grzesik <bag@semihalf.com>

acpi: Fix error code returned in acpi_bus_get_prop

ACPI implementation of device_get_property would return "-1" when
property was found, but it's type wasn't supported.
This causes device_has_property to return false in that scenario, which
arguably could be considered as incorrect.

Fix that by returning "0" in that case.

Reviewed by: bz, mw
Tested by: mw
MFC after: 2 weeks
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D33103


# 3f9a00e3 30-Jul-2021 Bartlomiej Grzesik <bag@semihalf.com>

device: add device_get_property and device_has_property

Generialize bus specific property accessors. Those functions allow driver code
to access device specific information.

Currently there is only support for FDT and ACPI buses.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31597


# b91fc6c4 27-Jul-2021 Bartlomiej Grzesik <bag@semihalf.com>

acpica: add ACPI_GET_PROPERTY to access Device Specific Data (DSD)

Add lazy acquiring of DSD package, which allows accessing Device
Specific Data.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31596


# ddfc9c4c 22-Jun-2021 Warner Losh <imp@FreeBSD.org>

newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf

Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by: jhb, bcr
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29937


# 35af9331 08-Feb-2021 Warner Losh <imp@FreeBSD.org>

acpi: limit the AMDI0020/AMDI0010 workaround to an option

It appears that production versions of EPYC firmware get the _STA method right
for these nodes. In fact, this workaround breaks on production hardware by
including too many uart nodes. This work around was for pre-release hardware
that wound up not having a large deployment. Move this work around to a kernel
option since the machines that needed it have been powered off and are difficult
to resurrect. Should there be a more significant deployment than is understood,
we can restrict it based on smbios strings.

Discussed with: mmacy@, seanc@, jhb@
MFC After: 3 days


# 523a67bb 01-Dec-2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

[arm64] Parse ACPI _PXM property on ARM64 platform

Enable devices' NUMA proximity infromation parsing on ARM64 systems

Sponsored by: Ampere Computing
Submitted by: Klara, Inc.


# f1084587 05-Nov-2020 Konstantin Belousov <kib@FreeBSD.org>

Suspend all writeable local filesystems on power suspend.

This ensures that no writes are pending in memory, either metadata or
user data, but not including dirty pages not yet converted to fs writes.

Only filesystems declared local are suspended.

Note that this does not guarantee absence of the metadata errors or
leaks if resume is not done: for instance, on UFS unlinked but opened
inodes are leaked and require fsck to gc.

Reviewed by: markj
Discussed with: imp
Tested by: imp (previous version), pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27054


# fe64ff3c 31-Oct-2020 Vladimir Kondratyev <wulf@FreeBSD.org>

acpi: Tweak _DSM method evaluation helpers.

- Use ACPI style for _DSM evaluation helper parameter types.
- Constify UUID parameter.
- Increase size of returned DSM function bitmap by acpi_DSMQuery() up to 64
items. Old limit of 8 functions is not sufficient for JEDEC JESD245 NVDIMMs.
- Add new acpi_EvaluateDSMTyped() helper which performs additional return
value type check as compared with acpi_EvaluateDSM().
- Reimplement acpi_EvaluateDSM() on top of the acpi_EvaluateDSMTyped() call.

Reviewed by: scottph, manu
Differential Revision: https://reviews.freebsd.org/D26602


# 82c28121 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

acpica: clean up empty lines in .c and .h files


# 855e49f3 27-Jul-2020 Alexander Motin <mav@FreeBSD.org>

Add initial driver for ACPI Platform Error Interfaces.

APEI allows platform to report different kinds of errors to OS in several
ways. We've found that Supermicro X10/X11 motherboards report PCIe errors
appearing on hot-unplug via this interface using NMI. Without respective
driver it ended up in kernel panic without any additional information.

This driver introduces support for the APEI Generic Hardware Error Source
reporting via NMI, SCI or polling. It decodes the reported errors and
either pass them to pci(4) for processing or just logs otherwise. Errors
marked as fatal still end up in kernel panic, but some more informative.

When somebody get to native PCIe AER support implementation both of the
reporting mechanisms should get common error recovery code. Since in our
case errors happen when the device is already gone, there is nothing to
recover, so the code just clears the error statuses, practically ignoring
the otherwise destructive NMIs in nicer way.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.


# 4149c6a3 10-Jun-2020 Konstantin Belousov <kib@FreeBSD.org>

Remove double-calls to tc_get_timecount() to warm timecounters.

It seems that second call does not add any useful state change for all
implemented timecounters.

Discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks


# ddf8c230 09-Mar-2020 Vladimir Kondratyev <wulf@FreeBSD.org>

acpi: Export functions required by upcoming acpi_iicbus driver.


# 709749aa 09-Mar-2020 Vladimir Kondratyev <wulf@FreeBSD.org>

acpi: Fix stalled value returned by acpi_get_device() after device deletion

Newbus device reference attached to ACPI handle is not cleared when newbus
device is deleted with devctl(8) delete command. Fix that with calling of
AcpiDetachData() from "child_deleted" bus method like acpi_pci driver does.

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22902


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# 334790ea 17-Feb-2020 Andrew Turner <andrew@FreeBSD.org>

Use EARLY_DRIVER_MODULE in the acpi bus.

We need this to use EARLY_DRIVER_MODULE in child drivers on arm64. This
should be a no-op on x86 as it has DRIVER_MODULE in the nexus driver making
all later drivers attach in the last pass.

Reviewed by: imp
MFC after: 1 month
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D23717


# 879e0604 11-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

Add KERNEL_PANICKED macro for use in place of direct panicstr tests


# 359a5f96 17-Dec-2019 Conrad Meyer <cem@FreeBSD.org>

acpi(4): Add _CID to PNP info string

While a given ACPI device may have 0-N compatibility IDs, in practice most
seem to have 0 or 1. If one is present, emit it as part of the PNP info
string associated with a device. This could enable MODULE_PNP_INFO-based
automatic kldload for ACPI drivers associated with a given _CID (but without
a good _HID or _UID identifier).

Reviewed by: imp, jhb
Differential Revision: https://reviews.freebsd.org/D22846


# 1974d7a4 19-Aug-2019 D Scott Phillips <scottph@FreeBSD.org>

Don't set the string "unknown" as a device's location_str

Return an empty string when the location is unknown instead of the
string "unknown". This ensures that all location entries are of
the form key=val.

Suggested by: imp
Approved by: jhb (mentor)
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21326


# e2e050c8 19-May-2019 Conrad Meyer <cem@FreeBSD.org>

Extract eventfilter declarations to sys/_eventfilter.h

This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions. The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended). Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.


# 1fe39413 09-Apr-2019 John Baldwin <jhb@FreeBSD.org>

Don't pre-reserve resources for CPU devices when they are set.

CPUs can use shared (RF_SHAREABLE) resources for the I/O port used for
entering and exiting C states. If this I/O port is included in an ACPI
system resource device, then this happens to still work, but if the port
wasn't part of a system resource device, only the first CPU could allocate
the I/O port and use C states since resource_list_reserve() was always
allocating the resource from nexus0 without RF_SHAREABLE. By avoiding
the reservation, the flags from the bus_alloc_resource() in the CPU driver
(which include RF_SHAREABLE) are honored.

PR: 236513
Reported by: stockhausen@collogia.de
Sleuthing by: avg
Reviewed by: avg
MFC after: 2 weeks


# 6d29ba58 07-Dec-2018 Andriy Gapon <avg@FreeBSD.org>

acpi_MatchHid: use ACPI_MATCHHID_NOMATCH instead of FALSE

Binary representation of both is the same (zero), but
ACPI_MATCHHID_NOMATCH is better for consistency.

MFC after: 4 days
X-MFC with: r339754


# 817b71bb 05-Dec-2018 Andriy Gapon <avg@FreeBSD.org>

acpi_{Device,Battery}IsPresent: restore pre-r330957 behaviour

Specifically, assume that the device is present if evaluation of _STA
method fails.

Before r330957 we ignored any _STA evaluation failure (which was
performed by AcpiGetObjectInfo in ACPICA contrib code) for the purpose
of acpi_DeviceIsPresent and acpi_BatteryIsPresent. ACPICA 20180313
removed evaluation of _STA from AcpiGetObjectInfo. So, we added
evaluation of _STA to acpi_DeviceIsPresent and acpi_BatteryIsPresent.
One important difference is that the new code ignored a failure only if
_STA did not exist (AE_NOT_FOUND). Any other kind of failure was
treated as a fatal failure. Apparently, on some systems we can get
AE_NOT_EXIST when evaluating _STA. And that error is not an evil twin
of AE_NOT_FOUND, despite a very similar name, but a distinct error
related to a missing handler for an ACPI operation region.

It's possible that for some people the problem was already fixed by
changes in ACPICA and/or in acpi_ec driver (or even in BIOS) that fixed
the AE_NOT_EXIST failure related to EC operation region.

This work is based on a great analysis by cem and an earlier patch by
Ali Abdallah <aliovx@gmail.com>.

PR: 227191
Reported by: 0mp
MFC after: 2 weeks


# 185c34f7 18-Nov-2018 Jayachandran C. <jchandra@FreeBSD.org>

acpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c

This is a major update for pci_host_generic_acpi.c, the current
implementation has some gaps that are better fixed up in one go.
The changes are to:
* Follow x86 method of not adding PCI resources to PCI host bridge in
ACPI code. This has been moved to pci_host_generic_acpi.c, where we
walk thru its resources of the host bridge and add them.
* Fixup code in pci_host_generic_acpi.c to read all decoded ranges
and update the 'ranges' property. This allows us to share most of
the code with generic implementation (and the FDT one).
* Parse and setup IO ranges and bus ranges when walking the resources
above. Drop most of the changes related to this from acpica code.
* Add the ECAM memory area as mem resource 0. Implement the logic to
get the ECAM area from MCFG (using bus range which we now decode),
or from _CBA (using _BBN/bus range). Drop aarch64 ifdefs from acpica
code which did part of this.
* Switch resource activation to similar code as FDT implementation,
this can be moved into generic implementation in a later pass.
* Drop the mechanism of using the 7th bit of bus number as the domain,
this is not correct and will work only in very specific cases. Use
_SEG as PCI domain and use the bus ranges of the host bridge to
provide start bus number.

This commit should not make any functional change to dev/acpica/acpi.c
for other architectures, almost all the changes there are to revert
earlier additions in this file done for aarch64.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17791


# d4d6ad3f 18-Nov-2018 Jayachandran C. <jchandra@FreeBSD.org>

acpica: rework INTRNG interrupts

On arm64 (where INTRNG is enabled), the interrupts have to be mapped
with ACPI_BUS_MAP_INTR() before adding them as resources to devices.

The earlier code did the mapping before calling acpi_set_resource(),
which bypassed code that checked for PCI link interrupts.

To fix this, move the call to map interrupts into acpi_set_resource()
and that requires additional work to lookup interrupt properties.
The changes here are to:
* extend acpi_lookup_irq_handler() to lookup an irq in the ACPI
resources
* create a helper function acpi_map_intr() which uses the updated
acpi_lookup_irq_handler() to look up an irq, and then map it
with ACPI_BUS_MAP_INTR()
* use acpi_map_intr() in acpi_pcib_route_interrupt() to map
pci link interrupts.

With these changes, we can drop the ifdefs in acpi_resource.c, and
we can also drop the call for mapping interrupts in generic_timer.c

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17790


# 5efca36f 25-Oct-2018 Takanori Watanabe <takawata@FreeBSD.org>

Distinguish _CID match and _HID match and make lower priority probe
when _CID match.

Reviewed by: jhb, imp
Differential Revision:https://reviews.freebsd.org/D16468


# bf15eaf2 25-Oct-2018 Warner Losh <imp@FreeBSD.org>

Update comment for AMI00[12]0 override.

The AML is even stupider than always returning 0. It will only return
non-zero for an OS that reports itself as "Windows 2015", at least
on the Threadripper board's AML that I've examined.

Those AMLs also suggest we may need this quirk for AMI0030 as well.
There may be other cases where we need to override the _STA in a
generic way, so we should consider writing code to do that.


# 8fd10880 21-Oct-2018 Ben Widawsky <bwidawsk@FreeBSD.org>

acpi: Add an interface to obtain DSM information

The Device Specific Method (_DSM) is on optional object that defines
device specific controls. This will be useful for our power management
controller in upcoming patches. More information can be found in ACPI
spec 6.2 section 9.1.1

https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf

This patch had a minor modification changing ENOMEM to AE_NO_MEMORY
after it got review and approval but before committing.

Test Plan: Tested in my s0ix branch

Reviewed by: kib
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D17121


# 381388b9 19-Aug-2018 Matt Macy <mmacy@FreeBSD.org>

add snps IP uart support / genaralize UART

This is an amalgam of a patch by Doug Ambrisko to
generalize uart_acpi_find_device, imp moving the
ACPI table to uart_dev_ns8250.c and advice by jhb
to work around a bug in the EPYC 3151 BIOS
(the BIOS incorrectly marks the serial ports as
disabled)

Reviewed by: imp
MFC after: 8 weeks
Differential Revision: https://reviews.freebsd.org/D16432


# d1655c6f 02-Jul-2018 Edward Tomasz Napierala <trasz@FreeBSD.org>

Change the group and the permissions on /dev/acpi, to make "acpiconf"
work when called by members of the 'operator' group. They are already
allowed to eg power off the system (via suid shutdown(8)), so they
might as well be permitted to suspend it.

Tested by: xmj@
Reviewed by: delphij@
MFC after: 2 weeks
Relnotes: yes
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16062


# bcc51ef4 04-Jun-2018 Mark Johnston <markj@FreeBSD.org>

Fix the NUMA build for non-x86 platforms.

acpi_map_pxm_to_vm_domainid() is currently implemented only on x86.

MFC after: 1 week


# 0a15ff37 01-Jun-2018 Andriy Gapon <avg@FreeBSD.org>

call AcpiLeaveSleepStatePrep after re-enabling interrupts

I want to do this change because this call (actually,
AcpiHwLegacyWakePrep) does a memory allocation and ACPI namespace
evaluation. Although it is not very likely to run into any trouble, it
is still not safe to make those calls with interrupts disabled.
witness(4) and malloc(9) do not currently check for a context with
interrupts disabled via intr_disable and we lack a facility for doing
that. So, those unsafe operations fly under the radar. But if
intr_disable in acpi_EnterSleepState was replaced with spinlock_enter
(which it probably should be), then witness and malloc would immediately
complain.

Also, AcpiLeaveSleepStatePrep is documented as called when interrupts
are enabled. It used to require disabled interrupts, but that
requirement was changed a long time ago when support for _BFS and _GTS
was removed from ACPICA.

The ACPI wakeup sequence is very sensitive to changes. I consider this
change to be correct, but there can be fallouts from it.

What AcpiHwLegacyWakePrep essentially does is writing a value
corresponding to S0 into SLP_TYPx bits of PM1 Control Register(s).
According to ACPI specifications that write should be a NOP as SLP_EN
bit is not set. But I see in some chipset specifications that they
allow to ignore SLP_EN altogether and to act on a change of SLP_TYPx
alone.

Also, there are a couple of accesses to ACPI hardware before the new
location of the call to AcpiLeaveSleepStatePrep. One is to clear the
power button status and the other is to enable SCI. So, the move may
affect the interaction between then OS and ACPI platform.

I have not seen any regressions on my test system, but it's a desktop.

MFC after: 5 weeks


# 279be68b 25-May-2018 Andriy Gapon <avg@FreeBSD.org>

re-synchronize TSC-s on SMP systems after resume, if necessary

The TSC-s are checked and synchronized only if they were good
originally. That is, invariant, synchronized, etc.

This is necessary on an AMD-based system where after a wakeup from STR I
see that BSP clock differs from AP clocks by a count that roughly
corresponds to one second. The APs are in sync with each other. Not
sure if this is a hardware quirk or a firmware bug.

This is what I see after a resume with this change:
SMP: passed TSC synchronization test after adjustment
acpi_timer0: restoring timecounter, ACPI-fast -> TSC-low

Reviewed by: kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D15551


# 27dca831 21-May-2018 Andriy Gapon <avg@FreeBSD.org>

stop and restart kernel event timers in the suspend / resume cycle

I have a system that is very unstable after resuming from suspend-to-RAM
but only if HPET is used as the event timer. The theory is that SMM
code / firmware could be enabling HPET for its own uses and unexpected
interrupts cause a trouble for it. Originally I wanted to solve the
problem in hpet_suspend() method, but that was insufficient as the event
timer could get reprogrammed again.

So, it's better, for my case and in general, to stop the event timer(s)
before entering the hardware suspend.

MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D15413


# 891cf3ed 18-May-2018 Ed Maste <emaste@FreeBSD.org>

Use NULL for SYSINIT's last arg, which is a pointer type

Sponsored by: The FreeBSD Foundation


# e787342e 03-May-2018 Jung-uk Kim <jkim@FreeBSD.org>

Redo r332918 with the ACPICA API and remove debug.acpi.suspend_deep_bounce.

AcpiOsEnterSleep() was meant to implement this feature.

Reviewed by: avg


# e673a4ec 24-Apr-2018 Andriy Gapon <avg@FreeBSD.org>

add a new ACPI suspend debugging knob, debug.acpi.suspend_deep_bounce

This sysctl allows a deeper dive into the sleep abyss comparing to
debug.acpi.suspend_bounce. When the new sysctl is set the system will
execute the suspend sequence up to the call to AcpiEnterSleepState().
That includes saving processor contexts and parking APs. Then, instead
of actually entering the sleep state, the BSP will call resumectx() to
emulate the wakeup. The APs should get restarted by the sequence of
Init and Startup IPIs that BSP sends to them.

MFC after: 8 days


# 08fdb4ce 07-Mar-2018 Andrew Turner <andrew@FreeBSD.org>

Add an acpi attachment to the pci_host_generic driver and have the ACPI
bus provide it with its needed memory resources.

This allows us to use PCIe on the ThunderX2 and, with a previous version
of the patch, on the SoftIron 3000 with ACPI.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation
Sponsored by: DARPA, AFRL
Sponsored by: Cavium (Hardware)
Differential Revision: https://reviews.freebsd.org/D8767


# b6715dab 13-Jan-2018 Jeff Roberson <jeff@FreeBSD.org>

Move VM_NUMA_ALLOC and DEVICE_NUMA under the single global config option NUMA.

Sponsored by: Netflix, Dell/EMC Isilon
Discussed with: jhb


# 224c3776 11-Jan-2018 Andrew Turner <andrew@FreeBSD.org>

Add the start of INTRNG support for ACPI.

This adds a new acpi_bus interface with a map_intr method. This is similar
to the Open Firmware map_intr method and allows us to create the needed
mapping from ACPI space to INTRNG space.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D8617


# dc8ab16e 09-Jan-2018 Warner Losh <imp@FreeBSD.org>

Consolidate two identical copies of sysres_ids.


# 4571c92f 20-Dec-2017 Warner Losh <imp@FreeBSD.org>

Simplify the code a bit.

Replace clumsy for(;;) { if (foo) break; ...} with simpler
while (!foo) { ... }.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13546


# 0e68afe5 16-Dec-2016 Andrew Turner <andrew@FreeBSD.org>

Add support to read the _CLS entry if it's present. It is used by
memory-mapped devices that are normally PCIe drives. Devices can then use
the existing pci_get_class, etc. accessors to query this data.

The ivar values are different enough from the existing ACPI and ISA values
to not conflict.

Reviewed by: jhb
Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D8721


# f9a22a06 12-Dec-2016 Andrew Turner <andrew@FreeBSD.org>

On non-Intel platforms don't ignore the PCI root bridge mapping in
acpi_set_resource, the mappings are needed on arm64.

Obtained from: ABT Systenms Ltd
Sponsored by: The FreeBSD Foundation


# 0aed566c 13-Jul-2016 Jung-uk Kim <jkim@FreeBSD.org>

Remove a tunable and always reset system clock while resuming with ACPI.

Requested by: bde (long ago)


# fdce57a0 14-May-2016 John Baldwin <jhb@FreeBSD.org>

Add an EARLY_AP_STARTUP option to start APs earlier during boot.

Currently, Application Processors (non-boot CPUs) are started by
MD code at SI_SUB_CPU, but they are kept waiting in a "pen" until
SI_SUB_SMP at which point they are released to run kernel threads.
SI_SUB_SMP is one of the last SYSINIT levels, so APs don't enter
the scheduler and start running threads until fairly late in the
boot.

This change moves SI_SUB_SMP up to just before software interrupt
threads are created allowing the APs to start executing kernel
threads much sooner (before any devices are probed). This allows
several initialization routines that need to perform initialization
on all CPUs to now perform that initialization in one step rather
than having to defer the AP initialization to a second SYSINIT run
at SI_SUB_SMP. It also permits all CPUs to be available for
handling interrupts before any devices are probed.

This last feature fixes a problem on with interrupt vector exhaustion.
Specifically, in the old model all device interrupts were routed
onto the boot CPU during boot. Later after the APs were released at
SI_SUB_SMP, interrupts were redistributed across all CPUs.

However, several drivers for multiqueue hardware allocate N interrupts
per CPU in the system. In a system with many CPUs, just a few drivers
doing this could exhaust the available pool of interrupt vectors on
the boot CPU as each driver was allocating N * mp_ncpu vectors on the
boot CPU. Now, drivers will allocate interrupts on their desired CPUs
during boot meaning that only N interrupts are allocated from the boot
CPU instead of N * mp_ncpu.

Some other bits of code can also be simplified as smp_started is
now true much earlier and will now always be true for these bits of
code. This removes the need to treat the single-CPU boot environment
as a special case.

As a transition aid, the new behavior is available under a new kernel
option (EARLY_AP_STARTUP). This will allow the option to be turned off
if need be during initial testing. I plan to enable this on x86 by
default in a followup commit in the next few days and to have all
platforms moved over before 11.0. Once the transition is complete,
the option will be removed along with the !EARLY_AP_STARTUP code.

These changes have only been tested on x86. Other platform maintainers
are encouraged to port their architectures over as well. The main
things to check for are any uses of smp_started in MD code that can be
simplified and SI_SUB_SMP SYSINITs in MD code that can be removed in
the EARLY_AP_STARTUP case (e.g. the interrupt shuffling).

PR: kern/199321
Reviewed by: markj, gnn, kib
Sponsored by: Netflix


# 8d791e5a 09-May-2016 John Baldwin <jhb@FreeBSD.org>

Add a new bus method to fetch device-specific CPU sets.

bus_get_cpus() returns a specified set of CPUs for a device. It accepts
an enum for the second parameter that indicates the type of cpuset to
request. Currently two valus are supported:

- LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to
the device when DEVICE_NUMA is enabled)
- INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core)

For systems that do not support NUMA (or if it is not enabled in the kernel
config), LOCAL_CPUS fails with EINVAL. INTR_CPUS is mapped to 'all_cpus'
by default. The idea is that INTR_CPUS should always return a valid set.

Device drivers which want to use per-CPU interrupts should start using
INTR_CPUS instead of simply assigning interrupts to all available CPUs.
In the future we may wish to add tunables to control the policy of
INTR_CPUS (e.g. should it be local-only or global, should it ignore
SMT threads or not).

The x86 nexus driver exposes the internal set of interrupt CPUs from the
the x86 interrupt code via INTR_CPUS.

The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable
LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled. They also and
the global INTR_CPUS set from the nexus driver with the per-domain set from
_PXM to generate a local INTR_CPUS set for child devices.

Compared to the r298933, this version uses 'struct _cpuset' in
<sys/bus.h> instead of 'cpuset_t' to avoid requiring <sys/param.h>
(<sys/_cpuset.h> still requires <sys/param.h> for MAXCPU even though
<sys/_bitset.h> does not after recent changes).


# 453130d9 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: minor spelling fixes.

Most affect comments, very few have user-visible effects.


# 8a08b7d3 02-May-2016 John Baldwin <jhb@FreeBSD.org>

Revert bus_get_cpus() for now.

I really thought I had run this through the tinderbox before committing,
but many places need <sys/types.h> -> <sys/param.h> for <sys/bus.h> now.


# bc153c69 02-May-2016 John Baldwin <jhb@FreeBSD.org>

Add a new bus method to fetch device-specific CPU sets.

bus_get_cpus() returns a specified set of CPUs for a device. It accepts
an enum for the second parameter that indicates the type of cpuset to
request. Currently two valus are supported:

- LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to
the device when DEVICE_NUMA is enabled)
- INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core)

For systems that do not support NUMA (or if it is not enabled in the kernel
config), LOCAL_CPUS fails with EINVAL. INTR_CPUS is mapped to 'all_cpus'
by default. The idea is that INTR_CPUS should always return a valid set.

Device drivers which want to use per-CPU interrupts should start using
INTR_CPUS instead of simply assigning interrupts to all available CPUs.
In the future we may wish to add tunables to control the policy of
INTR_CPUS (e.g. should it be local-only or global, should it ignore
SMT threads or not).

The x86 nexus driver exposes the internal set of interrupt CPUs from the
the x86 interrupt code via INTR_CPUS.

The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable
LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled. They also and
the global INTR_CPUS set from the nexus driver with the per-domain set from
_PXM to generate a local INTR_CPUS set for child devices.

Reviewed by: wblock (manpage)
Differential Revision: https://reviews.freebsd.org/D5519


# 4c26ac69 22-Apr-2016 John Baldwin <jhb@FreeBSD.org>

Optionally return the output capabilities list from _OSC.

Both of the callers were expecting the input cap_set to be modified.
This fixes them to request cap_set to be updated with the returned buffer.

Reviewed by: jkim
Differential Revision: https://reviews.freebsd.org/D6040


# e5f77010 20-Apr-2016 Jung-uk Kim <jkim@FreeBSD.org>

Prefer sizeof(*pointer) over sizeof(type). No funtional change.


# cad6d222 20-Apr-2016 Jung-uk Kim <jkim@FreeBSD.org>

Remove query flag from acpi_EvaluateOSC(). This function does not support
return buffer (yet).


# 5f3dd91a 20-Apr-2016 John Baldwin <jhb@FreeBSD.org>

Add a wrapper for evaluating _OSC methods.

This wrapper does not translate errors in the first word to ACPI
error status returns. Use this wrapper in the acpi_cpu(4) driver in
place of the existing _OSC code. While here, fix a bug where the wrong
count of words was passed when invoking _OSC.

Reviewed by: jkim
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6022


# 62d70a81 09-Apr-2016 John Baldwin <jhb@FreeBSD.org>

Add more fine-grained kernel options for NUMA support.

VM_NUMA_ALLOC is used to enable use of domain-aware memory allocation in
the virtual memory system. DEVICE_NUMA is used to enable affinity
reporting for devices such as bus_get_domain().

MAXMEMDOM must still be set to a value greater than for any NUMA support
to be effective. Note that 'cpuset -gd' always works if MAXMEMDOM is
enabled and the system supports NUMA.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D5782


# da1b038a 17-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.

On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544


# e8cf8358 03-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Remove default initializations for rman, a'la r296331


# 7915adb5 19-Feb-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.

This simplifies checking for default resource range for bus_alloc_resource(),
and improves readability.

This is part of, and related to, the migration of rman_res_t from u_long to
uintmax_t.

Discussed with: jhb
Suggested by: marcel


# ad73b301 18-Feb-2016 Adrian Chadd <adrian@FreeBSD.org>

document some ACPI related sysctls.

Submitted by: Oliver Pinter <oliver.pinter@hardenedbsd.org>
Sponsored by: HardenedBSD
Differential Revision: https://reviews.freebsd.org/D5263


# 2dd1bdf1 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Convert rman to use rman_res_t instead of u_long

Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources. For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075


# 2eb0015a 01-Oct-2015 Colin Percival <cperciva@FreeBSD.org>

Disable suspend when we're shutting down. This solves the "tell FreeBSD
to shut down; close laptop lid" scenario which otherwise tended to end
with a laptop overheating or the battery dying.

The implementation uses a new sysctl, kern.suspend_blocked; init(8) sets
this while rc.suspend runs, and the ACPI sleep code ignores requests while
the sysctl is set.

Discussed on: freebsd-acpi (35 emails)
MFC after: 1 week


# 0594dade 22-Jul-2015 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPICA 20150717.


# fd90e2ed 22-May-2015 Jung-uk Kim <jkim@FreeBSD.org>

CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head. However, it is continuously misused as the mpsafe argument
for callout_init(9). Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision: https://reviews.freebsd.org/D2613
Reviewed by: jhb
MFC after: 2 weeks


# fe5d5d7d 06-May-2015 Andrew Turner <andrew@FreeBSD.org>

AcpiGbl_FACS will not be defined when building using the reduced hardware
model. This may be the case on ARM.


# d8c37c3a 28-Apr-2015 Andrew Turner <andrew@FreeBSD.org>

There may not be an FACS table, check for this before accessing it.

Sponsored by: The FreeBSD Foundation


# 5d18c60a 19-Apr-2015 Adrian Chadd <adrian@FreeBSD.org>

Refactor out the _PXM -> VM domain lookup done in ACPI, in preparation for
its use in upcoming code.

This is inspired by something in jhb's NUMA IRQ allocation patchset.

However, the tricky bit here is that the PXM lookup for a node may
fail, requiring a lookup on the parent node. So if it doesn't
exist, don't fail - just go up to the parent. Only error out of the
lookup is the ACPI lookup returns an error.

Sponsored by: Norse Corp, Inc.


# 44947d3a 06-Apr-2015 John Baldwin <jhb@FreeBSD.org>

Move the message complaining about failed system resource allocations
under bootverbose. Every example I've seen to date has been due to
an ACPI system resource device reserving a range that overlaps with
system memory (which ram0 attempts to reserve) or a local or I/O APIC
(which apic0 attempts to reserve). These are always harmless but look
scary to users.

MFC after: 1 week


# 15ae88ba 06-Mar-2015 John Baldwin <jhb@FreeBSD.org>

Fix a typo.


# 64de8019 06-Feb-2015 John Baldwin <jhb@FreeBSD.org>

Add a new device control utility for new-bus devices called devctl. This
allows the user to request administrative changes to individual devices
such as attach or detaching drivers or disabling and re-enabling devices.
- Add a new /dev/devctl2 character device which uses ioctls for device
requests. The ioctls use a common 'struct devreq' which is somewhat
similar to 'struct ifreq'.
- The ioctls identify the device to operate on via a string. This
string can either by the device's name, or it can be a bus-specific
address. (For unattached devices, a bus address is the only way to
locate a device.) Bus drivers register an eventhandler to claim
unrecognized device names that the driver recognizes as a valid address.
Two buses currently support addresses: ACPI recognizes any device
in the ACPI namespace via its full path starting with "\" and
the PCI bus driver recognizes an address specification of
'pci[<domain>:]<bus>:<slot>:<func>' (identical to the PCI selector
strings supported by pciconf).
- To make it easier to cut and paste, change the PnP location string
in the PCI bus driver to output a full PCI selector string rather
than 'slot=<slot> function=<func>'.
- Add a devctl(3) interface in libdevctl which provides a wrapper around
the ioctls and is the preferred interface for other userland code.
- Add a devctl(8) program which is a simple wrapper around the requests
supported by devctl(3).
- Add a device_is_suspended() function to check DF_SUSPENDED.
- Add a resource_unset_value() function that can be used to remove a
hint from the kernel environment. This is used to clear a
hint.<driver>.<unit>.disabled hint when re-enabling a boot-time
disabled device.

Reviewed by: imp (parts)
Requested by: imp (changing PCI location string)
Relnotes: yes


# 85f95fff 27-Jan-2015 Andriy Gapon <avg@FreeBSD.org>

hook userland threads suspend + resume into acpi suspend code

Also, split power_suspend into power_suspend and power_suspend_early.

power_suspend_early is called before the userland is frozen.
power_suspend is called after the userland is frozen.

Currently only VT switching is hooked to power_suspend_early.
This is needed because switching away from X server requires its
cooperation, so obviously X server must not be frozen when that happens.

Freezing userland during ACPI suspend is useful because not all drivers
correctly handle suspension concurrent with other activity. This is
especially applicable to drivers ported from other operating systems
that suspend all software activity between placing drivers and hardware
into suspended state.
In particular drm2/radeon (radeonkms) depends on the described
procedure. The driver does not have any internal synchronization
between suspension activities and processing of userland requests.

Many thanks to kib for the code that allows to freeze and thaw all
userland threads.

Note that ideally we also need to park / inhibit (non-special) kernel
threads as well to ensure that they do not call into drivers.

MFC after: 17 days


# 44aba0f6 11-Nov-2014 Jung-uk Kim <jkim@FreeBSD.org>

Use the correct device. Note this commit complements r274386.

PR: 194884


# 2da2ade0 11-Nov-2014 Adrian Chadd <adrian@FreeBSD.org>

Use the correct device (child) when asking the bus layer about which power
state said device should go into.

This was a snafu introduced in the ACPI/PCI awareness separation.

When putting a device into a power state, the bus (and thus firmware,
eg ACPI) should be asked before hand to check whether the device
can indeed go into that power state.

There's a set of nodes in ACPI under each device - the _SxD nodes - which
state which ACPI power state to put the device into when the system is
going into power save state 'x'. So when going into S3, the existence
of an _S3D node would override whatever the system was trying to do.

By default the PCI code wants to put devices into D3 before suspending.

I have a laptop here (Asus Zenbook - check the PR) whose EHCI controller
really wants to be in D2 during suspend, not D3. So if we put it into
D3 and then try to enter S3, everything hangs. The device itself
can go into D3 - it just can't be there when the call to ACPI to enter
S3 occurs. The PCI patch fixes this.

jkim@ noticed that the same is needed for the ACPI child device
enumeration.

Thankyou to Matt Dillon (the programmer, not the actor) for buying me
this particular laptop so I could debug the issues with the Atheros
AR9485 that is in it. It's his fault that I ended up with this
laptop and was sufficiently annoyed by the lack of USB suspend
to go down this rabbit hole.

Tested:

* Thinkpad T400
* Thinkpad X230
* Thinkpad T42
* Thinkpad T60
* Asus Zenbook (see PR)
* Asus EEEPC 701
* Asus EEEPC 1001PX

TODO:

* Figure out what we should do about devices we unload drivers for
that want to be in a specific state when entering S3 / S4 -
the "put devices into D3 if they're not bound to a driver" option
may also mess with things.

PR: kern/194884
Reviewed by: jhb, jkim
MFC after: 1 week
Relnotes: yes
Sponsored by: Matt Dillon <dillon@apollo.backplane.com> (hardware)


# 0e1152fc 27-Oct-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

The SYSCTL data pointers can come from userspace and must not be
directly accessed. Although this will work on some platforms, it can
throw an exception if the pointer is invalid and then panic the kernel.

Add a missing SYSCTL_IN() of "SCTP_BASE_STATS" structure.

MFC after: 3 days
Sponsored by: Mellanox Technologies


# 2be111bf 16-Oct-2014 Davide Italiano <davide@FreeBSD.org>

Follow up to r225617. In order to maximize the re-usability of kernel code
in userland rename in-kernel getenv()/setenv() to kern_setenv()/kern_getenv().
This fixes a namespace collision with libc symbols.

Submitted by: kmacy
Tested by: make universe


# ffcf962d 08-Oct-2014 Adrian Chadd <adrian@FreeBSD.org>

Add a bus method to fetch the VM domain for the given device/bus.

* Add a bus_if.m method - get_domain() - returning the VM domain or
ENOENT if the device isn't in a VM domain;
* Add bus methods to print out the domain of the device if appropriate;
* Add code in srat.c to save the PXM -> VM domain mapping that's done and
expose a function to translate VM domain -> PXM;
* Add ACPI and ACPI PCI methods to check if the bus has a _PXM attribute
and if so map it to the VM domain;
* (.. yes, this works recursively.)
* Have the pci bus glue print out the device VM domain if present.

Note: this is just the plumbing to start enumerating information -
it doesn't at all modify behaviour.

Differential Revision: D906
Reviewed by: jhb
Sponsored by: Norse Corp


# fadf3fb9 22-Sep-2014 John Baldwin <jhb@FreeBSD.org>

Convert from timeout(9) to callout(9).


# 9cf5a6aa 19-Sep-2014 Adrian Chadd <adrian@FreeBSD.org>

Populate the device info string with _PXM (proximity domain) information.

This is primarily useful for debugging right now - it'll show up in
devinfo.

Reviewed by: jhb


# 1f895058 17-Sep-2014 John Baldwin <jhb@FreeBSD.org>

Revert unrelated changes accidentally committed in r271192.


# b1d735ba 06-Sep-2014 John Baldwin <jhb@FreeBSD.org>

Create a separate structure for per-CPU state saved across suspend and
resume that is a superset of a pcb. Move the FPU state out of the pcb and
into this new structure. As part of this, move the FPU resume code on
amd64 into a C function. This allows resumectx() to still operate only on
a pcb and more closely mirrors the i386 code.

Reviewed by: kib (earlier version)


# d2dc06ca 25-Jun-2014 John Baldwin <jhb@FreeBSD.org>

Expand r261243 even further and ignore any I/O port resources assigned to
PCI root bridges except for the one known-valid case on x86 where bridges
claim the I/O port registers used for PCI config space access.

Tested by: Hilko Meyer <hilko.meyer@gmx.de>
MFC after: 1 week


# 8a27a339 30-Mar-2014 Warner Losh <imp@FreeBSD.org>

Remove instances of variables that were set, but never used. gcc 4.9
warns about these by default.


# 7e3343bf 28-Jan-2014 John Baldwin <jhb@FreeBSD.org>

Some BIOSes incorrectly use standard memory resource ranges to list
the memory ranges that they decode for downstream devices rather than
creating ResourceProducer range resource entries. The result is that
we allocate the full range to the PCI root bridge device causing
allocations in child devices to all fail.

As a workaround, ignore any standard memory resources on a PCI root
bridge device. It is normal for a PCI root bridge to allocate an I/O
resource for the I/O ports used for PCI config access, but I have not
seen any PCI root bridges that legitimately allocate a memory resource.

Reviewed by: jkim
MFC after: 1 week


# feeec74d 29-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

More BUS_PROBE_NOWILDCARD sweeping. Some devices here (if_ath_ahb and siba)
resist easy conversion since they implement a great deal of their attach
logic inside probe(). Some of this could be fixed by moving it to attach(),
but some requires something more subtle than BUS_PROBE_NOWILDCARD.


# 60d306f0 22-Apr-2013 John Baldwin <jhb@FreeBSD.org>

- Some BIOSes use an Extended IRQ resource descriptor in _PRS for a link
that uses non-ISA IRQs but use a plain IRQ resource in _CRS. However,
a non-ISA IRQ can't fit into a plain IRQ resource. If we encounter a
link like this, build the resource buffer from _PRS instead of _CRS.
- Set the correct size of the end tag in a resource buffer.

Tested by: Benjamin Lee <ben@b1c1l1.com>
MFC after: 2 weeks


# ebbed20d 01-Feb-2013 Andriy Gapon <avg@FreeBSD.org>

revert accidentally committed unneeded changes from r246250

MFC after: 7 days
X-MFC with: r246250


# b913a7d5 01-Feb-2013 Andriy Gapon <avg@FreeBSD.org>

acpi: clear power button status bit after waking up...

so that it is not confused for a new power off request.

Learned from: Linux and ACPI specification
Tested by: gjb
MFC after: 12 days


# b1a5c017 01-Feb-2013 Andriy Gapon <avg@FreeBSD.org>

acpi: after wakeup from a state > S1 re-enable SCI_EN with a direct write

This hack is picked up from Linux, which claims that it follows
Windows behavior.

PR: amd64/174409
Tested by: Sergey V. Dyatko <sergey.dyatko@gmail.com>,
KAHO Toshikazu <kaho@elam.kais.kyoto-u.ac.jp>,
Slawa Olhovchenkov <slw@zxy.spb.ru>
MFC after: 13 days


# 61bfd867 30-Jan-2013 Sofian Brabez <sbz@FreeBSD.org>

Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays

Reviewed by: cognet
Approved by: cognet


# a8de37b0 22-Oct-2012 Eitan Adler <eadler@FreeBSD.org>

This isn't functionally identical. In some cases a hint to disable
unit 0 would in fact disable all units.

This reverts r241856

Approved by: cperciva (implicit)


# 76b75122 21-Oct-2012 Eitan Adler <eadler@FreeBSD.org>

Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

Reviewed by: des
Approved by: cperciva
MFC after: 1 week


# 4d46ef51 01-Jun-2012 Jung-uk Kim <jkim@FreeBSD.org>

Execute AcpiLeaveSleepStatePrep() for S1 and reduce code duplication.

MFC after: 3 days


# f0a101b7 01-Jun-2012 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Call AcpiLeaveSleepStatePrep() in interrupt disabled context
(described in ACPICA source code).

- Move intr_disable() and intr_restore() from acpi_wakeup.c to acpi.c
and call AcpiLeaveSleepStatePrep() in interrupt disabled context.
- Add acpi_wakeup_machdep() to execute wakeup MD procedures and call
it twice in interrupt disabled/enabled context (ia64 version is
just dummy).
- Rename wakeup_cpus variable in acpi_sleep_machdep() to suspcpus in
order to be shared by acpi_sleep_machdep() and acpi_wakeup_machdep().
- Move identity mapping related code to acpi_install_wakeup_handler()
(i386 version) for preparation of x86/acpica/acpi_wakeup.c
(MFC candidate).

Reviewed by: jkim@
MFC after: 2 days


# e3b56b66 28-May-2012 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Reorder resume procedures.

DEVICE_RESUME() should be done before AcpiLeaveSleepState() because
PCI config space evaluation can be occurred during control method
executions.

This should fix one of the hang up problems on resuming.

MFC after: 3 days


# ffe3f1f8 28-May-2012 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Fix the problem acpi_sleep_force() hang.

Suspending from callout cause the freeze in DEVICE_SUSPEND().
Suspend from acpi_task thread in stead.

MFC after: 3 days


# e4cd9dcf 23-May-2012 John Baldwin <jhb@FreeBSD.org>

Rework the previous change to honor MADT processor IDs when probing
processor objects. Instead of forcing the new-bus CPU objects to use
a unit number equal to pc_cpuid, adjust acpi_pcpu_get_id() to honor the
MADT IDs by default. As with the previous change, setting
debug.acpi.cpu_unordered to 1 in the loader will revert to the old
behavior.

Tested by: jimharris
MFC after: 1 month


# b12bc99f 21-May-2012 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Ignore the power button press event for resuming rather than starting
shutdown.

MFC after: 2 days


# f22377a8 20-May-2012 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Don't start the sleep state transition procedure while sleep is
disabled or the system is in shutdown procedure.

This should fix the problem which kernel never response to the sleep
button press events after the message `suspend request ignored (not
ready yet)'.

MFC after: 3 days


# 92fa7e24 04-May-2012 Jung-uk Kim <jkim@FreeBSD.org>

Complete commit message for r235024:

Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may
list CPUs in different orders, especially for disabled logical cores. Now
we match ACPI IDs from the MADT with Processor objects, strictly order CPUs
accordingly, and ignore disabled cores. This prevents us from executing
methods for other CPUs, e. g., _PSS for disabled logical core, which may not
exist. Unfortunately, it is known that there are a few systems with buggy
BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To
work around these problems, 'debug.acpi.cpu_unordered' tunable is added.
Set this to a non-zero value to restore the old behavior.
Many thanks to jhb for pointing me to the right direction and the manual
page change.

Reported by: Harris, James R (james dot r dot harris at intel dot com)
Tested by: Harris, James R (james dot r dot harris at intel dot com)
Reviewed by: jhb
MFC after: 1 month


# e5751426 04-May-2012 Jung-uk Kim <jkim@FreeBSD.org>

Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may
list CPUs in different orders, especially for disabled logical cores. Now
we match ACPI IDs from the MADT with Processor objects, strictly order CPUs
accordingly, and ignore disabled cores. This prevents us from executing
methods for other CPUs, e. g., _PSS for disabled logical core, which may not
exist. Unfortunately, it is known that there are a few systems with buggy
BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To
work around these problems


# 71804adc 27-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Restore interrupt state after executing AcpiEnterSleepState().


# cc6455af 22-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Add ACPI_LV_REPAIR debug level, available since ACPICA 20091214 (r200553).

MFC after: 3 days


# a0a15716 08-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Reset clock after atrtc(4) is properly resumed.


# 404b0d10 07-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

- Give all clocks and timers on acpi0 the equal probing order.
- Increase probing order for ECDT table to match HID-based probing.
- Decrease probing order for HPET table to match HID-based probing.
- Decrease probing order for CPUs and system resources.
- Fix ACPI_DEV_BASE_ORDER to reflect the reality.


# d745c852 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


# 5d0d779b 12-Oct-2011 John Baldwin <jhb@FreeBSD.org>

If an allocation for a specific resource range fails because it is not in
a decoded range for an ACPI Host-PCI bridge, try to allocate it from the
ACPI system resource range. If that works, permit the resource allocation
regardless.

MFC after: 1 week


# 31f301d0 13-Sep-2011 Christian Brueffer <brueffer@FreeBSD.org>

Improve the sleep_delay sysctl description by specifying which unit
the number is in.

PR: 159975
Submitted by: gcooper
Approved by: re (kib)
MFC after: 1 week


# f6133e71 24-Jun-2011 John Baldwin <jhb@FreeBSD.org>

Typo.


# 183c8af3 17-Jun-2011 John Baldwin <jhb@FreeBSD.org>

Don't create a device_t object or parse current resources (via _CRS) for
ACPI Device() objects that do not have any device IDs available via the
_HID or _CID methods. Without a device ID a device driver cannot attach
to the device anyway. Namespace objects that are devices but not of
type ACPI_TYPE_DEVICE are not affected.

A few BIOSes have also attached a _CRS method to a PCI device to
allocate resources that are not managed via a BAR. With the previous
code those resources are allocated from acpi0 directly which can interfere
with the new PCI-PCI bridge driver (since the PCI device in question may
be behind a bridge and its resources should be allocated from that
bridge's windows instead). The resources were also orphaned and
and would end up associated with some other random device whose device_t
reused the pointer of the original ACPI-enumerated device (after it was
free'd by the ACPI PCI bus driver) in devinfo output which was confusing.
If we want to handle _CRS on PCI devices we can adjust the ACPI PCI bus
driver to do that in the future and associate the resources with the
proper device object respecting PCI-PCI bridges, etc.

Note that with this change the ACPI PCI bus driver no longer has to
delete ACPI-enumerated device_t devices that mirror PCI devices since
they should in general not exist. There are rare cases when a BIOS
will give a PCI device a _HID (e.g. I've seen a PCI-ISA bridge given
a _HID for a system resource device). In that case we leave both the
ACPI and PCI-enumerated device_t objects around just as in the previous
code.


# 049dc0d1 09-Jun-2011 John Baldwin <jhb@FreeBSD.org>

Implement BUS_ADJUST_RESOURCE() for the x86 drivers that sit between the
Host-PCI bridge drivers and nexus.


# 4a8fa6fe 14-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Add event handlers for (ACPI) suspend/resume events. Suspend event handlers
are invoked right before device drivers go into sleep state and resume event
handlers are invoked right after all device drivers are waken up.


# 059e2464 04-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Move a trivial acpi_TimerDelta() to acpivar.h to make it inlineable.


# 8defd647 04-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Fix bogus logic to calculate delta between two values from ACPI timers.


# b5854f5f 11-Jan-2011 Jung-uk Kim <jkim@FreeBSD.org>

Work around a witness(4) panic introduced in r217238.

Reported by: jh


# 0d81cf12 23-Dec-2010 John Baldwin <jhb@FreeBSD.org>

Don't try to reserve a resource that is already allocated. If the ECDT
table is present, then the acpi_ec(4) driver will allocate its resources
from nexus0 before the acpi0 device reserves resources for child devices.

Reviewed by: jkim


# ea233199 22-Dec-2010 John Baldwin <jhb@FreeBSD.org>

Use resource_list_reserve() to reserve I/O port and memory resources for
ACPI devices even if they are not allocated by a device driver since the
resources are in use and should not be allocated to another device.


# 5e66b8e2 16-Dec-2010 John Baldwin <jhb@FreeBSD.org>

Spelling fix.


# affa1826 08-Nov-2010 Jung-uk Kim <jkim@FreeBSD.org>

Consistently use padding `_' in the comment.


# 495a4144 03-Nov-2010 Jung-uk Kim <jkim@FreeBSD.org>

Adjust a comment to clarify why \_SB_ and \_TZ_ are defined as device type
in ACPICA. Reshuffle the code a bit to make sure this kludge only applies
to these two specical cases and to make it cleaner.


# ae19af49 26-Oct-2010 Jung-uk Kim <jkim@FreeBSD.org>

Add two new loader tunables 'hw.acpi.install_interface' and
'hw.acpi.remove_interface'. hw.acpi.install_interface lets you install new
interfaces. Conversely, hw.acpi.remove_interface lets you remove OS
interfaces from the pre-defined list in ACPICA. For example,

hw.acpi.install_interface="FreeBSD"

lets _OSI("FreeBSD") method to return 0xffffffff (or success) and

hw.acpi.remove_interface="Windows 2009"

lets _OSI("Windows 2009") method to return zero (or failure). Both are
comma-separated lists and leading white spaces are ignored. For example,
the following examples are valid:

hw.acpi.install_interface="Linux, FreeBSD"
hw.acpi.remove_interface="Windows 2006, Windows 2006.1"


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 22066615 19-Oct-2010 Jung-uk Kim <jkim@FreeBSD.org>

Remove undocumented and stale debug.acpi.do_powerstate tunable. It was
added with hw.pci.do_powerstate but the PCI version was splitted into two
separate tunables later and now this is completely stale. To make it worse,
PCI devices enumerated in ACPI tree ignore this tunable as it is handled by
a function in acpi_pci.c instead.


# a7a3177f 19-Oct-2010 Jung-uk Kim <jkim@FreeBSD.org>

Remove PCI_SET_POWERSTATE method from acpi.c and eradicate all PCI-specific
knowledges from the file. All PCI devices enumerated in ACPI tree must use
correct one from acpi_pci.c any way. Reduce duplicate codes as we did for
pci.c in r213905. Do not return ESRCH from PCIB_POWER_FOR_SLEEP method.
When the method is not found, just return zero without modifying the given
default value as it is completely optional. As a side effect, the return
state must not be NULL. Note there is actually no functional change by
removing ESRCH because acpi_pcib_power_for_sleep() always returns zero.
Adjust debugging messages and add new ones under bootverbose to help
debugging device power state related issues.

Reviewed by: jhb, imp (earlier versions)


# ac731af5 12-Oct-2010 Jung-uk Kim <jkim@FreeBSD.org>

Use AcpiReset() from ACPICA instead of rolling our own, which is actually
incomplete. If FADT says the register is available, enable the capability
by default. Remove the previous default value from acpi(4).


# 9c2d0529 22-Sep-2010 Andriy Gapon <avg@FreeBSD.org>

acpi_attach: do not explicitly install default handlers for default
address spaces

There has been no need to do that starting with ACPICA 20040427 as
AcpiEnableSubsystem() installs the handlers automatically.
Additionaly, explicitly calling AcpiInstallAddressSpaceHandler before
AcpiEnableSubsystem is not supported by ACPICA and leads to too early
execution of _REG methods in some DSDTs, which may result in problems.

Big thanks to Robert Moore of ACPICA/Intel for explaining the above.

Reported by: Daniel Bilik <daniel.bilik@neosystem.cz>
Tested by: Daniel Bilik <daniel.bilik@neosystem.cz>
Reviewed by: jkim
Suggested by: "Moore, Robert" <robert.moore@intel.com>
MFC after: 1 week


# 3d844edd 10-Sep-2010 Andriy Gapon <avg@FreeBSD.org>

bus_add_child: change type of order parameter to u_int

This reflects actual type used to store and compare child device orders.
Change is mostly done via a Coccinelle (soon to be devel/coccinelle)
semantic patch.
Verified by LINT+modules kernel builds.

Followup to: r212213
MFC after: 10 days


# b1f9b996 03-Sep-2010 Andriy Gapon <avg@FreeBSD.org>

acpi: update stale comments about order of cpu devices probing

These comments should have been updated in r203776 when the order was
changed.

Pointyhat to: avg
MFC after: 3 days


# 62508c53 17-Aug-2010 John Baldwin <jhb@FreeBSD.org>

Add a new method to the PCI bridge interface, PCIB_POWER_FOR_SLEEP(). This
method is used by the PCI bus driver to query the power management system
to determine the proper device state to be used for a device during suspend
and resume. For the ACPI PCI bridge drivers this calls
acpi_device_pwr_for_sleep(). This removes ACPI-specific knowledge from
the PCI and PCI-PCI bridge drivers.

Reviewed by: jkim


# 337744d9 15-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

If there is any pending sleep request, disallow entering S5 state.
Otherwise, bad things may happen. ;-)


# 36a483bb 13-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Make SMP code path conditional at run-time.


# 36646862 06-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Fix mis-merges in the previous commit.


# 5753d036 10-Jun-2010 John Baldwin <jhb@FreeBSD.org>

MFC 208925:
The lock associated with the /dev/apm knote is already held, so use
KNOTE_LOCKED() instead of KNOTE_UNLOCKED().

Approved by: re (kib)


# 374d9c4d 08-Jun-2010 John Baldwin <jhb@FreeBSD.org>

The lock associated with the /dev/apm knote is already held, so use
KNOTE_LOCKED() instead of KNOTE_UNLOCKED().

Reported by: mav
MFC after: 3 days


# 3c4c08dc 23-May-2010 Alexander Motin <mav@FreeBSD.org>

Make table-based HPET identification more clever. Before creating fake
device, make sure we have no real HPET device entry with same ID.
As side effect, it potentially allows several HPETs to be attached.
Use first of them for timecounting, rest (if ever present) could later
be used as event sources.


# 44dd6ac2 26-Apr-2010 Jung-uk Kim <jkim@FreeBSD.org>

MFC: r204773
Merge ACPICA 20100304.

MFC: r204874
Update module Makefile for ACPICA 20100304.

MFC: r204877
Allow ACPI module build on amd64. Although we strongly recommend building
it into kernel, there is no need to prevent it from building at all.

MFC: r204916
- Allow users to enable dumping Debug objects without ACPI debugger.
Setting the new sysctl MIB "debug.acpi.enable_debug_objects" to a non-zero
value enables us to print Debug object when something is written to it.
- Allow users to disable interpreter slack mode. Setting the new tunable
"debug.acpi.interpreter_slack" to zero disables some workarounds for common
BIOS mistakes and enables strict ACPI implementations by the specification.

MFC: r204920
Since the interpreter slack mode is a tunable now, enable a local hack only
when it is set. Note the default behaviour does not change by this change.

MFC: r204965
Fix white spaces.

MFC: r206117
Merge ACPICA 20100331 (and four additional upstream patches).


# e850e471 11-Mar-2010 Andriy Gapon <avg@FreeBSD.org>

MFC r203785: acpi: drop the second bus_generic_attach pass

X-MFCto7 after: 1 week


# 57ff35ce 11-Mar-2010 Andriy Gapon <avg@FreeBSD.org>

MFC r203776: acpi cpu: probe+attach before all other enumerated children

X-MFCto7 after: 1 week


# 2a18c71d 09-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

- Allow users to enable dumping Debug objects without ACPI debugger.
Setting the new sysctl MIB "debug.acpi.enable_debug_objects" to a non-zero
value enables us to print Debug object when something is written to it.
- Allow users to disable interpreter slack mode. Setting the new tunable
"debug.acpi.interpreter_slack" to zero disables some workarounds for common
BIOS mistakes and enables strict ACPI implementations by the specification.


# 0430ba9e 11-Feb-2010 Andriy Gapon <avg@FreeBSD.org>

acpi: drop the second bus_generic_attach pass

It is belived that that pass s not needed anymore.
Specifically it is not required now for the reasons that were given
in the removed comment.

Discussed with: jhb
MFC after: 4 weeks


# aa835160 11-Feb-2010 Andriy Gapon <avg@FreeBSD.org>

acpi cpu: probe+attach before all other enumerated children on acpi bus

Some current systems dynamically load SSDT(s) when _PDC/_OSC method
of Processor is evaluated. Other devices in ACPI namespace may access
objects defined in the dynamic SSDT. Drivers for such devices might
have to have a rather high priority, because of other dependencies.
Good example is acpi_ec driver for EC.
Thus we attach to Processors as early as possible to load the SSDTs
before any other drivers may try to evaluate control methods.
It also seems to be a natural order for a processor in a device
hierarchy.

On the other hand, some child devices on acpi cpu bus need to access
other system resources like PCI configuration space of chipset devices,
so they need to be probed and attached rather late.
For this reason we probe and attach the cpu bus at
SI_SUB_CONFIGURE:SI_ORDER_MIDDLE SYSINIT level.
In the future this could be done more elegantly via multipass.

Please note that acpi drivers that might access ACPI namespace from
device_identify will do that before _PDC/_OSC of Processors are evaluated.

Legacy cpu driver is not affected by this change.

PR: kern/142561 (in part)
Reviewed by: jhb
Silence from: acpi@
MFC after: 5 weeks


# e21bbd17 05-Feb-2010 Andriy Gapon <avg@FreeBSD.org>

MFC r197104,197105,197106,197107,197688,198237,199337,199338,200553,200554,
202771,202773: bring acpica version to 20100121

MFC details:
r197104 | jkim | 2009-09-12 01:48:53 +0300 (Sat, 12 Sep 2009) | 4 lines
MFV: r196804
Import ACPICA 20090903

r197105 | jkim | 2009-09-12 01:49:34 +0300 (Sat, 12 Sep 2009) | 2 lines
Catch up with ACPICA 20090903.

r197106 | jkim | 2009-09-12 01:50:15 +0300 (Sat, 12 Sep 2009) | 2 lines
Catch up with ACPICA 20090903.

r197107 | jkim | 2009-09-12 01:56:08 +0300 (Sat, 12 Sep 2009) | 2 lines
Canonify include paths for newly added files.

r197688 | jkim | 2009-10-01 23:56:15 +0300 (Thu, 01 Oct 2009) | 4 lines
Compile ACPI debugger and disassembler for kernel modules
unconditionally.
These files will generate almost empty object files without
ACPI_DEBUG/DDB
options. As a result, size of acpi.ko will increase slightly.

r198237 | jkim | 2009-10-19 19:12:58 +0300 (Mon, 19 Oct 2009) | 2 lines
Merge ACPICA 20091013.

r199337 | jkim | 2009-11-16 23:47:12 +0200 (Mon, 16 Nov 2009) | 2 lines
Merge ACPICA 20091112.

r199338 | jkim | 2009-11-16 23:53:56 +0200 (Mon, 16 Nov 2009) | 2 lines
Add a forgotten module Makefile change from the previous commit.

r200553 | jkim | 2009-12-15 00:24:04 +0200 (Tue, 15 Dec 2009) | 2 lines
Merge ACPICA 20091214.

r200554 | jkim | 2009-12-15 00:28:32 +0200 (Tue, 15 Dec 2009) | 3 lines
Remove _FDE quirk handling as these quirks are automatically repaired
by ACPICA layer since ACPICA 20091214.

r202771 | jkim | 2010-01-21 23:14:28 +0200 (Thu, 21 Jan 2010) | 2 lines
Merge ACPICA 20100121.

r202773 | jkim | 2010-01-21 23:31:39 +0200 (Thu, 21 Jan 2010) | 2 lines
Fix a new header inclusion.

Discussed with: jkim, jhb
No objections from: acpi@


# f6eb382c 07-Nov-2009 Andriy Gapon <avg@FreeBSD.org>

acpi: remove 'magic' ivar

o acpi_hpet: auto-added 'wildcard' devices can be identified by
non-NULL handle attribute.
o acpi_ec: auto-add 'wildcard' devices can be identified by
unset (NULL) private attribute.
o acpi_cpu: use private instead of magic to store cpu id.

Reviewed by: jhb
Silence from: acpi@
MFC after: 2 weeks
X-MFC-Note: perhaps the ivar should stay for ABI stability


# ff5bfa3e 29-Oct-2009 John Baldwin <jhb@FreeBSD.org>

MFC 197439:
Extract the code to find and map the MADT ACPI table during early kernel
startup and genericize it so it can be reused to map other tables as well:
- Add a routine to walk a list of ACPI subtables such as those used in the
APIC and SRAT tables in the MI acpi(4) driver.
- Move the routines for mapping and unmapping an ACPI table as well as
mapping the RSDT or XSDT and searching for a table with a given signature
out into acpica_machdep.c for both amd64 and i386.


# 71f99e63 27-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Copy apm(4) emulation from sys/i386/acpica/acpi_machdep.c and
install apm(8) and apm_bios.h on amd64.


# d95e7f5a 23-Sep-2009 John Baldwin <jhb@FreeBSD.org>

Extract the code to find and map the MADT ACPI table during early kernel
startup and genericize it so it can be reused to map other tables as well:
- Add a routine to walk a list of ACPI subtables such as those used in the
APIC and SRAT tables in the MI acpi(4) driver.
- Move the routines for mapping and unmapping an ACPI table as well as
mapping the RSDT or XSDT and searching for a table with a given signature
out into acpica_machdep.c for both amd64 and i386.


# 92488a57 11-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPICA 20090903.


# 953e1b6c 27-Aug-2009 John Baldwin <jhb@FreeBSD.org>

MFC 196520:
Tweak the way that the ACPI and ISA bus drivers match hint devices to
BIOS-enumerated devices:
- Assume a device is a match if the memory and I/O ports match even if the
IRQ or DRQ is wrong or missing. Some BIOSes don't include an IRQ for
the atrtc device for example.
- Add a hack to better match floppy controller devices. Many BIOSes do not
include the starting port of the floppy controller listed in the hints
(0x3f0) in the resources for the device. So far, however, all the BIOS
variations encountered do include the 'port + 2' resource (0x3f2), so
adjust the matching for "fdc" devices to look for 'port + 2'.

Approved by: re (kib)


# 2fcd493c 24-Aug-2009 John Baldwin <jhb@FreeBSD.org>

Tweak the way that the ACPI and ISA bus drivers match hint devices to
BIOS-enumerated devices:
- Assume a device is a match if the memory and I/O ports match even if the
IRQ or DRQ is wrong or missing. Some BIOSes don't include an IRQ for
the atrtc device for example.
- Add a hack to better match floppy controller devices. Many BIOSes do not
include the starting port of the floppy controller listed in the hints
(0x3f0) in the resources for the device. So far, however, all the BIOS
variations encountered do include the 'port + 2' resource (0x3f2), so
adjust the matching for "fdc" devices to look for 'port + 2'.

Reviewed by: imp
MFC after: 3 days


# 247db074 20-Aug-2009 John Baldwin <jhb@FreeBSD.org>

MFC 196403: Temporarily revert the new-bus locking for 8.0 release.

Approved by: re (kib)


# a56fe095 20-Aug-2009 John Baldwin <jhb@FreeBSD.org>

Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by: re (kib), attilio


# 444b9186 02-Aug-2009 Attilio Rao <attilio@FreeBSD.org>

Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)


# 129d3046 05-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Import ACPICA 20090521.


# aaac7452 02-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Chase ACPICA API changes (for kernel and boot loader).


# 00b4e54a 20-May-2009 Warner Losh <imp@FreeBSD.org>

We no longer need to use d_thread_t, migrate to struct thread *.


# 54b43614 30-Apr-2009 Jung-uk Kim <jkim@FreeBSD.org>

Fix off-by-one bug. S5 state must be checked as well.


# 19682c48 30-Apr-2009 Jung-uk Kim <jkim@FreeBSD.org>

Fix style(9).


# 2d0c82e8 30-Apr-2009 Jung-uk Kim <jkim@FreeBSD.org>

Prefer device_printf() over printf() where ever possible.


# a0e73a12 30-Apr-2009 Jung-uk Kim <jkim@FreeBSD.org>

General sleep state change clean up.

- Probe supported sleep states from acpi_attach() just once and do not
call AcpiGetSleepTypeData() again. It is redundant because
AcpiEnterSleepStatePrep() does it any way.
- Treat UNKNOWN sleep state as NONE, i.e., "do nothing", and remove obscure
NONE state (ACPI_S_STATES_MAX + 1) to avoid confusions.
- Do not set unsupported sleep states as default button/switch events.
If the default sleep state is not supported, just set it as UNKNOWN/NONE.
- Do not allow sleep state change if the system is not fully up and running.
This should prevent entering S5 state multiple times, which causes strange
behaviours later.
- Make sleep states case-insensitive when they are used with sysctl(8).
For example,

sysctl hw.acpi.lid_switch_state=s1
sysctl hw.acpi.sleep_button_state=none

are now legal and equivalent to the uppercase ones.


# 33c70d41 28-Apr-2009 Andriy Gapon <avg@FreeBSD.org>

acpi: do not run resume/backout code when entering S0/S5 states

This change adds (possibly redundant) early check for invalid
state input parameter (including S0). Handling of S5 request
is reduced to simply calling shutdown_nice(). As a result
control flow of acpi_EnterSleepState is somewhat simplified
and resume/backout half of the function is not executed
for S5 (soft poweroff) request and invalid state requests.

Note: it seems that shutdown_nice may act as nop when initproc
is already initialized (to grab pid of 1), but init process is in
"pre-natal" state.

Tested by: Fabian Keil <fk@fabiankeil.de>
Reviewed by: njl, jkim
Approved by: rpaulo


# 0755473b 23-Mar-2009 Jung-uk Kim <jkim@FreeBSD.org>

Add a function to reset system time after resuming, which will be used
by amd64 shortly. It can be turned off by setting "debug.acpi.reset_clock"
tunable to zero.


# d42f0ad8 23-Mar-2009 Jung-uk Kim <jkim@FreeBSD.org>

Check whether devd is running before calling resume notifier and
reshuffle code to reduce unnecessary locking coverage.


# c66d2b38 16-Mar-2009 Jung-uk Kim <jkim@FreeBSD.org>

Initial suspend/resume support for amd64.

This code is heavily inspired by Takanori Watanabe's experimental SMP patch
for i386 and large portion was shamelessly cut and pasted from Peter Wemm's
AP boot code.


# 0d484d24 18-Nov-2008 John Baldwin <jhb@FreeBSD.org>

Allow device hints to wire the unit numbers of devices.
- An "at" hint now reserves a device name.
- A new BUS_HINT_DEVICE_UNIT method is added to the bus interface. When
determining the unit number of a device, this method is invoked to
let the bus driver specify the unit of a device given a specific
devclass. This is the only way a device can be given a name reserved
via an "at" hint.
- Implement BUS_HINT_DEVICE_UNIT() for the acpi(4) and isa(4) bus drivers.
Both of these busses implement this by comparing the resources for a
given hint device with the resources enumerated by ACPI/PnPBIOS and
wire a unit if the hint resources are a subset of the "real" resources.
- Use bus_hinted_children() for adding hinted devices on isa(4) busses
now instead of doing it by hand.
- Remove the unit kludging from sio(4) as it is no longer necessary.

Prodding from: peter, imp
OK'd by: marcel
MFC after: 1 month


# 96cf0b6d 02-Nov-2008 Warner Losh <imp@FreeBSD.org>

Make the no driver stuff an ifdef.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 099ea4b5 23-Aug-2008 Warner Losh <imp@FreeBSD.org>

Handle errors from device_get_children.


# d320e05c 21-Aug-2008 John Baldwin <jhb@FreeBSD.org>

Extend the support for PCI-e memory mapped configuration space access:
- Rename pciereg_cfgopen() to pcie_cfgregopen() and expose it to the
rest of the kernel. It now also accepts parameters via function
arguments rather than global variables.
- Add a notion of minimum and maximum bus numbers and reject requests for
an out of range bus.
- Add more range checks on slot/func/reg/bytes parameters to the cfg reg
read/write routines. Don't panic on any invalid parameters, just fail
the request (writes do nothing, reads return -1). This matches the
behavior of the other cfg mechanisms.
- Port the memory mapped configuration space access to amd64. On amd64
we simply use the direct map (via pmap_mapdev()) for the memory mapped
window.
- During acpi_attach() just after loading the ACPI tables, check for a
MCFG table. If it exists, call pciereg_cfgopen() on each subtable
(memory mapped window). For now we only support windows for domain 0
that start with bus 0. This removes the need for more chipset-specific
quirks in the MD code.
- Remove the chipset-specific quirks for the Intel 5000P/V/Z chipsets
since these machines should all have MCFG tables via ACPI.
- Updated pci_cfgregopen() to DTRT if ACPI had invoked pcie_cfgregopen()
earlier.

MFC after: 2 weeks


# 8c0879b6 04-Aug-2008 John Baldwin <jhb@FreeBSD.org>

Fix a typo.


# b6618687 23-Jul-2008 John Baldwin <jhb@FreeBSD.org>

Further refine the probe order of devices to more closely match the previous
behavior. Specifically, probe Host-PCI bridges in the order they are
encountered in the tree. For CPUs, just use an order of 100000 and assume
that no Host-PCI bridges will be more than 10000 levels deep in the
namespace. This fixes an issue on some boxes where the HPET timer stopped
attaching.


# d227204d 07-Apr-2008 John Baldwin <jhb@FreeBSD.org>

Revert back to probing Host-PCI bridges in the order we encounter them in
the tree rather than sorting them by their address on PCI bus 0.

Reported by: kan


# 5217af30 13-Mar-2008 John Baldwin <jhb@FreeBSD.org>

Rework how the nexus(4) device works on x86 to better handle the idea of
different "platforms" on x86 machines. The existing code already handles
having two platforms: ACPI and legacy. However, the existing approach was
rather hardcoded and difficult to extend. These changes take the approach
that each x86 hardware platform should provide its own nexus(4) driver (it
can inherit most of its behavior from the default legacy nexus(4) driver)
which is responsible for probing for the platform and performing
appropriate platform-specific setup during attach (such as adding a
platform-specific bus device). This does mean changing the x86 platform
busses to no longer use an identify routine for probing, but to move that
logic into their matching nexus(4) driver instead.
- Make the default nexus(4) driver in nexus.c on i386 and amd64 handle the
legacy platform. It's probe routine now returns BUS_PROBE_GENERIC so it
can be overriden.
- Expose a nexus_init_resources() routine which initializes the various
resource managers so that subclassed nexus(4) drivers can invoke it from
their attach routine.
- The legacy nexus(4) driver explicitly adds a legacy0 device in its
attach routine.
- The ACPI driver no longer contains an new-bus identify method. Instead
it exposes a public function (acpi_identify()) which is a probe routine
that the MD nexus(4) drivers can use to probe for ACPI. All of the
probe logic in acpi_probe() is now moved into acpi_identify() and
acpi_probe() is just a stub.
- On i386 and amd64, an ACPI-specific nexus(4) driver checks for ACPI via
acpi_identify() and claims the nexus0 device if the probe succeeds. It
then explicitly adds an acpi0 device in its attach routine.
- The legacy(4) driver no longer knows anything about the acpi0 device.
- On ia64 if acpi_identify() fails you basically end up with no devices.
This matches the previous behavior where the old acpi_identify() would
fail to add an acpi0 device again leaving you with no devices.

Discussed with: imp
Silence on: arch@


# 463e0f91 10-Mar-2008 John Baldwin <jhb@FreeBSD.org>

Probe CPUs after the PCI hierarchy on i386, amd64, and ia64. This allows
the cpufreq drivers to reliably use properties of PCI devices for quirks,
etc.
- For the legacy drivers, add CPU devices via an identify routine in the
CPU driver itself rather than in the legacy driver's attach routine.
- Add CPU devices after Host-PCI bridges in the acpi bus driver.
- Change the ichss(4) driver to use pci_find_bsf() to locate the ICH and
check its device ID rather than having a bogus PCI attachment that only
checked for the ID in probe and always failed. As a side effect, you
can now kldload ichss after boot.
- Fix the ichss(4) driver to use the correct device_t for the ICH (and not
for ichss0) when doing PCI config space operations to enable SpeedStep.

MFC after: 2 weeks
Reviewed by: njl, Andriy Gapon avg of icyb.net.ua


# 7572a9c7 27-Jan-2008 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Return errno value rather than boolean in this context.

MFC after: 1 week


# 0c26519e 27-Jan-2008 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Enter the sleep state immediately without waiting for timeout if
devd(8) is not running such as the system in single user mode.

MFC after: 1 week


# f74e3c98 09-Oct-2007 Nate Lawson <njl@FreeBSD.org>

Fix the HPET table probe routine to run from device_identify() instead
of directly from acpi0. Before it would attach prior to the sysresource
devices, causing the later allocation of its memory range to fail and
print a warning like "acpi0: reservation of fed00000, 1000 (3) failed".
Use an explicit define for our probe order base value of 10.

Help from: jhb
Tested by: Abdullah Ibn Hamad Al-Marri <almarrie / gmail.com>
MFC after: 3 days
Approved by: re


# b6648efd 12-Sep-2007 Nate Lawson <njl@FreeBSD.org>

Reject requests to start or ack a suspend sequence on platforms that do not
support suspend/resume, currently all except i386.

Tested by: jkim
Approved by: re


# 813d6dca 30-Jun-2007 Nate Lawson <njl@FreeBSD.org>

My previous commit introduced a spurious warning for the case where a
switch (i.e. lid) is set to have an action of NONE. This is not an
invalid state, so silently return. This fixes the warning:
"acpi: request to enter state S6 failed (err 22)"

Approved by: re


# 00a30448 21-Jun-2007 Nate Lawson <njl@FreeBSD.org>

Update the suspend/resume user API while maintaining backwards compat.

Improvements:
* /etc/rc.suspend,rc.resume are always run, no matter the source of the
suspend request (user or kernel, apm or acpi)
* suspend now requires positive user acknowledgement. If a user program
wants to cancel the suspend, they can. If one of the user programs
hangs or doesn't respond within 10 seconds, the system suspends anyway.
* /dev/apm is clonable, allowing multiple listeners for suspend events.
In the future, xorg-server can use this to be informed about suspend
even if there are other listeners (i.e. apmd).

Changes:
* Two new ACPI ioctls: REQSLPSTATE and ACKSLPSTATE. Request begins the
process of suspending by notifying all listeners. acpi is monitored by
devd(8) and /dev/apm listener(s) are also counted. Users register their
approval or disapproval via Ack. If anyone disapproves, suspend is vetoed.
* Old user programs or kernel modules that used SETSLPSTATE continue to
work. A message is printed once that this interface is deprecated.
* acpiconf gains the -k flag to ack the suspend request. This flag is
undocumented on purpose since it's only used by /etc/rc.suspend. It is
not intended to be a permanent change and will be removed once a better
power API is implemented.
* S5 (power off) is no longer supported via acpiconf -s 5 or apm -z/-Z.
This restores previous behavior of halt/shutdown -p being the interface.
* Miscellaneous improvements to error reporting

Approved by: re


# 70fa7bc0 15-Jun-2007 Nate Lawson <njl@FreeBSD.org>

Convert magic to a uintptr_t. This should get rid of some warnings on
gcc4.


# 93bfd059 24-May-2007 Nate Lawson <njl@FreeBSD.org>

Add a sysctl, 'debug.acpi.suspend_bounce', that causes the system to bounce
back in a simulated resume instead of entering the requested suspend state.
This helps in testing drivers separately from the acpi suspend code. To
test your drivers, set debug.acpi.suspend_bounce=1 and then run
acpiconf -s3 (or 4).

MFC after: 1 day


# fffe371d 15-May-2007 Takanori Watanabe <takawata@FreeBSD.org>

Add ACPI HPET table support.

Reviewed by:njl


# 4b1ff978 08-May-2007 Mark Santcroos <marks@FreeBSD.org>

Set the debug.acpi.acpi_ca_version sysctl even if ACPI support is not
available.


# 147c0ad0 25-Apr-2007 John Baldwin <jhb@FreeBSD.org>

Use a tighter check to see if a resource allocation request is for a
specific request and thus should first try to be allocated from the
sys_resource pool. This avoids using the sys_resource pool for wildcard
requests that have bounded ranges coming from cbb(4) and Host-PCI pcib(4)
drivers.

Tested by: Andrea Bittau <a.bittau of cs.ucl.ac.uk fame>
Sleuthing by: Andrea Bittau as well


# 2be4e471 22-Mar-2007 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPI-CA 20070320 import.


# 397c30a8 21-Mar-2007 John Baldwin <jhb@FreeBSD.org>

Change acpi's handling of suballocating system resources to be a little
simpler. It now can just use rman_is_region_manager() during
acpi_release_resource() to see if the the resource is suballocated from
a system resource. Also, the driver no longer needs MD knowledge about
how to setup bus space tags and handles when doing a suballocation, but
can simply rely on bus_activate_resource() in the parent setting all that
up.


# ce533e82 20-Mar-2007 John Baldwin <jhb@FreeBSD.org>

Tweak the probe/attach order of devices on the x86 nexus devices.
Various BIOS-related psuedo-devices are added at an order of 5. acpi0 is
added at an order of 10, and legacy0 is added at an order of 11.


# c7c42f0a 21-Feb-2007 Nate Lawson <njl@FreeBSD.org>

Improve readability of the version string.


# 907b6777 07-Jan-2007 Nate Lawson <njl@FreeBSD.org>

Re-work Cx handling to be per-cpu and asymmetrical, fixing support on
modern dual-core systems as well.

- Parse the _CST packages for each cpu and track all the states individually,
on a per-cpu basis.

- Revert to generic FADT/P_BLK based Cx control if the _CST package
is not present on all cpus. In that case, the new driver will
still support per-cpu Cx state handling. The driver will determine the
highest Cx level that can be supported by all the cpus and configure the
available Cx state based on that.

- Fixed the case where multiple cpus in the system share the same
registers for Cx state handling. To do that, added a new flag
parameter to the acpi_PkgGas and acpi_bus_alloc_gas functions that
enable the caller to add the RF_SHAREABLE flag. This flag could also be
useful to other callers (acpi_throttle?) in the tree but this change is
not yet made.

- For Core Duo cpus, both cores seems to be taken out of C3 state when
any one of the cores need to transition out. This broke the short sleep
detection logic. It is disabled now if there is more than one cpu in
the system for now as it fixed it in my case. This quirk may need to
be re-enabled later differently.

- Added support to control cx_lowest on a per-cpu basis. There is still
a generic cx_lowest to enable changing cx_lowest for all cpus with a single
sysctl and for ease of use. Sample output for the new sysctl:

dev.cpu.0.cx_supported: C1/1 C2/1 C3/57
dev.cpu.0.cx_lowest: C3
dev.cpu.0.cx_usage: 0.00% 43.16% 56.83%
dev.cpu.1.cx_supported: C1/1 C2/1 C3/57
dev.cpu.1.cx_lowest: C3
dev.cpu.1.cx_usage: 0.00% 45.65% 54.34%
hw.acpi.cpu.cx_lowest: C3

This work was done by Stephane E. Potvin with some simple reworking by
myself. Thank you.

Submitted by: Stephane E. Potvin <sepotvin / videotron.ca>
MFC after: 2 weeks


# e7a975ad 21-Sep-2006 John Baldwin <jhb@FreeBSD.org>

Fix a sign bug in acpi_release_resource(). acpi_sysres_find() returns !=
NULL if the specified resource is a sub-alloc of a system resource.


# 0bba6acf 11-Sep-2006 John Baldwin <jhb@FreeBSD.org>

Give the ACPI I/O rman's unique description strings to make 'devinfo -u'
output less confusing.

MFC after: 3 days


# d1b16e18 29-Jul-2006 Nate Lawson <njl@FreeBSD.org>

Add a new sysctl, hw.acpi.handle_reboot. If set, acpi will attempt to
perform the reboot action via the reset register instead of our legacy
method. Default is 0 (use legacy). This is needed because some systems
hang on reboot even though they claim to support the reset register.

MFC after: 2 days


# d85e6785 11-Jun-2006 Nate Lawson <njl@FreeBSD.org>

By default, don't disable ACPI during reboot. This appears to hang some
systems. Introduce a new sysctl "hw.acpi.disable_on_reboot" that allows
users to re-enable the old behavior in case it's needed for some systems.
We never disable in the power-off path.

Original approach submitted by Alexander Logvinov <abuse@akavia.ru> with
reworking by Jung-uk Kim and myself.


# 197b4dcc 10-Jun-2006 Nate Lawson <njl@FreeBSD.org>

Minor sysctl cleanup. The RW flag means read|write and so it is redundant
to add the RD flag. Also, the debug node does not need to be writable.


# c40da00c 16-May-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.


# da72d149 06-May-2006 Nate Lawson <njl@FreeBSD.org>

Don't attach special devices in the order they appear in the AML tree.
If the embedded controller exists before the sysresource devices, for
example, it will be attached first. Instead, let the normal device
order function work as we first desired. [1]

There still remained a problem where we couldn't allocate resources in
acpi0 that were passed up by the sysresource pseudo-devices. These
devices had to probe/attach first to give their resources to acpi, then
acpi would allocate them before probing/attaching other devices. To
work around this, we attach them from acpi_sysres_alloc(). A better
approach would be to implement multi-pass probe/attach in newbus but
that's a much bigger task.

Suggested by: jhb [1]
Hardware from: Centaur Technologies
MFC after: 1 week


# c3f861f4 19-Apr-2006 Warner Losh <imp@FreeBSD.org>

Set the rid for the resoruce obtained from rman_reserve_resource.


# 858a52f4 14-Apr-2006 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Import ACPI Dock Station support. Note that this is still very young.
Additional detach implementaions (or maybe improvement) for other
deivce drivers is required.

Reviewed by: njl, imp
MFC after: 1 week


# 87a500cd 28-Mar-2006 Nate Lawson <njl@FreeBSD.org>

Add reset register support. This is the only method to reboot some new
systems (blade servers). On most systems, this is implemented as an IO
write to the SMI port and the BIOS generates the actual reset.

PR: kern/94939
Submitted by: dodell@ixsystems.com
Reviewed by: jhb
MFC after: 3 weeks


# 3a6497c1 07-Nov-2005 John Baldwin <jhb@FreeBSD.org>

*sigh* Revert stuff that wasn't supposed to be committed. The
acpi_resource change was a minor nit offered as an early candidate for
the recent ACPICA import problem and the acpi.c change is one I need to
test still that makes the ordered probing of system devices actually work
as advertised (probe devices in order based on the type of device rather
than in the order we encounter them in the device tree).


# f25bdd3b 07-Nov-2005 John Baldwin <jhb@FreeBSD.org>

Work around at least one busted BIOS. If we get a source index in a _PRT
entry that is not zero, assume that it is really a hard-wired IRQ (commonly
used for APIC routing) and not a source index. In practice, we've only
ever seen source indices of 0 for legitimate non-hard-wired _PRT entries.

Reviewed by: njl
Tested by: Alex Lyashkov shadow at psoft dot net
MFC after: 2 weeks


# e8d472a7 01-Nov-2005 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPI-CA 20051021 import


# 893f750a 22-Oct-2005 Nate Lawson <njl@FreeBSD.org>

Add a hack to get around PCI link devices that report "present" but not
"functional" (i.e., if they are disabled). We should probe them anyway
since we may enable them later.

Tested by: thompsa
MFC after: 3 days


# 2a191126 11-Sep-2005 David E. O'Brien <obrien@FreeBSD.org>

Canonize the include of acpi.h.


# f09aa88c 03-Jun-2005 Warner Losh <imp@FreeBSD.org>

In newbus land, ivars can only be accessed for direct child, or when
the driver has unholy private knowledge of its great-*cgrandchildren.
The ACPI allocation routine lacked such knowledge when it tried to do
a default allocation for all descendants, rather than just its
immeidate children, so would access grandchild's ivar in an unsafe
way. This could lead to a panic when devices were present which had
no addresses setup by the BIOS, but which were later allocated in a
lazy manner via pci_alloc_map. As such, only do the default
allocation adjustments for immediate children. The manner that
acpi_sysres_find accesses the resource list, used later in
acpi_alloc_resource, is safe and proper so no additional test is
needed there.

This fixes a panic when probing an disabled ata controller on some
newer intel blades.

Reported by: dwhite


# 1c9ec538 19-May-2005 Nate Lawson <njl@FreeBSD.org>

If devclass_get_devices() returns success but a count of 0, free the
pointer. If kernel malloc(0) returns a valid pointer, it needs to be
freed. If it returns NULL, it's ok to free this also.

Submitted by: pjd
Reviewed by: imp, dfr
Obtained from: Coverity Prevent


# 8518ed9e 09-May-2005 Mark Santcroos <marks@FreeBSD.org>

Simplify the ACPI taskqueue implementation. Use a thread queue type instead
of swi. This allows us to use the taskqueue_thread_* functions instead of
rolling our own. It also avoids a double trip through the queue.

Submitted by: njl
Reviewed by: sam


# b460c6f8 14-Apr-2005 John Baldwin <jhb@FreeBSD.org>

Probe PCI link devices early so that we turn them all off via _DIS before
we start turning any of them back on again. This works around a bug in
some BIOSen that alias two different link devices for APIC vs ATPIC modes
onto the same physical hardware link.

Submitted by: njl
Tested by: Antoine Brodin antoine dot brodin at laposte dot net


# 965a34fb 31-Mar-2005 Nate Lawson <njl@FreeBSD.org>

Always free the returned env pointer even it doesn't indicate we're in
verbose mode.

Found by: Coverity Prevent (via sam)


# ca2c69c8 27-Mar-2005 Nate Lawson <njl@FreeBSD.org>

Clean up resources properly if acpi_perf fails to attach. First, change
acpi_bus_alloc_gas() to delete the resource it set if alloc fails. Then,
change acpi_perf to delete the resource after releasing it if alloc fails.
This should make probe and attach both fully restartable if either fails.


# 43ce1c77 26-Mar-2005 Nate Lawson <njl@FreeBSD.org>

If a device_add_child fails (i.e. low memory situation), be sure to free
the unused ivars also.

Submitted by: pjd
Obtained from: Coverity Prevent analysis


# 8b28b622 22-Mar-2005 Nate Lawson <njl@FreeBSD.org>

Add support for bus_delete_resource() and make acpi_bus_alloc_gas() do
this before setting a new resource.


# be1bf4d2 18-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

s/SLIST/STAILQ/
/imp/a\
pointy hat
.


# dad97fee 02-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Fix SCM ID's.


# ac8671f1 25-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Remove unused variable.

Noticed by: Coverity tool


# f45fc848 25-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Instead of assuming units of bytes, it seems more likely that this is
a bitfield.


# 2fe912df 22-Feb-2005 Nate Lawson <njl@FreeBSD.org>

If a register width is less than 8, assume the BIOS author thought it was
in units of bytes and adjust accordingly. This is found at least on the
Sony PCG-505BX.


# 8f118e25 17-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Check for the address space type first before validating it. In particular,
we want to return EOPNOTSUPP for FFixedHW no matter what the address.

Submitted by: Bruno Ducrot


# 39da3eb3 13-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Allow users to manually override quirks with the tunable "debug.acpi.quirks".
Suggested by: Jung-uk Kim


# e1c4bf3f 05-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Convert the acpi_bus_alloc_gas() and acpi_PkgGas() APIs to output the memory
type. This is needed if the resource is to be released later. The RID is
still also present, though less necessary since rman_get_rid() can be used
to obtain it from the resource.


# 33332dc2 08-Jan-2005 Nate Lawson <njl@FreeBSD.org>

In total violation of at least 4 sections in the ACPI spec, some systems
place device objects in \ (in this case, PCI links.) Work around this by
starting our probe from \. To avoid attaching system scope objects,
explicitly skip them. (I think it's an ACPI-CA bug that \_SB and \_TZ have
device and thermal object types.) Thanks to pjd@ for testing.

MFC after: 2 weeks


# d05fa56b 26-Dec-2004 Nate Lawson <njl@FreeBSD.org>

Remove trailing whitespace.


# 5d3d03f1 04-Dec-2004 Nate Lawson <njl@FreeBSD.org>

Grab Giant around calls to DEVICE_SUSPEND/RESUME in acpi_SetSleepState().
If we are resuming non-MPSAFE drivers, they need Giant held for them.
This may fix some obscure suspend/resume problems. It has fixed keyrate
setting problems that were triggered by cardbus (MPSAFE) changing the
ordering for syscons resume (non-MPSAFE). Also, add some asserts that
Giant is held in our suspend/resume and shutdown methods.

Found by: iedowse
MFC after: 2 days


# 834a79de 03-Dec-2004 Nate Lawson <njl@FreeBSD.org>

Enable the relaxed behavior for op regions and other workarounds for
non-standard BIOSen. We used to implement this in local patches but
now that ACPI-CA has merged/re-implemented most of our fixes, they were
no longer needed and we just needed to turn this knob on. Also, remove
an unnecessary cast.

Tested by: phk


# 10ce62b9 02-Dec-2004 Nate Lawson <njl@FreeBSD.org>

Turn ACPI and PCI devices off or to a lower power state in suspend and
back on again in resume. Override the default of D3 with the value the
BIOS specifies in _SxD, if present. Skip serial devices (PNP05xx) since
they seem to hang when set to D3 and may require special driver support.
Also, skip non-type 0 PCI devices (i.e., bridges) since our we don't yet
save/restore their config space and that seems to be necessary.

If this gives you trouble with suspend/resume, you can disable the new
ACPI and PCI power behavior separately with these tunables & sysctls:
debug.acpi.do_powerstate
hw.pci.do_powerstate

Approved by: imp (pci)
Tested by: acpi@ (numerous)


# 2c8d3b23 13-Oct-2004 Nate Lawson <njl@FreeBSD.org>

Print before the footer, not after.


# a91c5fa8 13-Oct-2004 Nate Lawson <njl@FreeBSD.org>

If flags are present, print them like ISA does.

MFC after: 1 day


# 9e0dd54f 12-Oct-2004 Nate Lawson <njl@FreeBSD.org>

Attach the device description for ISA devices on the ACPI bus.

MFC after: 1 day


# ba36768b 21-Sep-2004 Nate Lawson <njl@FreeBSD.org>

Don't disable acpi in shutdown if we're panicing (panicstr != NULL). This
may help with double panics.


# adad4744 23-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Rework sysresource management. Instead of having each sysresource object
hold its own values, pass them up to the parent (acpi0) and merge/uniq them
on the way. After the namespace evaluation, acpi will reserve these
resources and manage them via rman before bus_generic_probe() and
bus_generic_attach(). This is necessary because some systems specify
conflicting resources in separate sysresource objects. It's also cleaner
in that the interface between sysresource and acpi is now merely the parent's
resource list. This code handles the following cases:

1. Unique resource: add it to the parent via bus_set_resource().
2. New wholly contained in old: discard new.
3. New tail overlaps old head: grow old head downward.
AND/OR
4. New head overlaps old tail: grow old tail upward.

Tested by: Pawel Worach <sajd_at_telia.com>
Tested by: Radek Kozlowski <radek_at_raadradd.com>
MFC after: 5 days


# 071339e2 18-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Call AcpiLeaveSleepState() before DEVICE_RESUME(). The former calls the
BFS and WAK methods, which are needed to initialize some devices before
the driver can resume them. This was the original order.

MFC after: 2 days


# e079f949 17-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Remove the ACPIIO_ENABLE and ACPIIO_DISABLE ioctls as well as all
callers. These ioctls attempted to enable and disable the ACPI
interpreter at runtime. In practice, it is not possible to boot with
ACPI and then disable it on many systems and trying to do so can cause
crashes, interrupt storms, etc. Binary compatibility with userland is
retained.

MFC after: 2 days


# 15e2f34f 13-Aug-2004 Nate Lawson <njl@FreeBSD.org>

MPSAFE locking

* Serialize calls to acpi_alloc_resource(), acpi_release_resource(),
acpi_Enable(), acpi_Disable(), and acpi_debug_sysctl().
* Acquire the ACPI mutex in acpi_register_ioctl(), acpi_deregister_ioctl(),
and acpiioctl().
* Acquire the mutex while disabling subsequent requests to enter a
sleep state in acpi_SetSleepState().
* Be sure to re-enable sleep requests and don't run resume methods when
the current request fails.
* Don't check if sleep requests are disabled in the ACPIIO_SETSLPSTATE
ioctl. acpi_SetSleepState() does this for us.
* Remove the acquisition of Giant from the struct cdevsw.
* Remove the ACPI_USE_THREADS option.


# 0a9a1f44 12-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Allow null handles to be passed into acpi_name().


# c7f88fc3 10-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Don't call DEVICE_RESUME a second time if DEVICE_SUSPEND fails. The
bus_generic_suspend method does this for us. Disable interrupts before
entering S1. This may help some systems suspend to S1 successfully.


# 17dbe0f7 05-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Add flags for _STA (status) methods and convenience macros for checking
the presence of batteries and devices.


# 02a680b8 03-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Fix the ACPI_DEBUG case by removing a now unused variable.


# a2e35898 03-Aug-2004 David E. O'Brien <obrien@FreeBSD.org>

Initialize variables to fix kernel build on AMD64.


# bee4aa4a 02-Aug-2004 Nate Lawson <njl@FreeBSD.org>

/tmp/m


# 3fe12180 26-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Don't force an immediate probe/attach for all devices when compiled with
ACPI_DEBUG. This upset the ordering that acpi_probe_order() was meant to
provide, causing devices to attach before the sysresource object. This
debugging feature has been unnecessary for a while so just remove it.

Testing by: marcel


# df8d2a32 15-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Update the interface for child drivers. Add acpi_scan_children, which
allows a bus to re-enumerate its child handles and optionally replace
them with new children, arranged to the bus's liking. (The current device
space is flat with all devices immediately under acpi0). Add comments
for each interface.


# d40c0f53 13-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Clean up our pnpinfo and location strings.


# edc13633 13-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Call device_identify routines after doing the namespace walk. This is
needed so that sysresource objects are created first to reserve all regions,
then other devices can allocate from them. Otherwise, acpi_timer (the only
ACPI device with an identify routine), would allocate its resources from
the nexus, causing the later sysresource reserve to fail.

Debugging by: Taku YAMAMOTO, Andrea Campi


# d9aa98f8 01-Jul-2004 Warner Losh <imp@FreeBSD.org>

After re-exporting rman, et al, __RMAN_RESOURCE_VISIBLE is no longer
necessary for this file. It just needed the size and guts of struct
rman.


# 0363a126 30-Jun-2004 Warner Losh <imp@FreeBSD.org>

Hide struct resource and struct rman. You must define
__RMAN_RESOURCE_VISIBLE to see inside these now.

Reviewed by: dfr, njl (not njr)


# d4b9ff91 30-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Move flags into a private ivar so it can't collide with device flags.
Unify the code to disable GPEs with the enable code. Shutdown is handled
the same way. ACPI now does all wake/sleep prep for child devices so
now they no longer need to call external functions in the suspend/resume
path. Add the flags to non-ACPI busses (i.e., pci).


# 346eda4f 30-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Diff reduction for style.


# 89fb5af8 29-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Add new quirk code that disables problem BIOS versions. Remove old quirk
code that was never really used. Print a message when disabling ACPI via
a quirk. Allow the user to override the blacklist decision by setting
hint.acpi.0.disabled="0". Add missing AcpiTerminate() calls; they are
needed to clean up if bailing out after AcpiInitializeSubsystem().


# ce619b2e 29-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Add implementation of the ACPI methods which hands them off to ACPI-CA.
acpi_id_probe() returns NULL for no match or the ID string that matched
if the driver should attach.


# c796e27b 28-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Include isa/pnpvar.h and remove a duplicate copy of PNP_EISAID.


# ed67d9de 27-Jun-2004 Warner Losh <imp@FreeBSD.org>

rman_reserve_resource doesn't set the bushandle, so we have to do it here.

Badness noted by: njl
Perforce reply not read by: imp


# a3236570 27-Jun-2004 Warner Losh <imp@FreeBSD.org>

MFp4: Set the bus handle to the bus handle of the resource, not the
starting value. This is more pedantically correct (since the handle
isn't always identical to the start of the resource) and also doesn't
access the innards of struct resource direct (which I forbid in my
tree). We need to do this for all resource types, not just ioport.

Reviewed by: njl


# 80f0e4c2 23-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Run the power off code directly instead of using indirection through
smp_rendezvous() to ensure we run on the BSP. This reverts rev 1.128.
Add a comment indicating that MI code should be the one that runs all
shutdown functions on the BSP with the APs halted. This should work
around problems in power off while waiting for the MI code to be improved.


# 95957f62 23-Jun-2004 John Baldwin <jhb@FreeBSD.org>

- Defer BUS_CONFIG_INTR() on ACPI IRQ resources until the resources are
actually used. For most ACPI devices this means deferring the call
until bus_alloc_resource().
- Add a function acpi_config_intr() to call BUS_CONFIG_INTR() for an
ACPI IRQ resource using the trigger mode and polarity information
stored in the ACPI resource object.
- Add a function acpi_lookup_irq_resource() to lookup the ACPI IRQ
resource that corresponds to a specified rid and new-bus resource.
- Have the ACPI PCI bridge driver call BUS_CONFIG_INTR() on interrupts
that it routes through link devices.
- Remove needactivate variable from acpi_alloc_resource() by changing the
function not modify the flags variable but just mask off RF_ACTIVE when
calling rman_reserve_resource().

Reviewed by: njl (1, an earlier version)


# 89c9c53d 16-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 59e472e9 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Remove disable_on_poweroff and our pre-sync shutdown handler. Disabling
of GPEs is now done in acpi_shutdown() and so we no longer need the option
of disabling ACPI in the poweroff case.


# b82ca9a9 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Clean up acpi_probe_order() a bit and clarify some comments.


# f504b607 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Don't probe/attach in the ACPI_DEBUG case.


# 91233413 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Add support to ACPI to manage its own resources. Previously, resource
allocation was passed up to nexus. Now, we probe sysresource objects and
manage the resources they describe in a local rman pool. This helps
devices which attach/detach varying resources (like the _CST object) and
module loads/unloads. The allocation/release routines now check to see if
the resource is described in a child sysresource object and if so,
allocate from the local rman. Sysresource objects add their resources to
the pool and reserve them upon boot. This means sysresources need to be
probed before other ACPI devices.

Changes include:
* Add ordering to the child device probe. The current order is: system
resource objects, embedded controllers, then everything else.
* Make acpi_MatchHid take a handle instead of a device_t arg.
* Replace acpi_{get,set}_resource with the generic equivalents.


# 59a890e6 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Associate a device_t with an ACPI_HANDLE. This make AcpiWalkNamespace more
useful. If ACPI-CA allowed null object handlers, we wouldn't need the
placeholder function.


# 0e414868 05-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Don't forget to pass shutdown events down to children first now that we
handle them at the bus level too.


# 169b539a 05-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Disable wake GPEs in the reboot path as well as poweroff path. This fixes
"stray irq 9" messages on my Thinkpad. It may also help with general
reboot consistency although the recent hang on reboot was solved by
acpi_cpu.c rev 1.39.


# fe12f24b 30-May-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing <sys/module.h> includes


# 2b9609ab 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Decrease sleep_delay default to 1 second now that the machines that
required the 5 second delay have been fixed.


# 043498df 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Now that we properly disable GPEs before entering a sleep state, including
S5 (soft off), we don't need to disable ACPI when powering off. This may
fix some systems that don't power off correctly.


# cc85c78c 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Update the new suspend/resume GPE methods to properly limit the GPE
based on the destination sleep state. Add a method to restore the old
state on resume. This is needed for the case of suspending to a very low
state disabling a GPE (i.e. S4), resuming, and then suspending to a higher
state (i.e. S3). This case should now keep the proper GPEs enabled.


# 44b8ae71 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Pass a pointer to the sleep state instead of casting gymnastics to pass
the value itself in the pointer.


# 5c9ea25e 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Fix paste-o.


# 88a79fc0 28-May-2004 Nate Lawson <njl@FreeBSD.org>

Attach per-device sysctls to allow users to set whether or not a given
device can wake the system. For example:

dev.root0.nexus0.acpi0.acpi_lid0.wake: 1
dev.root0.nexus0.acpi0.acpi_button0.wake: 1
dev.root0.nexus0.acpi0.pcib0.wake: 0
dev.root0.nexus0.acpi0.sio0.wake: 0


# 80c74f3d 27-May-2004 Marcel Moolenaar <marcel@FreeBSD.org>

Fix LP64 environments: cast a pointer type to intptr_t before casting
to int and vice versa.


# e8b4d56e 27-May-2004 Nate Lawson <njl@FreeBSD.org>

Restructure the wake GPE API. Now there are three functions:

acpi_wake_init:
Evaluate _PRW and set the GPE type
acpi_wake_set_enable:
Enable or disable a device's GPE.
acpi_wake_sleep_prep:
Perform any last-minute changes to the device to prepare it for
entering the given sleep state.

Also, walk the entire namespace when transitioning to a sleep state,
disabling any GPEs which aren't appropriate for the given state. Transition
acpi_lid and acpi_button to the new API.

This clears the way for non-ACPI-aware devices to wake the system (i.e.
modems) and fixes a problem where systems power up after shutdown when a
GPE is triggered.


# f3fc4f8b 24-May-2004 Nate Lawson <njl@FreeBSD.org>

Changes to implement 20040514:

* Add calls to AcpiSetGpeType. We use wake/run as the type for lid and
button switches since wake-only causes Thinkpads to immediately wake on
the second suspend. Note that with wake/run, some systems return both
wake and device-specific notifies so we don't register for system notifies
for lid and button switches.
* Remove the hw.acpi.osi_method tunable since it is not needed.
* Always print unknown notifies for all types.
* Add more cleanup for the EC if it fails to attach.
* Use the GPE handle now that we parse it. This allows GPEs to be defined
in AML GPE blocks.
* Always use ACPI_NOT_ISR since it's ok to acquire a mutex in our thread
which processes queued requests.


# ea27c63e 06-May-2004 Nate Lawson <njl@FreeBSD.org>

Select the highest valid (i.e., S3) sleep state for the default for the
sleep button. Change the default for the lid switch to NONE. This can
be overridden in /etc/sysctl.conf as desired.


# 7e639165 05-May-2004 Nate Lawson <njl@FreeBSD.org>

Fix setting debug strings via sysctl. Also, clean up the way we print
debug strings.


# d33f4987 26-Apr-2004 Takanori Watanabe <takawata@FreeBSD.org>

Fix build breakage.

Submitted by: Xin LI <delphij@frontfree.net>
PR: 65979


# 904bf0c2 25-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Move the call to AcpiEnterSleepStatePrep() to before we select the BSP
(cpuid 0) as the processor. It mallocs some data and smp_rendezvous
calls functions with locks held.


# 8d01ceef 20-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Remove extran parens.


# eea17c34 20-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Move the timer difference convenience function from acpi_cpu.c to make it
globally available. acpi_TimerDelta() subtracts two readings from the
ACPI PM timer and returns the difference. It properly distinguishes between
24-bit and 32-bit timers and handles wraparound.


# a50f2c9f 16-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Disable the new wake GPE behavior. With it enabled, my laptop won't stay
suspended after the second try. Intel is working on a fix to properly
differentiate the non-standard wake/runtime GPEs from wake-only GPEs.


# 865b8d0b 14-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Remove a non-variable static and move other static variables to the same
location.


# c2b3a864 13-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Use TRUE for a boolean and a style nit.


# 074a57f5 09-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Add support for packages as the first element of _PRW. This may allow
some machines to enable wake events for more devices although I haven't
seen a system yet that uses this form. Also, introduce acpi_GetReference()
which retrieves an object reference from various types.


# a4ecd543 08-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Unify on version 1 to be similar to the rest of the tree. After 5-stable
branches, increment version on any API change visible to other modules.


# 5eb09c70 31-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Move the ivar accessing routines back to inlines (reverting acpivar.h
rev 1.44 and acpi.c rev 1.96). Now gcc can handle larger inlines and we
really need external drivers to be able to read their acpi ivars.


# 63600cc3 31-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Staticize pnp methods, style fixes. Remove unused variable to unbreak
kernel build.


# 72ad60ad 31-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Add an interface to pass an argument to the resource parsing functions.
This is just groundwork for changing sysresource behavior.

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:


# 247648af 31-Mar-2004 Takanori Watanabe <takawata@FreeBSD.org>

Style fix.

Pointed out by: njl


# c9b8d77d 30-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Disable serialize_methods and enable _OSI support by default. The former
is necessary because some IBMs use recursive methods (pointed out by
Robert Moore from Intel). The latter was a typo on my part. It was disabled
by default when it should have been enabled.


# 879d6c23 27-Mar-2004 Takanori Watanabe <takawata@FreeBSD.org>

Add ACPI PnP string. This affects devinfo(8) output with -v option.


# eeb3a05f 19-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Move the poweroff handler to a separate function. Make sure it is run
on the boot processor (cpuid == 0). Some chipsets do not power off the
system if the shutdown handler runs on an AP.


# 413081d7 18-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Add tunables for disabling serialized method execution and disabling the
new _OSI method. These can be used if these new features end up causing
regression for users.


# 5f96beb9 17-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# dba55fa2 08-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Simplify some logic in converting a buffer to an integer.


# cc58e4ee 08-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Use an unsigned int instead of an int for the Get/Set Integer interface.

Pointed out by: le


# 4e376d58 03-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Add a "quirks" value to disable quirks handling for a given boot.
Also, disable quirks if booting with a custom DSDT. Add a quirk
to disable loading ACPI so known bad systems can be completely
blacklisted.


# c310653e 03-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Change to acpi_{Get,Set}Integer to provide both methods. Convert all
callers to the new API.

Submitted by: Mark Santcroos <marks@ripe.net>


# 3184cf5a 02-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Add support for quirks for acpi tables. Key off OEM vendor and revision.
Sort acpi debug values. Change "disable" to "disabled" to match rest of
the kernel. Remove debugging from acpi_toshiba since it was only used for
probe/attach.


# dc08ffec 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


# c9c7976f 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


# abcbc5bc 19-Feb-2004 Nate Lawson <njl@FreeBSD.org>

Use ACPI_NEXT_RESOURCE instead of defining our own copy. The one provided
with ACPI-CA is identical now.


# 968c0e1b 18-Feb-2004 Nate Lawson <njl@FreeBSD.org>

Fix problem caused by previous commit where some users' buttons
stopped returning events. Don't disable the event when removing
the handler because it still needs to be enabled for the other
handler. Also, remove duplicate AcpiEnableEvent calls since the
install function now does this for us.


# 33febf93 10-Feb-2004 Nate Lawson <njl@FreeBSD.org>

Prefer buttons defined in the AML over the ones in the FADT. Some
systems define power/sleep buttons in both places but only deliver
notifies to the ones defined in the AML.

Also, reduce length of various function handler names.

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:


# 1b8c233d 28-Jan-2004 Peter Pentchev <roam@FreeBSD.org>

Add an ACPI_FUNCTION_TRACE() to the newly-added acpi_Startup() routine
to get the ACPI_DEBUG case (and LINT in particular) to build.

Reviewed by: jhb, njl
Approved by: jhb


# bbc2815c 26-Jan-2004 John Baldwin <jhb@FreeBSD.org>

Move the code to initialize ACPI-CA into a separate acpi_Startup() function
that other modules can call to initialize ACPI-CA before the new-bus probe
and change acpi_identify() to call it.

Reviewed by: njl


# 2ccd1cac 09-Jan-2004 Nate Lawson <njl@FreeBSD.org>

Clean up the acpi announce message of trailing spaces.


# c59c9a8e 26-Dec-2003 John Baldwin <jhb@FreeBSD.org>

Fix acpi_MatchHid() to check the compatibility ID's if the hardware ID
doesn't match.

Submitted by: marcel


# bd189fe7 23-Dec-2003 Nate Lawson <njl@FreeBSD.org>

Fix locking broken by recent _CID changes. Always be sure to unlock
in the error case.


# 1e4925e8 17-Dec-2003 Nate Lawson <njl@FreeBSD.org>

Add support for multiple CIDs since _CID can contain a package of values.
Implement this in acpi_MatchHid() and acpi_isa_get_compatid(). This
should fix mouse support for some users.

Move all users of AcpiGetObjectInfo() to use dynamic storage instead of
a devinfo on the stack. This is necessary since ACPI-CA needs to
allocate different sized arrays for the CompatList.


# 54f6bca0 08-Dec-2003 Nate Lawson <njl@FreeBSD.org>

Use sbufs instead of snprintf for parsing debug strings.


# 56a70ead 19-Nov-2003 Nate Lawson <njl@FreeBSD.org>

* Add a DEVMETHOD for acpi so that child detach methods get called. Add
an acpi_cpu method for shutdown that disables entry to acpi_cpu_idle
and then IPIs/waits for threads to exit. This fixes a panic late in
reboot in the SMP case.

* In the !SMP case, don't use the processor id filled out by the MADT
since there can only be one processor. This was causing a panic in
acpi_cpu_idle if the id was 1 since the data was being dereferenced from
cpu_softc[1] even though the actual data was in cpu_softc[0] (which is
correct).

* Rework the initialization functions so that cpu_idle_hook is written
late in the boot process.

* Make the P_BLK, P_BLK_LEN, and cpu_cx_count all softc-local variables.
This will help SMP boxes that have _CST or multiple P_BLKs. No such
boxes are known at this time.

* Always allocate the C1 state, even if the P_BLK is invalid. This means
we will always take over idling if enabled. Remove the value -1 as
valid for cx_lowest since this is redundant with machdep.cpu_idle_hlt.

* Reduce locking for the throttle initialization case to around the write
to the smi_cmd port. Add disabled code to write the CST_CNT. It will
be enabled once _CST re-evaluation is tested (post 5.2R).

Thank you: dfr, imp, jhb, marcel, peter
Tested by: rwatson, Harald Schmalzbauer <h@schmalzbauer.de>
Approved by: re (rwatson)


# dc750869 15-Nov-2003 Nate Lawson <njl@FreeBSD.org>

Add acpi_bus_alloc_gas() for allocating a memory or IO resource from its
Generic Address Structure.


# 9b937d48 24-Oct-2003 Nate Lawson <njl@FreeBSD.org>

Add devctl(4) notify support to ACPI. Various subsystems now notify
userland whenever events occur. See the example in devd.conf below
to see how to use it.


# 55398047 18-Oct-2003 Nate Lawson <njl@FreeBSD.org>

Disable irqs before entering the power-off state. This is not known
to fix any problems but is similar to how Linux implements this
function.


# 1d7b121c 26-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Make debug.acpi.level and debug.acpi.layer sysctls that can be set with
the strings found in acpi(4). Also make acpi_ca_version a string so it
is more readable.


# 297835bc 25-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Sort debugging levels and update the man page to match reality. Also
update man page to reflect iasl(8) import.


# 6c0e8467 17-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Add necessary newlines.


# a0e5a009 17-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Shorten the message announcing fixed power/sleep buttons.


# 2d610c46 15-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Only enable S4BIOS by default if the FACS says it is available. The
user can override this with a sysctl.

Be sure to return the acpi_SetSleepState return value to userland.


# 98175614 08-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Disallow attempts to suspend to S0. It was only enabled for testing.
Print a more informative message if a sleep state is not supported by BIOS.
Add comments.


# f97739da 04-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Don't free the buffer if it wasn't actually allocated.


# ad1fdf57 28-Aug-2003 Nate Lawson <njl@FreeBSD.org>

Use the ACPICA AcpiEnterSleepStateS4bios instead of rolling our own. This
change also disables interrupts around non-S4 suspends whereas before we
did not do this. Our version of AcpiEnterSleepStateS4bios was almost
identical to the ACPICA version.


# be2b1797 28-Aug-2003 Nate Lawson <njl@FreeBSD.org>

Style and whitespace changes. Also, make the ivar functions non-inline
since inlining failed due to the size of BUS_*


# 59ddeb18 14-Aug-2003 Nate Lawson <njl@FreeBSD.org>

Fix a couple changes that were incorrect in updating for 0619. Only unlock
the hardware mutex if it is held. Re-add calls to Enable/Clear fixed events.

This is not known to have caused problems. Bug symptoms might have included
instability after an aborted suspend attempt or power/sleep buttons not
being enabled.


# bf0c18ec 07-Aug-2003 Nate Lawson <njl@FreeBSD.org>

Default to 5 seconds before sleeping to give some machines time to stabilize.
This doesn't break anything on my laptop and some claim it helps them.


# e1a90ae1 19-Jul-2003 Nate Lawson <njl@FreeBSD.org>

Clarify the ACPI shutdown messages.


# f8335e3a 19-Jul-2003 Nate Lawson <njl@FreeBSD.org>

Add ECDT (ACPI 2.0) support. This allows the EC to be enabled before the
namespace has been evaluated. Machines with ACPI 2.0 expect this behavior
and have AML which calls EC functions early in the boot process. If the
ECDT is not available, fall back to original probe behavior.

Other minor changes:
* Add GPE bit and GLK usage to the device announcement
* Always use the global lock in the ECDT case, but potentially downgrade to
not using it if _GLK is 0 once the namespace is available. This is
announced with "Changing GLK from 1 to 0"
* Remove the acpi_object_list definitions which were earlier deprecated

Ideas from: takawata


# 6fca9360 13-Jul-2003 Nate Lawson <njl@FreeBSD.org>

Update code to work with 0619 dist

* Use ACPI_BUFFER as the type for AcpiGetObjectInfo
* Remove AcpiEnableEvent/AcpiClearEvent for ACPI_EVENT_FIXED (power/sleep
buttons) as they are no longer needed
* Change calls to use the new GPE functions
* Add AcpiOs*Lock functions


# 8a9bc9c0 02-Jul-2003 John Baldwin <jhb@FreeBSD.org>

- Use the new resource_disabled() helper function to see if devices are
disabled.
- Change the apm driver to match the acpi driver's behavior by checking to
see if the device is disabled in the identify routine instead of in the
probe routine. This way if the device is disabled it is never created.

Note that a few places (ips(4), Alpha SMP) used "disable" instead of
"disabled" for their hint names, and these hints must be changed to
"disabled". If this is a big problem, resource_disabled() can always be
changed to honor both names.


# 9501b603 01-May-2003 John Baldwin <jhb@FreeBSD.org>

Catch up to reworked debugging levels in latest Intel import.


# d75de536 11-Apr-2003 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add new sysctl MIB (hw.acpi.supported_sleep_state) to indicate
the list of supported sleep state.
This should help people understand what following message means.

acpi0: AcpiGetSleepTypeData failed - AE_NOT_FOUND

MFC after: 3 days


# b2566207 06-Mar-2003 Takanori Watanabe <takawata@FreeBSD.org>

Add integer value of _CID handling.
If _CID is string, it will need more complicated
handling to distinguish bus other than ISA.

Submitted by: Paul Wankadia <junyer@gmx.net>


# 7ac40f5f 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


# 6fee404e 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Use canonical form for cdevsw initialization.


# a89fcf28 14-Feb-2003 Takanori Watanabe <takawata@FreeBSD.org>

Allow non-privilaged user to retrive battery or AC line information.

Reviewed by: rwatson


# 2a4689e8 28-Dec-2002 Robert Watson <rwatson@FreeBSD.org>

Change ACPI make_dev() calls to use UID_ and GID_ constants rather
than hard-coded uids and gids.

Switch the device to a group of wheel instead of operator.

Narrow down the permissions on the device to require root privilege
to manipulate the system power state. It may be that we can broaden
access to the device after review of the access control in ACPI.

Submitted by: kris
Reviewed by: takawata


# c6a78e98 11-Dec-2002 Takanori Watanabe <takawata@FreeBSD.org>

Add sysctl knob to stop disabling acpi on shutdown.

Approved by: re(jhb)


# 87b45ed5 23-Nov-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add `if (!cold)' checkings for functions which is called via SYSINIT.
Loading acpi.ko with kldload is disallowed, however some
functions were executed unexpectedly.

Approved by: re


# 498d464f 31-Oct-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Interpret new loader tunable "hw.acpi.verbose" to turn
verbose mode on at boot time.


# 91da7c40 31-Oct-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Invoke 3 ACPI task threads as default if option ACPI_MAX_THREADS is
not defined.
To make previous default behavior (ACPI_MAX_THREADS undefined), define
option ACPI_MAX_THREADS as 0.


# fc0ea94a 16-Oct-2002 John Baldwin <jhb@FreeBSD.org>

Catch up to changes in acpivar.h to add support for using ACPI on
4-stable systems.

Sponsored by: The Weather Channel


# 6b4d1b08 09-Oct-2002 John Baldwin <jhb@FreeBSD.org>

Use d_thread_t for cdevsw functions instead of struct thread * so that it
is easier to share this code with 4-stable.


# 422971d7 08-Oct-2002 John Baldwin <jhb@FreeBSD.org>

Don't panic for a bad ivar request, just return ENOENT.


# eeb6dba2 06-Sep-2002 John Baldwin <jhb@FreeBSD.org>

Attach ACPI children a bit later in attach(), specifically after performing
any machine dependent initialization. This allows the MD code to set the
interrupt routing model so that PCI interrupts are routed correctly when
using an APIC or SAPIC for example.


# da14ac9f 06-Sep-2002 John Baldwin <jhb@FreeBSD.org>

Add a helper routine acpi_SetIntrModel() to call the _PIC method to set
the interrupt model in use so that ACPI can properly route interrupts for
machines using APIC's or SAPIC's.


# 9ed79eca 03-Sep-2002 John Baldwin <jhb@FreeBSD.org>

Use resource_list_print_types() instead of duplicating the code.


# 6c407052 30-Aug-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

s/hint.acpi.0.disable/hint.acpi.0.disabled/

Fix device hints entry for disabling acpi(4).
This also should fix the arbitration with apm(4) when both drivers
are enabled.

Note that your /boot/device.hints needs to be updated if you want to
stop auto-loading acpi.ko or disable acpi(4).


# d62ab2f4 28-Aug-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Resolve conflicts arising from the ACPI CA 20020815 import.


# f3a6cbb6 28-Aug-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Change default value of hw.acpi.sleep_delay to 0.
This caused problems (reset or lock up) at wakeup.


# ff01efb5 25-Aug-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add new sysctl MIB (hw.acpi.sleep_delay) to specify the delay (in
seconds) before ACPI sleep. Some machines might need this to sleep
by Hot-key.


# 2ab060ee 12-Aug-2002 Warner Losh <imp@FreeBSD.org>

don't include redunant \n in panic message


# b69ed3f4 30-Jul-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Resolve conflicts arising from the ACPI CA 20020725 import.


# a1fccb47 21-Jul-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add device(power/sleep button and lid) wake function from sleeping state.
This is required for some Thinkpad (and maybe VAIO) machines to wake
the system up from sleep.

Currently partially implemented, more complete implementation will come later.


# 98479b04 09-Jul-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Resolve conflicts arising from the ACPI CA 20020611 import.


# 494ae560 19-May-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Terminate ACPI subsystem on reboot.
Some machines stuck on reboot if ACPI sleep/wakeup was executed.


# b4a05238 19-May-2002 Peter Wemm <peter@FreeBSD.org>

Brutally deal with __func__ being 'const char *' on gcc-3.1.


# 3c600cfb 09-May-2002 John Baldwin <jhb@FreeBSD.org>

Fix acpi_avoid() to call freeenv() on the original char * returned from
getenv().

Reported by: joe
Tested by: joe


# 78689b15 24-Apr-2002 Maxime Henrion <mux@FreeBSD.org>

Don't call freeenv() on a modified pointer.

Submitted by: Alexander Kabaev <ak03@gte.com>
Reviewed by: phk
Pointy hat to: mux


# 94aae282 19-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

Fix compiling of acpica when debugging is enabled. In the previous
revision, two getenv()s were accidentally changed to use testenv().

Pointy hat to: mux


# d786139c 17-Apr-2002 Maxime Henrion <mux@FreeBSD.org>

Rework the kernel environment subsystem. We now convert the static
environment needed at boot time to a dynamic subsystem when VM is
up. The dynamic kernel environment is protected by an sx lock.

This adds some new functions to manipulate the kernel environment :
freeenv(), setenv(), unsetenv() and testenv(). freeenv() has to be
called after every getenv() when you have finished using the string.
testenv() only tests if an environment variable is present, and
doesn't require a freeenv() call. setenv() and unsetenv() are self
explanatory.

The kenv(2) syscall exports these new functionalities to userland,
mainly for kenv(1).

Reviewed by: peter


# 32b58d13 08-Apr-2002 Takanori Watanabe <takawata@FreeBSD.org>

Print DRQ resource in boot message.


# 6008862b 04-Apr-2002 John Baldwin <jhb@FreeBSD.org>

Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on: i386, alpha, sparc64


# b53f2771 22-Feb-2002 Mike Smith <msmith@FreeBSD.org>

Match namespace cleanup changes in ACPI CA 20020217 update.
Use ACPI_SUCCESS/ACPI_FAILURE consistently.
The AcpiGetInto* interfaces are obsoleted by ACPI_ALLOCATE_BUFFER.

Add AcpiBatteryIsPresent helper to determine whether a battery device
is inserted.

Add ACPI_ALL_DRIVERS to the list of debug layers, now that we own the
namespace for this.

Pr:


# 3273b005 07-Jan-2002 Mike Smith <msmith@FreeBSD.org>

Staticise devclasses and some unnecessarily global variables.


# c573e654 22-Dec-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add OS layer ACPI mutex and threading support.
- Temporary fix a bug of Intel ACPI CA core code.
- Add OS layer ACPI mutex support. This can be disabled by
specifying option ACPI_NO_SEMAPHORES.
- Add ACPI threading support. Now that we have a dedicate taskqueue for
ACPI tasks and more ACPI task threads can be created by specifying option
ACPI_MAX_THREADS.
- Change acpi_EvaluateIntoBuffer() behavior slightly to reuse given
caller's buffer unless AE_BUFFER_OVERFLOW occurs. Also CM battery's
evaluations were changed to use acpi_EvaluateIntoBuffer().
- Add new utility function acpi_ConvertBufferToInteger().
- Add simple locking for CM battery and temperature updating.
- Fix a minor problem on EC locking.
- Make the thermal zone polling rate to be changeable.
- Change minor things on AcpiOsSignal(); in ACPI_SIGNAL_FATAL case,
entering Debugger is easier to investigate the problem rather than panic.


# ece50487 09-Dec-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Disable sleep requests for 5 sec after wakeup. This is needed for
some Toshiba and Thinkpad laptops.
Wakeup event is generated by power button or sleep button on some
laptops but this also generates SCI interrupt, and shutdown the system
as result. So this is introduced so that acpi driver ignore given
requests for certain period.


# 931a10c9 30-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add a couple of minor changes.
- set sc->acpi_s4bios to 1 by default for hibernation until
OS-initiated S4 transition is implemented.
- change the behavior of acpi_sleep_state_sysctl() if new value is
the same as old one, do nothing instead of EINVAL.


# b9c780d6 27-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Yet another synch with minor changes in the ACPI CA 20011120 snapshot.
We need to call AcpiEnterSleepStatePrep() before AcpiEnterSleepState().


# 6397624d 22-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Validate requested sleep state in acpi_SetSleepState() to avoid reentry
during wakeup procedure.


# 964679ce 15-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Fix re-enabling ACPI on wakeup from hibernation. The problem was that
acpi_Disable() cleared all GPE events.
Some old ACPI implementaions still need current re-enabling code.


# b8670bed 15-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Remove "S4B" from sleep_state_names and add "NONE" instead.
Now you can say;
# sysctl hw.acpi.lid_switch_state=NONE
instead of specifying unsupported _Sx object in the system.

Actually, S4B is going to disappear in ACPICA and we already have
hw.acpi.s4bios to distinguish BIOS hibernation or OS hibernation.


# 1611ea87 06-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add S4BIOS sleep (BIOS hibernation) and DSDT overriding support.
- Add S4BIOS sleep implementation. This will works well if MIB
hw.acpi.s4bios is set (and of course BIOS supports it and hibernation
is enabled correctly).
- Add DSDT overriding support which is submitted by takawata originally.
If loader tunable acpi_dsdt_load="YES" and DSDT file is set to
acpi_dsdt_name (default DSDT file name is /boot/acpi_dsdt.aml),
ACPI CA core loads DSDT from given file rather than BIOS memory block.
DSDT file can be generated by iasl in ports/devel/acpicatools/.
- Add new files so that we can add our proposed additional code to Intel
ACPI CA into these files temporary. They will be removed when
similar code is added into ACPI CA officially.


# 09e97d2f 05-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Remove unnecessary WAK_STS bit waiting code for S1 sleep.
It was duplicated with AcpiEnterSleepState() since acpica-unix-20010816.


# f9390180 01-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Some fix for the recent apm module changes.
- Now that apm loadable module can inform its existence to other kernel
components (e.g. i386/isa/clock.c:startrtclock()'s TCS hack).
- Exchange priority of SI_SUB_CPU and SI_SUB_KLD for above purpose.
- Add simple arbitration mechanism for APM vs. ACPI. This prevents
the kernel enables both of them.
- Remove obsolete `#ifdef DEV_APM' related code.
- Add abstracted interface for Powermanagement operations. Public apm(4)
functions, such as apm_suspend(), should be replaced new interfaces.
Currently only power_pm_suspend (successor of apm_suspend) is implemented.

Reviewed by: peter, arch@ and audit@


# 2d644607 29-Oct-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Some small improvements of ACPI thermal driver.
- Give a guaranteed minimum cooling run time to avoid too frequent
cooling system On/Off switching. The minimum cooling run time can be
specified by hw.acpi.thermal.min_runtime in sec.
- Refine message printing (_AC-1 -> NONE).
- Add verbose mode enable/disable capability by hw.acpi.verbose in bool.

Reviewed by: acpi-jp@ folks


# f86214b6 26-Oct-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add APM compatibility feature to ACPI.
This emulates APM device node interface APIs (mainly ioctl) and
provides APM services for the applications. The goal is to support
most of APM applications without any changes.
Implemented ioctls in this commit are:
- APMIO_SUSPEND (mapped ACPI S3 as default but changable by sysctl)
- APMIO_STANDBY (mapped ACPI S1 as default but changable by sysctl)
- APMIO_GETINFO and APMIO_GETINFO_OLD
- APMIO_GETPWSTATUS

With above, many APM applications which get batteries, ac-line
info. and transition the system into suspend/standby mode (such as
wmapm, xbatt) should work with ACPI enabled kernel (if ACPI works well :-)

Reviewed by: arch@, audit@ and some guys


# 43896e91 04-Oct-2001 Mike Smith <msmith@FreeBSD.org>

Update usage of AcpiEnableEvent to reflect a new argument.

Fix acpi_DeviceIsPresent to check for valid _STA data and to check
the "present" and "functioning" bits.

Use acpi_DeviceIsPresent in acpi_pcib rather than rolling our own
(also broken) version.


# ed136da6 04-Oct-2001 Doug Rabson <dfr@FreeBSD.org>

Check the compatible ID as well as the hardware ID in acpi_MatchHid.


# 23b4e251 17-Sep-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Call acpi_DeviceIsPresent() only for devices. This should make
non-ACPI_TYPE_DEVICE devices (such as acpi_tz and acpi_cpu) enabled
again.

Reviewed by: msmith


# b519f9d6 14-Sep-2001 Mike Smith <msmith@FreeBSD.org>

Disable devices that are not present; at a later stage we can then enable
them if the device arrives.

This should solve the problem where devices that have been disabled eg. in
the BIOS show up with nonsense resources and hang the bootstrap process.


# b40ce416 12-Sep-2001 Julian Elischer <julian@FreeBSD.org>

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# b525621a 06-Sep-2001 Mike Smith <msmith@FreeBSD.org>

Should check debug.acpi.avoid, not .disable.


# 32d18aa5 06-Sep-2001 Mike Smith <msmith@FreeBSD.org>

Allow the ACPI subsystem to be disabled with a hint.

Avoid fully initialising the ACPI namespace if we are attempting to avoid
parts of it. This is a workaround for some systems that still crash
the interpreter.

Implement the ISA_IVAR_LOGICALID for ISA compatibility. Implement stubs
for other PnP ID-related ivars.


# 0c7da7ac 06-Sep-2001 John Baldwin <jhb@FreeBSD.org>

Add a hack to acpi_EvaluateInteger() to handle the case of a method
returning a Buffer that contains an Integer rather an an Integer directly.

Submitted by: msmith
Approved by: msmith


# dd081ed5 02-Sep-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Fix typo; CTLFLAG_RO -> CTLFLAG_RD.


# dde24897 01-Sep-2001 Mike Smith <msmith@FreeBSD.org>

Add a MODULE_VERSION declaration. This should prevent duplicate loading
of the module, and allows other modules to depend on and link against
the ACPI module.

Add a sysctl that allows us to retrieve the ACPI CA version number as
well.


# ff741bef 30-Aug-2001 Takanori Watanabe <takawata@FreeBSD.org>

Call OS-independent resume routine to execute _WAK .. etc.
This should also recover GPE bit,comment says, though not implemented yet.


# bc0f2195 29-Aug-2001 Mike Smith <msmith@FreeBSD.org>

Add support for attaching PnP-aware ISA drivers to ACPI.

Always parse ACPI device resource settings (current resources only)
and attach the resources to the device before probe/attaching.


# 4c1cdee6 26-Aug-2001 Mike Smith <msmith@FreeBSD.org>

Updates to match the ACPI CA 20010816 import:

- New debug macro (ACPI_DEBUG_PRINT), reducing debug-case code size.
- New debug level/subsystem codes.


# a692219d 03-Aug-2001 Mike Smith <msmith@FreeBSD.org>

Move the resource pointer when we reallocate the buffer.

Submitted by: "neckpain@nettaxi.com" <neckpain@nettaxi.com>


# 6d63101a 30-Jul-2001 Mike Smith <msmith@FreeBSD.org>

- Prevent the ACPI code from being loaded as a module other than at
boot time. Loading as a module once the system is up and running
doesn't make any sense.

- Fix acpi_FindIndexedResource (it would only check the first resource),
changes the calling interface.

- Add a new helper function (acpi_AppendBufferResource) to help building
buffers containing resources.


# 56d8cb57 22-Jul-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Don't do sleep state transition if specified sleep state is not
supported by the system.


# bfae45aa 21-Jul-2001 Mike Smith <msmith@FreeBSD.org>

Convert from acpi_strerror() to AcpiFormatException()

Fix dangling include of the dear departed acpi_ecreg.h


# acf72ef4 20-Jul-2001 Mike Smith <msmith@FreeBSD.org>

The API for loading tables changed (we no longer explicitly search for the
RSDP, it's now found via a callback).

AcpiOsSleepUsec() went away, use AcpiOsSleep() instead (we could use
AcpiOsStall() too)

AcpiFormatException() was changed to make more sense (it behaves like
our old acpi_strerror() did), so throw acpi_strerror() away (still
#defined in acpivar.h though, we need to sweep these seperately).


# 6161544c 20-Jul-2001 Takanori Watanabe <takawata@FreeBSD.org>

Add ACPI S2-S4BIOS Suspend/Resume code.
Some problems may remain.

Reviewed by:iwasaki


# 7d3bcec9 07-Jul-2001 Mike Smith <msmith@FreeBSD.org>

Add acpi_GetTableIntoBuffer, to aid in fetching tables.


# 6f69255b 05-Jul-2001 Mike Smith <msmith@FreeBSD.org>

Add a new helper function for finding resources in resource buffers.

Move the ACPI generic battery code into a new file.


# cb9b0d80 29-Jun-2001 Mike Smith <msmith@FreeBSD.org>

Update to synch with the 20010615 ACPI CA import.

Add an ACPI subsystem mutex, and macros for handling it. Because it's
not possible to differentiate between ACPI CA acquiring mutexes for
internal use and for use by AML, and because AML in the field doesn't
handle mutexes correctly, we can't use the ACPI subsystem's internal
locking. In addition, we have other private data of our own to lock.

Add initial locking to the ACPI driver code and the thermal module.
These locks are currently inoperative.

Pull some errant style back into line.


# c5ba0be4 28-Jun-2001 Mike Smith <msmith@FreeBSD.org>

Sync to my work in progress:

- Reorder the acpi_* functions in a sensible fashion
- Add acpi_ForeachPackageObject and acpi_GetHandleInScope
- Use the new debugging layer/level names
- Implement most of the guts of the acpi_thermal module; passive cooling
isn't there yet, but active cooling should work.
- Implement power resource handling (acpi_powerres.c)

This compiles and mostly works, but my test coverage is small, so feedback
is welcome.


# a5d1879b 23-Jun-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

- Swap order of "S4B" and "S5" in sleep_state_names. They already
changed in ACPICA actypes.h.
- Use ACPI_S_STATES_MAX instead of ACPI_STATE_S5.


# 4eb77744 23-Jun-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add sysctl interface (Read-only) for temprature, AC-line and Battery.
Patches for acpi_cmbat.c submitted by Munehiro Matsuda.


# 2a4ac806 29-May-2001 Mike Smith <msmith@FreeBSD.org>

- Updates for new constant naming in the ACPI CA 20010518 update.
- Use __func__ instead of __FUNCTION.
- Support power-off to S3 or S5 (takawata)
- Enable ACPI debugging earlier (with a sysinit)
- Fix a deadlock in the EC code (takawata)
- Improve arithmetic and reduce the risk of spurious wakeup in
AcpiOsSleep.
- Add AcpiOsGetThreadId.
- Simplify mutex code (still disabled).


# fb919e4d 01-May-2001 Mark Murray <markm@FreeBSD.org>

Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by: bde (with reservations)


# 606e1d68 02-Apr-2001 John Baldwin <jhb@FreeBSD.org>

Remove bogus block device major now that bdev majors are gone.


# f34fa851 28-Mar-2001 John Baldwin <jhb@FreeBSD.org>

Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>


# c30382df 07-Mar-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Bring our local hack for wakeup back from
sys/contrib/dev/acpica/Subsystem/Hardware/Attic/hwxface.c to the proper
location after AcpiEnterSleepState().

- Wait for the WAK_STS bit
- Evaluate the _WAK method and check result code


# 91467fc6 31-Jan-2001 Mike Smith <msmith@FreeBSD.org>

ACPI_NUMBER becomes ACPI_INTEGER. acpi_EvaluateNumber becomes
acpi_EvaluateInteger.

Use acpi_EvaluateInteger instead of doing things the hard way where
possible.

AcpiSetSystemSleepState (unofficial) becomes AcpiEnterSleepState.

Use the AcpiGbl_FADT pointer rather than searching for the FADT.


# 1d073b1d 13-Jan-2001 John Baldwin <jhb@FreeBSD.org>

Add 3 new dynamic sysctl's to control the sleep states switched to on a
power button, sleep button, or lid close event. The sysctl's use the
ACPI sleep state names S0, S1, S2, S3, S4, S4B, and S5.

Reviewed by: iwasaki


# 13d4f7ba 10-Jan-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Enable fixed event at not only boot but also wakeup.

Reported and patch tested by: Peter Dufault <dufault@hda.hda.com>


# 917d44c8 24-Dec-2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add ioctls to acpi_cmbat and acpi_acad. These use mike's acpi_register_ioctl().
Fix wrong AML method calling in acpi_cmbat.


# 5f3e4175 19-Dec-2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Fix testing reboot howto flags in acpi_shutdown_final().
This sould make the system power-off correctly where the howto had
more bits set than RB_POWEROFF, e.g. RB_NOSYNC.

Submitted by: Peter Pentchev <roam@orbitel.bg>


# b2c9c0da 12-Dec-2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Catch up with the recent conversion the per-eventhandler list mutex to
a lockmgr lock.


# 0ae55423 08-Dec-2000 Mike Smith <msmith@FreeBSD.org>

- Convert a lot of homebrew debugging output to use the ACPI CA debugging
infrastructure. It's not perfect, but it's a lot better than what
we've been using so far. The following rules apply to this:
o BSD component names should be capitalised
o Layer names should be taken from the non-CA set for now. We
may elect to add some new BSD-specific layers later.

- Make it possible to turn off selective debugging flags or layers
by listing them in debug.acpi.layer or debug.acpi.level prefixed
with !.

- Fully implement support for avoiding nodes in the ACPI namespace.
Nodes may be listed in the debug.acpi.avoid environment variable;
these nodes and all their children will be ignored (although still
scanned over) by ACPI functions which scan the namespace. Multiple
nodes can be specified, separated by whitespace.

- Implement support for selectively disabling ACPI subsystem components
via the debug.acpi.disable environment variable. The following
components can be disabled:
o bus creation/scanning of the ACPI 'bus'
o children attachment of children to the ACPI 'bus'
o button the acpi_button control-method button driver
o ec the acpi_ec embedded-controller driver
o isa acpi replacement of PnP BIOS for ISA device discovery
o lid the control-method lid switch driver
o pci pci root-bus discovery
o processor CPU power/speed management
o thermal system temperature detection and control
o timer ACPI timecounter
Multiple components may be disabled by specifying their name(s)
separated by whitespace.

- Add support for ioctl registration. ACPI subsystem components may
register ioctl handlers with the /dev/acpi generic ioctl handler,
allowing us to avoid the need for a multitude of /dev/acpi* control
devices, etc.


# 4d332989 04-Dec-2000 Mike Smith <msmith@FreeBSD.org>

ACPI HID's aren't limited to 7 characters. Don't check the length of the
HID passed in as an argument at all; callers are typically going to be
sending us static strings anyway.

Submitted by: Munehiro Matsuda <haro@tk.kubota.co.jp>


# 042283a6 01-Dec-2000 Mike Smith <msmith@FreeBSD.org>

Update to work with the new ACPI CA snapshot.

- Use ACPI_PHYSICAL_ADDRESS
- RSDT -> XSDT
- FACP -> FADT
- No APIC table support
- Don't install a global EC handler; this has bad side-effects
(it invokes _REG in *all* EC spaces in the namespace!)
- Check for PCI bus instances already existing before adding them


# aef80087 06-Nov-2000 Mike Smith <msmith@FreeBSD.org>

Remove unused PCI includes.


# 840f9b53 31-Oct-2000 Takanori Watanabe <takawata@FreeBSD.org>

If acpica driver is loaded using kldload(8), warn and just ignore.


# 15e32d5d 28-Oct-2000 Mike Smith <msmith@FreeBSD.org>

Initial FreeBSD OSPM (operating system power management) modules for
ACPICA. Most of these are still works in progress. Support exists for:

- Fixed feature and control method power, lid and sleep buttons.
- Detection of ISA PnP devices using ACPI namespace.
- Detection of PCI root busses using ACPI namespace.
- CPU throttling and sleep states (incomplete)
- Thermal monitoring and cooling control (incomplete)
- Interface to platform embedded controllers (mostly complete)
- ACPI timer (incomplete)
- Simple userland control of sleep states.
- Shutdown and poweroff.