From owner-acpi-jp@jp.freebsd.org  Sun Jun  4 19:05:22 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id TAA24924;
	Sun, 4 Jun 2000 19:05:22 +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 TAA24919
	for <acpi-jp@jp.freebsd.org>; Sun, 4 Jun 2000 19:05:21 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (isdnb33.imasy.or.jp [202.227.24.161])
	by tasogare.imasy.or.jp (8.10.1+3.3W/3.7W-tasogare/smtpfeed 1.04) with ESMTP id e54A5IP39297
	for <acpi-jp@jp.freebsd.org>; Sun, 4 Jun 2000 19:05:18 +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=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20000604190518Y.iwasaki@jp.FreeBSD.org>
Date: Sun, 04 Jun 2000 19:05:18 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 513
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 373
Subject: [acpi-jp 373] style fix: aml_evalobj.[ch]
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

Index: aml_evalobj.c
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_evalobj.c,v
retrieving revision 1.16
diff -u -r1.16 aml_evalobj.c
--- aml_evalobj.c	2000/06/03 14:32:57	1.16
+++ aml_evalobj.c	2000/06/04 09:21:42
@@ -27,7 +27,6 @@
  */
 
 #include <sys/param.h>
-#include <sys/types.h>
 
 #include <i386/acpi/aml/aml_amlmem.h>
 #include <i386/acpi/aml/aml_common.h>
@@ -41,54 +40,59 @@
 #include <i386/acpi/aml/aml_store.h>
 
 #ifndef _KERNEL
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
 #include <assert.h>
 #include <err.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
+
 #include "debug.h"
-#else
+#else /* _KERNEL */
 #include <sys/bus.h>
 #include <sys/systm.h>
-#endif
+#endif /* !_KERNEL */
+
+static union aml_object	*acpi_eval_fieldobject(struct aml_environ *env,
+					       struct aml_name *name);
 
