1475008d6SBrandon Bergren /* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $ */ 2475008d6SBrandon Bergren 3475008d6SBrandon Bergren /*- 4475008d6SBrandon Bergren * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5475008d6SBrandon Bergren * Copyright (C) 1995, 1996 TooLs GmbH. 6475008d6SBrandon Bergren * All rights reserved. 7475008d6SBrandon Bergren * 8475008d6SBrandon Bergren * Redistribution and use in source and binary forms, with or without 9475008d6SBrandon Bergren * modification, are permitted provided that the following conditions 10475008d6SBrandon Bergren * are met: 11475008d6SBrandon Bergren * 1. Redistributions of source code must retain the above copyright 12475008d6SBrandon Bergren * notice, this list of conditions and the following disclaimer. 13475008d6SBrandon Bergren * 2. Redistributions in binary form must reproduce the above copyright 14475008d6SBrandon Bergren * notice, this list of conditions and the following disclaimer in the 15475008d6SBrandon Bergren * documentation and/or other materials provided with the distribution. 16475008d6SBrandon Bergren * 3. All advertising materials mentioning features or use of this software 17475008d6SBrandon Bergren * must display the following acknowledgement: 18475008d6SBrandon Bergren * This product includes software developed by TooLs GmbH. 19475008d6SBrandon Bergren * 4. The name of TooLs GmbH may not be used to endorse or promote products 20475008d6SBrandon Bergren * derived from this software without specific prior written permission. 21475008d6SBrandon Bergren * 22475008d6SBrandon Bergren * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23475008d6SBrandon Bergren * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24475008d6SBrandon Bergren * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25475008d6SBrandon Bergren * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26475008d6SBrandon Bergren * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27475008d6SBrandon Bergren * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28475008d6SBrandon Bergren * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29475008d6SBrandon Bergren * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30475008d6SBrandon Bergren * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31475008d6SBrandon Bergren * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32475008d6SBrandon Bergren */ 33475008d6SBrandon Bergren /*- 34475008d6SBrandon Bergren * Copyright (C) 2000 Benno Rice. 35475008d6SBrandon Bergren * All rights reserved. 36475008d6SBrandon Bergren * 37475008d6SBrandon Bergren * Redistribution and use in source and binary forms, with or without 38475008d6SBrandon Bergren * modification, are permitted provided that the following conditions 39475008d6SBrandon Bergren * are met: 40475008d6SBrandon Bergren * 1. Redistributions of source code must retain the above copyright 41475008d6SBrandon Bergren * notice, this list of conditions and the following disclaimer. 42475008d6SBrandon Bergren * 2. Redistributions in binary form must reproduce the above copyright 43475008d6SBrandon Bergren * notice, this list of conditions and the following disclaimer in the 44475008d6SBrandon Bergren * documentation and/or other materials provided with the distribution. 45475008d6SBrandon Bergren * 46475008d6SBrandon Bergren * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 47475008d6SBrandon Bergren * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48475008d6SBrandon Bergren * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49475008d6SBrandon Bergren * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50475008d6SBrandon Bergren * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51475008d6SBrandon Bergren * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52475008d6SBrandon Bergren * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53475008d6SBrandon Bergren * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54475008d6SBrandon Bergren * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55475008d6SBrandon Bergren * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56475008d6SBrandon Bergren */ 57475008d6SBrandon Bergren #ifndef _OPENFIRM_H_ 58475008d6SBrandon Bergren #define _OPENFIRM_H_ 59475008d6SBrandon Bergren /* 60475008d6SBrandon Bergren * Prototypes for Open Firmware Interface Routines 61475008d6SBrandon Bergren */ 62475008d6SBrandon Bergren 63475008d6SBrandon Bergren #include <sys/types.h> 64475008d6SBrandon Bergren 65*f8328864SLeandro Lupori typedef uint32_t ihandle_t; 66*f8328864SLeandro Lupori typedef uint32_t phandle_t; 67*f8328864SLeandro Lupori typedef uint32_t cell_t; 68475008d6SBrandon Bergren 69475008d6SBrandon Bergren extern int (*openfirmware)(void *); 70475008d6SBrandon Bergren extern phandle_t chosen; 71475008d6SBrandon Bergren extern ihandle_t memory, mmu; 72475008d6SBrandon Bergren extern int real_mode; 73475008d6SBrandon Bergren 74475008d6SBrandon Bergren /* 75475008d6SBrandon Bergren * This isn't actually an Open Firmware function, but it seemed like the right 76475008d6SBrandon Bergren * place for it to go. 77475008d6SBrandon Bergren */ 78475008d6SBrandon Bergren void OF_init(int (*openfirm)(void *)); 79475008d6SBrandon Bergren 80475008d6SBrandon Bergren /* Generic functions */ 81475008d6SBrandon Bergren int OF_test(char *); 82475008d6SBrandon Bergren void OF_quiesce(); /* Disable firmware */ 83475008d6SBrandon Bergren 84475008d6SBrandon Bergren /* Device tree functions */ 85475008d6SBrandon Bergren phandle_t OF_peer(phandle_t); 86475008d6SBrandon Bergren phandle_t OF_child(phandle_t); 87475008d6SBrandon Bergren phandle_t OF_parent(phandle_t); 88475008d6SBrandon Bergren phandle_t OF_instance_to_package(ihandle_t); 89475008d6SBrandon Bergren int OF_getproplen(phandle_t, const char *); 90475008d6SBrandon Bergren int OF_getprop(phandle_t, const char *, void *, int); 91*f8328864SLeandro Lupori int OF_getencprop(phandle_t, const char *, cell_t *, int); 92475008d6SBrandon Bergren int OF_nextprop(phandle_t, const char *, char *); 93475008d6SBrandon Bergren int OF_setprop(phandle_t, const char *, void *, int); 94475008d6SBrandon Bergren int OF_canon(const char *, char *, int); 95475008d6SBrandon Bergren phandle_t OF_finddevice(const char *); 96475008d6SBrandon Bergren int OF_instance_to_path(ihandle_t, char *, int); 97475008d6SBrandon Bergren int OF_package_to_path(phandle_t, char *, int); 98475008d6SBrandon Bergren int OF_call_method(char *, ihandle_t, int, int, ...); 99475008d6SBrandon Bergren 100475008d6SBrandon Bergren /* Device I/O functions */ 101475008d6SBrandon Bergren ihandle_t OF_open(char *); 102475008d6SBrandon Bergren void OF_close(ihandle_t); 103475008d6SBrandon Bergren int OF_read(ihandle_t, void *, int); 104475008d6SBrandon Bergren int OF_write(ihandle_t, void *, int); 105475008d6SBrandon Bergren int OF_seek(ihandle_t, u_quad_t); 106475008d6SBrandon Bergren unsigned int OF_blocks(ihandle_t); 107475008d6SBrandon Bergren int OF_block_size(ihandle_t); 108475008d6SBrandon Bergren 109475008d6SBrandon Bergren /* Memory functions */ 110475008d6SBrandon Bergren void *OF_claim(void *, u_int, u_int); 111475008d6SBrandon Bergren void OF_release(void *, u_int); 112475008d6SBrandon Bergren 113475008d6SBrandon Bergren /* Control transfer functions */ 114475008d6SBrandon Bergren void OF_boot(char *); 115475008d6SBrandon Bergren void OF_enter(void); 116475008d6SBrandon Bergren void OF_exit(void) __attribute__((noreturn)); 117475008d6SBrandon Bergren void OF_chain(void *, u_int, void (*)(), void *, u_int); 118475008d6SBrandon Bergren 119475008d6SBrandon Bergren /* Time function */ 120475008d6SBrandon Bergren int OF_milliseconds(void); 121475008d6SBrandon Bergren 122475008d6SBrandon Bergren #endif /* _OPENFIRM_H_ */ 123