这篇教程C++ ACPI_MEMCPY函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ACPI_MEMCPY函数的典型用法代码示例。如果您正苦于以下问题:C++ ACPI_MEMCPY函数的具体用法?C++ ACPI_MEMCPY怎么用?C++ ACPI_MEMCPY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ACPI_MEMCPY函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: acpi_ut_copy_esimple_to_isimpleacpi_statusacpi_ut_copy_esimple_to_isimple ( union acpi_object *external_object, union acpi_operand_object **ret_internal_object){ union acpi_operand_object *internal_object; ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple"); /* * Simple types supported are: String, Buffer, Integer */ switch (external_object->type) { case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: internal_object = acpi_ut_create_internal_object ((u8) external_object->type); if (!internal_object) { return_ACPI_STATUS (AE_NO_MEMORY); } break; default: /* All other types are not supported */ return_ACPI_STATUS (AE_SUPPORT); } /* Must COPY string and buffer contents */ switch (external_object->type) { case ACPI_TYPE_STRING: internal_object->string.pointer = ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); if (!internal_object->string.pointer) { goto error_exit; } ACPI_MEMCPY (internal_object->string.pointer, external_object->string.pointer, external_object->string.length); internal_object->string.length = external_object->string.length; break; case ACPI_TYPE_BUFFER: internal_object->buffer.pointer = ACPI_MEM_CALLOCATE (external_object->buffer.length); if (!internal_object->buffer.pointer) { goto error_exit; } ACPI_MEMCPY (internal_object->buffer.pointer, external_object->buffer.pointer, external_object->buffer.length); internal_object->buffer.length = external_object->buffer.length; break; case ACPI_TYPE_INTEGER: internal_object->integer.value = external_object->integer.value; break; default: /* Other types can't get here */ break; } *ret_internal_object = internal_object; return_ACPI_STATUS (AE_OK);error_exit: acpi_ut_remove_reference (internal_object); return_ACPI_STATUS (AE_NO_MEMORY);}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:85,
示例2: OslTableInitializestatic ACPI_STATUSOslTableInitialize ( void){ char Buffer[32]; ACPI_TABLE_HEADER *MappedTable; UINT8 *TableAddress; UINT8 *RsdpAddress; ACPI_PHYSICAL_ADDRESS RsdpBase; ACPI_SIZE RsdpSize; ACPI_STATUS Status; u_long Address = 0; size_t Length = sizeof (Address); /* Get main ACPI tables from memory on first invocation of this function */ if (Gbl_MainTableObtained) { return (AE_OK); } /* Attempt to use kenv or sysctl to find RSD PTR record. */ if (Gbl_RsdpBase) { Address = Gbl_RsdpBase; } else if (kenv (KENV_GET, SYSTEM_KENV, Buffer, sizeof (Buffer)) > 0) { Address = ACPI_STRTOUL (Buffer, NULL, 0); } if (!Address) { if (sysctlbyname (SYSTEM_SYSCTL, &Address, &Length, NULL, 0) != 0) { Address = 0; } } if (Address) { RsdpBase = Address; RsdpSize = sizeof (Gbl_Rsdp); } else { RsdpBase = ACPI_HI_RSDP_WINDOW_BASE; RsdpSize = ACPI_HI_RSDP_WINDOW_SIZE; } /* Get RSDP from memory */ RsdpAddress = AcpiOsMapMemory (RsdpBase, RsdpSize); if (!RsdpAddress) { return (AE_BAD_ADDRESS); } /* Search low memory for the RSDP */ TableAddress = AcpiTbScanMemoryForRsdp (RsdpAddress, RsdpSize); if (!TableAddress) { AcpiOsUnmapMemory (RsdpAddress, RsdpSize); return (AE_ERROR); } ACPI_MEMCPY (&Gbl_Rsdp, TableAddress, sizeof (Gbl_Rsdp)); AcpiOsUnmapMemory (RsdpAddress, RsdpSize); /* Get XSDT from memory */ if (Gbl_Rsdp.Revision) { Status = OslMapTable (Gbl_Rsdp.XsdtPhysicalAddress, ACPI_SIG_XSDT, &MappedTable); if (ACPI_FAILURE (Status)) { return (Status); } Gbl_Revision = 2; Gbl_Xsdt = calloc (1, MappedTable->Length); if (!Gbl_Xsdt) { fprintf (stderr, "XSDT: Could not allocate buffer for table of length %X/n", MappedTable->Length); AcpiOsUnmapMemory (MappedTable, MappedTable->Length); return (AE_NO_MEMORY); } ACPI_MEMCPY (Gbl_Xsdt, MappedTable, MappedTable->Length); AcpiOsUnmapMemory (MappedTable, MappedTable->Length); } /* Get RSDT from memory */ if (Gbl_Rsdp.RsdtPhysicalAddress) {//.........这里部分代码省略.........
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:101,
示例3: acpi_ev_create_gpe_blockacpi_statusacpi_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_level, struct acpi_gpe_block_info **return_gpe_block){ struct acpi_gpe_block_info *gpe_block; acpi_status status; ACPI_FUNCTION_TRACE ("ev_create_gpe_block"); if (!register_count) { return_ACPI_STATUS (AE_OK); } /* Allocate a new GPE block */ gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info)); if (!gpe_block) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize the new GPE block */ 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 */ status = acpi_ev_create_gpe_info_blocks (gpe_block); if (ACPI_FAILURE (status)) { ACPI_MEM_FREE (gpe_block); return_ACPI_STATUS (status); } /* Install the new block in the global list(s) */ status = acpi_ev_install_gpe_block (gpe_block, interrupt_level); if (ACPI_FAILURE (status)) { ACPI_MEM_FREE (gpe_block); return_ACPI_STATUS (status); } /* Dump info about this GPE block */ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE %02d to %02d [%4.4s] %d regs at %8.8X%8.8X on int %d/n", gpe_block->block_base_number, (u32) (gpe_block->block_base_number + ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), gpe_device->name.ascii, gpe_block->register_count, ACPI_HIDWORD (gpe_block->block_address.address), ACPI_LODWORD (gpe_block->block_address.address), interrupt_level)); /* Find all GPE methods (_Lxx, _Exx) for this block */ status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, gpe_block, NULL); /* Return the new block */ if (return_gpe_block) { (*return_gpe_block) = gpe_block; } return_ACPI_STATUS (AE_OK);}
开发者ID:dduval,项目名称:kernel-rhel3,代码行数:76,
示例4: AeBuildLocalTablesACPI_STATUSAeBuildLocalTables ( UINT32 TableCount, AE_TABLE_DESC *TableList){ ACPI_PHYSICAL_ADDRESS DsdtAddress = 0; UINT32 XsdtSize; AE_TABLE_DESC *NextTable; UINT32 NextIndex; ACPI_TABLE_FADT *ExternalFadt = NULL; /* * Update the table count. For DSDT, it is not put into the XSDT. For * FADT, this is already accounted for since we usually install a * local FADT. */ NextTable = TableList; while (NextTable) { if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) || ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) { TableCount--; } NextTable = NextTable->Next; } XsdtSize = BASE_XSDT_SIZE + (TableCount * sizeof (UINT64)); /* Build an XSDT */ LocalXSDT = AcpiOsAllocate (XsdtSize); if (!LocalXSDT) { return (AE_NO_MEMORY); } ACPI_MEMSET (LocalXSDT, 0, XsdtSize); ACPI_MOVE_NAME (LocalXSDT->Header.Signature, ACPI_SIG_XSDT); LocalXSDT->Header.Length = XsdtSize; LocalXSDT->Header.Revision = 1; LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalFADT); /* * Install the user tables. The DSDT must be installed in the FADT. * All other tables are installed directly into the XSDT. */ NextIndex = BASE_XSDT_TABLES; NextTable = TableList; while (NextTable) { /* * Incoming DSDT or FADT are special cases. All other tables are * just immediately installed into the XSDT. */ if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT)) { if (DsdtAddress) { printf ("Already found a DSDT, only one allowed/n"); return (AE_ALREADY_EXISTS); } /* The incoming user table is a DSDT */ DsdtAddress = ACPI_PTR_TO_PHYSADDR (NextTable->Table); } else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) { ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table); LocalXSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (NextTable->Table); } else { /* Install the table in the XSDT */ LocalXSDT->TableOffsetEntry[NextIndex] = ACPI_PTR_TO_PHYSADDR (NextTable->Table); NextIndex++; } NextTable = NextTable->Next; } /* Build an RSDP */ ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP)); ACPI_MAKE_RSDP_SIG (LocalRSDP.Signature); ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6); LocalRSDP.Revision = 2; LocalRSDP.XsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalXSDT); LocalRSDP.Length = sizeof (ACPI_TABLE_XSDT); /* Set checksums for both XSDT and RSDP */ LocalXSDT->Header.Checksum = (UINT8) -AcpiTbChecksum ( (void *) LocalXSDT, LocalXSDT->Header.Length); LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ( (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH);//.........这里部分代码省略.........
开发者ID:zenny,项目名称:DragonFlyBSD,代码行数:101,
示例5: AeBuildLocalTables//.........这里部分代码省略......... if (AcpiGbl_LoadTestTables) { LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE); /* Install two SSDTs to test multiple table support */ LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code); LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code); /* Install the OEM1 table to test LoadTable */ LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Oem1Code); /* Install the OEMx table to test LoadTable */ LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&OemxCode); /* Install the ECDT table to test _REG */ LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&EcdtCode); /* Install two UEFIs to test multiple table support */ LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Uefi1Code); LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Uefi2Code); } /* Build an RSDP. Contains a valid XSDT only, no RSDT */ ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP)); ACPI_MAKE_RSDP_SIG (LocalRSDP.Signature); ACPI_MEMCPY (LocalRSDP.OemId, "Intel", 6); LocalRSDP.Revision = 2; LocalRSDP.XsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalXSDT); LocalRSDP.Length = sizeof (ACPI_TABLE_RSDP); /* Set checksums for both XSDT and RSDP */ LocalXSDT->Header.Checksum = 0; LocalXSDT->Header.Checksum = (UINT8) -AcpiTbChecksum ( (void *) LocalXSDT, LocalXSDT->Header.Length); LocalRSDP.Checksum = 0; LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ( (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH); if (!DsdtAddress) { /* Use the local DSDT because incoming table(s) are all SSDT(s) */ DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode); DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode); } /* * Build an FADT. There are three options for the FADT: * 1) Incoming external FADT specified on the command line * 2) A "hardware reduced" local FADT * 3) A fully featured local FADT */ if (ExternalFadt) { /*
开发者ID:macmade,项目名称:acpica,代码行数:67,
示例6: AcpiGetObjectInfo//.........这里部分代码省略......... Info->Name = Node->Name.Integer; Info->Valid = 0; Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* If not a device, we are all done */ if (Info->Type == ACPI_TYPE_DEVICE) { /* * Get extra info for ACPI Devices objects only: * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used * to indicate which methods were found and ran successfully. */ /* Execute the Device._HID method */ Status = AcpiUtExecute_HID (Node, &Info->HardwareId); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ Status = AcpiUtExecute_UID (Node, &Info->UniqueId); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ Status = AcpiUtExecute_CID (Node, &CidList); if (ACPI_SUCCESS (Status)) { Size += CidList->Size; Info->Valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &Info->Address); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_ADR; } /* Execute the Device._SxD methods */ Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_SXDS; } } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (Buffer, Size); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Populate the return buffer */ ReturnInfo = Buffer->Pointer; ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); if (CidList) { ACPI_MEMCPY (&ReturnInfo->CompatibilityId, CidList, CidList->Size); }Cleanup: ACPI_FREE (Info); if (CidList) { ACPI_FREE (CidList); } return (Status);}
开发者ID:samueldotj,项目名称:AceOS,代码行数:101,
示例7: AcpiExOpcode_2A_1T_1RACPI_STATUSAcpiExOpcode_2A_1T_1R ( ACPI_WALK_STATE *WalkState){ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; UINT64 Index; ACPI_STATUS Status = AE_OK; ACPI_SIZE Length = 0; ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); /* Execute the opcode */ if (WalkState->OpInfo->Flags & AML_MATH) { /* All simple math opcodes (add, etc.) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, Operand[0]->Integer.Value, Operand[1]->Integer.Value); goto StoreResultToTarget; } switch (WalkState->Opcode) { case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* ReturnDesc will contain the remainder */ Status = AcpiUtDivide (Operand[0]->Integer.Value, Operand[1]->Integer.Value, NULL, &ReturnDesc->Integer.Value); break; case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ Status = AcpiExDoConcatenate (Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ /* * Input object is guaranteed to be a buffer at this point (it may have * been converted.) Copy the raw buffer data to a new object of * type String. */ /* * Get the length of the new string. It is the smallest of: * 1) Length of the input buffer * 2) Max length as specified in the ToString operator * 3) Length of input buffer up to a zero byte (null terminator) * * NOTE: A length of zero is ok, and will create a zero-length, null * terminated string. */ while ((Length < Operand[0]->Buffer.Length) && (Length < Operand[1]->Integer.Value) && (Operand[0]->Buffer.Pointer[Length])) { Length++; } /* Allocate a new string object */ ReturnDesc = AcpiUtCreateStringObject (Length); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Copy the raw buffer data with no transform. * (NULL terminated already) */ ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); break; case AML_CONCAT_RES_OP://.........这里部分代码省略.........
开发者ID:LauraBerry,项目名称:A2cpsc457,代码行数:101,
示例8: acpi_ex_store_buffer_to_buffer/******************************************************************************* * * FUNCTION: acpi_ex_store_buffer_to_buffer * * PARAMETERS: source_desc - Source object to copy * target_desc - Destination object of the copy * * RETURN: Status * * DESCRIPTION: Copy a buffer object to another buffer object. * ******************************************************************************/acpi_statusacpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, union acpi_operand_object *target_desc){ u32 length; u8 *buffer; ACPI_FUNCTION_TRACE_PTR(ex_store_buffer_to_buffer, source_desc); if (source_desc == target_desc) { return_ACPI_STATUS(AE_OK); } /* We know that source_desc is a buffer by now */ buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer); length = source_desc->buffer.length; /* * If target is a buffer of length zero or is a static buffer, * allocate a new buffer of the proper length */ if ((target_desc->buffer.length == 0) || (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { target_desc->buffer.pointer = ACPI_ALLOCATE(length); if (!target_desc->buffer.pointer) { return_ACPI_STATUS(AE_NO_MEMORY); } target_desc->buffer.length = length; } /* Copy source buffer to target buffer */ if (length <= target_desc->buffer.length) { /* Clear existing buffer and copy in the new one */ ACPI_MEMSET(target_desc->buffer.pointer, 0, target_desc->buffer.length); ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length);#ifdef ACPI_OBSOLETE_BEHAVIOR /* * NOTE: ACPI versions up to 3.0 specified that the buffer must be * truncated if the string is smaller than the buffer. However, "other" * implementations of ACPI never did this and thus became the defacto * standard. ACPI 3.0_a changes this behavior such that the buffer * is no longer truncated. */ /* * OBSOLETE BEHAVIOR: * If the original source was a string, we must truncate the buffer, * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer * copy must not truncate the original buffer. */ if (original_src_type == ACPI_TYPE_STRING) { /* Set the new length of the target */ target_desc->buffer.length = length; }#endif } else { /* Truncate the source, copy only what will fit */ ACPI_MEMCPY(target_desc->buffer.pointer, buffer, target_desc->buffer.length); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Truncating source buffer from %X to %X/n", length, target_desc->buffer.length)); } /* Copy flags */ target_desc->buffer.flags = source_desc->buffer.flags; target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; return_ACPI_STATUS(AE_OK);}
开发者ID:xf739645524,项目名称:kernel-rhel5,代码行数:93,
示例9: acpi_get_tableacpi_statusacpi_get_table ( acpi_table_type table_type, u32 instance, struct acpi_buffer *ret_buffer){ struct acpi_table_header *tbl_ptr; acpi_status status; acpi_size table_length; ACPI_FUNCTION_TRACE ("acpi_get_table"); /* Parameter validation */ if (instance == 0) { return_ACPI_STATUS (AE_BAD_PARAMETER); } status = acpi_ut_validate_buffer (ret_buffer); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Check the table type and instance */ if ((table_type > ACPI_TABLE_MAX) || (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && instance > 1)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get a pointer to the entire table */ status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* * acpi_tb_get_table_ptr will return a NULL pointer if the * table is not loaded. */ if (tbl_ptr == NULL) { return_ACPI_STATUS (AE_NOT_EXIST); } /* Get the table length */ if (table_type == ACPI_TABLE_RSDP) { /* * RSD PTR is the only "table" without a header */ table_length = sizeof (struct rsdp_descriptor); } else { table_length = (acpi_size) tbl_ptr->length; } /* Validate/Allocate/Clear caller buffer */ status = acpi_ut_initialize_buffer (ret_buffer, table_length); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Copy the table to the buffer */ ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); return_ACPI_STATUS (AE_OK);}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:73,
示例10: AcpiDsBuildInternalBufferObjACPI_STATUSAcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr){ ACPI_PARSE_OBJECT *Arg; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *ByteList; UINT32 ByteListLength = 0; ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); /* * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". * The buffer object already exists (from the NS node), otherwise it must * be created. */ ObjDesc = *ObjDescPtr; if (!ObjDesc) { /* Create a new buffer object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); *ObjDescPtr = ObjDesc; if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } } /* * Second arg is the buffer data (optional) ByteList can be either * individual bytes or a string initializer. In either case, a * ByteList appears in the AML. */ Arg = Op->Common.Value.Arg; /* skip first arg */ ByteList = Arg->Named.Next; if (ByteList) { if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) { ACPI_ERROR ((AE_INFO, "Expecting bytelist, found AML opcode 0x%X in op %p", ByteList->Common.AmlOpcode, ByteList)); AcpiUtRemoveReference (ObjDesc); return (AE_TYPE); } ByteListLength = (UINT32) ByteList->Common.Value.Integer; } /* * The buffer length (number of bytes) will be the larger of: * 1) The specified buffer length and * 2) The length of the initializer byte list */ ObjDesc->Buffer.Length = BufferLength; if (ByteListLength > BufferLength) { ObjDesc->Buffer.Length = ByteListLength; } /* Allocate the buffer */ if (ObjDesc->Buffer.Length == 0) { ObjDesc->Buffer.Pointer = NULL; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer defined with zero length in AML, creating/n")); } else { ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( ObjDesc->Buffer.Length); if (!ObjDesc->Buffer.Pointer) { AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize buffer from the ByteList (if present) */ if (ByteList) { ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, ByteListLength); } } ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); return_ACPI_STATUS (AE_OK);}
开发者ID:0xffea,项目名称:MINIX3,代码行数:99,
示例11: acpi_get_object_info//.........这里部分代码省略......... return (AE_BAD_PARAMETER); } /* Init return structure */ size = sizeof (struct acpi_device_info); ACPI_MEMSET (&info, 0, size); info.type = node->type; info.name = node->name.integer; info.valid = 0; status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } /* If not a device, we are all done */ if (info.type == ACPI_TYPE_DEVICE) { /* * Get extra info for ACPI Devices objects only: * Run the Device _HID, _UID, _CID, _STA, and _ADR methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info.Valid bitfield is used * to indicate which methods were found and ran successfully. */ /* Execute the Device._HID method */ status = acpi_ut_execute_HID (node, &info.hardware_id); if (ACPI_SUCCESS (status)) { info.valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ status = acpi_ut_execute_UID (node, &info.unique_id); if (ACPI_SUCCESS (status)) { info.valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ status = acpi_ut_execute_CID (node, &cid_list); if (ACPI_SUCCESS (status)) { size += ((acpi_size) cid_list->count - 1) * sizeof (struct acpi_compatible_id); info.valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ status = acpi_ut_execute_STA (node, &info.current_status); if (ACPI_SUCCESS (status)) { info.valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node, &info.address); if (ACPI_SUCCESS (status)) { info.valid |= ACPI_VALID_ADR; } /* Execute the Device._sx_d methods */ status = acpi_ut_execute_sxds (node, info.highest_dstates); if (ACPI_SUCCESS (status)) { info.valid |= ACPI_VALID_STA; } status = AE_OK; } /* Validate/Allocate/Clear caller buffer */ status = acpi_ut_initialize_buffer (buffer, size); if (ACPI_FAILURE (status)) { goto cleanup; } /* Populate the return buffer */ return_info = buffer->pointer; ACPI_MEMCPY (return_info, &info, sizeof (struct acpi_device_info)); if (cid_list) { ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size); }cleanup: if (cid_list) { ACPI_MEM_FREE (cid_list); } return (status);}
开发者ID:Brainiarc7,项目名称:ralink_sdk,代码行数:101,
示例12: acpi_ev_asynch_execute_gpe_methodstatic void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context){ struct acpi_gpe_event_info *gpe_event_info = (void *)context; acpi_status status; struct acpi_gpe_event_info local_gpe_event_info; struct acpi_evaluate_info *info; ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method); status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); if (ACPI_FAILURE(status)) { return_VOID; } /* Must revalidate the gpe_number/gpe_block */ if (!acpi_ev_valid_gpe_event(gpe_event_info)) { status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); return_VOID; } /* Set the GPE flags for return to enabled state */ (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); /* * Take a snapshot of the GPE info for this level - we copy the info to * prevent a race condition with remove_handler/remove_block. */ ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, sizeof(struct acpi_gpe_event_info)); status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); if (ACPI_FAILURE(status)) { return_VOID; } /* * Must check for control method type dispatch one more time to avoid a * race with ev_gpe_install_handler */ if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { /* Allocate the evaluation information block */ info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); if (!info) { status = AE_NO_MEMORY; } else { /* * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx * control method that corresponds to this GPE */ info->prefix_node = local_gpe_event_info.dispatch.method_node; info->flags = ACPI_IGNORE_RETURN_VALUE; status = acpi_ns_evaluate(info); ACPI_FREE(info); } if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "while evaluating GPE method [%4.4s]", acpi_ut_get_node_name (local_gpe_event_info.dispatch. method_node))); } } /* Defer enabling of GPE until all notify handlers are done */ acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_asynch_enable_gpe, gpe_event_info); return_VOID;}
开发者ID:KroMignon,项目名称:linux-emcraft,代码行数:75,
示例13: acpi_ex_field_datum_iostatic acpi_statusacpi_ex_field_datum_io(union acpi_operand_object *obj_desc, u32 field_datum_byte_offset, acpi_integer * value, u32 read_write){ acpi_status status; acpi_integer local_value; ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset); if (read_write == ACPI_READ) { if (!value) { local_value = 0; /* To support reads without saving return value */ value = &local_value; } /* Clear the entire return buffer first, [Very Important!] */ *value = 0; } /* * The four types of fields are: * * buffer_field - Read/write from/to a Buffer * region_field - Read/write from/to a Operation Region. * bank_field - Write to a Bank Register, then read/write from/to an * operation_region * index_field - Write to an Index Register, then read/write from/to a * Data Register */ switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_BUFFER_FIELD: /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { status = acpi_ds_get_buffer_field_arguments(obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } if (read_write == ACPI_READ) { /* * Copy the data from the source buffer. * Length is the field width in bytes. */ ACPI_MEMCPY(value, (obj_desc->buffer_field.buffer_obj)->buffer. pointer + obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset, obj_desc->common_field.access_byte_width); } else { /* * Copy the data to the target buffer. * Length is the field width in bytes. */ ACPI_MEMCPY((obj_desc->buffer_field.buffer_obj)->buffer. pointer + obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset, value, obj_desc->common_field.access_byte_width); } status = AE_OK; break; case ACPI_TYPE_LOCAL_BANK_FIELD: /* * Ensure that the bank_value is not beyond the capacity of * the register */ if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj, (acpi_integer) obj_desc-> bank_field.value)) { return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); } /* * For bank_fields, we must write the bank_value to the bank_register * (itself a region_field) before we can access the data. */ status = acpi_ex_insert_into_field(obj_desc->bank_field.bank_obj, &obj_desc->bank_field.value, sizeof(obj_desc->bank_field. value)); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Now that the Bank has been selected, fall through to the * region_field case and write the datum to the Operation Region//.........这里部分代码省略.........
开发者ID:PyroOS,项目名称:Pyro,代码行数:101,
示例14: acpi_ex_extract_from_fieldacpi_statusacpi_ex_extract_from_field(union acpi_operand_object *obj_desc, void *buffer, u32 buffer_length){ acpi_status status; acpi_integer raw_datum; acpi_integer merged_datum; u32 field_offset = 0; u32 buffer_offset = 0; u32 buffer_tail_bits; u32 datum_count; u32 field_datum_count; u32 i; ACPI_FUNCTION_TRACE(ex_extract_from_field); /* Validate target buffer and clear it */ if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { ACPI_ERROR((AE_INFO, "Field size %X (bits) is too large for buffer (%X)", obj_desc->common_field.bit_length, buffer_length)); return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } ACPI_MEMSET(buffer, 0, buffer_length); /* Compute the number of datums (access width data items) */ datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, obj_desc->common_field.access_bit_width); field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length + obj_desc->common_field. start_field_bit_offset, obj_desc->common_field. access_bit_width); /* Priming read from the field */ status = acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum, ACPI_READ); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; /* Read the rest of the field */ for (i = 1; i < field_datum_count; i++) { /* Get next input datum from the field */ field_offset += obj_desc->common_field.access_byte_width; status = acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum, ACPI_READ); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Merge with previous datum if necessary. * * Note: Before the shift, check if the shift value will be larger than * the integer size. If so, there is no need to perform the operation. * This avoids the differences in behavior between different compilers * concerning shift values larger than the target data width. */ if ((obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset) < ACPI_INTEGER_BIT_SIZE) { merged_datum |= raw_datum << (obj_desc->common_field. access_bit_width - obj_desc->common_field. start_field_bit_offset); } if (i == datum_count) { break; } /* Write merged datum to target buffer */ ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum, ACPI_MIN(obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); buffer_offset += obj_desc->common_field.access_byte_width; merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; } /* Mask off any extra bits in the last datum */ buffer_tail_bits = obj_desc->common_field.bit_length % obj_desc->common_field.access_bit_width; if (buffer_tail_bits) {//.........这里部分代码省略.........
开发者ID:PyroOS,项目名称:Pyro,代码行数:101,
示例15: acpi_ex_insert_into_fieldacpi_statusacpi_ex_insert_into_field(union acpi_operand_object *obj_desc, void *buffer, u32 buffer_length){ acpi_status status; acpi_integer mask; acpi_integer width_mask; acpi_integer merged_datum; acpi_integer raw_datum = 0; u32 field_offset = 0; u32 buffer_offset = 0; u32 buffer_tail_bits; u32 datum_count; u32 field_datum_count; u32 i; u32 required_length; void *new_buffer; 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; } /* * Create the bitmasks used for bit insertion. * Note: This if/else is used to bypass compiler differences with the * shift operator */ if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) { width_mask = ACPI_INTEGER_MAX; } else { width_mask = ACPI_MASK_BITS_ABOVE(obj_desc->common_field. 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, obj_desc->common_field.access_bit_width); field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length + obj_desc->common_field. start_field_bit_offset, obj_desc->common_field. 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; status = acpi_ex_write_with_update_rule(obj_desc, mask, merged_datum, field_offset); if (ACPI_FAILURE(status)) { goto exit; }//.........这里部分代码省略.........
开发者ID:PyroOS,项目名称:Pyro,代码行数:101,
示例16: AcpiRsMoveDatavoidAcpiRsMoveData ( void *Destination, void *Source, UINT16 ItemCount, UINT8 MoveType){ UINT32 i; ACPI_FUNCTION_ENTRY (); /* One move per item */ for (i = 0; i < ItemCount; i++) { switch (MoveType) { /* * For the 8-bit case, we can perform the move all at once * since there are no alignment or endian issues */ case ACPI_RSC_MOVE8: case ACPI_RSC_MOVE_GPIO_RES: case ACPI_RSC_MOVE_SERIAL_VEN: case ACPI_RSC_MOVE_SERIAL_RES: ACPI_MEMCPY (Destination, Source, ItemCount); return; /* * 16-, 32-, and 64-bit cases must use the move macros that perform * endian conversion and/or accommodate hardware that cannot perform * misaligned memory transfers */ case ACPI_RSC_MOVE16: case ACPI_RSC_MOVE_GPIO_PIN: ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], &ACPI_CAST_PTR (UINT16, Source)[i]); break; case ACPI_RSC_MOVE32: ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], &ACPI_CAST_PTR (UINT32, Source)[i]); break; case ACPI_RSC_MOVE64: ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], &ACPI_CAST_PTR (UINT64, Source)[i]); break; default: return; } }}
开发者ID:sandeepnegi,项目名称:freebsd,代码行数:61,
示例17: acpi_ex_convert_to_bufferacpi_statusacpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, union acpi_operand_object **result_desc){ union acpi_operand_object *return_desc; u8 *new_buf; ACPI_FUNCTION_TRACE_PTR(ex_convert_to_buffer, obj_desc); switch (obj_desc->common.type) { case ACPI_TYPE_BUFFER: /* No conversion necessary */ *result_desc = obj_desc; return_ACPI_STATUS(AE_OK); case ACPI_TYPE_INTEGER: /* * Create a new Buffer object. * Need enough space for one integer */ return_desc = acpi_ut_create_buffer_object(acpi_gbl_integer_byte_width); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the integer to the buffer, LSB first */ new_buf = return_desc->buffer.pointer; ACPI_MEMCPY(new_buf, &obj_desc->integer.value, acpi_gbl_integer_byte_width); break; case ACPI_TYPE_STRING: /* * Create a new Buffer object * Size will be the string length * * NOTE: Add one to the string length to include the null terminator. * The ACPI spec is unclear on this subject, but there is existing * ASL/AML code that depends on the null being transferred to the new * buffer. */ return_desc = acpi_ut_create_buffer_object((acpi_size) obj_desc->string. length + 1); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the string to the buffer */ new_buf = return_desc->buffer.pointer; ACPI_STRNCPY((char *)new_buf, (char *)obj_desc->string.pointer, obj_desc->string.length); break; default: return_ACPI_STATUS(AE_TYPE); } /* Mark buffer initialized */ return_desc->common.flags |= AOPOBJ_DATA_VALID; *result_desc = return_desc; return_ACPI_STATUS(AE_OK);}
开发者ID:Core2idiot,项目名称:Kernel-Samsung-3.0...-,代码行数:72,
示例18: OslGetTableViaRoot//.........这里部分代码省略......... { if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XFACS) && Gbl_Fadt->XFacs) { TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XFacs; } else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_FACS) && Gbl_Fadt->Facs) { TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Facs; } } } else /* Case for a normal ACPI table */ { if (Gbl_Revision) { NumberOfTables = (Gbl_Xsdt->Header.Length - sizeof (Gbl_Xsdt->Header)) / sizeof (Gbl_Xsdt->TableOffsetEntry[0]); } else /* Use RSDT if XSDT is not available */ { NumberOfTables = (Gbl_Rsdt->Header.Length - sizeof (Gbl_Rsdt->Header)) / sizeof (Gbl_Rsdt->TableOffsetEntry[0]); } /* Search RSDT/XSDT for the requested table */ for (i = 0; i < NumberOfTables; i++) { if (Gbl_Revision) { TableAddress = Gbl_Xsdt->TableOffsetEntry[i]; } else { TableAddress = Gbl_Rsdt->TableOffsetEntry[i]; } MappedTable = AcpiOsMapMemory (TableAddress, sizeof (*MappedTable)); if (!MappedTable) { return (AE_BAD_ADDRESS); } /* Does this table match the requested signature? */ if (ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) { /* Match table instance (for SSDT/UEFI tables) */ if (CurrentInstance == Instance) { AcpiOsUnmapMemory (MappedTable, sizeof (*MappedTable)); break; } CurrentInstance++; } AcpiOsUnmapMemory (MappedTable, MappedTable->Length); TableAddress = 0; } } if (!TableAddress) { if (CurrentInstance) { return (AE_LIMIT); } return (AE_NOT_FOUND); } /* Now we can get the requested table */ Status = OslMapTable (TableAddress, Signature, &MappedTable); if (ACPI_FAILURE (Status)) { return (Status); } /* Copy table to local buffer and return it */ LocalTable = calloc (1, MappedTable->Length); if (!LocalTable) { AcpiOsUnmapMemory (MappedTable, MappedTable->Length); return (AE_NO_MEMORY); } ACPI_MEMCPY (LocalTable, MappedTable, MappedTable->Length); AcpiOsUnmapMemory (MappedTable, MappedTable->Length); *Table = LocalTable; *Address = TableAddress; return (AE_OK);}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:101,
示例19: acpi_ex_opcode_3A_1T_1Racpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state){ union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object *return_desc = NULL; char *buffer = NULL; acpi_status status = AE_OK; u64 index; acpi_size length; ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R, acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ /* * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ return_desc = acpi_ut_create_internal_object((operand[0])-> common.type); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } /* Get the Integer values from the objects */ index = operand[1]->integer.value; length = (acpi_size) operand[2]->integer.value; /* * If the index is beyond the length of the String/Buffer, or if the * requested length is zero, return a zero-length String/Buffer */ if (index >= operand[0]->string.length) { length = 0; } /* Truncate request if larger than the actual String/Buffer */ else if ((index + length) > operand[0]->string.length) { length = (acpi_size) operand[0]->string.length - (acpi_size) index; } /* Strings always have a sub-pointer, not so for buffers */ switch ((operand[0])->common.type) { case ACPI_TYPE_STRING: /* Always allocate a new buffer for the String */ buffer = ACPI_ALLOCATE_ZEROED((acpi_size) length + 1); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; } break; case ACPI_TYPE_BUFFER: /* If the requested length is zero, don't allocate a buffer */ if (length > 0) { /* Allocate a new buffer for the Buffer */ buffer = ACPI_ALLOCATE_ZEROED(length); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; } } break; default: /* Should not happen */ status = AE_AML_OPERAND_TYPE; goto cleanup; } if (buffer) { /* We have a buffer, copy the portion requested */ ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, length); } /* Set the length of the new String/Buffer */ return_desc->string.pointer = buffer; return_desc->string.length = (u32) length; /* Mark buffer initialized */ return_desc->buffer.flags |= AOPOBJ_DATA_VALID; break;//.........这里部分代码省略.........
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:101,
示例20: acpi_ex_do_concatenateacpi_statusacpi_ex_do_concatenate ( union acpi_operand_object *operand0, union acpi_operand_object *operand1, union acpi_operand_object **actual_return_desc, struct acpi_walk_state *walk_state){ union acpi_operand_object *local_operand1 = operand1; union acpi_operand_object *return_desc; char *new_buf; acpi_status status; acpi_size new_length; ACPI_FUNCTION_TRACE ("ex_do_concatenate"); /* * Convert the second operand if necessary. The first operand * determines the type of the second operand, (See the Data Types * section of the ACPI specification.) Both object types are * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ switch (ACPI_GET_OBJECT_TYPE (operand0)) { case ACPI_TYPE_INTEGER: status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16); break; case ACPI_TYPE_STRING: status = acpi_ex_convert_to_string (operand1, &local_operand1, ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: status = acpi_ex_convert_to_buffer (operand1, &local_operand1); break; default: ACPI_REPORT_ERROR (("Concat - invalid obj type: %X/n", ACPI_GET_OBJECT_TYPE (operand0))); status = AE_AML_INTERNAL; } if (ACPI_FAILURE (status)) { goto cleanup; } /* * Both operands are now known to be the same object type * (Both are Integer, String, or Buffer), and we can now perform the * concatenation. */ /* * There are three cases to handle: * * 1) Two Integers concatenated to produce a new Buffer * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ switch (ACPI_GET_OBJECT_TYPE (operand0)) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ return_desc = acpi_ut_create_buffer_object ( ACPI_MUL_2 (acpi_gbl_integer_byte_width)); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } new_buf = (char *) return_desc->buffer.pointer; /* Copy the first integer, LSB first */ ACPI_MEMCPY (new_buf, &operand0->integer.value, acpi_gbl_integer_byte_width); /* Copy the second integer (LSB first) after the first */ ACPI_MEMCPY (new_buf + acpi_gbl_integer_byte_width, &local_operand1->integer.value, acpi_gbl_integer_byte_width); break; case ACPI_TYPE_STRING: /* Result of two Strings is a String */ new_length = (acpi_size) operand0->string.length + (acpi_size) local_operand1->string.length; if (new_length > ACPI_MAX_STRING_CONVERSION) { status = AE_AML_STRING_LIMIT; goto cleanup; }//.........这里部分代码省略.........
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:101,
示例21: acpi_tb_get_this_tablestatic acpi_statusacpi_tb_get_this_table ( struct acpi_pointer *address, struct acpi_table_header *header, struct acpi_table_desc *table_info){ struct acpi_table_header *full_table = NULL; u8 allocation; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE ("tb_get_this_table"); /* * Flags contains the current processor mode (Virtual or Physical * addressing) The pointer_type is either Logical or Physical */ switch (address->pointer_type) { case ACPI_PHYSMODE_PHYSPTR: case ACPI_LOGMODE_LOGPTR: /* Pointer matches processor mode, copy the table to a new buffer */ full_table = ACPI_MEM_ALLOCATE (header->length); if (!full_table) { ACPI_REPORT_ERROR (( "Could not allocate table memory for [%4.4s] length %X/n", header->signature, header->length)); return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the entire table (including header) to the local buffer */ ACPI_MEMCPY (full_table, address->pointer.logical, header->length); /* Save allocation type */ allocation = ACPI_MEM_ALLOCATED; break; case ACPI_LOGMODE_PHYSPTR: /* * Just map the table's physical memory * into our address space. */ status = acpi_os_map_memory (address->pointer.physical, (acpi_size) header->length, (void *) &full_table); if (ACPI_FAILURE (status)) { ACPI_REPORT_ERROR (( "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X/n", header->signature, ACPI_FORMAT_UINT64 (address->pointer.physical), header->length)); return (status); } /* Save allocation type */ allocation = ACPI_MEM_MAPPED; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X/n", address->pointer_type)); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Validate checksum for _most_ tables, * even the ones whose signature we don't recognize */ if (table_info->type != ACPI_TABLE_FACS) { status = acpi_tb_verify_table_checksum (full_table);#if (!ACPI_CHECKSUM_ABORT) if (ACPI_FAILURE (status)) { /* Ignore the error if configuration says so */ status = AE_OK; }#endif } /* Return values */ table_info->pointer = full_table; table_info->length = (acpi_size) header->length; table_info->allocation = allocation; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p/n", full_table->signature, ACPI_FORMAT_UINT64 (address->pointer.physical), full_table)); return_ACPI_STATUS (status);//.........这里部分代码省略.........
开发者ID:kzlin129,项目名称:tt-gpl,代码行数:101,
示例22: DtCompileIntegervoidDtCompileInteger ( UINT8 *Buffer, DT_FIELD *Field, UINT32 ByteLength, UINT8 Flags){ UINT64 Value; UINT64 MaxValue; ACPI_STATUS Status; /* Output buffer byte length must be in range 1-8 */ if ((ByteLength > 8) || (ByteLength == 0)) { DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid internal Byte length"); return; } /* Resolve integer expression to a single integer value */ Status = DtResolveIntegerExpression (Field, &Value); if (ACPI_FAILURE (Status)) { return; } /* * Ensure that reserved fields are set properly. Note: uses * the DT_NON_ZERO flag to indicate that the reserved value * must be exactly one. Otherwise, the value must be zero. * This is sufficient for now. */ /* TBD: Should use a flag rather than compare "Reserved" */ if (!ACPI_STRCMP (Field->Name, "Reserved")) { if (Flags & DT_NON_ZERO) { if (Value != 1) { DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, "Must be one, setting to one"); Value = 1; } } else if (Value != 0) { DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, "Must be zero, setting to zero"); Value = 0; } } /* Check if the value must be non-zero */ else if ((Flags & DT_NON_ZERO) && (Value == 0)) { DtError (ASL_ERROR, ASL_MSG_ZERO_VALUE, Field, NULL); } /* * Generate the maximum value for the data type (ByteLength) * Note: construct chosen for maximum portability */ MaxValue = ((UINT64) (-1)) >> (64 - (ByteLength * 8)); /* Validate that the input value is within range of the target */ if (Value > MaxValue) { sprintf (MsgBuffer, "%8.8X%8.8X - max %u bytes", ACPI_FORMAT_UINT64 (Value), ByteLength); DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } ACPI_MEMCPY (Buffer, &Value, ByteLength); return;}
开发者ID:coyizumi,项目名称:cs111,代码行数:82,
示例23: acpi_ut_copy_simple_objectacpi_statusacpi_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; /* Handle the objects with extra data */ switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { case ACPI_TYPE_BUFFER: dest_desc->buffer.node = NULL; dest_desc->common.flags = source_desc->common.flags; /* * Allocate and copy the actual buffer if and only if: * 1) There is a valid buffer pointer * 2) The buffer is not static (not in an ACPI table) (in this case, * the actual pointer was already copied above) */ if ((source_desc->buffer.pointer) && (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { dest_desc->buffer.pointer = NULL; /* Create an actual buffer only if length > 0 */ if (source_desc->buffer.length) { dest_desc->buffer.pointer = ACPI_MEM_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 * 2) The string is not static (not in an ACPI table) (in this case, * the actual pointer was already copied above) */ if ((source_desc->string.pointer) && (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { dest_desc->string.pointer = ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); } 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);}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:96,
示例24: acpi_ev_create_gpe_blockacpi_statusacpi_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; 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->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); return_ACPI_STATUS(status); } /* Find all GPE methods (_Lxx, _Exx) for this block */ status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, gpe_block, NULL); /* Return the new block */ if (return_gpe_block) { (*return_gpe_block) = gpe_block; } ACPI_DEBUG_PRINT((ACPI_DB_INIT, "GPE %02X to %02X [%4.4s] %u regs on int 0x%X/n", (u32) gpe_block->block_base_number, (u32) (gpe_block->block_base_number + ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) - 1)), gpe_device->name.ascii, gpe_block->register_count, interrupt_number)); /* Update global count of currently available GPEs */ acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH; return_ACPI_STATUS(AE_OK);}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:78,
注:本文中的ACPI_MEMCPY函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ACPI_MEMSET函数代码示例 C++ ACPI_IS_ROOT_PREFIX函数代码示例 |