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 /* global device tree/properties access */ 15 extern int gChosen; 16 17 18 struct of_arguments { 19 const char *name; 20 int num_args; 21 int num_returns; 22 int data[0]; 23 24 #ifdef __cplusplus 25 int &Argument(int index) { return data[index]; } 26 int &ReturnValue(int index) { return data[num_args + index]; } 27 #endif 28 }; 29 30 struct of_region { 31 void *base; 32 uint32 size; 33 }; 34 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 extern status_t of_init(int (*openFirmwareEntry)(void *)); 41 42 /* device tree functions */ 43 extern int of_finddevice(const char *device); 44 extern int of_child(int node); 45 extern int of_peer(int node); 46 extern int of_parent(int node); 47 extern int of_instance_to_path(int instance, char *pathBuffer, int bufferSize); 48 extern int of_instance_to_package(int instance); 49 extern int of_getprop(int package, const char *property, void *buffer, 50 int bufferSize); 51 extern int of_setprop(int package, const char *property, const void *buffer, 52 int bufferSize); 53 extern int of_nextprop(int package, const char *previousProperty, 54 char *nextProperty); 55 extern int of_getproplen(int package, const char *property); 56 extern int of_package_to_path(int package, char *pathBuffer, int bufferSize); 57 58 /* I/O functions */ 59 extern int of_open(const char *nodeName); 60 extern void of_close(int handle); 61 extern int of_read(int handle, void *buffer, int bufferSize); 62 extern int of_write(int handle, const void *buffer, int bufferSize); 63 extern int of_seek(int handle, off_t pos); 64 65 /* memory functions */ 66 extern int of_release(void *virtualAddress, int size); 67 extern void *of_claim(void *virtualAddress, int size, int align); 68 69 /* misc functions */ 70 extern int of_call_client_function(const char *method, int numArgs, 71 int numReturns, ...); 72 extern int of_interpret(const char *command, int numArgs, int numReturns, ...); 73 extern int of_call_method(int handle, const char *method, int numArgs, 74 int numReturns, ...); 75 extern int of_test(const char *service); 76 extern int of_milliseconds(void); 77 extern void of_exit(void); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif /* OPEN_FIRMWARE_H */ 84