2003-09-03 06:03:28 +04:00
|
|
|
/*
|
2005-12-19 12:44:52 +03:00
|
|
|
* Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
2019-04-03 23:42:03 +03:00
|
|
|
* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
2005-12-19 12:44:52 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2003-09-03 06:03:28 +04:00
|
|
|
#ifndef OPEN_FIRMWARE_H
|
|
|
|
#define OPEN_FIRMWARE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define OF_FAILED (-1)
|
|
|
|
|
2011-07-26 19:09:18 +04:00
|
|
|
|
2003-09-03 06:03:28 +04:00
|
|
|
/* global device tree/properties access */
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t gChosen;
|
2003-09-03 06:03:28 +04:00
|
|
|
|
|
|
|
|
2019-05-25 00:12:08 +03:00
|
|
|
template<typename AddressType, typename SizeType>
|
2011-07-26 02:46:24 +04:00
|
|
|
struct of_region {
|
2011-07-26 20:42:14 +04:00
|
|
|
AddressType base;
|
2019-05-25 00:12:08 +03:00
|
|
|
SizeType size;
|
2012-11-06 19:34:01 +04:00
|
|
|
} _PACKED;
|
2011-07-26 02:26:35 +04:00
|
|
|
|
2003-10-29 00:26:08 +03:00
|
|
|
struct of_arguments {
|
|
|
|
const char *name;
|
2019-04-03 23:42:03 +03:00
|
|
|
intptr_t num_args;
|
|
|
|
intptr_t num_returns;
|
|
|
|
intptr_t data[0];
|
2003-10-29 00:26:08 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2019-04-03 23:42:03 +03:00
|
|
|
intptr_t &Argument(int index) { return data[index]; }
|
|
|
|
intptr_t &ReturnValue(int index) { return data[num_args + index]; }
|
2003-10-29 00:26:08 +03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2003-10-08 02:44:34 +04:00
|
|
|
|
2003-09-03 06:03:28 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-04-03 23:42:03 +03:00
|
|
|
extern status_t of_init(intptr_t (*openFirmwareEntry)(void *));
|
2003-09-03 06:03:28 +04:00
|
|
|
|
|
|
|
/* device tree functions */
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t of_finddevice(const char *device);
|
|
|
|
extern intptr_t of_child(intptr_t node);
|
|
|
|
extern intptr_t of_peer(intptr_t node);
|
|
|
|
extern intptr_t of_parent(intptr_t node);
|
|
|
|
extern intptr_t of_instance_to_path(uint32_t instance, char *pathBuffer,
|
|
|
|
intptr_t bufferSize);
|
|
|
|
extern intptr_t of_instance_to_package(uint32_t instance);
|
|
|
|
extern intptr_t of_getprop(intptr_t package, const char *property, void *buffer,
|
|
|
|
intptr_t bufferSize);
|
|
|
|
extern intptr_t of_setprop(intptr_t package, const char *property, const void *buffer,
|
|
|
|
intptr_t bufferSize);
|
|
|
|
extern intptr_t of_nextprop(intptr_t package, const char *previousProperty,
|
2005-12-28 00:15:56 +03:00
|
|
|
char *nextProperty);
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t of_getproplen(intptr_t package, const char *property);
|
|
|
|
extern intptr_t of_package_to_path(intptr_t package, char *pathBuffer,
|
|
|
|
intptr_t bufferSize);
|
2003-09-03 06:03:28 +04:00
|
|
|
|
|
|
|
/* I/O functions */
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t of_open(const char *nodeName);
|
|
|
|
extern void of_close(intptr_t handle);
|
|
|
|
extern intptr_t of_read(intptr_t handle, void *buffer, intptr_t bufferSize);
|
|
|
|
extern intptr_t of_write(intptr_t handle, const void *buffer, intptr_t bufferSize);
|
|
|
|
extern intptr_t of_seek(intptr_t handle, off_t pos);
|
2003-09-03 06:03:28 +04:00
|
|
|
|
|
|
|
/* memory functions */
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t of_release(void *virtualAddress, intptr_t size);
|
|
|
|
extern void *of_claim(void *virtualAddress, intptr_t size, intptr_t align);
|
2003-09-03 06:03:28 +04:00
|
|
|
|
|
|
|
/* misc functions */
|
2019-04-03 23:42:03 +03:00
|
|
|
extern intptr_t of_call_client_function(const char *method, intptr_t numArgs,
|
|
|
|
intptr_t numReturns, ...);
|
|
|
|
extern intptr_t of_interpret(const char *command, intptr_t numArgs,
|
|
|
|
intptr_t numReturns, ...);
|
2019-10-27 21:34:25 +03:00
|
|
|
extern intptr_t of_call_method(uint32_t handle, const char *method,
|
2019-04-03 23:42:03 +03:00
|
|
|
intptr_t numArgs, intptr_t numReturns, ...);
|
|
|
|
extern intptr_t of_test(const char *service);
|
|
|
|
extern intptr_t of_milliseconds(void);
|
2003-09-03 06:03:28 +04:00
|
|
|
extern void of_exit(void);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* OPEN_FIRMWARE_H */
|