From owner-acpi-jp@jp.freebsd.org  Tue Oct  2 11:10:48 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id LAA09961;
	Tue, 2 Oct 2001 11:10:48 +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 LAA09956
	for <acpi-jp@jp.FreeBSD.org>; Tue, 2 Oct 2001 11:10:48 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	by tasogare.imasy.or.jp (8.11.6+3.4W/8.11.6/tasogare/smtpfeed 1.14) with ESMTP/inet id f922Akm80194;
	Tue, 2 Oct 2001 11:10:46 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Date: Tue, 02 Oct 2001 11:10:45 +0900 (JST)
Message-Id: <20011002.111045.78762705.iwasaki@jp.FreeBSD.org>
To: sobomax@FreeBSD.org
Cc: ache@nagual.pp.ru, msmith@FreeBSD.org, current@FreeBSD.org,
        acpi-jp@jp.FreeBSD.org
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
In-Reply-To: <20011002.023158.71143343.iwasaki@jp.FreeBSD.org>
References: <20011002.005340.74695085.iwasaki@jp.FreeBSD.org>
	<3BB89FA1.DD75D31C@FreeBSD.org>
	<20011002.023158.71143343.iwasaki@jp.FreeBSD.org>
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 1315
Subject: [acpi-jp 1315] Re: ACPI: problem with fdc resource allocation
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

Hi, I've just made a workaround for this.  Intel folks, could you review
it as always?

> The problem is here, right?
> > can't fetch resources for \\_SB_.PCI0.ISA_.FDC0 - AE_AML_BUFFER_LIMIT
> 
> I'm sure _SB_.PCI0.ISA_.FDC0._CRS (Current Resource Settings) have some
> problems (not sure in BIOS or ACPICA yet).  I could reproduce the problem
> which you reported.  Trace attached in this mail.
[snip]
> dsopcode-0677 [09] DsEvalBufferFieldOpera: Field size 208 exceeds Buffer size 192 (bits)
> PsExecute: method failed - \_SB_.PCI0.ISA_.FDC0._CRS (0x8098fa8)
> Execution of \_SB_.PCI0.ISA_.FDC0._CRS failed with status AE_AML_BUFFER_LIMIT

This method is like this;
                Method(_CRS) {
                    Name(BUF0, Buffer(0x18) {0x47, 0x1, 0xf2, 0x3, 0xf2, 0x3,
			       0x0, 0x4, 0x47, 0x1, 0xf7, 0x3, 0xf7, 0x3, 0x0,
			       0x1, 0x22, 0x40, 0x0, 0x2a, 0x4, 0x0, 0x79, 0x0 })
                    CreateByteField(BUF0, 0x2, IOLO)
                    CreateByteField(BUF0, 0x3, IOHI)
                    CreateByteField(BUF0, 0x4, IORL)
                    CreateByteField(BUF0, 0x5, IORH)
                    CreateByteField(BUF0, 0x19, IRQL)
                    CreateByteField(BUF0, 0x1c, DMAV)
                    Return(BUF0)
                }

The problem is that this AML is trying to create a field at exceeded
position (0x19) of the Buffer (size is 0x18).
I couldn't find how AML interprepter treat this in ACPI Spec. so I'm
not sure wether AWRDACPI violates the Spec. or ACPICA can have a workaround
for this.
Anyway, I made a patch to reallocate a large enough buffer for the
requested operation.

Thanks

Index: dsopcode.c
===================================================================
RCS file: /home/ncvs/src/sys/contrib/dev/acpica/dsopcode.c,v
retrieving revision 1.1.1.10
diff -u -r1.1.1.10 dsopcode.c
--- dsopcode.c	7 Sep 2001 01:22:24 -0000	1.1.1.10
+++ dsopcode.c	1 Oct 2001 18:58:41 -0000
@@ -615,11 +615,24 @@
         if ((BitOffset + BitCount) >
             (8 * (UINT32) SrcDesc->Buffer.Length))
         {
+            UINT32      Length;
+            UINT8       *Pointer;
+
             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                 "Field size %d exceeds Buffer size %d (bits)\n",
                  BitOffset + BitCount, 8 * (UINT32) SrcDesc->Buffer.Length));
-            Status = AE_AML_BUFFER_LIMIT;
-            goto Cleanup;
+            Length = ((BitOffset + BitCount) / 8) +
+                     (((BitOffset + BitCount) % 8) ? 1 : 0);
+            Pointer = ACPI_MEM_CALLOCATE (Length);
+            if (!Pointer)
+            {
+                Status = AE_NO_MEMORY;
+                goto Cleanup;
+            }
+            MEMCPY (Pointer, SrcDesc->Buffer.Pointer, SrcDesc->Buffer.Length);
+            ACPI_MEM_FREE (SrcDesc->Buffer.Pointer);
+            SrcDesc->Buffer.Pointer = Pointer;
+            SrcDesc->Buffer.Length = Length;
         }
 
 
