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