Commit Graph

50 Commits

Author SHA1 Message Date
Nate Lawson
bbf7c27a9c MPSAFE locking
* Serialize calls to acpi_pcib_route_interrupt().
* Note that acpi_pcib_attach() should not be called concurrently.
2004-08-13 06:22:07 +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
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
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
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
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
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
869ec176fc Make unnecessary globals static and remove unused includes.
Pointed out by:	cscout
2004-05-06 02:18:58 +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
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
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
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
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
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
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
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
Nate Lawson
6fca9360db 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
2003-07-13 22:57:16 +00:00
John Baldwin
ebc4ae3b74 Add a missing newline to the end of a device_printf().
Reported by:	Michael G. Petry <petry@NetMasters.Com>
2002-10-29 19:08:55 +00:00
Mitsuru IWASAKI
ba835e3fe6 Add code for ACPI PCI link object manipulation.
This allocate the best IRQ to boot-disable devices (have IRQ 0).
Allocated IRQ will be used for PCI interrupt routing when ACPI is
enabled.

Note that verbose messaging enabled for the time being so that
people can easily notice the strange behavior if it happened.
2002-10-05 02:01:05 +00:00
Peter Wemm
0b57bf8a75 Fix printf format errors on 64 bit systems where sizes are long
instead of just int.
2002-10-04 00:33:46 +00:00
Peter Wemm
f144391b8f Display the name of the acpi node that we do not find the pci interrupt
routing table for.
2002-10-04 00:32:09 +00:00
John Baldwin
b8581e0d56 Now that we only probe host-PCI bridges once, we no longer have to check to
see if we have been probed before by checking for a pciX bus device.
2002-09-23 18:14:31 +00:00
John Baldwin
c6a121ab5e Make the printf messages when routing interrupts more consistent in the
various PCI bridge drivers.
2002-09-05 17:08:35 +00:00
John Baldwin
2ccfc93222 Overhaul the ACPI PCI bridge driver a bit:
- Add an ACPI PCI-PCI bridge driver (the previous driver just handled
  Host-PCI bridges) that is a PCI driver that is a subclass of the generic
  PCI-PCI bridge driver.  It overrides probe, attach, read_ivar, and
  pci_route_interrupt.
  - The probe routine only succeeds if our parent is an ACPI PCI bus which
    we test for by seeing if we can read our ACPI_HANDLE as an ivar.
  - The attach routine saves a copy of our handle and calls the new
    acpi_pcib_attach_common() function described below.
  - The read_ivar routine handles normal PCI-PCI bridge ivars and adds an
    ivar to return the ACPI_HANDLE of the bus this bridge represents.
  - The route_interrupt routine fetches the _PRT (PCI Interrupt Routing
    Table) from the bridge device's softc and passes it off to
    acpi_pcib_route_interrupt() to route the interrupt.
- Split the old ACPI Host-PCI bridge driver into two pieces.  Part of
  the attach routine and most of the route_interrupt routine remain in
  acpi_pcib.c and are shared by both ACPI PCI bridge drivers.
  - The attach routine verifies the PCI bridge is present, reads in
    the _PRT for the bridge, and attaches the child PCI bus.
  - The route_interrupt routine uses the passed in _PRT to route a PCI
    interrupt.
  The rest of the driver is the ACPI Host-PCI bridge specific bits that
  live in acpi_pcib_acpi.c.
  - We no longer duplicate pcib_maxslots but use it directly.
  - The driver now uses the pcib devclass instead of its own devclass.
    This means that PCI busses are now only children of pcib devices.
  - Allow the ACPI_HANDLE for the child PCI bus to be read as an ivar
    of the child bus.
  - Fetch the _PRT for routing PCI interrupts directly from our softc
    instead of walking the devclass to find ourself and then fetch our
    own softc.

With this change and the new ACPI PCI bus driver, ACPI can now properly
route interrupts for devices behind PCI-PCI bridges.  That is, the
Itanium2 with like 10 PCI busses can now boot ok and route all the PCI
interrupts.  Hopefully this will also fix problems people are having with
CardBus bridges behind PCI-PCI bridges not properly routing interrupts
when ACPI is used.

