1 /* OpenFirmware interface */
2 
3 
4 /* 6.3.2.1 Client interface */
5 
6 
7 typedef struct _of1275_test_service {
8 	const char *service;
9 	int n_args;
10 	int n_returns;
11 	/*in */
12 	const char *name;
13 	/*out */
14 	int missing;
15 } of1275_test_service;
16 
17 int of1275_test(const char *name, int *missing);
18 
19 
20 /* 6.3.2.2 Device tree */
21 
22 
23 typedef struct _of1275_peer_service {
24 	const char *service;
25 	int n_args;
26 	int n_returns;
27 	/*in */
28 	int phandle;
29 	/*out */
30 	int sibling_phandle;
31 } of1275_peer_service;
32 
33 int of1275_peer(int phandle, int *sibling_phandle);
34 
35 
36 typedef struct _of1275_child_service {
37 	const char *service;
38 	int n_args;
39 	int n_returns;
40 	/*in */
41 	int phandle;
42 	/*out */
43 	int child_phandle;
44 } of1275_child_service;
45 
46 int of1275_child(int phandle, int *child_phandle);
47 
48 
49 typedef struct _of1275_parent_service {
50 	const char *service;
51 	int n_args;
52 	int n_returns;
53 	/*in */
54 	int phandle;
55 	/*out */
56 	int parent_phandle;
57 } of1275_parent_service;
58 
59 int of1275_child(int phandle, int *parent_phandle);
60 
61 
62 typedef struct _of1275_instance_to_package_service {
63 	const char *service;
64 	int n_args;
65 	int n_returns;
66 	/*in */
67 	int ihandle;
68 	/*out */
69 	int phandle;
70 } of1275_instance_to_package_service;
71 
72 int of1275_instance_to_package(int ihandle, int *phandle);
73 
74 
75 typedef struct _of1275_getproplen_service {
76 	const char *service;
77 	int n_args;
78 	int n_returns;
79 	/*in */
80 	int phandle;
81 	const char *name;
82 	/*out */
83 	int proplen;
84 } of1275_getproplen_service;
85 
86 int of1275_getproplen(int phandle, const char *name, int *proplen);
87 
88 
89 typedef struct _of1275_getprop_service {
90 	const char *service;
91 	int n_args;
92 	int n_returns;
93 	/*in */
94 	int phandle;
95 	const char *name;
96 	void *buf;
97 	int buflen;
98 	/*out */
99 	int size;
100 } of1275_getprop_service;
101 
102 int of1275_getprop(int phandle, const char *name, void *buf, int buflen,
103 		   int *size);
104 
105 
106 typedef struct _of1275_nextprop_service {
107 	const char *service;
108 	int n_args;
109 	int n_returns;
110 	/*in */
111 	int phandle;
112 	const char *previous;
113 	void *buf;
114 	/*out */
115 	int flag;
116 } of1275_nextprop_service;
117 
118 int of1275_nextprop(int phandle, const char *previous, void *buf,
119 		    int *flag);
120 
121 
122 typedef struct _of1275_setprop_service {
123 	const char *service;
124 	int n_args;
125 	int n_returns;
126 	/*in */
127 	int phandle;
128 	const char *name;
129 	void *buf;
130 	int len;
131 	/*out */
132 	int size;
133 } of1275_setprop_service;
134 
135 int of1275_setprop(int phandle, const char *name, void *buf, int len,
136 		   int *size);
137 
138 
139 typedef struct _of1275_canon_service {
140 	const char *service;
141 	int n_args;
142 	int n_returns;
143 	/*in */
144 	const char *device_specifier;
145 	void *buf;
146 	int buflen;
147 	/*out */
148 	int length;
149 } of1275_canon_service;
150 
151 int of1275_canon(const char *device_specifier, void *buf, int buflen,
152 		 int *length);
153 
154 
155 typedef struct _of1275_finddevice_service {
156 	const char *service;
157 	int n_args;
158 	int n_returns;
159 	/*in */
160 	const char *device_specifier;
161 	/*out */
162 	int phandle;
163 } of1275_finddevice_service;
164 
165 int of1275_finddevice(const char *device_specifier, int *phandle);
166 
167 
168 typedef struct _of1275_instance_to_path_service {
169 	const char *service;
170 	int n_args;
171 	int n_returns;
172 	/*in */
173 	int ihandle;
174 	void *buf;
175 	int buflen;
176 	/*out */
177 	int length;
178 } of1275_instance_to_path_service;
179 
180 int of1275_instance_to_path(int ihandle, void *buf, int buflen,
181 			    int *length);
182 
183 
184 typedef struct _of1275_package_to_path_service {
185 	const char *service;
186 	int n_args;
187 	int n_returns;
188 	/*in */
189 	int phandle;
190 	void *buf;
191 	int buflen;
192 	/*out */
193 	int length;
194 } of1275_package_to_path_service;
195 
196 int of1275_package_to_path(int phandle, void *buf, int buflen,
197 			   int *length);
198 
199 
200 typedef struct _of1275_call_method_service {
201 	const char *service;
202 	int n_args;
203 	int n_returns;
204 	/*in */
205 	const char *method;
206 	int ihandle;
207 	/*... */
208 	int args[0];
209 } of1275_call_method_service;
210 
211 int of1275_call_method(const char *method, int ihandle, ...);
212 
213 
214 /* 6.3.2.3 Device I/O */
215 
216 
217 typedef struct _of1275_open_service {
218 	const char *service;
219 	int n_args;
220 	int n_returns;
221 	/*in */
222 	const char *device_specifier;
223 	/*out */
224 	int ihandle;
225 } of1275_open_service;
226 
227 int of1275_open(const char *device_specifier, int *ihandle);
228 
229 
230 typedef struct _of1275_close_service {
231 	const char *service;
232 	int n_args;
233 	int n_returns;
234 	/*in */
235 	int ihandle;
236 	/*out */
237 } of1275_close_service;
238 
239 int of1275_close(int ihandle);
240 
241 
242 typedef struct _of1275_read_service {
243 	const char *service;
244 	int n_args;
245 	int n_returns;
246 	/*in */
247 	int ihandle;
248 	void *addr;
249 	int len;
250 	/*out */
251 	int actual;
252 } of1275_read_service;
253 
254 int of1275_read(int ihandle, void *addr, int len, int *actual);
255 
256 
257 typedef struct _of1275_write_service {
258 	const char *service;
259 	int n_args;
260 	int n_returns;
261 	/*in */
262 	int ihandle;
263 	void *addr;
264 	int len;
265 	/*out */
266 	int actual;
267 } of1275_write_service;
268 
269 int of1275_write(int ihandle, void *addr, int len, int *actual);
270 
271 
272 typedef struct _of1275_seek_service {
273 	const char *service;
274 	int n_args;
275 	int n_returns;
276 	/*in */
277 	int ihandle;
278 	int pos_hi;
279 	int pos_lo;
280 	/*out */
281 	int status;
282 } of1275_seek_service;
283 
284 int of1275_seek(int ihandle, int pos_hi, int pos_lo, int *status);
285 
286 
287 /* 6.3.2.4 Memory */
288 
289 
290 typedef struct _of1275_claim_service {
291 	const char *service;
292 	int n_args;
293 	int n_returns;
294 	/*in */
295 	void *virt;
296 	int size;
297 	int align;
298 	/*out */
299 	void *baseaddr;
300 } of1275_claim_service;
301 
302 int of1275_claim(void *virt, int size, int align, void **baseaddr);
303 
304 
305 typedef struct _of1275_release_service {
306 	const char *service;
307 	int n_args;
308 	int n_returns;
309 	/*in */
310 	void *virt;
311 	int size;
312 	int align;
313 	/*out */
314 } of1275_release_service;
315 
316 int of1275_release(void *virt, int size);
317 
318 
319 /* 6.3.2.5 Control transfer */
320 
321 
322 typedef struct _of1275_boot_service {
323 	const char *service;
324 	int n_args;
325 	int n_returns;
326 	/*in */
327 	const char *bootspec;
328 	/*out */
329 } of1275_boot_service;
330 
331 int of1275_boot(const char *bootspec);
332 
333 
334 typedef struct _of1275_enter_service {
335 	const char *service;
336 	int n_args;
337 	int n_returns;
338 	/*in */
339 	/*out */
340 } of1275_enter_service;
341 
342 int of1275_enter(void);
343 
344 typedef struct _of1275_exit_service {
345 	const char *service;
346 	int n_args;
347 	int n_returns;
348 	/*in */
349 	int status;
350 	/*out */
351 } of1275_exit_service;
352 
353 int of1275_exit(int status);
354 
355 
356 typedef struct _of1275_chain_service {
357 	const char *service;
358 	int n_args;
359 	int n_returns;
360 	/*in */
361 	void *virt;
362 	int size;
363 	void *entry;
364 	void *args;
365 	int len;
366 	/*out */
367 } of1275_chain_service;
368 
369 int of1275_chain(void *virt, int size, void *entry, void *args, int len);
370 
371 
372 /* 6.3.2.6 User interface */
373 
374 
375 typedef struct _of1275_interpret_service {
376 	const char *service;
377 	int n_args;
378 	int n_returns;
379 	/*in */
380 	const char *cmd;
381 	int args[0];
382 	/*... */
383 	/*out */
384 	/*... */
385 } of1275_interpret_service;
386 
387 int of1275_interpret(const char *arg, ...);
388 
389 
390 typedef struct _of1275_set_callback_service {
391 	const char *service;
392 	int n_args;
393 	int n_returns;
394 	/*in */
395 	void *newfunc;
396 	/*out */
397 	void *oldfunc;
398 } of1275_set_callback_service;
399 
400 int of1275_set_callback(void *newfunc, void **oldfunc);
401 
402 
403 typedef struct _of1275_set_symbol_lookup_service {
404 	const char *service;
405 	int n_args;
406 	int n_returns;
407 	/*in */
408 	void *sym_to_value;
409 	void *value_to_sym;
410 	/*out */
411 } of1275_set_symbol_lookup_service;
412 
413 int of1275_set_symbol_lookup(void *sym_to_value, void *value_to_sym);
414 
415 
416 /* 6.3.2.7 Time */
417 
418 
419 typedef struct _of1275_milliseconds_service {
420 	const char *service;
421 	int n_args;
422 	int n_returns;
423 	/*in */
424 	/*out */
425 	int ms;
426 } of1275_milliseconds_service;
427 
428 int of1275_milliseconds(int *ms);
429 
430 
431 /* Common and useful utilities */
432 
433 
434 int of_find_integer_property(const char *path, const char *property);
435 
436 void of_find_string_property(const char *path, const char *property,
437 			     char *string, int sizeof_string);
438