ACPI AML decompiler w/ CFG recovery and structured pseudocode
1#include "t.h"
2
3#include "da.h"
4#include "p.h"
5
6int t_da(void) {
7 uint8_t m0[] = {0x14,0x0c,'M','T','H','0',0x01,0x70,0x0a,0x2a,0x60,0xa4,0x60};
8 tobi_parse_result r;
9 T_CHECK(tobi_parse(m0, sizeof(m0), 0, &r));
10 char *s = tobi_da_emit(m0, sizeof(m0), &r.meta);
11 T_STR(s, "0x0000: MethodOp");
12 T_STR(s, "operands=PkgLength NameString MethodFlags TermList");
13 T_STR(s, "pkglen=12");
14 T_STR(s, "StoreOp");
15 free(s);
16 tobi_parse_result_free(&r);
17 uint8_t buf[] = {0x08,'B','U','F','0',0x11,0x05,0x0a,0x02,0xaa,0xbb};
18 T_CHECK(tobi_parse(buf, sizeof(buf), 0, &r));
19 s = tobi_da_emit(buf, sizeof(buf), &r.meta);
20 T_STR(s, "BufferOp");
21 T_STR(s, "BufferData len=2");
22 T_CHECK(strstr(s, "UnknownOp opcode=0xaa") == NULL);
23 free(s);
24 tobi_parse_result_free(&r);
25 uint8_t bad[] = {0xfe,0x14,0xff};
26 T_CHECK(tobi_parse(bad, sizeof(bad), 0, &r));
27 s = tobi_da_emit(bad, sizeof(bad), &r.meta);
28 T_STR(s, "UnknownOp");
29 free(s);
30 tobi_parse_result_free(&r);
31 return 0;
32}