openfirm.h revision 208614
1280288Sjkim/* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $ */ 2280288Sjkim 3280288Sjkim/*- 4280288Sjkim * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5280288Sjkim * Copyright (C) 1995, 1996 TooLs GmbH. 6280288Sjkim * All rights reserved. 7280288Sjkim * 8280288Sjkim * Redistribution and use in source and binary forms, with or without 9280288Sjkim * modification, are permitted provided that the following conditions 10280288Sjkim * are met: 11280288Sjkim * 1. Redistributions of source code must retain the above copyright 12280288Sjkim * notice, this list of conditions and the following disclaimer. 13280288Sjkim * 2. Redistributions in binary form must reproduce the above copyright 14280288Sjkim * notice, this list of conditions and the following disclaimer in the 15280288Sjkim * documentation and/or other materials provided with the distribution. 16280288Sjkim * 3. All advertising materials mentioning features or use of this software 17280288Sjkim * must display the following acknowledgement: 18280288Sjkim * This product includes software developed by TooLs GmbH. 19280288Sjkim * 4. The name of TooLs GmbH may not be used to endorse or promote products 20280288Sjkim * derived from this software without specific prior written permission. 21280288Sjkim * 22280288Sjkim * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23280288Sjkim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24280288Sjkim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25280288Sjkim * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26280288Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27280288Sjkim * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28280288Sjkim * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29280288Sjkim * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30280288Sjkim * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31280288Sjkim * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32280288Sjkim */ 33280288Sjkim/* 34280288Sjkim * Copyright (C) 2000 Benno Rice. 35280288Sjkim * All rights reserved. 36280288Sjkim * 37280288Sjkim * Redistribution and use in source and binary forms, with or without 38280288Sjkim * modification, are permitted provided that the following conditions 39280288Sjkim * are met: 40280288Sjkim * 1. Redistributions of source code must retain the above copyright 41280288Sjkim * notice, this list of conditions and the following disclaimer. 42280288Sjkim * 2. Redistributions in binary form must reproduce the above copyright 43280288Sjkim * notice, this list of conditions and the following disclaimer in the 44280288Sjkim * documentation and/or other materials provided with the distribution. 45280288Sjkim * 46280288Sjkim * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 47280288Sjkim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48280288Sjkim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49280288Sjkim * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50280288Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51280288Sjkim * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52280288Sjkim * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53280288Sjkim * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54280288Sjkim * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55280288Sjkim * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56280288Sjkim * 57280288Sjkim * $FreeBSD: head/sys/dev/ofw/openfirm.h 208614 2010-05-28 10:43:56Z raj $ 58280288Sjkim */ 59280288Sjkim 60280288Sjkim#ifndef _DEV_OPENFIRM_H_ 61280288Sjkim#define _DEV_OPENFIRM_H_ 62280288Sjkim 63280288Sjkim#include <sys/types.h> 64280288Sjkim 65280288Sjkim/* 66280288Sjkim * Prototypes for Open Firmware Interface Routines 67280288Sjkim */ 68280288Sjkim 69280288Sjkimtypedef uint32_t ihandle_t; 70280288Sjkimtypedef uint32_t phandle_t; 71280288Sjkimtypedef uint32_t pcell_t; 72280288Sjkim 73280288Sjkim#ifdef _KERNEL 74280288Sjkim#include <sys/malloc.h> 75280288Sjkim 76280288Sjkim#include <machine/ofw_machdep.h> 77280288Sjkim 78280288SjkimMALLOC_DECLARE(M_OFWPROP); 79280288Sjkim 80280288Sjkim/* 81280288Sjkim * Open Firmware interface initialization. OF_install installs the named 82280288Sjkim * interface as the Open Firmware access mechanism, OF_init initializes it. 83280288Sjkim */ 84280288Sjkim 85280288Sjkimboolean_t OF_install(char *name, int prio); 86280288Sjkimint OF_init(void *cookie); 87280288Sjkim 88280288Sjkim/* 89280288Sjkim * Known Open Firmware interface names 90280288Sjkim */ 91280288Sjkim 92280288Sjkim#define OFW_STD_DIRECT "ofw_std" /* Standard OF interface */ 93280288Sjkim#define OFW_STD_REAL "ofw_real" /* Real-mode OF interface */ 94280288Sjkim#define OFW_FDT "ofw_fdt" /* Flattened Device Tree */ 95280288Sjkim 96280288Sjkim/* Generic functions */ 97280288Sjkimint OF_test(const char *name); 98280288Sjkimvoid OF_printf(const char *fmt, ...); 99280288Sjkim 100280288Sjkim/* Device tree functions */ 101280288Sjkimphandle_t OF_peer(phandle_t node); 102280288Sjkimphandle_t OF_child(phandle_t node); 103280288Sjkimphandle_t OF_parent(phandle_t node); 104280288Sjkimssize_t OF_getproplen(phandle_t node, const char *propname); 105280288Sjkimssize_t OF_getprop(phandle_t node, const char *propname, void *buf, 106280288Sjkim size_t len); 107280288Sjkimssize_t OF_searchprop(phandle_t node, const char *propname, void *buf, 108280288Sjkim size_t len); 109280288Sjkimssize_t OF_getprop_alloc(phandle_t node, const char *propname, 110280288Sjkim int elsz, void **buf); 111280288Sjkimint OF_nextprop(phandle_t node, const char *propname, char *buf, 112280288Sjkim size_t len); 113280288Sjkimint OF_setprop(phandle_t node, const char *name, const void *buf, 114280288Sjkim size_t len); 115280288Sjkimssize_t OF_canon(const char *path, char *buf, size_t len); 116280288Sjkimphandle_t OF_finddevice(const char *path); 117280288Sjkimssize_t OF_package_to_path(phandle_t node, char *buf, size_t len); 118280288Sjkim 119280288Sjkim/* Device I/O functions */ 120280288Sjkimihandle_t OF_open(const char *path); 121280288Sjkimvoid OF_close(ihandle_t instance); 122280288Sjkimssize_t OF_read(ihandle_t instance, void *buf, size_t len); 123280288Sjkimssize_t OF_write(ihandle_t instance, const void *buf, size_t len); 124280288Sjkimint OF_seek(ihandle_t instance, uint64_t where); 125280288Sjkim 126280288Sjkimphandle_t OF_instance_to_package(ihandle_t instance); 127280288Sjkimssize_t OF_instance_to_path(ihandle_t instance, char *buf, size_t len); 128280288Sjkimint OF_call_method(const char *method, ihandle_t instance, 129280288Sjkim int nargs, int nreturns, ...); 130280288Sjkim 131280288Sjkim/* Memory functions */ 132280288Sjkimvoid *OF_claim(void *virtrequest, size_t size, u_int align); 133280288Sjkimvoid OF_release(void *virt, size_t size); 134280288Sjkim 135280288Sjkim/* Control transfer functions */ 136280288Sjkimvoid OF_enter(void); 137280288Sjkimvoid OF_exit(void) __attribute__((noreturn)); 138280288Sjkim 139280288Sjkim/* User interface functions */ 140280288Sjkimint OF_interpret(const char *cmd, int nreturns, ...); 141280288Sjkim 142280288Sjkim#endif /* _KERNEL */ 143280288Sjkim#endif /* _DEV_OPENFIRM_H_ */ 144280288Sjkim