openfirmware: adjust for 64bit
Sparcv9 runs Openboot in 64 bit mode, which means the cell size is 64bit. Use intptr_t where appropriate to make the open firmware calls work. Beware, some values are still 32bit, this matters for example for of_getprop, if you get 32bits into a 64bit variables it will be in the MSB of it (big endian only weakness...) and confuse things. See for example in console.cpp, where the input and output handles are retrieved as 32bit values. It seems wise to check the expected size when using of_getprop in these cases, instead of just checking for errors. Change-Id: Ie72ebc4afe7c6d7602a47478f0bfb6b8247004b8 Reviewed-on: https://review.haiku-os.org/c/1369 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
bb6e4f5d94
commit
d5cd4a9d51
@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
bigtime_t system_time(void);
|
||||
int32 of_address_cells(int package);
|
||||
int32 of_size_cells(int package);
|
||||
int32 of_address_cells(intptr_t package);
|
||||
int32 of_size_cells(intptr_t package);
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
status_t of_get_next_device(int *_cookie, int root, const char *type,
|
||||
status_t of_get_next_device(intptr_t *_cookie, intptr_t root, const char *type,
|
||||
char *path, size_t pathSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef OPEN_FIRMWARE_H
|
||||
@ -13,7 +14,7 @@
|
||||
|
||||
|
||||
/* global device tree/properties access */
|
||||
extern int gChosen;
|
||||
extern intptr_t gChosen;
|
||||
|
||||
|
||||
template<typename AddressType>
|
||||
@ -24,13 +25,13 @@ struct of_region {
|
||||
|
||||
struct of_arguments {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int data[0];
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t data[0];
|
||||
|
||||
#ifdef __cplusplus
|
||||
int &Argument(int index) { return data[index]; }
|
||||
int &ReturnValue(int index) { return data[num_args + index]; }
|
||||
intptr_t &Argument(int index) { return data[index]; }
|
||||
intptr_t &ReturnValue(int index) { return data[num_args + index]; }
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -39,43 +40,46 @@ struct of_arguments {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern status_t of_init(int (*openFirmwareEntry)(void *));
|
||||
extern status_t of_init(intptr_t (*openFirmwareEntry)(void *));
|
||||
|
||||
/* device tree functions */
|
||||
extern int of_finddevice(const char *device);
|
||||
extern int of_child(int node);
|
||||
extern int of_peer(int node);
|
||||
extern int of_parent(int node);
|
||||
extern int of_instance_to_path(int instance, char *pathBuffer, int bufferSize);
|
||||
extern int of_instance_to_package(int instance);
|
||||
extern int of_getprop(int package, const char *property, void *buffer,
|
||||
int bufferSize);
|
||||
extern int of_setprop(int package, const char *property, const void *buffer,
|
||||
int bufferSize);
|
||||
extern int of_nextprop(int package, const char *previousProperty,
|
||||
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,
|
||||
char *nextProperty);
|
||||
extern int of_getproplen(int package, const char *property);
|
||||
extern int of_package_to_path(int package, char *pathBuffer, int bufferSize);
|
||||
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);
|
||||
|
||||
/* I/O functions */
|
||||
extern int of_open(const char *nodeName);
|
||||
extern void of_close(int handle);
|
||||
extern int of_read(int handle, void *buffer, int bufferSize);
|
||||
extern int of_write(int handle, const void *buffer, int bufferSize);
|
||||
extern int of_seek(int handle, off_t pos);
|
||||
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);
|
||||
|
||||
/* memory functions */
|
||||
extern int of_release(void *virtualAddress, int size);
|
||||
extern void *of_claim(void *virtualAddress, int size, int align);
|
||||
extern intptr_t of_release(void *virtualAddress, intptr_t size);
|
||||
extern void *of_claim(void *virtualAddress, intptr_t size, intptr_t align);
|
||||
|
||||
/* misc functions */
|
||||
extern int of_call_client_function(const char *method, int numArgs,
|
||||
int numReturns, ...);
|
||||
extern int of_interpret(const char *command, int numArgs, int numReturns, ...);
|
||||
extern int of_call_method(int handle, const char *method, int numArgs,
|
||||
int numReturns, ...);
|
||||
extern int of_test(const char *service);
|
||||
extern int of_milliseconds(void);
|
||||
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, ...);
|
||||
extern intptr_t of_call_method(intptr_t handle, const char *method,
|
||||
intptr_t numArgs, intptr_t numReturns, ...);
|
||||
extern intptr_t of_test(const char *service);
|
||||
extern intptr_t of_milliseconds(void);
|
||||
extern void of_exit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -28,7 +28,7 @@ status_t
|
||||
sparc_openfirmware_pci_controller_init(void)
|
||||
{
|
||||
char path[256];
|
||||
int cookie = 0;
|
||||
intptr_t cookie = 0;
|
||||
while (of_get_next_device(&cookie, 0, "pci", path, sizeof(path))
|
||||
== B_OK) {
|
||||
dprintf("sparc_openfirmware_pci_controller_init(): pci device node: %s\n", path);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
|
||||
Handle::Handle(int handle, bool takeOwnership)
|
||||
Handle::Handle(intptr_t handle, bool takeOwnership)
|
||||
:
|
||||
fHandle(handle),
|
||||
fOwnHandle(takeOwnership)
|
||||
@ -35,7 +35,7 @@ Handle::~Handle()
|
||||
|
||||
|
||||
void
|
||||
Handle::SetHandle(int handle, bool takeOwnership)
|
||||
Handle::SetHandle(intptr_t handle, bool takeOwnership)
|
||||
{
|
||||
if (fHandle && fOwnHandle)
|
||||
of_close(fHandle);
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
class Handle : public ConsoleNode {
|
||||
public:
|
||||
Handle(int handle, bool takeOwnership = true);
|
||||
Handle(intptr_t handle, bool takeOwnership = true);
|
||||
Handle();
|
||||
virtual ~Handle();
|
||||
|
||||
void SetHandle(int handle, bool takeOwnership = true);
|
||||
void SetHandle(intptr_t handle, bool takeOwnership = true);
|
||||
|
||||
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize);
|
||||
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize);
|
||||
@ -25,8 +25,8 @@ class Handle : public ConsoleNode {
|
||||
virtual off_t Size() const;
|
||||
|
||||
protected:
|
||||
int fHandle;
|
||||
bool fOwnHandle;
|
||||
intptr_t fHandle;
|
||||
bool fOwnHandle;
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
@ -191,11 +191,13 @@ InputConsoleHandle::GetChar()
|
||||
status_t
|
||||
console_init(void)
|
||||
{
|
||||
int input, output;
|
||||
if (of_getprop(gChosen, "stdin", &input, sizeof(int)) == OF_FAILED)
|
||||
unsigned int input, output;
|
||||
if (of_getprop(gChosen, "stdin", &input, sizeof(input)) != sizeof(input))
|
||||
return B_ERROR;
|
||||
if (of_getprop(gChosen, "stdout", &output, sizeof(int)) == OF_FAILED)
|
||||
if (of_getprop(gChosen, "stdout", &output, sizeof(output))
|
||||
!= sizeof(output)) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
sInput.SetHandle(input);
|
||||
sOutput.SetHandle(output);
|
||||
|
@ -182,7 +182,7 @@ platform_add_block_devices(stage2_args *args, NodeList *devicesList)
|
||||
{
|
||||
// add all block devices to the list of possible boot devices
|
||||
|
||||
int cookie = 0;
|
||||
intptr_t cookie = 0;
|
||||
char path[256];
|
||||
status_t status;
|
||||
while ((status = of_get_next_device(&cookie, 0, "block", path,
|
||||
|
@ -22,7 +22,7 @@ status_t
|
||||
init_real_time_clock(void)
|
||||
{
|
||||
// find RTC
|
||||
int rtcCookie = 0;
|
||||
intptr_t rtcCookie = 0;
|
||||
if (of_get_next_device(&rtcCookie, 0, "rtc",
|
||||
gKernelArgs.platform_args.rtc_path,
|
||||
sizeof(gKernelArgs.platform_args.rtc_path)) != B_OK) {
|
||||
|
@ -93,7 +93,8 @@ start(void *openFirmwareEntry)
|
||||
args.heap_size = HEAP_SIZE;
|
||||
args.arguments = NULL;
|
||||
|
||||
of_init((int (*)(void*))openFirmwareEntry);
|
||||
if (of_init((intptr_t (*)(void*))openFirmwareEntry) != B_OK)
|
||||
return;
|
||||
|
||||
// check for arguments
|
||||
if (of_getprop(gChosen, "bootargs", bootargs, sizeof(bootargs))
|
||||
@ -105,7 +106,8 @@ start(void *openFirmwareEntry)
|
||||
}
|
||||
|
||||
determine_machine();
|
||||
console_init();
|
||||
if (console_init() != B_OK)
|
||||
return;
|
||||
|
||||
#ifdef __powerpc__
|
||||
if ((gMachine & MACHINE_QEMU) != 0)
|
||||
|
@ -26,7 +26,7 @@ system_time(void)
|
||||
+ */
|
||||
|
||||
int32
|
||||
of_address_cells(int package) {
|
||||
of_address_cells(intptr_t package) {
|
||||
uint32 address_cells;
|
||||
if (of_getprop(package, "#address-cells",
|
||||
&address_cells, sizeof(address_cells)) == OF_FAILED)
|
||||
@ -37,7 +37,7 @@ of_address_cells(int package) {
|
||||
|
||||
|
||||
int32
|
||||
of_size_cells(int package) {
|
||||
of_size_cells(intptr_t package) {
|
||||
uint32 size_cells;
|
||||
if (of_getprop(package, "#size-cells",
|
||||
&size_cells, sizeof(size_cells)) == OF_FAILED)
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -9,12 +10,12 @@
|
||||
|
||||
|
||||
// OpenFirmware entry function
|
||||
static int (*gCallOpenFirmware)(void *) = 0;
|
||||
int gChosen;
|
||||
static intptr_t (*gCallOpenFirmware)(void *) = 0;
|
||||
intptr_t gChosen;
|
||||
|
||||
|
||||
status_t
|
||||
of_init(int (*openFirmwareEntry)(void *))
|
||||
of_init(intptr_t (*openFirmwareEntry)(void *))
|
||||
{
|
||||
gCallOpenFirmware = openFirmwareEntry;
|
||||
|
||||
@ -26,13 +27,14 @@ of_init(int (*openFirmwareEntry)(void *))
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_call_client_function(const char *method, int numArgs, int numReturns, ...)
|
||||
intptr_t
|
||||
of_call_client_function(const char *method, intptr_t numArgs,
|
||||
intptr_t numReturns, ...)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
void *args[10];
|
||||
} args = {method, numArgs, numReturns};
|
||||
va_list list;
|
||||
@ -69,13 +71,13 @@ of_call_client_function(const char *method, int numArgs, int numReturns, ...)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_interpret(const char *command, int numArgs, int numReturns, ...)
|
||||
intptr_t
|
||||
of_interpret(const char *command, intptr_t numArgs, intptr_t numReturns, ...)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
// "IN: [string] cmd, stack_arg1, ..., stack_argP
|
||||
// OUT: catch-result, stack_result1, ..., stack_resultQ
|
||||
// [...]
|
||||
@ -119,20 +121,21 @@ of_interpret(const char *command, int numArgs, int numReturns, ...)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_call_method(int handle, const char *method, int numArgs, int numReturns, ...)
|
||||
intptr_t
|
||||
of_call_method(intptr_t handle, const char *method, intptr_t numArgs,
|
||||
intptr_t numReturns, ...)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
// "IN: [string] method, ihandle, stack_arg1, ..., stack_argP
|
||||
// OUT: catch-result, stack_result1, ..., stack_resultQ
|
||||
// [...]
|
||||
// An implementation shall allow at least six stack_arg and six
|
||||
// stack_result items."
|
||||
const char *method;
|
||||
int handle;
|
||||
intptr_t handle;
|
||||
void *args[13];
|
||||
} args = {"call-method", numArgs + 2, numReturns + 1, method, handle};
|
||||
va_list list;
|
||||
@ -170,15 +173,15 @@ of_call_method(int handle, const char *method, int numArgs, int numReturns, ...)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
intptr_t
|
||||
of_finddevice(const char *device)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
const char *device;
|
||||
int handle;
|
||||
intptr_t handle;
|
||||
} args = {"finddevice", 1, 1, device, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -191,15 +194,15 @@ of_finddevice(const char *device)
|
||||
/** Returns the first child of the given node
|
||||
*/
|
||||
|
||||
int
|
||||
of_child(int node)
|
||||
intptr_t
|
||||
of_child(intptr_t node)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int node;
|
||||
int child;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t node;
|
||||
intptr_t child;
|
||||
} args = {"child", 1, 1, node, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -212,15 +215,15 @@ of_child(int node)
|
||||
/** Returns the next sibling of the given node
|
||||
*/
|
||||
|
||||
int
|
||||
of_peer(int node)
|
||||
intptr_t
|
||||
of_peer(intptr_t node)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int node;
|
||||
int next_sibling;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t node;
|
||||
intptr_t next_sibling;
|
||||
} args = {"peer", 1, 1, node, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -233,15 +236,15 @@ of_peer(int node)
|
||||
/** Returns the parent of the given node
|
||||
*/
|
||||
|
||||
int
|
||||
of_parent(int node)
|
||||
intptr_t
|
||||
of_parent(intptr_t node)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int node;
|
||||
int parent;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t node;
|
||||
intptr_t parent;
|
||||
} args = {"parent", 1, 1, node, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -251,17 +254,17 @@ of_parent(int node)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_instance_to_path(int instance, char *pathBuffer, int bufferSize)
|
||||
intptr_t
|
||||
of_instance_to_path(uint32_t instance, char *pathBuffer, intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int instance;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t instance;
|
||||
char *path_buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"instance-to-path", 3, 1, instance, pathBuffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -271,15 +274,15 @@ of_instance_to_path(int instance, char *pathBuffer, int bufferSize)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_instance_to_package(int instance)
|
||||
intptr_t
|
||||
of_instance_to_package(uint32_t instance)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int instance;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t instance;
|
||||
intptr_t package;
|
||||
} args = {"instance-to-package", 1, 1, instance, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -289,18 +292,18 @@ of_instance_to_package(int instance)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_getprop(int package, const char *property, void *buffer, int bufferSize)
|
||||
intptr_t
|
||||
of_getprop(intptr_t package, const char *property, void *buffer, intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t package;
|
||||
const char *property;
|
||||
void *buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"getprop", 4, 1, package, property, buffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -310,18 +313,19 @@ of_getprop(int package, const char *property, void *buffer, int bufferSize)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_setprop(int package, const char *property, const void *buffer, int bufferSize)
|
||||
intptr_t
|
||||
of_setprop(intptr_t package, const char *property, const void *buffer,
|
||||
intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t package;
|
||||
const char *property;
|
||||
const void *buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"setprop", 4, 1, package, property, buffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -331,16 +335,16 @@ of_setprop(int package, const char *property, const void *buffer, int bufferSize
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_getproplen(int package, const char *property)
|
||||
intptr_t
|
||||
of_getproplen(intptr_t package, const char *property)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t package;
|
||||
const char *property;
|
||||
int size;
|
||||
intptr_t size;
|
||||
} args = {"getproplen", 2, 1, package, property, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -350,17 +354,17 @@ of_getproplen(int package, const char *property)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_nextprop(int package, const char *previousProperty, char *nextProperty)
|
||||
intptr_t
|
||||
of_nextprop(intptr_t package, const char *previousProperty, char *nextProperty)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t package;
|
||||
const char *previous_property;
|
||||
char *next_property;
|
||||
int flag;
|
||||
intptr_t flag;
|
||||
} args = {"nextprop", 3, 1, package, previousProperty, nextProperty, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -370,17 +374,17 @@ of_nextprop(int package, const char *previousProperty, char *nextProperty)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_package_to_path(int package, char *pathBuffer, int bufferSize)
|
||||
intptr_t
|
||||
of_package_to_path(intptr_t package, char *pathBuffer, intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int package;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t package;
|
||||
char *path_buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"package-to-path", 3, 1, package, pathBuffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -393,15 +397,15 @@ of_package_to_path(int package, char *pathBuffer, int bufferSize)
|
||||
// I/O functions
|
||||
|
||||
|
||||
int
|
||||
intptr_t
|
||||
of_open(const char *nodeName)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
const char *node_name;
|
||||
int handle;
|
||||
intptr_t handle;
|
||||
} args = {"open", 1, 1, nodeName, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED || args.handle == 0)
|
||||
@ -412,30 +416,30 @@ of_open(const char *nodeName)
|
||||
|
||||
|
||||
void
|
||||
of_close(int handle)
|
||||
of_close(intptr_t handle)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int handle;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t handle;
|
||||
} args = {"close", 1, 0, handle};
|
||||
|
||||
gCallOpenFirmware(&args);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_read(int handle, void *buffer, int bufferSize)
|
||||
intptr_t
|
||||
of_read(intptr_t handle, void *buffer, intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int handle;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t handle;
|
||||
void *buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"read", 3, 1, handle, buffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -445,17 +449,17 @@ of_read(int handle, void *buffer, int bufferSize)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_write(int handle, const void *buffer, int bufferSize)
|
||||
intptr_t
|
||||
of_write(intptr_t handle, const void *buffer, intptr_t bufferSize)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int handle;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t handle;
|
||||
const void *buffer;
|
||||
int buffer_size;
|
||||
int size;
|
||||
intptr_t buffer_size;
|
||||
intptr_t size;
|
||||
} args = {"write", 3, 1, handle, buffer, bufferSize, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -465,16 +469,16 @@ of_write(int handle, const void *buffer, int bufferSize)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
of_seek(int handle, off_t pos)
|
||||
intptr_t
|
||||
of_seek(intptr_t handle, off_t pos)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int handle;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t handle;
|
||||
int64 pos;
|
||||
int status;
|
||||
intptr_t status;
|
||||
} args = {"seek", 3, 1, handle, pos, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -487,15 +491,15 @@ of_seek(int handle, off_t pos)
|
||||
// memory functions
|
||||
|
||||
|
||||
int
|
||||
of_release(void *virtualAddress, int size)
|
||||
intptr_t
|
||||
of_release(void *virtualAddress, intptr_t size)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
void *virtualAddress;
|
||||
int size;
|
||||
intptr_t size;
|
||||
} args = {"release", 2, 0, virtualAddress, size};
|
||||
|
||||
return gCallOpenFirmware(&args);
|
||||
@ -503,15 +507,15 @@ of_release(void *virtualAddress, int size)
|
||||
|
||||
|
||||
void *
|
||||
of_claim(void *virtualAddress, int size, int align)
|
||||
of_claim(void *virtualAddress, intptr_t size, intptr_t align)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
void *virtualAddress;
|
||||
int size;
|
||||
int align;
|
||||
intptr_t size;
|
||||
intptr_t align;
|
||||
void *address;
|
||||
} args = {"claim", 3, 1, virtualAddress, size, align};
|
||||
|
||||
@ -528,15 +532,15 @@ of_claim(void *virtualAddress, int size, int align)
|
||||
/** tests if the given service is missing
|
||||
*/
|
||||
|
||||
int
|
||||
intptr_t
|
||||
of_test(const char *service)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
const char *service;
|
||||
int missing;
|
||||
intptr_t missing;
|
||||
} args = {"test", 1, 1, service, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -549,14 +553,14 @@ of_test(const char *service)
|
||||
/** Returns the millisecond counter
|
||||
*/
|
||||
|
||||
int
|
||||
intptr_t
|
||||
of_milliseconds(void)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
int milliseconds;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
intptr_t milliseconds;
|
||||
} args = {"milliseconds", 0, 1, 0};
|
||||
|
||||
if (gCallOpenFirmware(&args) == OF_FAILED)
|
||||
@ -571,8 +575,8 @@ of_exit(void)
|
||||
{
|
||||
struct {
|
||||
const char *name;
|
||||
int num_args;
|
||||
int num_returns;
|
||||
intptr_t num_args;
|
||||
intptr_t num_returns;
|
||||
} args = {"exit", 0, 0};
|
||||
|
||||
gCallOpenFirmware(&args);
|
||||
|
@ -18,13 +18,13 @@
|
||||
* The cookie has to be initialized to zero.
|
||||
*/
|
||||
status_t
|
||||
of_get_next_device(int *_cookie, int root, const char *type, char *path,
|
||||
size_t pathSize)
|
||||
of_get_next_device(intptr_t *_cookie, intptr_t root, const char *type,
|
||||
char *path, size_t pathSize)
|
||||
{
|
||||
int node = *_cookie;
|
||||
intptr_t node = *_cookie;
|
||||
|
||||
while (true) {
|
||||
int next;
|
||||
intptr_t next;
|
||||
|
||||
if (node == 0) {
|
||||
// node is NULL, meaning that this is the initial function call.
|
||||
|
Loading…
Reference in New Issue
Block a user