From owner-acpi-jp@jp.freebsd.org  Fri Mar 17 16:34:23 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id QAA37594;
	Fri, 17 Mar 2000 16:34:23 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from mail.ogis-ri.co.jp (ns.ogis-ri.co.jp [158.201.127.1])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id QAA37589
	for <acpi-jp@jp.freebsd.org>; Fri, 17 Mar 2000 16:34:21 +0900 (JST)
	(envelope-from yokoyama@o3.otc.ogis-ri.co.jp)
Received: from nozomi.icc.ogis-ri.co.jp (nozomi.icc.ogis-ri.co.jp [158.201.123.33])
	by mail.ogis-ri.co.jp (8.9.2+3.1W/3.7W0002211103) with ESMTP id QAA25218
	for <acpi-jp@jp.freebsd.org>; Fri, 17 Mar 2000 16:33:45 +0900 (JST)
Received: from o3.otc.ogis-ri.co.jp (o3.otc.ogis-ri.co.jp [158.201.73.1]) by nozomi.icc.ogis-ri.co.jp (8.9.3+3.2W/3.5Wpl2-ogismail1.0) with ESMTP id QAA14843 for <acpi-jp@jp.freebsd.org>; Fri, 17 Mar 2000 16:33:43 +0900 (JST)
Received: from localhost (arcturus.o3.otc.ogis-ri.co.jp [158.201.73.15]) by o3.otc.ogis-ri.co.jp (8.8.4/3.5Wpl597042212) with ESMTP id QAA05053; Fri, 17 Mar 2000 16:33:42 +0900 (JST)
To: acpi-jp@jp.freebsd.org
Cc: Yasuo Yokoyama / =?iso-2022-jp?B?GyRCMiM7M0JZSVcbKEI=?=
 <yokoyama@o3.otc.ogis-ri.co.jp>
From: Yasuo Yokoyama / =?iso-2022-jp?B?GyRCMiM7M0JZSVcbKEI=?=
 <yokoyama@o3.otc.ogis-ri.co.jp>
In-Reply-To: <200002080652.PAA09798@o3.otc.ogis-ri.co.jp>
References: <200002041538.AAA09126@o3.otc.ogis-ri.co.jp>
	<200002071409.XAA04436@tasogare.imasy.or.jp>
	<200002080652.PAA09798@o3.otc.ogis-ri.co.jp>
X-Mailer: Mew version 1.95b3 on XEmacs 21.1 (Biscayne)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Fri_Mar_17_16:33:38_2000_250)--"
Content-Transfer-Encoding: 7bit
Message-Id: <20000317163346N.yokoyama@o3.otc.ogis-ri.co.jp>
Date: Fri, 17 Mar 2000 16:33:46 +0900
X-Dispatcher: imput version 991025(IM133)
Lines: 1539
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 279
Subject: [acpi-jp 279] Re: Destroy Objects
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: yokoyama@o3.otc.ogis-ri.co.jp

----Next_Part(Fri_Mar_17_16:33:38_2000_250)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B2#;3$G$9!#(B

In Message <200002080652.PAA09798@o3.otc.ogis-ri.co.jp>
	Yasuo Yokoyama/$B2#;3!!BYIW(B <yokoyama@o3.otc.ogis-ri.co.jp> wrote:

> >> temporary_object $B$N<h$j07$$$N$H$3$m$O2u$l$F$^$9!#(B
> $B$J$s$G!"(BReference $B4X78$,(B leak $B$r5/$3$9$s$8$c$J$$$+$H;W$$$^$9!#(B
> $BD>$9$^$G!"(Bcommit $B$7$J$$$[$&$,$$$$$G$7$g$&(B

$BBgJQCY$/$J$C$F?=$7Lu$J$$$G$9!#:#0l$D%F%9%H$,==J,$G$J$$$N$G$9$,(B
$B3+H/$K;H$C$F$$$k(B NotePC $B$,(B HDD $B%/%i%C%7%e$G$7$P$i$/I|5l$7$=$&$K$J$$$N$G(B
$B$3$l$^$G$N:n6HJ,$N(B patch $B$rE:IU$7$F$*$-$^$9!#(B
$BJQ99FbMF$O!"(B
$B!&(Bstruct aml_environ $B$+$i(B local object $B$rJ];}$7$F$$$k%j%s%/$H!"(BLocalX, ArgX 
 $B$rJ,N%$7$FFHN)$7$?9=B$BN$GJ];}$9$k!#(B
$B!&(Baml_name $B$r(B local object $B$H$7$FJ];}$G$-$k$h$&$K$9$k!#(B(RefOfOp $B$N%*%Z%i%s%I$,(B
  NameString $B$N;~$NBP1~(B)
$B!&(BReturnOp $B$N;~$K!"%*%Z%i%s%I$r(B eval $B$7$F!"F@$?(Bobject $B$r(B copy $B$7$FJV$9MM$KJQ99(B

----Next_Part(Fri_Mar_17_16:33:38_2000_250)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch.localobject"

Index: Makefile
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- Makefile	2000/01/02 20:04:31	1.6
+++ Makefile	2000/03/07 04:05:09
@@ -1,5 +1,5 @@
 PROG=	acpiconf
-SRCS=	parse name acpi acpi_user amlmem memman store obj evalobj search main debug region
+SRCS=	parse.c name.c acpi.c acpi_user.c amlmem.c memman.c store.c obj.c evalobj.c main.c debug.c region.c
 NOMAN=	yes
 DEBUG_FLAGS= -g  -Wall 
 #To run under FreeBSD2.2 Use following debug flag
Index: amlmem.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/amlmem.c,v
retrieving revision 1.5
diff -u -r1.5 amlmem.c
--- amlmem.c	2000/01/27 16:00:14	1.5
+++ amlmem.c	2000/03/07 04:23:19
@@ -50,10 +50,10 @@
 MEMMAN_INITIALSTORAGE_DESC(struct aml_bufferfield, _aml_bufferfield_storage);
 MEMMAN_INITIALSTORAGE_DESC(enum aml_objtype, _aml_objtype_storage);
 MEMMAN_INITIALSTORAGE_DESC(struct aml_name, _aml_name_storage);
-MEMMAN_INITIALSTORAGE_DESC(struct aml_nameptr, _aml_nameptr_storage);
+MEMMAN_INITIALSTORAGE_DESC(struct aml_name_group, _aml_name_group_storage);
 MEMMAN_INITIALSTORAGE_DESC(struct aml_objref, _aml_objref_storage);
 MEMMAN_INITIALSTORAGE_DESC(struct aml_environ, _aml_environ_storage);
-MEMMAN_INITIALSTORAGE_DESC(struct aml_objectptr, _aml_objectptr_storage);
+MEMMAN_INITIALSTORAGE_DESC(struct aml_local_stack, _aml_objectptr_storage);
 
 memman_blockman_t aml_blockman[] = {
 	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_namestr), _aml_namestr_storage),
@@ -70,10 +70,10 @@
 	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_bufferfield), _aml_bufferfield_storage),
 	MEMMAN_MEMBLOCK_DESC(sizeof(enum aml_objtype), _aml_objtype_storage),
 	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_name), _aml_name_storage),