-static union aml_object 
-*acpi_eval_fieldobject(struct aml_environ *env,struct aml_name *name)
+static union aml_object *
+acpi_eval_fieldobject(struct aml_environ *env, struct aml_name *name)
 {
-	struct aml_name *oname,*wname;
-	struct aml_field *field;
-	/*CANNOT OCCUR!*/
-	if(name==NULL||
-	    name->property==NULL||
-	    name->property->type!=aml_t_field){
+	struct	aml_name *oname,*wname;
+	struct	aml_field *field;
+	struct	aml_opregion *or;
+	union	aml_object tobj;
+
+	/* CANNOT OCCUR! */
+	if (name == NULL || name->property == NULL ||
+	    name->property->type != aml_t_field) {
 		printf("????\n");
-		env->stat=aml_stat_panic;
-		return NULL;
+		env->stat = aml_stat_panic;
+		return (NULL);
 	}
-	field=&name->property->field;
-	oname=env->curname;
-	if(field->bitlen > 32){
-		env->wobj.type=aml_t_regfield;
-	}else{
-		env->wobj.type=aml_t_num;
-	}
-	env->curname=name;
-	if(field->f.ftype==f_t_field){
-		struct aml_opregion *or;
-		wname=acpi_search_name(env,field->f.fld.regname);
-		if(wname ==NULL ||
-		    wname->property==NULL||
-		    wname->property->type!=aml_t_opregion){
+	field = &name->property->field;
+	oname = env->curname;
+	if (field->bitlen > 32) {
+		env->wobj.type = aml_t_regfield;
+	} else {
+		env->wobj.type = aml_t_num;
+	}
+	env->curname = name;
+	if (field->f.ftype == f_t_field) {
+		wname = acpi_search_name(env, field->f.fld.regname);
+		if (wname == NULL || wname->property == NULL ||
+		    wname->property->type != aml_t_opregion) {
 			AML_PRINTF("Inappropreate Type\n");
-			env->stat=aml_stat_panic;
-			env->curname=oname;
-			return NULL;
+			env->stat = aml_stat_panic;
+			env->curname = oname;
+			return (NULL);
 		}
-		or=&wname->property->opregion;
+		or = &wname->property->opregion;
 		if (env->wobj.type == aml_t_regfield) {
 			env->wobj.regfield.space = or->space;
 			env->wobj.regfield.flags = field->flags;
@@ -97,33 +101,32 @@
 			env->wobj.regfield.bitlen = field->bitlen;
 		} else {
 			AML_PRINTF("[read(From%d , 0x%x)]",
-			    or->space,or->offset+field->bitoffset/8);
+			    or->space, or->offset + field->bitoffset / 8);
 			env->wobj.type = aml_t_num;
 			env->wobj.num.number = acpi_region_read(or->space,
 			    field->flags, or->offset, field->bitoffset,
 			    field->bitlen);
 		}
-	}else if(field->f.ftype==f_t_index){
-		union aml_object tobj;
-		wname=acpi_search_name(env,field->f.ifld.indexname);
-		tobj.type=aml_t_num;
-		tobj.num.number=field->bitoffset;
-		acpi_store_to_name(env,&tobj,wname);
-		wname=acpi_search_name(env,field->f.ifld.dataname);
-		acpi_eval_name(env,wname);
-	}
-	env->curname=oname;
-	return &env->wobj;
-	
+	} else if (field->f.ftype == f_t_index) {
+		wname = acpi_search_name(env, field->f.ifld.indexname);
+		tobj.type = aml_t_num;
+		tobj.num.number = field->bitoffset;
+		acpi_store_to_name(env, &tobj, wname);
+		wname = acpi_search_name(env, field->f.ifld.dataname);
+		acpi_eval_name(env, wname);
+	}
+	env->curname = oname;
+	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;
+	union	aml_object num1;
+	union	aml_object *ref, *ret;
 
+	ret = obj;
 	if (obj->objref.deref == 1) {
 		num1.type = aml_t_num;
 		offset = obj->objref.offset;
@@ -131,7 +134,6 @@
 		if (ref == NULL) {
 			goto out;
 		}
-
 		switch (ref->type) {
 		case aml_t_package:
 			if (ref->package.elements > offset) {
@@ -155,48 +157,49 @@
 			break;
 		}
 	}
-
 	if (obj->objref.alias == 1) {
 		ret = acpi_eval_name(env, obj->objref.nameref);
 		goto out;
 	}
-
 out:
-	return ret;
+	return (ret);
 }
 
 /*
  * Eval named object.
  */
-union aml_object 
-*acpi_eval_name(struct aml_environ * env, struct aml_name * aname)
+union aml_object *
+acpi_eval_name(struct aml_environ *env, struct aml_name *aname)
 {
-	struct aml_name *tmp;
-	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){
-		return NULL;
+	int	argnum, i;
+	int	num;
+	struct	aml_name *tmp;
+	struct	aml_environ *copy;
+	struct	aml_local_stack *stack;
+	union	aml_object *obj, *ret;
+	union	aml_object *src;
+
+	ret = NULL;
+	if (aname == NULL || aname->property == NULL) {
+		return (NULL);
 	}
-
+	if (env->stat == aml_stat_panic) {
+		return (NULL);
+	}
 	copy = memman_alloc(aml_memman, memid_aml_environ);
 	if (copy == NULL) {
-		return NULL;
+		return (NULL);
 	}
-
 	ret = aname->property;
-	i=0;
+	i = 0;
 reevaluate:
-	if(i>10){
-		env->stat=aml_stat_panic;
+	if (i > 10) {
+		env->stat = aml_stat_panic;
 		printf("TOO MANY LOOP\n");
 		ret = NULL;
 		goto out;
 	}
-	switch(aname->property->type){
+	switch (aname->property->type) {
 	case aml_t_namestr:
 		tmp = aname;
 		aname = acpi_search_name(env, aname->property->nstr.dp);
@@ -205,6 +208,9 @@
 		}
 		i++;
 		goto reevaluate;
+	case aml_t_objref:
+		ret = acpi_eval_objref(env, aname->property);
+		goto out;
 	case aml_t_num:
 	case aml_t_string:
 	case aml_t_buffer:
@@ -212,94 +218,38 @@
 	case aml_t_debug:
 		ret = aname->property;
 		goto out;
-		
-	case aml_t_objref:
-	{
-		int	offset;
-		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;
-			offset = obj->objref.offset;
-			ref = obj->objref.ref;
-			if (ref == NULL) {
-				aname->property = ret;
-				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;
-			}
-			aname->property = ret;
-			goto out;
-		}
-
-		if (aname->property->objref.alias == 1) {
-			ret = acpi_eval_name(env, aname->property->objref.nameref);
-			goto out;
-		}
-
-		ret = aname->property;
-		goto out;
-#endif
-	}
 	case aml_t_field:
 		acpi_free_objectcontent(&env->wobj);
-		ret = acpi_eval_fieldobject(env,aname);
+		ret = acpi_eval_fieldobject(env, aname);
 		goto out;
 	case aml_t_method:
 		acpi_free_objectcontent(&env->wobj);
-		argnum=aname->property->meth.argnum&7;
-		*copy=*env;
-		copy->curname=aname;
-		copy->dp=aname->property->meth.from;
-		copy->end=aname->property->meth.to;
-		copy->stat=aml_stat_none;
+		argnum = aname->property->meth.argnum & 7;
+		*copy = *env;
+		copy->curname = aname;
+		copy->dp = aname->property->meth.from;
+		copy->end = aname->property->meth.to;
+		copy->stat = aml_stat_none;
 		stack = aml_local_stack_create();
 		AML_PRINTF("(");
-		for(i=0;i<argnum;i++){
-			aml_local_stack_getArgX(stack,i)->property =
+		for (i = 0; i < argnum; i++) {
+			aml_local_stack_getArgX(stack, i)->property =
 			    acpi_copy_object(env,
-				acpi_eval_name(env, acpi_parse_termobj(env,0)));
-			if (i < argnum-1)
+				acpi_eval_name(env,
+				    acpi_parse_termobj(env, 0)));
+			if (i < argnum - 1)
 				AML_PRINTF(", ");
 		}
 		AML_PRINTF(")\n");
 		aml_local_stack_push(stack);
-		if(env->stat==aml_stat_step){
+		if (env->stat == aml_stat_step) {
 			AML_DEBUGGER(env, copy);
 		}
-
 		tmp = acpi_execute_method(copy);
 		obj = acpi_eval_name(env, tmp);
-		if(copy->stat==aml_stat_panic){
+		if (copy->stat == aml_stat_panic) {
 			AML_PRINTF("PANIC OCCURED IN METHOD");
-			env->stat=aml_stat_panic;
+			env->stat = aml_stat_panic;
 			ret = NULL;
 			aml_local_stack_delete(aml_local_stack_pop());
 			goto out;
@@ -317,16 +267,13 @@
 			env->wobj.num.number = 0;
 		}
 
-		/*		ret = &env->wobj; ????? */
 		goto out;
 	case aml_t_bufferfield:
 		acpi_free_objectcontent(&env->wobj);
 		if (aname->property->bfld.bitlen > 32) {
 			ret = aname->property;
 		} else {
-			int			num;
-			union aml_object	*src = aname->property;
-
+			src = aname->property;
 			num = acpi_bufferfield_read(src->bfld.origin,
 			    src->bfld.bitoffset, src->bfld.bitlen);
 			env->wobj.type = aml_t_num;
@@ -335,71 +282,71 @@
 		}
 		goto out;
 	default:
-		AML_PRINTF("I eval the object that I should not eval,%s%d",
-		    aname->name,aname->property->type);
+		AML_PRINTF("I eval the object that I should not eval, %s%d",
+		    aname->name, aname->property->type);
 		AML_SYSABORT();
 		ret = NULL;
 		goto out;
 	}
 out:
 	memman_free(aml_memman, memid_aml_environ, copy);
-	return ret;
+	return (ret);
 }
+
 int
-acpi_objtonum(struct aml_environ *env,union aml_object * obj)
+acpi_objtonum(struct aml_environ *env, union aml_object *obj)
 {
-	if (obj != NULL && obj->type == aml_t_num){
-		return obj->num.number;
-	}
-	else{
-		env->stat=aml_stat_panic;
-		return -1;
+
+	if (obj != NULL && obj->type == aml_t_num) {
+		return (obj->num.number);
+	} else {
+		env->stat = aml_stat_panic;
+		return (-1);
 	}
 }
 
-struct aml_name 
-*acpi_execute_method(struct aml_environ *env)
+struct aml_name *
+acpi_execute_method(struct aml_environ *env)
 {
-	struct aml_name *name;
-	struct aml_name_group *newgrp;
+	struct	aml_name *name;
+	struct	aml_name_group *newgrp;
 
 	newgrp = new_aml_name_group(AML_NAME_GROUP_IN_METHOD);
 
 	AML_PRINTF("[");
 	acpi_print_curname(env->curname);
 	AML_PRINTF(" START]\n");
-	
-	name=acpi_parse_objectlist(env,0);
+
+	name = acpi_parse_objectlist(env, 0);
 	AML_PRINTF("[");
 	acpi_print_curname(env->curname);
 	AML_PRINTF(" END]\n");
 
 	delete_aml_name_group(newgrp);
-	return name;
+	return (name);
 }
 
 union aml_object *
 acpi_invoke_method_by_name(char *method, int argc, union aml_object *argv)
 {
-	struct aml_name *name;
-	union aml_object *retval = NULL;
-	union aml_object *obj;
-	struct aml_environ *env;
 	int	i;
+	struct	aml_name *name;
+	struct	aml_name *tmp;
+	struct	aml_environ *env;
+	struct	aml_local_stack *stack;
+	union	aml_object *retval;
+	union	aml_object *obj;
 
+	retval = NULL;
 	env = memman_alloc(aml_memman, memid_aml_environ);
 	if (env == NULL) {
-		return NULL;
+		return (NULL);
 	}
-
 	bzero(env, sizeof(struct aml_environ));
 	name = search_aml_name_recursive(get_rootname(), method);
 
 	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;
@@ -420,9 +367,7 @@
 			aml_create_local_object()->property = obj;
 			retval = obj;
 		}
-
 	}
 	memman_free(aml_memman, memid_aml_environ, env);
-	return retval;
+	return (retval);
 }
-
Index: aml_evalobj.h
===================================================================
RCS file: /home/cvs/ACPI/sys/i386/acpi/aml/aml_evalobj.h,v
retrieving revision 1.6
diff -u -r1.6 aml_evalobj.h
--- aml_evalobj.h	2000/06/03 13:31:12	1.6
+++ aml_evalobj.h	2000/06/04 09:22:08
@@ -26,12 +26,17 @@
  *	$Id: aml_evalobj.h,v 1.6 2000/06/03 13:31:12 iwasaki Exp $
  */
 
+#ifndef _AML_EVALOBJ_H_
+#define _AML_EVALOBJ_H_
+
 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 *);
-struct aml_name *acpi_execute_method(struct aml_environ *);
-union aml_object *acpi_invoke_method_by_name(char *,
-					    int, union aml_object *);
+union aml_object	*acpi_eval_name(struct aml_environ *,
+					struct aml_name *);
+int			 acpi_objtonum(struct aml_environ *,
+				       union aml_object *);
+struct aml_name		*acpi_execute_method(struct aml_environ *);
+union aml_object	*acpi_invoke_method_by_name(char *,
+						    int, union aml_object *);
 
+#endif /* !_AML_EVALOBJ_H_ */
