linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Problems evaluating WMI method
@ 2008-09-30 22:56 Duarte Silva
  2008-10-01 17:55 ` Carlos Corbacho
  0 siblings, 1 reply; 6+ messages in thread
From: Duarte Silva @ 2008-09-30 22:56 UTC (permalink / raw)
  To: linux-acpi

Hi,

After parsing the _WDG buffer from a PNP0C14 device I got this (the format is 
<guid> - <object-id> - <parsed-guid-type> - <guid-type>)

C3A72B38-D3EF-42D3-8CBB-D5A57049F66D - AB - method - 2
E4FB94F9-7F2B-4173-AD1A-CD1D95086248 - event - 8
023B133E-49D1-4E10-B313-698220140DC2 - event - 8
37BE1AC0-C3F2-4B1F-BFBE-8FDEAF2814D6 - event - 8
911BAD44-7DF8-4FBB-9319-BABA1C4B293B - event - 8
4E5C4404-3CED-4A5E-8C7A-1BA875D00A43 - BA - method - 2
2B4F501A-BD3C-4394-8DCF-00A7D2BC8210 - BB - method - 2
05901221-D566-11D1-B2F0-00A0C9062910 - AC - unknown - 0

That first GUID map to WMAB (I guess).  So why when I do this (simplified 
version)

struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer in;
structwmab_args args = {
	.mar0 = 0x00,
	.mar1 = 0x01,
	.mar2 = 0x00,
};

in.length = (acpi_size)sizeof(struct wmab_args);
in.pointer = &args;

wmi_evaluate_method("C3A72B38-D3EF-42D3-8CBB-D5A57049F66D", 1, 1, &in, &out);

printk( KERN_INFO "QUERY %i\n", (u32)out.length);

kfree(out.pointer);

I get a output with a lenght of 24 and when I convert it to a acpi_object I 
get type integer. Result in dmesg

QUERY 24

When the code in WMAB is

Method (WMAB, 3, Serialized)
{
    Store (Arg0, MAR0)
    Store (Arg1, MAR1)
    Store (Arg2, MAR2)
    If (LAnd (LGreaterEqual (MAR0, Zero), LLessEqual (MAR0, 0x2F)))
    {
        If (LEqual (MAR0, Zero))
        {
            If (LEqual (MAR1, One))
            {
                Return (0x0300)
            }
            Return (0x80000002)
       }
       (...)

With the parameters I provided it should be returning something like 0x300. 
What Iam doing wrong?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems evaluating WMI method
  2008-09-30 22:56 Duarte Silva
@ 2008-10-01 17:55 ` Carlos Corbacho
  2008-10-01 18:22   ` Duarte Silva
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos Corbacho @ 2008-10-01 17:55 UTC (permalink / raw)
  To: Duarte Silva; +Cc: linux-acpi

On Tuesday 30 September 2008 23:56:09 Duarte Silva wrote:
> wmi_evaluate_method("C3A72B38-D3EF-42D3-8CBB-D5A57049F66D", 1, 1, &in,
> &out);
>
> printk( KERN_INFO "QUERY %i\n", (u32)out.length);
>
> kfree(out.pointer);
>
> I get a output with a lenght of 24 and when I convert it to a acpi_object I
> get type integer. Result in dmesg
>
> QUERY 24

Ok, but what's the actual result?

e.g.

acpi_object *obj;

wmi_evaluate_method(guid, 1, 1, &in, &out);

obj = (union acpi_object *) out.pointer;

printk(KERN_INFO "RESULT %i\n", obj->value);

-Carlos
-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems evaluating WMI method
  2008-10-01 17:55 ` Carlos Corbacho
@ 2008-10-01 18:22   ` Duarte Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Duarte Silva @ 2008-10-01 18:22 UTC (permalink / raw)
  To: linux-acpi

On Wednesday 01 October 2008 18:55:29 Carlos Corbacho wrote:
> On Tuesday 30 September 2008 23:56:09 Duarte Silva wrote:
> > wmi_evaluate_method("C3A72B38-D3EF-42D3-8CBB-D5A57049F66D", 1, 1, &in,
> > &out);
> >
> > printk( KERN_INFO "QUERY %i\n", (u32)out.length);
> >
> > kfree(out.pointer);
> >
> > I get a output with a lenght of 24 and when I convert it to a acpi_object
> > I get type integer. Result in dmesg
> >
> > QUERY 24
>
> Ok, but what's the actual result?
>
> e.g.
>
> acpi_object *obj;
>
> wmi_evaluate_method(guid, 1, 1, &in, &out);
>
> obj = (union acpi_object *) out.pointer;
>
> printk(KERN_INFO "RESULT %i\n", obj->value);
>
> -Carlos

It's of type integer and the result is allways one. But it is possible, Iam in 
a 64 bits platform, so three ints are 24 bytes (8 * 3)
But the strange part is that the result is allways one, when it should be 
0x0300.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems evaluating WMI method
@ 2008-10-01 20:13 Duarte Silva
  2008-10-01 20:26 ` Carlos Corbacho
  0 siblings, 1 reply; 6+ messages in thread
From: Duarte Silva @ 2008-10-01 20:13 UTC (permalink / raw)
  To: linux-acpi

Hi,

I found out the problem. Looking at a part on the WMAB code

