summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/include/rtems/bsd/local/ofw_if.h
blob: 1bf051b2cc4abc8f236508e1d392be0d23b7825b (plain) (blame)
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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
/*
 * This file is produced automatically.
 * Do not modify anything in here by hand.
 *
 * Created from source file
 *   freebsd-org/sys/dev/ofw/ofw_if.m
 * with
 *   makeobjops.awk
 *
 * See the source file for legal information
 */

/**
 * @defgroup OFW ofw - KObj methods for Open Firmware RTAS implementations
 * @brief A set of methods to implement the Open Firmware client side interface.
 * @{
 */

#ifndef _ofw_if_h_
#define _ofw_if_h_

/** @brief Unique descriptor for the OFW_INIT() method */
extern struct kobjop_desc ofw_init_desc;
/** @brief A function implementing the OFW_INIT() method */
typedef int ofw_init_t(ofw_t _ofw, void *_cookie);
/**
 * @brief Initialize OFW client interface
 *
 * @param _cookie	A handle to the client interface, generally the OF
 *			callback routine.
 */

static __inline int OFW_INIT(ofw_t _ofw, void *_cookie)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_init);
	return ((ofw_init_t *) _m)(_ofw, _cookie);
}

/** @brief Unique descriptor for the OFW_PEER() method */
extern struct kobjop_desc ofw_peer_desc;
/** @brief A function implementing the OFW_PEER() method */
typedef phandle_t ofw_peer_t(ofw_t _ofw, phandle_t _node);
/**
 * @brief Return next sibling of node.
 *
 * @param _node		Selected node
 */

static __inline phandle_t OFW_PEER(ofw_t _ofw, phandle_t _node)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_peer);
	return ((ofw_peer_t *) _m)(_ofw, _node);
}

/** @brief Unique descriptor for the OFW_PARENT() method */
extern struct kobjop_desc ofw_parent_desc;
/** @brief A function implementing the OFW_PARENT() method */
typedef phandle_t ofw_parent_t(ofw_t _ofw, phandle_t _node);
/**
 * @brief Return parent of node.
 *
 * @param _node		Selected node
 */

static __inline phandle_t OFW_PARENT(ofw_t _ofw, phandle_t _node)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_parent);
	return ((ofw_parent_t *) _m)(_ofw, _node);
}

/** @brief Unique descriptor for the OFW_CHILD() method */
extern struct kobjop_desc ofw_child_desc;
/** @brief A function implementing the OFW_CHILD() method */
typedef phandle_t ofw_child_t(ofw_t _ofw, phandle_t _node);
/**
 * @brief Return first child of node.
 *
 * @param _node		Selected node
 */

static __inline phandle_t OFW_CHILD(ofw_t _ofw, phandle_t _node)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_child);
	return ((ofw_child_t *) _m)(_ofw, _node);
}

/** @brief Unique descriptor for the OFW_INSTANCE_TO_PACKAGE() method */
extern struct kobjop_desc ofw_instance_to_package_desc;
/** @brief A function implementing the OFW_INSTANCE_TO_PACKAGE() method */
typedef phandle_t ofw_instance_to_package_t(ofw_t _ofw, ihandle_t _handle);
/**
 * @brief Return package corresponding to instance.
 *
 * @param _handle	Selected instance
 */

static __inline phandle_t OFW_INSTANCE_TO_PACKAGE(ofw_t _ofw, ihandle_t _handle)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_instance_to_package);
	return ((ofw_instance_to_package_t *) _m)(_ofw, _handle);
}

/** @brief Unique descriptor for the OFW_GETPROPLEN() method */
extern struct kobjop_desc ofw_getproplen_desc;
/** @brief A function implementing the OFW_GETPROPLEN() method */
typedef ssize_t ofw_getproplen_t(ofw_t _ofw, phandle_t _node,
                                 const char *_prop);
/**
 * @brief Return length of node property.
 *
 * @param _node		Selected node
 * @param _prop		Property name
 */

