4 static int (*of1275_server
) (void *) = (int (*)(void *)) -1;
6 _start(void *residual_data_structure
,
7 void *program_entry_point
,
8 int (*client_interface_handler
) (void *), void *args
, int argslen
)
11 of1275_server
= client_interface_handler
;
16 /* 6.3.2.1 Client interface */
19 int of1275_test(const char *name
, int *missing
)
22 static of1275_test_service s
;
27 result
= of1275_server(&s
);
33 /* 6.3.2.2 Device tree */
36 int of1275_peer(int phandle
, int *sibling_phandle
)
39 static of1275_peer_service s
;
44 result
= of1275_server(&s
);
45 *sibling_phandle
= s
.sibling_phandle
;
49 int of1275_child(int phandle
, int *child_phandle
)
52 static of1275_child_service s
;
57 result
= of1275_server(&s
);
58 *child_phandle
= s
.child_phandle
;
62 int of1275_parent(int phandle
, int *parent_phandle
)
65 static of1275_parent_service s
;
70 result
= of1275_server(&s
);
71 *parent_phandle
= s
.parent_phandle
;
75 int of1275_instance_to_package(int ihandle
, int *phandle
)
78 static of1275_instance_to_package_service s
;
79 s
.service
= "instance-to-package";
83 result
= of1275_server(&s
);
88 int of1275_getproplen(int phandle
, const char *name
, int *proplen
)
91 static of1275_getproplen_service s
;
92 s
.service
= "getproplen";
97 result
= of1275_server(&s
);
103 of1275_getprop(int phandle
, const char *name
, void *buf
, int buflen
,
107 static of1275_getprop_service s
;
108 s
.service
= "getprop";
115 result
= of1275_server(&s
);
121 of1275_nextprop(int phandle
, const char *previous
, void *buf
, int *flag
)
124 static of1275_nextprop_service s
;
125 s
.service
= "nextprop";
129 s
.previous
= previous
;
131 result
= of1275_server(&s
);
137 of1275_setprop(int phandle
, const char *name
, void *buf
, int len
,
141 static of1275_setprop_service s
;
142 s
.service
= "setprop";
149 result
= of1275_server(&s
);
155 of1275_canon(const char *device_specifier
, void *buf
, int buflen
,
159 static of1275_canon_service s
;
163 s
.device_specifier
= device_specifier
;
166 result
= of1275_server(&s
);
171 int of1275_finddevice(const char *device_specifier
, int *phandle
)
174 static of1275_finddevice_service s
;
175 s
.service
= "finddevice";
178 s
.device_specifier
= device_specifier
;
179 result
= of1275_server(&s
);
180 *phandle
= s
.phandle
;
185 of1275_instance_to_path(int ihandle
, void *buf
, int buflen
, int *length
)
188 static of1275_instance_to_path_service s
;
189 s
.service
= "instance-to-path";
195 result
= of1275_server(&s
);
200 int of1275_package_to_path(int phandle
, void *buf
, int buflen
, int *length
)
203 static of1275_package_to_path_service s
;
204 s
.service
= "package-to-path";
210 result
= of1275_server(&s
);
215 /* int of1275_call_method(const char *method, int ihandle, ...); */
218 /* 6.3.2.3 Device I/O */
221 int of1275_open(const char *device_specifier
, int *ihandle
)
224 static of1275_open_service s
;
228 s
.device_specifier
= device_specifier
;
229 result
= of1275_server(&s
);
230 *ihandle
= s
.ihandle
;
234 int of1275_close(int ihandle
)
237 static of1275_close_service s
;
242 result
= of1275_server(&s
);
246 int of1275_read(int ihandle
, void *addr
, int len
, int *actual
)
249 static of1275_read_service s
;
256 result
= of1275_server(&s
);
261 int of1275_write(int ihandle
, void *addr
, int len
, int *actual
)
264 static of1275_write_service s
;
271 result
= of1275_server(&s
);
276 int of1275_seek(int ihandle
, int pos_hi
, int pos_lo
, int *status
)
279 static of1275_seek_service s
;
286 result
= of1275_server(&s
);
295 int of1275_claim(void *virt
, int size
, int align
, void **baseaddr
)
298 static of1275_claim_service s
;
305 result
= of1275_server(&s
);
306 *baseaddr
= s
.baseaddr
;
310 int of1275_release(void *virt
, int size
)
313 static of1275_release_service s
;
314 s
.service
= "release";
319 result
= of1275_server(&s
);
324 /* 6.3.2.5 Control transfer */
327 int of1275_boot(const char *bootspec
)
330 static of1275_boot_service s
;
334 s
.bootspec
= bootspec
;
335 result
= of1275_server(&s
);
339 int of1275_enter(void)
342 static of1275_enter_service s
;
346 result
= of1275_server(&s
);
350 int of1275_exit(int status
)
353 static of1275_exit_service s
;
358 result
= of1275_server(&s
);
362 /* int of1275_chain(void *virt, int size, void *entry, void *args, int len); */
365 /* 6.3.2.6 User interface */
368 /* int of1275_interpret(const char *arg, ...); */
370 int of1275_set_callback(void *newfunc
, void **oldfunc
)
373 static of1275_set_callback_service s
;
374 s
.service
= "set-callback";
378 result
= of1275_server(&s
);
379 *oldfunc
= s
.oldfunc
;
383 int of1275_set_symbol_lookup(void *sym_to_value
, void *value_to_sym
)
386 static of1275_set_symbol_lookup_service s
;
387 s
.service
= "set-symbol-lookup";
390 s
.sym_to_value
= sym_to_value
;
391 s
.value_to_sym
= s
.value_to_sym
;
392 result
= of1275_server(&s
);
399 int of1275_milliseconds(int *ms
)
402 static of1275_milliseconds_service s
;
403 s
.service
= "milliseconds";
406 result
= of1275_server(&s
);
412 int of_find_integer_property(const char *device
, const char *property
)
417 /* find the device's phandle */
418 if (of1275_finddevice(device
, &phandle
) < 0) {
419 //printk("of1275: no such device '%s'\n", device);
422 /* find the device's property */
423 of1275_getprop(phandle
, property
, &integer
,
424 sizeof(integer
), &size
);
425 if (size
< sizeof(integer
)) {
426 //printk("of1275: unknown integer property '%s'\n", property);
429 return ntohl(integer
);
433 of_find_string_property(const char *device
,
434 const char *property
,
435 char *string
, int sizeof_string
)
439 /* find the device's phandle */
440 if (of1275_finddevice(device
, &phandle
) < 0) {
441 //printk("of1275: no such device '%s'\n", device);
445 /* find the device's property */
446 of1275_getprop(phandle
, property
, string
, sizeof_string
, &size
);
447 if (size
== 0 || size
>= sizeof_string
) {
448 //printk("of1275: unknown string property '%s'\n", property);