Commit Graph

737 Commits

Author SHA1 Message Date
Nate Lawson
d92a2ebdb2 MPSAFE locking
* Hold the ACPI lock over table register writes.
* Serialize calls to acpi_cpu_throttle_set() and the sysctls.
2004-08-13 06:21:47 +00:00
Nate Lawson
98b2573f26 MPSAFE locking
* Serialize ops in acpi_cmbat_notify_handler(), acpi_cmbat_ioctl(),
  acpi_cmbat_init_battery(), and acpi_cmbat_get_battinfo().
* Get the softc directly in acpi_cmbat_get_total_battinfo() rather than
  build an array of them.
* Don't queue a _BIF query after receiving a notify.  Since we clear the
  timespec, a _BIF query will be done in the context of the next caller.
* Add asserts to leaf functions that operate on shared data.
* Remove the bst/bif updating flags now that we hold the lock over the
  full query.
* Explain various comments in more detail.
2004-08-13 06:21:44 +00:00
Nate Lawson
07d4077ebf MPSAFE locking
* Serialize acpi_battery_get_battdesc(), acpi_battery_register(), and
  acpi_battery_remove().
* Assert that the sx lock is held in acpi_batteries_init().
* Remove check for device_get_softc() returning NULL.
2004-08-13 06:21:41 +00:00
Nate Lawson
99eaaec19e MPSAFE locking
* Serialize notification of acline changes in acpi_acad_get_status().
* Remove the initializing flag.  With the locking, we don't need to
  push off requests for the acline before initialization is done.
* Don't check device_get_softc(), it can't return NULL.
2004-08-13 06:21:36 +00:00
Nate Lawson
15e2f34f90 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.
2004-08-13 06:21:32 +00:00
Nate Lawson
3a9865dd34 MPSAFE locking
* Add and comment our locking primitives.  The mutex primitives use a
  a static mutex and the serialization ones use a static sx lock.  A global
  acpi_mutex is used for access to global resources (i.e., writes to the
  SMI_CMD register.)
* Remove 4.x compat defines.
2004-08-13 06:21:19 +00:00
Nate Lawson
56a7639b91 Skip dependent functions when finding the resource from _PRS to use for
later calls to _SRS.  Add note that this code should be centralized at
some point.

Bug from:	Jiawei Ye <leafy7382_AT_gmail.com>
2004-08-12 17:06:05 +00:00
Nate Lawson
12f57103bb Only print the link name if there is a link. For the hardwired case, don't
bother printing it.  This fixes a panic and acpi_name() has been more robust
as well.

Bug from:	Tai-hwa Liang <avatar-at-mmlab.cse.yzu.edu.tw>
2004-08-12 17:04:19 +00:00
Nate Lawson
0a9a1f44ce Allow null handles to be passed into acpi_name(). 2004-08-12 17:02:53 +00:00
Nate Lawson
310953d935 Fix the PRT entry code in acpi_pci_link to always add the entry, even if
there is no irq link.  Since we now use the stored copy of PRT, not the
one that used to be passed into acpi_pcib_route_interrupt(), we need it in
the list. [1]

Fix a bug in acpi_pci_find_prt() where we weren't checking the bus, thus
choosing the wrong PRT entry to use for routing the link.  Also, add a
printf for the case where the PRT entry is not found as this should not
happen.

Tested by:	marcel [1]
2004-08-12 02:06:19 +00:00
Nate Lawson
8f24713075 Add some more verbose warning/error messages to help with users reporting
problems with irq routing.
2004-08-11 20:37:24 +00:00
Nate Lawson
e4116e931c Re-work ACPI PCI IRQ routing (_PRT, link devices). The old approach was
incomplete in that the PRT routing was not aware of link programming.
Fix this by doing all routing through the link devices.  The new algorithm
for setting up links is:

1. Read _CRS to get current setting.  If invalid (not in _PRS), then set
   to 0.
2. Attempt to call _DIS on the link.  If successful, mark the link as not
   routed.  Otherwise, assume it still is.

Then when a routing request occurs:

3. Update weights for all IRQs
4. Attempt to route the initial IRQ if valid
5. If that fails, walk through the sorted list, attempting to route IRQs.
6. Configure the trigger/polarity based on _PRS.

Other changes:
* Add acpi_pci_find_prt() to look up the PRT entry for a given device and
  acpi_pci_link_route() to select/route the best IRQ for it.
* Remove duplicated code in acpi_pcib_route_interrupt() that picked the
  first IRQ from _PRS.
* Remove unneeded arguments from acpi_pcib_resume() and friends.
* Ignore _STA on link devices but report if it seems strange.
* Add a prt_source handle to the PRT structure since the ACPI struct
  ACPI_PCI_ROUTING_TABLE uses a fixed-size entry for it.  We'll need to
  dynamically size this object if we want to use it the same way ACPI-CA
  does.  Null-terminate the source.

Tested by:	Luo Hong <luohong99_at_mails.tsinghua.edu.cn>,
		Jeffrey Katcher <jmkatcher_at_yahoo.com>
Info from:	jhb, Len Brown (Intel)
2004-08-11 14:52:50 +00:00
Nate Lawson
c7f88fc386 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.
2004-08-10 22:02:52 +00:00
Nate Lawson
85524256ea Refine updates to PCI irq routing. Check _STA and _CRS but only print a
message if they are incorrect.  Also, remove the hack of allowing the
initial irq setting to not be in _PRS.  As before, the old behavior can be
regained by defining ACPI_OLD_PCI_LINK.
2004-08-06 04:50:56 +00:00
Nate Lawson
17dbe0f79f Add flags for _STA (status) methods and convenience macros for checking
the presence of batteries and devices.
2004-08-06 00:38:50 +00:00
Nate Lawson
298e3d15d7 Work around non-compliant BIOS PCI link devices. Some systems have the
following behavior:

* Link devices return invalid status (_STA) values.  The results are very
  unreliable -- sometimes never present.  Just ignore the status and pick
  the best configuration from _PRS.

* Link devices return invalid current settings (_CRS).  Even after setting
  the link value, many systems still return a different setting for _CRS.
  When setting an IRQ, don't bother to check _CRS to see if we succeeded.
  Note that we still check _CRS before routing and this should be addressed
  as well.

Since this is a sensitive area, leave the old behavior accessible via
uncommenting the define for ACPI_OLD_PCI_LINK at the top of the file.  Once
this has been thoroughly tested, this option and the code it covers will
be removed.