static __inline ssize_t OFW_GETPROPLEN(ofw_t _ofw, phandle_t _node,
                                       const char *_prop)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_getproplen);
	return ((ofw_getproplen_t *) _m)(_ofw, _node, _prop);
}

/** @brief Unique descriptor for the OFW_GETPROP() method */
extern struct kobjop_desc ofw_getprop_desc;
/** @brief A function implementing the OFW_GETPROP() method */
typedef ssize_t ofw_getprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
                              void *_buf, size_t _size);
/**
 * @brief Read node property.
 *
 * @param _node		Selected node
 * @param _prop		Property name
 * @param _buf		Pointer to buffer
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_GETPROP(ofw_t _ofw, phandle_t _node,
                                    const char *_prop, void *_buf, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_getprop);
	return ((ofw_getprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
}

/** @brief Unique descriptor for the OFW_NEXTPROP() method */
extern struct kobjop_desc ofw_nextprop_desc;
/** @brief A function implementing the OFW_NEXTPROP() method */
typedef int ofw_nextprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
                           char *_buf, size_t _size);
/**
 * @brief Get next property name.
 *
 * @param _node		Selected node
 * @param _prop		Current property name
 * @param _buf		Buffer for next property name
 * @param _size		Size of buffer
 */

static __inline int OFW_NEXTPROP(ofw_t _ofw, phandle_t _node, const char *_prop,
                                 char *_buf, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_nextprop);
	return ((ofw_nextprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
}

/** @brief Unique descriptor for the OFW_SETPROP() method */
extern struct kobjop_desc ofw_setprop_desc;
/** @brief A function implementing the OFW_SETPROP() method */
typedef int ofw_setprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
                          const void *_buf, size_t _size);
/**
 * @brief Set property.
 *
 * @param _node		Selected node
 * @param _prop		Property name
 * @param _buf		Value to set
 * @param _size		Size of buffer
 */

static __inline int OFW_SETPROP(ofw_t _ofw, phandle_t _node, const char *_prop,
                                const void *_buf, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_setprop);
	return ((ofw_setprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
}

/** @brief Unique descriptor for the OFW_CANON() method */
extern struct kobjop_desc ofw_canon_desc;
/** @brief A function implementing the OFW_CANON() method */
typedef ssize_t ofw_canon_t(ofw_t _ofw, const char *_path, char *_buf,
                            size_t _size);
/**
 * @brief Canonicalize path.
 *
 * @param _path		Path to canonicalize
 * @param _buf		Buffer for canonicalized path
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_CANON(ofw_t _ofw, const char *_path, char *_buf,
                                  size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_canon);
	return ((ofw_canon_t *) _m)(_ofw, _path, _buf, _size);
}

/** @brief Unique descriptor for the OFW_FINDDEVICE() method */
extern struct kobjop_desc ofw_finddevice_desc;
/** @brief A function implementing the OFW_FINDDEVICE() method */
typedef phandle_t ofw_finddevice_t(ofw_t _ofw, const char *_path);
/**
 * @brief Return phandle for named device.
 *
 * @param _path		Device path
 */

static __inline phandle_t OFW_FINDDEVICE(ofw_t _ofw, const char *_path)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_finddevice);
	return ((ofw_finddevice_t *) _m)(_ofw, _path);
}

/** @brief Unique descriptor for the OFW_INSTANCE_TO_PATH() method */
extern struct kobjop_desc ofw_instance_to_path_desc;
/** @brief A function implementing the OFW_INSTANCE_TO_PATH() method */
typedef ssize_t ofw_instance_to_path_t(ofw_t _ofw, ihandle_t _handle,
                                       char *_path, size_t _size);
/**
 * @brief Return path for node instance.
 *
 * @param _handle	Instance handle
 * @param _path		Buffer for path
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_INSTANCE_TO_PATH(ofw_t _ofw, ihandle_t _handle,
                                             char *_path, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_instance_to_path);
	return ((ofw_instance_to_path_t *) _m)(_ofw, _handle, _path, _size);
}

/** @brief Unique descriptor for the OFW_PACKAGE_TO_PATH() method */
extern struct kobjop_desc ofw_package_to_path_desc;
/** @brief A function implementing the OFW_PACKAGE_TO_PATH() method */
typedef ssize_t ofw_package_to_path_t(ofw_t _ofw, phandle_t _node, char *_path,
                                      size_t _size);
