-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsmoldtb.h
110 lines (89 loc) · 3.09 KB
/
smoldtb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SMOLDTB_INIT_EMPTY_TREE 0
typedef struct dtb_node_t dtb_node;
typedef struct dtb_prop_t dtb_prop;
typedef struct
{
uintmax_t a;
uintmax_t b;
} dtb_pair;
typedef struct
{
uintmax_t a;
uintmax_t b;
uintmax_t c;
} dtb_triplet;
typedef struct
{
uintmax_t a;
uintmax_t b;
uintmax_t c;
uintmax_t d;
} dtb_quad;
typedef struct
{
void* (*malloc)(size_t length);
void (*free)(void* ptr, size_t length);
void (*on_error)(const char* why);
} dtb_ops;
typedef struct
{
const char* name;
size_t child_count;
size_t prop_count;
size_t sibling_count;
} dtb_node_stat;
typedef struct
{
const char* name;
const void* data;
size_t data_len;
} dtb_prop_stat;
size_t dtb_query_total_size(uintptr_t fdt_start);
bool dtb_init(uintptr_t start, dtb_ops ops);
dtb_node* dtb_find_compatible(dtb_node* node, const char* str);
dtb_node* dtb_find_phandle(unsigned handle);
dtb_node* dtb_find(const char* path);
dtb_node* dtb_find_child(dtb_node* node, const char* name);
dtb_prop* dtb_find_prop(dtb_node* node, const char* name);
dtb_node* dtb_get_sibling(dtb_node* node);
dtb_node* dtb_get_child(dtb_node* node);
dtb_node* dtb_get_parent(dtb_node* node);
dtb_prop* dtb_get_prop(dtb_node* node, size_t index);
size_t dtb_get_addr_cells_of(dtb_node* node);
size_t dtb_get_size_cells_of(dtb_node* node);
size_t dtb_get_addr_cells_for(dtb_node* node);
size_t dtb_get_size_cells_for(dtb_node* node);
bool dtb_is_compatible(dtb_node* node, const char* str);
bool dtb_stat_node(dtb_node* node, dtb_node_stat* stat);
bool dtb_stat_prop(dtb_prop* prop, dtb_prop_stat* stat);
const char* dtb_read_prop_string(dtb_prop* prop, size_t index);
size_t dtb_read_prop_1(dtb_prop* prop, size_t cell_count, uintmax_t* vals);
size_t dtb_read_prop_2(dtb_prop* prop, dtb_pair layout, dtb_pair* vals);
size_t dtb_read_prop_3(dtb_prop* prop, dtb_triplet layout, dtb_triplet* vals);
size_t dtb_read_prop_4(dtb_prop* prop, dtb_quad layout, dtb_quad* vals);
#ifdef SMOLDTB_ENABLE_WRITE_API
#define SMOLDTB_FINALISE_FAILURE ((size_t)-1)
size_t dtb_finalise_to_buffer(void* buffer, size_t buffer_size, uint32_t boot_cpu_id);
dtb_node* dtb_find_or_create_node(const char* path);
dtb_prop* dtb_find_or_create_prop(dtb_node* node, const char* name);
dtb_node* dtb_create_sibling(dtb_node* node, const char* name);
dtb_node* dtb_create_child(dtb_node* node, const char* name);
dtb_prop* dtb_create_prop(dtb_node* node, const char* name);
bool dtb_destroy_node(dtb_node* node);
bool dtb_destroy_prop(dtb_prop* prop);
bool dtb_write_prop_string(dtb_prop* prop, const char* str, size_t str_len);
bool dtb_write_prop_1(dtb_prop* prop, size_t count, size_t cell_count, const uintmax_t* vals);
bool dtb_write_prop_2(dtb_prop* prop, size_t count, dtb_pair layout, const dtb_pair* vals);
bool dtb_write_prop_3(dtb_prop* prop, size_t count, dtb_triplet layout, const dtb_triplet* vals);
bool dtb_write_prop_4(dtb_prop* prop, size_t count, dtb_quad layout, const dtb_quad* vals);
#endif
#ifdef __cplusplus
}
#endif