diff --git a/shell.c b/shell.c index ab79c78..e21daa5 100644 --- a/shell.c +++ b/shell.c @@ -1118,6 +1118,25 @@ void shell_acpi_get_usage(int argc, char **argv) { fprintf(fout, "ACPI usage: %" PRIu32 "\n", kos_acpi_usage); } +void shell_acpi_call(int argc, char **argv) { + const char *usage = \ + "usage: acpi_call [args...]\n" + " method name of acpi method to call, e.g. \\_SB_PCI0_PRT"; + if (argc > 2) { + puts("arguments are not supported / not implemented!"); + puts(usage); + return; + } + if (argc < 2) { + puts(usage); + return; + } + const char *method = argv[1]; + fprintf(fout, "calling acpi method: '%s'\n", method); + kos_acpi_call_name(acpi_ctx, method); + fprintf(fout, "acpi method returned\n"); +} + void shell_pci_set_path(int argc, char **argv) { const char *usage = \ "usage: pci_set_path \n" @@ -1892,6 +1911,7 @@ func_table_t funcs[] = { { "acpi_get_usage", shell_acpi_get_usage }, { "acpi_enable", shell_acpi_enable }, { "acpi_preload_table", shell_acpi_preload_table }, + { "acpi_call", shell_acpi_call }, { "stack_init", shell_stack_init }, { "net_add_device", shell_net_add_device }, { "net_get_dev_count", shell_net_get_dev_count }, diff --git a/test/031_#acpi_#unit_scope.ref.log b/test/031_#acpi_#unit_scope.ref.log index 419d8f8..c3e01b7 100644 --- a/test/031_#acpi_#unit_scope.ref.log +++ b/test/031_#acpi_#unit_scope.ref.log @@ -13,7 +13,7 @@ table length 0x00000028 Table signature: 'SSDT' Table length (with header): 0x00000028 Revision: 0x01 -Checksum: 0xD3 +Checksum: 0xE9 OEM ID: 'UMKA ' OEM Table ID: 'UMKADSDT' OEM Table Revision: 0x00000001 @@ -51,7 +51,7 @@ table length 0x0000068C Table signature: 'DSDT' Table length (with header): 0x0000068C Revision: 0x02 -Checksum: 0x9E +Checksum: 0xB4 OEM ID: 'UMKA ' OEM Table ID: 'UMKADSDT' OEM Table Revision: 0x00000000 @@ -3684,7 +3684,7 @@ table length 0x0000002C Table signature: 'DSDT' Table length (with header): 0x0000002C Revision: 0x01 -Checksum: 0xC7 +Checksum: 0xDD OEM ID: 'UMKA ' OEM Table ID: 'UMKADSDT' OEM Table Revision: 0x00000001 diff --git a/test/033_#acpi_debug_object.ref.log b/test/033_#acpi_debug_object.ref.log new file mode 100644 index 0000000..4261866 --- /dev/null +++ b/test/033_#acpi_debug_object.ref.log @@ -0,0 +1,407 @@ +/> acpi_set_usage 1 + +/> acpi_preload_table machines/unit/acpi/debug_object.aml +table #0 + +/> acpi_enable +acpi.aml.process_table begin +table length 0x00000084 +Table signature: 'DSDT' +Table length (with header): 0x00000084 +Revision: 0x01 +Checksum: 0x8B +OEM ID: 'UMKA ' +OEM Table ID: 'UMKADSDT' +OEM Table Revision: 0x00000001 + +table/position: [0x00000024] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.name begin +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000025 +aml._.name_path begin +aml._.name_path end +name_string: BUFF +aml._.name_string end +aml._.get_node_by_name begin +name: '' +aml._.get_node_by_name end +aml._.data_ref_object begin +aml._.data_object begin +aml._.buffer begin +pkg_length: 0x00000007 +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.byte_const begin +aml._.byte_const end +aml._.data_object end +aml._.term_arg end +aml._.cast begin +types 2 to 2 +aml._.cast.integer_to_integer begin +aml._.cast.integer_to_integer end +aml._.cast end +aml._.buffer end +aml._.data_object end +aml._.data_ref_object end +aml._.name end +aml._.namespace_modifier_obj end +aml._.object end +aml._.term_obj end +table/position: [0x00000031] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.method begin +pkg_length: 0x00000052 +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000034 +aml._.name_path begin +aml._.name_path end +name_string: TEST +aml._.name_string end +aml._.attach_node begin +aml._.get_node_by_name begin +name: '' +aml._.get_node_by_name end +aml._.attach_node end +aml._.method end +aml._.named_obj end +aml._.object end +aml._.term_obj end +==========ACPI_TREE========== +\TEST Method length:0x0000004B Args:0 serialize:0 sync_level:0 +\BUFF Buffer Len:0x00000004 +\_TZ_ Scope +\_SI_ Scope +\_SB_ Scope +\_PR_ Scope +\_GPE Scope +----------------------------- +acpi.aml.process_table end +==========ACPI_TREE========== +\TEST Method length:0x0000004B Args:0 serialize:0 sync_level:0 +\BUFF Buffer Len:0x00000004 +\_TZ_ Scope +\_SI_ Scope +\_SB_ Scope +\_PR_ Scope +\_GPE Scope +----------------------------- + +/> acpi_call \TEST +acpi.call_name begin +aml._.get_node_by_name begin +name: '\TEST' +aml._.get_node_by_name end +acpi.call_node begin +# func name TEST +# bytes 0x65680D70 +# bytes 0x006F6C6C +# bytes 0x0A70315B +table/position: [0x00000039] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 3 to 19 +aml._.store_table.string_to_debug_object begin +AML_DBG: hello +aml._.store_table.string_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +table/position: [0x00000043] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.byte_const begin +aml._.byte_const end +aml._.data_object end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 2 to 19 +aml._.store_table.integer_to_debug_object begin +AML_DBG: 0x0000000000000042 +aml._.store_table.integer_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +table/position: [0x00000048] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 3 to 19 +aml._.store_table.string_to_debug_object begin +AML_DBG: hello +aml._.store_table.string_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +table/position: [0x00000052] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.concat begin +aml._.term_arg begin +aml._.concat begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.byte_const begin +aml._.byte_const end +aml._.data_object end +aml._.term_arg end +concat 00000003 and 00000002 +aml._.cast begin +types 2 to 3 +aml._.cast.integer_to_string begin +aml._.cast.integer_to_string end +aml._.cast end +aml._.target begin +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.super_name end +aml._.null_name begin +aml._.null_name end +aml._.target end +aml._.concat end +aml._.term_arg end +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +concat 00000003 and 00000003 +aml._.cast begin +types 3 to 3 +aml._.cast.string_to_string begin +aml._.cast.string_to_string end +aml._.cast end +aml._.target begin +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.super_name end +aml._.null_name begin +aml._.null_name end +aml._.target end +aml._.concat end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 3 to 19 +aml._.store_table.string_to_debug_object begin +AML_DBG: hi 0x0000000000000042 there +aml._.store_table.string_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +table/position: [0x00000068] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.concat begin +aml._.term_arg begin +aml._.concat begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +aml._.term_arg begin +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000073 +aml._.name_path begin +aml._.name_path end +name_string: BUFF +aml._.name_string end +aml._.get_node_by_name begin +name: 'BUFF' +aml._.get_node_by_name end +aml._.data_object begin +aml._.data_object end +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000073 +aml._.name_path begin +aml._.name_path end +name_string: BUFF +aml._.name_string end +aml._.get_node_by_name begin +name: 'BUFF' +aml._.get_node_by_name end +aml._.term_arg end +concat 00000003 and 00000004 +aml._.cast begin +types 4 to 3 +aml._.cast.buffer_to_string begin +### buf len: 4 +aml._.cast.buffer_to_string end +aml._.cast end +aml._.target begin +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.super_name end +aml._.null_name begin +aml._.null_name end +aml._.target end +aml._.concat end +aml._.term_arg end +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +concat 00000003 and 00000003 +aml._.cast begin +types 3 to 3 +aml._.cast.string_to_string begin +aml._.cast.string_to_string end +aml._.cast end +aml._.target begin +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.super_name end +aml._.null_name begin +aml._.null_name end +aml._.target end +aml._.concat end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 3 to 19 +aml._.store_table.string_to_debug_object begin +AML_DBG: hello 66 72 6F 6D buffer +aml._.store_table.string_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +acpi.call_node end +acpi.call_name end +calling acpi method: '\TEST' +acpi method returned diff --git a/test/033_#acpi_debug_object.t b/test/033_#acpi_debug_object.t new file mode 100644 index 0000000..2ee7d00 --- /dev/null +++ b/test/033_#acpi_debug_object.t @@ -0,0 +1,7 @@ +acpi_set_usage 1 + +acpi_preload_table machines/unit/acpi/debug_object.aml + +acpi_enable + +acpi_call \TEST diff --git a/test/034_#acpi_#unit_fieldio.ref.log b/test/034_#acpi_#unit_fieldio.ref.log new file mode 100644 index 0000000..6e9a26a --- /dev/null +++ b/test/034_#acpi_#unit_fieldio.ref.log @@ -0,0 +1,198 @@ +/> acpi_set_usage 1 + +/> acpi_preload_table machines/unit/acpi/field.aml +table #0 + +/> acpi_enable +acpi.aml.process_table begin +table length 0x00000053 +Table signature: 'DSDT' +Table length (with header): 0x00000053 +Revision: 0x01 +Checksum: 0x48 +OEM ID: 'UMKA ' +OEM Table ID: 'UMKADSDT' +OEM Table Revision: 0x00000001 + +table/position: [0x00000024] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.op_region begin +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000026 +aml._.name_path begin +aml._.name_path end +name_string: M000 +aml._.name_string end +aml._.attach_node begin +aml._.get_node_by_name begin +name: '' +aml._.get_node_by_name end +aml._.attach_node end +RegionSpace: 0x00 +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.word_const begin +aml._.word_const end +aml._.data_object end +aml._.term_arg end +aml._.cast begin +types 2 to 2 +aml._.cast.integer_to_integer begin +aml._.cast.integer_to_integer end +aml._.cast end +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.byte_const begin +aml._.byte_const end +aml._.data_object end +aml._.term_arg end +aml._.cast begin +types 2 to 2 +aml._.cast.integer_to_integer begin +aml._.cast.integer_to_integer end +aml._.cast end +RegionLength: 0x00000011 +aml._.op_region end +aml._.named_obj end +aml._.object end +aml._.term_obj end +table/position: [0x00000030] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.region_field begin +pkg_length: 0x00000010 +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000033 +aml._.name_path begin +aml._.name_path end +name_string: M000 +aml._.name_string end +aml._.get_node_by_name begin +name: 'M000' +aml._.get_node_by_name end +aml._.field_list begin +aml._.field_element begin +aml._.named_field begin +name_seg: 'FM00' +pkg_length: 0x00000001 +aml._.named_field end +aml._.field_element end +aml._.field_element begin +aml._.named_field begin +name_seg: 'FM01' +pkg_length: 0x00000002 +aml._.named_field end +aml._.field_element end +aml._.field_list end +aml._.region_field end +aml._.named_obj end +aml._.object end +aml._.term_obj end +table/position: [0x00000042] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.method begin +pkg_length: 0x00000010 +aml._.name_string begin +aml._.name_string begin again +offset: 0x00000044 +aml._.name_path begin +aml._.name_path end +name_string: TEST +aml._.name_string end +aml._.attach_node begin +aml._.get_node_by_name begin +name: '' +aml._.get_node_by_name end +aml._.attach_node end +aml._.method end +aml._.named_obj end +aml._.object end +aml._.term_obj end +==========ACPI_TREE========== +\TEST Method length:0x0000000A Args:0 serialize:0 sync_level:0 +\FM01 RegionField Rgn [\M000] Off:00000001 Len:00000002 Acc:1 +\FM00 RegionField Rgn [\M000] Off:00000000 Len:00000001 Acc:1 +\M000 OpRegion [SystemMemory] Len:00000011 +\_TZ_ Scope +\_SI_ Scope +\_SB_ Scope +\_PR_ Scope +\_GPE Scope +----------------------------- +acpi.aml.process_table end +==========ACPI_TREE========== +\TEST Method length:0x0000000A Args:0 serialize:0 sync_level:0 +\FM01 RegionField Rgn [\M000] Off:00000001 Len:00000002 Acc:1 +\FM00 RegionField Rgn [\M000] Off:00000000 Len:00000001 Acc:1 +\M000 OpRegion [SystemMemory] Len:00000011 +\_TZ_ Scope +\_SI_ Scope +\_SB_ Scope +\_PR_ Scope +\_GPE Scope +----------------------------- + +/> acpi_call \TEST +acpi.call_name begin +aml._.get_node_by_name begin +name: '\TEST' +aml._.get_node_by_name end +acpi.call_node begin +# func name TEST +# bytes 0x65680D70 +# bytes 0x006F6C6C +# bytes 0x0000315B +table/position: [0x00000049] +aml._.term_obj begin +aml._.object begin +aml._.namespace_modifier_obj begin +aml._.namespace_modifier_obj end +aml._.named_obj begin +aml._.named_obj end +aml._.object end +aml._.store begin +aml._.term_arg begin +aml._.name_string begin +aml._.name_string end +aml._.data_object begin +aml._.string begin +aml._.string end +aml._.data_object end +aml._.term_arg end +aml._.super_name begin +aml._.simple_name begin +aml._.name_string begin +aml._.name_string end +aml._.simple_name end +aml._.debug_obj begin +aml._.debug_obj end +aml._.super_name end +aml._.store_table begin +types 3 to 19 +aml._.store_table.string_to_debug_object begin +AML_DBG: hello +aml._.store_table.string_to_debug_object end +aml._.store_table end +aml._.store end +aml._.term_obj end +acpi.call_node end +acpi.call_name end +calling acpi method: '\TEST' +acpi method returned diff --git a/test/034_#acpi_#unit_fieldio.t b/test/034_#acpi_#unit_fieldio.t new file mode 100644 index 0000000..da2b0e1 --- /dev/null +++ b/test/034_#acpi_#unit_fieldio.t @@ -0,0 +1,7 @@ +acpi_set_usage 1 + +acpi_preload_table machines/unit/acpi/field.aml + +acpi_enable + +acpi_call \TEST diff --git a/test/machines/unit/acpi/debug_object.asl b/test/machines/unit/acpi/debug_object.asl new file mode 100644 index 0000000..a1a73d3 --- /dev/null +++ b/test/machines/unit/acpi/debug_object.asl @@ -0,0 +1,13 @@ +DefinitionBlock ("", "DSDT", 1, "UMKA ", "UMKADSDT", 0x00000001) +{ + Name (BUFF, Buffer (4) {0x66, 0x72, 0x6F, 0x6D}) + + Method (TEST, 0, NotSerialized) + { + Debug = "hello" + Debug = 0x42 + printf("hello") + printf("hi %x there", 0x42) + printf("hello %o buffer", BUFF) + } +} diff --git a/test/machines/unit/acpi/field.asl b/test/machines/unit/acpi/field.asl index bc99aa3..e5238dd 100644 --- a/test/machines/unit/acpi/field.asl +++ b/test/machines/unit/acpi/field.asl @@ -1,4 +1,15 @@ DefinitionBlock ("", "DSDT", 1, "UMKA ", "UMKADSDT", 0x00000001) { - + OperationRegion (M000, SystemMemory, 0xE001, 17) + Field (M000, ByteAcc, NoLock, Preserve) + { + FM00, 1, + FM01, 2 + } + + + Method (TEST, 0, NotSerialized) + { + printf("hello") + } } diff --git a/umka.asm b/umka.asm index 3ef8cc5..ae8a971 100644 --- a/umka.asm +++ b/umka.asm @@ -35,18 +35,19 @@ public CURRENT_TASK as 'kos_current_task' public current_slot as 'kos_current_slot' public TASK_COUNT as 'kos_task_count' public TASK_BASE as 'kos_task_base' -;public task_base_addr as 'kos_task_base' -public task_data_addr as 'kos_task_data' -public slot_base_addr as 'kos_slot_base' +public TASK_DATA as 'kos_task_data' +public SLOT_BASE as 'kos_slot_base' -public win_stack_addr as 'kos_win_stack' -public win_pos_addr as 'kos_win_pos' -public lfb_base_addr as 'kos_lfb_base' +public WIN_STACK as 'kos_win_stack' +public WIN_POS as 'kos_win_pos' +public lfb_base as 'kos_lfb_base' public enable_acpi +public acpi.call_name public acpi_ssdt_cnt as 'kos_acpi_ssdt_cnt' -public kos_acpi_ssdt_base -public kos_acpi_ssdt_size +public acpi_ssdt_base as 'kos_acpi_ssdt_base' +public acpi_ssdt_size as 'kos_acpi_ssdt_size' +public acpi_ctx public acpi_usage as 'kos_acpi_usage' public stack_init @@ -572,19 +573,8 @@ umka_tool dd ? timer_ticks dd 0 fpu_owner dd ? -task_base_addr dd TASK_BASE -task_data_addr dd TASK_DATA -slot_base_addr dd SLOT_BASE - monitor_thread dd ? -win_stack_addr dd WIN_STACK -win_pos_addr dd WIN_POS -lfb_base_addr dd lfb_base - -kos_acpi_ssdt_base dd acpi_ssdt_base -kos_acpi_ssdt_size dd acpi_ssdt_size - uglobal context_counter dd ? LAPIC_BASE dd ? diff --git a/umka.h b/umka.h index 2127722..f2eec8a 100644 --- a/umka.h +++ b/umka.h @@ -343,6 +343,18 @@ static inline void kos_enable_acpi() { : "memory", "cc"); } +static inline void kos_acpi_call_name(void *ctx, const char *name) { + __asm__ __inline__ __volatile__ ( + "pushad;" + "push %[name];" + "push %[ctx];" + "call acpi.call_name;" + "popad" + : + : [ctx] "r"(ctx), [name] "r"(name) + : "memory", "cc"); +} + typedef struct { uint32_t value; uint32_t errorcode; @@ -478,15 +490,16 @@ extern uint32_t kos_current_task; extern appdata_t *kos_current_slot; extern size_t kos_task_count; extern taskdata_t *kos_task_base; -extern void *kos_task_data; -extern appdata_t *kos_slot_base; +extern taskdata_t kos_task_data[]; +extern appdata_t kos_slot_base[]; extern void (*monitor_thread)(void); -extern uint32_t *kos_lfb_base; -extern uint16_t *kos_win_stack; -extern uint16_t *kos_win_pos; +extern uint32_t kos_lfb_base[]; +extern uint16_t kos_win_stack[]; +extern uint16_t kos_win_pos[]; extern uint32_t kos_acpi_ssdt_cnt; -extern uint8_t **kos_acpi_ssdt_base; -extern size_t *kos_acpi_ssdt_size; +extern uint8_t *kos_acpi_ssdt_base[]; +extern size_t kos_acpi_ssdt_size[]; +extern void *acpi_ctx; extern uint32_t kos_acpi_usage; extern disk_t disk_list;