Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-all / prep / startup / of1275.c
blob9e7270d12da9eaff70218e6573b6cf3e7e78dc0a
1 /*
2 * BK Id: SCCS/s.of1275.c 1.6 05/18/01 15:16:42 cort
3 */
4 /* Open Firmware Client Interface */
7 #include "of1275.h"
10 static int (*of_server)(void *) = (int(*)(void*))-1;
12 void
13 of_init(void *handler)
15 of_server = (int(*)(void*))handler;
19 /* 6.3.2.1 Client interface */
22 int
23 of_test(const char *name, int *missing)
25 int result;
26 static of_test_service s;
27 s.service = "test";
28 s.n_args = 1;
29 s.n_returns = 1;
30 s.name = name;
31 result = of_server(&s);
32 *missing = s.missing;
33 return result;
37 /* 6.3.2.2 Device tree */
40 int
41 of_peer(int phandle, int *sibling_phandle)
43 int result;
44 static of_peer_service s;
45 s.service = "peer";
46 s.n_args = 1;
47 s.n_returns = 1;
48 s.phandle = phandle;
49 result = of_server(&s);
50 *sibling_phandle = s.sibling_phandle;
51 return result;
54 int
55 of_child(int phandle, int *child_phandle)
57 int result;
58 static of_child_service s;
59 s.service = "child";
60 s.n_args = 1;
61 s.n_returns = 1;
62 s.phandle = phandle;
63 result = of_server(&s);
64 *child_phandle = s.child_phandle;
65 return result;
68 int
69 of_parent(int phandle, int *parent_phandle)
71 int result;
72 static of_parent_service s;
73 s.service = "parent";
74 s.n_args = 1;
75 s.n_returns = 1;
76 s.phandle = phandle;
77 result = of_server(&s);
78 *parent_phandle = s.parent_phandle;
79 return result;
82 int
83 of_instance_to_package(int ihandle, int *phandle)
85 int result;
86 static of_instance_to_package_service s;
87 s.service = "instance-to-package";
88 s.n_args = 1;
89 s.n_returns = 1;
90 s.ihandle = ihandle;
91 result = of_server(&s);
92 *phandle = s.phandle;
93 return result;
96 int
97 of_getproplen(int phandle, const char *name, int *proplen)
99 int result;
100 static of_getproplen_service s;
101 s.service = "getproplen";
102 s.n_args = 2;
103 s.n_returns = 1;
104 s.phandle = phandle;
105 s.name = name;
106 result = of_server(&s);
107 *proplen = s.proplen;
108 return result;
112 of_getprop(int phandle, const char *name, void *buf, int buflen, int *size)
114 int result;
115 static of_getprop_service s;
116 s.service = "getprop";
117 s.n_args = 4;
118 s.n_returns = 1;
119 s.phandle = phandle;
120 s.name = name;
121 s.buf = buf;
122 s.buflen = buflen;
123 result = of_server(&s);
124 *size = s.size;
125 return result;
129 of_nextprop(int phandle, const char *previous, void *buf, int *flag)
131 int result;
132 static of_nextprop_service s;
133 s.service = "nextprop";
134 s.n_args = 3;
135 s.n_returns = 1;
136 s.phandle = phandle;
137 s.previous = previous;
138 s.buf = buf;
139 result = of_server(&s);
140 *flag = s.flag;
141 return result;
145 of_setprop(int phandle, const char *name, void *buf, int len, int *size)
147 int result;
148 static of_setprop_service s;
149 s.service = "setprop";
150 s.n_args = 4;
151 s.n_returns = 1;
152 s.phandle = phandle;
153 s.name = name;
154 s.buf = buf;
155 s.len = len;
156 result = of_server(&s);
157 *size = s.size;
158 return result;
162 of_canon(const char *device_specifier, void *buf, int buflen, int *length)
164 int result;
165 static of_canon_service s;
166 s.service = "canon";
167 s.n_args = 3;
168 s.n_returns = 1;
169 s.device_specifier = device_specifier;
170 s.buf = buf;
171 s.buflen = buflen;
172 result = of_server(&s);
173 *length = s.length;
174 return result;
178 of_finddevice(const char *device_specifier, int *phandle)
180 int result;
181 static of_finddevice_service s;
182 s.service = "finddevice";
183 s.n_args = 1;
184 s.n_returns = 1;
185 s.device_specifier = device_specifier;
186 result = of_server(&s);
187 *phandle = s.phandle;
188 return result;
192 of_instance_to_path(int ihandle, void *buf, int buflen, int *length)
194 int result;
195 static of_instance_to_path_service s;
196 s.service = "instance-to-path";
197 s.n_args = 3;
198 s.n_returns = 1;
199 s.ihandle = ihandle;
200 s.buf = buf;
201 s.buflen = buflen;
202 result = of_server(&s);
203 *length = s.length;
204 return result;
208 of_package_to_path(int phandle, void *buf, int buflen, int *length)
210 int result;
211 static of_package_to_path_service s;
212 s.service = "package-to-path";
213 s.n_args = 3;
214 s.n_returns = 1;
215 s.phandle = phandle;
216 s.buf = buf;
217 s.buflen = buflen;
218 result = of_server(&s);
219 *length = s.length;
220 return result;
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)
232 int result;
233 static of_open_service s;
234 s.service = "open";
235 s.n_args = 1;
236 s.n_returns = 1;
237 s.device_specifier = device_specifier;
238 result = of_server(&s);
239 *ihandle = s.ihandle;
240 return result;
244 of_close(int ihandle)
246 int result;
247 static of_close_service s;
248 s.service = "close";
249 s.n_args = 1;
250 s.n_returns = 0;
251 s.ihandle = ihandle;
252 result = of_server(&s);
253 return result;
257 of_read(int ihandle, void *addr, int len, int *actual)
259 int result;
260 static of_read_service s;
261 s.service = "read";
262 s.n_args = 3;
263 s.n_returns = 1;
264 s.ihandle = ihandle;
265 s.addr = addr;
266 s.len = len;
267 result = of_server(&s);
268 *actual = s.actual;
269 return result;
273 of_write(int ihandle, void *addr, int len, int *actual)
275 int result;
276 static of_write_service s;
277 s.service = "write";
278 s.n_args = 3;
279 s.n_returns = 1;
280 s.ihandle = ihandle;
281 s.addr = addr;
282 s.len = len;
283 result = of_server(&s);
284 *actual = s.actual;
285 return result;
289 of_seek(int ihandle, int pos_hi, int pos_lo, int *status)
291 int result;
292 static of_seek_service s;
293 s.service = "seek";
294 s.n_args = 3;
295 s.n_returns = 1;
296 s.ihandle = ihandle;
297 s.pos_hi = pos_hi;
298 s.pos_lo = pos_lo;
299 result = of_server(&s);
300 *status = s.status;
301 return result;
305 /* 6.3.2.4 Memory */
309 of_claim(void *virt, int size, int align, void **baseaddr)
311 int result;
312 static of_claim_service s;
313 s.service = "claim";
314 s.n_args = 3;
315 s.n_returns = 1;
316 s.virt = virt;
317 s.size = size;
318 s.align = align;
319 result = of_server(&s);
320 *baseaddr = s.baseaddr;
321 return result;
325 of_release(void *virt, int size)
327 int result;
328 static of_release_service s;
329 s.service = "release";
330 s.n_args = 2;
331 s.n_returns = 0;
332 s.virt = virt;
333 s.size = size;
334 result = of_server(&s);
335 return result;
339 /* 6.3.2.5 Control transfer */
343 of_boot(const char *bootspec)
345 int result;
346 static of_boot_service s;
347 s.service = "boot";
348 s.n_args = 1;
349 s.n_returns = 0;
350 s.bootspec = bootspec;
351 result = of_server(&s);
352 return result;
356 of_enter(void)
358 int result;
359 static of_enter_service s;
360 s.service = "enter";
361 s.n_args = 0;
362 s.n_returns = 0;
363 result = of_server(&s);
364 return result;
368 of_exit(void)
370 int result;
371 static of_exit_service s;
372 s.service = "exit";
373 s.n_args = 0;
374 s.n_returns = 0;
375 result = of_server(&s);
376 return result;
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)
390 int result;
391 static of_set_callback_service s;
392 s.service = "set-callback";
393 s.n_args = 1;
394 s.n_returns = 1;
395 s.newfunc = newfunc;
396 result = of_server(&s);
397 *oldfunc = s.oldfunc;
398 return result;
402 of_set_symbol_lookup(void *sym_to_value, void *value_to_sym)
404 int result;
405 static of_set_symbol_lookup_service s;
406 s.service = "set-symbol-lookup";
407 s.n_args = 2;
408 s.n_returns = 0;
409 s.sym_to_value = sym_to_value;
410 s.value_to_sym = s.value_to_sym;
411 result = of_server(&s);
412 return result;
416 /* 6.3.2.7 Time */
420 of_milliseconds(int *ms)
422 int result;
423 static of_milliseconds_service s;
424 s.service = "milliseconds";
425 s.n_args = 0;
426 s.n_returns = 1;
427 result = of_server(&s);
428 *ms = s.ms;
429 return result;