]> git.saurik.com Git - apple/bootx.git/blame - bootx.tproj/include.subproj/ci.h
BootX-81.tar.gz
[apple/bootx.git] / bootx.tproj / include.subproj / ci.h
CommitLineData
04fee52e
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
8be739c0
A
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.
04fee52e 11 *
8be739c0
A
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
04fee52e
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
8be739c0
A
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.
04fee52e
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * ci.h - Headers for the OF Client Interface Library
24 *
366defd1 25 * Copyright (c) 1998-2002 Apple Computer, Inc.
04fee52e
A
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
37typedef long CICell;
38
39struct CIArgs {
40 char *service;
41 CICell nArgs;
42 CICell nReturns;
43
44 union {
366defd1
A
45 struct { // nArgs=1 + args, nReturns=1 + rets
46 const char *forth;
47 CICell cells[6 + 1 + 6];
48 } interpret;
49
50 struct { // nArgs=2 + args, nReturns=1 + rets
51 const char *method;
52 CICell iHandle;
53 CICell cells[6 + 1 + 6];
54 } callMethod;
55
04fee52e
A
56 struct { // nArgs=1, nReturns=1 ( device-specifier -- ihandle )
57 char *devSpec; // IN parameter
58 CICell ihandle; // RETURN value
59 } open;
366defd1 60
04fee52e
A
61 struct { // nArgs=1, nReturns=0 ( ihandle -- )
62 CICell ihandle; // IN parameter
63 } close;
366defd1 64
04fee52e
A
65 struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual )
66 CICell ihandle;
67 CICell addr;
68 CICell length;
69 CICell actual;
70 } read;
71
72 struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual )
73 CICell ihandle;
74 CICell addr;
75 CICell length;
76 CICell actual;
77 } write;
78
79 struct { // nArgs=3, nReturns=1 ( ihandle pos.high pos.low -- result )
80 CICell ihandle;
81 CICell pos_high;
82 CICell pos_low;
83 CICell result;
84 } seek;
85
86 struct { // nArgs=3, nReturns=1
87 CICell virt;
88 CICell size;
89 CICell align;
90 CICell baseaddr;
91 } claim;
92
93 struct { // nArgs=2, nReturns=0
94 CICell virt;
95 CICell size;
96 } release;
97
98 struct { // nArgs=1, nReturns=1 ( phandle -- peer-phandle )
99 CICell phandle; // IN parameter
100 CICell peerPhandle; // RETURN value
101 } peer;
102
103 struct { // nArgs=1, nReturns=1 ( phandle -- child-phandle )
104 CICell phandle; // IN parameter
105 CICell childPhandle; // RETURN value
106 } child;
107
108 struct { // nArgs=1, nReturns=1 ( phandle -- parent-phandle )
109 CICell childPhandle; // IN parameter
110 CICell parentPhandle; // RETURN value
111 } parent;
112
113 struct { // nArgs=1, nReturns=1 ( devSpec -- phandle )
114 char *devSpec; // IN parameter
115 CICell phandle; // RETURN value
116 } finddevice;
117
118 struct { // nArgs=3, nReturns=1 ( ihandle buf buflen -- length )
119 CICell ihandle; // IN ihandle
120 char *buf; // IN buf
121 CICell buflen; // IN buflen
122 CICell length; // RETURN length
123 } instanceToPath;
124
125 struct { // nArgs=1, nReturns=1 ( ihandle -- phandle )
126 CICell ihandle; // IN ihandle
127 CICell phandle; // RETURN phandle
128 } instanceToPackage;
129
130 struct { // nArgs=3, nReturns=1 ( phandle buf buflen -- length )
131 CICell phandle; // IN phandle
132 char *buf; // IN buf
133 CICell buflen; // IN buflen
134 CICell length; // RETURN length
135 } packageToPath;
136
137 struct { // nArgs=2, nReturns=1 ( phandle name -- size )
138 CICell phandle; // IN parameter
139 char *name; // IN parameter
140 CICell size; // RETURN value
141 } getproplen;
142
143 struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size )
144 CICell phandle; // IN parameter
145 char *name; // IN parameter
146 char *buf; // IN parameter
147 CICell buflen; // IN parameter
148 CICell size; // RETURN value
149 } getprop;
150
151 struct { // nArgs=3, nReturns=1 ( phandle previous buf -- flag )
152 CICell phandle; // IN parameter
153 char *previous; // IN parameter
154 char *buf; // IN parameter
155 CICell flag; // RETURN value
156 } nextprop;
157
158 struct { // nArgs=4, nReturns=1 ( phandle name buf buflen -- size )
159 CICell phandle; // IN parameter
160 char *name; // IN parameter
161 char *buf; // IN parameter
162 CICell buflen; // IN parameter
163 CICell size; // RETURN value
164 } setprop;
165
166 struct { // nArgs=1, nReturns=0
167 char *bootspec;
168 } boot;
169 } args;
170};
171typedef struct CIArgs CIArgs;
172
173typedef long (*ClientInterfacePtr)(CIArgs *args);
174
175// ci.c
176long InitCI(ClientInterfacePtr ciPtr);
04fee52e
A
177long CallCI(CIArgs *ciArgsPtr);
178
179// Device Tree
180CICell Peer(CICell phandle);
181CICell Child(CICell phandle);
182CICell Parent(CICell phandle);
183CICell FindDevice(char *devSpec);
184CICell InstanceToPath(CICell ihandle, char *buf, long buflen);
185CICell InstanceToPackage(CICell ihandle);
186CICell PackageToPath(CICell phandle, char *buf, long buflen);
187CICell GetPropLen(CICell phandle, char *name);
188CICell GetProp(CICell phandle, char *name, char *buf, long buflen);
189CICell NextProp(CICell phandle, char *previous, char *buf);
190CICell SetProp(CICell phandle, char *name, char *buf, long buflen);
191
192// Device I/O
193CICell Open(char *devSpec);
194void Close(CICell ihandle);
195CICell Read(CICell ihandle, long addr, long length);
196CICell Write(CICell ihandle, long addr, long length);
197CICell Seek(CICell ihandle, long long position);
198
199// Call Method
366defd1 200long CallMethod(long args, long rets, CICell iHandle, const char *method, ...);
04fee52e
A
201
202// Memory
203CICell Claim(CICell virt, CICell size, CICell align);
204void Release(CICell virt, CICell size);
205
206// Control Transfer
207void Boot(char *bootspec);
208void Enter(void);
209void Exit(void);
210void Quiesce(void);
211
366defd1
A
212// Interpret
213long Interpret(long args, long rets, const char *forthString, ...);
04fee52e
A
214
215#endif /* ! _BOOTX_CI_H_ */