openfirm.h revision 86557
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 86557 2001-11-18 20:38:44Z tmm $
5867204Sobrien */
5967204Sobrien
6078877Sbenno#ifndef _OPENFIRM_H_
6178877Sbenno#define _OPENFIRM_H_
6278877Sbenno
6367204Sobrien/*
6467204Sobrien * Prototypes for Openfirmware Interface Routines
6567204Sobrien */
6667204Sobrien
6767204Sobrien#include <sys/cdefs.h>
6867204Sobrien#include <sys/types.h>
6986557Stmm#include <sys/malloc.h>
7067204Sobrien
7186557StmmMALLOC_DECLARE(M_OFWPROP);
7286557Stmm
7380697Sjaketypedef unsigned long cell_t;
7467204Sobrien
7580697Sjaketypedef	unsigned int	ihandle_t;
7680697Sjaketypedef unsigned int	phandle_t;
7780697Sjake
7867204Sobrien/*
7978346Sbenno * Stuff that is used by the OpenFirmware code.
8078346Sbenno */
8178346Sbennovoid	set_openfirm_callback(int (*)(void *));
8278346Sbennoint	openfirmware(void *);
8378346Sbenno
8478346Sbenno/*
8567204Sobrien * This isn't actually an OpenFirmware function, but it seemed like the right
8667204Sobrien * place for it to go.
8767204Sobrien */
8867204Sobrienvoid		OF_init(int (*openfirm)(void *));
8967204Sobrien
9067204Sobrien/* Generic functions */
9167204Sobrienint		OF_test(char *);
9278346Sbennovoid		OF_helloworld(void);
9378346Sbennovoid		OF_printf(const char *, ...);
9467204Sobrien
9567204Sobrien/* Device tree functions */
9667204Sobrienphandle_t	OF_peer(phandle_t);
9767204Sobrienphandle_t	OF_child(phandle_t);
9867204Sobrienphandle_t	OF_parent(phandle_t);
9967204Sobrienphandle_t	OF_instance_to_package(ihandle_t);
10067204Sobrienint		OF_getproplen(phandle_t, char *);
10167204Sobrienint		OF_getprop(phandle_t, char *, void *, int);
10286557Stmmint		OF_getprop_alloc(phandle_t package, char *propname, int elsz,
10386557Stmm    void **buf);
10467204Sobrienint		OF_nextprop(phandle_t, char *, char *);
10567204Sobrienint		OF_setprop(phandle_t, char *, void *, int);
10668548Sbennoint		OF_canon(const char *, char *, int);
10768548Sbennophandle_t	OF_finddevice(const char *);
10867204Sobrienint		OF_instance_to_path(ihandle_t, char *, int);
10967204Sobrienint		OF_package_to_path(phandle_t, char *, int);
11067204Sobrienint		OF_call_method(char *, ihandle_t, int, int, ...);
11167204Sobrien
11267204Sobrien/* Device I/O functions */
11367204Sobrienihandle_t	OF_open(char *);
11467204Sobrienvoid		OF_close(ihandle_t);
11567204Sobrienint		OF_read(ihandle_t, void *, int);
11667204Sobrienint		OF_write(ihandle_t, void *, int);
11767204Sobrienint		OF_seek(ihandle_t, u_quad_t);
11867204Sobrien
11967204Sobrien/* Memory functions */
12067204Sobrienvoid 		*OF_claim(void *, u_int, u_int);
12167204Sobrienvoid		OF_release(void *, u_int);
12267204Sobrien
12367204Sobrien/* Control transfer functions */
12467204Sobrienvoid		OF_boot(char *);
12567204Sobrienvoid		OF_enter(void);
12668548Sbennovoid		OF_exit(void) __attribute__((noreturn));
12778346Sbennovoid		OF_chain(void *, u_int,
12878346Sbenno    void (*)(void *, u_int, void *, void *, u_int), void *, u_int);
12967204Sobrien
13067204Sobrien#if 0
13167204Sobrien/* User interface functions */
13267204Sobrien/* OF_interpret */
13367204Sobrienvoid 		*OF_set_callback(void *);
13467204Sobrienvoid		OF_set_symbol_lookup(void *, void *);
13567204Sobrien#endif
13667204Sobrien
13767204Sobrien/* Time function */
13867204Sobrienint		OF_milliseconds(void);
13978877Sbenno
14078877Sbenno#endif /* _OPENFIRM_H_ */
141