21#ifndef UACPI_BAREBONES_MODE
74 struct op_context_array *arr
79 size = op_context_array_size(arr);
84 return op_context_array_at(arr,
size - 2);
119 slot = held_mutexes_array_alloc(arr);
134 size = held_mutexes_array_inline_capacity(arr);
139 size = arr->size_including_inline -
size;
143 &arr->dynamic_storage[
i], &arr->dynamic_storage[
i + 1],
144 size *
sizeof(arr->inline_storage[0])
147 held_mutexes_array_pop(arr);
152 arr->size_including_inline);
155 &arr->inline_storage[
i], &arr->inline_storage[
i + 1],
156 size *
sizeof(arr->inline_storage[0])
159 size = held_mutexes_array_size(arr);
160 i = held_mutexes_array_inline_capacity(arr);
168 arr->inline_storage[
i - 1] = arr->dynamic_storage[0];
172 &arr->dynamic_storage[0], &arr->dynamic_storage[1],
173 size *
sizeof(arr->inline_storage[0])
177 held_mutexes_array_pop(arr);
196 item = *held_mutexes_array_last(arr);
201 "ignoring mutex @%p release due to sync level mismatch: %d vs %d\n",
216 held_mutexes_array_pop(arr);
226 i = held_mutexes_array_size(arr);
228 item = *held_mutexes_array_at(arr, --
i);
259 slot = temp_namespace_node_array_alloc(arr);
309 struct call_frame_array *arr
314 size = call_frame_array_size(arr);
319 return call_frame_array_at(arr,
size - 2);
337#define AML_READ(ptr, offset) (*(((uacpi_u8*)(ptr)) + offset))
369 uacpi_size bytes_left, prefix_bytes, nameseg_bytes = 0, namesegs;
396 if (prev_char !=
'^')
417 uacpi_error(
"MultiNamePrefix but SegCount is 0\n");
442 nameseg_bytes = namesegs * 4;
445 nameseg_bytes += namesegs - 1;
448 *
out_size = nameseg_bytes + prefix_bytes + 1;
456 base_cursor = *out_string;
457 base_cursor += prefix_bytes;
459 while (namesegs-- > 0) {
465 *base_cursor++ =
'.';
499 if (prev_char ==
'^')
509 cur_node = cur_node->
parent;
528 if (prev_char !=
'^')
549 uacpi_error(
"MultiNamePrefix but SegCount is 0\n");
577 for (; namesegs;
cursor += 4, namesegs--) {
607 if (just_one_nameseg) {
633 *out_node = cur_node;
646 if (!frame->
method->named_objects_persist)
698 "invalid opcode '%s' encountered in bytestream\n",
715 aml_offset = item_array_at(&op_ctx->
items, 2)->immediate;
716 src =
ctx->cur_frame->method->code;
719 pkg = &item_array_at(&op_ctx->
items, 0)->pkg;
720 init_size = pkg->
end - aml_offset;
726 declared_size = item_array_at(&op_ctx->
items, 1)->obj;
730 "buffer is too large (%"UACPI_PRIu64"), assuming corrupted "
737 uacpi_error(
"attempted to create an empty buffer\n");
744 "too many buffer initializers: %u (size is %u)\n",
750 dst = item_array_at(&op_ctx->
items, 3)->obj;
768 obj = item_array_last(&
ctx->cur_op_ctx->items)->obj;
792 uacpi_u32 num_elements, num_defined_elements,
i;
801 package = item_array_last(&op_ctx->items)->obj->package;
804 if (op_ctx->
op->code == UACPI_AML_OP_VarPackageOp) {
807 var_num_elements = item_array_at(&op_ctx->
items, 1)->obj;
815 num_elements = var_num_elements->
integer;
817 num_elements = item_array_at(&op_ctx->
items, 1)->immediate;
820 num_defined_elements = (item_array_size(&op_ctx->
items) - 3) / 2;
823 "too many package initializers: %u, truncating to %u\n",
824 num_defined_elements, num_elements
827 num_defined_elements = num_elements;
836 for (
i = 0;
i < num_defined_elements; ++
i) {
842 base_pkg_index = (
i * 2) + 2;
843 item = item_array_at(&op_ctx->
items, base_pkg_index + 1);
874 item_array_at(&op_ctx->
items, base_pkg_index)->immediate,
913 if (out_buf->
length && !include_null)
916 out_buf->
text =
obj->buffer->text;
919 if (
obj->buffer->size == 0) {
942 out_cursor += buf_idx->
idx;
1011 "attempted to perform an invalid implicit cast (%s -> %s)\n",
1054 dst = item_array_last(&
ctx->cur_op_ctx->items);
1067 idx = op_ctx->
op->code - UACPI_AML_OP_Local0Op;
1076 idx = op_ctx->
op->code - UACPI_AML_OP_Arg0Op;
1085 src = item_array_at(&
ctx->cur_op_ctx->items, 0)->node;
1086 dst = item_array_at(&
ctx->cur_op_ctx->items, 1);
1099 src = item_array_at(&
ctx->cur_op_ctx->items, 0)->node;
1100 dst = item_array_at(&
ctx->cur_op_ctx->items, 1)->node;
1102 dst->object =
src->object;
1116 node = item_array_at(&
ctx->cur_op_ctx->items, 0)->node;
1117 obj = item_array_at(&
ctx->cur_op_ctx->items, 4)->obj;
1118 op_region =
obj->op_region;
1120 op_region->
space = item_array_at(&
ctx->cur_op_ctx->items, 1)->immediate;
1121 op_region->
offset = item_array_at(&
ctx->cur_op_ctx->items, 2)->obj->integer;
1122 op_region->
length = item_array_at(&
ctx->cur_op_ctx->items, 3)->obj->integer;
1127 uacpi_warn(
"unusable/empty operation region %.4s\n",
node->name.text);
1130 "invalid operation region %.4s bounds: offset=0x%"UACPI_PRIX64
1139 "invalid PCC operation region %.4s subspace %"UACPI_PRIX64"\n",
1169 "%s: unable to find table '%.4s' (OEM ID '%.6s', "
1170 "OEM Table ID '%.8s'): %s\n",
1171 opcode,
id->signature.text,
id->oemid,
id->oem_table_id,
1203 oem_table_id->
size ? oem_table_id->
size - 1 : 0
1212 struct item_array *
items = &
ctx->cur_op_ctx->items;
1222 "DataTableRegion", &table_id,
1223 item_array_at(
items, 1)->
obj->buffer,
1224 item_array_at(
items, 2)->
obj->buffer,
1225 item_array_at(
items, 3)->
obj->buffer
1236 obj = item_array_at(
items, 4)->obj;
1237 op_region =
obj->op_region;
1262 struct acpi_dsdt *dsdt =
ptr;
1268 "host-invoked load of" :
"dynamic load of";
1277 in_method->
code = dsdt->definition_block;
1278 in_method->
size = dsdt->hdr.length -
sizeof(dsdt->hdr);
1305 struct item_array *
items = &
ctx->cur_op_ctx->items;
1306 struct item *root_node_item;
1319 if (item_array_size(
items) == 12) {
1322 idx = item_array_at(
items, 2)->immediate;
1346 "LoadTable", &table_id,
1347 item_array_at(
items, 5)->
obj->buffer,
1348 item_array_at(
items, 6)->
obj->buffer,
1349 item_array_at(
items, 7)->
obj->buffer
1354 root_path = item_array_at(
items, 8)->obj->buffer;
1355 param_path = item_array_at(
items, 9)->obj->buffer;
1356 root_node_item = item_array_at(
items, 0);
1358 if (root_path->
size > 1) {
1374 root_node_item->
node = root_node;
1378 if (param_path->
size > 1) {
1379 struct item *param_item;
1393 param_item = item_array_at(
items, 3);
1406 item_array_at(
items, 2)->immediate =
table.index;
1416 struct item_array *
items = &
ctx->cur_op_ctx->items;
1431 if (item_array_size(
items) == 5) {
1432 if (item_array_at(
items, 4)->
obj->integer != 0)
1437 src = item_array_at(
items, 2)->obj;
1439 switch (
src->type) {
1443 op_region =
src->op_region;
1447 uacpi_error(
"Load: operation region is not SystemMemory\n");
1453 "Load: operation region is too small: %"UACPI_PRIu64"\n",
1462 "Load: failed to map operation region "
1471 declared_size = op_region->
length;
1479 if (
buffer->size <
sizeof(
struct acpi_sdt_hdr)) {
1481 "Load: buffer is too small: %zu\n",
1487 src_table =
buffer->data;
1488 declared_size =
buffer->size;
1494 "Load: invalid argument '%s', expected "
1495 "Buffer/Field/OperationRegion\n",
1503 "Load: table size %u is larger than the declared size %zu\n",
1504 src_table->length, declared_size
1509 if (
uacpi_unlikely(src_table->length <
sizeof(
struct acpi_sdt_hdr))) {
1510 uacpi_error(
"Load: table size %u is too small\n", src_table->length);
1518 uacpi_memcpy(table_buffer, src_table, src_table->length);
1544 if (unmap_src && src_table)
1584 "invalid argument: '%.4s' is not a field unit (%s)\n",
1590 *out_field =
obj->field_unit;
1602 "invalid argument: '%.4s' is not an operation region (%s)\n",
1622 uacpi_u8 raw_value, access_type, lock_rule, update_rule;
1623 uacpi_u8 access_attrib = 0, access_length = 0;
1625 switch (op_ctx->
op->code) {
1626 case UACPI_AML_OP_FieldOp:
1627 node = item_array_at(&op_ctx->
items,
i++)->node;
1633 case UACPI_AML_OP_BankFieldOp:
1634 node = item_array_at(&op_ctx->
items,
i++)->node;
1639 node = item_array_at(&op_ctx->
items,
i++)->node;
1644 field_data.
value = item_array_at(&op_ctx->
items,
i++)->obj->integer;
1647 case UACPI_AML_OP_IndexFieldOp:
1648 node = item_array_at(&op_ctx->
items,
i++)->node;
1653 node = item_array_at(&op_ctx->
items,
i++)->node;
1683 raw_value = item_array_at(&op_ctx->
items,
i++)->immediate;
1684 access_type = (raw_value >> 0) & 0b1111;
1685 lock_rule = (raw_value >> 4) & 0b1;
1686 update_rule = (raw_value >> 5) & 0b11;
1688 while (
i < item_array_size(&op_ctx->
items)) {
1699 obj = item_array_at(&op_ctx->
items,
i++)->obj;
1702 field->update_rule = update_rule;
1703 field->lock_rule = lock_rule;
1704 field->attributes = access_attrib;
1705 field->access_length = access_length;
1717 switch (access_type) {
1723 field->access_width_bytes = 1;
1726 field->access_width_bytes = 2;
1729 field->access_width_bytes = 4;
1732 field->access_width_bytes = 8;
1735 uacpi_error(
"invalid field '%.4s' access type %d\n",
1736 node->name.text, access_type);
1741 field->pin_offset = pin_offset;
1746 field->access_width_bytes,
1750 field->bit_offset_within_first_byte = bit_offset;
1751 field->bit_offset_within_first_byte =
1752 bit_offset & ((
field->access_width_bytes * 8) - 1);
1754 switch (op_ctx->
op->code) {
1755 case UACPI_AML_OP_FieldOp:
1762 case UACPI_AML_OP_BankFieldOp:
1773 case UACPI_AML_OP_IndexFieldOp:
1787 field->connection = connection_obj;
1788 if (
field->connection)
1819 raw_value = item_array_at(&op_ctx->
items,
i++)->immediate;
1821 access_type = raw_value & 0b1111;
1822 access_attrib = (raw_value >> 6) & 0b11;
1824 raw_value = item_array_at(&op_ctx->
items,
i++)->immediate;
1834 if (access_attrib) {
1835 switch (access_attrib) {
1847 access_length = raw_value;
1849 access_attrib = raw_value;
1853 access_length = item_array_at(&op_ctx->
items,
i++)->immediate;
1858 connection_obj = item_array_at(&op_ctx->
items,
i++)->obj;
1875 obj->integer &= 0xFFFFFFFF;
1889 depth = call_frame_array_size(&
ctx->call_stack);
1894 frame = call_frame_array_at(&
ctx->call_stack,
depth - 2);
1911 op_ctx->
op->code == UACPI_AML_OP_LoadTableOp)) {
1916 *out_operand = item_array_last(&op_ctx->
items)->obj;
1930 *out_obj =
ctx->ret;
1945 i = code_block_array_size(
blocks);
1981 pkg = &item_array_at(&op_ctx->
items, 0)->pkg;
1986 switch (op_ctx->
op->code) {
1987 case UACPI_AML_OP_IfOp:
1990 case UACPI_AML_OP_ElseOp:
1993 case UACPI_AML_OP_WhileOp:
2002 uacpi_error(
"loop time out after running for %u seconds\n",
2015 block->expiration_point +=
2019 case UACPI_AML_OP_ScopeOp:
2020 case UACPI_AML_OP_DeviceOp:
2021 case UACPI_AML_OP_ProcessorOp:
2022 case UACPI_AML_OP_PowerResOp:
2023 case UACPI_AML_OP_ThermalZoneOp:
2025 block->node = item_array_at(&op_ctx->
items, 1)->node;
2068 switch (
src->type) {
2092 "%s Package @%p (%p) (%zu elements)\n",
2098 "%s Buffer @%p (%p) (%zu bytes)\n",
2112 "%s Power Resource %d %d\n",
2113 prefix,
src->power_resource.system_level,
2114 src->power_resource.resource_order
2119 "%s Processor[%d] 0x%08X (%d)\n",
2120 prefix,
src->processor->id,
src->processor->block_address,
2121 src->processor->block_length
2126 "%s Buffer Index %p[%zu] => 0x%02X\n",
2127 prefix,
src->buffer_index.buffer->data,
src->buffer_index.idx,
2133 "%s Mutex @%p (%p => %p) sync level %d\n",
2135 src->mutex->sync_level
2205 if (
node->object == target_object) {
2252 switch (
dst->flags) {
2306 switch (
dst->flags) {
2357 dst->inner_object, src_obj, wtr_response
2366 src = item_array_at(&op_ctx->
items, 0)->obj;
2368 if (op_ctx->
op->code == UACPI_AML_OP_CondRefOfOp)
2369 dst = item_array_at(&op_ctx->
items, 2)->obj;
2371 dst = item_array_at(&op_ctx->
items, 1)->obj;
2373 if (op_ctx->
op->code == UACPI_AML_OP_DerefOfOp) {
2395 sizeof(
dst->integer), 1
2400 if (!was_a_reference) {
2402 "invalid DerefOf argument: %s, expected a reference\n",
2428 rhs =
arg1->integer;
2432 case UACPI_AML_OP_AddOp:
2435 case UACPI_AML_OP_SubtractOp:
2438 case UACPI_AML_OP_MultiplyOp:
2441 case UACPI_AML_OP_ShiftLeftOp:
2442 case UACPI_AML_OP_ShiftRightOp:
2444 if (
op == UACPI_AML_OP_ShiftLeftOp)
2452 case UACPI_AML_OP_NandOp:
2455 case UACPI_AML_OP_AndOp:
2458 case UACPI_AML_OP_NorOp:
2461 case UACPI_AML_OP_OrOp:
2464 case UACPI_AML_OP_XorOp:
2467 case UACPI_AML_OP_DivideOp:
2475 case UACPI_AML_OP_ModOp:
2477 uacpi_error(
"attempted to calculate modulo of zero\n");
2496 struct item_array *
items = &
ctx->cur_op_ctx->items;
2499 arg0 = item_array_at(
items, 0)->obj;
2502 if (
op == UACPI_AML_OP_DivideOp) {
2503 tgt0 = item_array_at(
items, 4)->obj;
2504 tgt1 = item_array_at(
items, 5)->obj;
2506 tgt0 = item_array_at(
items, 3)->obj;
2516 struct item_array *
items = &
ctx->cur_op_ctx->items;
2519 arg = item_array_at(
items, 0)->obj;
2520 tgt = item_array_at(
items, 2)->obj;
2523 case UACPI_AML_OP_NotOp:
2527 case UACPI_AML_OP_FindSetRightBitOp:
2530 case UACPI_AML_OP_FindSetLeftBitOp:
2547 "invalid index %zu, %s@%p has %zu elements\n",
2561 src = item_array_at(&op_ctx->
items, 0)->obj;
2562 idx = item_array_at(&op_ctx->
items, 1)->obj->integer;
2563 dst = item_array_at(&op_ctx->
items, 3);
2565 switch (
src->type) {
2581 buf_idx = &
dst->obj->buffer_index;
2628 "invalid argument for Index: %s, "
2629 "expected String/Buffer/Package\n",
2643 switch (
obj->type) {
2675 int_buf,
sizeof(int_buf),
2683 final_size = (
is_hex ? 2 : 0) + repr_len + 1;
2694 str->size = final_size;
2709 final_size = 4 *
buf->size;
2713 for (
i = 0;
i <
buf->size; ++
i) {
2718 else if (
value < 100)
2726 final_size +=
buf->size - 1;
2737 for (
i = 0;
i <
buf->size; ++
i) {
2739 int_buf,
sizeof(int_buf),
2740 is_hex ?
"0x%02X" :
"%d",
2752 if (
i !=
buf->size - 1)
2756 str->size = final_size;
2794 src = item_array_at(&op_ctx->
items, 0)->obj;
2795 dst = item_array_at(&op_ctx->
items, 2)->obj;
2797 switch (op_ctx->
op->code) {
2798 case UACPI_AML_OP_ToIntegerOp:
2803 case UACPI_AML_OP_ToHexStringOp:
2804 case UACPI_AML_OP_ToDecimalStringOp: {
2819 case UACPI_AML_OP_ToBufferOp: {
2835 dst->buffer->data = dst_buf;
2836 dst->buffer->size =
buf.length;
2853 src_buf = item_array_at(&op_ctx->
items, 0)->obj->buffer;
2854 req_len = item_array_at(&op_ctx->
items, 1)->obj->integer;
2855 dst_buf = item_array_at(&op_ctx->
items, 3)->obj->buffer;
2883 src = item_array_at(&op_ctx->
items, 0)->obj;
2887 "invalid argument for Mid: %s, expected String/Buffer\n",
2893 idx = item_array_at(&op_ctx->
items, 1)->obj->integer;
2894 len = item_array_at(&op_ctx->
items, 2)->obj->integer;
2895 dst = item_array_at(&op_ctx->
items, 4)->obj;
2896 dst_buf =
dst->buffer;
2922 dst_buf->
text[dst_buf->
size++] =
'\0';
2937 arg0 = item_array_at(&op_ctx->
items, 0)->obj;
2938 arg1 = item_array_at(&op_ctx->
items, 1)->obj;
2939 dst = item_array_at(&op_ctx->
items, 3)->obj;
2941 switch (arg0->
type) {
2947 buf_size = int_size * 2;
2956 uacpi_memcpy(dst_buf+ int_size, &arg1_as_int, int_size);
2980 switch (
arg1->type) {
2989 arg1_size =
size + 1;
2993 arg1_ptr =
arg1->buffer->data;
2994 arg1_size =
arg1->buffer->size;
3003 arg1_ptr = tmp_buf.
data;
3004 arg1_size = tmp_buf.
size;
3011 arg0_size = arg0_buf->
size ? arg0_buf->
size - 1 : arg0_buf->
size;
3012 buf_size = arg0_size + arg1_size;
3021 uacpi_memcpy(dst_buf + arg0_size, arg1_ptr, arg1_size);
3034 dst->buffer->data = dst_buf;
3035 dst->buffer->size = buf_size;
3049 arg0 = item_array_at(&op_ctx->
items, 0)->obj;
3050 arg1 = item_array_at(&op_ctx->
items, 1)->obj;
3051 dst = item_array_at(&op_ctx->
items, 3)->obj;
3069 dst->buffer->data = dst_buf;
3070 dst->buffer->size = dst_size;
3079 dst_buf[dst_size - 2] =
3082 dst_buf[dst_size - 1] = 0;
3092 src = item_array_at(&op_ctx->
items, 0)->obj;
3093 dst = item_array_at(&op_ctx->
items, 1)->obj;
3098 switch (
src->type) {
3104 dst->integer =
buf.length;
3109 dst->integer =
src->package->count;
3114 "invalid argument for Sizeof: %s, "
3115 "expected String/Buffer/Package\n",
3129 src = item_array_at(&op_ctx->
items, 0)->obj;
3130 dst = item_array_at(&op_ctx->
items, 1)->obj;
3147 dst = item_array_at(&op_ctx->
items, 0)->obj;
3158 time = item_array_at(&op_ctx->
items, 0)->obj->integer;
3160 if (op_ctx->
op->code == UACPI_AML_OP_SleepOp) {
3189 dst_obj = item_array_at(&op_ctx->
items, 2)->obj;
3197 if (op_ctx->
op->code == UACPI_AML_OP_FromBCDOp) {
3237 uacpi_warn(
"refusing to unload a table from AML\n");
3246 src = item_array_at(&op_ctx->
items, 0)->obj;
3247 dst = item_array_at(&op_ctx->
items, 1)->obj;
3292 else if (lhs_buf->
size > rhs_buf->
size)
3296 if (
op == UACPI_AML_OP_LLessOp)
3302 if (
op == UACPI_AML_OP_LLessOp)
3315 lhs = item_array_at(&op_ctx->
items, 0)->obj;
3316 rhs = item_array_at(&op_ctx->
items, 1)->obj;
3317 dst = item_array_at(&op_ctx->
items, 2)->obj;
3320 case UACPI_AML_OP_LEqualOp:
3321 case UACPI_AML_OP_LLessOp:
3322 case UACPI_AML_OP_LGreaterOp:
3326 "don't know how to do a logical comparison of '%s' and '%s'\n",
3333 if (
op == UACPI_AML_OP_LEqualOp)
3345 if (
op == UACPI_AML_OP_LandOp)
3346 res = lhs_int && rhs_int;
3348 res = lhs_int || rhs_int;
3394 pkg = item_array_at(&op_ctx->
items, 0)->obj->package;
3395 mop0 = item_array_at(&op_ctx->
items, 1)->immediate;
3396 operand0 = item_array_at(&op_ctx->
items, 2)->obj->integer;
3397 mop1 = item_array_at(&op_ctx->
items, 3)->immediate;
3398 operand1 = item_array_at(&op_ctx->
items, 4)->obj->integer;
3399 start_idx = item_array_at(&op_ctx->
items, 5)->obj->integer;
3400 dst = item_array_at(&op_ctx->
items, 6)->obj;
3402 for (
i = start_idx;
i < pkg->
count; ++
i) {
3445 marker_length += *
data >> 6;
3450 switch (marker_length) {
3463 size |= temp_byte << 4;
3473 "PkgLength overflow: start=%u, size=%u\n", out_pkg->
begin,
size
3491 method->args = flags_byte & 0b111;
3492 method->is_serialized = (flags_byte >> 3) & 1;
3493 method->sync_level = flags_byte >> 4;
3503 uacpi_u32 method_begin_offset, method_size;
3505 this_method =
ctx->cur_frame->method;
3506 pkg = &item_array_at(&op_ctx->
items, 0)->pkg;
3507 node = item_array_at(&op_ctx->
items, 1)->node;
3508 method_begin_offset = item_array_at(&op_ctx->
items, 3)->immediate;
3511 pkg->
end < method_begin_offset ||
3512 pkg->
end > this_method->
size)) {
3514 "invalid method %.4s bounds [%u..%u] (parent size is %u)\n",
3515 node->name.text, method_begin_offset, pkg->
end, this_method->
size
3520 dst = item_array_at(&op_ctx->
items, 4)->obj;
3523 method_size = pkg->
end - method_begin_offset;
3532 ctx->cur_frame->method->code + method_begin_offset,
3535 method->size = method_size;
3555 node = item_array_at(&op_ctx->
items, 0)->node;
3557 if (op_ctx->
op->code == UACPI_AML_OP_MutexOp) {
3558 dst = item_array_at(&op_ctx->
items, 2)->obj;
3561 dst->mutex->sync_level = item_array_at(&op_ctx->
items, 1)->immediate;
3562 dst->mutex->sync_level &= 0b1111;
3564 dst = item_array_at(&op_ctx->
items, 1)->obj;
3583 item_array_at(&op_ctx->
items, 0)->obj
3587 "%s: invalid argument '%s', expected an Event object\n",
3593 switch (op_ctx->
op->code)
3595 case UACPI_AML_OP_SignalOp:
3598 case UACPI_AML_OP_ResetOp:
3601 case UACPI_AML_OP_WaitOp: {
3605 timeout = item_array_at(&op_ctx->
items, 1)->obj->integer;
3618 item_array_at(&op_ctx->
items, 2)->obj->integer = 0;
3634 item_array_at(&op_ctx->
items, 0)->obj
3638 "%s: invalid argument '%s', expected a Mutex object\n",
3644 switch (op_ctx->
op->code)
3646 case UACPI_AML_OP_AcquireOp: {
3651 return_value = &item_array_at(&op_ctx->
items, 2)->obj->integer;
3655 "ignoring attempt to acquire mutex @%p with a lower sync level "
3656 "(%d < %d)\n",
obj->mutex,
obj->mutex->sync_level,
3677 ret = held_mutexes_array_push(&
ctx->held_mutexes,
obj->mutex);
3683 ctx->sync_level =
obj->mutex->sync_level;
3688 case UACPI_AML_OP_ReleaseOp: {
3693 "attempted to release not-previously-acquired mutex object "
3694 "@%p (%p)\n",
obj->mutex,
obj->mutex->handle
3700 &
ctx->held_mutexes,
obj->mutex,
3706 last_mutex = held_mutexes_array_last(&
ctx->held_mutexes);
3708 ctx->sync_level = 0;
3712 ctx->sync_level = (*last_mutex)->sync_level;
3731 node = item_array_at(&op_ctx->
items, 0)->node;
3732 value = item_array_at(&op_ctx->
items, 1)->obj->integer;
3743 "ignoring firmware Notify(%s, 0x%"UACPI_PRIX64") request, "
3752 uacpi_error(
"Notify() called on an invalid object %.4s\n",
3765 switch (op_ctx->
op->code) {
3766 case UACPI_AML_OP_BreakPointOp:
3770 case UACPI_AML_OP_FatalOp:
3772 req.
fatal.type = item_array_at(&op_ctx->
items, 0)->immediate;
3773 req.
fatal.code = item_array_at(&op_ctx->
items, 1)->immediate;
3774 req.
fatal.arg = item_array_at(&op_ctx->
items, 2)->obj->integer;
3793 node = item_array_at(&op_ctx->
items, 0)->node;
3794 src = item_array_at(&op_ctx->
items, 1)->obj;
3809 field->force_buffer)
3834 bit_length =
obj->buffer_field.bit_length;
3857 node = item_array_at(&op_ctx->
items, 0)->node;
3859 dst_obj = item_array_at(&op_ctx->
items, 1)->obj;
3861 if (op_ctx->
op->code == UACPI_AML_OP_InternalOpReadFieldAsBuffer) {
3868 if (dst_size != 0) {
3876 buf->size = dst_size;
3921 src_buf = item_array_at(&op_ctx->
items, 0)->obj->buffer;
3923 if (op_ctx->
op->code == UACPI_AML_OP_CreateFieldOp) {
3926 idx_obj = item_array_at(&op_ctx->
items, 1)->obj;
3927 len_obj = item_array_at(&op_ctx->
items, 2)->obj;
3928 node = item_array_at(&op_ctx->
items, 3)->node;
3929 field_obj = item_array_at(&op_ctx->
items, 4)->obj;
3935 len_obj->
integer > 0xFFFFFFFF)) {
3945 idx_obj = item_array_at(&op_ctx->
items, 1)->obj;
3946 node = item_array_at(&op_ctx->
items, 2)->node;
3947 field_obj = item_array_at(&op_ctx->
items, 3)->obj;
3951 switch (op_ctx->
op->code) {
3952 case UACPI_AML_OP_CreateBitFieldOp:
3953 field->bit_length = 1;
3955 case UACPI_AML_OP_CreateByteFieldOp:
3956 field->bit_length = 8;
3958 case UACPI_AML_OP_CreateWordFieldOp:
3959 field->bit_length = 16;
3961 case UACPI_AML_OP_CreateDWordFieldOp:
3962 field->bit_length = 32;
3964 case UACPI_AML_OP_CreateQWordFieldOp:
3965 field->bit_length = 64;
3971 if (op_ctx->
op->code != UACPI_AML_OP_CreateBitFieldOp)
3972 field->bit_index *= 8;
3976 src_buf->
size * 8)) {
3978 "invalid buffer field: bits [%zu..%zu], buffer size is %zu bytes\n",
3985 field->backing = src_buf;
4002 "attempting to %s outside of a While block\n",
4003 op_ctx->
op->code == UACPI_AML_OP_BreakOp ?
"Break" :
"Continue"
4014 if (op_ctx->
op->code == UACPI_AML_OP_BreakOp)
4030 node = item_array_at(&op_ctx->
items, 1)->node;
4031 obj = item_array_last(&op_ctx->
items)->obj;
4033 switch (op_ctx->
op->code) {
4034 case UACPI_AML_OP_ProcessorOp: {
4036 proc->id = item_array_at(&op_ctx->
items, 2)->immediate;
4037 proc->block_address = item_array_at(&op_ctx->
items, 3)->immediate;
4038 proc->block_length = item_array_at(&op_ctx->
items, 4)->immediate;
4042 case UACPI_AML_OP_PowerResOp: {
4065 switch (op_ctx->
op->code) {
4066 case UACPI_AML_OP_ProcessorOp:
4067 case UACPI_AML_OP_PowerResOp:
4068 case UACPI_AML_OP_ThermalZoneOp:
4069 case UACPI_AML_OP_DeviceOp: {
4078 case UACPI_AML_OP_ScopeOp:
4079 case UACPI_AML_OP_IfOp:
4080 case UACPI_AML_OP_ElseOp:
4081 case UACPI_AML_OP_WhileOp: {
4096 ctx->cur_frame->code_offset =
ctx->cur_frame->method->size;
4111 item_array_at(&
ctx->cur_op_ctx->items, 0)->obj,
4128 ctx->prev_op_ctx = op_context_array_one_before_last(&frame->
pending_ops);
4134 return ctx->cur_op_ctx && !
ctx->cur_op_ctx->preempted;
4154 "%s OP '%s' (0x%04X)\n",
4178 for (
i = 2;
i < item_array_size(&op_ctx->
items) - 1;
i++) {
4181 src = item_array_at(&op_ctx->
items,
i)->obj;
4204 block->node = scope;
4215 struct call_frame_array *call_stack = &
ctx->call_stack;
4218 *out_frame = call_frame_array_calloc(call_stack);
4227 prev_frame = call_frame_array_one_before_last(call_stack);
4228 ctx->cur_frame = prev_frame;
4257 switch (
dst->type) {
4272 if (
dst->integer == 0) {
4278 uacpi_error(
"attempted to store to an invalid target: %s\n",
4291 src = item_array_at(&op_ctx->
items, 0)->obj;
4292 dst = item_array_at(&op_ctx->
items, 1)->obj;
4294 if (op_ctx->
op->code == UACPI_AML_OP_StoreOp) {
4321 item_array_at(&op_ctx->
items, 0)->obj = wtr_response_obj;
4341 src = item_array_at(&op_ctx->
items, 0)->obj;
4342 dst = item_array_at(&op_ctx->
items, 1)->obj;
4361 switch (true_src_type) {
4363 dst->integer =
src->integer;
4394 if (op_ctx->
op->code == UACPI_AML_OP_IncrementOp)
4402 uacpi_error(
"Increment/Decrement: invalid object type '%s'\n",
4416 if (!
method->is_serialized)
4421 "cannot invoke method @%p, sync level %d is too low "
4422 "(current is %d)\n",
4440 ret = held_mutexes_array_push(&
ctx->held_mutexes,
method->mutex);
4457 op_ctx = op_context_array_calloc(&frame->
pending_ops);
4461 op_ctx->
op =
ctx->cur_op;
4470 if (item_array_size(&op_ctx->
items) == 0)
4481 item_array_pop(&op_ctx->
items);
4492 item_array_clear(&cur_op_ctx->
items);
4503 while (temp_namespace_node_array_size(&frame->
temp_nodes) != 0) {
4508 temp_namespace_node_array_pop(&frame->
temp_nodes);
4510 temp_namespace_node_array_clear(&frame->
temp_nodes);
4512 for (
i = 0;
i < 7; ++
i)
4514 for (
i = 0;
i < 8; ++
i)
4585#define EXEC_OP_DO_LVL(lvl, reason, ...) \
4586 uacpi_##lvl("Op 0x%04X ('%s'): "reason"\n", \
4587 op_ctx->op->code, op_ctx->op->name __VA_ARGS__)
4589#define EXEC_OP_DO_ERR(reason, ...) EXEC_OP_DO_LVL(error, reason, __VA_ARGS__)
4590#define EXEC_OP_DO_WARN(reason, ...) EXEC_OP_DO_LVL(warn, reason, __VA_ARGS__)
4592#define EXEC_OP_ERR_2(reason, arg0, arg1) EXEC_OP_DO_ERR(reason, ,arg0, arg1)
4593#define EXEC_OP_ERR_1(reason, arg0) EXEC_OP_DO_ERR(reason, ,arg0)
4594#define EXEC_OP_ERR(reason) EXEC_OP_DO_ERR(reason)
4596#define EXEC_OP_WARN(reason) EXEC_OP_DO_WARN(reason)
4598#define SPEC_SIMPLE_NAME "SimpleName := NameString | ArgObj | LocalObj"
4599#define SPEC_SUPER_NAME \
4600 "SuperName := SimpleName | DebugObj | ReferenceTypeOpcode"
4601#define SPEC_TERM_ARG \
4602 "TermArg := ExpressionOpcode | DataObject | ArgObj | LocalObj"
4603#define SPEC_OPERAND "Operand := TermArg => Integer"
4604#define SPEC_STRING "String := TermArg => String"
4605#define SPEC_TARGET "Target := SuperName | NullName"
4607#define SPEC_COMPUTATIONAL_DATA \
4608 "ComputationalData := ByteConst | WordConst | DWordConst | QWordConst " \
4609 "| String | ConstObj | RevisionOp | DefBuffer"
4703 if (!(
props & ok_mask)) {
4705 cur_op_ctx->
op->name, expected_type_str);
4748 switch (
obj->type) {
4755 "invalid argument type: %s, expected a %s",
4773 static const uacpi_char *oom_prefix =
"<...>";
4775 static const uacpi_char *unknown_path =
"<unknown-path>";
4776 static const uacpi_char *invalid_path =
"<invalid-path>";
4800 requested_path_to_print = unknown_path;
4802 requested_path_to_print = invalid_path;
4804 requested_path_to_print = requested_path;
4807 if (requested_path && requested_path[0] !=
'\\') {
4812 prefix_path = oom_prefix;
4814 if (prefix_path[1] !=
'\0')
4817 prefix_path = empty_string;
4821 middle_part = empty_string;
4823 if (
length == 5 && !is_create) {
4826 "unable to %s named object '%s' within (or above) "
4827 "scope '%s': %s\n",
action, requested_path_to_print,
4833 "unable to %s named object '%s%s%s': %s\n",
4834 action, prefix_path, middle_part,
4840 if (prefix_path != oom_prefix && prefix_path != empty_string)
5062#define EXT_OP_IDX(op) (op & 0xFF)
5127 goto method_dispatch_error;
5132 arg_count =
args ?
args->count : 0;
5135 "invalid number of arguments %zu to call %.4s, expected %d\n",
5140 goto method_dispatch_error;
5154 goto method_dispatch_error;
5159 goto method_dispatch_error;
5161 ctx->cur_frame = frame;
5164 ctx->cur_block = code_block_array_last(&
ctx->cur_frame->code_blocks);
5166 if (
method->native_call) {
5171 goto method_dispatch_error;
5178method_dispatch_error:
5180 call_frame_array_pop(&
ctx->call_stack);
5217 if (
ctx->prev_op_ctx)
5224 op_ctx =
ctx->cur_op_ctx;
5225 frame =
ctx->cur_frame;
5227 if (op_ctx->
pc == 0 &&
ctx->prev_op_ctx) {
5243 item = item_array_alloc(&op_ctx->
items);
5282 if (
ctx->cur_op_ctx) {
5284 ctx->cur_op_ctx->pc++;
5338 op_ctx->
pc += src_width;
5423 pkg = &item_array_at(&op_ctx->
items, pkg_idx)->pkg;
5426 op_ctx->
pc += bytes_skip;
5451 op_ctx->
pc += bytes_skip;
5463 op_ctx->
pc += bytes_skip;
5477 if (is_false == skip_if_false)
5478 op_ctx->
pc += bytes_skip;
5512 is_ok = op_ctx->
op->code == UACPI_AML_OP_ExternalOp;
5524 if (frame->
method->named_objects_persist &&
5529 first_ctx = op_context_array_at(&frame->
pending_ops, 0);
5530 abort_whileif = first_ctx->
op->code == UACPI_AML_OP_WhileOp ||
5531 first_ctx->
op->code == UACPI_AML_OP_IfOp;
5543 if (abort_whileif) {
5544 while (op_context_array_size(&frame->
pending_ops) != 1)
5547 op_ctx = op_context_array_at(&frame->
pending_ops, 0);
5558 !frame->
method->named_objects_persist)
5587 if (!
ctx->prev_op_ctx)
5619 EXEC_OP_ERR_1(
"don't know how to copy/transfer object to %d",
5626 dst = item_array_last(&
ctx->prev_op_ctx->items);
5653 src = item_array_at(&op_ctx->
items,
5674 item_array_pop(&op_ctx->
items);
5695 node = item_array_at(&op_ctx->
items, 0)->node;
5708 node = item_array_at(&op_ctx->
items, 0)->node;
5709 method = item_array_at(&op_ctx->
items, 1)->obj->method;
5718 uacpi_aml_op new_op = UACPI_AML_OP_InternalOpNamedObject;
5729 switch (
obj->type) {
5745 new_op = UACPI_AML_OP_InternalOpMethodCall0Args;
5746 new_op +=
obj->method->args;
5766 "unable to perform a read from field %s: "
5767 "parent opregion gone\n", field_path
5774 new_op = UACPI_AML_OP_InternalOpReadFieldAsBuffer;
5777 new_op = UACPI_AML_OP_InternalOpReadFieldAsInteger;
5804 if (op_length == 0 ||
op != target_op) {
5825 op_ctx->
pc += skip_bytes;
5841 if (
method->is_serialized) {
5845 ctx->sync_level =
ctx->cur_frame->prev_sync_level;
5849 call_frame_array_pop(&
ctx->call_stack);
5851 ctx->cur_frame = call_frame_array_last(&
ctx->call_stack);
5857 static const uacpi_char *unknown_path =
"<unknown>";
5867 absolute_path = unknown_path;
5872 if (absolute_path != oom_absolute_path && absolute_path != unknown_path)
5885 depth = call_frame_array_size(&
ctx->call_stack);
5892 table_level_code =
ctx->cur_frame->method->named_objects_persist;
5894 if (table_level_code &&
idx != 0)
5903 while (op_context_array_size(&
ctx->cur_frame->pending_ops) != 0)
5907 code_block_array_at(&
ctx->cur_frame->code_blocks, 0),
idx
5910 should_stop =
idx++ == 0 && table_level_code;
5912 }
while (--
depth && !should_stop);
5921 while (held_mutexes_array_size(&
ctx->held_mutexes) != 0) {
5924 *held_mutexes_array_last(&
ctx->held_mutexes),
5929 call_frame_array_clear(&
ctx->call_stack);
5930 held_mutexes_array_clear(&
ctx->held_mutexes);
5973 goto handle_method_abort;
5980 goto handle_method_abort;
5984 handle_method_abort:
5985 uacpi_error(
"aborting %s due to previous error: %s\n",
5986 ctx->cur_frame->method->named_objects_persist ?
5987 "table load" :
"method invocation",
5996 if (
ctx->cur_frame) {
5999 it = item_array_last(&
ctx->cur_op_ctx->items);
6030 uacpi_error(
"_OSI: invalid argument type %s, expected a String\n",
6046 uacpi_trace(
"_OSI(%s) => reporting as %ssupported\n",
6047 arg->buffer->text, is_supported ?
"" :
"un");
static unsigned char bytes[4]
void user(int argc, const char *argv[])
uacpi_status uacpi_acquire_aml_mutex(uacpi_mutex *, uacpi_u16 timeout)
uacpi_status uacpi_release_aml_mutex(uacpi_mutex *)
uacpi_bool uacpi_this_thread_owns_aml_mutex(uacpi_mutex *)
static void cleanup(void)
#define ACPI_SMALL_ITEM_NAME_IDX
struct uacpi_runtime_context g_uacpi_rt_ctx
static uacpi_bool uacpi_should_log(enum uacpi_log_level lvl)
uacpi_size uacpi_round_up_bits_to_bytes(uacpi_size bit_length)
void uacpi_write_buffer_field(uacpi_buffer_field *field, const void *src, uacpi_size size)
uacpi_status uacpi_field_unit_get_bit_length(struct uacpi_field_unit *field, uacpi_size *out_length)
void uacpi_read_buffer_field(const uacpi_buffer_field *field, void *dst)
uacpi_status uacpi_field_unit_get_read_type(struct uacpi_field_unit *field, uacpi_object_type *out_type)
uacpi_status uacpi_read_field_unit(uacpi_field_unit *field, void *dst, uacpi_size size, uacpi_data_view *wtr_response)
uacpi_status uacpi_write_field_unit(uacpi_field_unit *field, const void *src, uacpi_size size, uacpi_data_view *wtr_response)
#define uacpi_log_lvl(lvl,...)
void uacpi_namespace_node_unref(uacpi_namespace_node *node)
uacpi_status uacpi_namespace_do_for_each_child(uacpi_namespace_node *parent, uacpi_iteration_callback descending_callback, uacpi_iteration_callback ascending_callback, uacpi_object_type_bits, uacpi_u32 max_depth, enum uacpi_should_lock, enum uacpi_permanent_only, void *user)
uacpi_status uacpi_namespace_write_unlock(void)
#define UACPI_NAMESPACE_NODE_FLAG_TEMPORARY
@ UACPI_PERMANENT_ONLY_NO
uacpi_namespace_node * uacpi_namespace_node_find_sub_node(uacpi_namespace_node *parent, uacpi_object_name name)
#define UACPI_NAMESPACE_NODE_FLAG_ALIAS
uacpi_object * uacpi_namespace_node_get_object(const uacpi_namespace_node *node)
uacpi_namespace_node * uacpi_namespace_node_alloc(uacpi_object_name name)
uacpi_status uacpi_namespace_node_install(uacpi_namespace_node *parent, uacpi_namespace_node *node)
uacpi_status uacpi_namespace_node_uninstall(uacpi_namespace_node *node)
uacpi_status uacpi_namespace_write_lock(void)
@ UACPI_MAY_SEARCH_ABOVE_PARENT_YES
uacpi_status uacpi_namespace_node_resolve(uacpi_namespace_node *scope, const uacpi_char *path, enum uacpi_should_lock, enum uacpi_may_search_above_parent, enum uacpi_permanent_only, uacpi_namespace_node **out_node)
#define UACPI_DUAL_NAME_PREFIX
#define UACPI_MULTI_NAME_PREFIX
const uacpi_char * uacpi_parse_op_to_string(enum uacpi_parse_op op)
@ UACPI_PARSE_OP_COMPUTATIONAL_DATA
@ UACPI_PARSE_OP_OBJECT_CONVERT_TO_DEEP_COPY
@ UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL_IF_LOAD
@ UACPI_PARSE_OP_BAD_OPCODE
@ UACPI_PARSE_OP_STORE_TO_TARGET_INDIRECT
@ UACPI_PARSE_OP_TERM_ARG
@ UACPI_PARSE_OP_CREATE_NAMESTRING
@ UACPI_PARSE_OP_TRACKED_PKGLEN
@ UACPI_PARSE_OP_CONVERT_NAMESTRING
@ UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE
@ UACPI_PARSE_OP_IF_LAST_NULL
@ UACPI_PARSE_OP_AML_PC_DECREMENT
@ UACPI_PARSE_OP_OBJECT_COPY_TO_PREV
@ UACPI_PARSE_OP_EXISTING_NAMESTRING_OR_NULL
@ UACPI_PARSE_OP_LOAD_TRUE_OBJECT
@ UACPI_PARSE_OP_EXISTING_NAMESTRING
@ UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT
@ UACPI_PARSE_OP_IF_LAST_NOT_NULL
@ UACPI_PARSE_OP_INVOKE_HANDLER
@ UACPI_PARSE_OP_IF_HAS_DATA
@ UACPI_PARSE_OP_DISPATCH_TABLE_LOAD
@ UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL
@ UACPI_PARSE_OP_TYPECHECK
@ UACPI_PARSE_OP_SIMPLE_NAME
@ UACPI_PARSE_OP_IF_LAST_FALSE
@ UACPI_PARSE_OP_ITEM_POP
@ UACPI_PARSE_OP_SWITCH_TO_NEXT_IF_EQUALS
@ UACPI_PARSE_OP_SUPERNAME_OR_UNRESOLVED
@ UACPI_PARSE_OP_RECORD_AML_PC
@ UACPI_PARSE_OP_DISPATCH_METHOD_CALL
@ UACPI_PARSE_OP_SUPERNAME
@ UACPI_PARSE_OP_OBJECT_ALLOC
@ UACPI_PARSE_OP_OBJECT_TRANSFER_TO_PREV
@ UACPI_PARSE_OP_UNREACHABLE
@ UACPI_PARSE_OP_IF_LAST_TRUE
@ UACPI_PARSE_OP_LOAD_INLINE_IMM_AS_OBJECT
@ UACPI_PARSE_OP_LOAD_IMM
@ UACPI_PARSE_OP_STORE_TO_TARGET
@ UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL
@ UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD
@ UACPI_PARSE_OP_EMPTY_OBJECT_ALLOC
@ UACPI_PARSE_OP_LOAD_IMM_AS_OBJECT
@ UACPI_PARSE_OP_OBJECT_CONVERT_TO_SHALLOW_COPY
@ UACPI_PARSE_OP_TERM_ARG_OR_NAMED_OBJECT_OR_UNRESOLVED
@ UACPI_PARSE_OP_IF_LAST_EQUALS
@ UACPI_PARSE_OP_IF_NOT_NULL
@ UACPI_PARSE_OP_LOAD_FALSE_OBJECT
@ UACPI_PARSE_OP_OBJECT_ALLOC_TYPED
@ UACPI_PARSE_OP_EMIT_SKIP_WARN
@ UACPI_PARSE_OP_LOAD_ZERO_IMM
@ UACPI_PARSE_OP_IF_SWITCHED_FROM
@ UACPI_PARSE_OP_TRUNCATE_NUMBER
@ UACPI_PARSE_OP_IMM_DECREMENT
@ UACPI_PARSE_OP_LOAD_INLINE_IMM
const struct uacpi_op_spec * uacpi_get_op_spec(uacpi_aml_op)
@ UACPI_OP_PROPERTY_SIMPLE_NAME
@ UACPI_OP_PROPERTY_TERM_ARG
@ UACPI_OP_PROPERTY_SUPERNAME
@ UACPI_OP_PROPERTY_OUT_OF_LINE
@ UACPI_OP_PROPERTY_RESERVED
@ UACPI_OP_PROPERTY_TARGET
uacpi_status uacpi_find_aml_resource_end_tag(uacpi_data_view, uacpi_size *out_offset)
uacpi_u8 uacpi_bit_scan_forward(uacpi_u64)
uacpi_i32 uacpi_snprintf(uacpi_char *buffer, uacpi_size capacity, const uacpi_char *fmt,...)
#define uacpi_memzero(ptr, size)
#define uacpi_kernel_alloc_zeroed
uacpi_size uacpi_strnlen(const uacpi_char *str, uacpi_size max)
#define UACPI_ALIGN_DOWN(x, val, type)
#define uacpi_free(mem, _)
uacpi_u8 uacpi_bit_scan_backward(uacpi_u64)
void uacpi_memcpy_zerout(void *dst, const void *src, uacpi_size dst_size, uacpi_size src_size)
struct uacpi_object * uacpi_create_internal_reference(enum uacpi_reference_kind kind, uacpi_object *child)
@ UACPI_PREALLOC_OBJECTS_YES
uacpi_object * uacpi_create_object(uacpi_object_type type)
void uacpi_object_detach_child(uacpi_object *parent)
uacpi_bool uacpi_package_fill(uacpi_package *pkg, uacpi_size num_elements, enum uacpi_prealloc_objects prealloc_objects)
void uacpi_buffer_to_view(uacpi_buffer *, uacpi_data_view *)
@ UACPI_REFERENCE_KIND_LOCAL
@ UACPI_REFERENCE_KIND_ARG
@ UACPI_REFERENCE_KIND_PKG_INDEX
@ UACPI_REFERENCE_KIND_NAMED
@ UACPI_FIELD_UNIT_KIND_NORMAL
@ UACPI_FIELD_UNIT_KIND_BANK
@ UACPI_FIELD_UNIT_KIND_INDEX
uacpi_mutex * uacpi_create_mutex(void)
void uacpi_object_attach_child(uacpi_object *parent, uacpi_object *child)
uacpi_status uacpi_object_assign(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior)
void uacpi_method_unref(uacpi_control_method *)
@ UACPI_ASSIGN_BEHAVIOR_DEEP_COPY
@ UACPI_ASSIGN_BEHAVIOR_SHALLOW_COPY
void uacpi_mutex_unref(uacpi_mutex *)
uacpi_object * uacpi_unwrap_internal_reference(uacpi_object *object)
void uacpi_free_absolute_path(const uacpi_char *path)
#define UACPI_MAX_DEPTH_ANY
const uacpi_char * uacpi_namespace_node_generate_absolute_path(const uacpi_namespace_node *node)
uacpi_namespace_node * uacpi_namespace_root(void)
#define uacpi_likely_success(expr)
#define uacpi_unlikely_error(expr)
@ UACPI_STATUS_INVALID_ARGUMENT
@ UACPI_STATUS_AML_OBJECT_ALREADY_EXISTS
@ UACPI_STATUS_AML_OUT_OF_BOUNDS_INDEX
@ UACPI_STATUS_UNIMPLEMENTED
@ UACPI_STATUS_OUT_OF_MEMORY
@ UACPI_STATUS_OVERRIDDEN
@ UACPI_STATUS_AML_INCOMPATIBLE_OBJECT_TYPE
@ UACPI_STATUS_AML_UNDEFINED_REFERENCE
@ UACPI_STATUS_AML_LOOP_TIMEOUT
@ UACPI_STATUS_AML_BAD_ENCODING
@ UACPI_STATUS_AML_INVALID_OPCODE
@ UACPI_STATUS_AML_INVALID_NAMESTRING
@ UACPI_STATUS_AML_CALL_STACK_DEPTH_LIMIT
@ UACPI_STATUS_AML_SYNC_LEVEL_TOO_HIGH
@ UACPI_STATUS_NO_HANDLER
const uacpi_char * uacpi_status_to_string(uacpi_status)
void uacpi_object_ref(uacpi_object *obj)
@ UACPI_ITERATION_DECISION_BREAK
@ UACPI_ITERATION_DECISION_CONTINUE
@ UACPI_OBJECT_OPERATION_REGION_BIT
@ UACPI_ACCESS_ATTRIBUTE_RAW_BYTES
@ UACPI_ACCESS_ATTRIBUTE_RAW_PROCESS_BYTES
@ UACPI_ACCESS_ATTRIBUTE_BYTES
const uacpi_char * uacpi_object_type_to_string(uacpi_object_type)
@ UACPI_OBJECT_POWER_RESOURCE
@ UACPI_OBJECT_UNINITIALIZED
@ UACPI_OBJECT_BUFFER_FIELD
@ UACPI_OBJECT_OPERATION_REGION
@ UACPI_OBJECT_FIELD_UNIT
@ UACPI_OBJECT_BUFFER_INDEX
@ UACPI_FIRMWARE_REQUEST_TYPE_FATAL
@ UACPI_FIRMWARE_REQUEST_TYPE_BREAKPOINT
uacpi_bool uacpi_object_is(uacpi_object *, uacpi_object_type)
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
@ UACPI_ADDRESS_SPACE_TABLE_DATA
@ UACPI_ADDRESS_SPACE_PCC
void uacpi_object_unref(uacpi_object *obj)
void uacpi_events_match_post_dynamic_table_load(void)
static uacpi_status field_byte_size(uacpi_object *obj, uacpi_size *out_size)
static uacpi_status handle_arg(struct execution_context *ctx)
static uacpi_status handle_control_flow(struct execution_context *ctx)
static uacpi_status handle_create_field(struct execution_context *ctx)
static uacpi_status table_id_error(const uacpi_char *opcode, const uacpi_char *arg, uacpi_buffer *str)
static struct code_block * find_last_block(struct code_block_array *blocks, enum code_block_type type)
static uacpi_status handle_concatenate(struct execution_context *ctx)
static uacpi_status handle_unload(struct execution_context *ctx)
#define AML_READ(ptr, offset)
static const uacpi_char *const op_trace_action_types[3]
static uacpi_status handle_field_read(struct execution_context *ctx)
static uacpi_status frame_setup_base_scope(struct call_frame *frame, uacpi_namespace_node *scope, uacpi_control_method *method)
static uacpi_status typecheck_operand(const struct op_context *op_ctx, const uacpi_object *obj)
static uacpi_status do_load_table(uacpi_namespace_node *parent, struct acpi_sdt_hdr *tbl, enum uacpi_table_load_cause cause)
static uacpi_status method_get_ret_target(struct execution_context *ctx, uacpi_object **out_operand)
static uacpi_status store_to_target(uacpi_object *dst, uacpi_object *src, uacpi_data_view *wtr_response)
static void apply_tracked_pkg(struct call_frame *frame, struct op_context *op_ctx)
static uacpi_status prepare_method_call(struct execution_context *ctx, uacpi_namespace_node *node, uacpi_control_method *method, enum method_call_type type, const uacpi_object_array *args)
static uacpi_bool op_allows_unresolved_if_load(enum uacpi_parse_op op)
static uacpi_status handle_ref_or_deref_of(struct execution_context *ctx)
static uacpi_status handle_code_block(struct execution_context *ctx)
@ RESOLVE_FAIL_IF_DOESNT_EXIST
@ RESOLVE_CREATE_LAST_NAMESEG_FAIL_IF_EXISTS
static void truncate_number_if_needed(uacpi_object *obj)
static uacpi_status handle_event_ctl(struct execution_context *ctx)
@ OP_HANDLER_REF_OR_DEREF_OF
@ OP_HANDLER_CREATE_METHOD
@ OP_HANDLER_STALL_OR_SLEEP
@ OP_HANDLER_CREATE_DATA_REGION
@ OP_HANDLER_BINARY_LOGIC
@ OP_HANDLER_CREATE_MUTEX_OR_EVENT
@ OP_HANDLER_CREATE_FIELD
@ OP_HANDLER_COPY_OBJECT_OR_STORE
@ OP_HANDLER_NAMED_OBJECT
@ OP_HANDLER_CONCATENATE_RES
@ OP_HANDLER_CONTROL_FLOW
@ OP_HANDLER_FIRMWARE_REQUEST
@ OP_HANDLER_CREATE_BUFFER_FIELD
@ OP_HANDLER_CREATE_NAMED
@ OP_HANDLER_CREATE_OP_REGION
static uacpi_status debug_store(uacpi_object *src)
static uacpi_status field_get_read_type(uacpi_object *obj, uacpi_object_type *out_type)
static uacpi_status handle_create_named(struct execution_context *ctx)
static uacpi_status object_assign_with_implicit_cast(uacpi_object *dst, uacpi_object *src, uacpi_data_view *wtr_response)
static uacpi_status ensure_valid_idx(uacpi_object *obj, uacpi_size idx, uacpi_size src_size)
static uacpi_status method_get_ret_object(struct execution_context *ctx, uacpi_object **out_obj)
static uacpi_status handle_to(struct execution_context *ctx)
static uacpi_u8 parse_op_generates_item[0x100]
static uacpi_status handle_return(struct execution_context *ctx)
static uacpi_bool maybe_end_block(struct execution_context *ctx)
static void init_method_flags(uacpi_control_method *method, uacpi_u8 flags_byte)
static uacpi_status handle_create_method(struct execution_context *ctx)
static uacpi_status handle_buffer(struct execution_context *ctx)
static uacpi_status handle_mid(struct execution_context *ctx)
static uacpi_u64 ones(void)
static uacpi_object_type buffer_field_get_read_type(struct uacpi_buffer_field *field)
static void trace_pop(uacpi_u8 pop)
static uacpi_status do_binary_math(uacpi_object *arg0, uacpi_object *arg1, uacpi_object *tgt0, uacpi_object *tgt1, uacpi_aml_op op)
static uacpi_status name_string_to_path(struct call_frame *frame, uacpi_size offset, uacpi_char **out_string, uacpi_size *out_size)
static uacpi_status handle_create_mutex_or_event(struct execution_context *ctx)
static uacpi_status handle_inc_dec(struct execution_context *ctx)
static uacpi_status handle_unary_math(struct execution_context *ctx)
static uacpi_status handle_object_type(struct execution_context *ctx)
static void report_table_id_find_error(const uacpi_char *opcode, struct uacpi_table_identifiers *id, uacpi_status ret)
static uacpi_status handle_bcd(struct execution_context *ctx)
static void pop_op(struct execution_context *ctx)
static void trace_named_object_lookup_or_creation_failure(struct call_frame *frame, uacpi_size offset, enum uacpi_parse_op op, uacpi_status ret, enum uacpi_log_level level)
static uacpi_bool pop_item(struct op_context *op_ctx)
static uacpi_status held_mutexes_array_remove_and_release(struct held_mutexes_array *arr, uacpi_mutex *mutex, enum force_release force)
static uacpi_status handle_create_buffer_field(struct execution_context *ctx)
static uacpi_status build_table_id(const uacpi_char *opcode, struct uacpi_table_identifiers *out_id, uacpi_buffer *signature, uacpi_buffer *oem_id, uacpi_buffer *oem_table_id)
static uacpi_u8 handler_idx_of_ext_op[0x100]
static uacpi_status handle_match(struct execution_context *ctx)
static void emit_op_skip_warn(const struct op_context *op_ctx)
static uacpi_status handle_stall_or_sleep(struct execution_context *ctx)
static uacpi_status handle_notify(struct execution_context *ctx)
static uacpi_bool op_wants_supername(enum uacpi_parse_op op)
static uacpi_status do_make_empty_object(uacpi_buffer *buf, uacpi_bool is_string)
static void write_buffer_index(uacpi_buffer_index *buf_idx, uacpi_data_view *src_buf)
static uacpi_status push_op(struct execution_context *ctx)
static uacpi_status parse_package_length(struct call_frame *frame, struct package_length *out_pkg)
static uacpi_status handle_to_string(struct execution_context *ctx)
static void * call_frame_cursor(struct call_frame *frame)
static uacpi_u8 peek_next_op(struct call_frame *frame, uacpi_aml_op *out_op)
static uacpi_status handle_copy_object_or_store(struct execution_context *ctx)
static uacpi_status handle_string(struct execution_context *ctx)
static uacpi_status handle_arg_or_local(struct execution_context *ctx, uacpi_size idx, enum argx_or_localx type)
static uacpi_status handle_timer(struct execution_context *ctx)
static uacpi_u8 op_decode_byte(struct op_context *ctx)
static void stack_unwind(struct execution_context *ctx)
static void update_scope(struct call_frame *frame)
static uacpi_bool op_wants_term_arg_or_operand(enum uacpi_parse_op op)
static uacpi_status create_named_scope(struct op_context *op_ctx)
static void debug_store_no_recurse(const uacpi_char *prefix, uacpi_object *src)
static uacpi_status exec_op(struct execution_context *ctx)
static uacpi_status begin_block_execution(struct execution_context *ctx)
static uacpi_u8 handler_idx_of_op[0x100]
static uacpi_object * reference_unwind(uacpi_object *obj)
uacpi_status uacpi_execute_table(void *tbl, enum uacpi_table_load_cause cause)
static uacpi_status get_op(struct execution_context *ctx)
static uacpi_iteration_decision opregion_try_detach_from_parent(void *user, uacpi_namespace_node *node, uacpi_u32 node_depth)
static void object_replace_child(uacpi_object *parent, uacpi_object *new_child)
static void execution_context_release(struct execution_context *ctx)
static void prepare_table_load(void *ptr, enum uacpi_table_load_cause cause, uacpi_control_method *in_method)
static uacpi_status make_null_string(uacpi_buffer *buf)
static uacpi_bool op_allows_unresolved(enum uacpi_parse_op op)
static uacpi_status copy_object_to_reference(uacpi_object *dst, uacpi_object *src)
static uacpi_status handle_create_alias(struct execution_context *ctx)
static void trace_op(const struct uacpi_op_spec *op, enum op_trace_action_type action)
static uacpi_status typecheck_string(const struct op_context *op_ctx, const uacpi_object *obj)
#define EXEC_OP_ERR(reason)
static uacpi_status handle_load_table(struct execution_context *ctx)
static void frame_reset_post_end_block(struct execution_context *ctx, enum code_block_type type)
static uacpi_size sizeof_int(void)
static uacpi_status handle_local(struct execution_context *ctx)
static uacpi_status(* op_handlers[])(struct execution_context *ctx)
static uacpi_size call_frame_code_bytes_left(struct call_frame *frame)
static uacpi_aml_op op_decode_aml_op(struct op_context *op_ctx)
static uacpi_status handle_create_op_region(struct execution_context *ctx)
static void call_frame_clear(struct call_frame *frame)
static uacpi_status do_install_node_item(struct call_frame *frame, struct item *item)
static uacpi_status handle_sizeof(struct execution_context *ctx)
static uacpi_status handle_load(struct execution_context *ctx)
#define SPEC_COMPUTATIONAL_DATA
static uacpi_status resolve_name_string(struct call_frame *frame, enum resolve_behavior behavior, struct uacpi_namespace_node **out_node)
static uacpi_status handle_firmware_request(struct execution_context *ctx)
static void held_mutexes_array_remove_idx(struct held_mutexes_array *arr, uacpi_size i)
uacpi_status uacpi_execute_control_method(uacpi_namespace_node *scope, uacpi_control_method *method, const uacpi_object_array *args, uacpi_object **out_obj)
static uacpi_status handle_package(struct execution_context *ctx)
#define EXEC_OP_ERR_1(reason, arg0)
static void refresh_ctx_pointers(struct execution_context *ctx)
static uacpi_bool is_dynamic_table_load(enum uacpi_table_load_cause cause)
#define EXEC_OP_ERR_2(reason, arg0, arg1)
static uacpi_u64 object_to_integer(const uacpi_object *obj, uacpi_size max_buffer_bytes)
static uacpi_status handle_logical_not(struct execution_context *ctx)
static uacpi_status make_null_buffer(uacpi_buffer *buf)
static uacpi_bool call_frame_has_code(struct call_frame *frame)
static uacpi_u8 * buffer_index_cursor(uacpi_buffer_index *buf_idx)
static uacpi_bool match_one(enum match_op op, uacpi_u64 lhs, uacpi_u64 rhs)
static uacpi_status get_object_storage(uacpi_object *obj, uacpi_data_view *out_buf, uacpi_bool include_null)
static uacpi_status enter_method(struct execution_context *ctx, struct call_frame *new_frame, uacpi_control_method *method)
static void ctx_reload_post_ret(struct execution_context *ctx)
static uacpi_status ensure_is_a_field_unit(uacpi_namespace_node *node, uacpi_field_unit **out_field)
static uacpi_status handle_mutex_ctl(struct execution_context *ctx)
static void trace_method_abort(struct code_block *block, uacpi_size depth)
static uacpi_bool ctx_has_non_preempted_op(struct execution_context *ctx)
static uacpi_status typecheck_computational_data(const struct op_context *op_ctx, const uacpi_object *obj)
static uacpi_u32 get_field_length(struct item *item)
static uacpi_status store_to_reference(uacpi_object *dst, uacpi_object *src, uacpi_data_view *wtr_response)
static uacpi_status push_new_frame(struct execution_context *ctx, struct call_frame **out_frame)
static uacpi_status handle_concatenate_res(struct execution_context *ctx)
static uacpi_bool handle_logical_equality(uacpi_object *lhs, uacpi_object *rhs)
static uacpi_status ensure_is_an_op_region(uacpi_namespace_node *node, uacpi_namespace_node **out_node)
static uacpi_status handle_binary_math(struct execution_context *ctx)
static uacpi_status buffer_to_string(uacpi_buffer *buf, uacpi_buffer *str, uacpi_bool is_hex)
static uacpi_status handle_binary_logic(struct execution_context *ctx)
static uacpi_status handle_named_object(struct execution_context *ctx)
static uacpi_status integer_to_string(uacpi_u64 integer, uacpi_buffer *str, uacpi_bool is_hex)
static uacpi_status frame_push_args(struct call_frame *frame, struct op_context *op_ctx)
static uacpi_status uninstalled_op_handler(struct execution_context *ctx)
static uacpi_status parse_nameseg(uacpi_u8 *cursor, uacpi_object_name *out_name)
static uacpi_status typecheck_obj(const struct op_context *op_ctx, const uacpi_object *obj, enum uacpi_object_type expected_type, const uacpi_char *spec_desc)
static uacpi_bool handle_logical_less_or_greater(uacpi_aml_op op, uacpi_object *lhs, uacpi_object *rhs)
static uacpi_status handle_create_data_region(struct execution_context *ctx)
static uacpi_status op_typecheck(const struct op_context *op_ctx, const struct op_context *cur_op_ctx)
#define EXEC_OP_WARN(reason)
uacpi_status uacpi_osi(uacpi_handle handle, uacpi_object *retval)
static const uacpi_u8 * op_decode_cursor(const struct op_context *ctx)
static uacpi_status handle_index(struct execution_context *ctx)
#define DYNAMIC_ARRAY_WITH_INLINE_STORAGE_IMPL(name, type, prefix)
#define DYNAMIC_ARRAY_WITH_INLINE_STORAGE(name, type, inline_capacity)
GLint GLint GLsizei GLsizei GLsizei depth
GLuint GLuint GLsizei count
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei width
GLuint GLuint GLuint GLuint arg1
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
uacpi_status uacpi_notify_all(uacpi_namespace_node *node, uacpi_u64 value)
void uacpi_opregion_uninstall_handler(uacpi_namespace_node *node)
uacpi_status uacpi_initialize_opregion_node(uacpi_namespace_node *node)
uacpi_status uacpi_handle_osi(const uacpi_char *string, uacpi_bool *out_value)
#define UACPI_PRI_TBL_HDR
uacpi_status uacpi_table_install_with_origin(void *virt, enum uacpi_table_origin origin, uacpi_table *out_table)
void uacpi_table_mark_as_loaded(uacpi_size idx)
#define UACPI_FMT_TBL_HDR(hdr)
@ UACPI_TABLE_ORIGIN_FIRMWARE_VIRTUAL
#define UACPI_NANOSECONDS_PER_SEC
uacpi_status uacpi_string_to_integer(const uacpi_char *str, uacpi_size max_chars, enum uacpi_base base, uacpi_u64 *out_value)
uacpi_bool uacpi_is_valid_nameseg(uacpi_u8 *nameseg)
void uacpi_free_dynamic_string(const uacpi_char *str)
@ UACPI_TABLE_LOAD_CAUSE_HOST
@ UACPI_TABLE_LOAD_CAUSE_INIT
@ UACPI_TABLE_LOAD_CAUSE_LOAD_OP
@ UACPI_TABLE_LOAD_CAUSE_LOAD_TABLE_OP
static BOOL is_null(jsval_t v)
uacpi_bool uacpi_kernel_wait_for_event(uacpi_handle, uacpi_u16)
void * uacpi_kernel_alloc(uacpi_size size)
void uacpi_kernel_reset_event(uacpi_handle)
void uacpi_kernel_stall(uacpi_u8 usec)
void uacpi_kernel_sleep(uacpi_u64 msec)
uacpi_u64 uacpi_kernel_get_nanoseconds_since_boot(void)
uacpi_status uacpi_kernel_handle_firmware_request(uacpi_firmware_request *)
void uacpi_kernel_unmap(void *addr, uacpi_size len)
void * uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len)
void uacpi_kernel_signal_event(uacpi_handle)
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
static BOOL is_string(parse_buffer *buf)
static calc_node_t * pop(void)
uacpi_u32 uacpi_shareable_ref(uacpi_handle)
wchar_t const *const size_t const buffer_size
uacpi_u32 prev_while_code_offset
struct uacpi_namespace_node * cur_scope
struct code_block * last_while
struct temp_namespace_node_array temp_nodes
struct op_context_array pending_ops
struct uacpi_control_method * method
struct code_block_array code_blocks
uacpi_u64 prev_while_expiration
enum code_block_type type
struct uacpi_namespace_node * node
uacpi_u64 expiration_point
struct op_context * prev_op_ctx
struct code_block * cur_block
struct held_mutexes_array held_mutexes
struct call_frame * cur_frame
struct call_frame_array call_stack
struct op_context * cur_op_ctx
const struct uacpi_op_spec * cur_op
struct uacpi_field_unit * field1
struct uacpi_field_unit * field0
uacpi_namespace_node * region
struct uacpi_namespace_node * node
struct package_length pkg
uacpi_u8 immediate_bytes[8]
const struct uacpi_op_spec * op
uacpi_aml_op switched_from
uacpi_u8 named_objects_persist
struct uacpi_firmware_request::@731::@734 fatal
struct uacpi_firmware_request::@731::@733 breakpoint
struct uacpi_namespace_node * parent
uacpi_control_method * method
uacpi_field_unit * field_unit
uacpi_buffer_field buffer_field
uacpi_object * inner_object
uacpi_u8 * indirect_decode_ops
uacpi_object_name signature
uacpi_status uacpi_table_find(const uacpi_table_identifiers *id, uacpi_table *out_table)
uacpi_status uacpi_table_unref(uacpi_table *)
Character const *const prefix
static const WCHAR props[]
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
static unsigned int block