-	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_nameptr), _aml_nameptr_storage),
+	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_name_group), _aml_name_group_storage),
 	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_objref), _aml_objref_storage),
 	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_environ), _aml_environ_storage),
-	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_objectptr), _aml_objectptr_storage),
+	MEMMAN_MEMBLOCK_DESC(sizeof(struct aml_local_stack), _aml_objectptr_storage),
 };
 
 memman_histogram_t aml_histogram[MEMMAN_HISTOGRAM_SIZE];
Index: amlmem.h
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/amlmem.h,v
retrieving revision 1.4
diff -u -r1.4 amlmem.h
--- amlmem.h	2000/01/27 16:00:14	1.4
+++ amlmem.h	2000/03/07 04:23:31
@@ -49,10 +49,10 @@
 	memid_aml_bufferfield,
 	memid_aml_objtype,
 	memid_aml_name,
-	memid_aml_nameptr,
+	memid_aml_name_group,
 	memid_aml_objref,
 	memid_aml_environ,
-	memid_aml_objectptr,
+	memid_aml_local_stack,
 };
 
 extern memman_t	*aml_memman;
Index: debug.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/debug.c,v
retrieving revision 1.7
diff -u -r1.7 debug.c
--- debug.c	2000/01/27 16:00:14	1.7
+++ debug.c	2000/03/07 07:52:05
@@ -36,7 +36,6 @@
 #include "status.h"
 #include "env.h"
 #include "obj.h"
-#include "search.h"
 #include "evalobj.h"
 #include "parse.h"
 #include "store.h"
@@ -176,18 +175,22 @@
 			}
 		show_variables:
 			for (i = 0; i < 7; i++) {
-				if (env2->argumentvalue[i].property == NULL) {
-					break;
+			  struct aml_name *tmp =
+			    aml_local_stack_getArgX(NULL, i);
+				if (tmp == NULL || tmp->property == NULL) {
+				  break;
 				}
 				printf("  Arg%d    ", i);
-				showobject(env2->argumentvalue[i].property);
+				showobject(tmp->property);
 			}
 			for (i = 0; i < 8; i++) {
-				if (env2->localvalue[i].property == NULL) {
+			  struct aml_name *tmp =
+			    aml_local_stack_getLocalX(i);
+				if (tmp == NULL || tmp->property == NULL) {
 					continue;
 				}
 				printf("  Local%d  ", i);
-				showobject(env2->localvalue[i].property);
+				showobject(tmp->property);
 			}
 			break;
 		}
@@ -219,7 +222,7 @@
 			char	argbuf[7][BUFLEN];
 			char	*np, *ep;
 			int	i;
-
+			int     argnum;
 			/* NULL terminate */
 			ptr = &commandline[1];
 			while (ptr[0] != '\n')	ptr++;
@@ -234,23 +237,26 @@
 			}
 			name = search_aml_name_recursive(get_rootname(), ptr);
 			if (name == NULL) {
+			  printf("%s:%d:acpi_dbgr: not found name %s\n", __FILE__, __LINE__, ptr);
 				break;
 			}
 			if (name->property == NULL ||
 			    name->property->type != aml_t_method) {
+			  printf("%s:%d:acpi_dbgr: not method %s\n", __FILE__, __LINE__, ptr);
 				break;
 			}
 
 			showobject(name->property);
 			method = ptr;
 