/**
 * @brief Return path for node.
 *
 * @param _node		Package node
 * @param _path		Buffer for path
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_PACKAGE_TO_PATH(ofw_t _ofw, phandle_t _node,
                                            char *_path, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_package_to_path);
	return ((ofw_package_to_path_t *) _m)(_ofw, _node, _path, _size);
}

/** @brief Unique descriptor for the OFW_TEST() method */
extern struct kobjop_desc ofw_test_desc;
/** @brief A function implementing the OFW_TEST() method */
typedef int ofw_test_t(ofw_t _ofw, const char *_name);
/**
 * @brief Test to see if a service exists.
 *
 * @param _name		name of the service
 */

static __inline int OFW_TEST(ofw_t _ofw, const char *_name)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_test);
	return ((ofw_test_t *) _m)(_ofw, _name);
}

/** @brief Unique descriptor for the OFW_CALL_METHOD() method */
extern struct kobjop_desc ofw_call_method_desc;
/** @brief A function implementing the OFW_CALL_METHOD() method */
typedef int ofw_call_method_t(ofw_t _ofw, ihandle_t _instance,
                              const char *_method, int _nargs, int _nreturns,
                              cell_t *_args_and_returns);
/**
 * @brief Call method belonging to an instance handle.
 *
 * @param _instance	Instance handle
 * @param _method	Method name
 * @param _nargs	Number of arguments
 * @param _nreturns	Number of return values
 * @param _args_and_returns	Values for arguments, followed by returns
 */

static __inline int OFW_CALL_METHOD(ofw_t _ofw, ihandle_t _instance,
                                    const char *_method, int _nargs,
                                    int _nreturns, cell_t *_args_and_returns)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_call_method);
	return ((ofw_call_method_t *) _m)(_ofw, _instance, _method, _nargs, _nreturns, _args_and_returns);
}

/** @brief Unique descriptor for the OFW_INTERPRET() method */
extern struct kobjop_desc ofw_interpret_desc;
/** @brief A function implementing the OFW_INTERPRET() method */
typedef int ofw_interpret_t(ofw_t _ofw, const char *_cmd, int _nreturns,
                            cell_t *_returns);
/**
 * @brief Interpret a forth command.
 *
 * @param _cmd		Command
 * @param _nreturns	Number of return values
 * @param _returns	Values for returns
 */

static __inline int OFW_INTERPRET(ofw_t _ofw, const char *_cmd, int _nreturns,
                                  cell_t *_returns)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_interpret);
	return ((ofw_interpret_t *) _m)(_ofw, _cmd, _nreturns, _returns);
}

/** @brief Unique descriptor for the OFW_OPEN() method */
extern struct kobjop_desc ofw_open_desc;
/** @brief A function implementing the OFW_OPEN() method */
typedef ihandle_t ofw_open_t(ofw_t _ofw, const char *_path);
/**
 * @brief Open node, returning instance handle.
 *
 * @param _path		Path to node
 */

static __inline ihandle_t OFW_OPEN(ofw_t _ofw, const char *_path)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_open);
	return ((ofw_open_t *) _m)(_ofw, _path);
}

/** @brief Unique descriptor for the OFW_CLOSE() method */
extern struct kobjop_desc ofw_close_desc;
/** @brief A function implementing the OFW_CLOSE() method */
typedef void ofw_close_t(ofw_t _ofw, ihandle_t _instance);
/**
 * @brief Close node instance.
 *
 * @param _instance	Instance to close
 */

static __inline void OFW_CLOSE(ofw_t _ofw, ihandle_t _instance)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_close);
	((ofw_close_t *) _m)(_ofw, _instance);
}

