]>
Commit | Line | Data |
---|---|---|
04fee52e A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * ci.h - Headers for the OF Client Interface Library | |
24 | * | |
25 | * Copyright (c) 1998-2000 Apple Computer, Inc. | |
26 | * | |
27 | * DRI: Josh de Cesare | |
28 | */ | |
29 | ||
30 | #ifndef _BOOTX_CI_H_ | |
31 | #define _BOOTX_CI_H_ | |
32 | ||
33 | #define kCINoError (0) | |
34 | #define kCIError (-1) | |
35 | #define kCICatch (-2) | |
36 | ||
37 | typedef long CICell; | |
38 | ||
39 | struct CIArgs { | |
40 | char *service; | |
41 | CICell nArgs; | |
42 | CICell nReturns; | |
43 | ||
44 | union { | |
45 | struct { // nArgs=1, nReturns=1 | |
46 | char *forth; | |
47 | CICell catchResult; | |
48 | } interpret_0_0; | |
49 | ||
50 | struct { // nArgs=2, nReturns=1 | |
51 | char *forth; | |
52 | CICell arg1; | |
53 | CICell catchResult; | |
54 | } interpret_1_0; | |
55 | ||
56 | struct { // nArgs=2, nReturns=2 | |
57 | char *forth; | |
58 | CICell arg1; | |
59 | CICell catchResult; | |
60 | CICell return1; | |
61 | } interpret_1_1; | |
62 | ||
63 | struct { // nArgs=3, nReturns=2 | |
64 | char *forth; | |
65 | CICell arg1; | |
66 | CICell arg2; | |
67 | CICell catchResult; | |
68 | CICell return1; | |
69 | } interpret_2_1; | |
70 | ||
71 | struct { // nArgs=4, nReturns=2 | |
72 | char *forth; | |
73 | CICell arg1; | |
74 | CICell arg2; | |
75 | CICell arg3; | |
76 | CICell catchResult; | |
77 | CICell return1; | |
78 | } interpret_3_1; | |
79 | ||
80 | struct { // nArgs=4, nReturns=3 | |
81 | char *forth; | |
82 | CICell arg1; | |
83 | CICell arg2; | |
84 | CICell arg3; | |
85 | CICell catchResult; | |
86 | CICell return1; | |
87 | CICell return2; | |
88 | } interpret_3_2; | |
89 | ||
90 | struct { // nArgs=5, nReturns=1 | |
91 | char *forth; | |
92 | CICell arg1; | |
93 | CICell arg2; | |
94 | CICell arg3; | |
95 | CICell arg4; | |
96 | CICell catchResult; | |
97 | } interpret_4_0; | |
98 | ||
99 | struct { // nArgs=1, nReturns=2 | |
100 | char *forth; | |
101 | CICell catchResult; | |
102 | CICell return1; | |
103 | } interpret_0_1; | |
104 | ||
105 | struct { // nArgs=1, nReturns=3 | |
106 | char *forth; | |
107 | CICell catchResult; | |
108 | CICell return1; | |
109 | CICell return2; | |
110 | } interpret_0_2; | |
111 | ||
112 | struct { // nArgs=1, nReturns=4 | |
113 | char *forth; | |
114 | CICell catchResult; | |
115 | CICell return1; | |
116 | CICell return2; | |
117 | CICell return3; | |
118 | } interpret_0_3; | |
119 | ||
120 | struct { // nArgs=2, nReturns=4 | |
121 | char *forth; | |
122 | CICell arg1; | |
123 | CICell catchResult; | |
124 | CICell return1; | |
125 | CICell return2; | |
126 | CICell return3; | |
127 | } interpret_1_3; | |
128 | ||
129 | struct { // nArgs=3, nReturns=4 | |
130 | char *forth; | |
131 | CICell arg1; | |
132 | CICell arg2; | |
133 | CICell catchResult; | |
134 | CICell return1; | |
135 | CICell return2; | |
136 | CICell return3; | |
137 | } interpret_2_3; | |
138 | ||
139 | struct { // nArgs=3, nReturns=5 | |
140 | char *forth; | |
141 | CICell arg1; | |
142 | CICell arg2; | |
143 | CICell catchResult; | |
144 | CICell return1; | |
145 | CICell return2; | |
146 | CICell return3; | |
147 | CICell return4; | |
148 | } interpret_2_4; | |
149 | ||
150 | struct { // nArgs=3, nReturns=1 | |
151 | char *forth; | |
152 | CICell arg1; | |
153 | CICell arg2; | |
154 | CICell catchResult; | |
155 | } interpret_2_0; | |
156 | ||
157 | struct { // nArgs=3, nReturns=3 | |
158 | char *forth; | |
159 | CICell arg1; | |
160 | CICell arg2; | |
161 | CICell catchResult; | |
162 | CICell return1; | |
163 | CICell return2; | |
164 | } interpret_2_2; | |
165 | ||
166 | struct { // nArgs=4, nReturns=1 | |
167 | char *forth; | |
168 | CICell arg1; | |
169 | CICell arg2; | |
170 | CICell arg3; | |
171 | CICell catchResult; | |
172 | } interpret_3_0; | |
173 | ||
174 | struct { // nArgs=2, nReturns=1 | |
175 | char *method; | |
176 | CICell iHandle; | |
177 | CICell catchResult; | |
178 | } callMethod_0_0; | |
179 | ||
180 | struct { // nArgs=2, nReturns=2 | |
181 | char *method; | |
182 | CICell iHandle; | |
183 | CICell catchResult; | |
184 | CICell return1; | |
185 | } callMethod_0_1; | |
186 | ||
187 | struct { // nArgs=3, nReturns=1 | |
188 | char *method; | |
189 | CICell iHandle; | |
190 | CICell arg1; | |
191 | CICell catchResult; | |
192 | } callMethod_1_0; | |
193 | ||
194 | struct { // nArgs=3, nReturns=2 | |
195 | char *method; | |
196 | CICell iHandle; | |
197 | CICell arg1; | |
198 | CICell catchResult; | |
199 | CICell return1; | |
200 | } callMethod_1_1; | |
201 | ||
202 | struct { // nArgs=4, nReturns=1 | |
203 | char *method; | |
204 | CICell iHandle; | |
205 | CICell arg2; | |
206 | CICell arg1; | |
207 | CICell catchResult; | |
208 | } callMethod_2_0; | |
209 | ||
210 | struct { // nArgs=5, nReturns=1 | |
211 | char *method; | |
212 | CICell iHandle; | |
213 | CICell arg3; | |
214 | CICell arg2; | |
215 | CICell arg1; | |
216 | CICell catchResult; | |
217 | } callMethod_3_0; | |
218 | ||
219 | struct { // nArgs=5, nReturns=2 | |
220 | char *method; | |
221 | CICell iHandle; | |
222 | CICell arg3; | |
223 | CICell arg2; | |
224 | CICell arg1; | |
225 | CICell catchResult; | |
226 | CICell return1; | |
227 | } callMethod_3_1; | |
228 | ||
229 | struct { // nArgs=6, nReturns=1 | |
230 | char *method; | |
231 | CICell iHandle; | |
232 | CICell arg4; | |
233 | CICell arg3; | |
234 | CICell arg2; | |
235 | CICell arg1; | |
236 | CICell catchResult; | |
237 | } callMethod_4_0; | |
238 | ||
239 | struct { // nArgs=7, nReturns=1 | |
240 | char *method; | |
241 | CICell iHandle; | |
242 | CICell arg5; | |
243 | CICell arg4; | |
244 | CICell arg3; | |
245 | CICell arg2; | |
246 | CICell arg1; | |
247 | CICell catchResult; | |
248 | } callMethod_5_0; | |
249 | ||
250 | struct { // nArgs=8, nReturns=1 | |
251 | char *method; | |
252 | CICell iHandle; | |
253 | CICell arg6; | |
254 | CICell arg5; | |
255 | CICell arg4; | |
256 | CICell arg3; | |
257 | CICell arg2; | |
258 | CICell arg1; | |
259 | CICell catchResult; | |
260 | } callMethod_6_0; | |
261 | ||
262 | struct { // nArgs=1, nReturns=1 ( device-specifier -- ihandle ) | |
263 | char *devSpec; // IN parameter | |
264 | CICell ihandle; // RETURN value | |
265 | } open; | |
266 | ||
267 | struct { // nArgs=1, nReturns=0 ( ihandle -- ) | |
268 | CICell ihandle; // IN parameter | |
269 | } close; | |
270 | ||
271 | struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual ) | |
272 | CICell ihandle; | |
273 | CICell addr; | |
274 | CICell length; | |
275 | CICell actual; | |
276 | } read; | |
277 | ||
278 | struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual ) | |
279 | CICell ihandle; | |
280 | CICell addr; | |
281 | CICell length; | |
282 | CICell actual; | |
283 | } write; | |
284 | ||
285 | struct { // nArgs=3, nReturns=1 ( ihandle pos.high pos.low -- result ) | |
286 | CICell ihandle; | |
287 | CICell pos_high; | |
288 | CICell pos_low; | |
289 | CICell result; | |
290 | } seek; | |
291 | ||
292 | struct { // nArgs=3, nReturns=1 | |
293 | CICell virt; | |
294 | CICell size; | |
295 | CICell align; | |
296 | CICell baseaddr; | |
297 | } claim; | |
298 | ||
299 | struct { // nArgs=2, nReturns=0 | |
300 | CICell virt; | |
301 | CICell size; | |
302 | } release; | |
303 | ||
304 | struct { // nArgs=1, nReturns=1 ( phandle -- peer-phandle ) | |
305 | CICell phandle; // IN parameter | |
306 | CICell peerPhandle; // RETURN value | |
307 | } peer; | |
308 | ||
309 | struct { // nArgs=1, nReturns=1 ( phandle -- child-phandle ) | |
310 | CICell phandle; // IN parameter | |
311 | CICell childPhandle; // RETURN value | |
312 | } child; | |
313 | ||
314 | struct { // nArgs=1, nReturns=1 ( phandle -- parent-phandle ) | |
315 | CICell childPhandle; // IN parameter | |
316 | CICell parentPhandle; // RETURN value | |
317 | } parent; | |
318 | ||
319 | struct { // nArgs=1, nReturns=1 ( devSpec -- phandle ) | |
320 | char *devSpec; // IN parameter | |
321 | CICell phandle; // RETURN value | |
322 | } finddevice; | |
323 | ||
324 | struct { // nArgs=3, nReturns=1 ( ihandle buf buflen -- length ) | |
325 | CICell ihandle; // IN ihandle | |
326 | char *buf; // IN buf | |
327 | CICell buflen; // IN buflen | |
328 | CICell length; // RETURN length | |
329 | } instanceToPath; | |
330 | ||
331 | struct { // nArgs=1, nReturns=1 ( ihandle -- phandle ) | |
332 | CICell ihandle; // IN ihandle | |
333 | CICell phandle; // RETURN phandle | |
334 | } instanceToPackage; | |
335 | ||
336 | struct { // nArgs=3, nReturns=1 ( phandle buf buflen -- length ) | |
337 | CICell phandle; // IN phandle | |
338 | char *buf; // IN buf | |
339 | CICell buflen; // IN buflen | |
340 | CICell length; // RETURN length | |
341 | } packageToPath; | |
342 | ||
343 | struct { // nArgs=2, nReturns=1 ( phandle name -- size ) | |
344 | CICell phandle; // IN parameter | |
345 | char *name; // IN parameter | |
346 | CICell size; // RETURN value | |
347 | } getproplen; | |
348 | ||
349 | struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size ) | |
350 | CICell phandle; // IN parameter | |
351 | char *name; // IN parameter | |
352 | char *buf; // IN parameter | |
353 | CICell buflen; // IN parameter | |
354 | CICell size; // RETURN value | |
355 | } getprop; | |
356 | ||
357 | struct { // nArgs=3, nReturns=1 ( phandle previous buf -- flag ) | |
358 | CICell phandle; // IN parameter | |
359 | char *previous; // IN parameter | |
360 | char *buf; // IN parameter | |
361 | CICell flag; // RETURN value | |
362 | } nextprop; | |
363 | ||
364 | struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size ) | |
365 | CICell phandle; // IN parameter | |
366 | char *name; // IN parameter | |
367 | char *buf; // IN parameter | |
368 | CICell buflen; // IN parameter | |
369 | CICell size; // RETURN value | |
370 | } setprop; | |
371 | ||
372 | struct { // nArgs=1, nReturns=0 | |
373 | char *bootspec; | |
374 | } boot; | |
375 | } args; | |
376 | }; | |
377 | typedef struct CIArgs CIArgs; | |
378 | ||
379 | typedef long (*ClientInterfacePtr)(CIArgs *args); | |
380 | ||
381 | // ci.c | |
382 | long InitCI(ClientInterfacePtr ciPtr); | |
383 | ||
384 | long CallCI(CIArgs *ciArgsPtr); | |
385 | ||
386 | // Device Tree | |
387 | CICell Peer(CICell phandle); | |
388 | CICell Child(CICell phandle); | |
389 | CICell Parent(CICell phandle); | |
390 | CICell FindDevice(char *devSpec); | |
391 | CICell InstanceToPath(CICell ihandle, char *buf, long buflen); | |
392 | CICell InstanceToPackage(CICell ihandle); | |
393 | CICell PackageToPath(CICell phandle, char *buf, long buflen); | |
394 | CICell GetPropLen(CICell phandle, char *name); | |
395 | CICell GetProp(CICell phandle, char *name, char *buf, long buflen); | |
396 | CICell NextProp(CICell phandle, char *previous, char *buf); | |
397 | CICell SetProp(CICell phandle, char *name, char *buf, long buflen); | |
398 | ||
399 | // Device I/O | |
400 | CICell Open(char *devSpec); | |
401 | void Close(CICell ihandle); | |
402 | CICell Read(CICell ihandle, long addr, long length); | |
403 | CICell Write(CICell ihandle, long addr, long length); | |
404 | CICell Seek(CICell ihandle, long long position); | |
405 | ||
406 | // Call Method | |
407 | long CallMethod_0_0(CICell ihandle, char *method); | |
408 | long CallMethod_0_1(CICell ihandle, char *method, CICell *ret1); | |
409 | long CallMethod_1_0(CICell ihandle, char *method, CICell arg1); | |
410 | long CallMethod_1_1(CICell iHandle, char *method, CICell arg1, CICell *ret1); | |
411 | long CallMethod_2_0(CICell ihandle, char *method, | |
412 | CICell arg1, CICell arg2); | |
413 | long CallMethod_3_0(CICell ihandle, char *method, | |
414 | CICell arg1, CICell arg2, CICell arg3); | |
415 | long CallMethod_3_1(CICell ihandle, char *method, | |
416 | CICell arg1, CICell arg2, CICell arg3, CICell *ret1); | |
417 | long CallMethod_4_0(CICell ihandle, char *method, | |
418 | CICell arg1, CICell arg2, CICell arg3, CICell arg4); | |
419 | long CallMethod_5_0(CICell ihandle, char *method, CICell arg1, CICell arg2, | |
420 | CICell arg3, CICell arg4, CICell arg5); | |
421 | long CallMethod_6_0(CICell ihandle, char *method, CICell arg1, CICell arg2, | |
422 | CICell arg3, CICell arg4, CICell arg5, CICell arg6); | |
423 | ||
424 | // Memory | |
425 | CICell Claim(CICell virt, CICell size, CICell align); | |
426 | void Release(CICell virt, CICell size); | |
427 | ||
428 | // Control Transfer | |
429 | void Boot(char *bootspec); | |
430 | void Enter(void); | |
431 | void Exit(void); | |
432 | void Quiesce(void); | |
433 | ||
434 | // Interpret_n_m | |
435 | long Interpret_0_0(char *forthString); | |
436 | long Interpret_1_0(char *forthString, CICell arg1); | |
437 | long Interpret_1_1(char *forthString, CICell arg1, CICell *ret1); | |
438 | long Interpret_2_1(char *forthString, CICell arg1, CICell arg2, CICell *ret1); | |
439 | long Interpret_3_1(char *forthString, CICell arg1, CICell arg2, CICell arg3, | |
440 | CICell *ret1); | |
441 | long Interpret_3_2(char *forthString, CICell arg1, CICell arg2, CICell arg3, | |
442 | CICell *ret1, CICell *ret2); | |
443 | long Interpret_4_0(char *forthString, CICell arg1, CICell arg2, CICell arg3, | |
444 | CICell arg4); | |
445 | long Interpret_0_1(char *forthString, CICell *ret1); | |
446 | long Interpret_0_2(char *forthString, CICell *ret1, CICell *ret2); | |
447 | long Interpret_0_3(char *forthString, CICell *ret1, | |
448 | CICell *ret2, CICell *ret3); | |
449 | long Interpret_1_3(char *forthString, CICell arg1, CICell *ret1, CICell *ret2, | |
450 | CICell *ret3); | |
451 | long Interpret_2_3(char *forthString, CICell arg1, CICell arg2, CICell *ret1, | |
452 | CICell *ret2, CICell *ret3); | |
453 | long Interpret_2_4(char *forthString, CICell arg1, CICell arg2, CICell *ret1, | |
454 | CICell *ret2, CICell *ret3, CICell *ret4); | |
455 | long Interpret_2_0(char *forthString, CICell arg1, CICell arg2); | |
456 | long Interpret_2_2(char *forthString, CICell arg1, CICell arg2, CICell *ret1, | |
457 | CICell *ret2); | |
458 | long Interpret_3_0(char *forthString, CICell arg1, CICell arg2, CICell arg3); | |
459 | ||
460 | #endif /* ! _BOOTX_CI_H_ */ |