FreeBSD kernel amd64 OFW device code
ofw_if.m
Go to the documentation of this file.
1#-
2# Copyright (c) 2008 Nathan Whitehorn
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD$
27#
28
29#include <dev/ofw/openfirm.h>
30#include <dev/ofw/ofwvar.h>
31
38INTERFACE ofw;
39
46METHOD int init {
47 ofw_t _ofw;
48 void *_cookie;
49};
50
57 ofw_t _ofw;
59};
60
67 ofw_t _ofw;
69};
70
77 ofw_t _ofw;
79};
80
87 ofw_t _ofw;
89};
90
97METHOD ssize_t getproplen {
98 ofw_t _ofw;
100 const char *_prop;
101};
102
111METHOD ssize_t getprop {
112 ofw_t _ofw;
114 const char *_prop;
115 void *_buf;
116 size_t _size;
117};
118
127METHOD int nextprop {
128 ofw_t _ofw;
130 const char *_prop;
131 char *_buf;
132 size_t _size;
133};
134
143METHOD int setprop {
144 ofw_t _ofw;
146 const char *_prop;
147 const void *_buf;
148 size_t _size;
149};
150
158METHOD ssize_t canon {
159 ofw_t _ofw;
160 const char *_path;
161 char *_buf;
162 size_t _size;
163};
164
171 ofw_t _ofw;
172 const char *_path;
173};
174
182METHOD ssize_t instance_to_path {
183 ofw_t _ofw;
185 char *_path;
186 size_t _size;
187};
188
196METHOD ssize_t package_to_path {
197 ofw_t _ofw;
199 char *_path;
200 size_t _size;
201};
202
203# Methods for OF method calls (optional)
204
210METHOD int test {
211 ofw_t _ofw;
212 const char *_name;
213};
214
225METHOD int call_method {
226 ofw_t _ofw;
228 const char *_method;
231
233};
234
243METHOD int interpret {
244 ofw_t _ofw;
245 const char *_cmd;
246 int _nreturns;
247 cell_t *_returns;
248};
249
250# Device I/O Functions (optional)
251
258 ofw_t _ofw;
259 const char *_path;
260}
261
267METHOD void close {
268 ofw_t _ofw;
270}
271
279METHOD ssize_t read {
280 ofw_t _ofw;
282 void *_buf;
283 size_t size;
284}
285
293METHOD ssize_t write {
294 ofw_t _ofw;
296 const void *_buf;
297 size_t size;
298}
299
306METHOD int seek {
307 ofw_t _ofw;
309 uint64_t _off;
310}
311
312# Open Firmware memory management
313
321METHOD caddr_t claim {
322 ofw_t _ofw;
323 void *_addr;
324 size_t _size;
325 u_int _align;
326}
327
334METHOD void release {
335 ofw_t _ofw;
336 void *_addr;
337 size_t _size;
338};
339
340# Commands for returning control to the firmware
341
345METHOD void enter {
346 ofw_t _ofw;
347};
348
352METHOD void exit {
353 ofw_t _ofw;
354};
phandle_t _node
Definition: ofw_if.m:58
METHOD int setprop
Set property.
Definition: ofw_if.m:143
const char * _method
Definition: ofw_if.m:228
cell_t * _args_and_returns
Definition: ofw_if.m:232
METHOD phandle_t instance_to_package
Return package corresponding to instance.
Definition: ofw_if.m:86
ihandle_t _instance
Definition: ofw_if.m:227
const char * _prop
Definition: ofw_if.m:100
METHOD ssize_t read
Read from device.
Definition: ofw_if.m:279
METHOD phandle_t parent
Return parent of node.
Definition: ofw_if.m:66
METHOD void enter
Temporarily return control to firmware.
Definition: ofw_if.m:345
int _nreturns
Definition: ofw_if.m:230
size_t _size
Definition: ofw_if.m:116
METHOD ssize_t write
Write to device.
Definition: ofw_if.m:293
METHOD ssize_t instance_to_path
Return path for node instance.
Definition: ofw_if.m:182
uint64_t _off
Definition: ofw_if.m:309
METHOD int seek
Seek device.
Definition: ofw_if.m:306
cell_t * _returns
Definition: ofw_if.m:247
METHOD caddr_t claim
Claim virtual memory.
Definition: ofw_if.m:321
METHOD int init
Initialize OFW client interface.
Definition: ofw_if.m:46
METHOD phandle_t finddevice
Return phandle for named device.
Definition: ofw_if.m:170
METHOD int test
Test to see if a service exists.
Definition: ofw_if.m:210
METHOD ssize_t getproplen
Return length of node property.
Definition: ofw_if.m:97
METHOD ssize_t canon
Canonicalize path.
Definition: ofw_if.m:158
METHOD void release
Release virtual memory.
Definition: ofw_if.m:334
u_int _align
Definition: ofw_if.m:325
size_t size
Definition: ofw_if.m:283
const char * _path
Definition: ofw_if.m:160
METHOD int interpret
Interpret a forth command.
Definition: ofw_if.m:243
METHOD phandle_t peer
Return next sibling of node.
Definition: ofw_if.m:56
METHOD int nextprop
Get next property name.
Definition: ofw_if.m:127
const char * _name
Definition: ofw_if.m:212
METHOD void exit
Halt and return control to firmware.
Definition: ofw_if.m:352
const char * _cmd
Definition: ofw_if.m:245
METHOD int call_method
Call method belonging to an instance handle.
Definition: ofw_if.m:225
void * _buf
Definition: ofw_if.m:115
METHOD ssize_t getprop
Read node property.
Definition: ofw_if.m:111
METHOD ihandle_t open
Open node, returning instance handle.
Definition: ofw_if.m:257
void * _addr
Definition: ofw_if.m:323
METHOD phandle_t child
Return first child of node.
Definition: ofw_if.m:76
METHOD ssize_t package_to_path
Return path for node.
Definition: ofw_if.m:196
void * _cookie
Definition: ofw_if.m:48
ihandle_t _handle
Definition: ofw_if.m:88
METHOD void close
Close node instance.
Definition: ofw_if.m:267
int _nargs
Definition: ofw_if.m:229
INTERFACE ofw
Definition: ofw_if.m:38
uint32_t phandle_t
Definition: openfirm.h:73
uint32_t ihandle_t
Definition: openfirm.h:72