ACPI AML decompiler w/ CFG recovery and structured pseudocode
29

Configure Feed

Select the types of activity you want to include in your feed.

tobi / test / t_js.c
2.3 kB 70 lines
1#include "t.h" 2 3#include "js.h" 4#include "p.h" 5 6int t_js(void) { 7 uint8_t data[] = {0x08,'S','T','R','0',0x0d,'a','"','b','\\','c',0x00,0xfe}; 8 tobi_parse_result r; 9 T_CHECK(tobi_parse(data, sizeof(data), 0, &r)); 10 char *s = tobi_js_emit(&r); 11 T_STR(s, "\"kind\":\"root\""); 12 T_STR(s, "\"source\":\"raw\""); 13 T_STR(s, "\"inputs\":["); 14 T_STR(s, "\"checksum_sum\":0"); 15 T_STR(s, "\"checksum_valid\":false"); 16 T_STR(s, "\"header_hash\":0"); 17 T_STR(s, "\"aml_hash\":"); 18 T_STR(s, "\"oem_id\":\"\""); 19 T_STR(s, "\"namespace\":["); 20 T_STR(s, "\"path\":\"\\\\STR0\""); 21 T_STR(s, "\"kind\":\"name\""); 22 T_STR(s, "a\\\"b\\\\c"); 23 T_STR(s, "\"raw_opcode\":254"); 24 T_CHECK(strstr(s, ",}") == NULL); 25 T_CHECK(strstr(s, ",]") == NULL); 26 free(s); 27 tobi_parse_result_free(&r); 28 29 uint8_t bad[] = {0x14,0x20,'M','T'}; 30 tobi_parse_input inputs[] = { 31 {data, sizeof(data), "good.aml"}, 32 {bad, sizeof(bad), "bad.aml"} 33 }; 34 T_CHECK(tobi_parse_multi(inputs, 2, 0, &r)); 35 s = tobi_js_emit(&r); 36 T_STR(s, "\"source\":\"good.aml\""); 37 T_STR(s, "\"source\":\"bad.aml\""); 38 T_STR(s, "\"input_index\":1"); 39 T_STR(s, "\"diagnostics\":["); 40 T_STR(s, "bad method name"); 41 T_CHECK(strstr(s, ",}") == NULL); 42 T_CHECK(strstr(s, ",]") == NULL); 43 free(s); 44 tobi_parse_result_free(&r); 45 46 uint8_t res[] = {0x11,0x05,0x0a,0x02,0x79,0x00}; 47 T_CHECK(tobi_parse(res, sizeof(res), 0, &r)); 48 s = tobi_js_emit(&r); 49 T_STR(s, "\"kind\":\"resource\""); 50 T_STR(s, "\"name\":\"EndTag\""); 51 T_STR(s, "\"string\":\"checksum=0x0\""); 52 T_CHECK(strstr(s, ",}") == NULL); 53 T_CHECK(strstr(s, ",]") == NULL); 54 free(s); 55 tobi_parse_result_free(&r); 56 57 uint8_t fld[] = {0x5b,0x80,'R','E','G','0',0x01,0x0a,0x10,0x0a,0x04,0x5b,0x81,0x0b,'R','E','G','0',0x00,'F','L','D','0',0x08}; 58 T_CHECK(tobi_parse(fld, sizeof(fld), 0, &r)); 59 s = tobi_js_emit(&r); 60 T_STR(s, "\"target\":\"region=\\\\REG0 space=SystemIO"); 61 T_STR(s, "\"bit_offset\":0"); 62 T_STR(s, "\"bit_length\":8"); 63 T_STR(s, "\"access_type\":0"); 64 T_STR(s, "absolute_byte=0x10"); 65 T_CHECK(strstr(s, ",}") == NULL); 66 T_CHECK(strstr(s, ",]") == NULL); 67 free(s); 68 tobi_parse_result_free(&r); 69 return 0; 70}