本文整理匯總了C++中ACPI_ALLOCATE_ZEROED函數的典型用法代碼示例。如果您正苦於以下問題:C++ ACPI_ALLOCATE_ZEROED函數的具體用法?C++ ACPI_ALLOCATE_ZEROED怎麽用?C++ ACPI_ALLOCATE_ZEROED使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ACPI_ALLOCATE_ZEROED函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: acpi_evaluate_object
/*******************************************************************************
*
* FUNCTION: acpi_evaluate_object
*
* PARAMETERS: handle - Object handle (optional)
* pathname - Object pathname (optional)
* external_params - List of parameters to pass to method,
* terminated by NULL. May be NULL
* if no parameters are being passed.
* return_buffer - Where to put method's return value (if
* any). If NULL, no value is returned.
*
* RETURN: Status
*
* DESCRIPTION: Find and evaluate the given object, passing the given
* parameters if necessary. One of "Handle" or "Pathname" must
* be valid (non-null)
*
******************************************************************************/
acpi_status
acpi_evaluate_object(acpi_handle handle,
acpi_string pathname,
struct acpi_object_list *external_params,
struct acpi_buffer *return_buffer)
{
acpi_status status;
struct acpi_evaluate_info *info;
acpi_size buffer_space_needed;
u32 i;
ACPI_FUNCTION_TRACE(acpi_evaluate_object);
/* Allocate and initialize the evaluation information block */
info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
if (!info) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Convert and validate the device handle */
info->prefix_node = acpi_ns_validate_handle(handle);
if (!info->prefix_node) {
status = AE_BAD_PARAMETER;
goto cleanup;
}
/*
* Get the actual namespace node for the target object.
* Handles these cases:
*
* 1) Null node, valid pathname from root (absolute path)
* 2) Node and valid pathname (path relative to Node)
* 3) Node, Null pathname
*/
if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
/* The path is fully qualified, just evaluate by name */
info->prefix_node = NULL;
} else if (!handle) {
/*
* A handle is optional iff a fully qualified pathname is specified.
* Since we've already handled fully qualified names above, this is
* an error.
*/
if (!pathname) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Both Handle and Pathname are NULL"));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Null Handle with relative pathname [%s]",
pathname));
}
status = AE_BAD_PARAMETER;
goto cleanup;
}
info->relative_pathname = pathname;
/*
* Convert all external objects passed as arguments to the
* internal version(s).
*/
if (external_params && external_params->count) {
info->param_count = (u16)external_params->count;
/* Warn on impossible argument count */
if (info->param_count > ACPI_METHOD_NUM_ARGS) {
ACPI_WARN_PREDEFINED((AE_INFO, pathname,
ACPI_WARN_ALWAYS,
"Excess arguments (%u) - using only %u",
info->param_count,
ACPI_METHOD_NUM_ARGS));
info->param_count = ACPI_METHOD_NUM_ARGS;
}
//.........這裏部分代碼省略.........
示例2: acpi_ex_insert_into_field
acpi_status
acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
void *buffer, u32 buffer_length)
{
void *new_buffer;
acpi_status status;
u64 mask;
u64 width_mask;
u64 merged_datum;
u64 raw_datum = 0;
u32 field_offset = 0;
u32 buffer_offset = 0;
u32 buffer_tail_bits;
u32 datum_count;
u32 field_datum_count;
u32 access_bit_width;
u32 required_length;
u32 i;
ACPI_FUNCTION_TRACE(ex_insert_into_field);
/* Validate input buffer */
new_buffer = NULL;
required_length =
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
/*
* We must have a buffer that is at least as long as the field
* we are writing to. This is because individual fields are
* indivisible and partial writes are not supported -- as per
* the ACPI specification.
*/
if (buffer_length < required_length) {
/* We need to create a new buffer */
new_buffer = ACPI_ALLOCATE_ZEROED(required_length);
if (!new_buffer) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
/*
* Copy the original data to the new buffer, starting
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length);
buffer = new_buffer;
buffer_length = required_length;
}
/* TBD: Move to common setup code */
/* Algo is limited to sizeof(u64), so cut the access_byte_width */
if (obj_desc->common_field.access_byte_width > sizeof(u64)) {
obj_desc->common_field.access_byte_width = sizeof(u64);
}
access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width);
/*
* Create the bitmasks used for bit insertion.
* Note: This if/else is used to bypass compiler differences with the
* shift operator
*/
if (access_bit_width == ACPI_INTEGER_BIT_SIZE) {
width_mask = ACPI_UINT64_MAX;
} else {
width_mask = ACPI_MASK_BITS_ABOVE(access_bit_width);
}
mask = width_mask &
ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
/* Compute the number of datums (access width data items) */
datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
access_bit_width);
field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
obj_desc->common_field.
start_field_bit_offset,
access_bit_width);
/* Get initial Datum from the input buffer */
ACPI_MEMCPY(&raw_datum, buffer,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum =
raw_datum << obj_desc->common_field.start_field_bit_offset;
/* Write the entire field */
for (i = 1; i < field_datum_count; i++) {
/* Write merged datum to the target field */
merged_datum &= mask;
//.........這裏部分代碼省略.........
示例3: AcpiDmAddNodeToExternalList
void
AcpiDmAddNodeToExternalList (
ACPI_NAMESPACE_NODE *Node,
UINT8 Type,
UINT32 Value,
UINT16 Flags)
{
char *ExternalPath;
char *InternalPath;
char *Temp;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE (DmAddNodeToExternalList);
if (!Node)
{
return_VOID;
}
/* Get the full external and internal pathnames to the node */
ExternalPath = AcpiNsGetExternalPathname (Node);
if (!ExternalPath)
{
return_VOID;
}
Status = AcpiNsInternalizeName (ExternalPath, &InternalPath);
if (ACPI_FAILURE (Status))
{
ACPI_FREE (ExternalPath);
return_VOID;
}
/* Remove the root backslash */
if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1]))
{
Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1);
if (!Temp)
{
return_VOID;
}
strcpy (Temp, &ExternalPath[1]);
ACPI_FREE (ExternalPath);
ExternalPath = Temp;
}
/* Create the new External() declaration node */
Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, Type,
Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED));
if (ACPI_FAILURE (Status))
{
ACPI_FREE (ExternalPath);
ACPI_FREE (InternalPath);
}
return_VOID;
}
示例4: AcpiDecodePldBuffer
ACPI_STATUS
AcpiDecodePldBuffer (
UINT8 *InBuffer,
ACPI_SIZE Length,
ACPI_PLD_INFO **ReturnBuffer)
{
ACPI_PLD_INFO *PldInfo;
UINT32 *Buffer = ACPI_CAST_PTR (UINT32, InBuffer);
UINT32 Dword;
/* Parameter validation */
if (!InBuffer || !ReturnBuffer || (Length < 16))
{
return (AE_BAD_PARAMETER);
}
PldInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PLD_INFO));
if (!PldInfo)
{
return (AE_NO_MEMORY);
}
/* First 32-bit DWord */
ACPI_MOVE_32_TO_32 (&Dword, &Buffer[0]);
PldInfo->Revision = ACPI_PLD_GET_REVISION (&Dword);
PldInfo->IgnoreColor = ACPI_PLD_GET_IGNORE_COLOR (&Dword);
PldInfo->Color = ACPI_PLD_GET_COLOR (&Dword);
/* Second 32-bit DWord */
ACPI_MOVE_32_TO_32 (&Dword, &Buffer[1]);
PldInfo->Width = ACPI_PLD_GET_WIDTH (&Dword);
PldInfo->Height = ACPI_PLD_GET_HEIGHT(&Dword);
/* Third 32-bit DWord */
ACPI_MOVE_32_TO_32 (&Dword, &Buffer[2]);
PldInfo->UserVisible = ACPI_PLD_GET_USER_VISIBLE (&Dword);
PldInfo->Dock = ACPI_PLD_GET_DOCK (&Dword);
PldInfo->Lid = ACPI_PLD_GET_LID (&Dword);
PldInfo->Panel = ACPI_PLD_GET_PANEL (&Dword);
PldInfo->VerticalPosition = ACPI_PLD_GET_VERTICAL (&Dword);
PldInfo->HorizontalPosition = ACPI_PLD_GET_HORIZONTAL (&Dword);
PldInfo->Shape = ACPI_PLD_GET_SHAPE (&Dword);
PldInfo->GroupOrientation = ACPI_PLD_GET_ORIENTATION (&Dword);
PldInfo->GroupToken = ACPI_PLD_GET_TOKEN (&Dword);
PldInfo->GroupPosition = ACPI_PLD_GET_POSITION (&Dword);
PldInfo->Bay = ACPI_PLD_GET_BAY (&Dword);
/* Fourth 32-bit DWord */
ACPI_MOVE_32_TO_32 (&Dword, &Buffer[3]);
PldInfo->Ejectable = ACPI_PLD_GET_EJECTABLE (&Dword);
PldInfo->OspmEjectRequired = ACPI_PLD_GET_OSPM_EJECT (&Dword);
PldInfo->CabinetNumber = ACPI_PLD_GET_CABINET (&Dword);
PldInfo->CardCageNumber = ACPI_PLD_GET_CARD_CAGE (&Dword);
PldInfo->Reference = ACPI_PLD_GET_REFERENCE (&Dword);
PldInfo->Rotation = ACPI_PLD_GET_ROTATION (&Dword);
PldInfo->Order = ACPI_PLD_GET_ORDER (&Dword);
if (Length >= ACPI_PLD_BUFFER_SIZE)
{
/* Fifth 32-bit DWord (Revision 2 of _PLD) */
ACPI_MOVE_32_TO_32 (&Dword, &Buffer[4]);
PldInfo->VerticalOffset = ACPI_PLD_GET_VERT_OFFSET (&Dword);
PldInfo->HorizontalOffset = ACPI_PLD_GET_HORIZ_OFFSET (&Dword);
}
*ReturnBuffer = PldInfo;
return (AE_OK);
}
示例5: AcpiEvGetGpeXruptBlock
static ACPI_GPE_XRUPT_INFO *
AcpiEvGetGpeXruptBlock (
UINT32 InterruptNumber)
{
ACPI_GPE_XRUPT_INFO *NextGpeXrupt;
ACPI_GPE_XRUPT_INFO *GpeXrupt;
ACPI_STATUS Status;
ACPI_CPU_FLAGS Flags;
ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock);
/* No need for lock since we are not changing any list elements here */
NextGpeXrupt = AcpiGbl_GpeXruptListHead;
while (NextGpeXrupt)
{
if (NextGpeXrupt->InterruptNumber == InterruptNumber)
{
return_PTR (NextGpeXrupt);
}
NextGpeXrupt = NextGpeXrupt->Next;
}
/* Not found, must allocate a new xrupt descriptor */
GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO));
if (!GpeXrupt)
{
return_PTR (NULL);
}
GpeXrupt->InterruptNumber = InterruptNumber;
/* Install new interrupt descriptor with spin lock */
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
if (AcpiGbl_GpeXruptListHead)
{
NextGpeXrupt = AcpiGbl_GpeXruptListHead;
while (NextGpeXrupt->Next)
{
NextGpeXrupt = NextGpeXrupt->Next;
}
NextGpeXrupt->Next = GpeXrupt;
GpeXrupt->Previous = NextGpeXrupt;
}
else
{
AcpiGbl_GpeXruptListHead = GpeXrupt;
}
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
/* Install new interrupt handler if not SCI_INT */
if (InterruptNumber != AcpiGbl_FADT.SciInterrupt)
{
Status = AcpiOsInstallInterruptHandler (InterruptNumber,
AcpiEvGpeXruptHandler, GpeXrupt);
if (ACPI_FAILURE (Status))
{
ACPI_ERROR ((AE_INFO,
"Could not install GPE interrupt handler at level 0x%X",
InterruptNumber));
return_PTR (NULL);
}
}
return_PTR (GpeXrupt);
}
示例6: AcpiGetTagPathname
static char *
AcpiGetTagPathname (
ACPI_PARSE_OBJECT *IndexOp,
ACPI_NAMESPACE_NODE *BufferNode,
ACPI_NAMESPACE_NODE *ResourceNode,
UINT32 BitIndex)
{
ACPI_STATUS Status;
UINT32 ResourceBitIndex;
UINT8 ResourceTableIndex;
ACPI_SIZE RequiredSize;
char *Pathname;
AML_RESOURCE *Aml;
ACPI_PARSE_OBJECT *Op;
char *InternalPath;
char *Tag;
/* Get the Op that contains the actual buffer data */
Op = BufferNode->Op->Common.Value.Arg;
Op = Op->Common.Next;
if (!Op)
{
return (NULL);
}
/* Get the individual resource descriptor and validate it */
Aml = ACPI_CAST_PTR (AML_RESOURCE,
&Op->Named.Data[ResourceNode->Value]);
Status = AcpiUtValidateResource (NULL, Aml, &ResourceTableIndex);
if (ACPI_FAILURE (Status))
{
return (NULL);
}
/* Get offset into this descriptor (from offset into entire buffer) */
ResourceBitIndex = BitIndex - ACPI_MUL_8 (ResourceNode->Value);
/* Get the tag associated with this resource descriptor and offset */
Tag = AcpiDmGetResourceTag (ResourceBitIndex, Aml, ResourceTableIndex);
if (!Tag)
{
return (NULL);
}
/*
* Now that we know that we have a reference that can be converted to a
* symbol, change the name of the resource to a unique name.
*/
AcpiDmUpdateResourceName (ResourceNode);
/* Get the full pathname to the parent buffer */
RequiredSize = AcpiNsGetPathnameLength (BufferNode);
if (!RequiredSize)
{
return (NULL);
}
Pathname = ACPI_ALLOCATE_ZEROED (RequiredSize + ACPI_PATH_SEGMENT_LENGTH);
if (!Pathname)
{
return (NULL);
}
Status = AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname);
if (ACPI_FAILURE (Status))
{
ACPI_FREE (Pathname);
return (NULL);
}
/*
* Create the full path to the resource and tag by: remove the buffer name,
* append the resource descriptor name, append a dot, append the tag name.
*
* TBD: Always using the full path is a bit brute force, the path can be
* often be optimized with carats (if the original buffer namepath is a
* single nameseg). This doesn't really matter, because these paths do not
* end up in the final compiled AML, it's just an appearance issue for the
* disassembled code.
*/
Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0;
ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
ACPI_STRCAT (Pathname, ".");
ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE);
/* Internalize the namepath to AML format */
AcpiNsInternalizeName (Pathname, &InternalPath);
ACPI_FREE (Pathname);
/* Update the Op with the symbol */
AcpiPsInitOp (IndexOp, AML_INT_NAMEPATH_OP);
//.........這裏部分代碼省略.........
示例7: acpi_install_gpe_handler
/*******************************************************************************
*
* FUNCTION: acpi_install_gpe_handler
*
* PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
* defined GPEs)
* gpe_number - The GPE number within the GPE block
* Type - Whether this GPE should be treated as an
* edge- or level-triggered interrupt.
* Address - Address of the handler
* Context - Value passed to the handler on each GPE
*
* RETURN: Status
*
* DESCRIPTION: Install a handler for a General Purpose Event.
*
******************************************************************************/
acpi_status
acpi_install_gpe_handler(acpi_handle gpe_device,
u32 gpe_number,
u32 type, acpi_event_handler address, void *context)
{
struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler;
acpi_status status;
acpi_cpu_flags flags;
ACPI_FUNCTION_TRACE(acpi_install_gpe_handler);
/* Parameter validation */
if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
status = AE_BAD_PARAMETER;
goto exit;
}
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
goto exit;
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
/* Make sure that there isn't a handler there already */
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_HANDLER) {
status = AE_ALREADY_EXISTS;
goto unlock_and_exit;
}
/* Allocate and init handler object */
handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
if (!handler) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
handler->address = address;
handler->context = context;
handler->method_node = gpe_event_info->dispatch.method_node;
/* Disable the GPE before installing the handler */
status = acpi_ev_disable_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Install the handler */
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
gpe_event_info->dispatch.handler = handler;
/* Setup up dispatch flags to indicate handler (vs. method) */
gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
exit:
if (ACPI_FAILURE(status))
ACPI_EXCEPTION((AE_INFO, status,
"Installing notify handler failed"));
return_ACPI_STATUS(status);
}
示例8: AcpiUtCopyEsimpleToIsimple
static ACPI_STATUS
AcpiUtCopyEsimpleToIsimple (
ACPI_OBJECT *ExternalObject,
ACPI_OPERAND_OBJECT **RetInternalObject)
{
ACPI_OPERAND_OBJECT *InternalObject;
ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple);
/*
* Simple types supported are: String, Buffer, Integer
*/
switch (ExternalObject->Type)
{
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_LOCAL_REFERENCE:
InternalObject = AcpiUtCreateInternalObject (
(UINT8) ExternalObject->Type);
if (!InternalObject)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
break;
case ACPI_TYPE_ANY: /* This is the case for a NULL object */
*RetInternalObject = NULL;
return_ACPI_STATUS (AE_OK);
default:
/* All other types are not supported */
ACPI_ERROR ((AE_INFO,
"Unsupported object type, cannot convert to internal object: %s",
AcpiUtGetTypeName (ExternalObject->Type)));
return_ACPI_STATUS (AE_SUPPORT);
}
/* Must COPY string and buffer contents */
switch (ExternalObject->Type)
{
case ACPI_TYPE_STRING:
InternalObject->String.Pointer =
ACPI_ALLOCATE_ZEROED ((ACPI_SIZE)
ExternalObject->String.Length + 1);
if (!InternalObject->String.Pointer)
{
goto ErrorExit;
}
ACPI_MEMCPY (InternalObject->String.Pointer,
ExternalObject->String.Pointer,
ExternalObject->String.Length);
InternalObject->String.Length = ExternalObject->String.Length;
break;
case ACPI_TYPE_BUFFER:
InternalObject->Buffer.Pointer =
ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length);
if (!InternalObject->Buffer.Pointer)
{
goto ErrorExit;
}
ACPI_MEMCPY (InternalObject->Buffer.Pointer,
ExternalObject->Buffer.Pointer,
ExternalObject->Buffer.Length);
InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
/* Mark buffer data valid */
InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID;
break;
case ACPI_TYPE_INTEGER:
InternalObject->Integer.Value = ExternalObject->Integer.Value;
break;
case ACPI_TYPE_LOCAL_REFERENCE:
/* TBD: should validate incoming handle */
InternalObject->Reference.Class = ACPI_REFCLASS_NAME;
InternalObject->Reference.Node = ExternalObject->Reference.Handle;
//.........這裏部分代碼省略.........
示例9: AcpiDsCallControlMethod
ACPI_STATUS
AcpiDsCallControlMethod (
ACPI_THREAD_STATE *Thread,
ACPI_WALK_STATE *ThisWalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *MethodNode;
ACPI_WALK_STATE *NextWalkState = NULL;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_EVALUATE_INFO *Info;
UINT32 i;
ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Calling method %p, currentstate=%p\n",
ThisWalkState->PrevOp, ThisWalkState));
/*
* Get the namespace entry for the control method we are about to call
*/
MethodNode = ThisWalkState->MethodCallNode;
if (!MethodNode)
{
return_ACPI_STATUS (AE_NULL_ENTRY);
}
ObjDesc = AcpiNsGetAttachedObject (MethodNode);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NULL_OBJECT);
}
/* Init for new method, possibly wait on method mutex */
Status = AcpiDsBeginMethodExecution (
MethodNode, ObjDesc, ThisWalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Begin method parse/execution. Create a new walk state */
NextWalkState = AcpiDsCreateWalkState (
ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread);
if (!NextWalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
/*
* The resolved arguments were put on the previous walk state's operand
* stack. Operands on the previous walk state stack always
* start at index 0. Also, null terminate the list of arguments
*/
ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
/*
* Allocate and initialize the evaluation information block
* TBD: this is somewhat inefficient, should change interface to
* DsInitAmlWalk. For now, keeps this struct off the CPU stack
*/
Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
if (!Info)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
Info->Parameters = &ThisWalkState->Operands[0];
Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
Info, ACPI_IMODE_EXECUTE);
ACPI_FREE (Info);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/*
* Delete the operands on the previous walkstate operand stack
* (they were copied to new objects)
*/
for (i = 0; i < ObjDesc->Method.ParamCount; i++)
{
AcpiUtRemoveReference (ThisWalkState->Operands [i]);
ThisWalkState->Operands [i] = NULL;
}
/* Clear the operand stack */
ThisWalkState->NumOperands = 0;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
//.........這裏部分代碼省略.........
示例10: acpi_ev_create_gpe_block
acpi_status
acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
struct acpi_generic_address *gpe_block_address,
u32 register_count,
u8 gpe_block_base_number,
u32 interrupt_number,
struct acpi_gpe_block_info **return_gpe_block)
{
acpi_status status;
struct acpi_gpe_block_info *gpe_block;
struct acpi_gpe_walk_info walk_info;
ACPI_FUNCTION_TRACE(ev_create_gpe_block);
if (!register_count) {
return_ACPI_STATUS(AE_OK);
}
/* Allocate a new GPE block */
gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info));
if (!gpe_block) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize the new GPE block */
gpe_block->node = gpe_device;
gpe_block->gpe_count = (u16)(register_count * ACPI_GPE_REGISTER_WIDTH);
gpe_block->initialized = FALSE;
gpe_block->register_count = register_count;
gpe_block->block_base_number = gpe_block_base_number;
ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
sizeof(struct acpi_generic_address));
/*
* Create the register_info and event_info sub-structures
* Note: disables and clears all GPEs in the block
*/
status = acpi_ev_create_gpe_info_blocks(gpe_block);
if (ACPI_FAILURE(status)) {
ACPI_FREE(gpe_block);
return_ACPI_STATUS(status);
}
/* Install the new block in the global lists */
status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
if (ACPI_FAILURE(status)) {
ACPI_FREE(gpe_block->register_info);
ACPI_FREE(gpe_block->event_info);
ACPI_FREE(gpe_block);
return_ACPI_STATUS(status);
}
acpi_gbl_all_gpes_initialized = FALSE;
/* Find all GPE methods (_Lxx or_Exx) for this block */
walk_info.gpe_block = gpe_block;
walk_info.gpe_device = gpe_device;
walk_info.execute_by_owner_id = FALSE;
status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
acpi_ev_match_gpe_method, NULL,
&walk_info, NULL);
/* Return the new block */
if (return_gpe_block) {
(*return_gpe_block) = gpe_block;
}
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
" Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X\n",
(u32)gpe_block->block_base_number,
(u32)(gpe_block->block_base_number +
(gpe_block->gpe_count - 1)),
gpe_device->name.ascii, gpe_block->register_count,
interrupt_number));
/* Update global count of currently available GPEs */
acpi_current_gpe_count += gpe_block->gpe_count;
return_ACPI_STATUS(AE_OK);
}
示例11: acpi_ns_initialize_devices
acpi_status acpi_ns_initialize_devices(void)
{
acpi_status status;
struct acpi_device_walk_info info;
ACPI_FUNCTION_TRACE(ns_initialize_devices);
/* Init counters */
info.device_count = 0;
info.num_STA = 0;
info.num_INI = 0;
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"Initializing Device/Processor/Thermal objects "
"by executing _INI methods:"));
/* Tree analysis: find all subtrees that contain _INI methods */
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE,
acpi_ns_find_ini_methods, NULL, &info,
NULL);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
/* Allocate the evaluation information block */
info.evaluate_info =
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
if (!info.evaluate_info) {
status = AE_NO_MEMORY;
goto error_exit;
}
/*
* Execute the "global" _INI method that may appear at the root. This
* support is provided for Windows compatibility (Vista+) and is not
* part of the ACPI specification.
*/
info.evaluate_info->prefix_node = acpi_gbl_root_node;
info.evaluate_info->pathname = METHOD_NAME__INI;
info.evaluate_info->parameters = NULL;
info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE;
status = acpi_ns_evaluate(info.evaluate_info);
if (ACPI_SUCCESS(status)) {
info.num_INI++;
}
/* Walk namespace to execute all _INIs on present devices */
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE,
acpi_ns_init_one_device, NULL, &info,
NULL);
/*
* Any _OSI requests should be completed by now. If the BIOS has
* requested any Windows OSI strings, we will always truncate
* I/O addresses to 16 bits -- for Windows compatibility.
*/
if (acpi_gbl_osi_data >= ACPI_OSI_WIN_2000) {
acpi_gbl_truncate_io_addresses = TRUE;
}
ACPI_FREE(info.evaluate_info);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"\nExecuted %u _INI methods requiring %u _STA executions "
"(examined %u objects)\n",
info.num_INI, info.num_STA, info.device_count));
return_ACPI_STATUS(status);
error_exit:
ACPI_EXCEPTION((AE_INFO, status, "During device initialization"));
return_ACPI_STATUS(status);
}
示例12: acpi_ev_create_gpe_info_blocks
static acpi_status
acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
{
struct acpi_gpe_register_info *gpe_register_info = NULL;
struct acpi_gpe_event_info *gpe_event_info = NULL;
struct acpi_gpe_event_info *this_event;
struct acpi_gpe_register_info *this_register;
u32 i;
u32 j;
acpi_status status;
ACPI_FUNCTION_TRACE(ev_create_gpe_info_blocks);
/* Allocate the GPE register information block */
gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->
register_count *
sizeof(struct
acpi_gpe_register_info));
if (!gpe_register_info) {
ACPI_ERROR((AE_INFO,
"Could not allocate the GpeRegisterInfo table"));
return_ACPI_STATUS(AE_NO_MEMORY);
}
/*
* Allocate the GPE event_info block. There are eight distinct GPEs
* per register. Initialization to zeros is sufficient.
*/
gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->gpe_count *
sizeof(struct
acpi_gpe_event_info));
if (!gpe_event_info) {
ACPI_ERROR((AE_INFO,
"Could not allocate the GpeEventInfo table"));
status = AE_NO_MEMORY;
goto error_exit;
}
/* Save the new Info arrays in the GPE block */
gpe_block->register_info = gpe_register_info;
gpe_block->event_info = gpe_event_info;
/*
* Initialize the GPE Register and Event structures. A goal of these
* tables is to hide the fact that there are two separate GPE register
* sets in a given GPE hardware block, the status registers occupy the
* first half, and the enable registers occupy the second half.
*/
this_register = gpe_register_info;
this_event = gpe_event_info;
for (i = 0; i < gpe_block->register_count; i++) {
/* Init the register_info for this GPE register (8 GPEs) */
this_register->base_gpe_number =
(u8) (gpe_block->block_base_number +
(i * ACPI_GPE_REGISTER_WIDTH));
this_register->status_address.address =
gpe_block->block_address.address + i;
this_register->enable_address.address =
gpe_block->block_address.address + i +
gpe_block->register_count;
this_register->status_address.space_id =
gpe_block->block_address.space_id;
this_register->enable_address.space_id =
gpe_block->block_address.space_id;
this_register->status_address.bit_width =
ACPI_GPE_REGISTER_WIDTH;
this_register->enable_address.bit_width =
ACPI_GPE_REGISTER_WIDTH;
this_register->status_address.bit_offset = 0;
this_register->enable_address.bit_offset = 0;
/* Init the event_info for each GPE within this register */
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
this_event->gpe_number =
(u8) (this_register->base_gpe_number + j);
this_event->register_info = this_register;
this_event++;
}
/* Disable all GPEs within this register */
status = acpi_hw_write(0x00, &this_register->enable_address);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
/* Clear any pending GPE events within this register */
status = acpi_hw_write(0xFF, &this_register->status_address);
if (ACPI_FAILURE(status)) {
goto error_exit;
//.........這裏部分代碼省略.........
示例13: AcpiUtInitializeBuffer
ACPI_STATUS
AcpiUtInitializeBuffer (
ACPI_BUFFER *Buffer,
ACPI_SIZE RequiredLength)
{
ACPI_STATUS Status = AE_OK;
switch (Buffer->Length)
{
case ACPI_NO_BUFFER:
/* Set the exception and returned the required length */
Status = AE_BUFFER_OVERFLOW;
break;
case ACPI_ALLOCATE_BUFFER:
/* Allocate a new buffer */
Buffer->Pointer = AcpiOsAllocate (RequiredLength);
if (!Buffer->Pointer)
{
return (AE_NO_MEMORY);
}
/* Clear the buffer */
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
break;
case ACPI_ALLOCATE_LOCAL_BUFFER:
/* Allocate a new buffer with local interface to allow tracking */
Buffer->Pointer = ACPI_ALLOCATE_ZEROED (RequiredLength);
if (!Buffer->Pointer)
{
return (AE_NO_MEMORY);
}
break;
default:
/* Existing buffer: Validate the size of the buffer */
if (Buffer->Length < RequiredLength)
{
Status = AE_BUFFER_OVERFLOW;
break;
}
/* Clear the buffer */
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
break;
}
Buffer->Length = RequiredLength;
return (Status);
}
示例14: AcpiEvExecuteRegMethod
ACPI_STATUS
AcpiEvExecuteRegMethod (
ACPI_OPERAND_OBJECT *RegionObj,
UINT32 Function)
{
ACPI_EVALUATE_INFO *Info;
ACPI_OPERAND_OBJECT *Args[3];
ACPI_OPERAND_OBJECT *RegionObj2;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE (EvExecuteRegMethod);
RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
if (!RegionObj2)
{
return_ACPI_STATUS (AE_NOT_EXIST);
}
if (RegionObj2->Extra.Method_REG == NULL)
{
return_ACPI_STATUS (AE_OK);
}
/* Allocate and initialize the evaluation information block */
Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
if (!Info)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Info->PrefixNode = RegionObj2->Extra.Method_REG;
Info->RelativePathname = NULL;
Info->Parameters = Args;
Info->Flags = ACPI_IGNORE_RETURN_VALUE;
/*
* The _REG method has two arguments:
*
* Arg0 - Integer:
* Operation region space ID Same value as RegionObj->Region.SpaceId
*
* Arg1 - Integer:
* connection status 1 for connecting the handler, 0 for disconnecting
* the handler (Passed as a parameter)
*/
Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId);
if (!Args[0])
{
Status = AE_NO_MEMORY;
goto Cleanup1;
}
Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function);
if (!Args[1])
{
Status = AE_NO_MEMORY;
goto Cleanup2;
}
Args[2] = NULL; /* Terminate list */
/* Execute the method, no return value */
ACPI_DEBUG_EXEC (
AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL));
Status = AcpiNsEvaluate (Info);
AcpiUtRemoveReference (Args[1]);
Cleanup2:
AcpiUtRemoveReference (Args[0]);
Cleanup1:
ACPI_FREE (Info);
return_ACPI_STATUS (Status);
}
示例15: AcpiSetupGpeForWake
ACPI_STATUS
AcpiSetupGpeForWake (
ACPI_HANDLE WakeDevice,
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber)
{
ACPI_STATUS Status;
ACPI_GPE_EVENT_INFO *GpeEventInfo;
ACPI_NAMESPACE_NODE *DeviceNode;
ACPI_GPE_NOTIFY_INFO *Notify;
ACPI_GPE_NOTIFY_INFO *NewNotify;
ACPI_CPU_FLAGS Flags;
ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
/* Parameter Validation */
if (!WakeDevice)
{
/*
* By forcing WakeDevice to be valid, we automatically enable the
* implicit notify feature on all hosts.
*/
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/* Handle root object case */
if (WakeDevice == ACPI_ROOT_OBJECT)
{
DeviceNode = AcpiGbl_RootNode;
}
else
{
DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
}
/* Validate WakeDevice is of type Device */
if (DeviceNode->Type != ACPI_TYPE_DEVICE)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* Allocate a new notify object up front, in case it is needed.
* Memory allocation while holding a spinlock is a big no-no
* on some hosts.
*/
NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
if (!NewNotify)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
/* Ensure that we have a valid GPE number */
GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
if (!GpeEventInfo)
{
Status = AE_BAD_PARAMETER;
goto UnlockAndExit;
}
/*
* If there is no method or handler for this GPE, then the
* WakeDevice will be notified whenever this GPE fires. This is
* known as an "implicit notify". Note: The GPE is assumed to be
* level-triggered (for windows compatibility).
*/
if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_NONE)
{
/*
* This is the first device for implicit notify on this GPE.
* Just set the flags here, and enter the NOTIFY block below.
*/
GpeEventInfo->Flags =
(ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
}
/*
* If we already have an implicit notify on this GPE, add
* this device to the notify list.
*/
if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_NOTIFY)
{
/* Ensure that the device is not already in the list */
Notify = GpeEventInfo->Dispatch.NotifyList;
while (Notify)
{
if (Notify->DeviceNode == DeviceNode)
{
Status = AE_ALREADY_EXISTS;
//.........這裏部分代碼省略.........