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 char *source;
30 tobi_ns_kind kind;
31 size_t off;
32 uint64_t region_offset;
33 uint64_t region_len;
34 unsigned args;
35 unsigned flags;
36 int has_region_range;
37 int external;
38 size_t input_index;
39 int has_source;
40} tobi_ns_ent;
41
42typedef struct tobi_ns {
43 tobi_ns_ent *items;
44 size_t len;
45 size_t cap;
46} tobi_ns;
47
48int tobi_nm_is_lead(unsigned char c);
49
50int tobi_nm_is_tail(unsigned char c);
51
52int tobi_nm_nameseg(tobi_rd *rd, char **out);
53
54int tobi_nm_namestring(tobi_rd *rd, char **out);
55
56char *tobi_nm_resolve(const char *scope, const char *name);
57
58void tobi_ns_init(tobi_ns *ns);
59
60void tobi_ns_free(tobi_ns *ns);
61
62const char *tobi_ns_kind_name(tobi_ns_kind kind);
63
64const char *tobi_ns_leaf(const char *path);
65
66tobi_ns_ent *tobi_ns_find(tobi_ns *ns, const char *path);
67
68const tobi_ns_ent *tobi_ns_find_const(const tobi_ns *ns, const char *path);
69
70const tobi_ns_ent *tobi_ns_find_method(const tobi_ns *ns, const char *name);
71
72const tobi_ns_ent *tobi_ns_lookup(const tobi_ns *ns, const char *scope, const char *name);
73
74char *tobi_ns_resolve_path(const tobi_ns *ns, const char *scope, const char *name);
75
76tobi_ns_ent *tobi_ns_add(tobi_ns *ns, tobi_ns_kind kind, const char *path, const char *owner,
77 size_t off, unsigned args, unsigned flags, int external,
78 const char *target, int *duplicate);
79
80void tobi_ns_ent_set_source(tobi_ns_ent *e, const char *source, size_t input_index);
81
82void tobi_ns_set_source(tobi_ns *ns, const char *source, size_t input_index);
83
84#endif