From owner-acpi-jp@jp.freebsd.org  Sat Nov  3 06:39:06 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id GAA20910;
	Sat, 3 Nov 2001 06:39:06 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from tasogare.imasy.or.jp (root@tasogare.imasy.or.jp [202.227.24.5])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id GAA20905
	for <acpi-jp@jp.freebsd.org>; Sat, 3 Nov 2001 06:39:05 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	(authenticated as iwa with CRAM-MD5)
	by tasogare.imasy.or.jp (8.11.6+3.4W/8.11.6/tasogare) with ESMTP/inet id fA2Ld4W98315
	for <acpi-jp@jp.freebsd.org>; Sat, 3 Nov 2001 06:39:04 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Date: Sat, 03 Nov 2001 06:40:35 +0900 (JST)
Message-Id: <20011103.064035.71082946.iwasaki@jp.FreeBSD.org>
To: acpi-jp@jp.freebsd.org
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
In-Reply-To: <200110171348.WAA91918@shidahara1.planet.sci.kobe-u.ac.jp>
References: <20011016.223207.74756782.iwasaki@jp.FreeBSD.org>
	<200110171348.WAA91918@shidahara1.planet.sci.kobe-u.ac.jp>
X-Mailer: Mew version 2.0 on Emacs 20.7 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+010328
X-Sequence: acpi-jp 1420
Subject: [acpi-jp 1420] Re: DSDT Override
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

> >+
> >+    if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) != NULL) {
> >+        if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) != NULL) {
> >+            AcpiGbl_DSDT_TablePtr = *(void **)p;
> >+	    printf("ACPI: DSDT was overridden.\n");
> >+        }
> >+    }
> >+
> 
> Hmmm, touching ACPICA internal variable is not so clean way. 
> I want Intel forks to add official interface for overriding DSDT.
> I tried to load the DSDT with AcpiLoadTable() but rejected 
> with AE_EXIST.

OK, I think this should give us the same effect.

            AcpiUnloadTable(ACPI_TABLE_DSDT);
            AcpiNsRootInitialize();
            AcpiLoadTable(*(void **)p);
            AcpiNsLoadNamespace();

However, it seems there are some bugs in nsalloc.c.  Quick fixes
attached.  AcpiUnloadTable() in userland debugger can work well with
the paches.
In kernel side, we still get infinity loop in somewhere around
AcpiUnloadTable()...
Anyone try to fix this?

Thanks

Index: nsalloc.c
===================================================================
RCS file: /home/ncvs/src/sys/contrib/dev/acpica/nsalloc.c,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 nsalloc.c
--- nsalloc.c	31 Oct 2001 02:32:28 -0000	1.1.1.11
+++ nsalloc.c	2 Nov 2001 21:32:08 -0000
@@ -546,7 +546,7 @@
 AcpiNsRemoveReference (
     ACPI_NAMESPACE_NODE     *Node)
 {
-    ACPI_NAMESPACE_NODE     *NextNode;
+    ACPI_NAMESPACE_NODE     *NextNode, *ParentNode;
 
 
     FUNCTION_ENTRY ();
@@ -559,6 +559,8 @@
     NextNode = Node;
     while (NextNode)
     {
+        ParentNode = AcpiNsGetParentObject (NextNode);
+
         /* Decrement the reference count on this node*/
 
         NextNode->ReferenceCount--;
@@ -567,6 +569,13 @@
 
         if (!NextNode->ReferenceCount)
         {
+            if (NextNode == AcpiGbl_RootNode)
+            {
+                AcpiGbl_RootNodeStruct.Child = NULL;
+                AcpiGbl_RootNode = NULL;
+                break;
+            }
+
             /* Delete all children and delete the node */
 
             AcpiNsDeleteChildren (NextNode);
@@ -575,7 +584,7 @@
 
         /* Move up to parent */
 
-        NextNode = AcpiNsGetParentObject (NextNode);
+        NextNode = ParentNode;
     }
 }
 
@@ -620,6 +629,11 @@
 
         ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode,
                                             ChildNode);
+        if (ChildNode == AcpiGbl_RootNode)
+        {
+            break;
+        }
+
         if (ChildNode)
         {
             if (ChildNode->OwnerId == OwnerId)
@@ -645,6 +659,7 @@
             else if (ChildNode->OwnerId == OwnerId)
             {
                 AcpiNsRemoveReference (ChildNode);
+                ChildNode   = 0;
             }
         }
 
