Deleted Added
sdiff udiff text old ( 208172 ) new ( 208614 )
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 $");
60
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 */
113void
114OF_init(void *cookie)
115{
116 phandle_t chosen;
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
126 OFW_INIT(ofw_obj, cookie);
127
128 if ((chosen = OF_finddevice("/chosen")) == -1)
129 OF_exit();
130 if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
131 stdout = -1;
132}
133
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}
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/*
231 * Resursively 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
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}