-			if (name->property->meth.argnum) {
+			argnum = name->property->meth.argnum & 0x07;
+			if (argnum) {
 				fputs("  Enter argument values "
 				    "(ex. number 1 / string foo). "
 				    "'q' to quit.\n",stderr);
 			}
 			/* get and parse argument values */
-			for (i = 0; i < name->property->meth.argnum; i++) {
+			for (i = 0; i < argnum; i++) {
 			retry:
 				fprintf(stderr, "  Arg%d ? ", i);
 				if (read(0, argbuf[i], BUFLEN) == 0) {
@@ -312,10 +318,10 @@
 			}
 			bzero(lastcommand, sizeof lastcommand);
 			fprintf(stderr, "==== Running %s. ====\n", method);
-			retval = acpi_invoke_method_by_name(method,
-			    name->property->meth.argnum, argv);
+			aml_local_stack_push(aml_local_stack_create());
+			retval = acpi_invoke_method_by_name(method,argnum, argv);
 			showobject(retval);
-			acpi_free_object(&retval);
+			aml_local_stack_delete(aml_local_stack_pop());
 			fprintf(stderr, "==== %s finished. ====\n", method);
 		finish_execution:
 			break;
@@ -434,7 +440,7 @@
 			printf(" (offset %d)", obj->objref.offset);
 		}
 		printf(" of ");
-		showobject(*(obj->objref.ref));
+		showobject(obj->objref.ref);
 		break;
 	default:
 		printf("UNK ID=%d\n", obj->type);
Index: env.h
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/env.h,v
retrieving revision 1.5
diff -u -r1.5 env.h
--- env.h	2000/01/27 16:00:14	1.5
+++ env.h	2000/03/07 08:50:37
@@ -25,7 +25,11 @@
  *
  *	$Id: env.h,v 1.5 2000/01/27 16:00:14 iwasaki Exp $
  */
+#ifndef _ENV_H_
+#define _ENV_H_
+
 #include "name.h"
+#include "obj.h"
 #include "status.h"
 
 struct aml_environ {
@@ -33,13 +37,8 @@
 	 u_int8_t       *end;
 	 enum aml_status stat;
 	 struct aml_name *curname;
-	 struct aml_name localvalue[8];
-	 struct aml_name argumentvalue[7];
 	 struct aml_name work;
 	 union aml_object wobj;
-	 struct aml_name_list created_on_exec;
-	 unsigned	executing;
-	 unsigned	work_needfree;
-	 struct aml_object_list temporary_objects;
        };
 
+#endif /* _ENV_H_ */
Index: evalobj.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/evalobj.c,v
retrieving revision 1.9
diff -u -r1.9 evalobj.c
--- evalobj.c	2000/01/27 16:00:14	1.9
+++ evalobj.c	2000/03/07 08:50:20
@@ -43,7 +43,6 @@
 #include "obj.h"
 #include "evalobj.h"
 #include "parse.h"
-#include "search.h"
 #include "store.h"
 #include "region.h"
 #include <stdlib.h>
@@ -110,6 +109,7 @@
 	int argnum,i;
 	struct aml_environ *copy;
 	union aml_object *obj, *ret = NULL;
+	struct aml_local_stack *stack;
 	if (aname==NULL||aname->property == NULL)
 		return NULL;
 	if(env->stat==aml_stat_panic){
@@ -152,14 +152,11 @@
 		union aml_object num1;
 		union aml_object *ref;
 
-		if (aname->property != &env->wobj) {
-			acpi_free_objectcontent(&env->wobj);
-		}
 		if (aname->property->objref.deref == 1) {
 			ret = obj = aname->property;
 			num1.type = aml_t_num;
 			offset = obj->objref.offset;
-			ref = *(obj->objref.ref);
+			ref = obj->objref.ref;
 			if (ref == NULL) {
 				aname->property = ret;
 				return aname->property;
@@ -169,14 +166,8 @@
 			case aml_t_package:
 				if (ref->package.elements > offset) {
 					ret = ref->package.objects[offset];
-					if (obj != &env->wobj) {
-						acpi_free_object(&obj);
-					}
 				} else {
 					num1.num.number = 0;
-					if (obj != &env->wobj) {
-						acpi_free_object(&obj);
-					}
 					env->wobj = num1;
 					ret = &env->wobj;
 				}
@@ -187,9 +178,6 @@
 				} else {
 					num1.num.number = 0;
 				}
-				if (obj != &env->wobj) {
-					acpi_free_object(&obj);
-				}
 				env->wobj = num1;
 				ret = &env->wobj;
 				break;
@@ -213,63 +201,45 @@
 		copy->dp=aname->property->meth.from;
 		copy->end=aname->property->meth.to;
 		copy->stat=aml_stat_none;
+		stack = aml_local_stack_create();
 		DPRINT("(");
 		for(i=0;i<argnum;i++){
-			copy->argumentvalue[i].property=acpi_copy_object
-			    (env,acpi_eval_name
-				(env,acpi_parse_termobj(env,0)));
+		  aml_local_stack_getArgX(stack,i)->property 
+		    =  acpi_copy_object(env, acpi_eval_name(env,
+			       acpi_parse_termobj(env,0)));
 			if (i < argnum-1)
 				DPRINT(", ");
 		}
 		DPRINT(")\n");
-		
-		bzero(&copy->localvalue,sizeof(struct aml_name)*8);
+		aml_local_stack_push(stack);
 		if(env->stat==aml_stat_step){
 			acpi_dbgr(env,copy);
 		}
-		obj=acpi_eval_name(env,acpi_execute_method(copy));
-		acpi_free_childname(copy->curname);
+
+		tmp = acpi_execute_method(copy);
+		obj=acpi_eval_name(env, tmp);
 		if(copy->stat==aml_stat_panic){
 			DPRINT("PANIC OCCURED IN METHOD");
 			env->stat=aml_stat_panic;
 			ret = NULL;
+			aml_local_stack_delete(aml_local_stack_pop());
 			goto out;
 		}
 		showobject(obj);
-#if 0
-		env->wobj.type=aml_t_num;/*Temporally*/
-		env->wobj.num.number=0;
-#else
+
+		if (tmp)
+		  tmp->property = NULL;
+		aml_local_stack_delete(aml_local_stack_pop());
 		if (obj) {
-			switch (obj->type) {
-			case aml_t_objref:
-				ret = obj;
-				break;
-			default:
-				ret = acpi_copy_object(env, obj);
-				break;
-			}
-			env->wobj = *ret;
-			memman_free(aml_memman, memid_unkown, ret);
-		} else {
-			env->wobj.type = aml_t_num;
-			env->wobj.num.number = 0;
-		}
-#endif
-		for(i=0;i<argnum;i++){
-			acpi_free_object(&copy->argumentvalue[i].property);
+		  aml_create_local_object()->property = obj;
+		  ret = obj;
 		}
-		for(i=0;i<8;i++){
-			acpi_free_object(&copy->localvalue[i].property);
+		else {
+		  env->wobj.type = aml_t_num;
+		  env->wobj.num.number = 0;
 		}
 
-#if 1
-		/* we have a return value in env->wobj already, try to free obj */
-		if (obj == copy->work.property && copy->work_needfree == 1) {
-			acpi_free_object(&obj);
-		}
-#endif
-		ret = &env->wobj;
+		/*		ret = &env->wobj; ????? */
 		goto out;
 	case aml_t_bufferfield:
 		acpi_free_objectcontent(&env->wobj);
@@ -305,25 +275,10 @@
 *acpi_execute_method(struct aml_environ *env)
 {
 	struct aml_name *name;
-	struct aml_nameptr *created;
-	struct aml_environ *orgenv;
-	struct aml_objectptr *objptr;
-	
-	orgenv = memman_alloc(aml_memman, memid_aml_environ);
-	if (orgenv == NULL) {
-		return NULL;
-	}
+	struct aml_name_group *newgrp;
 
-#if 1
-	orgenv->executing = env->executing;
-	memcpy(&orgenv->created_on_exec, &env->created_on_exec,
-	    sizeof env->created_on_exec);
-	TAILQ_INIT(&env->created_on_exec);
-	env->executing = 1;
-	memcpy(&orgenv->temporary_objects, &env->temporary_objects,
-	    sizeof env->temporary_objects);
-	TAILQ_INIT(&env->temporary_objects);
-#endif
+	newgrp = new_aml_name_group(AML_NAME_GROUP_IN_METHOD);
+
 	DPRINT("[");
 	acpi_print_curname(env->curname);
 	DPRINT(" START]\n");
@@ -332,40 +287,8 @@
 	DPRINT("[");
 	acpi_print_curname(env->curname);
 	DPRINT(" END]\n");
-
-#if 1
-	env->work_needfree = 0;
-	while (!TAILQ_EMPTY(&env->created_on_exec)) {
-		created = TAILQ_FIRST(&env->created_on_exec);
-		if (name != NULL && name->property == created->name->property) {
-			name = &env->work;
-			name->property = acpi_copy_object(env, created->name->property);
-			env->work_needfree = 1;
-		}
-		acpi_free_childname_one(get_rootname(), created->name);
-		TAILQ_REMOVE(&env->created_on_exec, created, links);
-		memman_free(aml_memman, memid_aml_nameptr, created);
-	}
-	TAILQ_INIT(&env->created_on_exec);
-
-	while (!TAILQ_EMPTY(&env->temporary_objects)) {
-		objptr = TAILQ_FIRST(&env->temporary_objects);
-		TAILQ_REMOVE(&env->temporary_objects, objptr, links);
-		if (objptr->object != NULL &&
-		    objptr->object->type != aml_t_null) {
-			acpi_free_object(&objptr->object);
-		}
-		memman_free(aml_memman, memid_aml_objectptr, objptr);
-	}
-	TAILQ_INIT(&env->temporary_objects);
 
-	memcpy(&env->created_on_exec, &orgenv->created_on_exec,
-	    sizeof env->created_on_exec);
-	env->executing = orgenv->executing;
-	memcpy(&env->temporary_objects, &orgenv->temporary_objects,
-	    sizeof env->temporary_objects);
-	memman_free(aml_memman, memid_aml_environ, orgenv);
-#endif
+	delete_aml_name_group(newgrp);
 	return name;
 }
 
@@ -388,35 +311,29 @@
 
 	if (name != NULL && name->property != NULL &&
 	    name->property->type == aml_t_method) {
+	  struct aml_local_stack *stack;
+	  struct aml_name *tmp;
 		env->curname = name;
 		env->dp = name->property->meth.from;
 		env->end = name->property->meth.to;
 		acpi_dbgr(env,env);
+		stack = aml_local_stack_create();
 		for (i = 0; i < argc; i++) {
-			env->argumentvalue[i].property = acpi_alloc_object(argv[i].type, &argv[i]);
+		  aml_local_stack_getArgX(stack, i)->property
+		    = acpi_alloc_object(argv[i].type, &argv[i]);
 		}
-		obj = acpi_eval_name(env, acpi_execute_method(env));
+		aml_local_stack_push(stack);
+		obj = acpi_eval_name(env, tmp = acpi_execute_method(env));
 		showtree(name, 0);
+
+		if (tmp)
+		  tmp->property = NULL;
+		aml_local_stack_delete(aml_local_stack_pop());
 		if (obj) {
-			switch (obj->type) {
-			case aml_t_objref:
-				retval = obj;
-				break;
-			default:
-				retval = acpi_copy_object(env, obj);
-				break;
-			}
+		  aml_create_local_object()->property = obj;
+		  retval = obj;
 		}
 
-		for (i = 0; i < argc; i++) {
-			acpi_free_object(&env->argumentvalue[i].property);
-		}
-		for (i = 0; i < 8; i++) {
-			acpi_free_object(&env->localvalue[i].property);
-		}
-		if (env->work_needfree == 1) {
-			acpi_free_object(&env->work.property);
-		}
 	}
 	memman_free(aml_memman, memid_aml_environ, env);
 	return retval;
Index: main.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/main.c,v
retrieving revision 1.8
diff -u -r1.8 main.c
--- main.c	2000/01/23 15:58:09	1.8
+++ main.c	2000/03/07 04:04:27
@@ -39,7 +39,6 @@
 #include "status.h"
 #include "env.h"
 #include "obj.h"
-#include "search.h"
 #include "evalobj.h"
 #include "parse.h"
 #include "store.h"
@@ -90,6 +89,7 @@
 	u_int8_t       *code;
 	struct stat     sb;
 	int             fd;
+	struct aml_name_group *newgrp;
 	
 	fd = open(dsdtfile, O_RDONLY, 0);
 	if (fd == -1) {
@@ -104,6 +104,7 @@
 		perror("mmap");
 		exit(-1);
 	}
+	newgrp = new_aml_name_group((int)code);
 	bzero(&env, sizeof(env));
 	env.dp = code;
 	env.end = code + sb.st_size;
@@ -115,11 +116,12 @@
 	env.curname = get_rootname();
 	
 	showtree(env.curname, 0);
+
 	do {
 		acpi_dbgr(&env,&env);
 	} while (env.stat != aml_stat_panic);
 	acpi_simulation_regdump("region.dmp");
-	acpi_free_childname(get_rootname());
+
 	return 0;
 }
 
@@ -316,7 +318,8 @@
 	}
 
 out:
-	acpi_free_childname(get_rootname());
+	while (name_group_list->id != AML_NAME_GROUP_ROOT)
+	  delete_aml_name_group(name_group_list);
 	memman_statistics(aml_memman);
 	memman_freeall(aml_memman);
 
Index: name.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/name.c,v
retrieving revision 1.4
diff -u -r1.4 name.c
--- name.c	2000/01/12 18:45:13	1.4
+++ name.c	2000/03/07 07:46:46
@@ -1,11 +1,53 @@
+/*-
+ * Copyright (c) 1999 Takanori Watanabe
+ * Copyright (c) 1999,2000 Yasuo Yokoyama
+ * 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include "name.h"
 #include "amlmem.h"
+#include "env.h"
+#include "debug.h"
+
+static struct aml_name rootname = {"\\", NULL, NULL, NULL, NULL, NULL};
+
+static struct aml_name_group root_group = {
+	AML_NAME_GROUP_ROOT,
+	&rootname,
+/*	&rootname,*/
+	NULL
+};
+
+struct aml_name_group *name_group_list = &root_group;
+struct aml_local_stack *stack_top = NULL;
 
-struct aml_name rootname = {"\\", NULL, NULL, NULL, NULL};
 struct aml_name *
 get_rootname()
 {
@@ -15,8 +57,9 @@
 struct aml_name *
 search_aml_name(struct aml_name * parent, char *name)
 {
-	/* assert(parent) */
 	struct aml_name *result;
+	if (!parent)
+		parent = &rootname;
 	for (result = parent->child; result; result = result->brother) 
 		if (!strncmp(result->name, name, 4))
 			break;
@@ -24,17 +67,18 @@
 }
 
 struct aml_name *
-search_aml_name_recursive(struct aml_name *start, char *name)
+search_aml_name_recursive(struct aml_name *parent, char *name)
 {
 	char	*ptr = name;
 	int	len;
-	/* assert(parent) */
-	struct aml_name *parent, *result;
+	struct  aml_name *result;
 	
-	parent = start;
+	if (!parent)
+		parent = &rootname;
+
 	if (ptr[0] == '\\') {
 		ptr++;
-		parent = get_rootname();
+		parent = &rootname;
 	}
 
 	for (len = 0; ptr[len] != '.' && ptr[len] != '\0'; len++)
@@ -57,8 +101,39 @@
 	return NULL;
 }
 
+struct aml_name_group *
+new_aml_name_group(int Id)
+{
+	struct aml_name_group *result =
+	  memman_alloc(aml_memman, memid_aml_name_group);
+	result->id = Id;
+/*	result->head = result->tail = NULL; */ 
+	result->head = NULL;
+	result->next = name_group_list;
+	name_group_list = result;
+	return result;
+}
+
+void
+delete_aml_name_group(struct aml_name_group *target)
+{
+	struct aml_name_group *previous = name_group_list;
+	if (previous == target)
+		name_group_list = target->next;
+	else {
+		while (previous && previous->next != target)
+			previous = previous->next;
+		if (previous)
+			previous->next = target->next;
+	}
+	target->next = NULL;
+	if (target->head)
+		delete_aml_name(target->head);
+	memman_free(aml_memman, memid_aml_name_group, target);
+}
+
 struct aml_name *
-set_aml_name(struct aml_name * parent, char *name)
+new_aml_name(struct aml_name * parent, char *name)
 {
 	struct aml_name *newname;
 
@@ -70,37 +145,189 @@
 	newname->parent = parent;
 	newname->child = NULL;
 	newname->property = NULL;
-	if (parent->child) {
-		struct aml_name *last;
-		for (last = parent->child; last->brother; last = last->brother) ;
-		last->brother = newname;
-        } else {
-		parent->child = newname;
-        }
+	if (parent->child)
+		newname->brother=parent->child;
+	else
+		newname->brother=NULL;
+	parent->child = newname;
 
-	newname->brother = NULL;
+	newname->chain = name_group_list->head;
+	name_group_list->head = newname;
+	/*
+	if (!name_group_list->tail)
+		name_group_list->tail = newname;
+	*/
 	return newname;
 }
+
 /*
-	     parent
-            +------>null
-        +---+----+
-        |rootname| brother
-	|  "\\"  +-------->null
-	|        |<----+<-----------------+
-	+---+----+     |parent            |parent            
-      child |      +---+----+ brother +---+----+ brother
-            +----->| "GPE"  +-------->| "_PTS" +-------> null
-                   |        |<-+      |        |
-                   +---+----+  |      +---=----+
-                       |       |          | child
-                       |       |          +-->null
-                       |       |
-                       |       +-+<-----------------+
-                       |         |parent            |parent
-                       |    +----+----+ brother +---+----+ brother
-                       + -->| "_L01"  +-------->| "_L02" +-------> null
-                            +----+----+         +---+----+
-                                 | child            | child
-                                 +-->null           +-->null
-*/
+ * $BCm0U(B
+ * delete_aml_name $B$O(B aml_name_group::{head,tail} $B$r%a%s%F%J%s%9(B
+ * $B$7$F$$$^$;$s!#(B
+ */
+void
+delete_aml_name(struct aml_name *target)
+{
+        struct aml_name *next;
+	for (;target; target = next) {
+		next = target->chain;
+		if (target->child) {
+			target->chain = NULL;
+			continue;
+		}
+		if (target->brother) {
+		  if (target->parent) {
+			if (target->parent->child == target)
+			       target->parent->child = target->brother;
+			else {
+				struct aml_name	*ptr = target->parent->child;
+				while (ptr && ptr->brother != target)
+					ptr = ptr->brother;
+				if (ptr)
+					ptr->brother = target->brother;
+			}
+			target->brother = NULL;
+		  }
+		}
+		else
+		  if (target->parent)
+			target->parent->child = NULL;
+		acpi_free_object(&target->property);
+		memman_free(aml_memman, memid_aml_name, target);
+	}
+}
+
+#define ACPI_SEARCH_NAME 0
+#define ACPI_CREATE_NAME 1
+static struct aml_name *acpi_nameman(struct aml_environ *, u_int8_t *, int);
+
+struct aml_name *
+acpi_search_name(struct aml_environ * env, u_int8_t * dp)
+{
+	return acpi_nameman(env, dp, ACPI_SEARCH_NAME);
+}
+
+struct aml_name *
+acpi_create_name(struct aml_environ * env, u_int8_t * dp)
+{
+	return acpi_nameman(env, dp, ACPI_CREATE_NAME);
+	
+}
+
+static struct aml_name *
+acpi_nameman(struct aml_environ * env, u_int8_t * dp, int flag)
+{
+	struct aml_name *newname, *curname;
+	struct aml_name *(*searchfunc) (struct aml_name *, char *);
+#define CREATECHECK if(newname==NULL){fprintf(stderr,"ERROR CANNOT FIND NAME\n");exit(-1);}
+	searchfunc = (flag == ACPI_CREATE_NAME) ? new_aml_name : search_aml_name;
+	newname = env->curname;
+	if (dp[0] == '\\') {
+		newname = &rootname;
+		dp++;
+	} else if (dp[0] == '^') {
+		while (dp[0] == '^') {
+			newname = newname->parent;
+			CREATECHECK;
+			dp++;
+		}
+	}
+	if (dp[0] == 0x00) {	/* NullName */
+		dp++;
+	} else if (dp[0] == 0x2e) {	/* DualNamePrefix */
+		newname = (*searchfunc) (newname, dp + 1);
+		CREATECHECK;
+		newname = (*searchfunc) (newname, dp + 5);
+		CREATECHECK;
+	} else if (dp[0] == 0x2f) {	/* MultiNamePrefix */
+		int             segcount = dp[1];
+		int             i;
+		for (i = 0, dp += 2; i < segcount; i++, dp += 4) {
+			newname = (*searchfunc) (newname, dp);
+			CREATECHECK;
+		}
+	} else if (flag == ACPI_CREATE_NAME) {	/* NameSeg */
+		newname = new_aml_name(newname, dp);
+		CREATECHECK;
+	} else {
+		curname = newname;
+		for(;;) {
+			newname = search_aml_name(curname, dp);
+			if (newname != NULL)
+				break;
+			if(curname == &rootname)
+				break;
+			curname = curname->parent;
+		} 
+	}
+	return newname;
+}
+#undef CREATECHECK
+
+struct aml_local_stack *
+aml_local_stack_create()
+{
+	struct aml_local_stack *result =
+	  memman_alloc(aml_memman, memid_aml_local_stack);
+	memset(result, 0, sizeof(struct aml_local_stack));
+	return result;
+}
+
+
+void aml_local_stack_push(struct aml_local_stack *stack)
+{
+	stack->next = stack_top;
+	stack_top = stack;
+	return;
+}
+
+struct aml_local_stack*
+aml_local_stack_pop()
+{
+  struct aml_local_stack *result = stack_top;
+  stack_top = result->next;
+  result->next = NULL;
+  return result;
+}
+
+void
+aml_local_stack_delete(struct aml_local_stack *stack)
+{
+  int i;
+  for (i = 0; i < 8; i ++)
+    acpi_free_object(&stack->localvalue[i].property);
+  for (i = 0; i < 7; i ++)
+    acpi_free_object(&stack->argumentvalue[i].property);
+  delete_aml_name(stack->temporary);
+  memman_free(aml_memman, memid_aml_local_stack, stack);
+  return;
+}
+
+struct aml_name *
+aml_local_stack_getLocalX(int index)
+{
+  if (stack_top == NULL)
+    return NULL;
+  return &stack_top->localvalue[index];
+}
+
+struct aml_name *
+aml_local_stack_getArgX(struct aml_local_stack *stack, int index)
+{
+  if (!stack)
+    stack = stack_top;
+  if (stack == NULL)
+    return NULL;
+  return &stack->argumentvalue[index];
+}
+
+struct aml_name *
+aml_create_local_object()
+{
+  struct aml_name *result = memman_alloc(aml_memman, memid_aml_name);
+  result->child = result->brother = result->parent = NULL;
+  result->property = NULL;
+  result->chain = stack_top->temporary;
+  stack_top->temporary = result;
+  return result;
+}
Index: name.h
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/name.h,v
retrieving revision 1.6
diff -u -r1.6 name.h
--- name.h	2000/01/12 18:45:13	1.6
+++ name.h	2000/03/07 04:20:07
@@ -1,6 +1,34 @@
+/*-
+ * Copyright (c) 1999 Takanori Watanabe
+ * Copyright (c) 1999,2000 Yasuo Yokoyama
+ * 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$
+ */
+
 #ifndef _NAME_H_
 #define _NAME_H_
-#include <sys/queue.h>
 #include "obj.h"
 
 struct aml_name {
@@ -9,16 +37,48 @@
 	struct aml_name *parent;
 	struct aml_name *brother;
 	struct aml_name *child;
+	struct aml_name *chain;
+};
+
+#define AML_NAME_GROUP_ROOT       0
+#define AML_NAME_GROUP_OS_DEFINED 1
+#define AML_NAME_GROUP_IN_METHOD  2
+
+struct aml_name_group{
+        int id; /* DSDT address or DBHANDLE */
+	struct aml_name *head;
+/*	struct aml_name *tail; $B;H$o$J$$$+$b(B */
+	struct aml_name_group *next;
 };
 
-struct aml_nameptr {
-	TAILQ_ENTRY(aml_nameptr)	links;
-	struct aml_name *name;
+struct aml_local_stack {
+	struct aml_name localvalue[8];
+	struct aml_name argumentvalue[7];
+	struct aml_name *temporary;
+	struct aml_local_stack *next;
 };
-TAILQ_HEAD(aml_name_list, aml_nameptr);
 
+/* forward declarement */
+struct aml_envrion;
+
 struct aml_name *get_rootname();
+struct aml_name_group *new_aml_name_group(int Id);
+void delete_aml_name_group(struct aml_name_group *target);
+extern struct aml_name_group *name_group_list;
+
+struct aml_name *new_aml_name(struct aml_name * parent, char *name);
+void delete_aml_name(struct aml_name *target);
 struct aml_name *search_aml_name(struct aml_name * parent, char *name);
 struct aml_name *search_aml_name_recursive(struct aml_name * parent, char *name);
-struct aml_name *set_aml_name(struct aml_name * parent, char *name);
+struct aml_name *acpi_search_name(struct aml_environ * env, u_int8_t * dp);
+struct aml_name *acpi_create_name(struct aml_environ * env, u_int8_t * dp);
+
+struct aml_local_stack *aml_local_stack_create();
+void aml_local_stack_push(struct aml_local_stack *stack);
+struct aml_local_stack *aml_local_stack_pop();
+void aml_local_stack_delete(struct aml_local_stack *stack);
+struct aml_name *aml_local_stack_getLocalX(int index);
+struct aml_name *aml_local_stack_getArgX(struct aml_local_stack *stack,
+					 int index);
+struct aml_name *aml_create_local_object();
 #endif
Index: obj.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/obj.c,v
retrieving revision 1.4
diff -u -r1.4 obj.c
--- obj.c	2000/01/27 16:00:14	1.4
+++ obj.c	2000/03/07 08:51:30
@@ -50,7 +50,7 @@
 	if(orig==NULL)
 		return NULL;
 	ret=acpi_alloc_object(0,orig);
-	if(orig!=&env->wobj){
+	if(1 || orig!=&env->wobj){
 		if (orig->type == aml_t_buffer) {
 			ret->buffer.data = memman_alloc_flexsize(aml_memman,
 			    orig->buffer.size);
@@ -67,7 +67,8 @@
 			strcpy(orig->str.string, ret->str.string);	
 		}
 	}else{
-		env->wobj.type=aml_t_null;
+	  printf ("%s:%d \n",__FILE__, __LINE__);
+	  		env->wobj.type=aml_t_null;
 	}
 	return ret;
 }
@@ -145,24 +146,23 @@
 acpi_free_objectcontent(union aml_object * obj)
 {
 	int             i;
-	if (obj->type == aml_t_buffer) {
+	if (obj->type == aml_t_buffer && obj->buffer.data) {
 		memman_free_flexsize(aml_memman, obj->buffer.data);
 		obj->buffer.data = NULL;
 	}
-	if (obj->type == aml_t_string) {
+	if (obj->type == aml_t_string && obj->str.string) {
 		if (obj->str.needfree != 0) {
 			memman_free_flexsize(aml_memman, obj->str.string);
 			obj->str.string = NULL;
 		}
 	}
-	if (obj->type == aml_t_package) {
+	if (obj->type == aml_t_package && obj->package.objects) {
 		for (i = 0; i < obj->package.elements; i++) {
 			acpi_free_object(&obj->package.objects[i]);
 		}
 		memman_free_flexsize(aml_memman, obj->package.objects);
 		obj->package.objects=NULL;
 	}
-	obj->type=aml_t_null;
 	return;
 }
 void
@@ -222,25 +222,5 @@
 	default:
 		break;
 	}
-}
-
-void
-acpi_register_temporary_object(struct aml_environ *env, union aml_object *obj)
-{
-	struct aml_objectptr *objptr;
-
-	TAILQ_FOREACH(objptr, &env->temporary_objects, links) {
-		if (objptr->object == obj) {
-			return;
-		}
-	}
-
-	objptr = memman_alloc(aml_memman, memid_aml_objectptr);
-	if (objptr == NULL) {
-		printf("acpi_register_temporary_object: memory alloc failed for objptr\n");
-		return;
-	}
-	objptr->object = obj;
-	TAILQ_INSERT_HEAD(&env->temporary_objects, objptr, links);
 }
 
Index: obj.h
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/obj.h,v
retrieving revision 1.5
diff -u -r1.5 obj.h
--- obj.h	2000/01/27 16:00:14	1.5
+++ obj.h	2000/03/07 09:17:53
@@ -146,7 +146,8 @@
 };
 struct aml_objref {
 	enum aml_objtype type;
-	union aml_object **ref;
+	struct aml_name *nameref;
+	union aml_object *ref;
 	int             offset;	/* of aml_buffer.data or aml_package.objects. */
 	/* if negative value, not ready to dereference for element access. */
 	unsigned	deref;	/* indicates whether dereffenced or not */
@@ -168,18 +169,10 @@
 	struct aml_objref objref;
 };
 
-struct aml_objectptr {
-        TAILQ_ENTRY(aml_objectptr)        links;
-        union aml_object *object;
-};
-TAILQ_HEAD(aml_object_list, aml_objectptr);
-
-
 union aml_object * acpi_copy_object(struct aml_environ *env,union aml_object *orig);
 union aml_object * acpi_alloc_object(enum aml_objtype type, union aml_object * orig);
 void acpi_free_objectcontent(union aml_object * obj);
 void
 acpi_free_object(union aml_object ** obj);
 void acpi_realloc_object(union aml_object * obj, int size);
-void acpi_register_temporary_object(struct aml_environ *env,union aml_object *obj);
 #endif
Index: parse.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/parse.c,v
retrieving revision 1.17
diff -u -r1.17 parse.c
--- parse.c	2000/01/27 16:00:14	1.17
+++ parse.c	2000/03/07 07:29:21
@@ -40,7 +40,6 @@
 #include "amlmem.h"
 #include "status.h"
 #include "env.h"
-#include "search.h"
 #include "evalobj.h"
 #include "debug.h"
 #include "parse.h"
@@ -1282,16 +1281,17 @@
 
 	case 0x68 ... 0x6e:	/* ArgN */
 		DPRINT("Arg%d", opcode - 0x68);
-		return &env->argumentvalue[opcode-0x68];
+		return aml_local_stack_getArgX(NULL, opcode - 0x68);
 		break;
 		
 	case 0x60 ... 0x67:
 		DPRINT("Local%d", opcode - 0x60);
-		return &env->localvalue[opcode-0x60];
+		return aml_local_stack_getLocalX(opcode-0x60);
 		break;
 	case 0x70:		/* StoreOp */
 		DPRINT("Store(");
-		tmpobj=acpi_copy_object
+		aname = aml_create_local_object();
+		aname->property = tmpobj=acpi_copy_object
 		    (env,acpi_eval_name(env,acpi_parse_termobj(env, indent)));
 		if(tmpobj==NULL){
 			printf("!!!");
@@ -1305,10 +1305,6 @@
 			printf("???");
 			break;
 		}
-		env->wobj=*tmpobj;
-		tmpobj->type=aml_t_null;
-		acpi_free_object(&tmpobj);
-		env->work.property=&env->wobj;
 		break;
 
 	case 0x71:		/* RefOfOp */
@@ -1320,13 +1316,18 @@
 		src = acpi_parse_termobj(env, indent);
 		DPRINT(")");
 
-		objref = acpi_alloc_object(aml_t_objref, NULL);
-		acpi_register_temporary_object(env, objref);
-		objref->objref.ref = &src->property;
+		aname = aml_create_local_object();
+		aname->property = objref =
+		  acpi_alloc_object(aml_t_objref, NULL);
+		
+		if (src->property->type != aml_t_namestr) {
+		  objref->objref.nameref = src;
+		}
+		else {
+		  objref->objref.nameref = aml_create_local_object();
+		}
+		objref->objref.ref = src->property;
 		objref->objref.offset = -1;	/* deferent from IndexOp */
-		objref->objref.deref = 0;
-		env->work.property = objref;
-		aname = &env->work;
 		break;
 	}
 
@@ -1448,27 +1449,24 @@
 		objref = acpi_eval_name(env, acpi_parse_termobj(env, indent));
 		DPRINT(")");
 
-		if ((*(objref->objref.ref)) == NULL) {
-			env->work.property = *(objref->objref.ref);
+		if (objref->objref.ref == NULL) {
+			env->work.property = objref->objref.ref;
 			aname = &env->work;
 			break;
 		}
 
-		switch ((*(objref->objref.ref))->type) {
+		switch (objref->objref.ref->type) {
 		case aml_t_package:
 		case aml_t_buffer:
 			if (objref->objref.offset < 0) {
-				env->work.property = *(objref->objref.ref);
-				if (objref != &env->wobj) {
-					acpi_free_object(&objref);
-				}
+				env->work.property = objref->objref.ref;
 			} else {
-				objref->objref.deref = 1;
+			  objref->objref.deref = 1;
 				env->work.property = objref;
 			}
 			break;
 		default:
-			env->work.property = *(objref->objref.ref);
+			env->work.property = objref->objref.ref;
 			break;
 		}
 
@@ -1526,12 +1524,13 @@
 		DPRINT(", ");
 		distname1 = acpi_parse_termobj(env, indent);
 		DPRINT(")");
+		aname = aml_create_local_object();
 		switch (srcobj->type) {
 		case aml_t_package:
 		case aml_t_buffer:
+		  aname->property = 
 			objref = acpi_alloc_object(aml_t_objref, NULL);
-			acpi_register_temporary_object(env, objref);
-			objref->objref.ref = &srcobj;
+			objref->objref.ref = srcobj;
 			objref->objref.offset = num1;
 			objref->objref.deref = 0;
 			break;
@@ -1541,8 +1540,6 @@
 		}
 		
 		acpi_store_to_name(env, objref, distname1);
-		env->work.property = objref;
-		aname = &env->work;
 		break;
 	}
 	
@@ -1668,7 +1665,10 @@
 
 	case 0xa4:		/* ReturnOp */
 		DPRINT("Return(");
-		aname=acpi_parse_termobj(env, indent);
+		env->work.property = acpi_copy_object(env,
+			       acpi_eval_name(env,
+					      acpi_parse_termobj(env, indent)));
+		aname = &env->work;
 		env->stat=aml_stat_return;
 		DPRINT(")");
 		break;
@@ -1685,48 +1685,3 @@
 	return aname;
 }
 
-
-
-void acpi_free_childname(struct aml_name *aname)
-{
-  struct aml_name *ptr,*curname;
-  ptr=aname->child;
-  aname->child=NULL;
-  while(ptr != NULL){
-    curname=ptr;
-    ptr=ptr->brother;
-    acpi_free_object(&curname->property);
-    acpi_free_childname(curname);
-    memman_free(aml_memman,memid_aml_name,curname);
-  }
-}
-
-void
-acpi_free_childname_one(struct aml_name *aname, struct aml_name *child)
-{
-	struct aml_name *ptr, *curname, *bigbrother;
-
-	ptr = aname->child;
-
-	while (ptr != NULL) {
-		curname = ptr;
-		ptr = ptr->brother;
-		if (curname == child) {
-			/* I'm going to die, say good bye to my family... */
-			if (curname->parent->child == curname) {
-				curname->parent->child = curname->brother;
-			} else {
-				for (bigbrother = curname->parent->child;
-				     bigbrother->brother != curname;
-				     bigbrother = bigbrother->brother) ;
-				bigbrother->brother = curname->brother;
-			}
-			
-			acpi_free_object(&curname->property);
-			acpi_free_childname(curname);
-			memman_free(aml_memman, memid_aml_name, curname);
-			return;
-		}
-		acpi_free_childname_one(curname, child);
-	}
-}
Index: parse.h
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/parse.h,v
retrieving revision 1.2
diff -u -r1.2 parse.h
--- parse.h	2000/01/11 11:33:41	1.2
+++ parse.h	2000/03/07 04:04:27
@@ -29,7 +29,3 @@
 void acpi_print_namestring(u_int8_t * dp);
 struct aml_name *acpi_parse_objectlist(struct aml_environ * env, int indent);
 struct aml_name *acpi_parse_termobj(struct aml_environ * env, int indent);
-void acpi_free_childname(struct aml_name *aname);
-void acpi_free_childname_one(struct aml_name *aname,
-			     struct aml_name *child);
-
Index: search.c
===================================================================
RCS file: search.c
diff -N search.c
--- /tmp/cvsMUeNGl2309	Tue Mar  7 18:17:56 2000
+++ /dev/null	Tue Mar  7 11:04:42 2000
@@ -1,121 +0,0 @@
-/*-
- * Copyright (c) 1999 Takanori Watanabe
- * 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: search.c,v 1.2 2000/01/11 11:33:41 iwasaki Exp $
- */
-#include <sys/param.h>
-#include <stdio.h>
-#include <assert.h>
-#include <err.h>
-#include <machine/pc/acpi.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include "name.h"
-#include "amlmem.h"
-#include "status.h"
-#include "env.h"
-#include "obj.h"
-#include "evalobj.h"
-#include "search.h"
-#include "parse.h"
-#include "store.h"
-#include <stdlib.h>
-#include <string.h>
-
-#define ACPI_SEARCH_NAME 0
-#define ACPI_CREATE_NAME 1
-static struct aml_name *acpi_nameman(struct aml_environ *, u_int8_t *, int);
-struct aml_name *
-acpi_search_name(struct aml_environ * env, u_int8_t * dp)
-{
-	return acpi_nameman(env, dp, ACPI_SEARCH_NAME);
-}
-struct aml_name *
-acpi_create_name(struct aml_environ * env, u_int8_t * dp)
-{
-	struct aml_name *newname;
-	struct aml_nameptr *created;
-
-	newname = acpi_nameman(env, dp, ACPI_CREATE_NAME);
-
-	if (env->executing == 1) {
-		created = memman_alloc(aml_memman, memid_aml_nameptr);
-		created->name = newname;
-		TAILQ_INSERT_TAIL(&env->created_on_exec, created, links);
-	}
-
-	return newname;
-}
-static struct aml_name *
-acpi_nameman(struct aml_environ * env, u_int8_t * dp, int flag)
-{
-	struct aml_name *newname, *curname;
-	struct aml_name *(*searchfunc) (struct aml_name *, char *);
-#define CREATECHECK if(newname==NULL){fprintf(stderr,"ERROR CANNOT FIND NAME\n");exit(-1);}
-	searchfunc = (flag == ACPI_CREATE_NAME) ? set_aml_name : search_aml_name;
-	newname = env->curname;
-	if (dp[0] == '\\') {
-		newname = get_rootname();
-		dp++;
-	} else if (dp[0] == '^') {
-		while (dp[0] == '^') {
-			newname = newname->parent;
-			CREATECHECK;
-			dp++;
-		}
-	}
-	if (dp[0] == 0x00) {	/* NullName */
-		dp++;
-	} else if (dp[0] == 0x2e) {	/* DualNamePrefix */
-		newname = (*searchfunc) (newname, dp + 1);
-		CREATECHECK;
-		newname = (*searchfunc) (newname, dp + 5);
-		CREATECHECK;
-	} else if (dp[0] == 0x2f) {	/* MultiNamePrefix */
-		int             segcount = dp[1];
-		int             i;
-		for (i = 0, dp += 2; i < segcount; i++, dp += 4) {
-			newname = (*searchfunc) (newname, dp);
-			CREATECHECK;
-		}
-	} else if (flag == ACPI_CREATE_NAME) {	/* NameSeg */
-		newname = set_aml_name(newname, dp);
-		CREATECHECK;
-	} else {
-		curname = newname;
-		for(;;) {
-			newname = search_aml_name(curname, dp);
-			if (newname != NULL)
-				break;
-			if(curname == get_rootname())
-			  break;
-			curname = curname->parent;
-		} 
-	}
-	return newname;
-#undef CREATECHECK
-}
Index: search.h
===================================================================
RCS file: search.h
diff -N search.h
--- /tmp/cvsEwdWVB2309	Tue Mar  7 18:17:56 2000
+++ /dev/null	Tue Mar  7 11:04:42 2000
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 1999 Takanori Watanabe
- * 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: search.h,v 1.1 1999/12/26 06:36:25 takawata Exp $
- */
-struct aml_name *acpi_search_name(struct aml_environ * env, u_int8_t * dp);
-struct aml_name *acpi_create_name(struct aml_environ * env, u_int8_t * dp);
Index: store.c
===================================================================
RCS file: /home/ncvs-acpi/ACPI/util/acpiconf/store.c,v
retrieving revision 1.7
diff -u -r1.7 store.c
--- store.c	2000/01/27 16:00:14	1.7
+++ store.c	2000/03/07 04:04:27
@@ -36,7 +36,6 @@
 #include "status.h"
 #include "debug.h"
 #include "env.h"
-#include "search.h"
 #include "store.h"
 #include "obj.h"
 #include "region.h"
@@ -181,11 +180,12 @@
 	int	offset;
 	union aml_object *ref;
 
-	if (*(r->objref.ref) == NULL) {
-		*(r->objref.ref) = acpi_alloc_object(obj->type, NULL);
+	if (r->objref.ref == NULL) {
+		r->objref.ref = acpi_alloc_object(obj->type, NULL);/* XXX */
+		r->objref.nameref->property = r->objref.ref;
 	}
 
-	ref = *(r->objref.ref);
+	ref = r->objref.ref;
 
 	switch(ref->type){
 	case aml_t_buffer:
@@ -195,7 +195,7 @@
 
 	case aml_t_package:
 		offset = r->objref.offset;
-		if ((*(r->objref.ref))->package.elements < offset) {
+		if (r->objref.ref->package.elements < offset) {
 			acpi_realloc_object(ref, offset);
 		}
 		if (ref->package.objects[offset] == NULL) {

----Next_Part(Fri_Mar_17_16:33:38_2000_250)----
