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
1.7 kB 52 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, "\"checksum_sum\":0"); 14 T_STR(s, "\"checksum_valid\":false"); 15 T_STR(s, "\"header_hash\":0"); 16 T_STR(s, "\"aml_hash\":"); 17 T_STR(s, "\"oem_id\":\"\""); 18 T_STR(s, "\"namespace\":["); 19 T_STR(s, "\"path\":\"\\\\STR0\""); 20 T_STR(s, "\"kind\":\"name\""); 21 T_STR(s, "a\\\"b\\\\c"); 22 T_STR(s, "\"raw_opcode\":254"); 23 T_CHECK(strstr(s, ",}") == NULL); 24 T_CHECK(strstr(s, ",]") == NULL); 25 free(s); 26 tobi_parse_result_free(&r); 27 28 uint8_t res[] = {0x11,0x05,0x0a,0x02,0x79,0x00}; 29 T_CHECK(tobi_parse(res, sizeof(res), 0, &r)); 30 s = tobi_js_emit(&r); 31 T_STR(s, "\"kind\":\"resource\""); 32 T_STR(s, "\"name\":\"EndTag\""); 33 T_STR(s, "\"string\":\"checksum=0x0\""); 34 T_CHECK(strstr(s, ",}") == NULL); 35 T_CHECK(strstr(s, ",]") == NULL); 36 free(s); 37 tobi_parse_result_free(&r); 38 39 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}; 40 T_CHECK(tobi_parse(fld, sizeof(fld), 0, &r)); 41 s = tobi_js_emit(&r); 42 T_STR(s, "\"target\":\"region=\\\\REG0 space=SystemIO"); 43 T_STR(s, "\"bit_offset\":0"); 44 T_STR(s, "\"bit_length\":8"); 45 T_STR(s, "\"access_type\":0"); 46 T_STR(s, "absolute_byte=0x10"); 47 T_CHECK(strstr(s, ",}") == NULL); 48 T_CHECK(strstr(s, ",]") == NULL); 49 free(s); 50 tobi_parse_result_free(&r); 51 return 0; 52}