ACPI AML decompiler w/ CFG recovery and structured pseudocode
1#ifndef TOBI_NM_H
2#define TOBI_NM_H
3
4#include "rd.h"
5
6#include <stddef.h>
7#include <stdint.h>
8
9typedef enum tobi_ns_kind {
10 TOBI_NS_UNKNOWN,
11 TOBI_NS_SCOPE,
12 TOBI_NS_DEVICE,
13 TOBI_NS_METHOD,
14 TOBI_NS_PROCESSOR,
15 TOBI_NS_NAME,
16 TOBI_NS_ALIAS,
17 TOBI_NS_OPREGION,
18 TOBI_NS_FIELD,
19 TOBI_NS_MUTEX,
20 TOBI_NS_EVENT,
21 TOBI_NS_EXTERNAL
22} tobi_ns_kind;
23
24typedef struct tobi_ns_ent {
25 char *path;
26 char *name;
27 char *owner;
28 char *target;
29 tobi_ns_kind kind;
30 size_t off;
31 uint64_t region_offset;
32 uint64_t region_len;
33 unsigned args;
34 unsigned flags;
35 int has_region_range;
36 int external;
37} tobi_ns_ent;
38
39typedef struct tobi_ns {
40 tobi_ns_ent *items;
41 size_t len;
42 size_t cap;
43} tobi_ns;
44
45int tobi_nm_is_lead(unsigned char c);
46
47int tobi_nm_is_tail(unsigned char c);
48
49int tobi_nm_nameseg(tobi_rd *rd, char **out);
50
51int tobi_nm_namestring(tobi_rd *rd, char **out);
52
53char *tobi_nm_resolve(const char *scope, const char *name);
54
55void tobi_ns_init(tobi_ns *ns);
56
57void tobi_ns_free(tobi_ns *ns);
58
59const char *tobi_ns_kind_name(tobi_ns_kind kind);
60
61const char *tobi_ns_leaf(const char *path);
62
63tobi_ns_ent *tobi_ns_find(tobi_ns *ns, const char *path);
64
65const tobi_ns_ent *tobi_ns_find_const(const tobi_ns *ns, const char *path);
66
67const tobi_ns_ent *tobi_ns_find_method(const tobi_ns *ns, const char *name);
68
69const tobi_ns_ent *tobi_ns_lookup(const tobi_ns *ns, const char *scope, const char *name);
70
71char *tobi_ns_resolve_path(const tobi_ns *ns, const char *scope, const char *name);
72
73tobi_ns_ent *tobi_ns_add(tobi_ns *ns, tobi_ns_kind kind, const char *path, const char *owner,
74 size_t off, unsigned args, unsigned flags, int external,
75 const char *target, int *duplicate);
76
77#endif