summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/boot/i386/libi386/biosacpi.c1
-rw-r--r--sys/dev/acpica/Osd/OsdDebug.c8
-rw-r--r--sys/dev/acpica/Osd/OsdHardware.c96
-rw-r--r--sys/dev/acpica/Osd/OsdStream.c4
-rw-r--r--sys/dev/acpica/Osd/OsdTable.c20
-rw-r--r--sys/dev/acpica/acpivar.h3
-rw-r--r--sys/modules/acpi/Makefile35
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c3
8 files changed, 144 insertions, 26 deletions
diff --git a/sys/boot/i386/libi386/biosacpi.c b/sys/boot/i386/libi386/biosacpi.c
index f10b006..90217c5 100644
--- a/sys/boot/i386/libi386/biosacpi.c
+++ b/sys/boot/i386/libi386/biosacpi.c
@@ -31,6 +31,7 @@
#include <bootstrap.h>
#include "acfreebsd.h"
+#define ACPI_SYSTEM_XFACE
#include "actypes.h"
#include "actbl.h"
diff --git a/sys/dev/acpica/Osd/OsdDebug.c b/sys/dev/acpica/Osd/OsdDebug.c
index 1651d25..3df9e45 100644
--- a/sys/dev/acpica/Osd/OsdDebug.c
+++ b/sys/dev/acpica/Osd/OsdDebug.c
@@ -50,7 +50,7 @@
#include <dev/acpica/acpivar.h>
UINT32
-AcpiOsGetLine(NATIVE_CHAR *Buffer)
+AcpiOsGetLine(char *Buffer)
{
#ifdef DDB
char *cp;
@@ -67,7 +67,7 @@ AcpiOsGetLine(NATIVE_CHAR *Buffer)
}
void
-AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, NATIVE_CHAR *Message)
+AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, char *Message)
{
printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
printf("ACPI: assertion %s\n", (char *)FailedAssertion);
@@ -79,7 +79,7 @@ AcpiOsSignal (
void *Info)
{
ACPI_SIGNAL_FATAL_INFO *fatal;
- NATIVE_CHAR *message;
+ char *message;
switch(Function) {
case ACPI_SIGNAL_FATAL:
@@ -90,7 +90,7 @@ AcpiOsSignal (
break;
case ACPI_SIGNAL_BREAKPOINT:
- message = (NATIVE_CHAR *)Info;
+ message = (char *)Info;
Debugger(message);
break;
diff --git a/sys/dev/acpica/Osd/OsdHardware.c b/sys/dev/acpica/Osd/OsdHardware.c
index 5897157..9eeae49 100644
--- a/sys/dev/acpica/Osd/OsdHardware.c
+++ b/sys/dev/acpica/Osd/OsdHardware.c
@@ -36,6 +36,7 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/pci_cfgreg.h>
+#include <dev/pci/pcireg.h>
/*
* ACPICA's rather gung-ho approach to hardware resource ownership is a little
@@ -155,3 +156,98 @@ AcpiOsWritePciConfiguration (
return(AE_OK);
}
+
+/* XXX should use acpivar.h but too many include dependencies */
+extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int
+ *number);
+
+/*
+ * Depth-first recursive case for finding the bus, given the slot/function.
+ */
+static int
+acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
+{
+ ACPI_HANDLE parent;
+ ACPI_OBJECT_TYPE type;
+ UINT32 adr;
+ int bus, slot, func, class, subclass, header;
+
+ /* Try to get the _BBN object of the root, otherwise assume it is 0 */
+ bus = 0;
+ if (root == curr) {
+ if (ACPI_FAILURE(acpi_EvaluateInteger(root, "_BBN", &bus)))
+ printf("acpi_bus_number: root bus has no _BBN, assuming 0\n");
+ return (bus);
+ }
+ if (ACPI_FAILURE(AcpiGetParent(curr, &parent)))
+ return (bus);
+
+ /* First, recurse up the tree until we find the host bus */
+ bus = acpi_bus_number(root, parent, PciId);
+
+ /* Validate parent bus device type */
+ if (ACPI_FAILURE(AcpiGetType(parent, &type)) || type != ACPI_TYPE_DEVICE) {
+ printf("acpi_bus_number: not a device, type %d\n", type);
+ return (bus);
+ }
+ /* Get the parent's slot and function */
+ if (ACPI_FAILURE(acpi_EvaluateInteger(parent, "_ADR", &adr))) {
+ printf("acpi_bus_number: can't get _ADR\n");
+ return (bus);
+ }
+ slot = ACPI_HIWORD(adr);
+ func = ACPI_LOWORD(adr);
+
+ /* Is this a PCI-PCI or Cardbus-PCI bridge? */
+ class = pci_cfgregread(bus, slot, func, PCIR_CLASS, 1);
+ if (class != PCIC_BRIDGE)
+ return (bus);
+ subclass = pci_cfgregread(bus, slot, func, PCIR_SUBCLASS, 1);
+ /* Find the header type, masking off the multifunction bit */
+ header = pci_cfgregread(bus, slot, func, PCIR_HEADERTYPE, 1) & 0x7f;
+ if (header == 1 && subclass == PCIS_BRIDGE_PCI)
+ bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_1, 1);
+ if (header == 2 && subclass == PCIS_BRIDGE_CARDBUS)
+ bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1);
+ return (bus);
+}
+
+/*
+ * Find the bus number for a device
+ *
+ * rhandle: handle for the root bus
+ * chandle: handle for the device
+ * PciId: pointer to device slot and function, we fill out bus
+ */
+void
+AcpiOsDerivePciId (
+ ACPI_HANDLE rhandle,
+ ACPI_HANDLE chandle,
+ ACPI_PCI_ID **PciId)
+{
+ ACPI_HANDLE parent;
+ int bus;
+
+ if (pci_cfgregopen() == 0)
+ panic("AcpiOsDerivePciId unable to initialize pci bus");
+
+ /* Try to read _BBN for bus number if we're at the root */
+ bus = 0;
+ if (rhandle == chandle) {
+ if (ACPI_FAILURE(acpi_EvaluateInteger(rhandle, "_BBN", &bus)))
+ printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n");
+ }
+ /*
+ * Get the parent handle and call the recursive case. It is not
+ * clear why we seem to be getting a chandle that points to a child
+ * of the desired slot/function but passing in the parent handle
+ * here works.
+ */
+ if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent)))
+ bus = acpi_bus_number(rhandle, parent, *PciId);
+ (*PciId)->Bus = bus;
+ if (bootverbose) {
+ printf("AcpiOsDerivePciId: bus %d dev %d func %d\n",
+ (*PciId)->Bus, (*PciId)->Device, (*PciId)->Function);
+ }
+}
diff --git a/sys/dev/acpica/Osd/OsdStream.c b/sys/dev/acpica/Osd/OsdStream.c
index 31778d6..7c9acde 100644
--- a/sys/dev/acpica/Osd/OsdStream.c
+++ b/sys/dev/acpica/Osd/OsdStream.c
@@ -34,7 +34,7 @@
#include "acpi.h"
void
-AcpiOsPrintf (const NATIVE_CHAR *Format, ...)
+AcpiOsPrintf (const char *Format, ...)
{
va_list ap;
@@ -44,7 +44,7 @@ AcpiOsPrintf (const NATIVE_CHAR *Format, ...)
}
void
-AcpiOsVprintf (const NATIVE_CHAR *Format, va_list Args)
+AcpiOsVprintf (const char *Format, va_list Args)
{
vprintf(Format, Args);
}
diff --git a/sys/dev/acpica/Osd/OsdTable.c b/sys/dev/acpica/Osd/OsdTable.c
index 58c01cd..f24c5ea 100644
--- a/sys/dev/acpica/Osd/OsdTable.c
+++ b/sys/dev/acpica/Osd/OsdTable.c
@@ -38,6 +38,26 @@
#undef _COMPONENT
#define _COMPONENT ACPI_TABLES
+static char acpi_os_name[128];
+
+ACPI_STATUS
+AcpiOsPredefinedOverride (
+ const ACPI_PREDEFINED_NAMES *InitVal,
+ ACPI_STRING *NewVal)
+{
+ if (InitVal == NULL || NewVal == NULL)
+ return(AE_BAD_PARAMETER);
+
+ *NewVal = NULL;
+ if (strncmp(InitVal->Name, "_OS_", 4) == 0 &&
+ getenv_string("hw.acpi.os_name", acpi_os_name, sizeof(acpi_os_name))) {
+ printf("ACPI: Overriding _OS definition with \"%s\"\n", acpi_os_name);
+ *NewVal = acpi_os_name;
+ }
+
+ return(AE_OK);
+}
+
ACPI_STATUS
AcpiOsTableOverride (
ACPI_TABLE_HEADER *ExistingTable,
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index e31862a..12a5a68 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -141,6 +141,8 @@ extern struct mtx acpi_mutex;
#define ACPI_INTR_APIC 1
#define ACPI_INTR_SAPIC 2
+/* XXX this is no longer referenced anywhere, remove? */
+#if 0
/*
* This is a cheap and nasty way to get around the horrid counted list
* argument format that AcpiEvalateObject uses.
@@ -168,6 +170,7 @@ acpi_AllocObjectList(int nobj)
l->count = nobj;
return(l);
}
+#endif /* unused */
/*
* Note that the low ivar values are reserved to provide
diff --git a/sys/modules/acpi/Makefile b/sys/modules/acpi/Makefile
index c8281d1..ef56d3d 100644
--- a/sys/modules/acpi/Makefile
+++ b/sys/modules/acpi/Makefile
@@ -10,29 +10,28 @@ KMOD= acpi
# ACPI CA sources
CFLAGS+= -I${.CURDIR}/../../contrib/dev/acpica
-SRCS+= dsfield.c dsmethod.c dsmthdat.c dsobject.c dsopcode.c
-SRCS+= dsutils.c dswexec.c dswload.c dswscope.c dswstate.c
-SRCS+= evevent.c evmisc.c evregion.c evrgnini.c evsci.c
-SRCS+= evxface.c evxfevnt.c evxfregn.c
-SRCS+= exconfig.c exconvrt.c excreate.c exdump.c exfield.c
-SRCS+= exfldio.c exmisc.c exmutex.c exnames.c exoparg1.c
-SRCS+= exoparg2.c exoparg3.c exoparg6.c exprep.c exregion.c
-SRCS+= exresnte.c exresolv.c exresop.c exstore.c exstoren.c
-SRCS+= exstorob.c exsystem.c exutils.c
+SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c
+SRCS+= dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c
+SRCS+= dswscope.c dswstate.c evevent.c evgpe.c evgpeblk.c
+SRCS+= evmisc.c evregion.c evrgnini.c evsci.c evxface.c
+SRCS+= evxfevnt.c evxfregn.c exconfig.c exconvrt.c excreate.c
+SRCS+= exdump.c exfield.c exfldio.c exmisc.c exmutex.c
+SRCS+= exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c
+SRCS+= exprep.c exregion.c exresnte.c exresolv.c exresop.c
+SRCS+= exstore.c exstoren.c exstorob.c exsystem.c exutils.c
SRCS+= hwacpi.c hwgpe.c hwregs.c hwsleep.c hwtimer.c
SRCS+= nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c
-SRCS+= nsload.c nsnames.c nsobject.c nssearch.c nsutils.c
-SRCS+= nswalk.c nsxfeval.c nsxfname.c nsxfobj.c
-SRCS+= psargs.c psfind.c psopcode.c psparse.c psscope.c
+SRCS+= nsload.c nsnames.c nsobject.c nsparse.c nssearch.c
+SRCS+= nsutils.c nswalk.c nsxfeval.c nsxfname.c nsxfobj.c
+SRCS+= psargs.c psopcode.c psparse.c psscope.c
SRCS+= pstree.c psutils.c pswalk.c psxface.c
SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsio.c
SRCS+= rsirq.c rslist.c rsmemory.c rsmisc.c rsutils.c
-SRCS+= rsxface.c
-SRCS+= tbconvrt.c tbget.c tbgetall.c tbinstal.c tbrsdt.c
-SRCS+= tbutils.c tbxface.c tbxfroot.c
-SRCS+= utalloc.c utclib.c utcopy.c utdebug.c utdelete.c
-SRCS+= uteval.c utglobal.c utinit.c utmath.c utmisc.c
-SRCS+= utobject.c utxface.c
+SRCS+= rsxface.c tbconvrt.c tbget.c tbgetall.c tbinstal.c
+SRCS+= tbrsdt.c tbutils.c tbxface.c tbxfroot.c utalloc.c
+SRCS+= utclib.c utcopy.c utdebug.c utdelete.c uteval.c
+SRCS+= utglobal.c utinit.c utmath.c utmisc.c utobject.c
+SRCS+= utxface.c
# OSD layer
SRCS+= acpi.c acpi_acad.c acpi_battery.c acpi_button.c acpi_cmbat.c acpi_cpu.c
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index 3d83803..584e23a 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -38,8 +38,7 @@
#include <dev/acpica/acpiio.h>
-#include <contrib/dev/acpica/acfreebsd.h>
-#include <contrib/dev/acpica/actypes.h>
+#include <contrib/dev/acpica/acpi.h>
#define ACPIDEV "/dev/acpi"
OpenPOWER on IntegriCloud