From owner-acpi-jp@jp.freebsd.org  Fri Jun  2 23:13:41 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id XAA07994;
	Fri, 2 Jun 2000 23:13:41 +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 XAA07989
	for <acpi-jp@jp.freebsd.org>; Fri, 2 Jun 2000 23:13:40 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (isdnb31.imasy.or.jp [202.227.24.159])
	by tasogare.imasy.or.jp (8.10.1+3.3W/3.7W-tasogare/smtpfeed 1.04) with ESMTP id e52EDcP33473
	for <acpi-jp@jp.freebsd.org>; Fri, 2 Jun 2000 23:13:38 +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: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Message-Id: <20000602231332X.iwasaki@jp.FreeBSD.org>
Date: Fri, 02 Jun 2000 23:13:32 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 148
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 362
Subject: [acpi-jp 362] objref fix and more
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

objref $B4XO"$N(B fix $B$H(B StoreOp $B$N5!G=DI2C(B(?) $B$G$9!#(B

$B8=>u!"(BStore() $B$G(B source $BB&$K(B objref $B$,$"$k>l9g$OA[Dj$5$l$F$$$J$$%3!<%I(B
$B$K$J$C$F$$$^$9$,!"$3$NC&(B Reference $B2=$N=hM}$KLdBj$,$"$j$^$7$?!#(B
$BL5M}$d$j(B acpi_eval_name(env, obj->objref.nameref) $B$N$h$&$K(B nameref $B$r(B
eval $B$9$k$h$&$K$7$F$$$^$9$,!"I,$:$7$b85$N%*%V%8%'%/%H$,L>A0IU$-$H$O(B
$B8B$j$^$;$s!#$=$&$$$&>l9g$O%*%V%8%'%/%H$O0UL#$N$"$kCM$r;}$C$F$$$k$K$b(B
$B$+$+$o$i$:L>A0L5$7$J$N$GI>2A7k2L$,(B NULL $B$H$J$j$^$9!#(B
$B2r7h:v$H$7$F%*%V%8%'%/%H$=$N$b$N$r(B eval $B$9$k(B acpi_eval_object() $B$r(B
$BMQ0U$9$k$3$H$r9M$($^$7$?$,!"Bg2~B$$K$J$j$=$&$@$C$?$N$G!"$H$j$"$($:(B 
objref $B7?$@$1$N$b$N$rMQ0U$7$^$7$?!#(B

AddOp $B$NBh;00z?t$N%*%V%8%'%/%H$J$I$K$O%*%W%7%g%s$G7k2L$r3JG<$G$-$k$h$&(B
$B$K$J$C$F$$$^$9$,!";XDj$5$l$F$$$J$$>l9g$O(B Zero $B$,F~$C$F$*$j!"$3$l$KBP$9(B
$B$k(B Store $B$NL5BL$J=hM}$,<B9T$5$l$F$$$^$9!#7k2L$N(B Store $B$r8F$S=P$98D=j(B
$B$9$Y$F$K%A%'%C%/$rF~$l$k$N$O%$%d$@$C$?$N$G!"(Bacpi_store_to_name() $B$N(B
$B0lO"$N%(%i!<%A%'%C%/$N0l$D$H$7$F5[<}$9$k$h$&$K$7$F$_$^$7$?!#(B

$BLdBjL5$1$l$PL@F|$NLk$"$?$j$K(B commit $B$7$^$9!#(B
$B$G!"(Baml/ $B$,(B kernel $B$GF0$/$h$&$K$9$k$?$a$N:n6H$r3+;O$7$^$9$,!"(B
takawata $B$5$s$,$9$G$K$d$i$l$?:n6H$O$I$s$I$sH?1G$7$F$$$C$F$/$@$5$$$J(B :-)

Index: aml_evalobj.c
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_evalobj.c,v
retrieving revision 1.14
diff -u -r1.14 aml_evalobj.c
--- aml_evalobj.c	2000/06/02 07:15:10	1.14
+++ aml_evalobj.c	2000/06/02 13:17:58
@@ -115,6 +115,55 @@
 	return &env->wobj;
 	
 }
+
+union aml_object *
+acpi_eval_objref(struct aml_environ *env, union aml_object *obj)
+{
+	int	offset;
+	union aml_object num1;
+	union aml_object *ref, *ret = obj;
+
+	if (obj->objref.deref == 1) {
+		num1.type = aml_t_num;
+		offset = obj->objref.offset;
+		ref = obj->objref.ref;
+		if (ref == NULL) {
+			goto out;
+		}
+
+		switch (ref->type) {
+		case aml_t_package:
+			if (ref->package.elements > offset) {
+				ret = ref->package.objects[offset];
+			} else {
+				num1.num.number = 0;
+				env->wobj = num1;
+				ret = &env->wobj;
+			}
+			break;
+		case aml_t_buffer:
+			if (ref->buffer.size > offset) {
+				num1.num.number = ref->buffer.data[offset] & 0xff;
+			} else {
+				num1.num.number = 0;
+			}
+			env->wobj = num1;
+			ret = &env->wobj;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (obj->objref.alias == 1) {
+		ret = acpi_eval_name(env, obj->objref.nameref);
+		goto out;
+	}
+
+out:
+	return ret;
+}
+
 /*
  * Eval named object.
  */
@@ -169,6 +218,10 @@
 		union aml_object num1;
 		union aml_object *ref;
 
+#if 1
+		ret = acpi_eval_objref(env, aname->property);
+		goto out;
+#else
 		if (aname->property->objref.deref == 1) {
 			ret = obj = aname->property;
 			num1.type = aml_t_num;
@@ -212,6 +265,7 @@
 
 		ret = aname->property;
 		goto out;
+#endif
 	}
 	case aml_t_field:
 		acpi_free_objectcontent(&env->wobj);
Index: aml_evalobj.h
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_evalobj.h,v
retrieving revision 1.5
diff -u -r1.5 aml_evalobj.h
--- aml_evalobj.h	2000/06/02 07:15:10	1.5
+++ aml_evalobj.h	2000/06/02 13:17:58
@@ -26,6 +26,8 @@
  *	$Id: aml_evalobj.h,v 1.5 2000/06/02 07:15:10 yokoyama Exp $
  */
 
+union aml_object	*acpi_eval_objref(struct aml_environ *,
+					  union aml_object *);
 union aml_object 
 *acpi_eval_name(struct aml_environ *, struct aml_name *);
 int acpi_objtonum(struct aml_environ *,union aml_object *);
Index: aml_store.c
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_store.c,v
retrieving revision 1.11
diff -u -r1.11 aml_store.c
--- aml_store.c	2000/06/02 07:15:10	1.11
+++ aml_store.c	2000/06/02 13:19:33
@@ -308,11 +308,19 @@
 		return;
 	}
 
+	/* no need to store to Zero object */
+	if (name->name[0] == NULL && name->property != NULL &&
+	    name->property->type == aml_t_num &&
+	    name->property->num.number == 0) {
+		return;
+	}
+
 	/* try to dereference */
 	if (obj->type == aml_t_objref && obj->objref.deref == 0) {
 		DPRINT("Source object isn't dereferenced yet, "
 		       "try to dereference anyway\n");
-		obj = acpi_eval_name(env, obj->objref.nameref);
+		obj->objref.deref = 1;
+		obj = acpi_eval_objref(env, obj);
 	}
 
 	switch(name->property->type){
