2 * BK Id: SCCS/s.of1275.c 1.6 05/18/01 15:16:42 cort
4 /* Open Firmware Client Interface */
10 static int (*of_server
)(void *) = (int(*)(void*))-1;
13 of_init(void *handler
)
15 of_server
= (int(*)(void*))handler
;
19 /* 6.3.2.1 Client interface */
23 of_test(const char *name
, int *missing
)
26 static of_test_service s
;
31 result
= of_server(&s
);
37 /* 6.3.2.2 Device tree */
41 of_peer(int phandle
, int *sibling_phandle
)
44 static of_peer_service s
;
49 result
= of_server(&s
);
50 *sibling_phandle
= s
.sibling_phandle
;
55 of_child(int phandle
, int *child_phandle
)
58 static of_child_service s
;
63 result
= of_server(&s
);
64 *child_phandle
= s
.child_phandle
;
69 of_parent(int phandle
, int *parent_phandle
)
72 static of_parent_service s
;
77 result
= of_server(&s
);
78 *parent_phandle
= s
.parent_phandle
;
83 of_instance_to_package(int ihandle
, int *phandle
)
86 static of_instance_to_package_service s
;
87 s
.service
= "instance-to-package";
91 result
= of_server(&s
);
97 of_getproplen(int phandle
, const char *name
, int *proplen
)
100 static of_getproplen_service s
;
101 s
.service
= "getproplen";
106 result
= of_server(&s
);
107 *proplen
= s
.proplen
;
112 of_getprop(int phandle
, const char *name
, void *buf
, int buflen
, int *size
)
115 static of_getprop_service s
;
116 s
.service
= "getprop";
123 result
= of_server(&s
);
129 of_nextprop(int phandle
, const char *previous
, void *buf
, int *flag
)
132 static of_nextprop_service s
;
133 s
.service
= "nextprop";
137 s
.previous
= previous
;
139 result
= of_server(&s
);
145 of_setprop(int phandle
, const char *name
, void *buf
, int len
, int *size
)
148 static of_setprop_service s
;
149 s
.service
= "setprop";
156 result
= of_server(&s
);
162 of_canon(const char *device_specifier
, void *buf
, int buflen
, int *length
)
165 static of_canon_service s
;
169 s
.device_specifier
= device_specifier
;
172 result
= of_server(&s
);
178 of_finddevice(const char *device_specifier
, int *phandle
)
181 static of_finddevice_service s
;
182 s
.service
= "finddevice";
185 s
.device_specifier
= device_specifier
;
186 result
= of_server(&s
);
187 *phandle
= s
.phandle
;
192 of_instance_to_path(int ihandle
, void *buf
, int buflen
, int *length
)
195 static of_instance_to_path_service s
;
196 s
.service
= "instance-to-path";
202 result
= of_server(&s
);
208 of_package_to_path(int phandle
, void *buf
, int buflen
, int *length
)
211 static of_package_to_path_service s
;
212 s
.service
= "package-to-path";
218 result
= of_server(&s
);
223 /* int of_call_method(const char *method, int ihandle, ...); */
226 /* 6.3.2.3 Device I/O */
230 of_open(const char *device_specifier
, int *ihandle
)
233 static of_open_service s
;
237 s
.device_specifier
= device_specifier
;
238 result
= of_server(&s
);
239 *ihandle
= s
.ihandle
;
244 of_close(int ihandle
)
247 static of_close_service s
;
252 result
= of_server(&s
);
257 of_read(int ihandle
, void *addr
, int len
, int *actual
)
260 static of_read_service s
;
267 result
= of_server(&s
);
273 of_write(int ihandle
, void *addr
, int len
, int *actual
)
276 static of_write_service s
;
283 result
= of_server(&s
);
289 of_seek(int ihandle
, int pos_hi
, int pos_lo
, int *status
)
292 static of_seek_service s
;
299 result
= of_server(&s
);
309 of_claim(void *virt
, int size
, int align
, void **baseaddr
)
312 static of_claim_service s
;
319 result
= of_server(&s
);
320 *baseaddr
= s
.baseaddr
;
325 of_release(void *virt
, int size
)
328 static of_release_service s
;
329 s
.service
= "release";
334 result
= of_server(&s
);
339 /* 6.3.2.5 Control transfer */
343 of_boot(const char *bootspec
)
346 static of_boot_service s
;
350 s
.bootspec
= bootspec
;
351 result
= of_server(&s
);
359 static of_enter_service s
;
363 result
= of_server(&s
);
371 static of_exit_service s
;
375 result
= of_server(&s
);
379 /* int of_chain(void *virt, int size, void *entry, void *args, int len); */
382 /* 6.3.2.6 User interface */
385 /* int of_interpret(const char *arg, ...); */
388 of_set_callback(void *newfunc
, void **oldfunc
)
391 static of_set_callback_service s
;
392 s
.service
= "set-callback";
396 result
= of_server(&s
);
397 *oldfunc
= s
.oldfunc
;
402 of_set_symbol_lookup(void *sym_to_value
, void *value_to_sym
)
405 static of_set_symbol_lookup_service s
;
406 s
.service
= "set-symbol-lookup";
409 s
.sym_to_value
= sym_to_value
;
410 s
.value_to_sym
= s
.value_to_sym
;
411 result
= of_server(&s
);
420 of_milliseconds(int *ms
)
423 static of_milliseconds_service s
;
424 s
.service
= "milliseconds";
427 result
= of_server(&s
);