Jump to content

evaluateInteger with buffer argument


alex.daoud
 Share

1 post in this topic

Recommended Posts

Hey guys, not sure where to post this but this seems like the best place.

 

I'm trying to evaluate a _DSM which accepts 3 arguments, one of which is a buffer. Here is what the method looks like in the DSDT:

                Method (_DSM, 4, NotSerialized)
                {
                    If (LEqual (Arg0, Buffer (0x10)
                            {
                                /* 0000 */    0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45, 
                                /* 0008 */    0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE
                            }))
                    {
                        If (LEqual (Arg2, Zero))
                        {
                            If (LEqual (Arg1, One))
                            {
                                Return (Buffer (One)
                                {
                                    0x03
                                })
                            }
                            Else
                            {
                                Return (Buffer (One)
                                {
                                    0x00
                                })
                            }
                        }

                        If (LEqual (Arg2, One))
                        {
                            Return (0x20)
                        }
                    }
                    Else
                    {
                        Return (Buffer (One)
                        {
                            0x00
                        })
                    }
                }

The aim is to get the integer value 0x20 in return (the only variation on the arguments where an integer is returned, the rest are buffers).

 

I have tried to use the following code to evaluate the method but it gives me an argument error:

    static UInt8 i2c_hid_guid[] = {
        0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
        0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE
     };
    
    UInt32 *result = NULL;
    OSObject *params[3];
    char buffer[16];
    
    memcpy(buffer, i2c_hid_guid, 16);
    
    params[0] = OSData::withBytes(buffer, 16);
    params[1] = OSNumber::withNumber(0x1, 8);
    params[2] = OSNumber::withNumber(0x1, 8);
    
    int ret = ihid->client->provider->evaluateInteger("_DSM", result, params, 3);

where ihid->client->provider returns a pointer to the IOService object with the _DSM method described above. Whenever I try this, ret gives a bad argument error. Does anyone have any idea on what I should do to get the above working? I'm probably missing something simple while copying the integer array into the buffer.

 

Thanks in advance.

 

 

Edit:

 

For anyone interested in this, I fixed it by using 4 32-bit integers with their bytes reversed instead of an array of 8-bit integers. I think it was the byte reversal that was needed.

Link to comment
Share on other sites

 Share

×
×
  • Create New...