Method (WMAB, 3, Serialized)
{
    Store (Arg0, MAR0)
    Store (Arg1, MAR1)
    Store (Arg2, MAR2)
    (...)

    If (LEqual (MAR0, 0x33))
    {
        If (LEqual (MAR1, One))
        {
            If (ECON)
            {
                Store (^^PCI0.LPCB.EC.DFAN, Local0)
            }
            (...)
            Return (Local0)
       }
       (...)

I know the posible values for DFAN, they are 12, 22 and 2. This are the states 
of the laptop fan. So when I do WMAB(0x33, 0x01, 0x00) it should return one 
of those values. In wmi.c we got this 

acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
{
    (...)
    input.count = 2;
    input.pointer = params;
    params[0].type = ACPI_TYPE_INTEGER;
    params[0].integer.value = instance;
    params[1].type = ACPI_TYPE_INTEGER;
    params[1].integer.value = method_id;

    if (in) {
        input.count = 3;

        if (block->flags & ACPI_WMI_STRING) {
            params[2].type = ACPI_TYPE_STRING;
        } else {
            params[2].type = ACPI_TYPE_BUFFER;
        }
        params[2].buffer.length = in->length;
        params[2].buffer.pointer = in->pointer;
    }

    strncat(method, block->object_id, 2);

    status = acpi_evaluate_object(handle, method, &input, out);

So, when I try to evaluate the WMAB method, the parameters will be screwed up 
because we are not only passing the structure, we are also passing the 
instance and the method_id to WMAB. The following is a stack look like 
representation.

[CORRECT] [CURRENT]
arg0           instance -> gets to be the Arg0
arg1           method_id -> gets to be the Arg1
arg2           arg0 -> gets to be the Arg2
                  arg1
                  arg2

I got the correct answer when I do instance = 0x33 and method_id = 0x01. So, I 
looked at hp-wmi.c code and acer-wmi.c and they depend on this instance and  
method_id. But my laptop doesnt seem to depend. Is this instance and 
method_id a WMI standart or is it a HP and Acer laptop specific? My laptop is 
a LG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems evaluating WMI method
  2008-10-01 20:13 Problems evaluating WMI method Duarte Silva
@ 2008-10-01 20:26 ` Carlos Corbacho
  2008-10-01 20:48   ` Duarte Silva
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos Corbacho @ 2008-10-01 20:26 UTC (permalink / raw)
  To: Duarte Silva; +Cc: linux-acpi

On Wednesday 01 October 2008 21:13:50 Duarte Silva wrote:
> I got the correct answer when I do instance = 0x33 and method_id = 0x01.
> So, I looked at hp-wmi.c code and acer-wmi.c and they depend on this
> instance and method_id. But my laptop doesnt seem to depend. 

acer-wmi doesn't rely on the instance_id, it just gets ignored. It does use 
the method_id though.

> Is this 
> instance and method_id a WMI standart or is it a HP and Acer laptop
> specific? My laptop is a LG.

Yes, these are part of the WMI standard (in that, they need to be passed in). 
I would recommend you read through the spec:

http://web.archive.org/web/20071011004327/http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

Essentially - you need to pass the instance and method id's, but what values 
you pass and their meaning is completely vendor specific (which is pretty 
much a good summary of ACPI-WMI in general).

-Carlos
-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems evaluating WMI method
  2008-10-01 20:26 ` Carlos Corbacho
@ 2008-10-01 20:48   ` Duarte Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Duarte Silva @ 2008-10-01 20:48 UTC (permalink / raw)
  To: linux-acpi

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

On Wednesday 01 October 2008 21:26:28 Carlos Corbacho wrote:
> On Wednesday 01 October 2008 21:13:50 Duarte Silva wrote:
> > I got the correct answer when I do instance = 0x33 and method_id = 0x01.
> > So, I looked at hp-wmi.c code and acer-wmi.c and they depend on this
> > instance and method_id. But my laptop doesnt seem to depend.
>
> acer-wmi doesn't rely on the instance_id, it just gets ignored. It does use
> the method_id though.
>
> > Is this
> > instance and method_id a WMI standart or is it a HP and Acer laptop
> > specific? My laptop is a LG.
>
> Yes, these are part of the WMI standard (in that, they need to be passed
> in). I would recommend you read through the spec:
>
> http://web.archive.org/web/20071011004327/http://www.microsoft.com/whdc/sys
>tem/pnppwr/wmi/wmi-acpi.mspx
>
> Essentially - you need to pass the instance and method id's, but what
> values you pass and their meaning is completely vendor specific (which is
> pretty much a good summary of ACPI-WMI in general).
>
> -Carlos

Oh, I got it, so it doesnt have a standart meaning, now it makes sence. In my 
case when you pass 0x01 as the method_id you are saying you want to get the 
value defined by the instance variable. Other values for the method_id can 
mean other actions. Thanks for the help Carlos :)

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-10-01 20:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-01 20:13 Problems evaluating WMI method Duarte Silva
2008-10-01 20:26 ` Carlos Corbacho
2008-10-01 20:48   ` Duarte Silva
  -- strict thread matches above, loose matches on Subject: below --
2008-09-30 22:56 Duarte Silva
2008-10-01 17:55 ` Carlos Corbacho
2008-10-01 18:22   ` Duarte Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).