#define DB_DEFAULT_PKG_ELEMENTS 33 /******************************************************************************* * * FUNCTION: acpi_db_hex_char_to_value * * PARAMETERS: hex_char - Ascii Hex digit, 0-9|a-f|A-F * return_value - Where the converted value is returned * * RETURN: Status * * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16). *
******************************************************************************/
acpi_status acpi_db_hex_char_to_value(int hex_char, u8 *return_value)
{
u8 value;
/* Digit must be ascii [0-9a-fA-F] */
if (!isxdigit(hex_char)) { return (AE_BAD_HEX_CONSTANT);
}
if (hex_char <= 0x39) {
value = (u8)(hex_char - 0x30);
} else {
value = (u8)(toupper(hex_char) - 0x37);
}
*return_value = value; return (AE_OK);
}
/******************************************************************************* * * FUNCTION: acpi_db_hex_byte_to_binary * * PARAMETERS: hex_byte - Double hex digit (0x00 - 0xFF) in format: * hi_byte then lo_byte. * return_value - Where the converted value is returned * * RETURN: Status * * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255). *
******************************************************************************/
/******************************************************************************* * * FUNCTION: acpi_db_convert_to_buffer * * PARAMETERS: string - Input string to be converted * object - Where the buffer object is returned * * RETURN: Status * * DESCRIPTION: Convert a string to a buffer object. String is treated a list * of buffer elements, each separated by a space or comma. *
******************************************************************************/
buffer = ACPI_ALLOCATE(length); if (!buffer) { return (AE_NO_MEMORY);
}
/* Convert the command line bytes to the buffer */
for (i = 0, j = 0; string[i];) {
status = acpi_db_hex_byte_to_binary(&string[i], &buffer[j]); if (ACPI_FAILURE(status)) {
ACPI_FREE(buffer); return (status);
}
j++;
i += 2; while (string[i] && ((string[i] == ',') || (string[i] == ' '))) {
i++;
}
}
/******************************************************************************* * * FUNCTION: acpi_db_convert_to_package * * PARAMETERS: string - Input string to be converted * object - Where the package object is returned * * RETURN: Status * * DESCRIPTION: Convert a string to a package object. Handles nested packages * via recursion with acpi_db_convert_to_object. *
******************************************************************************/
acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object)
{ char *this; char *next;
u32 i;
acpi_object_type type; union acpi_object *elements;
acpi_status status;
elements =
ACPI_ALLOCATE_ZEROED(DB_DEFAULT_PKG_ELEMENTS * sizeof(union acpi_object)); if (!elements) return (AE_NO_MEMORY);
this = string; for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) { this = acpi_db_get_next_token(this, &next, &type); if (!this) { break;
}
/* Recursive call to convert each package element */
status = acpi_db_convert_to_object(type, this, &elements[i]); if (ACPI_FAILURE(status)) {
acpi_db_delete_objects(i + 1, elements);
ACPI_FREE(elements); return (status);
}
/******************************************************************************* * * FUNCTION: acpi_db_convert_to_object * * PARAMETERS: type - Object type as determined by parser * string - Input string to be converted * object - Where the new object is returned * * RETURN: Status * * DESCRIPTION: Convert a typed and tokenized string to a union acpi_object. Typing: * 1) String objects were surrounded by quotes. * 2) Buffer objects were surrounded by parentheses. * 3) Package objects were surrounded by brackets "[]". * 4) All standalone tokens are treated as integers. *
******************************************************************************/
acpi_status
acpi_db_convert_to_object(acpi_object_type type, char *string, union acpi_object *object)
{
acpi_status status = AE_OK;
status = acpi_db_convert_to_buffer(string, object); break;
case ACPI_TYPE_PACKAGE:
status = acpi_db_convert_to_package(string, object); break;
default:
object->type = ACPI_TYPE_INTEGER;
status = acpi_ut_strtoul64(string, &object->integer.value); break;
}
return (status);
}
/******************************************************************************* * * FUNCTION: acpi_db_encode_pld_buffer * * PARAMETERS: pld_info - _PLD buffer struct (Using local struct) * * RETURN: Encode _PLD buffer suitable for return value from _PLD * * DESCRIPTION: Bit-packs a _PLD buffer struct. Used to test the _PLD macros *
******************************************************************************/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.