Deleted Added
full compact
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
61#include "opt_platform.h"
62
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
116OF_init(void *cookie)
117{
118 phandle_t chosen;
119 int rv;
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);
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);
136}
137
138#ifndef FDT
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
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
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
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