|
PatchworkOS
|
Data Type Conversion. More...
Functions | |
| uint64_t | aml_convert (aml_state_t *state, aml_object_t *src, aml_object_t *dest, aml_type_t allowedTypes) |
| Converts the data in the source object to a allowed type and stores it in the destination object. | |
| uint64_t | aml_convert_result (aml_state_t *state, aml_object_t *result, aml_object_t *target) |
| Performs a "Implicit Result Object Conversion" acording to the rules in section 19.3.5.5 of the ACPI specification. | |
| uint64_t | aml_convert_source (aml_state_t *state, aml_object_t *src, aml_object_t **dest, aml_type_t allowedTypes) |
| Performs a "Implicit Source Operand Conversion" acording to the rules in section 19.3.5.4 of the ACPI specification. | |
| uint64_t | aml_convert_to_buffer (aml_state_t *state, aml_object_t *src, aml_object_t **dest) |
| Converts a Integer, String or Buffer source object to a Buffer destination object. | |
| uint64_t | aml_convert_to_decimal_string (aml_state_t *state, aml_object_t *src, aml_object_t **dest) |
| Converts a Integer, String or Buffer source object to a String destination object in decimal format. | |
| uint64_t | aml_convert_to_hex_string (aml_state_t *state, aml_object_t *src, aml_object_t **dest) |
| Converts a Integer, String or Buffer source object to a String destination object in hexadecimal format. | |
| uint64_t | aml_convert_to_integer (aml_state_t *state, aml_object_t *src, aml_object_t **dest) |
| Converts a Integer, String or Buffer source object to an Integer destination object. | |
| uint64_t | aml_convert_integer_to_bcd (aml_integer_t value, aml_integer_t *out) |
| Converts an integer to its Binary-Coded Decimal (BCD) representation. | |
Data Type Conversion.
| uint64_t aml_convert | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t * | dest, | ||
| aml_type_t | allowedTypes | ||
| ) |
Converts the data in the source object to a allowed type and stores it in the destination object.
Follows the rules in table 19.6 section 19.3.5.6 of the ACPI specification.
See Section 19.3.5.6 of the ACPI specification for more details.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert. |
| dest | Pointer to the destination object where the converted value will be stored, can be of type AML_UNINITIALIZED. |
0. On failure, ERR and errno is set. Definition at line 369 of file convert.c.
References AML_BUFFER_FIELD, aml_buffer_field_load(), aml_convert(), AML_CONVERT_TRY_NEXT_CONVERTER, aml_converters_get(), aml_copy_data_and_type(), AML_FIELD_UNIT, aml_field_unit_load(), aml_object_new(), AML_TYPE_AMOUNT, aml_type_to_string(), AML_UNINITIALIZED, aml_object_t::bufferField, aml_convert_entry_t::convertFunc, DEREF_DEFER, aml_convert_entry_t::destType, EILSEQ, EINVAL, ENOSYS, ERR, errno, aml_object_t::fieldUnit, LOG_ERR, NULL, and aml_convert_entry_t::srcType.
Referenced by aml_convert(), aml_convert_result(), aml_convert_source(), and aml_store().
| uint64_t aml_convert_integer_to_bcd | ( | aml_integer_t | value, |
| aml_integer_t * | out | ||
| ) |
Converts an integer to its Binary-Coded Decimal (BCD) representation.
Binary-Coded decimal (BCD) is a format where instead of each bit representing a power of two, the Integer is split into its individual decimal digits, and each digit is represented by a fixed number of bits. For example, the integer 45 would be represented in BCD as 0x45 or in binary 0100 0101.
The number of bits per digit varies and the ACPI specification does not seem to specify how many should be used, nor really anything at all about BCD. However, the most common representation seems to be 4 bits per digit, which is what this function uses. The spec also does not specify what to do if the integer is too large to fit in the BCD representation, so we just ignore it. I love ACPI.
| value | The integer value to convert. |
| out | Pointer to the output buffer where the BCD representation will be stored. |
0. On failure, ERR and errno is set. Definition at line 947 of file convert.c.
References aml_integer_byte_size(), EINVAL, ERR, errno, and NULL.
Referenced by aml_def_to_bcd_read().
| uint64_t aml_convert_result | ( | aml_state_t * | state, |
| aml_object_t * | result, | ||
| aml_object_t * | target | ||
| ) |
Performs a "Implicit Result Object Conversion" acording to the rules in section 19.3.5.5 of the ACPI specification.
| state | Pointer to the current AML state. |
| result | Pointer to the result object to convert. |
| target | Pointer to the target object to store the result in. For convenience this can be NULL, in which case this does nothing. |
0. On failure, ERR and errno is set. Definition at line 489 of file convert.c.
References AML_ARG, aml_convert(), aml_copy_data_and_type(), AML_DATA_REF_OBJECTS, AML_LOCAL, aml_store(), aml_type_to_string(), AML_UNINITIALIZED, EINVAL, ERR, errno, LOG_ERR, and NULL.
Referenced by aml_copy_object(), aml_def_decrement_read(), aml_def_increment_read(), and aml_store().
| uint64_t aml_convert_source | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t ** | dest, | ||
| aml_type_t | allowedTypes | ||
| ) |
Performs a "Implicit Source Operand Conversion" acording to the rules in section 19.3.5.4 of the ACPI specification.
If dest is NULL then either, a new object is allocated and assigned to *dest, or *dest will be set to a reference src if no conversion is needed.
If dest is not NULL then the object pointed to by *dest will be set to the converted value or a copy of src if no conversion is needed.
This dest handling is to allow for the common case where the source object does not need to be converted. In which case we can avoid a allocation and a copy buts its also just a requirement. For instance if we are implementing Index and the source in a buffer well then we need the created BufferField to point to the original buffer not a copy of it.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert, if AML_ARG or AML_LOCAL, the value object will be used. |
| dest | Pointer to the object pointer where the converted value will be stored, see above for details. |
| allowedTypes | Bitmask of allowed destination types. |
0. On failure, ERR and errno is set. Definition at line 541 of file convert.c.
References AML_ARG, aml_convert(), aml_convert_source(), aml_copy_data_and_type(), AML_LOCAL, aml_object_new(), AML_UNINITIALIZED, aml_object_t::arg, DEREF, EINVAL, ERR, errno, aml_object_t::local, LOG_ERR, NULL, REF, aml_arg_obj_t::value, and aml_local_obj_t::value.
Referenced by aml_concat_resolve_to_buffer(), aml_concat_resolve_to_integer(), aml_concat_resolve_to_string(), aml_convert_source(), aml_def_decrement_read(), aml_def_increment_read(), aml_def_match_read(), aml_package_element_handle_name(), and aml_term_arg_read().
| uint64_t aml_convert_to_buffer | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t ** | dest | ||
| ) |
Converts a Integer, String or Buffer source object to a Buffer destination object.
Note that this behaviour is different from the implicit source operand conversion and implicit result object conversion rules.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert. Must be of type Integer, String or Buffer. |
| dest | Pointer to the object pointer where the converted value will be stored, see aml_convert_source for details. |
0. On failure, ERR and errno is set. Definition at line 598 of file convert.c.
References AML_BUFFER, AML_INTEGER, aml_integer_to_buffer(), aml_object_new(), AML_STRING, aml_string_to_buffer(), aml_type_to_string(), AML_UNINITIALIZED, DEREF_DEFER, EILSEQ, EINVAL, ERR, errno, LOG_ERR, NULL, and REF.
Referenced by aml_def_to_buffer_read().
| uint64_t aml_convert_to_decimal_string | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t ** | dest | ||
| ) |
Converts a Integer, String or Buffer source object to a String destination object in decimal format.
Note that this behaviour is different from the implicit source operand conversion and implicit result object conversion rules.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert. Must be of type Integer, String or Buffer. |
| dest | Pointer to the object pointer where the converted value will be stored, see aml_convert_source for details. |
0. On failure, ERR and errno is set. Definition at line 651 of file convert.c.
References AML_BUFFER, AML_INTEGER, aml_object_new(), AML_STRING, aml_string_prepare(), aml_string_set_empty(), aml_type_to_string(), AML_UNINITIALIZED, aml_object_t::buffer, buffer, aml_buffer_obj_t::content, aml_string_obj_t::content, DEREF_DEFER, EILSEQ, EINVAL, ERR, errno, free(), aml_object_t::integer, aml_buffer_obj_t::length, LOG_ERR, malloc(), memcpy(), NULL, REF, snprintf(), aml_object_t::string, and aml_integer_obj_t::value.
Referenced by aml_def_to_decimal_string_read().
| uint64_t aml_convert_to_hex_string | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t ** | dest | ||
| ) |
Converts a Integer, String or Buffer source object to a String destination object in hexadecimal format.
Note that this behaviour is different from the implicit source operand conversion and implicit result object conversion rules.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert. Must be of type Integer, String or Buffer. |
| dest | Pointer to the object pointer where the converted value will be stored, see aml_convert_source for details. |
0. On failure, ERR and errno is set. Definition at line 757 of file convert.c.
References AML_BUFFER, aml_byte_to_hex(), AML_INTEGER, aml_object_new(), AML_STRING, aml_string_set_empty(), aml_type_to_string(), AML_UNINITIALIZED, aml_object_t::buffer, buffer, aml_buffer_obj_t::content, aml_string_obj_t::content, DEREF, DEREF_DEFER, EILSEQ, EINVAL, ERR, errno, aml_object_t::integer, aml_buffer_obj_t::length, LOG_ERR, memcpy(), NULL, REF, snprintf(), aml_object_t::string, and aml_integer_obj_t::value.
Referenced by aml_def_to_hex_string_read().
| uint64_t aml_convert_to_integer | ( | aml_state_t * | state, |
| aml_object_t * | src, | ||
| aml_object_t ** | dest | ||
| ) |
Converts a Integer, String or Buffer source object to an Integer destination object.
Note that this behaviour is different from the implicit source operand conversion and implicit result object conversion rules.
| state | Pointer to the current AML state. |
| src | Pointer to the source object to convert. Must be of type Integer, String or Buffer. |
| dest | Pointer to the object pointer where the converted value will be stored, see aml_convert_source for details. |
0. On failure, ERR and errno is set. Definition at line 847 of file convert.c.
References AML_BUFFER, aml_buffer_to_integer(), aml_hex_to_byte(), AML_INTEGER, aml_integer_set(), aml_object_new(), AML_STRING, aml_type_to_string(), AML_UNINITIALIZED, aml_string_obj_t::content, DEREF_DEFER, EILSEQ, EINVAL, ERR, errno, aml_string_obj_t::length, LOG_ERR, NULL, REF, and aml_object_t::string.
Referenced by aml_def_to_integer_read().