本文整理匯總了C++中AcpiOsFree函數的典型用法代碼示例。如果您正苦於以下問題:C++ AcpiOsFree函數的具體用法?C++ AcpiOsFree怎麽用?C++ AcpiOsFree使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AcpiOsFree函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: AcpiEvaluateObject
/**
* radeon_atpx_call - call an ATPX method
*
* @handle: acpi handle
* @function: the ATPX function to execute
* @params: ATPX function params
*
* Executes the requested ATPX function (all asics).
* Returns a pointer to the acpi output buffer.
*/
static ACPI_OBJECT *radeon_atpx_call(ACPI_HANDLE handle, int function,
ACPI_BUFFER *params)
{
ACPI_STATUS status;
ACPI_OBJECT atpx_arg_elements[2];
ACPI_OBJECT_LIST atpx_arg;
ACPI_BUFFER buffer = { ACPI_ALLOCATE_BUFFER, NULL };
atpx_arg.Count = 2;
atpx_arg.Pointer = &atpx_arg_elements[0];
atpx_arg_elements[0].Type = ACPI_TYPE_INTEGER;
atpx_arg_elements[0].Integer.Value = function;
if (params) {
atpx_arg_elements[1].Type = ACPI_TYPE_BUFFER;
atpx_arg_elements[1].Buffer.Length = params->Length;
atpx_arg_elements[1].Buffer.Pointer = params->Pointer;
} else {
/* We need a second fake parameter */
atpx_arg_elements[1].Type = ACPI_TYPE_INTEGER;
atpx_arg_elements[1].Integer.Value = 0;
}
status = AcpiEvaluateObject(handle, NULL, &atpx_arg, &buffer);
/* Fail only if calling the method fails and ATPX is supported */
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
DRM_ERROR("failed to evaluate ATPX got %s\n",
AcpiFormatException(status));
AcpiOsFree(buffer.Pointer);
return NULL;
}
return buffer.Pointer;
}
示例2: AcpiUtAllocateAndTrack
void *
AcpiUtAllocateAndTrack (
ACPI_SIZE Size,
UINT32 Component,
const char *Module,
UINT32 Line)
{
ACPI_DEBUG_MEM_BLOCK *Allocation;
ACPI_STATUS Status;
Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
Component, Module, Line);
if (!Allocation)
{
return (NULL);
}
Status = AcpiUtTrackAllocation (Allocation, Size,
ACPI_MEM_MALLOC, Component, Module, Line);
if (ACPI_FAILURE (Status))
{
AcpiOsFree (Allocation);
return (NULL);
}
AcpiGbl_GlobalList->TotalAllocated++;
AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
{
AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
}
return ((void *) &Allocation->UserSpace);
}
示例3: acpi_panasonic_hkey_event
static int
acpi_panasonic_hkey_event(struct acpi_panasonic_softc *sc, ACPI_HANDLE h,
UINT32 *arg)
{
ACPI_BUFFER buf;
ACPI_OBJECT *res;
ACPI_INTEGER val;
int status;
ACPI_SERIAL_ASSERT(panasonic);
status = ENXIO;
buf.Length = ACPI_ALLOCATE_BUFFER;
buf.Pointer = NULL;
AcpiEvaluateObject(h, "HINF", NULL, &buf);
res = (ACPI_OBJECT *)buf.Pointer;
if (res->Type != ACPI_TYPE_INTEGER) {
device_printf(sc->dev, "HINF returned non-integer\n");
goto end;
}
val = res->Integer.Value;
#ifdef ACPI_PANASONIC_DEBUG
device_printf(sc->dev, "%s button Fn+F%d\n",
(val & 0x80) ? "Pressed" : "Released",
(int)(val & 0x7f));
#endif
if ((val & 0x7f) > 0 && (val & 0x7f) < 11) {
*arg = val;
status = 0;
}
end:
if (buf.Pointer)
AcpiOsFree(buf.Pointer);
return (status);
}
示例4: AeExceptionHandler
static ACPI_STATUS
AeExceptionHandler (
ACPI_STATUS AmlStatus,
ACPI_NAME Name,
UINT16 Opcode,
UINT32 AmlOffset,
void *Context)
{
ACPI_STATUS NewAmlStatus = AmlStatus;
ACPI_STATUS Status;
ACPI_BUFFER ReturnObj;
ACPI_OBJECT_LIST ArgList;
ACPI_OBJECT Arg[3];
const char *Exception;
Exception = AcpiFormatException (AmlStatus);
AcpiOsPrintf ("[AcpiExec] Exception %s during execution ", Exception);
if (Name)
{
AcpiOsPrintf ("of method [%4.4s]", (char *) &Name);
}
else
{
AcpiOsPrintf ("at module level (table load)");
}
AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset);
/*
* Invoke the _ERR method if present
*
* Setup parameter object
*/
ArgList.Count = 3;
ArgList.Pointer = Arg;
Arg[0].Type = ACPI_TYPE_INTEGER;
Arg[0].Integer.Value = AmlStatus;
Arg[1].Type = ACPI_TYPE_STRING;
Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception);
Arg[1].String.Length = ACPI_STRLEN (Exception);
Arg[2].Type = ACPI_TYPE_INTEGER;
Arg[2].Integer.Value = AcpiOsGetThreadId();
/* Setup return buffer */
ReturnObj.Pointer = NULL;
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj);
if (ACPI_SUCCESS (Status))
{
if (ReturnObj.Pointer)
{
/* Override original status */
NewAmlStatus = (ACPI_STATUS)
((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value;
/* Free a buffer created via ACPI_ALLOCATE_BUFFER */
AcpiOsFree (ReturnObj.Pointer);
}
}
else if (Status != AE_NOT_FOUND)
{
AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n",
AcpiFormatException (Status));
}
/* Global override */
if (AcpiGbl_IgnoreErrors)
{
NewAmlStatus = AE_OK;
}
if (NewAmlStatus != AmlStatus)
{
AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n",
AcpiFormatException (NewAmlStatus));
}
return (NewAmlStatus);
}
示例5: AcpiDbAddToHistory
void
AcpiDbAddToHistory (
char *CommandLine)
{
UINT16 CmdLen;
UINT16 BufferLen;
/* Put command into the next available slot */
CmdLen = (UINT16) strlen (CommandLine);
if (!CmdLen)
{
return;
}
if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL)
{
BufferLen = (UINT16) strlen (
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command);
if (CmdLen > BufferLen)
{
AcpiOsFree (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].
Command);
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command =
AcpiOsAllocate (CmdLen + 1);
}
}
else
{
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command =
AcpiOsAllocate (CmdLen + 1);
}
strcpy (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command,
CommandLine);
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum =
AcpiGbl_NextCmdNum;
/* Adjust indexes */
if ((AcpiGbl_NumHistory == HISTORY_SIZE) &&
(AcpiGbl_NextHistoryIndex == AcpiGbl_LoHistory))
{
AcpiGbl_LoHistory++;
if (AcpiGbl_LoHistory >= HISTORY_SIZE)
{
AcpiGbl_LoHistory = 0;
}
}
AcpiGbl_NextHistoryIndex++;
if (AcpiGbl_NextHistoryIndex >= HISTORY_SIZE)
{
AcpiGbl_NextHistoryIndex = 0;
}
AcpiGbl_NextCmdNum++;
if (AcpiGbl_NumHistory < HISTORY_SIZE)
{
AcpiGbl_NumHistory++;
}
}
示例6: AeMiscellaneousTests
//.........這裏部分代碼省略.........
ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 1);
ACPI_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 2,
ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 2);
ACPI_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 3,
ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 4,
ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 5,
ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
ACPI_CHECK_OK (AcpiGetHandle, Status);
Status = AcpiSetupGpeForWake (Handle, NULL, 5);
ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status);
Status = AcpiSetupGpeForWake (Handle, NULL, 6);
ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6);
ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
Status = AcpiSetupGpeForWake (Handle, NULL, 9);
ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
Status = AcpiInstallGpeHandler (NULL, 0x19,
ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 0x19);
ACPI_CHECK_OK (AcpiEnableGpe, Status);
/* GPE block 1 */
Status = AcpiInstallGpeHandler (NULL, 101,
ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 101);
ACPI_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiDisableGpe (NULL, 101);
ACPI_CHECK_OK (AcpiDisableGpe, Status);
AfInstallGpeBlock ();
/* Here is where the GPEs are actually "enabled" */
Status = AcpiUpdateAllGpes ();
ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
Status = AcpiGetHandle (NULL, "RSRC", &Handle);
if (ACPI_SUCCESS (Status))
{
ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
if (ACPI_SUCCESS (Status))
{
AcpiOsFree (ReturnBuf.Pointer);
}
}
/* Test global lock */
Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
Status = AcpiReleaseGlobalLock (LockHandle1);
ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
Status = AcpiReleaseGlobalLock (LockHandle2);
ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
#endif /* !ACPI_REDUCED_HARDWARE */
}
示例7: acpi_ec_probe
//.........這裏部分代碼省略.........
struct acpi_ec_params *params;
static char *ec_ids[] = { "PNP0C09", NULL };
/* Check that this is a device and that EC is not disabled. */
if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("ec"))
return (ENXIO);
/*
* If probed via ECDT, set description and continue. Otherwise,
* we can access the namespace and make sure this is not a
* duplicate probe.
*/
ret = ENXIO;
ecdt = 0;
buf.Pointer = NULL;
buf.Length = ACPI_ALLOCATE_BUFFER;
params = acpi_get_private(dev);
if (params != NULL) {
ecdt = 1;
ret = 0;
} else if (ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids)) {
params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP,
M_WAITOK | M_ZERO);
h = acpi_get_handle(dev);
/*
* Read the unit ID to check for duplicate attach and the
* global lock value to see if we should acquire it when
* accessing the EC.
*/
status = acpi_GetInteger(h, "_UID", ¶ms->uid);
if (ACPI_FAILURE(status))
params->uid = 0;
status = acpi_GetInteger(h, "_GLK", ¶ms->glk);
if (ACPI_FAILURE(status))
params->glk = 0;
/*
* Evaluate the _GPE method to find the GPE bit used by the EC to
* signal status (SCI). If it's a package, it contains a reference
* and GPE bit, similar to _PRW.
*/
status = AcpiEvaluateObject(h, "_GPE", NULL, &buf);
if (ACPI_FAILURE(status)) {
device_printf(dev, "can't evaluate _GPE - %s\n",
AcpiFormatException(status));
goto out;
}
obj = (ACPI_OBJECT *)buf.Pointer;
if (obj == NULL)
goto out;
switch (obj->Type) {
case ACPI_TYPE_INTEGER:
params->gpe_handle = NULL;
params->gpe_bit = obj->Integer.Value;
break;
case ACPI_TYPE_PACKAGE:
if (!ACPI_PKG_VALID(obj, 2))
goto out;
params->gpe_handle =
acpi_GetReference(NULL, &obj->Package.Elements[0]);
if (params->gpe_handle == NULL ||
acpi_PkgInt32(obj, 1, ¶ms->gpe_bit) != 0)
goto out;
break;
default:
device_printf(dev, "_GPE has invalid type %d\n", obj->Type);
goto out;
}
/* Store the values we got from the namespace for attach. */
acpi_set_private(dev, params);
/*
* Check for a duplicate probe. This can happen when a probe
* via ECDT succeeded already. If this is a duplicate, disable
* this device.
*/
peer = devclass_get_device(acpi_ec_devclass, params->uid);
if (peer == NULL || !device_is_alive(peer))
ret = 0;
else
device_disable(dev);
}
out:
if (ret == 0) {
ksnprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",
params->gpe_bit, (params->glk) ? ", GLK" : "",
ecdt ? ", ECDT" : "");
device_set_desc_copy(dev, desc);
}
if (ret > 0 && params)
kfree(params, M_TEMP);
if (buf.Pointer)
AcpiOsFree(buf.Pointer);
return (ret);
}
示例8: aibs_sysctl
static int
aibs_sysctl(SYSCTL_HANDLER_ARGS)
{
struct aibs_softc *sc = arg1;
enum aibs_type st = arg2;
int i = oidp->oid_number;
ACPI_STATUS rs;
ACPI_OBJECT p, *bp;
ACPI_OBJECT_LIST mp;
ACPI_BUFFER b;
char *name;
struct aibs_sensor *as;
ACPI_INTEGER v, l, h;
int so[3];
switch (st) {
case AIBS_VOLT:
name = "RVLT";
as = sc->sc_asens_volt;
break;
case AIBS_TEMP:
name = "RTMP";
as = sc->sc_asens_temp;
break;
case AIBS_FAN:
name = "RFAN";
as = sc->sc_asens_fan;
break;
default:
return ENOENT;
}
if (as == NULL)
return ENOENT;
l = as[i].l;
h = as[i].h;
p.Type = ACPI_TYPE_INTEGER;
p.Integer.Value = as[i].i;
mp.Count = 1;
mp.Pointer = &p;
b.Length = ACPI_ALLOCATE_BUFFER;
ACPI_SERIAL_BEGIN(aibs);
rs = AcpiEvaluateObjectTyped(sc->sc_ah, name, &mp, &b,
ACPI_TYPE_INTEGER);
if (ACPI_FAILURE(rs)) {
ddevice_printf(sc->sc_dev,
"%s: %i: evaluation failed\n",
name, i);
ACPI_SERIAL_END(aibs);
return EIO;
}
bp = b.Pointer;
v = bp->Integer.Value;
AcpiOsFree(b.Pointer);
ACPI_SERIAL_END(aibs);
switch (st) {
case AIBS_VOLT:
break;
case AIBS_TEMP:
v += 2731;
l += 2731;
h += 2731;
break;
case AIBS_FAN:
break;
}
so[0] = v;
so[1] = l;
so[2] = h;
return sysctl_handle_opaque(oidp, &so, sizeof(so), req);
}
示例9: AcpiDbReadFromObject
static ACPI_STATUS
AcpiDbReadFromObject (
ACPI_NAMESPACE_NODE *Node,
ACPI_OBJECT_TYPE ExpectedType,
ACPI_OBJECT **Value)
{
ACPI_OBJECT *RetValue;
ACPI_OBJECT_LIST ParamObjects;
ACPI_OBJECT Params[2];
ACPI_BUFFER ReturnObj;
ACPI_STATUS Status;
Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
Params[0].Reference.ActualType = Node->Type;
Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
ParamObjects.Count = 1;
ParamObjects.Pointer = Params;
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
AcpiGbl_MethodExecuting = TRUE;
Status = AcpiEvaluateObject (ReadHandle, NULL,
&ParamObjects, &ReturnObj);
AcpiGbl_MethodExecuting = FALSE;
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not read from object, %s",
AcpiFormatException (Status));
return (Status);
}
RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
switch (RetValue->Type)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_STRING:
/*
* Did we receive the type we wanted? Most important for the
* Integer/Buffer case (when a field is larger than an Integer,
* it should return a Buffer).
*/
if (RetValue->Type != ExpectedType)
{
AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
AcpiUtGetTypeName (ExpectedType),
AcpiUtGetTypeName (RetValue->Type));
return (AE_TYPE);
}
*Value = RetValue;
break;
default:
AcpiOsPrintf (" Unsupported return object type, %s",
AcpiUtGetTypeName (RetValue->Type));
AcpiOsFree (ReturnObj.Pointer);
return (AE_TYPE);
}
return (Status);
}
示例10: AcpiDbTestStringType
static ACPI_STATUS
AcpiDbTestStringType (
ACPI_NAMESPACE_NODE *Node,
UINT32 ByteLength)
{
ACPI_OBJECT *Temp1 = NULL;
ACPI_OBJECT *Temp2 = NULL;
ACPI_OBJECT *Temp3 = NULL;
char *ValueToWrite = "Test String from AML Debugger";
ACPI_OBJECT WriteValue;
ACPI_STATUS Status;
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
Temp1->String.Length, Temp1->String.Pointer);
/* Write a new value */
WriteValue.Type = ACPI_TYPE_STRING;
WriteValue.String.Length = strlen (ValueToWrite);
WriteValue.String.Pointer = ValueToWrite;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (strcmp (Temp2->String.Pointer, ValueToWrite))
{
AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
Temp2->String.Pointer, ValueToWrite);
}
/* Write back the original value */
WriteValue.String.Length = strlen (Temp1->String.Pointer);
WriteValue.String.Pointer = Temp1->String.Pointer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
{
AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
Temp3->String.Pointer, Temp1->String.Pointer);
}
Exit:
if (Temp1) {AcpiOsFree (Temp1);}
if (Temp2) {AcpiOsFree (Temp2);}
if (Temp3) {AcpiOsFree (Temp3);}
return (Status);
}
示例11: AcpiDbTestBufferType
//.........這裏部分代碼省略.........
{
AcpiOsPrintf (" Ignoring zero length buffer");
return (AE_OK);
}
/* Allocate a local buffer */
Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
if (!Buffer)
{
return (AE_NO_MEMORY);
}
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Emit a few bytes of the buffer */
AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
for (i = 0; ((i < 4) && (i < ByteLength)); i++)
{
AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
}
AcpiOsPrintf ("... ");
/*
* Write a new value.
*
* Handle possible extra bits at the end of the buffer. Can
* happen for FieldUnits larger than an integer, but the bit
* count is not an integral number of bytes. Zero out the
* unused bits.
*/
memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
ExtraBits = BitLength % 8;
if (ExtraBits)
{
Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
}
WriteValue.Type = ACPI_TYPE_BUFFER;
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Buffer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 2: New buffer value");
}
/* Write back the original value */
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (memcmp (Temp1->Buffer.Pointer,
Temp3->Buffer.Pointer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
}
Exit:
ACPI_FREE (Buffer);
if (Temp1) {AcpiOsFree (Temp1);}
if (Temp2) {AcpiOsFree (Temp2);}
if (Temp3) {AcpiOsFree (Temp3);}
return (Status);
}
示例12: AcpiDbTestIntegerType
static ACPI_STATUS
AcpiDbTestIntegerType (
ACPI_NAMESPACE_NODE *Node,
UINT32 BitLength)
{
ACPI_OBJECT *Temp1 = NULL;
ACPI_OBJECT *Temp2 = NULL;
ACPI_OBJECT *Temp3 = NULL;
ACPI_OBJECT WriteValue;
UINT64 ValueToWrite;
ACPI_STATUS Status;
if (BitLength > 64)
{
AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
return (AE_OK);
}
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
if (Temp1->Integer.Value == ValueToWrite)
{
ValueToWrite = 0;
}
/* Write a new value */
WriteValue.Type = ACPI_TYPE_INTEGER;
WriteValue.Integer.Value = ValueToWrite;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (Temp2->Integer.Value != ValueToWrite)
{
AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
ACPI_FORMAT_UINT64 (ValueToWrite));
}
/* Write back the original value */
WriteValue.Integer.Value = Temp1->Integer.Value;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (Temp3->Integer.Value != Temp1->Integer.Value)
{
AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
}
Exit:
if (Temp1) {AcpiOsFree (Temp1);}
if (Temp2) {AcpiOsFree (Temp2);}
if (Temp3) {AcpiOsFree (Temp3);}
return (AE_OK);
}
示例13: acpi_tz_establish
/*
* Parse the current state of this thermal zone and set up to use it.
*
* Note that we may have previous state, which will have to be discarded.
*/
static int
acpi_tz_establish(struct acpi_tz_softc *sc)
{
ACPI_OBJECT *obj;
int i;
char nbuf[8];
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/* Erase any existing state. */
for (i = 0; i < TZ_NUMLEVELS; i++)
if (sc->tz_zone.al[i].Pointer != NULL)
AcpiOsFree(sc->tz_zone.al[i].Pointer);
if (sc->tz_zone.psl.Pointer != NULL)
AcpiOsFree(sc->tz_zone.psl.Pointer);
/*
* XXX: We initialize only ACPI_BUFFER to avoid race condition
* with passive cooling thread which refers psv, tc1, tc2 and tsp.
*/
bzero(sc->tz_zone.ac, sizeof(sc->tz_zone.ac));
bzero(sc->tz_zone.al, sizeof(sc->tz_zone.al));
bzero(&sc->tz_zone.psl, sizeof(sc->tz_zone.psl));
/* Evaluate thermal zone parameters. */
for (i = 0; i < TZ_NUMLEVELS; i++) {
sprintf(nbuf, "_AC%d", i);
acpi_tz_getparam(sc, nbuf, &sc->tz_zone.ac[i]);
sprintf(nbuf, "_AL%d", i);
sc->tz_zone.al[i].Length = ACPI_ALLOCATE_BUFFER;
sc->tz_zone.al[i].Pointer = NULL;
AcpiEvaluateObject(sc->tz_handle, nbuf, NULL, &sc->tz_zone.al[i]);
obj = (ACPI_OBJECT *)sc->tz_zone.al[i].Pointer;
if (obj != NULL) {
/* Should be a package containing a list of power objects */
if (obj->Type != ACPI_TYPE_PACKAGE) {
device_printf(sc->tz_dev, "%s has unknown type %d, rejecting\n",
nbuf, obj->Type);
return_VALUE (ENXIO);
}
}
}
acpi_tz_getparam(sc, "_CRT", &sc->tz_zone.crt);
acpi_tz_getparam(sc, "_HOT", &sc->tz_zone.hot);
sc->tz_zone.psl.Length = ACPI_ALLOCATE_BUFFER;
sc->tz_zone.psl.Pointer = NULL;
AcpiEvaluateObject(sc->tz_handle, "_PSL", NULL, &sc->tz_zone.psl);
acpi_tz_getparam(sc, "_PSV", &sc->tz_zone.psv);
acpi_tz_getparam(sc, "_TC1", &sc->tz_zone.tc1);
acpi_tz_getparam(sc, "_TC2", &sc->tz_zone.tc2);
acpi_tz_getparam(sc, "_TSP", &sc->tz_zone.tsp);
acpi_tz_getparam(sc, "_TZP", &sc->tz_zone.tzp);
/*
* Sanity-check the values we've been given.
*
* XXX what do we do about systems that give us the same value for
* more than one of these setpoints?
*/
acpi_tz_sanity(sc, &sc->tz_zone.crt, "_CRT");
acpi_tz_sanity(sc, &sc->tz_zone.hot, "_HOT");
acpi_tz_sanity(sc, &sc->tz_zone.psv, "_PSV");
for (i = 0; i < TZ_NUMLEVELS; i++)
acpi_tz_sanity(sc, &sc->tz_zone.ac[i], "_ACx");
return_VALUE (0);
}
示例14: AeMiscellaneousTests
//.........這裏部分代碼省略.........
*/
Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 0);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
AE_CHECK_OK (AcpiRemoveGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 0);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
AE_CHECK_OK (AcpiSetGpe, Status);
Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
AE_CHECK_OK (AcpiSetGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 1);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 2);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 0x19);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiInstallGpeHandler (NULL, 0x62, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
AE_CHECK_OK (AcpiInstallGpeHandler, Status);
Status = AcpiEnableGpe (NULL, 0x62);
AE_CHECK_OK (AcpiEnableGpe, Status);
Status = AcpiDisableGpe (NULL, 0x62);
AE_CHECK_OK (AcpiDisableGpe, Status);
AfInstallGpeBlock ();
Status = AcpiGetHandle (NULL, "RSRC", &Handle);
if (ACPI_SUCCESS (Status))
{
ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
if (ACPI_SUCCESS (Status))
{
AcpiOsFree (ReturnBuf.Pointer);
}
}
/* Test global lock */
Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
Status = AcpiReleaseGlobalLock (LockHandle1);
AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
Status = AcpiReleaseGlobalLock (LockHandle2);
AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
/* Get Devices */
Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
AE_CHECK_OK (AcpiGetDevices, Status);
Status = AcpiGetStatistics (&Stats);
AE_CHECK_OK (AcpiGetStatistics, Status);
}
示例15: OsGetTable
//.........這裏部分代碼省略.........
/*
* Somewhere along the way, MS changed the registry entry for
* the FADT from
* HARDWARE/ACPI/FACP to
* HARDWARE/ACPI/FADT.
*
* This code allows for both.
*/
if (ACPI_COMPARE_NAME (Signature, "FACP"))
{
Signature = "FADT";
}
else
{
AcpiOsPrintf ("Could not find %s in registry at %s\n",
Signature, KeyBuffer);
return (NULL);
}
}
else
{
break;
}
}
/* Actual data for table is down a couple levels */
for (i = 0; ;)
{
Status = RegEnumKey (Handle, i, KeyBuffer, sizeof (KeyBuffer));
i += 1;
if (Status == ERROR_NO_MORE_ITEMS)
{
break;
}
Status = RegOpenKey (Handle, KeyBuffer, &SubKey);
if (Status != ERROR_SUCCESS)
{
AcpiOsPrintf ("Could not open %s entry\n", Signature);
return (NULL);
}
RegCloseKey (Handle);
Handle = SubKey;
i = 0;
}
/* Find the (binary) table entry */
for (i = 0; ;)
{
NameSize = sizeof (KeyBuffer);
Status = RegEnumValue (Handle, i, KeyBuffer, &NameSize,
NULL, &Type, NULL, 0);
if (Status != ERROR_SUCCESS)
{
AcpiOsPrintf ("Could not get %s registry entry\n", Signature);
return (NULL);
}
if (Type == REG_BINARY)
{
break;
}
i += 1;
}
/* Get the size of the table */
Status = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize);
if (Status != ERROR_SUCCESS)
{
AcpiOsPrintf ("Could not read the %s table size\n", Signature);
return (NULL);
}
/* Allocate a new buffer for the table */
ReturnTable = AcpiOsAllocate (DataSize);
if (!ReturnTable)
{
goto Cleanup;
}
/* Get the actual table from the registry */
Status = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
(UCHAR *) ReturnTable, &DataSize);
if (Status != ERROR_SUCCESS)
{
AcpiOsPrintf ("Could not read %s data\n", Signature);
AcpiOsFree (ReturnTable);
return (NULL);
}
Cleanup:
RegCloseKey (Handle);
return (ReturnTable);
}