summaryrefslogtreecommitdiffstats
path: root/arch/ppc/boot/of1275.c
blob: b82fa7a4695f333e2ac9caee34ba39807cfdac6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/* Open Firmware Client Interface */


#include "of1275.h"


static int (*of_server)(void *) = (int(*)(void*))-1;

void
of_init(void *handler)
{
	of_server = (int(*)(void*))handler;
}


/* 6.3.2.1 Client interface */


int
of_test(const char *name, int *missing)
{
	int result;
	static of_test_service s;
	s.service = "test";
	s.n_args = 1;
	s.n_returns = 1;
	s.name = name;
	result = of_server(&s);
	*missing = s.missing;
	return result;
}


/* 6.3.2.2 Device tree */


int
of_peer(int phandle, int *sibling_phandle)
{
	int result;
	static of_peer_service s;
	s.service = "peer";
	s.n_args = 1;
	s.n_returns = 1;
	s.phandle = phandle;
	result = of_server(&s);
	*sibling_phandle = s.sibling_phandle;
	return result;
}

int
of_child(int phandle, int *child_phandle)
{
	int result;
	static of_child_service s;
	s.service = "child";
	s.n_args = 1;
	s.n_returns = 1;
	s.phandle = phandle;
	result = of_server(&s);
	*child_phandle = s.child_phandle;
	return result;
}

int
of_parent(int phandle, int *parent_phandle)
{
	int result;
	static of_parent_service s;
	s.service = "parent";
	s.n_args = 1;
	s.n_returns = 1;
	s.phandle = phandle;
	result = of_server(&s);
	*parent_phandle = s.parent_phandle;
	return result;
}

int
of_instance_to_package(int ihandle, int *phandle)
{
	int result;
	static of_instance_to_package_service s;
	s.service = "instance-to-package";
	s.n_args = 1;
	s.n_returns = 1;
	s.ihandle = ihandle;
	result = of_server(&s);
	*phandle = s.phandle;
	return result;
}

int
of_getproplen(int phandle, const char *name, int *proplen)
{
	int result;
	static of_getproplen_service s;
	s.service = "getproplen";
	s.n_args = 2;
	s.n_returns = 1;
	s.phandle = phandle;
	s.name = name;
	result = of_server(&s);
	*proplen = s.proplen;
	return result;
}

int
of_getprop(int phandle, const char *name, void *buf, int buflen, int *size)
{
	int result;
	static of_getprop_service s;
	s.service = "getprop";
	s.n_args = 4;
	s.n_returns = 1;
	s.phandle = phandle;
	s.name = name;
	s.buf = buf;
	s.buflen = buflen;
	result = of_server(&s);
	*size = s.size;
	return result;
}

int
of_nextprop(int phandle, const char *previous, void *buf, int *flag)
{
	int result;
	static of_nextprop_service s;
	s.service = "nextprop";
	s.n_args = 3;
	s.n_returns = 1;
	s.phandle = phandle;
	s.previous = previous;
	s.buf = buf;
	result = of_server(&s);
	*flag = s.flag;
	return result;
}

int
of_setprop(int phandle, const char *name, void *buf, int len, int *size)
{
	int result;
	static of_setprop_service s;
	s.service = "setprop";
	s.n_args = 4;
	s.n_returns = 1;
	s.phandle = phandle;
	s.name = name;
	s.buf = buf;
	s.len = len;
	result = of_server(&s);
	*size = s.size;
	return result;
}

int
of_canon(const char *device_specifier, void *buf, int buflen, int *length)
{
	int result;
	static of_canon_service s;
	s.service = "canon";
	s.n_args = 3;
	s.n_returns = 1;
	s.device_specifier = device_specifier;
	s.buf = buf;
	s.buflen = buflen;
	result = of_server(&s);
	*length = s.length;
	return result;
}

int
of_finddevice(const char *device_specifier, int *phandle)
{
	int result;
	static of_finddevice_service s;
	s.service = "finddevice";
	s.n_args = 1;
	s.n_returns = 1;
	s.device_specifier = device_specifier;
	result = of_server(&s);
	*phandle = s.phandle;
	return result;
}

int
of_instance_to_path(int ihandle, void *buf, int buflen, int *length)
{
	int result;
	static of_instance_to_path_service s;
	s.service = "instance-to-path";
	s.n_args = 3;
	s.n_returns = 1;
	s.ihandle = ihandle;
	s.buf = buf;
	s.buflen = buflen;
	result = of_server(&s);
	*length = s.length;
	return result;
}