Thanks to Len Brown at Intel for informing us of these issues as he worked
around them in Linux.
2004-08-05 06:54:16 +00:00
Nate Lawson
02a680b8f5 Fix the ACPI_DEBUG case by removing a now unused variable. 2004-08-03 17:16:30 +00:00
David E. O'Brien
a2e358988f Initialize variables to fix kernel build on AMD64. 2004-08-03 14:14:53 +00:00
Nate Lawson
bee4aa4ae5 /tmp/m 2004-08-03 05:13:56 +00:00
Nate Lawson
3fe12180a5 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
2004-07-26 06:04:35 +00:00
Nate Lawson
6b3322721c Fix a bug where an item was being removed from a list without using
FOREACH_SAFE.  Remove bad cast of retp and instead use an additional
arg to pass back the number of valid outputs.  Use the package convenience
functions for parsing packages.
2004-07-24 17:51:22 +00:00
Nate Lawson
14827d7eae Reinsert the bus space handle and tag, they are needed for the timer test. 2004-07-22 05:42:14 +00:00
Nate Lawson
be1841b4ae Instead of doing everything in identify, do a proper probe/attach. Also,
don't add another device if identify is called twice.  Minor reworking by
myself.

Submitted by:	marcel
2004-07-22 05:32:56 +00:00
Nate Lawson
c8f3591b78 Remove unused (and bogus) locking, style cleanup, remove unnecessary casts. 2004-07-22 05:18:05 +00:00
Nate Lawson
021730ab36 Use ACPI_ALL_NOTIFY instead of registering handlers separately. 2004-07-16 19:05:40 +00:00
Nate Lawson
7051c84dd3 Fix acpi_video loading. When we started cleaning up the duplicate handles
left around after the PCI probe, acpi_video stopped attaching because while
it was an acpi child device, it really is a PCI device.  Fix this by making
it a PCI child.

* Remove non-handle ivars accesses since child busses only implement
acpi_get_handle().
* Access the acpi softc directly through the devclass instead of through
the implied parent.
* Clean up a potential panic on unload by freeing the sysctl context before
storing NULL in the OID.

Found by:	marks
2004-07-16 16:59:32 +00:00
Nate Lawson
df8d2a326e 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.
2004-07-15 16:29:08 +00:00
Mark Santcroos
9b7b2aeff6 Some laptops report the "design-capacity" instead of the "real-capacity"
when the battery is fully charged. That breaks some of the arithmetic in
calculating the remaining capacity (ends up with more than 100%).
This commit makes sure the max is 100.

Approved by:	njl
2004-07-14 19:31:31 +00:00
Takanori Watanabe
8c4c207db4 Follow PnP location string change in acpi.c. 2004-07-14 06:58:39 +00:00
Nate Lawson
d40c0f5324 Clean up our pnpinfo and location strings. 2004-07-13 18:59:49 +00:00
Nate Lawson
edc136334b 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
2004-07-13 17:57:41 +00:00
Nate Lawson
7a5230b8ad Add the ability to detach a battery. Now batteries that are detached are
also removed from the battery list.
2004-07-12 20:53:04 +00:00
Marcel Moolenaar
124ea6b5ac Update for the KDB framework:
o  Call kdb_enter() instead of Debugger().
2004-07-10 20:56:43 +00:00
Warner Losh
dfbaec0a6d Make the default memory range in the top 2GB of ram in the hopes that
this more accurately reflects what the underlying hardware of most
acpi machines that don't have children pci busses.

We still need a better way to get this information from acpi/hardware.
2004-07-04 16:23:25 +00:00
Nate Lawson
5a66986def Remove duplicate FreeBSD id. 2004-07-02 20:15:53 +00:00
Nate Lawson
99eb9c8b3b Get rid of the strict aliasing error by retrieving the ECDT via a table
header pointer and then casting it to the ecdt pointer.  This fixes the
-O2 build.  I'm unsure what changed recently to reveal this error since
this code has been unchanged for months.
2004-07-02 19:17:27 +00:00
Warner Losh
d9aa98f83b 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.
2004-07-01 17:21:18 +00:00
John Baldwin
39981fed82 Trim a few things from the dmesg output and stick them under bootverbose to
cut down on the clutter including PCI interrupt routing, MTRR, pcibios,
etc.

Discussed with:	USENIX Cabal
2004-07-01 07:46:29 +00:00
Nate Lawson
b0eefa38f9 Rework the code that waits for a response from the EC. Use an sx lock
instead of a mutex so we do not unblock it in msleep().  If we do this,
another event could occur, resetting the status register since reads
reset it.  While I'm here, remove the backoff approach.  Instead, sleep
in 10 ms chunks for up to the configured timeout using either DELAY (if
we aren't booted yet) or tsleep.

Help from:	dillon
Tested by:	Andrew Thompson andy AT fud.org.nz
2004-07-01 00:51:31 +00:00
Nate Lawson
3309d2fbc8 Add missing function debug trace macros to the new powerres functions.
Reported by:	phk
2004-06-30 20:31:13 +00:00
Warner Losh
0363a12688 Hide struct resource and struct rman. You must define
__RMAN_RESOURCE_VISIBLE to see inside these now.

Reviewed by: dfr, njl (not njr)
2004-06-30 16:54:10 +00:00
Nate Lawson
d4b9ff9179 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).
2004-06-30 16:08:03 +00:00
Nate Lawson
d3b9d3d1d7 Add a method for referencing/switching power resources based on _PRW.
This brings us into line with the standard, which requires power resources
be enabled when wake is enabled for a given device.  Move the dereferencing
code into its own function, +acpi_pwr_dereference_resource().
2004-06-30 16:02:40 +00:00
Nate Lawson
340a7f6a9b Disable the EC GPE in the shutdown path. This is correct but is not known
to fix any bug.
2004-06-30 16:00:20 +00:00
Nate Lawson
346eda4f40 Diff reduction for style. 2004-06-30 15:10:02 +00:00
Nate Lawson
89fb5af803 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().
2004-06-30 04:49:54 +00:00
Nate Lawson
1bf4426682 Add the table quirk matching code. It matches rules defined in acpi_quirks
and sets the flags.  It also calls the machdep quirk code first.  This
allows table quirks (or whitelists) to override machdep quirks.
2004-06-30 04:45:32 +00:00
Nate Lawson
1a26ea7f2c Add machdep quirks functions. On i386, this disables acpi on systems with
BIOS dates earlier than Jan 1, 1999.  Add prototypes and quirks flags.
2004-06-30 04:42:29 +00:00
Nate Lawson
0e01bb0580 Staticize acpi_MatchHid() and include acpi_if.h 2004-06-29 19:03:50 +00:00
Nate Lawson
5fcc8a587e Use the acpi_id_probe() method instead of acpi_MatchHid(), which is now
static.
2004-06-29 19:02:27 +00:00
Nate Lawson
ce619b2e38 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.
2004-06-29 19:00:36 +00:00
Nate Lawson
d13e5a4065 Add acpi methods for HID/CID probing, evaluating objects, and walking the
namespace.  This is to allow decoupling of attachments from ACPI where they
need some functionality when ACPI is present but do not want to require ACPI
to always be loaded.
2004-06-29 18:56:14 +00:00
Nate Lawson
8c541590b6 Use a default of the FADT for matching CreatorId quirks. Use XSDT to mean
"match either RSDT or XSDT."
2004-06-29 14:32:06 +00:00
Nate Lawson
c796e27ba8 Include isa/pnpvar.h and remove a duplicate copy of PNP_EISAID. 2004-06-29 01:33:35 +00:00
Nate Lawson
636af3826f While booting, use DELAY() for waiting for the EC to respond instead of
msleep().  Until we're finally up, msleep is a no-op.

