ACPI_STATUS AcpiUtCreateMutex ( ACPI_MUTEX_HANDLE MutexId) { ACPI_STATUS Status = AE_OK; FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); if (MutexId > MAX_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!AcpiGbl_AcpiMutexInfo[MutexId].Mutex) { Status = AcpiOsCreateSemaphore (1, 1, &AcpiGbl_AcpiMutexInfo[MutexId].Mutex); AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; AcpiGbl_AcpiMutexInfo[MutexId].UseCount = 0; } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDsMethodDataGetEntry ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT ***Entry) { FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); /* * Get the requested object. * The stack "Opcode" is either a LocalVariable or an Argument */ switch (Opcode) { case AML_LOCAL_OP: if (Index > MTH_MAX_LOCAL) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "LocalVar index %d is invalid (max %d)\n", Index, MTH_MAX_LOCAL)); return_ACPI_STATUS (AE_BAD_PARAMETER); } *Entry = (ACPI_OPERAND_OBJECT **) &WalkState->LocalVariables[Index].Object; break; case AML_ARG_OP: if (Index > MTH_MAX_ARG) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", Index, MTH_MAX_ARG)); return_ACPI_STATUS (AE_BAD_PARAMETER); } *Entry = (ACPI_OPERAND_OBJECT **) &WalkState->Arguments[Index].Object; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); return_ACPI_STATUS (AE_BAD_PARAMETER); } return_ACPI_STATUS (AE_OK); }
static ACPI_STATUS EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UINT32 *Value, void *Context, void *RegionContext) { struct acpi_ec_softc *sc = Context; ACPI_STATUS Status = AE_OK; EC_REQUEST EcRequest; int i; FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Address); if ((Address > 0xFF) || (width % 8 != 0) || (Value == NULL) || (Context == NULL)) return_ACPI_STATUS(AE_BAD_PARAMETER); switch (Function) { case ACPI_READ_ADR_SPACE: EcRequest.Command = EC_COMMAND_READ; EcRequest.Address = Address; (*Value) = 0; break; case ACPI_WRITE_ADR_SPACE: EcRequest.Command = EC_COMMAND_WRITE; EcRequest.Address = Address; break; default: printf("%s: invalid Address Space function: %d\n", sc->sc_dev.dv_xname, Function); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Perform the transaction. */ (*Value) = 0; for (i = 0; i < width; i += 8) { if (Function == ACPI_READ_ADR_SPACE) EcRequest.Data = 0; else EcRequest.Data = (UINT8)((*Value) >> i); if ((Status = EcTransaction(sc, &EcRequest)) != AE_OK) break; (*Value) |= (UINT32)EcRequest.Data << i; if (++EcRequest.Address == 0) return_ACPI_STATUS(AE_BAD_PARAMETER); } return_ACPI_STATUS(Status); }
void acpi_tb_delete_acpi_table ( acpi_table_type type) { FUNCTION_TRACE_U32 ("Tb_delete_acpi_table", type); if (type > ACPI_TABLE_MAX) { return_VOID; } acpi_ut_acquire_mutex (ACPI_MTX_TABLES); /* Free the table */ acpi_tb_free_acpi_tables_of_type (&acpi_gbl_acpi_tables[type]); /* Clear the appropriate "typed" global table pointer */ switch (type) { case ACPI_TABLE_RSDP: acpi_gbl_RSDP = NULL; break; case ACPI_TABLE_DSDT: acpi_gbl_DSDT = NULL; break; case ACPI_TABLE_FADT: acpi_gbl_FADT = NULL; break; case ACPI_TABLE_FACS: acpi_gbl_FACS = NULL; break; case ACPI_TABLE_XSDT: acpi_gbl_XSDT = NULL; break; case ACPI_TABLE_SSDT: case ACPI_TABLE_PSDT: default: break; } acpi_ut_release_mutex (ACPI_MTX_TABLES); return_VOID; }
acpi_status acpi_ds_method_data_get_entry ( u16 opcode, u32 index, acpi_walk_state *walk_state, acpi_operand_object ***entry) { FUNCTION_TRACE_U32 ("Ds_method_data_get_entry", index); /* * Get the requested object. * The stack "Opcode" is either a Local_variable or an Argument */ switch (opcode) { case AML_LOCAL_OP: if (index > MTH_MAX_LOCAL) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local_var index %d is invalid (max %d)\n", index, MTH_MAX_LOCAL)); return_ACPI_STATUS (AE_BAD_PARAMETER); } *entry = (acpi_operand_object **) &walk_state->local_variables[index].object; break; case AML_ARG_OP: if (index > MTH_MAX_ARG) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", index, MTH_MAX_ARG)); return_ACPI_STATUS (AE_BAD_PARAMETER); } *entry = (acpi_operand_object **) &walk_state->arguments[index].object; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); return_ACPI_STATUS (AE_BAD_PARAMETER); } return_ACPI_STATUS (AE_OK); }
void * AcpiUtAllocate ( UINT32 Size, UINT32 Component, NATIVE_CHAR *Module, UINT32 Line) { ACPI_DEBUG_MEM_BLOCK *Address; ACPI_STATUS Status; FUNCTION_TRACE_U32 ("UtAllocate", Size); /* Check for an inadvertent size of zero bytes */ if (!Size) { _REPORT_ERROR (Module, Line, Component, ("UtAllocate: Attempt to allocate zero bytes\n")); Size = 1; } Address = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK)); if (!Address) { /* Report allocation error */ _REPORT_ERROR (Module, Line, Component, ("UtAllocate: Could not allocate size %X\n", Size)); return_PTR (NULL); } Status = AcpiUtAddElementToAllocList (ACPI_MEM_LIST_GLOBAL, Address, Size, MEM_MALLOC, Component, Module, Line); if (ACPI_FAILURE (Status)) { AcpiOsFree (Address); return_PTR (NULL); } AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++; AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += Size; ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", Address, Size)); return_PTR ((void *) &Address->UserSpace); }
u32 acpi_ns_opens_scope ( acpi_object_type8 type) { FUNCTION_TRACE_U32 ("Ns_opens_scope", type); if (!acpi_ut_valid_object_type (type)) { /* type code out of range */ REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n")); return_VALUE (NSP_NORMAL); } return_VALUE (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE); }
acpi_status acpi_ut_delete_mutex ( ACPI_MUTEX_HANDLE mutex_id) { acpi_status status; FUNCTION_TRACE_U32 ("Ut_delete_mutex", mutex_id); if (mutex_id > MAX_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } status = acpi_os_delete_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex); acpi_gbl_acpi_mutex_info[mutex_id].mutex = NULL; acpi_gbl_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; return_ACPI_STATUS (status); }
static ACPI_STATUS EcWaitEventIntr(struct acpi_ec_softc *sc, EC_EVENT Event) { EC_STATUS EcStatus; int i; FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Event); /* XXX Need better test for "yes, you have interrupts". */ if (cold) return_ACPI_STATUS(EcWaitEvent(sc, Event)); if (EcIsLocked(sc) == 0) printf("%s: EcWaitEventIntr called without EC lock!\n", sc->sc_dev.dv_xname); EcStatus = EC_CSR_READ(sc); /* Too long? */ for (i = 0; i < 10; i++) { /* Check EC status against the desired event. */ if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && (EcStatus & EC_FLAG_OUTPUT_BUFFER) != 0) return_ACPI_STATUS(AE_OK); if ((Event == EC_EVENT_INPUT_BUFFER_EMPTY) && (EcStatus & EC_FLAG_INPUT_BUFFER) == 0) return_ACPI_STATUS(AE_OK); sc->sc_csrvalue = 0; /* XXXJRT Sleeping with a lock held? */ if (tsleep(&sc->sc_csrvalue, 0, "EcWait", 1) != EWOULDBLOCK) EcStatus = sc->sc_csrvalue; else EcStatus = EC_CSR_READ(sc); } return_ACPI_STATUS(AE_ERROR); }
ACPI_STATUS AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE MutexId) { ACPI_STATUS Status; FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); if (MutexId > MAX_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiOsDeleteSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex); AcpiGbl_AcpiMutexInfo[MutexId].Mutex = NULL; AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; return_ACPI_STATUS (Status); }
acpi_status acpi_ut_create_mutex ( ACPI_MUTEX_HANDLE mutex_id) { acpi_status status = AE_OK; FUNCTION_TRACE_U32 ("Ut_create_mutex", mutex_id); if (mutex_id > MAX_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!acpi_gbl_acpi_mutex_info[mutex_id].mutex) { status = acpi_os_create_semaphore (1, 1, &acpi_gbl_acpi_mutex_info[mutex_id].mutex); acpi_gbl_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_acpi_mutex_info[mutex_id].use_count = 0; } return_ACPI_STATUS (status); }
acpi_status acpi_tb_init_table_descriptor ( acpi_table_type table_type, acpi_table_desc *table_info) { acpi_table_desc *list_head; acpi_table_desc *table_desc; FUNCTION_TRACE_U32 ("Tb_init_table_descriptor", table_type); /* * Install the table into the global data structure */ list_head = &acpi_gbl_acpi_tables[table_type]; table_desc = list_head; /* * Two major types of tables: 1) Only one instance is allowed. This * includes most ACPI tables such as the DSDT. 2) Multiple instances of * the table are allowed. This includes SSDT and PSDTs. */ if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) { /* * Only one table allowed, and a table has alread been installed * at this location, so return an error. */ if (list_head->pointer) { return_ACPI_STATUS (AE_EXIST); } table_desc->count = 1; } else { /* * Multiple tables allowed for this table type, we must link * the new table in to the list of tables of this type. */ if (list_head->pointer) { table_desc = ACPI_MEM_CALLOCATE (sizeof (acpi_table_desc)); if (!table_desc) { return_ACPI_STATUS (AE_NO_MEMORY); } list_head->count++; /* Update the original previous */ list_head->prev->next = table_desc; /* Update new entry */ table_desc->prev = list_head->prev; table_desc->next = list_head; /* Update list head */ list_head->prev = table_desc; } else { table_desc->count = 1; } } /* Common initialization of the table descriptor */ table_desc->pointer = table_info->pointer; table_desc->base_pointer = table_info->base_pointer; table_desc->length = table_info->length; table_desc->allocation = table_info->allocation; table_desc->aml_start = (u8 *) (table_desc->pointer + 1), table_desc->aml_length = (u32) (table_desc->length - (u32) sizeof (acpi_table_header)); table_desc->table_id = acpi_ut_allocate_owner_id (OWNER_TYPE_TABLE); table_desc->loaded_into_namespace = FALSE; /* * Set the appropriate global pointer (if there is one) to point to the * newly installed table */ if (acpi_gbl_acpi_table_data[table_type].global_ptr) { *(acpi_gbl_acpi_table_data[table_type].global_ptr) = table_info->pointer; } /* Return Data */ table_info->table_id = table_desc->table_id; table_info->installed_desc = table_desc; return_ACPI_STATUS (AE_OK); }
void AcpiPsGetNextSimpleArg ( ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg) { FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); switch (ArgType) { case ARGP_BYTEDATA: AcpiPsInitOp (Arg, AML_BYTE_OP); Arg->Value.Integer = (UINT32) GET8 (ParserState->Aml); ParserState->Aml++; break; case ARGP_WORDDATA: AcpiPsInitOp (Arg, AML_WORD_OP); /* Get 2 bytes from the AML stream */ MOVE_UNALIGNED16_TO_32 (&Arg->Value.Integer, ParserState->Aml); ParserState->Aml += 2; break; case ARGP_DWORDDATA: AcpiPsInitOp (Arg, AML_DWORD_OP); /* Get 4 bytes from the AML stream */ MOVE_UNALIGNED32_TO_32 (&Arg->Value.Integer, ParserState->Aml); ParserState->Aml += 4; break; case ARGP_QWORDDATA: AcpiPsInitOp (Arg, AML_QWORD_OP); /* Get 8 bytes from the AML stream */ MOVE_UNALIGNED64_TO_64 (&Arg->Value.Integer, ParserState->Aml); ParserState->Aml += 8; break; case ARGP_CHARLIST: AcpiPsInitOp (Arg, AML_STRING_OP); Arg->Value.String = (char*) ParserState->Aml; while (GET8 (ParserState->Aml) != '\0') { ParserState->Aml++; } ParserState->Aml++; break; case ARGP_NAME: case ARGP_NAMESTRING: AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); Arg->Value.Name = AcpiPsGetNextNamestring (ParserState); break; } return_VOID; }