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 <[email protected]>
This commit is contained in:
PulkoMandy
2019-08-10 17:59:04 +00:00
committed by waddlesplash
parent bb6e4f5d94
commit d5cd4a9d51
13 changed files with 201 additions and 189 deletions
@@ -13,7 +13,7 @@
bigtime_t system_time(void); bigtime_t system_time(void);
int32 of_address_cells(int package); int32 of_address_cells(intptr_t package);
int32 of_size_cells(int package); int32 of_size_cells(intptr_t package);
#endif #endif
@@ -12,7 +12,7 @@
extern "C" { extern "C" {
#endif #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); char *path, size_t pathSize);
#ifdef __cplusplus #ifdef __cplusplus
@@ -1,5 +1,6 @@
/* /*
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2019, Adrien Destugues, [email protected]
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef OPEN_FIRMWARE_H #ifndef OPEN_FIRMWARE_H
@@ -13,7 +14,7 @@
/* global device tree/properties access */ /* global device tree/properties access */
extern int gChosen; extern intptr_t gChosen;
template<typename AddressType> template<typename AddressType>
@@ -24,13 +25,13 @@ struct of_region {
struct of_arguments { struct of_arguments {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int data[0]; intptr_t data[0];
#ifdef __cplusplus #ifdef __cplusplus
int &Argument(int index) { return data[index]; } intptr_t &Argument(int index) { return data[index]; }
int &ReturnValue(int index) { return data[num_args + index]; } intptr_t &ReturnValue(int index) { return data[num_args + index]; }
#endif #endif
}; };
@@ -39,43 +40,46 @@ struct of_arguments {
extern "C" { extern "C" {
#endif #endif
extern status_t of_init(int (*openFirmwareEntry)(void *)); extern status_t of_init(intptr_t (*openFirmwareEntry)(void *));
/* device tree functions */ /* device tree functions */
extern int of_finddevice(const char *device); extern intptr_t of_finddevice(const char *device);
extern int of_child(int node); extern intptr_t of_child(intptr_t node);
extern int of_peer(int node); extern intptr_t of_peer(intptr_t node);
extern int of_parent(int node); extern intptr_t of_parent(intptr_t node);
extern int of_instance_to_path(int instance, char *pathBuffer, int bufferSize); extern intptr_t of_instance_to_path(uint32_t instance, char *pathBuffer,
extern int of_instance_to_package(int instance); intptr_t bufferSize);
extern int of_getprop(int package, const char *property, void *buffer, extern intptr_t of_instance_to_package(uint32_t instance);
int bufferSize); extern intptr_t of_getprop(intptr_t package, const char *property, void *buffer,
extern int of_setprop(int package, const char *property, const void *buffer, intptr_t bufferSize);
int bufferSize); extern intptr_t of_setprop(intptr_t package, const char *property, const void *buffer,
extern int of_nextprop(int package, const char *previousProperty, intptr_t bufferSize);
extern intptr_t of_nextprop(intptr_t package, const char *previousProperty,
char *nextProperty); char *nextProperty);
extern int of_getproplen(int package, const char *property); extern intptr_t of_getproplen(intptr_t package, const char *property);
extern int of_package_to_path(int package, char *pathBuffer, int bufferSize); extern intptr_t of_package_to_path(intptr_t package, char *pathBuffer,
intptr_t bufferSize);
/* I/O functions */ /* I/O functions */
extern int of_open(const char *nodeName); extern intptr_t of_open(const char *nodeName);
extern void of_close(int handle); extern void of_close(intptr_t handle);
extern int of_read(int handle, void *buffer, int bufferSize); extern intptr_t of_read(intptr_t handle, void *buffer, intptr_t bufferSize);
extern int of_write(int handle, const void *buffer, int bufferSize); extern intptr_t of_write(intptr_t handle, const void *buffer, intptr_t bufferSize);
extern int of_seek(int handle, off_t pos); extern intptr_t of_seek(intptr_t handle, off_t pos);
/* memory functions */ /* memory functions */
extern int of_release(void *virtualAddress, int size); extern intptr_t of_release(void *virtualAddress, intptr_t size);
extern void *of_claim(void *virtualAddress, int size, int align); extern void *of_claim(void *virtualAddress, intptr_t size, intptr_t align);
/* misc functions */ /* misc functions */
extern int of_call_client_function(const char *method, int numArgs, extern intptr_t of_call_client_function(const char *method, intptr_t numArgs,
int numReturns, ...); intptr_t numReturns, ...);
extern int of_interpret(const char *command, int numArgs, int numReturns, ...); extern intptr_t of_interpret(const char *command, intptr_t numArgs,
extern int of_call_method(int handle, const char *method, int numArgs, intptr_t numReturns, ...);
int numReturns, ...); extern intptr_t of_call_method(intptr_t handle, const char *method,
extern int of_test(const char *service); intptr_t numArgs, intptr_t numReturns, ...);
extern int of_milliseconds(void); extern intptr_t of_test(const char *service);
extern intptr_t of_milliseconds(void);
extern void of_exit(void); extern void of_exit(void);
#ifdef __cplusplus #ifdef __cplusplus
@@ -28,7 +28,7 @@ status_t
sparc_openfirmware_pci_controller_init(void) sparc_openfirmware_pci_controller_init(void)
{ {
char path[256]; char path[256];
int cookie = 0; intptr_t cookie = 0;
while (of_get_next_device(&cookie, 0, "pci", path, sizeof(path)) while (of_get_next_device(&cookie, 0, "pci", path, sizeof(path))
== B_OK) { == B_OK) {
dprintf("sparc_openfirmware_pci_controller_init(): pci device node: %s\n", path); dprintf("sparc_openfirmware_pci_controller_init(): pci device node: %s\n", path);
@@ -12,7 +12,7 @@
#include <util/kernel_cpp.h> #include <util/kernel_cpp.h>
Handle::Handle(int handle, bool takeOwnership) Handle::Handle(intptr_t handle, bool takeOwnership)
: :
fHandle(handle), fHandle(handle),
fOwnHandle(takeOwnership) fOwnHandle(takeOwnership)
@@ -35,7 +35,7 @@ Handle::~Handle()
void void
Handle::SetHandle(int handle, bool takeOwnership) Handle::SetHandle(intptr_t handle, bool takeOwnership)
{ {
if (fHandle && fOwnHandle) if (fHandle && fOwnHandle)
of_close(fHandle); of_close(fHandle);
@@ -13,11 +13,11 @@
class Handle : public ConsoleNode { class Handle : public ConsoleNode {
public: public:
Handle(int handle, bool takeOwnership = true); Handle(intptr_t handle, bool takeOwnership = true);
Handle(); Handle();
virtual ~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 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); 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; virtual off_t Size() const;
protected: protected:
int fHandle; intptr_t fHandle;
bool fOwnHandle; bool fOwnHandle;
}; };
#endif /* __cplusplus */ #endif /* __cplusplus */
@@ -191,11 +191,13 @@ InputConsoleHandle::GetChar()
status_t status_t
console_init(void) console_init(void)
{ {
int input, output; unsigned int input, output;
if (of_getprop(gChosen, "stdin", &input, sizeof(int)) == OF_FAILED) if (of_getprop(gChosen, "stdin", &input, sizeof(input)) != sizeof(input))
return B_ERROR; 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; return B_ERROR;
}
sInput.SetHandle(input); sInput.SetHandle(input);
sOutput.SetHandle(output); 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 // add all block devices to the list of possible boot devices
int cookie = 0; intptr_t cookie = 0;
char path[256]; char path[256];
status_t status; status_t status;
while ((status = of_get_next_device(&cookie, 0, "block", path, while ((status = of_get_next_device(&cookie, 0, "block", path,
@@ -22,7 +22,7 @@ status_t
init_real_time_clock(void) init_real_time_clock(void)
{ {
// find RTC // find RTC
int rtcCookie = 0; intptr_t rtcCookie = 0;
if (of_get_next_device(&rtcCookie, 0, "rtc", if (of_get_next_device(&rtcCookie, 0, "rtc",
gKernelArgs.platform_args.rtc_path, gKernelArgs.platform_args.rtc_path,
sizeof(gKernelArgs.platform_args.rtc_path)) != B_OK) { sizeof(gKernelArgs.platform_args.rtc_path)) != B_OK) {
@@ -93,7 +93,8 @@ start(void *openFirmwareEntry)
args.heap_size = HEAP_SIZE; args.heap_size = HEAP_SIZE;
args.arguments = NULL; args.arguments = NULL;
of_init((int (*)(void*))openFirmwareEntry); if (of_init((intptr_t (*)(void*))openFirmwareEntry) != B_OK)
return;
// check for arguments // check for arguments
if (of_getprop(gChosen, "bootargs", bootargs, sizeof(bootargs)) if (of_getprop(gChosen, "bootargs", bootargs, sizeof(bootargs))
@@ -105,7 +106,8 @@ start(void *openFirmwareEntry)
} }
determine_machine(); determine_machine();
console_init(); if (console_init() != B_OK)
return;
#ifdef __powerpc__ #ifdef __powerpc__
if ((gMachine & MACHINE_QEMU) != 0) if ((gMachine & MACHINE_QEMU) != 0)
@@ -26,7 +26,7 @@ system_time(void)
+ */ + */
int32 int32
of_address_cells(int package) { of_address_cells(intptr_t package) {
uint32 address_cells; uint32 address_cells;
if (of_getprop(package, "#address-cells", if (of_getprop(package, "#address-cells",
&address_cells, sizeof(address_cells)) == OF_FAILED) &address_cells, sizeof(address_cells)) == OF_FAILED)
@@ -37,7 +37,7 @@ of_address_cells(int package) {
int32 int32
of_size_cells(int package) { of_size_cells(intptr_t package) {
uint32 size_cells; uint32 size_cells;
if (of_getprop(package, "#size-cells", if (of_getprop(package, "#size-cells",
&size_cells, sizeof(size_cells)) == OF_FAILED) &size_cells, sizeof(size_cells)) == OF_FAILED)
@@ -1,5 +1,6 @@
/* /*
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2019, Adrien Destugues, [email protected]
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -9,12 +10,12 @@
// OpenFirmware entry function // OpenFirmware entry function
static int (*gCallOpenFirmware)(void *) = 0; static intptr_t (*gCallOpenFirmware)(void *) = 0;
int gChosen; intptr_t gChosen;
status_t status_t
of_init(int (*openFirmwareEntry)(void *)) of_init(intptr_t (*openFirmwareEntry)(void *))
{ {
gCallOpenFirmware = openFirmwareEntry; gCallOpenFirmware = openFirmwareEntry;
@@ -26,13 +27,14 @@ of_init(int (*openFirmwareEntry)(void *))
} }
int intptr_t
of_call_client_function(const char *method, int numArgs, int numReturns, ...) of_call_client_function(const char *method, intptr_t numArgs,
intptr_t numReturns, ...)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
void *args[10]; void *args[10];
} args = {method, numArgs, numReturns}; } args = {method, numArgs, numReturns};
va_list list; va_list list;
@@ -69,13 +71,13 @@ of_call_client_function(const char *method, int numArgs, int numReturns, ...)
} }
int intptr_t
of_interpret(const char *command, int numArgs, int numReturns, ...) of_interpret(const char *command, intptr_t numArgs, intptr_t numReturns, ...)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
// "IN: [string] cmd, stack_arg1, ..., stack_argP // "IN: [string] cmd, stack_arg1, ..., stack_argP
// OUT: catch-result, stack_result1, ..., stack_resultQ // OUT: catch-result, stack_result1, ..., stack_resultQ
// [...] // [...]
@@ -119,20 +121,21 @@ of_interpret(const char *command, int numArgs, int numReturns, ...)
} }
int intptr_t
of_call_method(int handle, const char *method, int numArgs, int numReturns, ...) of_call_method(intptr_t handle, const char *method, intptr_t numArgs,
intptr_t numReturns, ...)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
// "IN: [string] method, ihandle, stack_arg1, ..., stack_argP // "IN: [string] method, ihandle, stack_arg1, ..., stack_argP
// OUT: catch-result, stack_result1, ..., stack_resultQ // OUT: catch-result, stack_result1, ..., stack_resultQ
// [...] // [...]
// An implementation shall allow at least six stack_arg and six // An implementation shall allow at least six stack_arg and six
// stack_result items." // stack_result items."
const char *method; const char *method;
int handle; intptr_t handle;
void *args[13]; void *args[13];
} args = {"call-method", numArgs + 2, numReturns + 1, method, handle}; } args = {"call-method", numArgs + 2, numReturns + 1, method, handle};
va_list list; 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) of_finddevice(const char *device)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
const char *device; const char *device;
int handle; intptr_t handle;
} args = {"finddevice", 1, 1, device, 0}; } args = {"finddevice", 1, 1, device, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -191,15 +194,15 @@ of_finddevice(const char *device)
/** Returns the first child of the given node /** Returns the first child of the given node
*/ */
int intptr_t
of_child(int node) of_child(intptr_t node)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int node; intptr_t node;
int child; intptr_t child;
} args = {"child", 1, 1, node, 0}; } args = {"child", 1, 1, node, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -212,15 +215,15 @@ of_child(int node)
/** Returns the next sibling of the given node /** Returns the next sibling of the given node
*/ */
int intptr_t
of_peer(int node) of_peer(intptr_t node)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int node; intptr_t node;
int next_sibling; intptr_t next_sibling;
} args = {"peer", 1, 1, node, 0}; } args = {"peer", 1, 1, node, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -233,15 +236,15 @@ of_peer(int node)
/** Returns the parent of the given node /** Returns the parent of the given node
*/ */
int intptr_t
of_parent(int node) of_parent(intptr_t node)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int node; intptr_t node;
int parent; intptr_t parent;
} args = {"parent", 1, 1, node, 0}; } args = {"parent", 1, 1, node, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -251,17 +254,17 @@ of_parent(int node)
} }
int intptr_t
of_instance_to_path(int instance, char *pathBuffer, int bufferSize) of_instance_to_path(uint32_t instance, char *pathBuffer, intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int instance; intptr_t instance;
char *path_buffer; char *path_buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"instance-to-path", 3, 1, instance, pathBuffer, bufferSize, 0}; } args = {"instance-to-path", 3, 1, instance, pathBuffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -271,15 +274,15 @@ of_instance_to_path(int instance, char *pathBuffer, int bufferSize)
} }
int intptr_t
of_instance_to_package(int instance) of_instance_to_package(uint32_t instance)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int instance; intptr_t instance;
int package; intptr_t package;
} args = {"instance-to-package", 1, 1, instance, 0}; } args = {"instance-to-package", 1, 1, instance, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -289,18 +292,18 @@ of_instance_to_package(int instance)
} }
int intptr_t
of_getprop(int package, const char *property, void *buffer, int bufferSize) of_getprop(intptr_t package, const char *property, void *buffer, intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int package; intptr_t package;
const char *property; const char *property;
void *buffer; void *buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"getprop", 4, 1, package, property, buffer, bufferSize, 0}; } args = {"getprop", 4, 1, package, property, buffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -310,18 +313,19 @@ of_getprop(int package, const char *property, void *buffer, int bufferSize)
} }
int intptr_t
of_setprop(int package, const char *property, const void *buffer, int bufferSize) of_setprop(intptr_t package, const char *property, const void *buffer,
intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int package; intptr_t package;
const char *property; const char *property;
const void *buffer; const void *buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"setprop", 4, 1, package, property, buffer, bufferSize, 0}; } args = {"setprop", 4, 1, package, property, buffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -331,16 +335,16 @@ of_setprop(int package, const char *property, const void *buffer, int bufferSize
} }
int intptr_t
of_getproplen(int package, const char *property) of_getproplen(intptr_t package, const char *property)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int package; intptr_t package;
const char *property; const char *property;
int size; intptr_t size;
} args = {"getproplen", 2, 1, package, property, 0}; } args = {"getproplen", 2, 1, package, property, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -350,17 +354,17 @@ of_getproplen(int package, const char *property)
} }
int intptr_t
of_nextprop(int package, const char *previousProperty, char *nextProperty) of_nextprop(intptr_t package, const char *previousProperty, char *nextProperty)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int package; intptr_t package;
const char *previous_property; const char *previous_property;
char *next_property; char *next_property;
int flag; intptr_t flag;
} args = {"nextprop", 3, 1, package, previousProperty, nextProperty, 0}; } args = {"nextprop", 3, 1, package, previousProperty, nextProperty, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -370,17 +374,17 @@ of_nextprop(int package, const char *previousProperty, char *nextProperty)
} }
int intptr_t
of_package_to_path(int package, char *pathBuffer, int bufferSize) of_package_to_path(intptr_t package, char *pathBuffer, intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int package; intptr_t package;
char *path_buffer; char *path_buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"package-to-path", 3, 1, package, pathBuffer, bufferSize, 0}; } args = {"package-to-path", 3, 1, package, pathBuffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -393,15 +397,15 @@ of_package_to_path(int package, char *pathBuffer, int bufferSize)
// I/O functions // I/O functions
int intptr_t
of_open(const char *nodeName) of_open(const char *nodeName)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
const char *node_name; const char *node_name;
int handle; intptr_t handle;
} args = {"open", 1, 1, nodeName, 0}; } args = {"open", 1, 1, nodeName, 0};
if (gCallOpenFirmware(&args) == OF_FAILED || args.handle == 0) if (gCallOpenFirmware(&args) == OF_FAILED || args.handle == 0)
@@ -412,30 +416,30 @@ of_open(const char *nodeName)
void void
of_close(int handle) of_close(intptr_t handle)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int handle; intptr_t handle;
} args = {"close", 1, 0, handle}; } args = {"close", 1, 0, handle};
gCallOpenFirmware(&args); gCallOpenFirmware(&args);
} }
int intptr_t
of_read(int handle, void *buffer, int bufferSize) of_read(intptr_t handle, void *buffer, intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int handle; intptr_t handle;
void *buffer; void *buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"read", 3, 1, handle, buffer, bufferSize, 0}; } args = {"read", 3, 1, handle, buffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -445,17 +449,17 @@ of_read(int handle, void *buffer, int bufferSize)
} }
int intptr_t
of_write(int handle, const void *buffer, int bufferSize) of_write(intptr_t handle, const void *buffer, intptr_t bufferSize)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int handle; intptr_t handle;
const void *buffer; const void *buffer;
int buffer_size; intptr_t buffer_size;
int size; intptr_t size;
} args = {"write", 3, 1, handle, buffer, bufferSize, 0}; } args = {"write", 3, 1, handle, buffer, bufferSize, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -465,16 +469,16 @@ of_write(int handle, const void *buffer, int bufferSize)
} }
int intptr_t
of_seek(int handle, off_t pos) of_seek(intptr_t handle, off_t pos)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int handle; intptr_t handle;
int64 pos; int64 pos;
int status; intptr_t status;
} args = {"seek", 3, 1, handle, pos, 0}; } args = {"seek", 3, 1, handle, pos, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -487,15 +491,15 @@ of_seek(int handle, off_t pos)
// memory functions // memory functions
int intptr_t
of_release(void *virtualAddress, int size) of_release(void *virtualAddress, intptr_t size)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
void *virtualAddress; void *virtualAddress;
int size; intptr_t size;
} args = {"release", 2, 0, virtualAddress, size}; } args = {"release", 2, 0, virtualAddress, size};
return gCallOpenFirmware(&args); return gCallOpenFirmware(&args);
@@ -503,15 +507,15 @@ of_release(void *virtualAddress, int size)
void * void *
of_claim(void *virtualAddress, int size, int align) of_claim(void *virtualAddress, intptr_t size, intptr_t align)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
void *virtualAddress; void *virtualAddress;
int size; intptr_t size;
int align; intptr_t align;
void *address; void *address;
} args = {"claim", 3, 1, virtualAddress, size, align}; } 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 /** tests if the given service is missing
*/ */
int intptr_t
of_test(const char *service) of_test(const char *service)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
const char *service; const char *service;
int missing; intptr_t missing;
} args = {"test", 1, 1, service, 0}; } args = {"test", 1, 1, service, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -549,14 +553,14 @@ of_test(const char *service)
/** Returns the millisecond counter /** Returns the millisecond counter
*/ */
int intptr_t
of_milliseconds(void) of_milliseconds(void)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
int milliseconds; intptr_t milliseconds;
} args = {"milliseconds", 0, 1, 0}; } args = {"milliseconds", 0, 1, 0};
if (gCallOpenFirmware(&args) == OF_FAILED) if (gCallOpenFirmware(&args) == OF_FAILED)
@@ -571,8 +575,8 @@ of_exit(void)
{ {
struct { struct {
const char *name; const char *name;
int num_args; intptr_t num_args;
int num_returns; intptr_t num_returns;
} args = {"exit", 0, 0}; } args = {"exit", 0, 0};
gCallOpenFirmware(&args); gCallOpenFirmware(&args);
@@ -18,13 +18,13 @@
* The cookie has to be initialized to zero. * The cookie has to be initialized to zero.
*/ */
status_t status_t
of_get_next_device(int *_cookie, int root, const char *type, char *path, of_get_next_device(intptr_t *_cookie, intptr_t root, const char *type,
size_t pathSize) char *path, size_t pathSize)
{ {
int node = *_cookie; intptr_t node = *_cookie;
while (true) { while (true) {
int next; intptr_t next;
if (node == 0) { if (node == 0) {
// node is NULL, meaning that this is the initial function call. // node is NULL, meaning that this is the initial function call.