From owner-acpi-jp@jp.freebsd.org  Tue Jun 27 09:20:59 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id JAA38479;
	Tue, 27 Jun 2000 09:20:59 +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 JAA38474
	for <acpi-jp@jp.freebsd.org>; Tue, 27 Jun 2000 09:20:58 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (isdn23.imasy.or.jp [202.227.24.215])
	by tasogare.imasy.or.jp (8.10.1+3.3W/3.7W-tasogare/smtpfeed 1.07) with ESMTP id e5R0Kqp61640
	for <acpi-jp@jp.freebsd.org>; Tue, 27 Jun 2000 09:20:52 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
To: acpi-jp@jp.freebsd.org
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Tue_Jun_27_09:20:40_2000_518)--"
Content-Transfer-Encoding: 7bit
Message-Id: <20000627092046Y.iwasaki@jp.FreeBSD.org>
Date: Tue, 27 Jun 2000 09:20:46 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 1681
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 443
Subject: [acpi-jp 443] merging to FreeBSD
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

----Next_Part(Tue_Jun_27_09:20:40_2000_518)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B$$$o$5$-$G$9(B
USENIX $B$G(B Mike, Doug, Peter, John $B$i$H%^!<%8$NBG$A9g$o$;$r(B
$B$7$F$-$^$7$?!#(BIA64$B!"(BPnPBIOS $B$NCV$-49$($H$$$C$?L\E*$+$i$9$0$K(B
$B$G$b%^!<%8$7$?$$$H$N$3$H$G$7$?!#(B
IA64 $B$N$3$H$r9M$($k$H8=:_$N%=!<%9$NCV$->l$OET9g$,0-$$$N$G(B
sys/dev/acpi/ $B$"$?$j$K(B MI $B$J%3!<%I$rCV$3$&$H$7$F$$$^$9!#(B
$B$G!"(Bi386 $B0MB8$NItJ,$O(B sys/i386/i386/i386_acpi.c $B$"$?$j$K(B
$B=8$a$F$7$^$&46$8$G$9!#(B
$B$^$?!"$\$/8D?M$H$7$F$O!"(BIntel $B$N(B ACPICA $B$X$N>h$j49$($b(B
$BF,$NJR6y$KCV$$$F$*$-$?$$$N$G!"(BACPICA $B;EMM$N(B OS $B0MB8$N%3!<%I$b(B
$B=q$-Cy$a$F$*$$$F!"8=9T$N%3!<%I$+$i$bMxMQ$9$k46$8$K$7$F$*$-$?$$(B
$B$H;W$C$F$$$^$9!#$^$:$O(B system resource $B$X%"%/%;%9$9$kItJ,!"(B
ioport $B$H(B $BJ*M}%a%b%j$N%^%C%W$r$3$NOHAH$_$K0\9T$7$F$_$^$7$?!#(B
$B:G=*E*$K$O(B resource manager $B$H6(D4$9$Y$-$H;W$$$^$9$,!"B>$N(B
$B8=>u$G$O(B device driver $B$,%j%=!<%9$rFH@j$7$F$$$k2DG=@-$b$"$k(B
$B$?$a!"(Bresource manager $B$r2p$5$:$K$d$C$F$_$^$7$?!#(B
# $B;D$j$O(B PCI config regs $B$J$I$G$9$,!"$d$C$F$/$l$k?M$$$^$;$s$+(B?

$B$^$?!"(Bacpi $B%I%i%$%P$KAH$_9~$_$N@)8f%a%=%C%I$O!"$=$m$=$mLrL\$r(B
$B=*$($?5$J,$J$N$G!"$6$C$/$j>C$7$?$$$H;W$$$^$9!#(B
$B$H$j$"$($:0J>e$N$3$H$r@0M}$7$?:9J,$G$9!#%=!<%9$NCV>l=j$O(B
$BJQ$C$F$$$^$;$s!#$^$?!"JL%Q!<%H$K(B sys/i386/i386/i386_acpi.c $B$N(B
$B=iHG$r$/$C$D$1$F$*$-$^$9!#(B

Index: conf/files.i386
===================================================================
RCS file: /home/cvs/ACPI/sys/conf/files.i386,v
retrieving revision 1.3
diff -u -r1.3 files.i386
--- conf/files.i386	2000/06/03 14:32:49	1.3
+++ conf/files.i386	2000/06/26 15:47:44
@@ -155,6 +155,7 @@
 i386/i386/exception.s		standard
 i386/i386/globals.s		standard
 i386/i386/i386-gdbstub.c	optional	ddb
+i386/i386/i386_acpi.c		optional	acpi
 i386/i386/i686_mem.c		standard
 i386/i386/identcpu.c		standard
 i386/i386/in_cksum.c		optional	inet
Index: i386/acpi/acpi.c
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/acpi.c,v
retrieving revision 1.15
diff -u -r1.15 acpi.c
--- i386/acpi/acpi.c	2000/06/18 17:51:28	1.15
+++ i386/acpi/acpi.c	2000/06/26 23:42:58
@@ -771,7 +771,7 @@
 
 	val = 0;
 	for (i = size - 1; i >= 0; i--) {
-		val = (val << 8) | inb(ioaddr + i);
+		val = (val << 8) | OsdIn8(ioaddr + i);
 	}
 	*value = val;
 }
@@ -784,7 +784,7 @@
 
 	val = *value;
 	for (i = 0; i < size; i++) {
-		outb(ioaddr + i, val & 0xff);
+		OsdOut8(ioaddr + i, val & 0xff);
 		val >>= 8;
 	}
 }
@@ -802,7 +802,7 @@
 		val = facp->acpi_disable;
 	}
 
-	outb(ioaddr, val);
+	OsdOut8(ioaddr, val);
 
 	if (acpi_debug) {
 		ACPIPRINTF("acpi_enable_disable(%d) = (%x)\n", enable, val);
@@ -1126,1064 +1126,9 @@
 	return (i386_btop(acpi_pmap_vtp((vm_offset_t)(sc->dsdt + offset))));
 }
 
-/*
- * Builtin Control method code.
- */
-
-#define ACPI_BUILTIN_STATEPACKAGE	/* stupid? :-) Yes, I know. */
-
-/*
- * Macros for ASL translation.
-*/
-#define OperationRegion(RegionName, RegionSpace, Offset, Length) \
-	/* XXX Supports StstemIO RegionSpace only */ \
-	u_int32_t RegionName = Offset;
-
-#define Field(RegionName, AccessType, LockRule, UpdateRule, Offset, FieldName, Bitlen) \
-	/* XXX Supports ByteAcc AccessType only */ \
-	u_int32_t FieldName = RegionName + (Offset / 8); \
-	u_int32_t FieldName##_OFFSET = (Offset % 8); \
-	u_int32_t FieldName##_MASK = (~((1 << Bitlen) - 1) << (Offset % 8)) | (Offset % 8); \
-	u_int32_t FieldName##_LEN = Bitlen / 8 + ((Bitlen % 8)? 1 : 0);
-
-#define IndexField(IndexName, DataName, AccessType, LockRule, UpdateRule, Offset, FieldName, Bitlen) \
-	/* XXX Supports ByteAcc AccessType only */ \
-	u_int32_t FieldName##_POS = (Offset / 8); \
-	u_int32_t FieldName##_INDEX = IndexName; \
-	u_int32_t FieldName##_INDEX_OFFSET = IndexName##_OFFSET; \
-	u_int32_t FieldName##_INDEX_MASK = IndexName##_MASK; \
-	u_int32_t FieldName##_INDEX_LEN = IndexName##_LEN; \
-	u_int32_t FieldName##_DATA = DataName; \
-	u_int32_t FieldName##_DATA_OFFSET = DataName##_OFFSET; \
-	u_int32_t FieldName##_DATA_MASK = DataName##_MASK; \
-	u_int32_t FieldName##_DATA_LEN = DataName##_LEN;
-
-#define StoreIndexField(VAL, FIELD) \
-	/* XXX Supports StstemIO RegionSpace only */ \
-	acpi_registers_input(FIELD##_INDEX, &tmp, FIELD##_INDEX_LEN); \
-	tmp = (tmp & FIELD##_INDEX_MASK) | (FIELD##_POS << FIELD##_INDEX_OFFSET); \
-	acpi_registers_output(FIELD##_INDEX, &tmp, FIELD##_INDEX_LEN); \
-	acpi_registers_input(FIELD##_DATA, &tmp, FIELD##_DATA##_LEN); \
-	tmp = (tmp & FIELD##_DATA_MASK) | (VAL << FIELD##_DATA_OFFSET); \
-	acpi_registers_output(FIELD##_DATA, &tmp, FIELD##_INDEX_LEN);
-
-#define Mutex(MutexName, SyncLevel)	/* Mutex() will be ingnored */
-
-#define Acquire(SyncObject, TimeoutValue) /* Acquire() will be ingnored */
-
-#define Release(SyncObject)	/* Release() will be ingnored */
-
-#define Return(Arg)		/* Return() will be ingnored */
-
-#define If(x)	if(x)
-
-#define While(x)	while(x)
-
-#define Else	else
-
-#define LNot(x)	!(x)
-
-#define LOr(op1, op2)		(op1) || (op2)
-
-#define LAnd(op1, op2)		(op1) && (op2)
-
-#define LEqual(op1, op2)	op1 == op2
-
-#define LLess(op1, op2)		op1 < op2
-
-#define LGreater(op1, op2)	op1 > op2
-
-#define Store(VAL, OBJ)	\
-	/* XXX Supports StstemIO RegionSpace only */ \
-	acpi_registers_input(OBJ, &tmp, OBJ##_LEN); \
-	tmp = (tmp & OBJ##_MASK) | (VAL << OBJ##_OFFSET); \
-	acpi_registers_output(OBJ, &tmp, OBJ##_LEN);
-
-#define Notify(x, y)	/* Notify() will be ingnored */
-
-#define Or(op1, op2, op3) \
-	op3 = op1 | op2;
-
-#define And(op1, op2, op3) \
-	op3 = op1 & op2;
-
-#define One	0x1
-
-#define Zero	0x0
-
-/*
- * _PTS and _WAK for P2B.
- */
-static void
-acpi_execute_pts_p2b(acpi_softc_t *sc, u_int8_t Arg0)
-{
-
-	/* Original ASL code
-	 *
-	Name(\_S0, Package() {
-	    0x5
-	    0x5
-	    0x0
-	    0x0
-	})
-	Name(\_S1, Package() {
-	    0x7
-	    0x7
-	    0x0
-	    0x0
-	})
-	Name(\_S5, Package() {
-	    0x6
-	    0x6
-	    0x0
-	    0x0
-	})
-	OperationRegion(\DEBG, SystemIO, 0x80, 0x1)
-	Field(\DEBG, ByteAcc, NoLock, Preserve) {
-		DBG1,       8
-	}
-	OperationRegion(GPOB, SystemIO, 0xe42c, 0x10)
-	Field(GPOB, ByteAcc, NoLock, Preserve) {
-		Offset(0x18),
-		TO12,       1,
-		Offset(0x40),
-		FANM,       1,
-		Offset(0x48),
-		PLED,       1,
-		Offset(0x4c),
-		Offset(0x4e),
-		Offset(0x5e),
-		MSG0,       1
-	} 
-	Method(\_PTS, 1) {
-		If(LNot(LEqual(Arg0, 0x5))) {
-			Store(0x0, FANM)
-			Store(0x0, PLED)
-		}
-		If(LEqual(Arg0, 0x1)) {
-			Store(One, TO12)
-		}
-		If(LEqual(Arg0, 0x2)) {
-		}
-		Store(One, TO12)
-		Or(Arg0, 0xf0, Local2)
-		Store(Local2, DBG1)
-	}
-	*
-	*/
-
-	u_int32_t	tmp;
-	u_int8_t	Local2;
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x5, 0x5},
-		{0x7, 0x7},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{0x6, 0x6},
-	}};
-#endif
-
-	OperationRegion(_DEBG, SystemIO, 0x80, 0x1)
-	Field(_DEBG, ByteAcc, NoLock, Preserve, 0x0, DBG1, 8)
-
-	OperationRegion(GPOB, SystemIO, 0xe42c, 0x10)
-	Field(GPOB, ByteAcc, NoLock, Preserve, 0x18, TO12, 1)
-	Field(GPOB, ByteAcc, NoLock, Preserve, 0x40, FANM, 1)
-	Field(GPOB, ByteAcc, NoLock, Preserve, 0x48, PLED, 1)
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-	If(LNot(LEqual(Arg0, 0x5))) {
-		Store(0x0, FANM)
-		Store(0x0, PLED)
-	}
-	If(LEqual(Arg0, 0x1)) {
-		Store(One, TO12)
-	}
-	If(LEqual(Arg0, 0x2)) {
-	}
-	Store(One, TO12)
-	Or(Arg0, 0xf0, Local2)
-	Store(Local2, DBG1)
-
-}
-
-static void
-acpi_execute_wak_p2b(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	u_int32_t	tmp;
-	OperationRegion(_DEBG, SystemIO, 0x80, 0x1)
-	Field(_DEBG, ByteAcc, NoLock, Preserve, 0x0, DBG1, 8)
-	OperationRegion(GPOB, SystemIO, 0xe42c, 0x10)
-	Field(GPOB, ByteAcc, NoLock, Preserve, 0x40, FANM, 1)
-	Field(GPOB, ByteAcc, NoLock, Preserve, 0x48, PLED, 1)
-
-	Store(0x1, FANM)
-	Store(One, PLED)
-	Store(0xff, DBG1)
-}
-
-/*
- * _PTS for MobioNX.
- */
-static void
-acpi_execute_pts_mobionx(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	Name(_S0, Package() {
-	    0x0
-	    0x0
-	})
-	Name(_S3, Package() {
-	    0x3
-	    0x0
-	})
-	Name(_S4, Package() {
-	    0x4
-	    0x0
-	})
-	Name(_S5, Package() { 
-	    0x4
-	    0x0
-	})
-	OperationRegion(SMI0, SystemMemory, 0x4ffff2c, 0x90)
-	Field(SMI0, AnyAcc, NoLock, Preserve) {
-		BCMD,	8,
-		DID,	32,
-		INFO,	32
-	}
-	OperationRegion(SMI1, SystemIO, 0xfe00, 0x2)
-	Field(SMI1, AnyAcc, NoLock, Preserve) {
-		SMIC,	8
-	}
-	Mutex(MPHS, 0)
-	Method(PHS, 9) {
-		Acquire(MPHS, 0xffff)
-		Store(Arg0, BCMD)
-		Store(0x0, DID)
-		Store(Zero, SMIC)
-		Store(0x0, BCMD)
-		Release(MPHS)
-		Return(INFO)
-	}
-
-	Method(_PTS, 1) {
-		If(LEqual(Arg0, 0x3)) {
-			PHS
-			0x85
-		}
-	} 
-	*
-	*/
-
-	u_int32_t	tmp;
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x0, 0x0},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{0x3, 0x0},
-		{0x4, 0x0},
-		{0x4, 0x0},
-	}};
-#endif
-
-#if 0
-	OperationRegion(SMI0, SystemMemory, 0x4ffff2c, 0x90)
-	Field(SMI0, AnyAcc, NoLock, Preserve, 0, BCMD, 8)
-	Field(SMI0, AnyAcc, NoLock, Preserve, 8, DID, 32)
-#endif
-	vm_offset_t	SMI0 = acpi_pmap_ptv(0x4ffff2c);
-	u_int8_t	*BCMD;
-	u_int32_t	*DID;
-
-	OperationRegion(SMI1, SystemIO, 0xfe00, 0x2)
-	Field(SMI1, AnyAcc, NoLock, Preserve, 0, SMIC, 8);
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-	BCMD = (u_int8_t *) SMI0 + (0 / 8);
-	DID = (u_int32_t *) SMI0 + (8 / 8);
-
-	If(LEqual(Arg0, 0x3)) {
-		Mutex(MPHS, 0)
-		/* PHS(0x85) */
-		Acquire(MPHS, 0xffff)
-#if 0
-		Store(0x85, BCMD)
-		Store(0x0, DID)
-#endif
-		*BCMD = 0x85;
-		*DID = 0x0;
-
-		Store(Zero, SMIC)
-#if 0
-		Store(0x0, BCMD)
-#endif
-		*BCMD = 0x0;
-		Release(MPHS)
-		Return(INFO)
-	}
-}
-
-/*
- * _PTS for Chandra2.
- */
-static void
-acpi_execute_pts_chandra2(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	OperationRegion(CTRC, SystemIO, 0x1d6, 0x2)
-	Field(CTRC, ByteAcc, NoLock, Preserve) {
-	    CIDX,       8,
-	    CDAT,       8
-	}   
-	IndexField(CIDX, CDAT, ByteAcc, NoLock, Preserve) {
-	    WKST,       8,
-	    SLNO,       8,
-	    SYSI,       8,
-	    MSGI,       8
-	}
-
-	Name(\_S0, Package() {
-	    0x0
-	    0x0
-	    0x0
-	})
-	Name(\_S1, Package() {
-	    0x1
-	    0x1
-	    0x0
-	})
-	Name(\_S2, Package() {
-	    0x2
-	    0x2
-	    0x0
-	})
-	Name(\_S3, Package() {
-	    0x3
-	    0x3
-	    0x0
-	})
-	Name(\_S4, Package() {
-	    0x4
-	    0x4
-	    0x0
-	})
-	Name(\_S5, Package() {
-	    0x5
-	    0x5
-	    0x0
-	})
-
-	Method(\_PTS, 1) {
-	    Store(Arg0, SLNO)
-	}       
-	*
-	*/
-
-	u_int32_t	tmp;
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x0, 0x0},
-		{0x1, 0x1},
-		{0x2, 0x2},
-		{0x3, 0x3},
-		{0x4, 0x4},
-		{0x5, 0x5},
-	}};
-#endif
-
-	OperationRegion(CTRC, SystemIO, 0x1d6, 0x2)
-	Field(CTRC, ByteAcc, NoLock, Preserve, 0, CIDX, 8)
-	Field(CTRC, ByteAcc, NoLock, Preserve, 8, CDAT, 8)
-	IndexField(CIDX, CDAT, ByteAcc, NoLock, Preserve, 8, SLNO, 8)
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-	StoreIndexField(Arg0, SLNO)
-}
-
-/*
- * _PTS and _WAK for AWARDBIOS.
- */
-static void
-acpi_execute_pts_awardbios(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	Name(\_S0, Package() {
-	    0x5
-	    0x5
-	})
-	Name(\_S1, Package() {
-	    0x2
-	    0x2
-	})
-	Name(\_S5, Package() {
-	    Zero
-	    Zero
-	})
-
-	OperationRegion(\DEBG, SystemIO, 0x80, 0x1)
-	Field(\DEBG, ByteAcc, NoLock, Preserve) {
-	    DBG1,	8
-	}
-	Method(\_PTS, 1) {
-	    Or(Arg0, 0xf0, Local0)
-	    Store(Local0, DBG1)
-	}
-	*
-	*/
-
-	u_int32_t	tmp;
-	u_int8_t	Local0;
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x5, 0x5},
-		{0x2, 0x2},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{0x0, 0x0},
-	}};
-#endif
-
-	OperationRegion(_DEBG, SystemIO, 0x80, 0x1)
-	Field(_DEBG, ByteAcc, NoLock, Preserve, 0, DBG1, 8)
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-	Or(Arg0, 0xf0, Local0)
-	Store(Local0, DBG1)
-}
-
-static void
-acpi_execute_wak_awardbios(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	u_int32_t	tmp;
-
-	OperationRegion(_DEBG, SystemIO, 0x80, 0x1)
-	Field(_DEBG, ByteAcc, NoLock, Preserve, 0, DBG1, 8)
-
-	Store(0xff, DBG1)
-}
-
-/*
- * _PTS and _WAK for Z505FX and Z505JX.
- */
-static void
-acpi_execute_pts_Z505FX(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	Name(_S0, Package() {
-	    0x5
-	    0x5
-	})
-	Name(_S1, Package() {
-	    0x4
-	    0x4
-	})
-	Name(_S3, Package() {
-	    0x1
-	    0x1
-	})
-	Name(_S4, Package() {
-	    0x0
-	    0x0
-	})
-	Name(_S5, Package() {
-	    0x0
-	    0x0
-	})
-	*
-	*/
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x5, 0x5},
-		{0x4, 0x4},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{0x1, 0x1},
-		{0x0, 0x0},
-		{0x0, 0x0},
-	}};
-
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-}
-
-static void
-acpi_execute_wak_Z505FX(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	Method(_WAK, 1) {
-	    Notify(\_SB.PWRB, 0x2)
-	    Return(Zero)
-	}
-	*
-	*/
-
-	/* How to implement? */
-}
-
-/*
- * _PTS and _WAK for PORTEGE 3110CT
- */
-static void
-acpi_execute_pts_3110CT(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-	Name(\_S0, Package() {
-	    0x5
-	    0x0
-	    0x0
-	    0x0
-	})
-	Name(\_S1, Package() {
-	    0x7
-	    0x0
-	    0x0
-	    0x0
-	})
-	Name(\_S3, Package() {
-	    0x7
-	    0x0
-	    0x0
-	    0x0
-	})
-	Name(\_S4, Package() {
-	    0x0
-	    0x0
-	    0x0
-	    0x0
-	})
-	Name(\_S5, Package() {
-	    0x7
-	    0x0
-	    0x0
-	    0x0
-	})
-        OperationRegion(TRAP, SystemMemory, 0x100b6800, 0x10)
-        Field(TRAP, AnyAcc, NoLock, Preserve) {
-            PAR1,	16,
-            PAR2,	16,
-            PAR3,	16,
-            PAR4,	16,
-            PAR5,	16,
-            PAR6,	16
-        }
-        OperationRegion(SRAM, SystemMemory, 0x100b0000, 0x10000)
-        Field(SRAM, AnyAcc, NoLock, Preserve) {
-            Offset(0x34000),
-            IEAX,	32,
-            IEBX,	32,
-            IECX,	32,
-            IEDX,	32,
-            IESI,	32,
-            IEDI,	32,
-            IEBP,	32,
-            Offset(0x36018),
-            WED0,	1,
-            WED1,	1,
-            WED2,	1,
-            WED3,	1,
-            WED4,	1,
-            Offset(0x36870),
-            BDID,	32,
-            DSPW,	1,
-            VGAF,	1,
-            VWE0,	1,
-            VWE1,	1,
-            PPSC,	1,
-            SPSC,	1,
-            EWLD,	1,
-            EPWS,	1,
-            LCDS,	4,
-            CRTS,	4,
-	}
-	OperationRegion(SRG1, SystemIO, 0xb2, 0x1)
-	Field(SRG1, ByteAcc, NoLock, Preserve) {
-	    TRP4,	8
-	}
-	Method(_PTS, 1) {
-	    If(LOr(\_SB.MEM.VWE0, \_SB.MEM.VWE1)) {
-		Store(0x1, \_SB.MEM.WED2)
-	    }
-	    Else {
-		Store(0x0, \_SB.MEM.WED2)
-	    }
-	    If(LAnd(LNot(LLess(Arg0, 0x1)), LNot(LGreater(Arg0, 0x4)))) {
-		Store(\_SB.MEM.EWLD, \_SB.MEM.PAR1)
-		Store(0x60, \_SB.PCI0.FNC0.SYSR.TRP4)
-	    }
-	    And(Arg0, 0x7, Local0)
-	    Or(Local0, 0x2100, Local0)
-	    SMBR(0xfa00, Local0, 0x0, 0x0, 0xb2)
-	}
-	Method(SMBR, 5) {
-	    Store(Arg0, \_SB.MEM.IEAX)
-	    Store(Arg1, \_SB.MEM.IEBX)
-	    Store(Arg2, \_SB.MEM.IECX)
-	    Store(Arg3, \_SB.MEM.IEDX)
-	    Store(Arg4, \_SB.PCI0.FNC0.SYSR.TRP4)
-	}
-	*
-	*/
-
-#define SMBR(Arg0, Arg1, Arg2, Arg3, Arg4)	\
-	*IEAX = Arg0; \
-	*IEBX = Arg1; \
-	*IECX = Arg2; \
-	*IEDX = Arg3; \
-	Store(Arg4, TRP4)
-
-	u_int32_t	tmp;
-	u_int32_t	Local0;
-
-	vm_offset_t	WED;
-	vm_offset_t	BDID;
-	u_int8_t	*WED0;
-	u_int8_t	*DSPW;
-	u_int8_t	VWE0, VWE1, EWLD;
-	u_int16_t	*PAR1;
-	u_int32_t	*IEAX, *IEBX, *IECX, *IEDX;
-
-	OperationRegion(SRG1, SystemIO, 0xb2, 0x1)
-	Field(SRG1, ByteAcc, NoLock, Preserve, 0, TRP4,	8)
-
-#ifdef ACPI_BUILTIN_STATEPACKAGE
-	struct acpi_system_state_package system_state_package = {{
-		{0x5, 0x0},
-		{0x7, 0x0},
-		{ACPI_UNSUPPORTSLPTYP, ACPI_UNSUPPORTSLPTYP},
-		{0x7, 0x0},
-		{0x0, 0x0},
-		{0x7, 0x0},
-	}};
-
-	sc->system_state_package = system_state_package;
-	sc->system_state_initialized = 1;
-#endif
-
-	pmap_kenter((vm_offset_t)ptvmmap, (0x100b6800-0x800) & ~PAGE_MASK);
-	PAR1 = (u_int16_t *)&ptvmmap[16*0 / 8 + 0x800];
-	IEAX = (u_int32_t *)&ptvmmap[32*0 / 8 + 0x800];
-	IEBX = (u_int32_t *)&ptvmmap[32*1 / 8 + 0x800];
-	IECX = (u_int32_t *)&ptvmmap[32*2 / 8 + 0x800];
-	IEDX = (u_int32_t *)&ptvmmap[32*3 / 8 + 0x800];
-
-	BDID = (vm_offset_t)&ptvmmap[(0x36870-0x34000) / 8 + 0x800];
-	DSPW = (u_int8_t *) BDID + 4;
-	VWE0 = ((*DSPW) >> 2) & 0x01;
-	VWE1 = ((*DSPW) >> 3) & 0x01;
-	WED  = (vm_offset_t)&ptvmmap[(0x36018-0x34000) / 8 + 0x800];
-	WED0 = (u_int8_t *) WED;
-
-	If(LOr(VWE0, VWE1)) {
-	    /* Store(0x1, \_SB.MEM.WED2) */
-	    *WED0 = (*WED0 & ~(0x1 << 2)) | (0x1 << 2);
-	}
-	Else {
-	    /* Store(0x0, \_SB.MEM.WED2) */
-	    *WED0 = (*WED0 & ~(0x1 << 2)) | (0x0 << 2);
-	}
-
-	If(LAnd(LNot(LLess(Arg0, 0x1)), LNot(LGreater(Arg0, 0x4)))) {
-	    /* Store(\_SB.MEM.EWLD, \_SB.MEM.PAR1) */
-	    EWLD = ((*DSPW) >> 6) & 0x01;
-	    *PAR1 = EWLD;
-	    /* Store(0x60, \_SB.PCI0.FNC0.SYSR.TRP4) */
-	    Store(0x60, TRP4)
-	}
-	And(Arg0, 0x7, Local0)
-	Or(Local0, 0x2100, Local0)
-
-	SMBR(0xfa00, Local0, 0x0, 0x0, 0xb2);
-
-	pmap_kremove((vm_offset_t)ptvmmap);
-
-}
-
-static void
-acpi_execute_wak_3110CT(acpi_softc_t *sc, u_int8_t Arg0)
-{
-	/* Original ASL code
-	 *
-        OperationRegion(SRM, SystemMemory, 0x100b6800, 0x10)
-        Field(SRM, AnyAcc, NoLock, Preserve) {
-            Offset(0x10),
-            RDID,	32,
-            RDSN,	32,
-            CAPB,	16
-        }
-        OperationRegion(SRAM, SystemMemory, 0x100b0000, 0x10000)
-        Field(SRAM, AnyAcc, NoLock, Preserve) {
-            Offset(0x34100),
-            OEAX,	32,
-            OEBX,	32,
-            OECX,	32,
-            OEDX,	32,
-            OESI,	32,
-            OEDI,	32,
-            OEBP,	32,
-            Offset(0x36028),
-            LIDS,	1,
-            VALF,	1,
-            DCST,	1,
-            DOS2,	1,
-            DCKI,	1,
-            DCKF,	1,
-            BT1F,	1,
-            BT2F,	1,
-            NXLA,	1,
-            NXCA,	1,
-            NXTA,	1,
-            Offset(0x36034),
-            Offset(0x36810),
-            DLID,	32,
-            DSRN,	32,
-	}
-
-	Method(_WAK, 1) {
-	    And(Arg0, 0x7, Local0)
-	    Or(Local0, 0x2180, Local0)
-	    SMBR(0xfa00, Local0, 0x0, 0x0, 0xb2)
-	    Notify(\_SB.PCI0.FNC0.FDD, 0x0)
-	    Notify(\_SB.PCI0.FNC1.IDE0, 0x0)
-	    Notify(\_SB.BAT1, 0x80)
-	    Notify(\_SB.ADP1, 0x80)
-	    Store(0x0, \_SB.MEM.RDID)
-	    Store(0x0, \_SB.MEM.RDSN)
-	    Store(0x5, \_SB.PCI0.FNC0.SYSR.TRP4)
-	    If(LEqual(\_SB.MEM.PAR1, 0x0)) {
-		If(LEqual(0x1151f351, \_SB.MEM.RDID)) {
-		    If(LOr(LNot(LEqual(\_SB.MEM.RDID, \_SB.MEM.DLID)), LNot(LEqual(*RDSN, \_SB.MEM.DSRN)))) {
-			Notify(\_SB.PCI0.DOCK, 0x0)
-		    }
-		}
-	    }
-	    Else {
-		If(\_SB.MEM.DLID) {
-		    Notify(\_SB.PCI0.DOCK, 0x1)
-		}
-	    }
-	    Notify(\_TZ.THRM, 0x80)
-	    If(LEqual(\_SB.MEM.VGAF, 0x1)) {
-		Store(0x1, \_SB.MEM.IESI)
-		Store(0x0, \_SB.MEM.IEDI)
-		SMBR(0xff00, 0x23, 0x20, 0x0, 0xb2)
-		WPSX(0x20, 0x1, 0x0, 0x0)
-		Store(0x0, \_SB.MEM.VGAF)
-	    }
-	    If(LEqual(\_SB.MEM.DOS2, 0x0)) {
-		If(LOr(LNot(LEqual(\_SB.MEM.CTLA, \_SB.MEM.NXLA)), LNot(LEqual(\_SB.MEM.CTCA, \_SB.MEM.NXCA)))) {
-		    Notify(\_SB.PCI0.VGA, 0x80)
-		}
-	    }
-	    DIS(0x14)
-	    SMBR(0xff00, 0x1e, 0x1, 0x0, 0xb2)
-	    Store(0x1, \_SB.MEM.PAR1)
-	    Store(0x60, \_SB.PCI0.FNC0.SYSR.TRP4)
-	    Name(BUFF, Package() {
-		0x0
-		0x1
-	    })
-	    If(LEqual(\_SB.MEM.ACST, 0x0)) {
-		And(\_SB.MEM.BST1, 0x4, Local0)
-		If(LEqual(Local0, 0x4)) {
-		    Store(0x1, Index(BUFF, 0x0, Zero))
-		}
-	    }
-	    Return(BUFF)
-	}
-	Method(WPSX, 4) {
-	    Store(Arg1, \_SB.MEM.IESI)
-	    Store(Arg2, \_SB.MEM.IEDI)
-	    SMBR(0xfe00, 0x23, Arg0, 0x0, 0xb2)
-	    While(LNot(LEqual(\_SB.MEM.OECX, 0x0))) {
-		Store(Arg1, \_SB.MEM.IESI)
-		Store(Arg2, \_SB.MEM.IEDI)
-		SMBR(0xfe00, 0x23, Arg0, 0x0, 0xb2)
-	    }
-	}
-	Method(DIS, 1) {
-	    Store(Arg0, \_SB.MEM.PAR1)
-	    Store(0x0, \_SB.MEM.PAR2)
-	    Store(0x0, \_SB.MEM.PAR3)
-	    Store(0x0, \_SB.MEM.PAR4)
-	    Store(0x0, \_SB.MEM.PAR5)
-	    Store(0x0, \_SB.MEM.PAR6)
-	    Store(0x3, \_SB.PCI0.FNC0.SYSR.TRP4)
-	}
-	*
-	*/
-
-#define DIS(Arg0)	\
-	*PAR1 = Arg0; \
-	*PAR2 = 0x0; \
-	*PAR3 = 0x0; \
-	*PAR4 = 0x0; \
-	*PAR5 = 0x0; \
-	*PAR6 = 0x0; \
-	Store(0x3, TRP4)
-
-	u_int32_t	tmp;
-	u_int32_t	Local0;
-
-	u_int16_t	*PAR1, *PAR2, *PAR3, *PAR4, *PAR5, *PAR6;
-	u_int32_t	*IEAX, *IEBX, *IECX, *IEDX, *IESI, *IEDI;
-	u_int32_t	*OECX;
-	u_int32_t	*RDID, *RDSN;
-	u_int32_t	*DLID;
-	u_int32_t	*DSRN;
-
-	vm_offset_t	BDID;
-	u_int8_t	*DSPW;
-	u_int8_t	VGAF;
-
-	OperationRegion(SRG1, SystemIO, 0xb2, 0x1)
-	Field(SRG1, ByteAcc, NoLock, Preserve, 0, TRP4,	8)
-
-	pmap_kenter((vm_offset_t)ptvmmap, (0x100b6800-0x800) & ~PAGE_MASK);
-
-	PAR1 = (u_int16_t *)&ptvmmap[16*0 / 8 + 0x800];
-	PAR2 = (u_int16_t *)&ptvmmap[16*1 / 8 + 0x800];
-	PAR3 = (u_int16_t *)&ptvmmap[16*2 / 8 + 0x800];
-	PAR4 = (u_int16_t *)&ptvmmap[16*3 / 8 + 0x800];
-	PAR5 = (u_int16_t *)&ptvmmap[16*4 / 8 + 0x800];
-	PAR6 = (u_int16_t *)&ptvmmap[16*5 / 8 + 0x800];
-	IEAX = (u_int32_t *)&ptvmmap[32*0 / 8 + 0x800];
-	IEBX = (u_int32_t *)&ptvmmap[32*1 / 8 + 0x800];
-	IECX = (u_int32_t *)&ptvmmap[32*2 / 8 + 0x800];
-	IEDX = (u_int32_t *)&ptvmmap[32*3 / 8 + 0x800];
-	IESI = (u_int32_t *)&ptvmmap[32*4 / 8 + 0x800];
-	IEDI = (u_int32_t *)&ptvmmap[32*5 / 8 + 0x800];
-	OECX = (u_int32_t *)&ptvmmap[32*9 / 8 + 0x800];
-
-	RDID = (u_int32_t *)&ptvmmap[0x10 / 8 + (32 * 0) / 8 + 0x800];
-	RDSN = (u_int32_t *)&ptvmmap[0x10 / 8 + (32 * 1) / 8 + 0x800];
-
-	DLID = (u_int32_t *)&ptvmmap[(0x36810-0x34000) / 8 + 0x800];
-        DSRN = (u_int32_t *)&ptvmmap[(0x36810-0x34000) / 8 + 0x800 + 4];
-
-	BDID = (vm_offset_t)&ptvmmap[(0x36870-0x34000) / 8 + 0x800];
-	DSPW = (u_int8_t *) BDID + 4;
-
-	And(Arg0, 0x7, Local0)
-	Or(Local0, 0x2180, Local0)
-
-	SMBR(0xfa00, Local0, 0x0, 0x0, 0xb2)
-
-	Notify(\_SB.PCI0.FNC0.FDD, 0x0)
-	Notify(\_SB.PCI0.FNC1.IDE0, 0x0)
-	Notify(\_SB.BAT1, 0x80)
-	Notify(\_SB.ADP1, 0x80)
-	/*
-	 Store(0x0, \_SB.MEM.RDID)
-	 Store(0x0, \_SB.MEM.RDSN)
-	 Store(0x5, \_SB.PCI0.FNC0.SYSR.TRP4)
-	*/
-	*RDID = 0x0;
-	*RDSN = 0x0;
-	Store(0x5, TRP4)
-
-	If(LEqual(*PAR1, 0x0)) {
-		If(LEqual(0x1151f351, *RDID)) {
-		If(LOr(LNot(LEqual(*RDID, *DLID)), LNot(LEqual(*RDSN, *DSRN)))) {
-			Notify(\_SB.PCI0.DOCK, 0x0)
-		}
-		}
-	}
-	Else {
-		If(*DLID) {
-		Notify(\_SB.PCI0.DOCK, 0x1)
-		}
-	}
-
-	Notify(\_TZ.THRM, 0x80)
-	/* If(LEqual(\_SB.MEM.VGAF, 0x1)) */
-	VGAF = (*DSPW >> 1) & 0x01;
-	If(LEqual(VGAF, 0x1)) {
-		/*
-		 Store(0x1, \_SB.MEM.IESI)
-		 Store(0x0, \_SB.MEM.IEDI)
-		*/
-		*IESI = 0x1;
-		*IEDI = 0x0;
-
-		SMBR(0xff00, 0x23, 0x20, 0x0, 0xb2)
-
-		/* WPSX(0x20, 0x1, 0x0, 0x0) */
-		{
-			*IESI = 0x1;
-			*IEDI = 0x0;
-
-			SMBR(0xfe00, 0x23, 0x20 /*Arg0*/, 0x0, 0xb2)
-
-			While(LNot(LEqual(*OECX, 0x0))) {
-				*IESI = 0x1;
-				*IEDI = 0x0;
-				SMBR(0xfe00, 0x23, 0x20 /*Arg0*/, 0x0, 0xb2)
-			}
-		}
-		/* Store(0x0, \_SB.MEM.VGAF) */
-		*DSPW = (*DSPW & 0xfd) | 0x0 << 1;
-	}
-#if 0
-	If(LEqual(\_SB.MEM.DOS2, 0x0)) {
-		If(LOr(LNot(LEqual(\_SB.MEM.CTLA, \_SB.MEM.NXLA)), LNot(LEqual(\_SB.MEM.CTCA, \_SB.MEM.NXCA)))) {
-		Notify(\_SB.PCI0.VGA, 0x80)
-		}
-	}
-#endif
-	DIS(0x14)
-	SMBR(0xff00, 0x1e, 0x1, 0x0, 0xb2)
-	*PAR1 = 0x1;
-	Store(0x60, TRP4)
-#if 0
-	Name(BUFF, Package() {
-		0x0
-		0x1
-	})
-	If(LEqual(\_SB.MEM.ACST, 0x0)) {
-		And(\_SB.MEM.BST1, 0x4, Local0)
-		If(LEqual(Local0, 0x4)) {
-		Store(0x1, Index(BUFF, 0x0, Zero))
-		}
-	}
-#endif
-
-	pmap_kremove((vm_offset_t)ptvmmap);
-}
-#undef SMBR
-#undef DIS
-
-typedef struct {
-	char		*oemid;
-	char		*oemtblid;
-	u_int32_t	oemrev_range[2];
-	void		(*pts_func)(acpi_softc_t *, u_int8_t);
-	void		(*wak_func)(acpi_softc_t *, u_int8_t);
-} acpi_builtin_method_t;
-
-static acpi_builtin_method_t	method_table[] = {
-	{
-		"ASUS", "P2B", {0x1000, 0x1000},
-		acpi_execute_pts_p2b, acpi_execute_wak_p2b
-	},
-	{
-		"NEC", "ND000004", {0x1, 0x1},
-		acpi_execute_pts_mobionx, NULL
-	},
-	{
-		"RIOS", "Clavius", {0x2, 0x2},
-		acpi_execute_pts_chandra2, NULL
-	},
-	{
-		"AWARD", "AWRDACPI", {0x1000, 0x1000},
-		acpi_execute_pts_awardbios, acpi_execute_wak_awardbios
-	},
-	{
-		"SONY", "", {0x0, 0x0},
-		acpi_execute_pts_Z505FX, acpi_execute_wak_Z505FX
-	},
-	{
-		" SONY", "Z0", {0x1310859, 0x1310859},
-		acpi_execute_pts_Z505FX, acpi_execute_wak_Z505FX
-	},
-	{
-		"TOSHIB", "3110CT", {0x19990528, 0x19990528},
-		acpi_execute_pts_3110CT, acpi_execute_wak_3110CT
-	},
-	{ NULL,	NULL, {NULL, NULL}, NULL, NULL}
-};
-
-#define ACPI_METHOD_PTS	0
-#define ACPI_METHOD_WAK	1
-
-static void
-acpi_execute_method(acpi_softc_t *sc, u_int8_t state, u_int8_t method)
-{
-	u_char		oemid[6];
-	u_char		oemtblid[8];
-	u_int32_t	oemrev;
-	int		id_len, tblid_len;
-	acpi_builtin_method_t	*table_ptr;
-	char		*method_name[] = {"pts", "wak"};
-
-	memcpy(oemid, sc->dsdt->oemid, sizeof oemid);
-	memcpy(oemtblid, sc->dsdt->oemtblid, sizeof oemtblid);
-	oemrev = sc->dsdt->oemrev;
-
-	table_ptr = method_table;
-	while (table_ptr->oemid) {
-		id_len = strlen(table_ptr->oemid);
-		tblid_len = strlen(table_ptr->oemtblid);
-
-		if ((!strncmp(oemid,    table_ptr->oemid,    id_len)) &&
-		    (!strncmp(oemtblid, table_ptr->oemtblid, tblid_len)) &&
-		    (oemrev >= table_ptr->oemrev_range[0]) &&
-		    (oemrev <= table_ptr->oemrev_range[1])) {
-			if (acpi_debug) {
-				ACPIPRINTF("acpi_execute_%s(%s, %s, %x).\n",
-				    method_name[method], table_ptr->oemid,
-				    table_ptr->oemtblid, oemrev);
-			}
-
-			switch (method) {
-			case ACPI_METHOD_PTS:
-				if (table_ptr->pts_func) {
-					table_ptr->pts_func(sc, state);
-				}
-				break;
-			case ACPI_METHOD_WAK:
-				if (table_ptr->wak_func) {
-					table_ptr->wak_func(sc, state);
-				}
-				break;
-			default:
-				break;
-			}
-			return;
-		}
-		table_ptr++;
-	}
-
-	/* not found */
-	if (acpi_debug) {
-		ACPIPRINTF("acpi_execute_%s not found.\n",
-		    method_name[method]);
-	}
-}
-
 static void
 acpi_execute_pts(acpi_softc_t *sc, u_int8_t state)
 {
-#if 1
-	acpi_execute_method(sc, state, ACPI_METHOD_PTS);
-#else
 	union	aml_object argv[1], *retval;
 
 	argv[0].type = aml_t_num;
@@ -2191,15 +1136,11 @@
 	aml_local_stack_push(aml_local_stack_create());
 	retval = aml_invoke_method_by_name("_PTS", 1, argv);
 	aml_local_stack_delete(aml_local_stack_pop());
-#endif
 }
 
 static void
 acpi_execute_wak(acpi_softc_t *sc, u_int8_t state)
 {
-#if 1
-	acpi_execute_method(sc, state, ACPI_METHOD_WAK);
-#else
 	union	aml_object argv[1], *retval;
 
 	argv[0].type = aml_t_num;
@@ -2207,5 +1148,4 @@
 	aml_local_stack_push(aml_local_stack_create());
 	retval = aml_invoke_method_by_name("_WAK", 1, argv);
 	aml_local_stack_delete(aml_local_stack_pop());
-#endif
 }
Index: i386/acpi/aml/aml_region.c
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_region.c,v
retrieving revision 1.4
diff -u -r1.4 aml_region.c
--- i386/acpi/aml/aml_region.c	2000/06/18 17:51:32	1.4
+++ i386/acpi/aml/aml_region.c	2000/06/26 23:42:32
@@ -32,143 +32,34 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <machine/bus.h>
+#include <machine/pc/acpi.h>
 
 #include <i386/acpi/aml/aml_common.h>
 #include <i386/acpi/aml/aml_region.h>
 
-/*
- * ACPICA compatibility
- */
-typedef unsigned char			UINT8;
-typedef unsigned short			UINT16;
-typedef unsigned int			UINT32;
-typedef UINT32				NATIVE_UINT;
-typedef NATIVE_UINT			ACPI_IO_ADDRESS;
-
-static UINT32	OsdInX(ACPI_IO_ADDRESS, int);
-static void	OsdOutX(ACPI_IO_ADDRESS, UINT32, int);
-
-UINT8		OsdIn8(ACPI_IO_ADDRESS);
-UINT16		OsdIn16(ACPI_IO_ADDRESS);
-UINT32		OsdIn32(ACPI_IO_ADDRESS);
-void		OsdOut8(ACPI_IO_ADDRESS, UINT8);
-void		OsdOut16(ACPI_IO_ADDRESS, UINT16);
-void		OsdOut32(ACPI_IO_ADDRESS, UINT32);
-
-/*
- * Platform/Hardware independent I/O interfaces
- */
+#define AML_REGION_INPUT	0
+#define AML_REGION_OUTPUT	1
 
-static UINT32
-OsdInX(ACPI_IO_ADDRESS InPort, int bytes)
-{
-	bus_space_tag_t		bst;
-	bus_space_handle_t	bsh;
-	UINT32			retval;
-
-	bst = I386_BUS_SPACE_IO;
-	bsh = InPort;
-	switch (bytes) {
-	case 1:
-		retval = bus_space_read_1(bst, bsh, 0);
-		break;
-	case 2:
-		retval = bus_space_read_2(bst, bsh, 0);
-		break;
-	case 4:
-		retval = bus_space_read_4(bst, bsh, 0);
-		break;
-	default:
-		printf("OsdInX: wrong length to read\n");
-		retval = 0;
-	}
-	return (retval);
-}
-
-UINT8
-OsdIn8(ACPI_IO_ADDRESS InPort)
-{
-	return (OsdInX(InPort, 1) & 0xff);
-}
- 
-UINT16
-OsdIn16(ACPI_IO_ADDRESS InPort)
-{
-	return (OsdInX(InPort, 2) & 0xffff);
-}
- 
-UINT32
-OsdIn32(ACPI_IO_ADDRESS InPort)
-{
-	return (OsdInX(InPort, 4));
-}
-
-static void
-OsdOutX(ACPI_IO_ADDRESS OutPort, UINT32 Value, int bytes)
-{
-	bus_space_tag_t		bst;
-	bus_space_handle_t	bsh;
-
-	bst = I386_BUS_SPACE_IO;
-	bsh = OutPort;
-	switch (bytes) {
-	case 1:
-		bus_space_write_1(bst, bsh, 0, Value & 0xff);
-		break;
-	case 2:
-		bus_space_write_2(bst, bsh, 0, Value & 0xffff);
-		break;
-	case 4:
-		bus_space_write_4(bst, bsh, 0, Value);
-		break;
-	default:
-		printf("OsdOutX: wrong length to write\n");
-	}
-}
-
-void
-OsdOut8(ACPI_IO_ADDRESS OutPort, UINT8 Value)
-{
-	OsdOutX(OutPort, Value, 1);
-}
-
-void    
-OsdOut16(ACPI_IO_ADDRESS OutPort, UINT16 Value)
-{
-	OsdOutX(OutPort, Value, 2);
-}
-
-void
-OsdOut32(ACPI_IO_ADDRESS OutPort, UINT32 Value)
-{
-	OsdOutX(OutPort, Value, 4);
-}
-
-/*
- * region I/O
- */
-
-static int	aml_region_io_systemio(int, int, u_int32_t, u_int32_t *,
-				       u_int32_t, u_int32_t, u_int32_t);
-
-#define ACPI_REGION_INPUT	0
-#define ACPI_REGION_OUTPUT	1
-
 static int
-aml_region_io_systemio(int io, int regtype, u_int32_t flags, u_int32_t *valuep,
+aml_region_io_system(int io, int regtype, u_int32_t flags, u_int32_t *valuep,
     u_int32_t baseaddr, u_int32_t bitoffset, u_int32_t bitlen)
 {
 	u_int8_t	val, tmp, masklow, maskhigh;
 	u_int8_t	offsetlow, offsethigh;
-	u_int32_t	addr, byteoffset, bytelen;
+	vm_offset_t	addr, vaddr, byteoffset, bytelen;
 	int		value, readval;
 	int		state, i;
+	int		debug;
+
+	/* save debug level and shut it up */
+	debug = aml_debug;
+	aml_debug = 0;
 
 	value = *valuep;
 	val = readval = 0;
 	masklow = maskhigh = 0xff;
 	state = 0;
+	vaddr = 0;
 
 	byteoffset = bitoffset / 8;
 	bytelen = bitlen / 8 + ((bitlen % 8) ? 1 : 0);
@@ -191,12 +82,30 @@
 		AML_PRINTF("\t[offsethigh = 0x%x, maskhigh = 0x%x, ~maskhigh = 0x%x]\n",
 		    offsethigh, maskhigh, ~maskhigh & 0xff);
 	}
-	for (i = bytelen; i > 0; i--, addr++) {
-		val = OsdIn8(addr);
+
+	if (regtype == 0) {
+		OsdMapMemory((void *)addr, bytelen, (void **)&vaddr);
+	}
+	for (i = 0; i < bytelen; i++) {
+		/* XXX */
+		switch (regtype) {
+		case 0:
+			val = *(volatile u_int8_t *)(vaddr + i);
+			break;
+		case 1:
+			val = OsdIn8(addr);
+			break;
+		default:
+			printf("aml_region_io_system: not supported yet (%d)\n",
+			    regtype);
+			val = 0;
+			break;
+		}
+
 		AML_PRINTF("\t[%d:0x%02x@0x%x]", regtype, val, addr);
 
 		switch (io) {
-		case ACPI_REGION_INPUT:
+		case AML_REGION_INPUT:
 			tmp = val;
 			/* the lowest byte? */
 			if (i == bytelen) {
@@ -227,7 +136,7 @@
 			*valuep = value;
 
 			break;
-		case ACPI_REGION_OUTPUT:
+		case AML_REGION_OUTPUT:
 			tmp = value & 0xff;
 			/* the lowest byte? */
 			if (i == bytelen) {
@@ -245,11 +154,31 @@
 			AML_PRINTF("->[%d:0x%02x@0x%x]\n",
 				    regtype, tmp, addr);
 			val = tmp;
-			OsdOut8(addr, val);
+
+			/* XXX */
+			switch (regtype) {
+			case 0:
+				*(volatile u_int8_t *)(vaddr + i) = val;
+				break;
+			case 1:
+				OsdOut8(addr, val);
+				break;
+			default:
+				printf("aml_region_io_system: not supported yet (%d)\n",
+				    regtype);
+				break;
+			}
+
 			break;
 		}
 	}
 
+	if (regtype == 0) {
+		OsdUnMapMemory((void *)vaddr, bytelen);
+	}
+
+	aml_debug = debug;	/* restore debug devel */
+
 	return (state);
 }
 
@@ -260,16 +189,9 @@
 	int	value;
 	int	state;
 
-	value = 0;
-	switch (regtype) {
-	case 1:
-		state = aml_region_io_systemio(ACPI_REGION_INPUT, regtype,
-		    flags, &value, addr, bitoffset, bitlen);
-		AML_SYSASSERT(state != -1);
-		break;
-	default:
-		printf("aml_region_read: not supported yet\n");
-	}
+	state = aml_region_io_system(AML_REGION_INPUT, regtype,
+	    flags, &value, addr, bitoffset, bitlen);
+	AML_SYSASSERT(state != -1);
 
         return (value);
 }
@@ -287,16 +209,9 @@
 {
 	int	state;
 
-	state = 0;
-	switch (regtype) {
-	case 1:
-		state = aml_region_io_systemio(ACPI_REGION_OUTPUT, regtype,
-		    flags, &value, addr, bitoffset, bitlen);
-		AML_SYSASSERT(state != -1);
-		break;
-	default:
-		printf("aml_region_write: not supported yet\n");
-	}
+	state = aml_region_io_system(AML_REGION_OUTPUT, regtype,
+	    flags, &value, addr, bitoffset, bitlen);
+	AML_SYSASSERT(state != -1);
 
         return (state);
 }
Index: i386/include/pc/acpi.h
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/include/pc/acpi.h,v
retrieving revision 1.6
diff -u -r1.6 acpi.h
--- i386/include/pc/acpi.h	2000/05/29 16:08:07	1.6
+++ i386/include/pc/acpi.h	2000/06/26 13:06:24
@@ -174,6 +174,59 @@
 void            acpi_print_rsdt(struct ACPIsdt * rsdp);
 void            acpi_print_facp(struct FACPbody * facp);
 void            acpi_print_dsdt(struct ACPIsdt * dsdp);
+
+#else	/* _KERNEL */
+/*
+ * ACPICA compatibility
+ */
+#ifdef _IA64
+typedef signed char			INT8;
+typedef unsigned char			UINT8;
+typedef unsigned char			UCHAR;
+typedef short				INT16;
+typedef unsigned short			UINT16;
+typedef int				INT32;
+typedef unsigned int			UINT32;
+typedef long				INT64;
+typedef unsigned long			UINT64;
+
+typedef UINT64				NATIVE_UINT;
+typedef INT64				NATIVE_INT;
+
+typedef NATIVE_UINT			ACPI_TBLPTR;
+#else	/* !_IA64 */
+typedef signed char			INT8;
+typedef unsigned char			UINT8;
+typedef unsigned char			UCHAR;
+typedef short				INT16;
+typedef unsigned short			UINT16;
+typedef int				INT32;
+typedef unsigned int			UINT32;
+
+typedef UINT32				NATIVE_UINT;
+typedef INT32				NATIVE_INT;
+
+typedef NATIVE_UINT			ACPI_TBLPTR;
+#endif	/* _IA64 */
+
+/* common types */
+typedef NATIVE_UINT			ACPI_IO_ADDRESS;
+typedef UINT32				ACPI_STATUS;
+
+/*
+ * ACPICA Osd family functions
+ */
+
+ACPI_STATUS	OsdMapMemory(void *, UINT32, void **);
+void		OsdUnMapMemory(void *, UINT32);
+
+UINT8		OsdIn8(ACPI_IO_ADDRESS);
+UINT16		OsdIn16(ACPI_IO_ADDRESS);
+UINT32		OsdIn32(ACPI_IO_ADDRESS);
+void		OsdOut8(ACPI_IO_ADDRESS, UINT8);
+void		OsdOut16(ACPI_IO_ADDRESS, UINT16);
+void		OsdOut32(ACPI_IO_ADDRESS, UINT32);
+
 #endif	/* !_KERNEL */
 
 #endif	/* _MACHINE_PC_ACPI_H_ */

----Next_Part(Tue_Jun_27_09:20:40_2000_518)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="i386_acpi.c"

/*-
 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	$Id$
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/vmparam.h>
#include <machine/pc/acpi.h>
#include <vm/vm.h>
#include <vm/pmap.h>

/*
 * ACPICA compatibility
 */

static UINT32	OsdInX(ACPI_IO_ADDRESS, int);
static void	OsdOutX(ACPI_IO_ADDRESS, UINT32, int);

/*
 * Platform/Hardware independent I/O interfaces
 */

static UINT32
OsdInX(ACPI_IO_ADDRESS InPort, int bytes)
{
	bus_space_tag_t		bst;
	bus_space_handle_t	bsh;
	UINT32			retval;

	bst = I386_BUS_SPACE_IO;
	bsh = InPort;
	switch (bytes) {
	case 1:
		retval = bus_space_read_1(bst, bsh, 0);
		break;
	case 2:
		retval = bus_space_read_2(bst, bsh, 0);
		break;
	case 4:
		retval = bus_space_read_4(bst, bsh, 0);
		break;
	default:
		printf("OsdInX: wrong length to read\n");
		retval = 0;
	}
	return (retval);
}

UINT8
OsdIn8(ACPI_IO_ADDRESS InPort)
{
	return (OsdInX(InPort, 1) & 0xff);
}
 
UINT16
OsdIn16(ACPI_IO_ADDRESS InPort)
{
	return (OsdInX(InPort, 2) & 0xffff);
}
 
UINT32
OsdIn32(ACPI_IO_ADDRESS InPort)
{
	return (OsdInX(InPort, 4));
}

static void
OsdOutX(ACPI_IO_ADDRESS OutPort, UINT32 Value, int bytes)
{
	bus_space_tag_t		bst;
	bus_space_handle_t	bsh;

	bst = I386_BUS_SPACE_IO;
	bsh = OutPort;
	switch (bytes) {
	case 1:
		bus_space_write_1(bst, bsh, 0, Value & 0xff);
		break;
	case 2:
		bus_space_write_2(bst, bsh, 0, Value & 0xffff);
		break;
	case 4:
		bus_space_write_4(bst, bsh, 0, Value);
		break;
	default:
		printf("OsdOutX: wrong length to write\n");
	}
}

void
OsdOut8(ACPI_IO_ADDRESS OutPort, UINT8 Value)
{
	OsdOutX(OutPort, Value, 1);
}

void    
OsdOut16(ACPI_IO_ADDRESS OutPort, UINT16 Value)
{
	OsdOutX(OutPort, Value, 2);
}

void
OsdOut32(ACPI_IO_ADDRESS OutPort, UINT32 Value)
{
	OsdOutX(OutPort, Value, 4);
}

ACPI_STATUS
OsdMapMemory(void *PhysicalAddress, UINT32 Length, void **LogicalAddress)
{
	vm_offset_t	PhysicalEnd;
	vm_offset_t	PhysicalOffs;

	PhysicalEnd = (vm_offset_t)PhysicalAddress + Length;
	if (PhysicalEnd < 1024 * 1024) {
		/*
		 * The first 1Mb is mapped at KERNBASE.
		 */
		*LogicalAddress = (void *)(uintptr_t)
				  (KERNBASE + (vm_offset_t)PhysicalAddress);
	} else {
		PhysicalOffs = (vm_offset_t)PhysicalAddress -
			       trunc_page((vm_offset_t)PhysicalAddress);
		*LogicalAddress = (caddr_t)
		    pmap_mapdev((vm_offset_t)PhysicalAddress - PhysicalOffs,
				Length + PhysicalOffs) + PhysicalOffs;
	}

	return (0);
}

void    
OsdUnMapMemory(void *LogicalAddress, UINT32 Length)
{

	if ((vm_offset_t)LogicalAddress + Length - KERNBASE >= 1024 * 1024) {
		pmap_unmapdev((vm_offset_t)LogicalAddress, Length);
	}
}

----Next_Part(Tue_Jun_27_09:20:40_2000_518)----
