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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/* This file is part of the program psim.
Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _DEVICE_TREE_H_
#define _DEVICE_TREE_H_
#ifndef INLINE_DEVICE_TREE
#define INLINE_DEVICE_TREE
#endif
#include "devices.h"
typedef struct _device_tree device_tree;
/* extend the device tree, each function returns the address of the
new node */
INLINE_DEVICE_TREE device_tree *device_tree_add_passthrough
(device_tree *root,
const char *path);
INLINE_DEVICE_TREE device_tree *device_tree_add_device
(device_tree *root,
const char *path,
const device *dev);
INLINE_DEVICE_TREE device_tree *device_tree_add_integer
(device_tree *root,
const char *path,
signed_word integer);
INLINE_DEVICE_TREE device_tree *device_tree_add_string
(device_tree *root,
const char *path,
const char *string);
INLINE_DEVICE_TREE device_tree *device_tree_add_boolean
(device_tree *root,
const char *path,
int bool);
INLINE_DEVICE_TREE device_tree *device_tree_add_found_device
(device_tree *root,
const char *path);
/* query the device tree */
INLINE_DEVICE_TREE const device *device_tree_find_device
(device_tree *root,
const char *path);
INLINE_DEVICE_TREE signed_word device_tree_find_integer
(device_tree *root,
const char *path);
INLINE_DEVICE_TREE const char *device_tree_find_string
(device_tree *root,
const char *path);
INLINE_DEVICE_TREE int device_tree_find_boolean
(device_tree *root,
const char *path);
/* initialize the entire tree */
INLINE_DEVICE_TREE void device_tree_init
(device_tree *root,
psim *system);
/* traverse the tree eiter pre or post fix */
typedef void (device_tree_traverse_function)
(device_tree *device,
void *data);
INLINE_DEVICE_TREE void device_tree_traverse
(device_tree *root,
device_tree_traverse_function *prefix,
device_tree_traverse_function *postfix,
void *data);
/* dump a node, this can be passed to the device_tree_traverse()
function to dump out the entire device tree */
INLINE_DEVICE_TREE void device_tree_dump
(device_tree *device,
void *ignore_data_argument);
/* Parse a device name, various formats */
INLINE_DEVICE_TREE int scand_uw
(const char *name,
unsigned_word *uw1);
INLINE_DEVICE_TREE int scand_uw_u
(const char *name,
unsigned_word *uw1,
unsigned *u2);
INLINE_DEVICE_TREE int scand_uw_u_u
(const char *name,
unsigned_word *uw1,
unsigned *u2,
unsigned *u3);
INLINE_DEVICE_TREE int scand_uw_uw_u
(const char *name,
unsigned_word *uw1,
unsigned_word *uw2,
unsigned *u3);
INLINE_DEVICE_TREE int scand_c
(const char *name,
char *c1);
INLINE_DEVICE_TREE int scand_c_uw_u
(const char *name,
char *c1,
unsigned_word *uw2,
unsigned *u3);
INLINE_DEVICE_TREE char *printd_uw_u
(const char *name,
unsigned_word uw1,
unsigned u2);
INLINE_DEVICE_TREE char *printd_uw_u_u
(const char *name,
unsigned_word uw1,
unsigned u2,
unsigned u3);
INLINE_DEVICE_TREE char *printd_uw_u_u_c
(const char *name,
unsigned_word uw1,
unsigned u2,
unsigned u3,
const char *c4);
INLINE_DEVICE_TREE char *printd_c
(const char *name,
const char *c1);
INLINE_DEVICE_TREE char *printd_c_uw
(const char *name,
const char *c1,
unsigned_word uw2);
#endif /* _DEVICE_TREE_H_ */
|