From owner-acpi-jp@jp.freebsd.org  Thu Aug 31 03:31:46 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id DAA15300;
	Thu, 31 Aug 2000 03:31:46 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from tasogare.imasy.or.jp (daemon@tasogare.imasy.or.jp [202.227.24.5])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id DAA15294;
	Thu, 31 Aug 2000 03:31:44 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	by tasogare.imasy.or.jp (8.10.2+3.3W/3.7W-tasogare/smtpfeed 1.07) with ESMTP id e7UIVZr40127;
	Thu, 31 Aug 2000 03:31:35 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
To: takawata@shidahara1.planet.sci.kobe-u.ac.jp
Cc: dfr@freebsd.org, iwasaki@jp.freebsd.org, acpi-jp@jp.freebsd.org
In-Reply-To: <200008301607.BAA04705@shidahara1.planet.sci.kobe-u.ac.jp>
References: <Pine.BSF.4.21.0008300938420.24553-100000@salmon.nlsystems.com>
	<200008301607.BAA04705@shidahara1.planet.sci.kobe-u.ac.jp>
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20000831033134U.iwasaki@jp.FreeBSD.org>
Date: Thu, 31 Aug 2000 03:31:34 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 97
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 591
Subject: [acpi-jp 591] Re: PCI changes affect ACPI bus space access
 code.
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

> >> Just for very short-term solution, is it enough to delete the lines
> >> which access to pcicfgregs:hose in sys/i386/include/acpica_osd.h ?
> >> It seems the problem had gone if I delete the lines, but I could be
> >> wrong :-)
> 
> I don't think it work,because pcicfg{read/write} is replaced into
> pcib_if.m method.How about this patch?

Ah, you meant that pcicfgregs:dev (device_t) is now mandatory for
pci_cfg{read/write}, right?
Then how about just obtain device_t acpi (or nexus? not sure) and set
it to pcicfgregs:dev ?

Index: acpica_osd.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/acpica_osd.h,v
retrieving revision 1.2
diff -u -r1.2 acpica_osd.h
--- acpica_osd.h	2000/08/29 20:30:51	1.2
+++ acpica_osd.h	2000/08/30 18:17:53
@@ -30,6 +30,7 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/bus.h>
 #include <machine/bus.h>
 #include <machine/vmparam.h>
 #include <sys/acpi.h>
@@ -197,19 +198,34 @@
  * Standard access to PCI configuration space
  */
 
+static device_t	get_acpi_device();
+
+static __inline device_t
+get_acpi_device()
+{
+	device_t	nexus, acpi;
+
+	nexus = acpi = NULL;
+	if ((nexus = device_find_child(root_bus, "nexus", 0)) == NULL) {
+		return (NULL);
+	}
+	if ((acpi = device_find_child(nexus, "acpi", 0)) == NULL) {
+		return (NULL);
+	}
+
+	return (acpi);
+}
+
 static __inline ACPI_STATUS
 OsdReadPciCfg(UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT32 *Value, int bytes)
 {
 	pcicfgregs	pcicfg;
-
-	/*
-	 * XXX Hack for Alpha(tsunami) systems.
-	 * pcicfg.hose is set to -1 in the hope that,
-	 * tsunami_cfgreadX() will set it up right.
-	 * Other Alpha systems (and i386's) don't seem to use hose.
-	 */
-	pcicfg.hose = -1;
+	device_t	acpi;
 
+	if ((acpi = get_acpi_device()) == NULL) {
+		return (AE_ERROR);
+	}
+	pcicfg.dev = acpi;
 	pcicfg.bus = Bus;
 	pcicfg.slot = (DeviceFunction >> 16) & 0xff;
 	pcicfg.func = DeviceFunction & 0xff;
@@ -265,15 +281,12 @@
 OsdWritePciCfg(UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT32 Value, int bytes)
 {
 	pcicfgregs	pcicfg;
-
-	/*
-	 * XXX Hack for Alpha(tsunami) systems.
-	 * pcicfg.hose is set to -1 in the hope that,
-	 * tsunami_cfgreadX() will set it up right.
-	 * Other Alpha systems (and i386's) don't seem to use hose.
-	 */
-	pcicfg.hose = -1;
+	device_t	acpi;
 
+	if ((acpi = get_acpi_device()) == NULL) {
+		return (AE_ERROR);
+	}
+	pcicfg.dev = acpi;
 	pcicfg.bus = Bus;
 	pcicfg.slot = (DeviceFunction >> 16) & 0xff;
 	pcicfg.func = DeviceFunction & 0xff;

I'm not sure this will work, but I prefer this way using more general
functions for portability reason rather than violating protected
nexus_pcib* stuff and accessing it directly.
How can we reach nexus_pcib* ?
