]>
Commit | Line | Data |
---|---|---|
04fee52e A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
db839b1d | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
04fee52e | 7 | * |
db839b1d A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
04fee52e A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
db839b1d A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
04fee52e A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * ci.h - Headers for the OF Client Interface Library | |
27 | * | |
366defd1 | 28 | * Copyright (c) 1998-2002 Apple Computer, Inc. |
04fee52e A |
29 | * |
30 | * DRI: Josh de Cesare | |
31 | */ | |
32 | ||
33 | #ifndef _BOOTX_CI_H_ | |
34 | #define _BOOTX_CI_H_ | |
35 | ||
36 | #define kCINoError (0) | |
37 | #define kCIError (-1) | |
38 | #define kCICatch (-2) | |
39 | ||
40 | typedef long CICell; | |
41 | ||
42 | struct CIArgs { | |
43 | char *service; | |
44 | CICell nArgs; | |
45 | CICell nReturns; | |
46 | ||
47 | union { | |
366defd1 A |
48 | struct { // nArgs=1 + args, nReturns=1 + rets |
49 | const char *forth; | |
50 | CICell cells[6 + 1 + 6]; | |
51 | } interpret; | |
52 | ||
53 | struct { // nArgs=2 + args, nReturns=1 + rets | |
54 | const char *method; | |
55 | CICell iHandle; | |
56 | CICell cells[6 + 1 + 6]; | |
57 | } callMethod; | |
58 | ||
04fee52e A |
59 | struct { // nArgs=1, nReturns=1 ( device-specifier -- ihandle ) |
60 | char *devSpec; // IN parameter | |
61 | CICell ihandle; // RETURN value | |
62 | } open; | |
366defd1 | 63 | |
04fee52e A |
64 | struct { // nArgs=1, nReturns=0 ( ihandle -- ) |
65 | CICell ihandle; // IN parameter | |
66 | } close; | |
366defd1 | 67 | |
04fee52e A |
68 | struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual ) |
69 | CICell ihandle; | |
70 | CICell addr; | |
71 | CICell length; | |
72 | CICell actual; | |
73 | } read; | |
74 | ||
75 | struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual ) | |
76 | CICell ihandle; | |
77 | CICell addr; | |
78 | CICell length; | |
79 | CICell actual; | |
80 | } write; | |
81 | ||
82 | struct { // nArgs=3, nReturns=1 ( ihandle pos.high pos.low -- result ) | |
83 | CICell ihandle; | |
84 | CICell pos_high; | |
85 | CICell pos_low; | |
86 | CICell result; | |
87 | } seek; | |
88 | ||
89 | struct { // nArgs=3, nReturns=1 | |
90 | CICell virt; | |
91 | CICell size; | |
92 | CICell align; | |
93 | CICell baseaddr; | |
94 | } claim; | |
95 | ||
96 | struct { // nArgs=2, nReturns=0 | |
97 | CICell virt; | |
98 | CICell size; | |
99 | } release; | |
100 | ||
101 | struct { // nArgs=1, nReturns=1 ( phandle -- peer-phandle ) | |
102 | CICell phandle; // IN parameter | |
103 | CICell peerPhandle; // RETURN value | |
104 | } peer; | |
105 | ||
106 | struct { // nArgs=1, nReturns=1 ( phandle -- child-phandle ) | |
107 | CICell phandle; // IN parameter | |
108 | CICell childPhandle; // RETURN value | |
109 | } child; | |
110 | ||
111 | struct { // nArgs=1, nReturns=1 ( phandle -- parent-phandle ) | |
112 | CICell childPhandle; // IN parameter | |
113 | CICell parentPhandle; // RETURN value | |
114 | } parent; | |
115 | ||
116 | struct { // nArgs=1, nReturns=1 ( devSpec -- phandle ) | |
117 | char *devSpec; // IN parameter | |
118 | CICell phandle; // RETURN value | |
119 | } finddevice; | |
120 | ||
121 | struct { // nArgs=3, nReturns=1 ( ihandle buf buflen -- length ) | |
122 | CICell ihandle; // IN ihandle | |
123 | char *buf; // IN buf | |
124 | CICell buflen; // IN buflen | |
125 | CICell length; // RETURN length | |
126 | } instanceToPath; | |
127 | ||
128 | struct { // nArgs=1, nReturns=1 ( ihandle -- phandle ) | |
129 | CICell ihandle; // IN ihandle | |
130 | CICell phandle; // RETURN phandle | |
131 | } instanceToPackage; | |
132 | ||
133 | struct { // nArgs=3, nReturns=1 ( phandle buf buflen -- length ) | |
134 | CICell phandle; // IN phandle | |
135 | char *buf; // IN buf | |
136 | CICell buflen; // IN buflen | |
137 | CICell length; // RETURN length | |
138 | } packageToPath; | |
139 | ||
140 | struct { // nArgs=2, nReturns=1 ( phandle name -- size ) | |
141 | CICell phandle; // IN parameter | |
142 | char *name; // IN parameter | |
143 | CICell size; // RETURN value | |
144 | } getproplen; | |
145 | ||
146 | struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size ) | |
147 | CICell phandle; // IN parameter | |
148 | char *name; // IN parameter | |
149 | char *buf; // IN parameter | |
150 | CICell buflen; // IN parameter | |
151 | CICell size; // RETURN value | |
152 | } getprop; | |
153 | ||
154 | struct { // nArgs=3, nReturns=1 ( phandle previous buf -- flag ) | |
155 | CICell phandle; // IN parameter | |
156 | char *previous; // IN parameter | |
157 | char *buf; // IN parameter | |
158 | CICell flag; // RETURN value | |
159 | } nextprop; | |
160 | ||
161 | struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size ) | |
162 | CICell phandle; // IN parameter | |
163 | char *name; // IN parameter | |
164 | char *buf; // IN parameter | |
165 | CICell buflen; // IN parameter | |
166 | CICell size; // RETURN value | |
167 | } setprop; | |
168 | ||
169 | struct { // nArgs=1, nReturns=0 | |
170 | char *bootspec; | |
171 | } boot; | |
172 | } args; | |
173 | }; | |
174 | typedef struct CIArgs CIArgs; | |
175 | ||
176 | typedef long (*ClientInterfacePtr)(CIArgs *args); | |
177 | ||
178 | // ci.c | |
179 | long InitCI(ClientInterfacePtr ciPtr); | |
04fee52e A |
180 | long CallCI(CIArgs *ciArgsPtr); |
181 | ||
182 | // Device Tree | |
183 | CICell Peer(CICell phandle); | |
184 | CICell Child(CICell phandle); | |
185 | CICell Parent(CICell phandle); | |
186 | CICell FindDevice(char *devSpec); | |
187 | CICell InstanceToPath(CICell ihandle, char *buf, long buflen); | |
188 | CICell InstanceToPackage(CICell ihandle); | |
189 | CICell PackageToPath(CICell phandle, char *buf, long buflen); | |
190 | CICell GetPropLen(CICell phandle, char *name); | |
191 | CICell GetProp(CICell phandle, char *name, char *buf, long buflen); | |
192 | CICell NextProp(CICell phandle, char *previous, char *buf); | |
193 | CICell SetProp(CICell phandle, char *name, char *buf, long buflen); | |
194 | ||
195 | // Device I/O | |
196 | CICell Open(char *devSpec); | |
197 | void Close(CICell ihandle); | |
198 | CICell Read(CICell ihandle, long addr, long length); | |
199 | CICell Write(CICell ihandle, long addr, long length); | |
200 | CICell Seek(CICell ihandle, long long position); | |
201 | ||
202 | // Call Method | |
366defd1 | 203 | long CallMethod(long args, long rets, CICell iHandle, const char *method, ...); |
04fee52e A |
204 | |
205 | // Memory | |
206 | CICell Claim(CICell virt, CICell size, CICell align); | |
207 | void Release(CICell virt, CICell size); | |
208 | ||
209 | // Control Transfer | |
210 | void Boot(char *bootspec); | |
211 | void Enter(void); | |
212 | void Exit(void); | |
213 | void Quiesce(void); | |
214 | ||
366defd1 A |
215 | // Interpret |
216 | long Interpret(long args, long rets, const char *forthString, ...); | |
04fee52e A |
217 | |
218 | #endif /* ! _BOOTX_CI_H_ */ |