/** @brief Unique descriptor for the OFW_READ() method */
extern struct kobjop_desc ofw_read_desc;
/** @brief A function implementing the OFW_READ() method */
typedef ssize_t ofw_read_t(ofw_t _ofw, ihandle_t _instance, void *_buf,
                           size_t size);
/**
 * @brief Read from device.
 *
 * @param _instance	Device instance
 * @param _buf		Buffer to read to
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_READ(ofw_t _ofw, ihandle_t _instance, void *_buf,
                                 size_t size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_read);
	return ((ofw_read_t *) _m)(_ofw, _instance, _buf, size);
}

/** @brief Unique descriptor for the OFW_WRITE() method */
extern struct kobjop_desc ofw_write_desc;
/** @brief A function implementing the OFW_WRITE() method */
typedef ssize_t ofw_write_t(ofw_t _ofw, ihandle_t _instance, const void *_buf,
                            size_t size);
/**
 * @brief Write to device.
 *
 * @param _instance	Device instance
 * @param _buf		Buffer to write from
 * @param _size		Size of buffer
 */

static __inline ssize_t OFW_WRITE(ofw_t _ofw, ihandle_t _instance,
                                  const void *_buf, size_t size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_write);
	return ((ofw_write_t *) _m)(_ofw, _instance, _buf, size);
}

/** @brief Unique descriptor for the OFW_SEEK() method */
extern struct kobjop_desc ofw_seek_desc;
/** @brief A function implementing the OFW_SEEK() method */
typedef int ofw_seek_t(ofw_t _ofw, ihandle_t _instance, uint64_t _off);
/**
 * @brief Seek device.
 *
 * @param _instance	Device instance
 * @param _off		Offset to which to seek
 */

static __inline int OFW_SEEK(ofw_t _ofw, ihandle_t _instance, uint64_t _off)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_seek);
	return ((ofw_seek_t *) _m)(_ofw, _instance, _off);
}

/** @brief Unique descriptor for the OFW_CLAIM() method */
extern struct kobjop_desc ofw_claim_desc;
/** @brief A function implementing the OFW_CLAIM() method */
typedef caddr_t ofw_claim_t(ofw_t _ofw, void *_addr, size_t _size,
                            u_int _align);
/**
 * @brief Claim virtual memory.
 *
 * @param _addr		Requested memory location (NULL for first available)
 * @param _size		Requested size in bytes
 * @param _align	Requested alignment
 */

static __inline caddr_t OFW_CLAIM(ofw_t _ofw, void *_addr, size_t _size,
                                  u_int _align)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_claim);
	return ((ofw_claim_t *) _m)(_ofw, _addr, _size, _align);
}

/** @brief Unique descriptor for the OFW_RELEASE() method */
extern struct kobjop_desc ofw_release_desc;
/** @brief A function implementing the OFW_RELEASE() method */
typedef void ofw_release_t(ofw_t _ofw, void *_addr, size_t _size);
/**
 * @brief Release virtual memory.
 *
 * @param _addr		Memory location
 * @param _size		Size in bytes
 */

static __inline void OFW_RELEASE(ofw_t _ofw, void *_addr, size_t _size)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_release);
	((ofw_release_t *) _m)(_ofw, _addr, _size);
}

/** @brief Unique descriptor for the OFW_ENTER() method */
extern struct kobjop_desc ofw_enter_desc;
/** @brief A function implementing the OFW_ENTER() method */
typedef void ofw_enter_t(ofw_t _ofw);
/**
 * @brief Temporarily return control to firmware.
 */

static __inline void OFW_ENTER(ofw_t _ofw)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_enter);
	((ofw_enter_t *) _m)(_ofw);
}

/** @brief Unique descriptor for the OFW_EXIT() method */
extern struct kobjop_desc ofw_exit_desc;
/** @brief A function implementing the OFW_EXIT() method */
typedef void ofw_exit_t(ofw_t _ofw);
/**
 * @brief Halt and return control to firmware.
 */

static __inline void OFW_EXIT(ofw_t _ofw)
{
	kobjop_t _m;
	KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_exit);
	((ofw_exit_t *) _m)(_ofw);
}

#endif /* _ofw_if_h_ */