Deleted Added
full compact
ofw_standard.c (194025) ofw_standard.c (194138)
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/ofw_standard.c 194025 2009-06-11 17:15:20Z avg $");
59__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_standard.c 194138 2009-06-14 00:05:38Z marius $");
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
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/openfirm.h>
69#include <dev/ofw/ofwvar.h>
68#include <dev/ofw/ofwvar.h>
69#include <dev/ofw/openfirm.h>
70
70#include "ofw_if.h"
71
72static void ofw_std_init(ofw_t ofw, void *openfirm);
73static int ofw_std_test(ofw_t ofw, const char *name);
74static int ofw_std_interpret(ofw_t ofw, const char *cmd, int nreturns,
75 unsigned long *returns);
76static phandle_t ofw_std_peer(ofw_t ofw, phandle_t node);
77static phandle_t ofw_std_child(ofw_t ofw, phandle_t node);

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

96 const char *method, int nargs, int nreturns,
97 unsigned long *args_and_returns);
98static ihandle_t ofw_std_open(ofw_t ofw, const char *device);
99static void ofw_std_close(ofw_t ofw, ihandle_t instance);
100static ssize_t ofw_std_read(ofw_t ofw, ihandle_t instance, void *addr,
101 size_t len);
102static ssize_t ofw_std_write(ofw_t ofw, ihandle_t instance, const void *addr,
103 size_t len);
71#include "ofw_if.h"
72
73static void ofw_std_init(ofw_t ofw, void *openfirm);
74static int ofw_std_test(ofw_t ofw, const char *name);
75static int ofw_std_interpret(ofw_t ofw, const char *cmd, int nreturns,
76 unsigned long *returns);
77static phandle_t ofw_std_peer(ofw_t ofw, phandle_t node);
78static phandle_t ofw_std_child(ofw_t ofw, phandle_t node);

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

97 const char *method, int nargs, int nreturns,
98 unsigned long *args_and_returns);
99static ihandle_t ofw_std_open(ofw_t ofw, const char *device);
100static void ofw_std_close(ofw_t ofw, ihandle_t instance);
101static ssize_t ofw_std_read(ofw_t ofw, ihandle_t instance, void *addr,
102 size_t len);
103static ssize_t ofw_std_write(ofw_t ofw, ihandle_t instance, const void *addr,
104 size_t len);
104static int ofw_std_seek(ofw_t ofw, ihandle_t instance, u_int64_t pos);
105static int ofw_std_seek(ofw_t ofw, ihandle_t instance, uint64_t pos);
105static caddr_t ofw_std_claim(ofw_t ofw, void *virt, size_t size, u_int align);
106static void ofw_std_release(ofw_t ofw, void *virt, size_t size);
107static void ofw_std_enter(ofw_t ofw);
108static void ofw_std_exit(ofw_t ofw);
109
110static ofw_method_t ofw_std_methods[] = {
111 OFWMETHOD(ofw_init, ofw_std_init),
112 OFWMETHOD(ofw_peer, ofw_std_peer),

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

142 OFW_STD_DIRECT,
143 ofw_std_methods,
144 0
145};
146OFW_DEF(ofw_std);
147
148static int (*openfirmware)(void *);
149
106static caddr_t ofw_std_claim(ofw_t ofw, void *virt, size_t size, u_int align);
107static void ofw_std_release(ofw_t ofw, void *virt, size_t size);
108static void ofw_std_enter(ofw_t ofw);
109static void ofw_std_exit(ofw_t ofw);
110
111static ofw_method_t ofw_std_methods[] = {
112 OFWMETHOD(ofw_init, ofw_std_init),
113 OFWMETHOD(ofw_peer, ofw_std_peer),

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

143 OFW_STD_DIRECT,
144 ofw_std_methods,
145 0
146};
147OFW_DEF(ofw_std);
148
149static int (*openfirmware)(void *);
150
150/* Initialiser */
151/* Initializer */
151
152static void
153ofw_std_init(ofw_t ofw, void *openfirm)
154{
152
153static void
154ofw_std_init(ofw_t ofw, void *openfirm)
155{
156
155 openfirmware = (int (*)(void *))openfirm;
156}
157
158/*
159 * Generic functions
160 */
161
162/* Test to see if a service exists. */

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

194 (cell_t)"interpret",
195 1,
196 };
197 cell_t status;
198 int i = 0, j = 0;
199
200 args.nreturns = ++nreturns;
201 args.slot[i++] = (cell_t)cmd;
157 openfirmware = (int (*)(void *))openfirm;
158}
159
160/*
161 * Generic functions
162 */
163
164/* Test to see if a service exists. */

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

196 (cell_t)"interpret",
197 1,
198 };
199 cell_t status;
200 int i = 0, j = 0;
201
202 args.nreturns = ++nreturns;
203 args.slot[i++] = (cell_t)cmd;
202 if (openfirmware(&args) == -1) {
204 if (openfirmware(&args) == -1)
203 return (-1);
205 return (-1);
204 }
205 status = args.slot[i++];
206 while (i < 1 + nreturns)
207 returns[j++] = args.slot[i++];
208 return (status);
209}
210
211/*
212 * Device tree functions

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

566 cell_t instance;
567 } args = {
568 (cell_t)"open",
569 1,
570 1,
571 };
572
573 args.device = (cell_t)device;
206 status = args.slot[i++];
207 while (i < 1 + nreturns)
208 returns[j++] = args.slot[i++];
209 return (status);
210}
211
212/*
213 * Device tree functions

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

567 cell_t instance;
568 } args = {
569 (cell_t)"open",
570 1,
571 1,
572 };
573
574 args.device = (cell_t)device;
574 if (openfirmware(&args) == -1 || args.instance == 0) {
575 if (openfirmware(&args) == -1 || args.instance == 0)
575 return (-1);
576 return (-1);
576 }
577 return (args.instance);
578}
579
580/* Close an instance. */
581static void
582ofw_std_close(ofw_t ofw, ihandle_t instance)
583{
584 static struct {

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

645 args.len = len;
646 if (openfirmware(&args) == -1)
647 return (-1);
648 return (args.actual);
649}
650
651/* Seek to a position. */
652static int
577 return (args.instance);
578}
579
580/* Close an instance. */
581static void
582ofw_std_close(ofw_t ofw, ihandle_t instance)
583{
584 static struct {

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

645 args.len = len;
646 if (openfirmware(&args) == -1)
647 return (-1);
648 return (args.actual);
649}
650
651/* Seek to a position. */
652static int
653ofw_std_seek(ofw_t ofw, ihandle_t instance, u_int64_t pos)
653ofw_std_seek(ofw_t ofw, ihandle_t instance, uint64_t pos)
654{
655 static struct {
656 cell_t name;
657 cell_t nargs;
658 cell_t nreturns;
659 cell_t instance;
660 cell_t poshi;
661 cell_t poslo;

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

755 } args = {
756 (cell_t)"exit",
757 };
758
759 openfirmware(&args);
760 for (;;) /* just in case */
761 ;
762}
654{
655 static struct {
656 cell_t name;
657 cell_t nargs;
658 cell_t nreturns;
659 cell_t instance;
660 cell_t poshi;
661 cell_t poslo;

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

755 } args = {
756 (cell_t)"exit",
757 };
758
759 openfirmware(&args);
760 for (;;) /* just in case */
761 ;
762}
763