From owner-acpi-jp@jp.FreeBSD.org Tue Jul 23 03:15:11 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g6MIFBT03042;
	Tue, 23 Jul 2002 03:15:11 +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.11.6+3.4W/8.11.3) with ESMTP/inet id g6MIF8n02981
	for <acpi-jp@jp.FreeBSD.org>; Tue, 23 Jul 2002 03:15:08 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwa@tasogare.imasy.or.jp [202.227.24.5])
	by tasogare.imasy.or.jp (8.11.6+3.4W/8.11.6/tasogare) with ESMTP/inet id g6MIF0h92702;
	Tue, 23 Jul 2002 03:15:01 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Date: Tue, 23 Jul 2002 03:14:49 +0900 (JST)
Message-Id: <20020723.031449.21934582.iwasaki@jp.FreeBSD.org>
To: acpi-jp@jp.FreeBSD.org, jon@freebsd.org
From: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
In-Reply-To: <20020718225041.J46307@porthos.spock.org>
References: <20020718225041.J46307@porthos.spock.org>
X-Mailer: Mew version 2.2 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-Sequence: acpi-jp 1690
Subject: [acpi-jp 1690] Re: simple acpi fixes, and some questions
Errors-To: owner-acpi-jp@jp.FreeBSD.org
Sender: owner-acpi-jp@jp.FreeBSD.org
X-Originator: iwasaki@jp.FreeBSD.org
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+020717

Hi,

> First, it seems that AcpiEvaluateObject() can sometimes return OK but leave
> the output buffer NULL.  The patch to acpi_cmbat.c fixes the resulting
> panics I was seeing.  I'm not sure if AcpiEvaluateObject()'s behavior is
> intended or not.  If this patch looks okay, let me know and I can commit
> it; or if you think something else is wrong here, let me know what and I
> can play with it some more.

Thanks.  I'll commit this one shortly.

> Also, I have some general questions as well.  The main problem I had with
> getting ACPI to work was some mysterious panics in the UFS code whenever
> ACPI was enabled.  I finally was able to track the problem down, which was
> caused by running the _INI method for \_SB_.PCI0.PCI1.CBS0 or
> \_SB_.PCI0.PCI1.CBS1.  The simple fix was to set debug.acpi.avoid="" (ie
> flags=ACPI_NO_DEVICE_INIT when running AcpiEnableSubsystem()).  NetBSD
> appears to have this as the default, does anyone know why they skip running
> _INI and we don't?  In any case, can I/how do I find out what CBS0/CBS1 are
> doing in the _INI method?  I don't have too much experience with ACPI, but

acpicadb in ports/devel/acpicatools/ would be useful for your purpose.
Sample usage log attached.

> I'm guessing this might have something to do with PCI1 not being properly
> initialized, might that be the case?  Or do I need to use _REG to turn on
> some regions in PCI1 before I can _INI the children?  (incidentally, does
> _REG affect things globally or just for one device?)  I'm reading the 
> ACPI2.0 specs, which says that we must enable a bunch of regions, yet I do 
> not see _REG used anywhere in the FreeBSD ACPI code.  Is this an oversight, 
> or am I missing something?

I think it's in ACPI CA code.

AcpiInstallAddressSpaceHandler()
  AcpiEvAddrHandlerHelper()
    AcpiEvAttachRegion()
      AcpiEvExecuteRegMethod()
        AcpiNsEvaluateByHandle()

Also _INI is executed at AcpiNsInitOneDevice().

Thanks

# ./acpicadb /tmp/TPA20P.dsdt
 tbutils-0360: *** Warning: Invalid checksum (C3) in table DSDT
  utmisc-0708 [10] UtAcquireMutex        : Mutex [ACPI_MTX_Namespace] already acquired by this thread [75C8]
  utmisc-0708 [10] UtAcquireMutex        : Mutex [ACPI_MTX_Namespace] already acquired by this thread [75C8]
Parsing Methods:.......................................................................................................................................................................................................................................................................................................................
Table [DSDT] - 1079 Objects with 53 Devices 311 Methods 19 Regions
- f _INI
                 \_SB_.PCI0._INI (0x80a9128) - Method
       \_SB_.PCI0.AGP_.VID_._INI (0x80ae428) - Method
       \_SB_.PCI0.ISA_.EC__._INI (0x808cea8) - Method
            \_SB_.PCI0.CBS0._INI (0x80c0028) - Method
            \_SB_.PCI0.CBS1._INI (0x80c0a28) - Method
            \_SB_.PCI0.DOCK._INI (0x80c1128) - Method
                 \_SB_.BT__._INI (0x80c6a28) - Method
- debug _SB_.PCI0.CBS0._INI
Executing \_SB_.PCI0.CBS0._INI
00000 #0070 [00]  Store
            [00]  (
00001 #0000 [01]  ....Zero
00002 #002D [01]  ....LGDC  (Path \_SB_.PCI0.CBS0.LGDC)
            [01]  }

