From owner-acpi-jp@jp.freebsd.org  Mon Feb  5 13:51:58 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id NAA00544;
	Mon, 5 Feb 2001 13:51:58 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (shidahara1.planet.sci.kobe-u.ac.jp [133.30.50.200])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id NAA00539
	for <acpi-jp@jp.freebsd.org>; Mon, 5 Feb 2001 13:51:58 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (localhost [127.0.0.1])
	by shidahara1.planet.sci.kobe-u.ac.jp (8.9.3/8.9.3) with ESMTP id NAA52909;
	Mon, 5 Feb 2001 13:53:40 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Message-Id: <200102050453.NAA52909@shidahara1.planet.sci.kobe-u.ac.jp>
To: andrew.grover@intel.com
cc: acpi-jp@jp.freebsd.org
Date: Mon, 05 Feb 2001 13:53:39 +0900
From: Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 1050
Subject: [acpi-jp 1050] Some problem in resource handle part.
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: takawata@shidahara1.planet.sci.kobe-u.ac.jp

Hi, I wrote some code for configuration using ACPI, and I have some comment.


1. Is this structure correct?

typedef struct
{
    UINT32                      ProducerConsumer;
    UINT32                      EdgeLevel;
    UINT32                      ActiveHighLow;
    UINT32                      SharedExclusive;
    UINT32                      NumberOfInterrupts;
    UINT32                      Interrupts[1];
    UINT32                      ResourceSourceIndex;
    UINT32                      ResourceSourceStringLength;
    NATIVE_CHAR                 ResourceSource[1];

} EXTENDED_IRQ_RESOURCE;

I think it is wrong.As far as I read, size of both Interrupt member 
and Resource Source member are variable.If ResourceSource exists
Interrupts array will smash it!

BASE   +---------------------------------+
       |ProducerConsumer                 |
BASE+4 +---------------------------------+
       |EdgeLevel			 |
BASE+8 +---------------------------------+
       |ActiveHighLow			 |
BASE+12+---------------------------------+
       |SharedExclusive			 |
BASE+16+---------------------------------+
       |NumberOfInterrupts		 |
BASE+20+---------------------------------+
       |                    Interrupts[0]|
BASE+24+---------------------------------+
       |ResourceSourceIndex|Interrupts[1]|<-Smash after this!
BASE+28+---------------------------------+
       |ResourceSourceStringLength       |
BASE+32+---------------------------------+
       |ResourceSource[0]		 |
BASE+33+---------------------------------+
       |ResourceSource[1]		 |
                    .
		    .
To fix this, the structure should be as follows

typedef struct
{
    UINT32                      ProducerConsumer;
    UINT32                      EdgeLevel;
    UINT32                      ActiveHighLow;
    UINT32                      SharedExclusive;
    UINT32                      NumberOfInterrupts;
    UINT32                      ResourceSourceIndex;
    UINT32                      ResourceSourceStringLength;
    NATIVE_CHAR                 *ResourceSource;
    UINT32                      Interrupts[1];
    /*Resource Source content follows after this*/
} EXTENDED_IRQ_RESOURCE;

BASE   +---------------------------------+
       |ProducerConsumer                 |
BASE+4 +---------------------------------+
       |EdgeLevel			 |
BASE+8 +---------------------------------+
       |ActiveHighLow			 |
BASE+12+---------------------------------+
       |SharedExclusive			 |
BASE+16+---------------------------------+
       |NumberOfInterrupts		 |
BASE+20+---------------------------------+
       |ResourceSourceIndex              |
BASE+24+---------------------------------+
       |ResourceSourceStringLength       |
BASE+28+---------------------------------+
       |ResourceSource			 |-+
BASE+32+---------------------------------+ |
       |Interrupts[0]		 	 | |
BASE+36+---------------------------------+ |
       |Interrupts[1]		 	 | |
BASE+40+---------------------------------+ |
                      ....                 |
BASE+XX+---------------------------------+<+		      
       |String Begins here               |
       +---------------------------------+
                      ....
       +---------------------------------+       
       |               \0                |
       +---------------------------------+              


2.Shouldn't it be more liberal for size of resource stream?
There are some cases that the resource stream buffer does not 
end with end tag resource.For example,If there is  AML that is generated from 
following ASL

OperationRegion(SREG,SystemIo,0x3f2,2)
Field(SREG,ByteAcc,NoLock,Preserve){
	SMRQ,8
}
OperationRegion(SDAT,SystemMemory,0x3fff000,0x80)
Field(SDAT,ByteAcc, NoLock,Preserve){
	CMD,8
	DID,8
	RESB,1000
}

Device(DEV0){
	Method(_PRS){
		Store(0,DID)
		Store(0,CMD)
		Store(0,SMRQ)
		Return(RESB)
	}
	Method(_CRS){
		Store(0,DID)
		Store(1,CMD)
		Store(0,SMRQ)
		Return(RESB)
	}
}
Device(DEV1){
	Method(_PRS){
		Store(1,DID)
		Store(0,CMD)
		Store(0,SMRQ)
		Return(RESB)
	}
	Method(_CRS){
		Store(1,DID)
		Store(1,CMD)
		Store(0,SMRQ)
		Return(RESB)
	}
}

and SMRQ access generates SMI and process DID and CMD field then 
return result in SMRQ buffer.
In this case The RESB size is always 125 bytes long,but resource
stream is not always 125 and I do not find resource stream buffer
always have to be just same length as resource stream itself in
the spac.(If there is such description, please show me.)


3.At least one bogus vendor puts ANSI string tag into the ACPI resource stream.
As described in the spec, format of the resource stream is almost like the
one used in PnPBIOS.But there is some different:some tags are not used and 
marked as Reserved.ANSI string tag is one of them. The role is now in
_STR object. But, in my TP240,the vendor puts the tag, as in PnPBIOS.


I think 1. 2. is the problem of ACPICA side. So I want you to fix it.

3. is vendor side problem.So if you don't want to incorporate the workaround,
we will have it as a local patch.

Thanks.

Takanori Watanabe
<a href="http://www.planet.sci.kobe-u.ac.jp/~takawata/key.html">
Public Key</a>
Key fingerprint =  2C 51 E2 78 2C E1 C5 2D  0F F1 20 A3 11 3A 62 2A 


