本文整理匯總了C++中ACPI_ALLOCATE函數的典型用法代碼示例。如果您正苦於以下問題:C++ ACPI_ALLOCATE函數的具體用法?C++ ACPI_ALLOCATE怎麽用?C++ ACPI_ALLOCATE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ACPI_ALLOCATE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: acpi_ut_add_address_range
/*******************************************************************************
*
* FUNCTION: acpi_ut_add_address_range
*
* PARAMETERS: space_id - Address space ID
* address - op_region start address
* length - op_region length
* region_node - op_region namespace node
*
* RETURN: Status
*
* DESCRIPTION: Add the Operation Region address range to the global list.
* The only supported Space IDs are Memory and I/O. Called when
* the op_region address/length operands are fully evaluated.
*
* MUTEX: Locks the namespace
*
* NOTE: Because this interface is only called when an op_region argument
* list is evaluated, there cannot be any duplicate region_nodes.
* Duplicate Address/Length values are allowed, however, so that multiple
* address conflicts can be detected.
*
******************************************************************************/
acpi_status
acpi_ut_add_address_range(acpi_adr_space_type space_id,
acpi_physical_address address,
u32 length, struct acpi_namespace_node *region_node)
{
struct acpi_address_range *range_info;
acpi_status status;
ACPI_FUNCTION_TRACE(ut_add_address_range);
if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
(space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
return_ACPI_STATUS(AE_OK);
}
/* Allocate/init a new info block, add it to the appropriate list */
range_info = ACPI_ALLOCATE(sizeof(struct acpi_address_range));
if (!range_info) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
range_info->start_address = address;
range_info->end_address = (address + length - 1);
range_info->region_node = region_node;
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
ACPI_FREE(range_info);
return_ACPI_STATUS(status);
}
range_info->next = acpi_gbl_address_range_list[space_id];
acpi_gbl_address_range_list[space_id] = range_info;
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"\nAdded [%4.4s] address range: 0x%p-0x%p\n",
acpi_ut_get_node_name(range_info->region_node),
ACPI_CAST_PTR(void, address),
ACPI_CAST_PTR(void, range_info->end_address)));
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(AE_OK);
}
示例2: acpi_hw_build_pci_list
static acpi_status
acpi_hw_build_pci_list(acpi_handle root_pci_device,
acpi_handle pci_region,
struct acpi_pci_device **return_list_head)
{
acpi_handle current_device;
acpi_handle parent_device;
acpi_status status;
struct acpi_pci_device *list_element;
struct acpi_pci_device *list_head = NULL;
/*
* Ascend namespace branch until the root_pci_device is reached, building
* a list of device nodes. Loop will exit when either the PCI device is
* found, or the root of the namespace is reached.
*/
current_device = pci_region;
while (1) {
status = acpi_get_parent(current_device, &parent_device);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */
if (parent_device == root_pci_device) {
*return_list_head = list_head;
return (AE_OK);
}
list_element = ACPI_ALLOCATE(sizeof(struct acpi_pci_device));
if (!list_element) {
return (AE_NO_MEMORY);
}
/* Put new element at the head of the list */
list_element->next = list_head;
list_element->device = parent_device;
list_head = list_element;
current_device = parent_device;
}
}
示例3: AcpiUtAddAddressRange
ACPI_STATUS
AcpiUtAddAddressRange (
ACPI_ADR_SPACE_TYPE SpaceId,
ACPI_PHYSICAL_ADDRESS Address,
UINT32 Length,
ACPI_NAMESPACE_NODE *RegionNode)
{
ACPI_ADDRESS_RANGE *RangeInfo;
ACPI_FUNCTION_TRACE (UtAddAddressRange);
if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
(SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
{
return_ACPI_STATUS (AE_OK);
}
/* Allocate/init a new info block, add it to the appropriate list */
RangeInfo = ACPI_ALLOCATE (sizeof (ACPI_ADDRESS_RANGE));
if (!RangeInfo)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
RangeInfo->StartAddress = Address;
RangeInfo->EndAddress = (Address + Length - 1);
RangeInfo->RegionNode = RegionNode;
RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId];
AcpiGbl_AddressRangeList[SpaceId] = RangeInfo;
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
"\nAdded [%4.4s] address range: 0x%8.8X%8.8X-0x%8.8X%8.8X\n",
AcpiUtGetNodeName (RangeInfo->RegionNode),
ACPI_FORMAT_UINT64 (Address),
ACPI_FORMAT_UINT64 (RangeInfo->EndAddress)));
return_ACPI_STATUS (AE_OK);
}
示例4: AcpiDmAddToExternalFileList
ACPI_STATUS
AcpiDmAddToExternalFileList (
char *Pathname)
{
ACPI_EXTERNAL_FILE *ExternalFile;
char *LocalPathname;
if (!Pathname)
{
return (AE_OK);
}
LocalPathname = ACPI_ALLOCATE (strlen (Pathname) + 1);
if (!LocalPathname)
{
return (AE_NO_MEMORY);
}
ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE));
if (!ExternalFile)
{
ACPI_FREE (LocalPathname);
return (AE_NO_MEMORY);
}
/* Take a copy of the file pathname */
strcpy (LocalPathname, Pathname);
ExternalFile->Path = LocalPathname;
if (AcpiGbl_ExternalFileList)
{
ExternalFile->Next = AcpiGbl_ExternalFileList;
}
AcpiGbl_ExternalFileList = ExternalFile;
return (AE_OK);
}
示例5: acpi_ut_add_address_range
/*******************************************************************************
*
* FUNCTION: acpi_ut_add_address_range
*
* PARAMETERS: space_id - Address space ID
* address - op_region start address
* length - op_region length
* region_node - op_region namespace node
*
* RETURN: Status
*
* DESCRIPTION: Add the Operation Region address range to the global list.
* The only supported Space IDs are Memory and I/O. Called when
* the op_region address/length operands are fully evaluated.
*
* MUTEX: Locks the namespace
*
* NOTE: Because this interface is only called when an op_region argument
* list is evaluated, there cannot be any duplicate region_nodes.
* Duplicate Address/Length values are allowed, however, so that multiple
* address conflicts can be detected.
*
******************************************************************************/
acpi_status
acpi_ut_add_address_range(acpi_adr_space_type space_id,
acpi_physical_address address,
u32 length, struct acpi_namespace_node *region_node)
{
struct acpi_address_range *range_info;
ACPI_FUNCTION_TRACE(ut_add_address_range);
if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
(space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
return_ACPI_STATUS(AE_OK);
}
/* Allocate/init a new info block, add it to the appropriate list */
range_info = ACPI_ALLOCATE(sizeof(struct acpi_address_range));
if (!range_info) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
range_info->start_address = address;
range_info->end_address = (address + length - 1);
range_info->region_node = region_node;
range_info->next = acpi_gbl_address_range_list[space_id];
acpi_gbl_address_range_list[space_id] = range_info;
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"\nAdded [%4.4s] address range: 0x%8.8X%8.8X-0x%8.8X%8.8X\n",
acpi_ut_get_node_name(range_info->region_node),
ACPI_FORMAT_UINT64(address),
ACPI_FORMAT_UINT64(range_info->end_address)));
return_ACPI_STATUS(AE_OK);
}
示例6: FlMergePathnames
char *
FlMergePathnames (
char *PrefixDir,
char *FilePathname)
{
char *CommonPath;
char *Pathname;
char *LastElement;
DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
"Include: FilePathname - \"%s\"\n",
PrefixDir, FilePathname);
/*
* If there is no prefix directory or if the file pathname is absolute,
* just return the original file pathname
*/
if (!PrefixDir || (!*PrefixDir) ||
(*FilePathname == '/') ||
(FilePathname[1] == ':'))
{
Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1);
strcpy (Pathname, FilePathname);
goto ConvertBackslashes;
}
/* Need a local copy of the prefix directory path */
CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1);
strcpy (CommonPath, PrefixDir);
/*
* Walk forward through the file path, and simultaneously backward
* through the prefix directory path until there are no more
* relative references at the start of the file path.
*/
while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
{
/* Remove last element of the prefix directory path */
LastElement = strrchr (CommonPath, '/');
if (!LastElement)
{
goto ConcatenatePaths;
}
*LastElement = 0; /* Terminate CommonPath string */
FilePathname += 3; /* Point to next path element */
}
/*
* Remove the last element of the prefix directory path (it is the same as
* the first element of the file pathname), and build the final merged
* pathname.
*/
LastElement = strrchr (CommonPath, '/');
if (LastElement)
{
*LastElement = 0;
}
/* Build the final merged pathname */
ConcatenatePaths:
Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2);
if (LastElement && *CommonPath)
{
strcpy (Pathname, CommonPath);
strcat (Pathname, "/");
}
strcat (Pathname, FilePathname);
ACPI_FREE (CommonPath);
/* Convert all backslashes to normal slashes */
ConvertBackslashes:
UtConvertBackslashes (Pathname);
DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
Pathname);
return (Pathname);
}
示例7: AcpiDbExecute
void
AcpiDbExecute (
char *Name,
char **Args,
UINT32 Flags)
{
ACPI_STATUS Status;
ACPI_BUFFER ReturnObj;
char *NameString;
#ifdef ACPI_DEBUG_OUTPUT
UINT32 PreviousAllocations;
UINT32 Allocations;
/* Memory allocation tracking */
PreviousAllocations = AcpiDbGetOutstandingAllocations ();
#endif
if (*Name == '*')
{
(void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL);
return;
}
else
{
NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1);
if (!NameString)
{
return;
}
ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
ACPI_STRCPY (NameString, Name);
AcpiUtStrupr (NameString);
AcpiGbl_DbMethodInfo.Name = NameString;
AcpiGbl_DbMethodInfo.Args = Args;
AcpiGbl_DbMethodInfo.Flags = Flags;
ReturnObj.Pointer = NULL;
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj);
ACPI_FREE (NameString);
}
/*
* Allow any handlers in separate threads to complete.
* (Such as Notify handlers invoked from AML executed above).
*/
AcpiOsSleep ((UINT64) 10);
#ifdef ACPI_DEBUG_OUTPUT
/* Memory allocation tracking */
Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations;
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
if (Allocations > 0)
{
AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n",
Allocations);
}
#endif
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Execution of %s failed with status %s\n",
AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status));
}
else
{
/* Display a return object, if any */
if (ReturnObj.Length)
{
AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer,
(UINT32) ReturnObj.Length);
AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
}
else
{
AcpiOsPrintf ("No return object from execution of %s\n",
AcpiGbl_DbMethodInfo.Pathname);
}
}
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
}
示例8: ACPI_FUNCTION_TRACE
static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
{
char *temp_ptr;
char *name_string;
u32 size_needed;
ACPI_FUNCTION_TRACE(ex_allocate_name_string);
/*
* Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
* Also, one byte for the null terminator.
* This may actually be somewhat longer than needed.
*/
if (prefix_count == ACPI_UINT32_MAX) {
/* Special case for root */
size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
} else {
size_needed =
prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
}
/*
* Allocate a buffer for the name.
* This buffer must be deleted by the caller!
*/
name_string = ACPI_ALLOCATE(size_needed);
if (!name_string) {
ACPI_ERROR((AE_INFO,
"Could not allocate size %u", size_needed));
return_PTR(NULL);
}
temp_ptr = name_string;
/* Set up Root or Parent prefixes if needed */
if (prefix_count == ACPI_UINT32_MAX) {
*temp_ptr++ = AML_ROOT_PREFIX;
} else {
while (prefix_count--) {
*temp_ptr++ = AML_PARENT_PREFIX;
}
}
/* Set up Dual or Multi prefixes if needed */
if (num_name_segs > 2) {
/* Set up multi prefixes */
*temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
*temp_ptr++ = (char)num_name_segs;
} else if (2 == num_name_segs) {
/* Set up dual prefixes */
*temp_ptr++ = AML_DUAL_NAME_PREFIX;
}
/*
* Terminate string following prefixes. acpi_ex_name_segment() will
* append the segment(s)
*/
*temp_ptr = 0;
return_PTR(name_string);
}
示例9: acpi_ut_initialize_buffer
acpi_status
acpi_ut_initialize_buffer(struct acpi_buffer *buffer, acpi_size required_length)
{
acpi_size input_buffer_length;
/* Parameter validation */
if (!buffer || !required_length) {
return (AE_BAD_PARAMETER);
}
/*
* Buffer->Length is used as both an input and output parameter. Get the
* input actual length and set the output required buffer length.
*/
input_buffer_length = buffer->length;
buffer->length = required_length;
/*
* The input buffer length contains the actual buffer length, or the type
* of buffer to be allocated by this routine.
*/
switch (input_buffer_length) {
case ACPI_NO_BUFFER:
/* Return the exception (and the required buffer length) */
return (AE_BUFFER_OVERFLOW);
case ACPI_ALLOCATE_BUFFER:
/*
* Allocate a new buffer. We directectly call acpi_os_allocate here to
* purposefully bypass the (optionally enabled) internal allocation
* tracking mechanism since we only want to track internal
* allocations. Note: The caller should use acpi_os_free to free this
* buffer created via ACPI_ALLOCATE_BUFFER.
*/
buffer->pointer = acpi_os_allocate(required_length);
break;
case ACPI_ALLOCATE_LOCAL_BUFFER:
/* Allocate a new buffer with local interface to allow tracking */
buffer->pointer = ACPI_ALLOCATE(required_length);
break;
default:
/* Existing buffer: Validate the size of the buffer */
if (input_buffer_length < required_length) {
return (AE_BUFFER_OVERFLOW);
}
break;
}
/* Validate allocation from above or input buffer pointer */
if (!buffer->pointer) {
return (AE_NO_MEMORY);
}
/* Have a valid buffer, clear it */
memset(buffer->pointer, 0, required_length);
return (AE_OK);
}
示例10: ACPI_FUNCTION_TRACE
static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
{
char *temp_ptr;
char *name_string;
u32 size_needed;
ACPI_FUNCTION_TRACE(ex_allocate_name_string);
/*
*/
if (prefix_count == ACPI_UINT32_MAX) {
/* */
size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
} else {
size_needed =
prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
}
/*
*/
name_string = ACPI_ALLOCATE(size_needed);
if (!name_string) {
ACPI_ERROR((AE_INFO,
"Could not allocate size %u", size_needed));
return_PTR(NULL);
}
temp_ptr = name_string;
/* */
if (prefix_count == ACPI_UINT32_MAX) {
*temp_ptr++ = AML_ROOT_PREFIX;
} else {
while (prefix_count--) {
*temp_ptr++ = AML_PARENT_PREFIX;
}
}
/* */
if (num_name_segs > 2) {
/* */
*temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
*temp_ptr++ = (char)num_name_segs;
} else if (2 == num_name_segs) {
/* */
*temp_ptr++ = AML_DUAL_NAME_PREFIX;
}
/*
*/
*temp_ptr = 0;
return_PTR(name_string);
}
示例11: acpi_ex_load_op
acpi_status
acpi_ex_load_op(union acpi_operand_object *obj_desc,
union acpi_operand_object *target,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *ddb_handle;
struct acpi_table_desc table_desc;
u32 table_index;
acpi_status status;
u32 length;
ACPI_FUNCTION_TRACE(ex_load_op);
ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
/* Source Object can be either an op_region or a Buffer/Field */
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_REGION:
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n",
obj_desc,
acpi_ut_get_object_type_name(obj_desc)));
/* Region must be system_memory (from ACPI spec) */
if (obj_desc->region.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
* If the Region Address and Length have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
status = acpi_ds_get_region_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/*
* We will simply map the memory region for the table. However, the
* memory region is technically not guaranteed to remain stable and
* we may eventually have to copy the table to a local buffer.
*/
table_desc.address = obj_desc->region.address;
table_desc.length = obj_desc->region.length;
table_desc.flags = ACPI_TABLE_ORIGIN_MAPPED;
break;
case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Load from Buffer or Field %p %s\n", obj_desc,
acpi_ut_get_object_type_name(obj_desc)));
length = obj_desc->buffer.length;
/* Must have at least an ACPI table header */
if (length < sizeof(struct acpi_table_header)) {
return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
}
/* Validate checksum here. It won't get validated in tb_add_table */
status =
acpi_tb_verify_checksum(ACPI_CAST_PTR
(struct acpi_table_header,
obj_desc->buffer.pointer), length);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* We need to copy the buffer since the original buffer could be
* changed or deleted in the future
*/
table_desc.pointer = ACPI_ALLOCATE(length);
if (!table_desc.pointer) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
ACPI_MEMCPY(table_desc.pointer, obj_desc->buffer.pointer,
length);
table_desc.length = length;
table_desc.flags = ACPI_TABLE_ORIGIN_ALLOCATED;
break;
default:
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
* Install the new table into the local data structures
*/
status = acpi_tb_add_table(&table_desc, &table_index);
if (ACPI_FAILURE(status)) {
goto cleanup;
//.........這裏部分代碼省略.........
示例12: acpi_ut_copy_simple_object
static acpi_status
acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc)
{
u16 reference_count;
union acpi_operand_object *next_object;
/* Save fields from destination that we don't want to overwrite */
reference_count = dest_desc->common.reference_count;
next_object = dest_desc->common.next_object;
/* Copy the entire source object over the destination object */
ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
sizeof(union acpi_operand_object));
/* Restore the saved fields */
dest_desc->common.reference_count = reference_count;
dest_desc->common.next_object = next_object;
/* New object is not static, regardless of source */
dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
/* Handle the objects with extra data */
switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
case ACPI_TYPE_BUFFER:
/*
* Allocate and copy the actual buffer if and only if:
* 1) There is a valid buffer pointer
* 2) The buffer has a length > 0
*/
if ((source_desc->buffer.pointer) &&
(source_desc->buffer.length)) {
dest_desc->buffer.pointer =
ACPI_ALLOCATE(source_desc->buffer.length);
if (!dest_desc->buffer.pointer) {
return (AE_NO_MEMORY);
}
/* Copy the actual buffer data */
ACPI_MEMCPY(dest_desc->buffer.pointer,
source_desc->buffer.pointer,
source_desc->buffer.length);
}
break;
case ACPI_TYPE_STRING:
/*
* Allocate and copy the actual string if and only if:
* 1) There is a valid string pointer
* (Pointer to a NULL string is allowed)
*/
if (source_desc->string.pointer) {
dest_desc->string.pointer =
ACPI_ALLOCATE((acpi_size) source_desc->string.
length + 1);
if (!dest_desc->string.pointer) {
return (AE_NO_MEMORY);
}
/* Copy the actual string data */
ACPI_MEMCPY(dest_desc->string.pointer,
source_desc->string.pointer,
(acpi_size) source_desc->string.length + 1);
}
break;
case ACPI_TYPE_LOCAL_REFERENCE:
/*
* We copied the reference object, so we now must add a reference
* to the object pointed to by the reference
*/
acpi_ut_add_reference(source_desc->reference.object);
break;
default:
/* Nothing to do for other simple objects */
break;
}
return (AE_OK);
}
示例13: AcpiInstallSciHandler
ACPI_STATUS
AcpiInstallSciHandler (
ACPI_SCI_HANDLER Address,
void *Context)
{
ACPI_SCI_HANDLER_INFO *NewSciHandler;
ACPI_SCI_HANDLER_INFO *SciHandler;
ACPI_CPU_FLAGS Flags;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE (AcpiInstallSciHandler);
if (!Address)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/* Allocate and init a handler object */
NewSciHandler = ACPI_ALLOCATE (sizeof (ACPI_SCI_HANDLER_INFO));
if (!NewSciHandler)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
NewSciHandler->Address = Address;
NewSciHandler->Context = Context;
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Lock list during installation */
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
SciHandler = AcpiGbl_SciHandlerList;
/* Ensure handler does not already exist */
while (SciHandler)
{
if (Address == SciHandler->Address)
{
Status = AE_ALREADY_EXISTS;
goto UnlockAndExit;
}
SciHandler = SciHandler->Next;
}
/* Install the new handler into the global list (at head) */
NewSciHandler->Next = AcpiGbl_SciHandlerList;
AcpiGbl_SciHandlerList = NewSciHandler;
UnlockAndExit:
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
Exit:
if (ACPI_FAILURE (Status))
{
ACPI_FREE (NewSciHandler);
}
return_ACPI_STATUS (Status);
}
示例14: acpi_ut_initialize_buffer
acpi_status
acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
acpi_size required_length)
{
acpi_size input_buffer_length;
/* Parameter validation */
if (!buffer || !required_length) {
return (AE_BAD_PARAMETER);
}
/*
* Buffer->Length is used as both an input and output parameter. Get the
* input actual length and set the output required buffer length.
*/
input_buffer_length = buffer->length;
buffer->length = required_length;
/*
* The input buffer length contains the actual buffer length, or the type
* of buffer to be allocated by this routine.
*/
switch (input_buffer_length) {
case ACPI_NO_BUFFER:
/* Return the exception (and the required buffer length) */
return (AE_BUFFER_OVERFLOW);
case ACPI_ALLOCATE_BUFFER:
/* Allocate a new buffer */
buffer->pointer = acpi_os_allocate(required_length);
break;
case ACPI_ALLOCATE_LOCAL_BUFFER:
/* Allocate a new buffer with local interface to allow tracking */
buffer->pointer = ACPI_ALLOCATE(required_length);
break;
default:
/* Existing buffer: Validate the size of the buffer */
if (input_buffer_length < required_length) {
return (AE_BUFFER_OVERFLOW);
}
break;
}
/* Validate allocation from above or input buffer pointer */
if (!buffer->pointer) {
return (AE_NO_MEMORY);
}
/* Have a valid buffer, clear it */
ACPI_MEMSET(buffer->pointer, 0, required_length);
return (AE_OK);
}
示例15: acpi_ex_opcode_3A_0T_0R
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_3A_0T_0R
*
* PARAMETERS: walk_state - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Execute Triadic operator (3 operands)
*
******************************************************************************/
acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_signal_fatal_info *fatal;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_0T_0R,
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"FatalOp: Type %X Code %X Arg %X "
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
(u32)operand[0]->integer.value,
(u32)operand[1]->integer.value,
(u32)operand[2]->integer.value));
fatal = ACPI_ALLOCATE(sizeof(struct acpi_signal_fatal_info));
if (fatal) {
fatal->type = (u32) operand[0]->integer.value;
fatal->code = (u32) operand[1]->integer.value;
fatal->argument = (u32) operand[2]->integer.value;
}
/* Always signal the OS! */
status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal);
/* Might return while OS is shutting down, just continue */
ACPI_FREE(fatal);
goto cleanup;
case AML_EXTERNAL_OP:
/*
* If the interpreter sees this opcode, just ignore it. The External
* op is intended for use by disassemblers in order to properly
* disassemble control method invocations. The opcode or group of
* opcodes should be surrounded by an "if (0)" clause to ensure that
* AML interpreters never see the opcode. Thus, something is
* wrong if an external opcode ever gets here.
*/
ACPI_ERROR((AE_INFO, "Executed External Op"));
status = AE_OK;
goto cleanup;
default:
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
cleanup:
return_ACPI_STATUS(status);
}