int
of_package_to_path(int phandle, void *buf, int buflen, int *length)
{
	int result;
	static of_package_to_path_service s;
	s.service = "package-to-path";
	s.n_args = 3;
	s.n_returns = 1;
	s.phandle = phandle;
	s.buf = buf;
	s.buflen = buflen;
	result = of_server(&s);
	*length = s.length;
	return result;
}

/* int of_call_method(const char *method, int ihandle, ...); */


/* 6.3.2.3 Device I/O */


int
of_open(const char *device_specifier, int *ihandle)
{
	int result;
	static of_open_service s;
	s.service = "open";
	s.n_args = 1;
	s.n_returns = 1;
	s.device_specifier = device_specifier;
	result = of_server(&s);
	*ihandle = s.ihandle;
	return result;
}

int
of_close(int ihandle)
{
	int result;
	static of_close_service s;
	s.service = "close";
	s.n_args = 1;
	s.n_returns = 0;
	s.ihandle = ihandle;
	result = of_server(&s);
	return result;
}

int
of_read(int ihandle, void *addr, int len, int *actual)
{
	int result;
	static of_read_service s;
	s.service = "read";
	s.n_args = 3;
	s.n_returns = 1;
	s.ihandle = ihandle;
	s.addr = addr;
	s.len = len;
	result = of_server(&s);
	*actual = s.actual;
	return result;
}

int
of_write(int ihandle, void *addr, int len, int *actual)
{
	int result;
	static of_write_service s;
	s.service = "write";
	s.n_args = 3;
	s.n_returns = 1;
	s.ihandle = ihandle;
	s.addr = addr;
	s.len = len;
	result = of_server(&s);
	*actual = s.actual;
	return result;
}

int
of_seek(int ihandle, int pos_hi, int pos_lo, int *status)
{
	int result;
	static of_seek_service s;
	s.service = "seek";
	s.n_args = 3;
	s.n_returns = 1;
	s.ihandle = ihandle;
	s.pos_hi = pos_hi;
	s.pos_lo = pos_lo;
	result = of_server(&s);
	*status = s.status;
	return result;
}


/* 6.3.2.4 Memory */


int
of_claim(void *virt, int size, int align, void **baseaddr)
{
	int result;
	static of_claim_service s;
	s.service = "claim";
	s.n_args = 3;
	s.n_returns = 1;
	s.virt = virt;
	s.size = size;
	s.align = align;
	result = of_server(&s);
	*baseaddr = s.baseaddr;
	return result;
}

int
of_release(void *virt, int size)
{
	int result;
	static of_release_service s;
	s.service = "release";
	s.n_args = 2;
	s.n_returns = 0;
	s.virt = virt;
	s.size = size;
	result = of_server(&s);
	return result;
}


/* 6.3.2.5 Control transfer */


int
of_boot(const char *bootspec)
{
	int result;
	static of_boot_service s;
	s.service = "boot";
	s.n_args = 1;
	s.n_returns = 0;
	s.bootspec = bootspec;
	result = of_server(&s);
	return result;
}

int
of_enter(void)
{
	int result;
	static of_enter_service s;
	s.service = "enter";
	s.n_args = 0;
	s.n_returns = 0;
	result = of_server(&s);
	return result;
}

int
of_exit(void)
{
	int result;
	static of_exit_service s;
	s.service = "exit";
	s.n_args = 0;
	s.n_returns = 0;
	result = of_server(&s);
	return result;
}

/* int of_chain(void *virt, int size, void *entry, void *args, int len); */


/* 6.3.2.6 User interface */


/* int of_interpret(const char *arg, ...); */

int
of_set_callback(void *newfunc, void **oldfunc)
{
	int result;
	static of_set_callback_service s;
	s.service = "set-callback";
	s.n_args = 1;
	s.n_returns = 1;
	s.newfunc = newfunc;
	result = of_server(&s);
	*oldfunc = s.oldfunc;
	return result;
}

int
of_set_symbol_lookup(void *sym_to_value, void *value_to_sym)
{
	int result;
	static of_set_symbol_lookup_service s;
	s.service = "set-symbol-lookup";
	s.n_args = 2;
	s.n_returns = 0;
	s.sym_to_value = sym_to_value;
	s.value_to_sym = s.value_to_sym;
	result = of_server(&s);
	return result;
}


/* 6.3.2.7 Time */


int
of_milliseconds(int *ms)
{
	int result;
	static of_milliseconds_service s;
	s.service = "milliseconds";
	s.n_args = 0;
	s.n_returns = 1;
	result = of_server(&s);
	*ms = s.ms;
	return result;
}