Deleted Added
full compact
openfirm.c (208172) openfirm.c (208614)
1/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
2
3/*-
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 42 unchanged lines hidden (view full) ---

51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
1/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
2
3/*-
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 42 unchanged lines hidden (view full) ---

51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
59__FBSDID("$FreeBSD: head/sys/dev/ofw/openfirm.c 208172 2010-05-16 22:01:43Z nwhitehorn $");
59__FBSDID("$FreeBSD: head/sys/dev/ofw/openfirm.c 208614 2010-05-28 10:43:56Z raj $");
60
60
61#include "opt_platform.h"
62
61#include <sys/param.h>
62#include <sys/kernel.h>
63#include <sys/malloc.h>
64#include <sys/systm.h>
65
66#include <machine/stdarg.h>
67
68#include <dev/ofw/ofwvar.h>

--- 36 unchanged lines hidden (view full) ---

105 return (TRUE);
106 }
107 }
108
109 return (FALSE);
110}
111
112/* Initializer */
63#include <sys/param.h>
64#include <sys/kernel.h>
65#include <sys/malloc.h>
66#include <sys/systm.h>
67
68#include <machine/stdarg.h>
69
70#include <dev/ofw/ofwvar.h>

--- 36 unchanged lines hidden (view full) ---

107 return (TRUE);
108 }
109 }
110
111 return (FALSE);
112}
113
114/* Initializer */
113void
115int
114OF_init(void *cookie)
115{
116 phandle_t chosen;
116OF_init(void *cookie)
117{
118 phandle_t chosen;
119 int rv;
117
118 ofw_obj = &ofw_kernel_obj;
119 /*
120 * Take care of compiling the selected class, and
121 * then statically initialize the OFW object.
122 */
123 kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);
124 kobj_init((kobj_t)ofw_obj, ofw_def_impl);
125
120
121 ofw_obj = &ofw_kernel_obj;
122 /*
123 * Take care of compiling the selected class, and
124 * then statically initialize the OFW object.
125 */
126 kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);
127 kobj_init((kobj_t)ofw_obj, ofw_def_impl);
128
126 OFW_INIT(ofw_obj, cookie);
129 rv = OFW_INIT(ofw_obj, cookie);
127
130
128 if ((chosen = OF_finddevice("/chosen")) == -1)
129 OF_exit();
130 if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
131 stdout = -1;
131 if ((chosen = OF_finddevice("/chosen")) > 0)
132 if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
133 stdout = -1;
134
135 return (rv);
132}
133
136}
137
138#ifndef FDT
134void
135OF_printf(const char *fmt, ...)
136{
137 va_list va;
138 char buf[1024];
139
140 va_start(va, fmt);
141 vsprintf(buf, fmt, va);

--- 7 unchanged lines hidden (view full) ---

149
150/* Test to see if a service exists. */
151int
152OF_test(const char *name)
153{
154
155 return (OFW_TEST(ofw_obj, name));
156}
139void
140OF_printf(const char *fmt, ...)
141{
142 va_list va;
143 char buf[1024];
144
145 va_start(va, fmt);
146 vsprintf(buf, fmt, va);

--- 7 unchanged lines hidden (view full) ---

154
155/* Test to see if a service exists. */
156int
157OF_test(const char *name)
158{
159
160 return (OFW_TEST(ofw_obj, name));
161}
162#endif
157
158int
159OF_interpret(const char *cmd, int nreturns, ...)
160{
161 va_list ap;
162 unsigned long slots[16];
163 int i = 0;
164 int status;

--- 58 unchanged lines hidden (view full) ---

223ssize_t
224OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
225{
226
227 return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));
228}
229
230/*
163
164int
165OF_interpret(const char *cmd, int nreturns, ...)
166{
167 va_list ap;
168 unsigned long slots[16];
169 int i = 0;
170 int status;

--- 58 unchanged lines hidden (view full) ---

229ssize_t
230OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
231{
232
233 return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));
234}
235
236/*
231 * Resursively search the node and its parent for the given property, working
237 * Recursively search the node and its parent for the given property, working
232 * downward from the node to the device tree root. Returns the value of the
233 * first match.
234 */
235ssize_t
236OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len)
237{
238 ssize_t rv;
239

--- 70 unchanged lines hidden (view full) ---

310/* Return the fully qualified pathname corresponding to a package. */
311ssize_t
312OF_package_to_path(phandle_t package, char *buf, size_t len)
313{
314
315 return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
316}
317
238 * downward from the node to the device tree root. Returns the value of the
239 * first match.
240 */
241ssize_t
242OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len)
243{
244 ssize_t rv;
245

--- 70 unchanged lines hidden (view full) ---

316/* Return the fully qualified pathname corresponding to a package. */
317ssize_t
318OF_package_to_path(phandle_t package, char *buf, size_t len)
319{
320
321 return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
322}
323
324#ifndef FDT
318/* Call the method in the scope of a given instance. */
319int
320OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
321 ...)
322{
323 va_list ap;
324 unsigned long args_n_results[12];
325 int n, status;

--- 97 unchanged lines hidden (view full) ---

423{
424
425 /* Should not return */
426 OFW_EXIT(ofw_obj);
427
428 for (;;) /* just in case */
429 ;
430}
325/* Call the method in the scope of a given instance. */
326int
327OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
328 ...)
329{
330 va_list ap;
331 unsigned long args_n_results[12];
332 int n, status;

--- 97 unchanged lines hidden (view full) ---

430{
431
432 /* Should not return */
433 OFW_EXIT(ofw_obj);
434
435 for (;;) /* just in case */
436 ;
437}
438#endif