openfirm.h revision 105397
167204Sobrien/*	$NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $	*/
267204Sobrien
367204Sobrien/*
467204Sobrien * Copyright (C) 1995, 1996 Wolfgang Solfrank.
567204Sobrien * Copyright (C) 1995, 1996 TooLs GmbH.
667204Sobrien * All rights reserved.
767204Sobrien *
867204Sobrien * Redistribution and use in source and binary forms, with or without
967204Sobrien * modification, are permitted provided that the following conditions
1067204Sobrien * are met:
1167204Sobrien * 1. Redistributions of source code must retain the above copyright
1267204Sobrien *    notice, this list of conditions and the following disclaimer.
1367204Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1467204Sobrien *    notice, this list of conditions and the following disclaimer in the
1567204Sobrien *    documentation and/or other materials provided with the distribution.
1667204Sobrien * 3. All advertising materials mentioning features or use of this software
1767204Sobrien *    must display the following acknowledgement:
1867204Sobrien *	This product includes software developed by TooLs GmbH.
1967204Sobrien * 4. The name of TooLs GmbH may not be used to endorse or promote products
2067204Sobrien *    derived from this software without specific prior written permission.
2167204Sobrien *
2267204Sobrien * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
2367204Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2467204Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2567204Sobrien * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2667204Sobrien * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2767204Sobrien * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2867204Sobrien * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2967204Sobrien * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
3067204Sobrien * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
3167204Sobrien * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3267204Sobrien */
3367204Sobrien/*
3467204Sobrien * Copyright (C) 2000 Benno Rice.
3567204Sobrien * All rights reserved.
3667204Sobrien *
3767204Sobrien * Redistribution and use in source and binary forms, with or without
3867204Sobrien * modification, are permitted provided that the following conditions
3967204Sobrien * are met:
4067204Sobrien * 1. Redistributions of source code must retain the above copyright
4167204Sobrien *    notice, this list of conditions and the following disclaimer.
4267204Sobrien * 2. Redistributions in binary form must reproduce the above copyright
4367204Sobrien *    notice, this list of conditions and the following disclaimer in the
4467204Sobrien *    documentation and/or other materials provided with the distribution.
4567204Sobrien *
4667204Sobrien * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
4767204Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4867204Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4967204Sobrien * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5067204Sobrien * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
5167204Sobrien * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
5267204Sobrien * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
5367204Sobrien * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
5467204Sobrien * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5567204Sobrien * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5667204Sobrien *
5767204Sobrien * $FreeBSD: head/sys/dev/ofw/openfirm.h 105397 2002-10-18 15:21:09Z tmm $
5867204Sobrien */
5967204Sobrien
6078877Sbenno#ifndef _OPENFIRM_H_
6178877Sbenno#define _OPENFIRM_H_
6278877Sbenno
6367204Sobrien/*
6467204Sobrien * Prototypes for Openfirmware Interface Routines
6567204Sobrien */
6667204Sobrien
67105397Stmmtypedef unsigned long cell_t;
68105397Stmm
69105397Stmmtypedef	unsigned int	ihandle_t;
70105397Stmmtypedef unsigned int	phandle_t;
71105397Stmm
72105397Stmm#ifdef _KERNEL
7367204Sobrien#include <sys/cdefs.h>
7467204Sobrien#include <sys/types.h>
7586557Stmm#include <sys/malloc.h>
7667204Sobrien
7786557StmmMALLOC_DECLARE(M_OFWPROP);
7886557Stmm
7967204Sobrien/*
8078346Sbenno * Stuff that is used by the OpenFirmware code.
8178346Sbenno */
8278346Sbennovoid	set_openfirm_callback(int (*)(void *));
8378346Sbennoint	openfirmware(void *);
8478346Sbenno
8578346Sbenno/*
8667204Sobrien * This isn't actually an OpenFirmware function, but it seemed like the right
8767204Sobrien * place for it to go.
8867204Sobrien */
8967204Sobrienvoid		OF_init(int (*openfirm)(void *));
9067204Sobrien
9167204Sobrien/* Generic functions */
9267204Sobrienint		OF_test(char *);
9378346Sbennovoid		OF_helloworld(void);
9478346Sbennovoid		OF_printf(const char *, ...);
9567204Sobrien
9667204Sobrien/* Device tree functions */
9767204Sobrienphandle_t	OF_peer(phandle_t);
9867204Sobrienphandle_t	OF_child(phandle_t);
9967204Sobrienphandle_t	OF_parent(phandle_t);
10067204Sobrienphandle_t	OF_instance_to_package(ihandle_t);
10167204Sobrienint		OF_getproplen(phandle_t, char *);
10267204Sobrienint		OF_getprop(phandle_t, char *, void *, int);
10386557Stmmint		OF_getprop_alloc(phandle_t package, char *propname, int elsz,
10486557Stmm    void **buf);
10567204Sobrienint		OF_nextprop(phandle_t, char *, char *);
10667204Sobrienint		OF_setprop(phandle_t, char *, void *, int);
10768548Sbennoint		OF_canon(const char *, char *, int);
10868548Sbennophandle_t	OF_finddevice(const char *);
10967204Sobrienint		OF_instance_to_path(ihandle_t, char *, int);
11067204Sobrienint		OF_package_to_path(phandle_t, char *, int);
11167204Sobrienint		OF_call_method(char *, ihandle_t, int, int, ...);
11267204Sobrien
11367204Sobrien/* Device I/O functions */
11467204Sobrienihandle_t	OF_open(char *);
11567204Sobrienvoid		OF_close(ihandle_t);
11667204Sobrienint		OF_read(ihandle_t, void *, int);
11767204Sobrienint		OF_write(ihandle_t, void *, int);
11867204Sobrienint		OF_seek(ihandle_t, u_quad_t);
11967204Sobrien
12067204Sobrien/* Memory functions */
12167204Sobrienvoid 		*OF_claim(void *, u_int, u_int);
12267204Sobrienvoid		OF_release(void *, u_int);
12367204Sobrien
12467204Sobrien/* Control transfer functions */
12567204Sobrienvoid		OF_boot(char *);
12667204Sobrienvoid		OF_enter(void);
12768548Sbennovoid		OF_exit(void) __attribute__((noreturn));
12878346Sbennovoid		OF_chain(void *, u_int,
12978346Sbenno    void (*)(void *, u_int, void *, void *, u_int), void *, u_int);
13067204Sobrien
13167204Sobrien#if 0
13267204Sobrien/* User interface functions */
13367204Sobrien/* OF_interpret */
13467204Sobrienvoid 		*OF_set_callback(void *);
13567204Sobrienvoid		OF_set_symbol_lookup(void *, void *);
13667204Sobrien#endif
13767204Sobrien
13867204Sobrien/* Time function */
13967204Sobrienint		OF_milliseconds(void);
14078877Sbenno
141105397Stmm#endif /* _KERNEL */
14278877Sbenno#endif /* _OPENFIRM_H_ */
143