% 
ArgObj:    0x80ef828 [Const]           Zero (0) [Null Target]
ArgObj:    0x80bfda8 <Node>            Name LGDC Type-RegionField
00000 #5B80 [00]  OperationRegion CBUS  (Path \_SB_.PCI0.CBS0.CBUS)
            [00]  (
00006 #000A [01]  ....(UINT8)  0x02,
00007 #000A [01]  ....(UINT8)  0x00,
00009 #000B [01]  ....(UINT16) 0x0100
            [01]  }

% 
ArgObj:    0x80ef828 <Obj>             Integer 0000000000000000
ArgObj:    0x80ef928 <Obj>             Integer 0000000000000100
DEBUG[write(PCI_CONFIG, 32, 0x44)](default: 0x0  / 0) >>
ResultObj: 0x80ef8a8 <Obj>             Integer 0000000000000000

00006 #007B [00]  And
            [00]  (
00007 #002D [01]  ....CCTL,  (Path \_SB_.PCI0.CBS0.CCTL)
0000B #000A [01]  ....(UINT8)  0x7F,
0000D #002D [01]  ....CCTL  (Path \_SB_.PCI0.CBS0.CCTL)
            [01]  }

% 
ArgObj:    0x80bff28 <Node>            Name CCTL Type-RegionField
ArgObj:    0x80ef8a8 <Obj>             Integer 000000000000007F
ArgObj:    0x80bff28 <Node>            Name CCTL Type-RegionField
DEBUG[read (PCI_CONFIG, 32, 0x90)](default: 0x0  / 0) >>
DEBUG[read (PCI_CONFIG, 32, 0x90)](default: 0x0  / 0) >>
DEBUG[write(PCI_CONFIG, 32, 0x90)](default: 0x0  / 0) >>
ResultObj: 0x80ef828 <Obj>             Integer 0000000000000000

00011 #007D [00]  Or
            [00]  (
00012 #002D [01]  ....SYSC,  (Path \_SB_.PCI0.CBS0.SYSC)
00016 #000A [01]  ....(UINT8)  0x01,
00018 #002D [01]  ....SYSC  (Path \_SB_.PCI0.CBS0.SYSC)
            [01]  }

% 
ArgObj:    0x80bfe28 <Node>            Name SYSC Type-RegionField
ArgObj:    0x80ef828 <Obj>             Integer 0000000000000001
ArgObj:    0x80bfe28 <Node>            Name SYSC Type-RegionField
DEBUG[read (PCI_CONFIG, 32, 0x80)](default: 0x0  / 0) >>
DEBUG[write(PCI_CONFIG, 32, 0x80)](default: 0x1  / 1) >>
ResultObj: 0x80ef8a8 <Obj>             Integer 0000000000000001

0001C #00A0 [00]  If
            [00]  (
0001E #0092 [01]  ....LNot
            [01]  ....(
0001F #007B [02]  ........And
            [02]  ........(
00020 #002D [03]  ............_ADR,  (Path \_SB_.PCI0.CBS0._ADR)
00024 #000B [03]  ............(UINT16) 0xFFFF,
00027 #002D [03]  ............<NULL NAME PTR>
            [03]  ........}
            [02]  ....}
            [01]  }

% 
ArgObj:    0x80b2128 <Node>            Name _ADR Type-Integer
ArgObj:    0x80ef8a8 <Obj>             Integer 000000000000FFFF
ArgObj:    0x80ef828 [Const]           Zero (0) [Null Target]
ResultObj: 0x80ef928 <Obj>             Integer 0000000000000000

0001C #00A0 [00]  If
            [00]  (
0001E #0092 [01]  ....LNot
            [01]  ....(
00000 #0036 [02]  ........[Return Value] Integer 0000000000000000
            [02]  ....}
            [01]  }

% 
ArgObj:    0x80af328 <Parser>  
ArgObj:    0x80ef928 <Obj>             Integer 0000000000000000
ResultObj: 0x80ef828 <Obj>             Integer 0000000000000001

00028 #007B [00]  And
            [00]  (
00029 #002D [01]  ....MCTL,  (Path \_SB_.PCI0.CBS0.MCTL)
0002D #000A [01]  ....(UINT8)  0x83,
0002F #002D [01]  ....BMCL  (Path \_SB_.PCI0.CBS0.BMCL)
            [01]  }

% 
ArgObj:    0x80bfea8 <Node>            Name MCTL Type-RegionField
ArgObj:    0x80ef828 <Obj>             Integer 0000000000000083
ArgObj:    0x80c00a8 <Node>            Name BMCL Type-Integer
DEBUG[read (PCI_CONFIG, 32, 0x84)](default: 0x0  / 0) >>
ResultObj: 0x80ef928 <Obj>             Integer 0000000000000000

0001C #00A0 [00]  If
Predicate = [True], IF block was executed

% 
- q
 utalloc-1109 [09] UtDumpAllocations     : No outstanding allocations.