Tested on:	i386, ia64
2002-08-26 18:30:27 +00:00
John Baldwin
473f1ca90d In acpi_pcib_route_interrupt(), the code claims to check to see if a PCI
LNK device (interrupt source provider sort of) is present before using it,
but the code actually tested the status (_STA) of the PCI bridge device
doing the routing, not the actual LNK device.  Fix it to check the status
of the LNK device.
2002-08-26 15:12:47 +00:00
Peter Wemm
b4a052380f Brutally deal with __func__ being 'const char *' on gcc-3.1. 2002-05-19 06:16:47 +00:00
Mike Smith
0a702a9b3a Fix error introduced in the 20020217 update, where GetPossibleResources
was spammed with GetCurrentResources.

Submitted by:	Munehiro Matsuda <haro@h4.dion.ne.jp>
2002-03-21 02:02:31 +00:00
Mike Smith
c1b1f7874c Match namespace cleanup changes in ACPI CA 20020217 update.
Use ACPI_SUCCESS/ACPI_FAILURE consistently.
The AcpiGetInto* interfaces are obsoleted by ACPI_ALLOCATE_BUFFER.

Use _ADR as well as _BBN to get our bus number.
2002-02-23 05:27:49 +00:00
Mike Smith
3273b00523 Staticise devclasses and some unnecessarily global variables. 2002-01-08 06:46:01 +00:00
Doug Rabson
a067d21032 Make the interrupt routing a bit less chatty unless bootverbose is set. 2001-10-07 18:25:43 +00:00
Peter Wemm
555143d0df Fix a stack trashing bug when int != sizeof(pointer)
This fixes the ia64 boot!  We have scsi disks!
2001-10-06 03:49:38 +00:00
Mike Smith
43896e913a 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.
2001-10-04 23:21:09 +00:00
Mike Smith
4c1cdee628 Updates to match the ACPI CA 20010816 import:
- New debug macro (ACPI_DEBUG_PRINT), reducing debug-case code size.
 - New debug level/subsystem codes.
2001-08-26 22:50:15 +00:00
Mike Smith
d93b034fe9 Shoud build resources in the _CRS buffer. Oops.
Submitted by:	"neckpain@nettaxi.com" <neckpain@nettaxi.com>
2001-08-03 08:38:49 +00:00
Mike Smith
f16527bb44 The current resource buffer returned from an interrupt link device
in the case where there are no interrupts routed for it does not
contain enough space to use it to route an interrupt.  In the case
where we need to route an interrupt, throw away the returned buffer
and create a new one containing the interrupt we want.
2001-07-30 09:01:18 +00:00
Mike Smith
bfae45aa43 Convert from acpi_strerror() to AcpiFormatException()
Fix dangling include of the dear departed acpi_ecreg.h
2001-07-21 10:24:37 +00:00
Mike Smith
8077a62b9c Oops, have to use AcpiSetCurrentResources, not invoke the _SRS method
directly.
2001-07-07 10:12:06 +00:00
Mike Smith
4fa387b692 Implement PCI interrupt routing using the ACPI data attached to the
PCI bus object.  This should deal both with already-routed interrupts
as well as devices that need an interrupt routed.

Note that it *doesn't* deal with interlocked interrupt dependancies, nor
does it select between interrupt options in a smart way.  These are
optimisations that need further work.
2001-07-05 07:20:51 +00:00
Mike Smith
e71b638175 Update for new debug layer constant names in the ACPI CA 20010615
import.
2001-06-29 20:32:29 +00:00
Mike Smith
2a4ac806d7 - 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).
2001-05-29 20:13:42 +00:00
Mike Smith
91467fc61d 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.
2001-01-31 09:30:57 +00:00
Mike Smith
39a8493ac0 Hack in interrupt routing support (using the core $PIR support, not using
ACPICA properly).  This makes it possible to use ACPICA in conjunction with
CardBus before I get around to implementing ACPI/PCI interrupt routing.
2000-12-29 09:42:05 +00:00
Mike Smith
0ae554237c - 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.
2000-12-08 09:16:20 +00:00
Scott Long
3cd59d7b9c Revert attach() back to the old behaviour of calling bus_generic_attach().
The new way doesn't seem to work reliably and was causing devices to not
be seen.

Approved by:	msmith
2000-12-02 01:14:14 +00:00
Mike Smith
042283a67b 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
2000-12-01 10:18:57 +00:00
Mike Smith
15e32d5d03 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.
2000-10-28 06:59:48 +00:00