Add basic node counting logic, update tests.

This commit is contained in:
Ivan Baravy 2021-05-31 17:32:04 +03:00
parent f87fcd87dc
commit e5d50667de
33 changed files with 416 additions and 1 deletions

40
shell.c
View File

@ -1707,6 +1707,43 @@ shell_acpi_enable(int argc, char **argv) {
COVERAGE_OFF();
}
static void
shell_acpi_get_node_cnt(int argc, char **argv) {
(void)argv;
const char *usage = \
"usage: acpi_get_node_cnt";
if (argc != 1) {
fputs(usage, fout);
return;
}
uint32_t cnt = kos_acpi_count_nodes(acpi_ctx);
fprintf(fout, "nodes in namespace: %" PRIu32 "\n", cnt);
}
static void
shell_acpi_get_node_alloc_cnt(int argc, char **argv) {
(void)argv;
const char *usage = \
"usage: acpi_get_node_alloc_cnt";
if (argc != 1) {
fputs(usage, fout);
return;
}
fprintf(fout, "nodes allocated: %" PRIu32 "\n", kos_acpi_node_alloc_cnt);
}
static void
shell_acpi_get_node_free_cnt(int argc, char **argv) {
(void)argv;
const char *usage = \
"usage: acpi_get_node_free_cnt";
if (argc != 1) {
fputs(usage, fout);
return;
}
fprintf(fout, "nodes freed: %" PRIu32 "\n", kos_acpi_node_free_cnt);
}
static void
shell_acpi_set_usage(int argc, char **argv) {
const char *usage = \
@ -2544,6 +2581,9 @@ func_table_t shell_cmds[] = {
{ "acpi_get_usage", shell_acpi_get_usage },
{ "acpi_preload_table", shell_acpi_preload_table },
{ "acpi_set_usage", shell_acpi_set_usage },
{ "acpi_get_node_alloc_cnt", shell_acpi_get_node_alloc_cnt },
{ "acpi_get_node_free_cnt", shell_acpi_get_node_free_cnt },
{ "acpi_get_node_cnt", shell_acpi_get_node_cnt },
{ "bg_map", shell_bg_map },
{ "bg_put_img", shell_bg_put_img },
{ "bg_put_pixel", shell_bg_put_pixel },

View File

@ -135997,3 +135997,10 @@ aml._.get_node_by_name end
00:01.7 0000:0000 00 1 \_SB_\PCI0\GPP6
02:00.F FFFF:FFFF 00 0 \_SB_\PCI0\GPP6\D027
02:00.0 10EC:8168 30 0 \_SB_\PCI0\GPP6\XPDV
/> acpi_get_node_alloc_cnt
nodes allocated: 6980
/> acpi_get_node_free_cnt
nodes freed: 328
/> acpi_get_node_cnt
nodes in namespace: 2240

View File

@ -10,3 +10,7 @@ acpi_preload_table machines/000/acpi/SSDT5
acpi_preload_table machines/000/acpi/SSDT6
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -74423,3 +74423,10 @@ aml._.get_node_by_name end
00:11.0 1022:7801 13 0 \_SB_\PCI0\SATA
00:14.1 FFFF:FFFF 00 0 \_SB_\PCI0\IDE_
00:18.3 0000:0000 00 1 \_SB_\PCI0\G3F3
/> acpi_get_node_alloc_cnt
nodes allocated: 4695
/> acpi_get_node_free_cnt
nodes freed: 530
/> acpi_get_node_cnt
nodes in namespace: 2128

View File

@ -6,3 +6,7 @@ acpi_preload_table machines/001/acpi/SSDT1
acpi_preload_table machines/001/acpi/SSDT2
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -279830,3 +279830,10 @@ aml._.get_node_by_name end
\_GPE\OSUP Method length:0x0000009D Args:1 serialize:1 sync_level:0
\_GPE\_L6D Method length:0x0000004C Args:0 serialize:1 sync_level:0
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 11935
/> acpi_get_node_free_cnt
nodes freed: 883
/> acpi_get_node_cnt
nodes in namespace: 5143

View File

@ -19,3 +19,7 @@ acpi_preload_table machines/002/acpi/SSDT11
acpi_preload_table machines/002/acpi/SSDT12
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -29380,3 +29380,10 @@ aml._.get_node_by_name end
00:00.0 0000:0000 00 1 \_SB_\PCI0\S00_
00:01.0 1234:1111 00 0 \_SB_\PCI0\S08_
00:02.0 8086:10D3 16 0 \_SB_\PCI0\S10_
/> acpi_get_node_alloc_cnt
nodes allocated: 1917
/> acpi_get_node_free_cnt
nodes freed: 6
/> acpi_get_node_cnt
nodes in namespace: 248

View File

@ -4,3 +4,7 @@ acpi_set_usage 2
acpi_preload_table machines/003/acpi/DSDT
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -74832,3 +74832,10 @@ aml._.get_node_by_name end
\_GPE\_L1D Method length:0x00000020 Args:0 serialize:0 sync_level:0
\_GPE\_L1F Method length:0x00000020 Args:0 serialize:0 sync_level:0
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 4097
/> acpi_get_node_free_cnt
nodes freed: 311
/> acpi_get_node_cnt
nodes in namespace: 1727

View File

@ -6,3 +6,7 @@ acpi_preload_table machines/004/acpi/SSDT2
acpi_preload_table machines/004/acpi/SSDT3
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -5130,3 +5130,10 @@ aml._.get_node_by_name end
\_PR_ Scope
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 197
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 109

View File

@ -5,3 +5,7 @@ acpi_preload_table machines/unit/acpi/scope_spec1.aml
acpi_preload_table machines/unit/acpi/scope.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -32882,3 +32882,10 @@ aml._.get_node_by_name end
00:1D.2 FFFF:FFFF 00 0 \_SB_\PCI0\AZAL
00:1F.0 10B9:5229 13 0 \_SB_\PCI0\IDEC
00:1F.1 10B9:5288 13 0 \_SB_\PCI0\SATA
/> acpi_get_node_alloc_cnt
nodes allocated: 1844
/> acpi_get_node_free_cnt
nodes freed: 46
/> acpi_get_node_cnt
nodes in namespace: 777

View File

@ -4,3 +4,7 @@ acpi_set_usage 2
acpi_preload_table machines/005/acpi/DSDT
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -100,6 +100,13 @@ acpi.aml.process_table end
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 11
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 9
/> acpi_call \MAIN
acpi.call_name begin
aml._.get_node_by_name begin
@ -444,3 +451,10 @@ acpi.call_node end
acpi.call_name end
calling acpi method: '\MAIN'
acpi method returned
/> acpi_get_node_alloc_cnt
nodes allocated: 29
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 9

View File

@ -4,4 +4,12 @@ acpi_preload_table machines/unit/acpi/debug_object.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -1792,6 +1792,13 @@ acpi.aml.process_table end
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 105
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 33
/> acpi_call \MAIN
acpi.call_name begin
aml._.get_node_by_name begin
@ -2210,3 +2217,10 @@ acpi.call_node end
acpi.call_name end
calling acpi method: '\MAIN'
acpi method returned
/> acpi_get_node_alloc_cnt
nodes allocated: 121
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 33

View File

@ -4,4 +4,12 @@ acpi_preload_table machines/unit/acpi/field.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -356873,3 +356873,10 @@ aml._.get_node_by_name end
00:1D.0 FFFF:FFFF 00 0 \_SB_\PCI0\SE8_
00:1E.0 FFFF:FFFF 00 0 \_SB_\PCI0\SF0_
00:1F.0 FFFF:FFFF 00 0 \_SB_\PCI0\SF8_
/> acpi_get_node_alloc_cnt
nodes allocated: 30850
/> acpi_get_node_free_cnt
nodes freed: 771
/> acpi_get_node_cnt
nodes in namespace: 282

View File

@ -4,3 +4,7 @@ acpi_set_usage 2
acpi_preload_table machines/006/acpi/DSDT
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -55739,3 +55739,10 @@ aml._.get_node_by_name end
00:01.0 0000:0000 00 1 \_SB_\PCI0\NPE1
00:03.0 0000:0000 00 1 \_SB_\PCI0\NPE3
00:07.0 0000:0000 00 1 \_SB_\PCI0\NPE7
/> acpi_get_node_alloc_cnt
nodes allocated: 3096
/> acpi_get_node_free_cnt
nodes freed: 68
/> acpi_get_node_cnt
nodes in namespace: 968

View File

@ -5,3 +5,7 @@ acpi_preload_table machines/007/acpi/DSDT
acpi_preload_table machines/007/acpi/SSDT
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -4,4 +4,12 @@ acpi_preload_table /data/work/mirror/acpica/tests/aslts/tmp/aml/20201217/nopt/64
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -152513,3 +152513,10 @@ aml._.get_node_by_name end
\_PR_\CPU0\HI0_ Integer = 0x0000000000000000
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 6311
/> acpi_get_node_free_cnt
nodes freed: 174
/> acpi_get_node_cnt
nodes in namespace: 2927

View File

@ -11,3 +11,7 @@ acpi_preload_table machines/008/acpi/ssdt7.dat
acpi_preload_table machines/008/acpi/ssdt8.dat
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -145788,3 +145788,10 @@ aml._.get_node_by_name end
\_PR_\CPU0\HI0_ Integer = 0x0000000000000000
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 6381
/> acpi_get_node_free_cnt
nodes freed: 173
/> acpi_get_node_cnt
nodes in namespace: 2764

View File

@ -10,3 +10,7 @@ acpi_preload_table machines/010/acpi/ssdt5.dat
acpi_preload_table machines/010/acpi/ssdt6.dat
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -0,0 +1,15 @@
acpi_set_usage 1
acpi_preload_table machines/unit/acpi/alloc_free.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

View File

@ -0,0 +1,114 @@
/> acpi_set_usage 1
/> acpi_preload_table machines/unit/acpi/alloc_free.aml
table #0
/> acpi_enable
acpi.aml.process_table begin
table length 0x00000032
Table signature: 'DSDT'
Table length (with header): 0x00000032
Revision: 0x01
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: INT5
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._.computational_data begin
aml._.byte_const begin
aml._.byte_const end
aml._.computational_data 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: [0x0000002B]
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: 0x00000006
aml._.name_string begin
aml._.name_string begin again
offset: 0x0000002D
aml._.name_path begin
aml._.name_path end
name_string: MAIN
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==========
\MAIN Method length:0x00000000 Args:0 serialize:0 sync_level:0
\INT5 Integer = 0x0000000000000005
\_TZ_ Scope
\_SI_ Scope
\_SB_ Scope
\_PR_ Scope
\_GPE Scope
-----------------------------
acpi.aml.process_table end
==========ACPI_TREE==========
\MAIN Method length:0x00000000 Args:0 serialize:0 sync_level:0
\INT5 Integer = 0x0000000000000005
\_TZ_ Scope
\_SI_ Scope
\_SB_ Scope
\_PR_ Scope
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 9
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 9
/> acpi_call \MAIN
acpi.call_name begin
aml._.get_node_by_name begin
name: '\MAIN'
aml._.get_node_by_name end
acpi.call_node begin
# func name MAIN
# bytes 0x00000000
# bytes 0x00000000
# bytes 0xDF590000
acpi.call_node end
acpi.call_name end
calling acpi method: '\MAIN'
acpi method returned
/> acpi_get_node_alloc_cnt
nodes allocated: 9
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 9

View File

@ -0,0 +1,67 @@
DefinitionBlock ("", "DSDT", 1, "UMKA ", "UMKADSDT", 0x00000001)
{
Name (INT5, 5)
Name (REF5, 2)
Method (AREF, 1) {
Debug = INT5
Debug = Arg0
Debug = REF5
Store("\n", Debug)
Local0 = RefOf(Arg0)
CopyObject(Local0, REF5)
CopyObject(RefOf(Arg0), REF5)
Local1 = DerefOf(Local0)
Local2 = DerefOf(Local0)
Local3 = RefOf(Local0)
Local4 = RefOf(REF5)
Local5 = RefOf(Local3)
Local6 = RefOf(Local5)
Local7 = RefOf(Local6)
Debug = Local0
Debug = Local1
Debug = Local2
Debug = Local3
Debug = Local4
Debug = Local5
Debug = Local6
Debug = Local7
Debug = INT5
Debug = REF5
Debug = DeRefOf(REF5)
Debug = DerefOf(Local0)
DeRefOf(Local0) = 0
DeRefOf(Local3) = 3
DeRefOf(Local4) = 4
DeRefOf(Local7) = 7
// DeRefOf(REF5) = 3
Local0 = 3
Local1 = 3
Local2 = 3
Store("\n", Debug)
Debug = Local0
Debug = Local1
Debug = Local2
Debug = Local3
Debug = Local4
Debug = Local5
Debug = Local6
Debug = Local7
Debug = INT5
Debug = Arg0
Debug = REF5
Debug = DeRefOf(REF5)
}
Method (MAIN, 0) {
AREF(INT5)
}
}

View File

@ -53,6 +53,9 @@ 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 acpi_node_alloc_cnt as 'kos_acpi_node_alloc_cnt'
public acpi_node_free_cnt as 'kos_acpi_node_free_cnt'
public acpi.count_nodes as 'kos_acpi_count_nodes'
public stack_init as 'kos_stack_init'
public net_add_device
@ -743,7 +746,7 @@ BTN_ADDR dd ?
MEM_AMOUNT rd 0x1d
SYS_SHUTDOWN db ?
sys_proc rd 0x800
rb 0xb202 ; align SLOT_BASE on 0x10000
rb 0xb142 ; align SLOT_BASE on 0x10000
SLOT_BASE: rd 0x8000
VGABasePtr rb 640*480
;rb 0x582 ; align HEAP_BASE on page boundary

3
umka.h
View File

@ -636,6 +636,9 @@ 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 uint32_t kos_acpi_node_alloc_cnt;
extern uint32_t kos_acpi_node_free_cnt;
extern uint32_t kos_acpi_count_nodes(void *ctx) __attribute__((__stdcall__));
extern disk_t disk_list;
static inline void