ACPI AML decompiler w/ CFG recovery and structured pseudocode
1#include "t.h"
2
3#include "cf.h"
4#include "dc.h"
5#include "p.h"
6
7int t_dc(void) {
8 uint8_t m2[] = {0x14,0x20,'W','L','O','0',0x01,0x70,0x0a,0x03,0x60,0xa2,0x13,0x60,0xa0,0x06,0x68,0x70,0x0a,0x01,0x61,0xa1,0x05,0x70,0x0a,0x02,0x61,0x74,0x60,0x01,0x60,0xa4,0x61};
9 tobi_parse_result r;
10 T_CHECK(tobi_parse(m2, sizeof(m2), 0, &r));
11 (void)tobi_cf_recover(r.root, &r.diag);
12 char *s = tobi_dc_emit(r.root, &r.diag);
13 T_STR(s, "method WLO0(args=1");
14 T_STR(s, "Local0 = 0x3");
15 T_STR(s, "while (Local0)");
16 T_STR(s, "if (Arg0)");
17 T_STR(s, " while");
18 T_STR(s, "return Local1");
19 free(s);
20 tobi_parse_result_free(&r);
21 uint8_t bad[] = {0xfe};
22 T_CHECK(tobi_parse(bad, sizeof(bad), 0, &r));
23 s = tobi_dc_emit(r.root, &r.diag);
24 T_STR(s, "unknown opcode 0xfe at 0x0");
25 free(s);
26 tobi_parse_result_free(&r);
27 return 0;
28}