Explained by:	peter
2004-06-28 20:41:30 +00:00
Warner Losh
ed67d9de40 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
2004-06-28 03:36:37 +00:00
Warner Losh
a323657048 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
2004-06-27 13:04:19 +00:00
Nate Lawson
bef5734687 Update some comments and remove non-standard notation. 2004-06-24 06:37:23 +00:00
Nate Lawson
e008d0c51c Add a quirks array based on matching ACPI tables. The entries in this file
are currently all bad BIOS revisions that will never be able to support
ACPI.  They were derived by examining which BIOS's are blacklisted by other
operating systems.  Other types of quirks will be possible here as well.
2004-06-24 06:27:05 +00:00
Nate Lawson
30d577a014 Attach the correct handle, not the one that was just deleted. Also,
remove some duplicated code.
2004-06-24 01:57:31 +00:00
Nate Lawson
80f0e4c265 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.
2004-06-24 00:48:45 +00:00
Nate Lawson
4a03551ddd Use uintmax_t for CPU statistics and add a cast to prevent truncation of
the statistics in a multiply.

Pointed out by:	YONETANI Tomokazu
2004-06-24 00:38:51 +00:00
John Baldwin
95957f6256 - 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)
2004-06-23 17:21:02 +00:00
John Baldwin
81bb99d26b Now that we associate a device_t with ACPI device handles, lookup the
device associated with any PCI devices that are enumerated in the ACPI
tree when adding children to an ACPI PCI bus and remove the duplicate
ACPI-only device_t and replace the device_t associated with the handle with
the ACPI and PCI aware device_t.
2004-06-23 15:08:40 +00:00
Christian Brueffer
889608790b Fix typos and add spaces before `(' in some comments
Submitted by:	markus
Approved by:	njl
MFC after:	3 days
2004-06-22 08:23:26 +00:00
Nate Lawson
3e7fa136ea Add more precision to the cx_usage sysctl output and special-case 0%.
Submitted by:	YONETANI Tomokazu <qhwt+freebsd-acpi AT les.ath.cx>
2004-06-19 02:27:23 +00:00
Nate Lawson
98910d5551 Remove compat code and unused lock declarations. 2004-06-18 17:58:11 +00:00
Nate Lawson
c5fe3c3311 Remove compat defines. 2004-06-18 17:56:45 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
John Baldwin
522542cc9c Revert the removal of the initial_irq hack for now as this code is more
broken than I thought and doesn't do a good job of routing virgin
interrupts at all.
2004-06-14 18:54:14 +00:00
Nate Lawson
59e472e952 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.
2004-06-14 04:37:45 +00:00
Nate Lawson
b82ca9a91f Clean up acpi_probe_order() a bit and clarify some comments. 2004-06-14 04:01:12 +00:00
Nate Lawson
f504b6074b Don't probe/attach in the ACPI_DEBUG case. 2004-06-14 03:52:19 +00:00
Nate Lawson
9123341378 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.
2004-06-13 22:52:30 +00:00
Nate Lawson
59a890e6a3 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.
2004-06-13 17:29:35 +00:00
Nate Lawson
1f36889f63 Remove accidental change. 2004-06-07 21:44:01 +00:00
Nate Lawson
45e556cc69 Avoid printing extraneous warning messages when trying to switch a device
which doesn't support ACPI power states.  Return AE_NOT_FOUND for these
cases and don't print the warning message.  Also, print the name of the
handle instead of device when unable to switch states.  The device is often
not attached at this point and so its name is NULL, which doesn't help
debugging.
2004-06-07 21:39:15 +00:00
John Baldwin
4dc4ea2604 - Use PCI_INVALID_IRQ macro rather than a magic number.
- Remove obsolete comment about APIC_IO routing.
2004-06-07 17:36:22 +00:00
Nate Lawson
0e4148688c Don't forget to pass shutdown events down to children first now that we
handle them at the bus level too.
2004-06-05 09:56:04 +00:00
Nate Lawson
169b539a33 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.
2004-06-05 07:25:58 +00:00
Nate Lawson
a2afe45a8a Rework acpi_cpu_idle() to select the next idle state before sleeping, not
after.  Unify the paths for all Cx states.  Remove cpu_idle_busy and
instead do the little profiling we need before re-enabling interrupts.
Use 1 quantum as estimate for C1 sleep duration since the timer interrupt
is the main reason we wake.

While here, change the cx_history sysctl to cx_usage and report statistics
for which idle states were used in terms of percent.  This seems more
intuitive than counters.  Remove the cx_stats structure since it's no
longer used.  Update the man page.

Change various types which do not need explicit size.
2004-06-05 07:02:18 +00:00
Peter Wemm
f2b6954343 Work around the preemption problem in acpi_cpu.c for shutting down.
Submitted by:  nate / jhb
2004-06-04 17:03:18 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +00:00
Nate Lawson
2b9609ab9b Decrease sleep_delay default to 1 second now that the machines that
required the 5 second delay have been fixed.
2004-05-29 05:34:04 +00:00
Nate Lawson
5acd02180c Style cleanups, don't set the device description before the probe routine
has completed successfully.
2004-05-29 04:32:50 +00:00
John Baldwin
91c14f698c Don't assume that the current setting (_CRS) of a PCI link device is
correct.  Instead, check it against the possible settings (_PRS) when
the link is probed.  This is important when using APIC mode but link
devices still have PIC mode settings.  This is also what Linux does.

Additional prodding by:	Len Brown len dot brown at intel dot com
2004-05-28 17:31:32 +00:00
Nate Lawson
e3aa81b84d Style fixes. 2004-05-28 16:38:37 +00:00
Nate Lawson
043498df33 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.
2004-05-28 07:16:52 +00:00
Nate Lawson
54af2f27c7 Style cleanups. "extern" is unneeded for function prototypes. 2004-05-28 07:15:55 +00:00
Nate Lawson
cc85c78ce3 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.
2004-05-28 07:04:09 +00:00
Nate Lawson
44b8ae7193 Pass a pointer to the sleep state instead of casting gymnastics to pass
the value itself in the pointer.
2004-05-28 06:32:16 +00:00
Nate Lawson
5c9ea25e69 Fix paste-o. 2004-05-28 06:29:30 +00:00
Nate Lawson
88a79fc05b 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
2004-05-28 06:28:55 +00:00
Marcel Moolenaar
80c74f3d56 Fix LP64 environments: cast a pointer type to intptr_t before casting
to int and vice versa.
2004-05-28 02:50:43 +00:00
Nate Lawson
e8b4d56eb5 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.
2004-05-27 18:38:45 +00:00
Nate Lawson
841caa96b4 Enable GPE at runtime rather than suspend time. This is to match the
new behavior in ACPI-CA that defers GPE configuration.  This is a temporary
measure while reworking the GPE interface.
2004-05-25 16:17:39 +00:00
Nate Lawson
09a98d8ce9 Remove call to _INI for thermal devices. ACPI-CA now calls _INI for
Devices, ThermalZones, and Processors.
2004-05-25 04:18:22 +00:00
Nate Lawson
f3fc4f8b4a 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.
2004-05-25 02:47:35 +00:00
Nate Lawson
12957d4991 Revert the previous commit. The bus accessor macros do not check the
return value for BUS_READ_IVAR and thus don't generate the proper NULL
in cases where a device (i.e. on PCI) does not have a handle.

Found by:	peadar, tjr
2004-05-22 17:19:59 +00:00
Nate Lawson
14e2b11f18 Use the simpler __BUS_ACCESSOR macros for ivars instead of defining them
ourselves.
2004-05-18 16:53:29 +00:00
Nate Lawson
0025fb0f4f Add support for GPE being a package of { reference, gpe bit }.
Rework the ECDT probe to pass all the parameters in a temporary struct.
Note why we are mostly ok evaluating _GLK so early.
2004-05-14 04:17:56 +00:00
Nate Lawson
c868ac7d12 Add support for retrieving _GLK in the ECDT probe. Now we no longer always
use the global lock at the beginning of the ECDT probe.  Instead, we use
the handle from the ECDT to call _GLK.  Also, unify the device description.
2004-05-13 03:17:08 +00:00
John Baldwin
fb0ac5433b If an ACPI PCI-PCI bridge doesn't have a _PRT object, fall back to using
the swizzle method for routing PCI interrupts across the bridge.  This
fixes problems with motherboards (typically laptops) whose BIOS doesn't
provide a PRT for the AGP bridge even though there is a device entry for
the bridge in the ACPI namespace.

Tested by:	Kenneth Culver culverk at sweetdreamsracing dot biz
2004-05-10 18:26:22 +00:00
Nate Lawson
ccc09458fa Change hw.acpi.cpu.cx_lowest to accept values in the form of C1,
C2, ...  Update power_profile to use the new format.  Update the
man page to reflect this and give more info on Cx states.
2004-05-07 05:22:38 +00:00
Nate Lawson
b0e2b625f2 Rename acpi_cpu to cpu. Change the probe routine to early on reject
devices it cannot attach to.  This gets rid of extraneous but harmless
device_probe_and_attach() errors.  While I'm here, make the device
description more useful.  The !acpi case for cpu is handled by legacy0.
2004-05-06 17:25:23 +00:00
Nate Lawson
ea27c63ec6 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.
2004-05-06 08:04:34 +00:00
Nate Lawson
2fb3498126 Add back sys/reboot.h which is needed. 2004-05-06 02:57:24 +00:00
Nate Lawson
869ec176fc Make unnecessary globals static and remove unused includes.
Pointed out by:	cscout
2004-05-06 02:18:58 +00:00
Nate Lawson
7e639165c2 Fix setting debug strings via sysctl. Also, clean up the way we print
debug strings.
2004-05-06 02:05:45 +00:00
Nate Lawson
c8dd768173 Remove extra parentheses. 2004-05-05 20:07:52 +00:00
Nate Lawson
65a7c90189 Add an MI implementation of the ACPI global lock routines and retire the
individual asm versions.  The global lock is shared between the BIOS and
OS and thus cannot use our mutexes.  It is defined in section 5.2.9.1 of
the ACPI specification.

Reviewed by:	marcel, bde, jhb
2004-05-05 20:04:14 +00:00
Takanori Watanabe
d33f4987f6 Fix build breakage.
Submitted by: Xin LI <delphij@frontfree.net>
PR: 65979
2004-04-26 08:49:11 +00:00
Nate Lawson
904bf0c2f7 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.
2004-04-26 05:25:06 +00:00
Warner Losh
1c168bb710 Fix two typos from PR: 65694
1) In pci.c, we need to check the child device's state, not the parent
   device's state.
2) In acpi_pci.c, we have to run the power state change after the acpi
   method when the old_state is > new state, not the other way around.

Submitted by: Dmitry Remesov
PR: 65694
2004-04-26 02:11:38 +00:00
Nate Lawson
c0b9a6de4a Disable interrupts while testing the timer. Not doing this unnecessarily
added an arbitrary delay to our readings, causing us to use the ACPI-safe
read method when not necessary.  Submitted by: bde

Old:
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD  min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD  min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000

New:
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000

Also, reduce unnecesary overhead in ACPI-fast by remove the barrier for
reads.  The timer in the ACPI-fast case is known to increase monotonically
so there is no need to serialize access to it.
2004-04-24 16:25:00 +00:00
Philip Paeps
9a1fc77e3a Add the ACPI Asus extras driver. Provides support for cool ACPI-controled
gadgets (hotkeys, lcd, ...) on Asus laptops.  I aim to closely track the
acpi4asus project which implements these features in the Linux kernel.

If this breaks your laptop, please let me know how it does it :-)

Approved by:	njl (mentor)
2004-04-22 21:29:02 +00:00
Nate Lawson
d9b6df606a Fix stepping in ddb by not checking for a maximum interval. The ACPI-safe
workaround was for hardware where the clock was not latched, not for
hardware that was too slow.  Also, make variable names more specific for ddb
printing.
2004-04-22 01:50:08 +00:00
Nate Lawson
af807c0f33 Add comments, including restoring the PIIX4 errata comment, to indicate
what the ACPI-safe workaround is intended to fix.  Requested by phk.

Set the bushandle and tag when attaching the timer, don't do it each time
in read_counter().  Pointed out by bde.

Move test_counter() to the end.  Staticize acpi_timer_reg.
2004-04-21 18:07:21 +00:00
Nate Lawson
75988358a2 Fix several bugs where 32-bit timers and wraparound were not properly
supported.  Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:

    ACPI timer looks BAD  min = 2, max = 16777206, width = 16777204
    ACPI timer looks BAD  min = 2, max = 7, width = 5
    ACPI timer looks GOOD min = 4, max = 5, width = 1
    ACPI timer looks BAD  min = 2, max = 16777206, width = 16777204
    ACPI timer looks BAD  min = 2, max = 7, width = 5
    ACPI timer looks BAD  min = 2, max = 16777210, width = 16777208
    ACPI timer looks BAD  min = 4, max = 16777189, width = 16777185
    ACPI timer looks GOOD min = 4, max = 5, width = 1
    ACPI timer looks BAD  min = 2, max = 7, width = 5
    ACPI timer looks BAD  min = 4, max = 16777189, width = 16777185

To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
  bit timers and wraparound.

Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround.  The timecounter testing code has
  been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
Nate Lawson
8d01ceefd8 Remove extran parens. 2004-04-21 00:38:54 +00:00
Nate Lawson
eea17c34cd 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.
2004-04-21 00:36:15 +00:00
Nate Lawson
43813837ed Style fixes. 2004-04-20 17:13:08 +00:00
Nate Lawson
0b84952197 Allow the AC adapter device to be disabled with debug.acpi.disable="acad".
Even though documented, this option was never enabled even in rev 1.1.

Submitted by:	sos
2004-04-20 13:09:17 +00:00
Nate Lawson
4ed2b85d66 Add a temporary workaround for acpi_AppendBufferResource() returning with
a NULL crsbuf pointer.  This shouldn't happen if it returns AE_OK.  We'll
figure out why this is happening later.

Submitted by:	Bruno Ducrot <ducrot@poupinou.org>
2004-04-19 17:52:20 +00:00
Nate Lawson
a50f2c9f42 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.
2004-04-16 16:27:37 +00:00
Nate Lawson
a34ec6cdf6 Return an error immediately if asked to switch a non-existent consumer. 2004-04-14 17:58:19 +00:00
Nate Lawson
865b8d0bfd Remove a non-variable static and move other static variables to the same
location.
2004-04-14 17:48:33 +00:00
Nate Lawson
dfd36c130b Fix some warnings by commenting out unused code. 2004-04-14 17:47:42 +00:00
Nate Lawson
916dc0e20c Only try to set the ACPI power state if the handle is valid. There was
probably no problem with this except it may have had the side effect of
registering a NULL consumer.
2004-04-14 17:46:21 +00:00
Nate Lawson
0f4f8be30d Unbreak the DDB build by replacing #includes that were deleted.
Pointed out by:	Tai-hwa Liang, Xin LI
Pointed hat to:	njl
2004-04-14 16:24:28 +00:00
Nate Lawson
a3924cd9b4 Style cleanups, M_ZERO instead of bzero. 2004-04-14 03:45:20 +00:00
Nate Lawson
e4a5123464 Style cleanups, use M_ZERO instead of bzero, unify the !semaphore and
semaphore return paths.
2004-04-14 03:43:06 +00:00
Nate Lawson
e6f06f99f6 Style cleanup, plus properly backup partial resource allocation in
AcpiOsInstallInterruptHandler() in the case of failure to initialize.
2004-04-14 03:41:06 +00:00
Nate Lawson
c871a6da4c Style cleanups to reduce diffs to locking tree. 2004-04-14 03:39:08 +00:00
Nate Lawson
ea6b2bc923 Style and printf message cleanups. 2004-04-14 03:34:11 +00:00
Nate Lawson
c2b3a864be Use TRUE for a boolean and a style nit. 2004-04-14 03:30:09 +00:00
Nate Lawson
b7d13479aa Update the name for edge triggered for the 20040402 import. 2004-04-14 02:20:35 +00:00
Nate Lawson
881c6e063e Remove a check for the return value added in rev 1.41. It's not an error
to fail to turn off a fan, since the case is that it's usually already off.
2004-04-12 05:04:47 +00:00
Nate Lawson
64278df5e0 Add MODULE_DEPEND entries so some of these drivers can eventually be
loaded separately from ACPI (i.e., embedded use).
2004-04-09 18:14:32 +00:00
Warner Losh
cd8b53ed2d Omnibus PCI commit:
o Save and restore bars for suspend/resume as well as for D3->D0
	  transitions.
	o preallocate resources that the PCI devices use to avoid resource
	  conflicts
	o lazy allocation of resources not allocated by the BIOS.
	o set unattached drivers to state D3.  Set power state to D0
	  before probe/attach.  Right now there's two special cases
	  for this (display and memory devices) that need work in other
	  areas of the tree.

Please report any bugs to me.
2004-04-09 15:44:34 +00:00
Nate Lawson
aa95c5b148 Replace more ad-hoc versions of acpi_GetReference(). Since the type of
Reference objects changed from ACPI_TYPE_ANY to ACPI_TYPE_LOCAL_REFERENCE
in Oct. 2002, this may help systems where switching the cooler on failed.
We support both types for now until this sorts out.
2004-04-09 06:55:50 +00:00
Nate Lawson
4a74bb97ed Include the prototype for acpi_GetReference. 2004-04-09 06:53:50 +00:00
Nate Lawson
074a57f560 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.
2004-04-09 06:40:03 +00:00
Nate Lawson
a4ecd54325 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.
2004-04-08 16:45:12 +00:00
John Baldwin
5233e9ffda Implement an ACPI-aware pci_set_powerstate() method for PCI busses that
are enumerated in the ACPI device tree.  In addition to the normal PCI
powerstate functionality, the ACPI _PSx methods are executed and ACPI
PowerResources are switched on and off via the acpi_pwr_switch_consumer()
function.

Glanced at by:	imp, njl
2004-04-07 19:42:21 +00:00
Nate Lawson
5eb09c7066 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.
2004-04-01 04:21:33 +00:00
Nate Lawson
63600cc345 Staticize pnp methods, style fixes. Remove unused variable to unbreak
kernel build.
2004-03-31 17:35:28 +00:00
Takanori Watanabe
cd284d7a6a Add ACPI path in location string for ACPI namespace aware PCI device. 2004-03-31 17:27:19 +00:00
Nate Lawson
72ad60ada4 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:
2004-03-31 17:23:46 +00:00
Takanori Watanabe
247648affb Style fix.
Pointed out by: njl
2004-03-31 17:21:14 +00:00
Nate Lawson
c9b8d77d80 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.
2004-03-30 07:35:18 +00:00
Takanori Watanabe
879d6c2306 Add ACPI PnP string. This affects devinfo(8) output with -v option. 2004-03-27 16:26:00 +00:00
Nate Lawson
e548abe75b Use the correct length for appending an extended irq resource. This may
have broken APIC routing.  This bug has been present since rev 1.33.
2004-03-22 20:39:20 +00:00
Nate Lawson
3dc52520c4 Shorten some printfs to fit better. No other functional changes. 2004-03-22 20:36:33 +00:00
Nate Lawson
3304735dd9 Whitespace and comment changes. No MD5 change to the object file. 2004-03-22 20:32:27 +00:00
Nate Lawson
8e1624b6f8 Fix loop termination condition for parsing resources in _PRS buffers.
This completes the effort to handle dependent functions, which are used
in some machines for irq link resources.  Also, clean up some nearby
comments while I'm at it.
2004-03-20 20:47:08 +00:00
Nate Lawson
eeb3a05f9a 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.
2004-03-19 07:05:01 +00:00
Nate Lawson
413081d79d 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.
2004-03-18 18:42:22 +00:00
Nate Lawson
d19b6e67ac Support the DPF (start dependent function) resource type in parsing _PRS.
This should fix this error people get attaching cardbus controllers:

    pcib0: _PRS resource entry has unsupported type 2
2004-03-18 02:33:58 +00:00
Nate Lawson
e5ada020f1 Fix border error to allow systems that specify 100 for latency also use
C2 and 1000 to use C3.

Submitted by:	Bruno Ducrot <ducrot@poupinou.org>
Tested by:	Scott Lambert <lambert@lambertfam.org>
2004-03-17 21:49:47 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Nate Lawson
dba55fa26d Simplify some logic in converting a buffer to an integer. 2004-03-09 05:44:47 +00:00
Nate Lawson
cc58e4ee5e Use an unsigned int instead of an int for the Get/Set Integer interface.
Pointed out by:	le
2004-03-09 05:41:28 +00:00
Nate Lawson
08b994c07e Document a sysctl.
Submitted by:	Craig Rodrigues <rodrigc@crodrigues.org>
2004-03-05 18:08:23 +00:00
Nate Lawson
9db195a8d1 A user can set tz_requested via the hw.acpi.thermal.tzX.active sysctl.
The previous logic meant that if a user sets it to a minimal cooling value
acpi_thermal will not use higher cooling levels.  Reverse the logic so that
the user requesting a level (say, 2) also gets 0 - 1 also.

PR:		kern/61592
Submitted by:	Andrew Thompson <andy@fud.org.nz>
2004-03-05 18:06:31 +00:00
Nate Lawson
4ed391b8d7 Fix an off-by-one error and rework our EC space handler. Writing to address
0xFF would fail previously as AE_BAD_PARAMETER.  It's unknown if this caused
any actual problems.
2004-03-04 05:58:50 +00:00
Nate Lawson
c181b89bc1 Don't disable Cx support and throttling on machines with a P_BLK_LEN != 6
even though the spec mandates this.  Some have a value of 5 to indicate
throttling + C2 and some have 7 to indicate an extra C3 state.  Support
throttling if the value is >= 4, C2 for >= 5, and C3 for >= 6.
2004-03-04 05:17:52 +00:00
Nate Lawson
4e376d58dc 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.
2004-03-04 04:42:59 +00:00
Nate Lawson
c310653ea1 Change to acpi_{Get,Set}Integer to provide both methods. Convert all
callers to the new API.

Submitted by:	Mark Santcroos <marks@ripe.net>
2004-03-03 18:34:42 +00:00
Nate Lawson
3184cf5a6b 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.
2004-03-03 03:02:17 +00:00
Nate Lawson
c58375c3a5 Add the ACPI standard video extensions driver. I've done some style cleanup
but a bit more reamins to be done.  For now, it is usable.

Submitted by:	Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
2004-03-01 08:12:56 +00:00
Nate Lawson
2881b39793 Call _INI on Thermal Zones as well as devices. 2004-02-28 22:43:18 +00:00
Poul-Henning Kamp
dc08ffec87 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.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
c9c7976f7f 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.
2004-02-21 19:42:58 +00:00
Nate Lawson
abcbc5bc60 Use ACPI_NEXT_RESOURCE instead of defining our own copy. The one provided
with ACPI-CA is identical now.
2004-02-19 18:20:03 +00:00
Nate Lawson
bb949efb95 Do not remove the fixed handlers. Several systems (e.g., ASUS) only
return events on the fixed handler even after defining a duplicate in the
AML.  While this violates the spec, hopefully we can get by with leaving
both installed.
2004-02-19 18:16:34 +00:00
Nate Lawson
968c0e1bf4 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.
2004-02-19 05:35:20 +00:00
Nate Lawson
d3e1c2411e Fix hw.acpi.os_name by renaming it to hw.acpi.osname. The "_name" suffix
is reserved by the loader, and thus any tunable name with that suffix will
be silently discarded.

Document this in the header and man page so that other developers do not
develop so many bumps on the head after banging it against the wall.

Detective work by:	Mark Santcroos, grehan
2004-02-14 03:17:30 +00:00
John Baldwin
e4a87c455e Fix a whitespace nit. 2004-02-12 20:45:01 +00:00
Nate Lawson
33febf93d6 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:
2004-02-11 02:57:33 +00:00
Philip Paeps
1527dcc82e Make all ACPI debug layers unique again. This makes debugging a more
pleasant experience (for certain definition of 'pleasant').

Submitted by:	Mark Santcroos <marks@ripe.net>
Approved by:	njl (mentor)
2004-02-06 19:38:05 +00:00
Nate Lawson
526785c638 Notify the user (at kern.emerg) that the system will be shutting down if
it is still above the critical temperature on the next poll cycle.  This
is a 10 second advance notice by default.  Document the private
(non-standard) notify we will be using with devd(8).
2004-02-03 04:18:56 +00:00
Nate Lawson
322141f1e2 If the temperature is at _HOT or _CRT for 3 sequential readings, shutdown
the system.  Also, decrease the poll interval to 10 seconds from 30
seconds.  This is needed because some systems will report an invalid high
temperature for one poll cycle.  It is suspected this is due to the
embedded controller timing out.  A typical value is 138C for one cycle on a
system that is otherwise 65C.  This prevents the system from prematurely
shutting down after one invalid reading.  It will still shut down after 30
seconds of high temperature, which is the same as previous default
behavior.

Tested by:	Scott Lambert <lambert AT lambertfam.org>
2004-02-02 18:03:35 +00:00
Peter Pentchev
1b8c233de3 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
2004-01-28 07:48:03 +00:00
Nate Lawson
e0ccb58ad9 Add TUNABLE_STR to make "hw.acpi.os_name" more correct. However, the call
to getenv_string() still doesn't work.
2004-01-27 06:07:09 +00:00
John Baldwin
bbc2815c8d 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
2004-01-26 19:29:04 +00:00
John Baldwin
1aa9b61068 Use getenv_int() rather than reimplementing it. 2004-01-20 21:38:48 +00:00
John Baldwin
0657fe7356 Add a component constant for ACPI_TOSHIBA to fix compilation of
acpi_toshiba(4) driver with ACPI_DEBUG and thus fix LINT on i386.
2004-01-13 21:27:50 +00:00
Nate Lawson
5ce6805764 Bite the bullet and uncomment the shutdown() in case we hit the _CRT or
_HOT temperatures.  We have to do this at some point to keep from getting
imp(tm) melted hardware.
2004-01-12 17:59:10 +00:00
Nate Lawson
2ccd1cac95 Clean up the acpi announce message of trailing spaces. 2004-01-09 21:04:28 +00:00
Nate Lawson
25611cfe97 Expand the check for overriding the OS name to override _OS* (including
_OS_, _OS, and _OSI).  This should fix this option for people who reported
it not changing anything.
2004-01-09 20:01:42 +00:00
Nate Lawson
16844a97c8 Delete the region we are passed if that is the requested operation.
This should fix the problem with removing an address space handler
although we don't currently use that capability so it's unlikely anyone
saw this problem.
2004-01-03 02:01:39 +00:00
Nate Lawson
3fb343ac12 Use the appropriate values for the notifies. No change in behavior
since both notifies result in the same function being called.

Found by:	documenting the code
2003-12-31 19:11:19 +00:00
Nate Lawson
5016979369 Don't attach throttling if the P_BLK is 0, even if the P_BLK_LEN is 6.
This is more strict but no known systems have this problem.
2003-12-28 22:15:24 +00:00
John Baldwin
c59c9a8e1c Fix acpi_MatchHid() to check the compatibility ID's if the hardware ID
doesn't match.

Submitted by:	marcel
2003-12-26 15:42:13 +00:00
Nate Lawson
bd189fe7fa Fix locking broken by recent _CID changes. Always be sure to unlock
in the error case.
2003-12-23 18:47:31 +00:00
Nate Lawson
8d181eb589 Update to use the new package routines instead of rolling our own
macros.
2003-12-23 18:27:35 +00:00
Nate Lawson
21cea91f6e Remove the device_t parameter from package routines that only used it to
print an error message.  Update all callers of the package routines.
2003-12-23 18:26:53 +00:00
Peter Wemm
8070ad52a1 Don't use NULL (pointer) when we're testing for a count of 0 (integer). 2003-12-23 02:29:46 +00:00
Alexander Kabaev
2b26028dce Initialize acpi buffer structs early in order to avoid freeing
unallocated pointers later in done: section.
2003-12-18 17:04:11 +00:00
Nate Lawson
0d8fb61a49 Remove power profile support from acpi_cpu, it will be managed by a
script run from devd(8).
2003-12-18 04:38:45 +00:00
Nate Lawson
1e4925e8d3 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.
2003-12-18 03:25:22 +00:00
Nate Lawson
b279c35a4f Fix throttling to use the proper mask. The bug resulted in only two
throttling values being available regardless of the CPU's capabilities.
This has been broken since rev 1.1.  Also clarify a comment.

Submitted by:	Taku YAMAMATO <taku@cent.saitama-u.ac.jp>
2003-12-12 19:42:16 +00:00
John Baldwin
4d5f2cbbd6 Trim trailing whitespace. 2003-12-10 19:10:27 +00:00
Nate Lawson
54f6bca07c Use sbufs instead of snprintf for parsing debug strings. 2003-12-09 06:29:57 +00:00
Nate Lawson
0911e271e3 Delete madt.h since definitions are now used from actbl.h 2003-12-09 03:18:06 +00:00
Nate Lawson
73a34dd424 We don't need to call _INI on processor objects now that ACPI-CA does
this as it should.
2003-12-09 03:01:54 +00:00
John Baldwin
447a5fa113 Update this driver to be more module friendly:
- Dynamically allocate the cpu_softc[] array based on mp_maxid instead of
  using a statically sized array that depended on 'options SMP'.
- Use mp_maxid rather than MAXCPU when walking all the CPUs looking for a
  match.
- Always call smp_rendezvous() since UP kernels now provide this.
- Use mp_ncpus rather than cpu_ndevices when determining if we need to
  disable C3 for SMP machines.

Approved by:	re (rwatson)
Reviewed by:	njl
2003-12-03 20:27:48 +00:00
Nate Lawson
cd1f3db9ba * If a processor's softc is NULL, use C1 since there is no ACPI
processor object for this CPU.  This occurs for logical CPUs which
  do not have an associated processor object (e.g., HTT).

Approved by:	re (rwatson)
2003-11-27 16:32:46 +00:00
Nate Lawson
b6426963c4 * Add acpi_pcpu_get_id(idx, *acpi_id, *cpu_id) which fetches the
idx'th present CPU with pc_acpi_id equal to *acpi_id.  If *acpi_id
  does not match that processor's pc_acpi_id, return the value for
  ProcId derived from the MADT in *acpi_id.  If pc_acpi_id is 0xffffffff,
  always override it with the value of *acpi_id.  Finally, return
  pc_cpuid in *cpu_id and use that as our primary key.

* Use pc_cpuid as our unique key because we know it is valid since
  MD code set it.  The values for ProcId in the ASL and MADT don't
  match up on some machines (!), forcing us to fall back to ordered
  probing in that case.

* Remove some #ifdef SMP since the refcount doesn't hurt performance
  and will be needed for dynamic _CST objects.  Only one #ifdef SMP
  (for smp_rendezvous) remains.

* Hook up SMP in the compile flags in the Makefile.

Tested by:	marcel, truckman
Approved by:	re (scottl)
2003-11-26 19:01:33 +00:00
John Baldwin
3500189b0e Fix a typo in my patches to support extended IRQ resources that broke the
type checking for _PRS for a link device's interrupt resources.

Approved by:	re (scottl)
2003-11-20 22:21:51 +00:00
John Baldwin
d784bc82f2 Try all of the possible interrupts for a link device when programming
boot-disabled devices instead of skipping the last interrupt.  This is
especially important for devices that only have one interrupt as this
bug was keeping any interrupt from being tried at all.

Reviewed by:	msmith
Approved by:	re (scottl)
2003-11-20 21:23:49 +00:00
Nate Lawson
56a70eadf5 * 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)
2003-11-19 20:27:06 +00:00
Nate Lawson
6b74f9b7f5 Implement Cx CPU idle states and updated throttling support.
* Use the cpu_idle_hook() to do idling for C1-C3.
* Use both _CST and the FADT to detect Cx states.
* Use both _PTC and P_CNT for controlling throttling.
* Add a notify handler to detect changes in _CST and _PSS
* Call the _INI function for each processor if present.  This will be
  done by ACPI-CA in the future.
* Fix a bug on SMP systems where CPUs will attach multiple times if the
  bus is rescan.
* Document new sysctls for controlling idling.
2003-11-15 19:26:06 +00:00
Nate Lawson
b5049ddbf0 Add acpi_package.c with routines for validating packages and pulling
various data types from them.  This is loosely based on the acpi_cmbat
macros (by Mike Smith) and will eventually replace them.
2003-11-15 19:20:46 +00:00
Nate Lawson
dc75086936 Add acpi_bus_alloc_gas() for allocating a memory or IO resource from its
Generic Address Structure.
2003-11-15 19:18:29 +00:00
John Baldwin
3d9644ef0b Improve support for extended IRQ resources:
- For acpi_pci_link_entry_dump(), add a few helper functions to display
  the trigger mode, polarity, and sharemode of an individual IRQ resource.
  These functions are then called for both regular and extended IRQ
  resources.
- In acpi_pci_link_set_irq(), use the same type of IRQ resource
  (regular vs. extended) for the new current resource as the type of
  the resources from _PRS.
- When routing an interrupt don't ignore extended IRQ resources.  Also,
  use the same type of IRQ resource (regular vs. extended) for the new
  current resource when as the type of the resource from _PRS.

Tested by:	peter
2003-11-14 21:36:09 +00:00
John Baldwin
68cb89dc06 Fix some typos. 2003-11-12 19:46:17 +00:00
John Baldwin
284739a942 Reindent to non-style(9) compliant 4 space indent to match rest of file. 2003-11-12 16:24:16 +00:00
John Baldwin
07f0d09e81 Add an ACPI_FUNCTION_TRACE() invocation to acpi_OverrideInterruptLevel()
to fix compile with ACPI_DEBUG.

Reported by:	tinderbox
2003-11-12 16:23:21 +00:00
John Baldwin
801cc576ec Add an acpi_OverrideInterruptLevel() method that OSPM can use to override
the InterruptLevel used for the SCI.
2003-11-11 18:12:12 +00:00
Nate Lawson
9b937d4836 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.
2003-10-25 05:03:25 +00:00
Nate Lawson
5539804740 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.
2003-10-19 05:56:59 +00:00
Nate Lawson
8525ffefc2 If requested to Sleep for less than our hz granularity (e.g., 10 ms),
use DELAY instead of tsleep.

Submitted by:	peter
2003-10-02 05:09:37 +00:00
Nate Lawson
ae0781a1cb Revert 1.24. It causes a hang on shutdown for Marcel. This is due to
AcpiEnterSleepState() calling a long AcpiOsStall() with interrupts
disabled.  This fix will instead be added to ACPI-CA.

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
2003-09-30 19:12:37 +00:00
Nate Lawson
b22df41bbd If asked to stall for more than 100 us (which is specified as the max in
the ACPI standard), call sleep instead since that is probably what the
caller meant.

Mentioned by:		peter
2003-09-29 07:29:26 +00:00
Nate Lawson
1d7b121ca4 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.
2003-09-26 21:22:10 +00:00
Nate Lawson
656b9dd5c3 Consistently print attach messages. 2003-09-26 05:24:55 +00:00
Nate Lawson
297835bcd5 Sort debugging levels and update the man page to match reality. Also
update man page to reflect iasl(8) import.
2003-09-26 04:32:40 +00:00
Nate Lawson
a6a1d01594 Fix the ACPI_DEBUG case.
Reported by:	Larry Rosenman <ler@lerctr.org>
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
2003-09-22 04:50:29 +00:00
Poul-Henning Kamp
d2f243d06a Make this compile. 2003-09-21 18:54:52 +00:00
Nate Lawson
be8dca590c Add support for fixed event buttons defined in the DSDT (HID "ACPI_FSB"
and "ACPI_FPB").

Pointed out by:		Linux
2003-09-21 02:49:59 +00:00
Nate Lawson
6c0e8467af Add necessary newlines. 2003-09-18 05:12:45 +00:00
Nate Lawson
a0e5a00957 Shorten the message announcing fixed power/sleep buttons. 2003-09-18 05:01:03 +00:00
Mitsuru IWASAKI
526b5e659d Add pci_resume() to reestablish interrupt routing after
suspend/resume.
Especially after hibernation, interrupt routing went back to initial
status on some machines.
2003-09-17 08:32:44 +00:00
Nate Lawson
c87cfaedf2 Bump the EC timeout from 50 to 100 ms. I believe the underlying issue is
global lock contention as symptoms only appear under heavy load (i.e. the
nightly periodic run).
2003-09-15 21:20:55 +00:00
Nate Lawson
2d610c4638 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.
2003-09-15 06:29:31 +00:00
Nate Lawson
5f7e1e2f82 Print notify values as hex. 2003-09-14 17:47:44 +00:00
Nate Lawson
64fdad2352 Add the -i flag to acpiconf(8) to retrieve battery information.
Rename a few structure elements.
2003-09-13 20:13:01 +00:00
Nate Lawson
5c5967082f Add a system notify handler in addition to the device notify handler.
At least some Toshiba notebooks use a Notify of 0 or 1 for this.

PR:
Submitted by:	Hiroyuki Aizu <aizu@navi.org>
2003-09-11 03:17:33 +00:00
Marcel Moolenaar
24752c4291 Extend the ACPI resource handling to make use of the BUS_CONFIG_INTR()
method. This is necessary on ia64 where it's known that serial interfaces
described in the ACPI namespace may not have the well-known IRQs assigned
to them. This confuses us in thinking they are PCI based interrupts and
wrongly program the APIC.
2003-09-10 22:06:41 +00:00
John Baldwin
42a12b2bd8 Move the definitions for ACPI MADT table entries not present in the ACPICA
distribution to a MI header so it can be shared with other architectures.
2003-09-10 06:32:27 +00:00
Nate Lawson
9817561470 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.
2003-09-09 04:09:25 +00:00
Nate Lawson
f97739da4d Don't free the buffer if it wasn't actually allocated. 2003-09-04 15:55:41 +00:00
Nate Lawson
ad1fdf57d2 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.
2003-08-29 04:02:19 +00:00
John Baldwin
729d7ffbcf - Rename PCIx_HEADERTYPE* to PCIx_HDRTYPE* so the constants aren't so long.
- Add a new PCIM_HDRTYPE constant for the field in PCIR_HDRTYPE that holds
  the header type.
- Replace several magic numbers with appropriate constants for the header
  type register and a couple of PCI_FUNCMAX.
- Merge to amd64 the fix to the i386 bridge code to skip devices with
  unknown header types.

Requested by:	imp (1, 2)
2003-08-28 21:22:25 +00:00
Nate Lawson
be2b179704 Style and whitespace changes. Also, make the ivar functions non-inline
since inlining failed due to the size of BUS_*
2003-08-28 16:06:30 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Warner Losh
cace7a2a4d Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.
2003-08-22 06:06:16 +00:00
Takanori Watanabe
f09e4e876e Update my mail address on copyright notice.
Noticed by: njl
2003-08-19 01:54:34 +00:00