New shell command: acpi_call, new test: ACPI Debug object.

Also, clean up extern/public variables.
This commit is contained in:
Ivan Baravy 2020-09-17 04:40:25 +03:00
parent d1e15190f4
commit b3a27127b2
10 changed files with 696 additions and 30 deletions

20
shell.c
View File

@ -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 <method> [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 <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 },

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,7 @@
acpi_set_usage 1
acpi_preload_table machines/unit/acpi/debug_object.aml
acpi_enable
acpi_call \TEST

View File

@ -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

View File

@ -0,0 +1,7 @@
acpi_set_usage 1
acpi_preload_table machines/unit/acpi/field.aml
acpi_enable
acpi_call \TEST

View File

@ -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)
}
}

View File

@ -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")
}
}

View File

@ -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 ?

27
umka.h
View File

@ -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;