1/* 2 * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef OPEN_FIRMWARE_H 6#define OPEN_FIRMWARE_H 7 8 9#include <SupportDefs.h> 10 11 12#define OF_FAILED (-1) 13 14 15/* global device tree/properties access */ 16extern int gChosen; 17 18 19template<typename AddressType> 20struct of_region { 21 AddressType base; 22 uint32 size; 23}; 24 25struct of_arguments { 26 const char *name; 27 int num_args; 28 int num_returns; 29 int data[0]; 30 31#ifdef __cplusplus 32 int &Argument(int index) { return data[index]; } 33 int &ReturnValue(int index) { return data[num_args + index]; } 34#endif 35}; 36 37 38#ifdef __cplusplus 39extern "C" { 40#endif 41 42extern status_t of_init(int (*openFirmwareEntry)(void *)); 43 44/* device tree functions */ 45extern int of_finddevice(const char *device); 46extern int of_child(int node); 47extern int of_peer(int node); 48extern int of_parent(int node); 49extern int of_instance_to_path(int instance, char *pathBuffer, int bufferSize); 50extern int of_instance_to_package(int instance); 51extern int of_getprop(int package, const char *property, void *buffer, 52 int bufferSize); 53extern int of_setprop(int package, const char *property, const void *buffer, 54 int bufferSize); 55extern int of_nextprop(int package, const char *previousProperty, 56 char *nextProperty); 57extern int of_getproplen(int package, const char *property); 58extern int of_package_to_path(int package, char *pathBuffer, int bufferSize); 59 60/* I/O functions */ 61extern int of_open(const char *nodeName); 62extern void of_close(int handle); 63extern int of_read(int handle, void *buffer, int bufferSize); 64extern int of_write(int handle, const void *buffer, int bufferSize); 65extern int of_seek(int handle, off_t pos); 66 67/* memory functions */ 68extern int of_release(void *virtualAddress, int size); 69extern void *of_claim(void *virtualAddress, int size, int align); 70 71/* misc functions */ 72extern int of_call_client_function(const char *method, int numArgs, 73 int numReturns, ...); 74extern int of_interpret(const char *command, int numArgs, int numReturns, ...); 75extern int of_call_method(int handle, const char *method, int numArgs, 76 int numReturns, ...); 77extern int of_test(const char *service); 78extern int of_milliseconds(void); 79extern void of_exit(void); 80 81#ifdef __cplusplus 82} 83#endif 84 85#endif /* OPEN_FIRMWARE_H */ 86