[haiku-commits] haiku: hrev53360 - src/system/kernel/platform/openfirmware headers/private/kernel/platform/openfirmware src/system/boot/platform/openfirmware

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 10 Aug 2019 13:59:19 -0400 (EDT)

hrev53360 adds 1 changeset to branch 'master'
old head: bb6e4f5d94cbc0488fcd4cf6c6579dfb095b5506
new head: d5cd4a9d51842c063a3273a6a88dbfb2fdc82f7e
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=d5cd4a9d5184+%5Ebb6e4f5d94cb

----------------------------------------------------------------------------

d5cd4a9d5184: 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@xxxxxxxxx>

                                   [ PulkoMandy <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53360
Commit:      d5cd4a9d51842c063a3273a6a88dbfb2fdc82f7e
URL:         https://git.haiku-os.org/haiku/commit/?id=d5cd4a9d5184
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Apr  3 20:42:03 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Aug 10 17:59:04 2019 UTC

----------------------------------------------------------------------------

13 files changed, 201 insertions(+), 189 deletions(-)
.../kernel/boot/platform/openfirmware/support.h  |   4 +-
.../kernel/platform/openfirmware/devices.h       |   2 +-
.../kernel/platform/openfirmware/openfirmware.h  |  72 ++---
.../arch/sparc/openfirmware/pci_openfirmware.cpp |   2 +-
src/system/boot/platform/openfirmware/Handle.cpp |   4 +-
src/system/boot/platform/openfirmware/Handle.h   |   8 +-
.../boot/platform/openfirmware/console.cpp       |   8 +-
.../boot/platform/openfirmware/devices.cpp       |   2 +-
.../platform/openfirmware/real_time_clock.cpp    |   2 +-
src/system/boot/platform/openfirmware/start.cpp  |   6 +-
.../boot/platform/openfirmware/support.cpp       |   4 +-
.../platform/openfirmware/openfirmware.cpp       | 268 ++++++++++---------
.../openfirmware/openfirmware_devices.cpp        |   8 +-

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/boot/platform/openfirmware/support.h 
b/headers/private/kernel/boot/platform/openfirmware/support.h
index afdae7c48b..8d7b0ef75d 100644
--- a/headers/private/kernel/boot/platform/openfirmware/support.h
+++ b/headers/private/kernel/boot/platform/openfirmware/support.h
@@ -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
diff --git a/headers/private/kernel/platform/openfirmware/devices.h 
b/headers/private/kernel/platform/openfirmware/devices.h
index e365815a27..fd7380c96f 100644
--- a/headers/private/kernel/platform/openfirmware/devices.h
+++ b/headers/private/kernel/platform/openfirmware/devices.h
@@ -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
diff --git a/headers/private/kernel/platform/openfirmware/openfirmware.h 
b/headers/private/kernel/platform/openfirmware/openfirmware.h
index 7c82079c6b..2ca5212692 100644
--- a/headers/private/kernel/platform/openfirmware/openfirmware.h
+++ b/headers/private/kernel/platform/openfirmware/openfirmware.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2003, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx. All rights reserved.
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
  * 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
diff --git 
a/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
index 7df3153a98..11506abc66 100644
--- 
a/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
+++ 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
@@ -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);
diff --git a/src/system/boot/platform/openfirmware/Handle.cpp 
b/src/system/boot/platform/openfirmware/Handle.cpp
index 1ff0f87d75..6871ca614c 100644
--- a/src/system/boot/platform/openfirmware/Handle.cpp
+++ b/src/system/boot/platform/openfirmware/Handle.cpp
@@ -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);
diff --git a/src/system/boot/platform/openfirmware/Handle.h 
b/src/system/boot/platform/openfirmware/Handle.h
index 937b801bb4..d5e95836eb 100644
--- a/src/system/boot/platform/openfirmware/Handle.h
+++ b/src/system/boot/platform/openfirmware/Handle.h
@@ -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 */
diff --git a/src/system/boot/platform/openfirmware/console.cpp 
b/src/system/boot/platform/openfirmware/console.cpp
index f2aef4d32d..41aa3bf005 100644
--- a/src/system/boot/platform/openfirmware/console.cpp
+++ b/src/system/boot/platform/openfirmware/console.cpp
@@ -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);
diff --git a/src/system/boot/platform/openfirmware/devices.cpp 
b/src/system/boot/platform/openfirmware/devices.cpp
index e21f9c759e..507d622d10 100644
--- a/src/system/boot/platform/openfirmware/devices.cpp
+++ b/src/system/boot/platform/openfirmware/devices.cpp
@@ -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,
diff --git a/src/system/boot/platform/openfirmware/real_time_clock.cpp 
b/src/system/boot/platform/openfirmware/real_time_clock.cpp
index 3ea8bf522e..fb91a6686b 100644
--- a/src/system/boot/platform/openfirmware/real_time_clock.cpp
+++ b/src/system/boot/platform/openfirmware/real_time_clock.cpp
@@ -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) {
diff --git a/src/system/boot/platform/openfirmware/start.cpp 
b/src/system/boot/platform/openfirmware/start.cpp
index a034441dcb..e49398efdd 100644
--- a/src/system/boot/platform/openfirmware/start.cpp
+++ b/src/system/boot/platform/openfirmware/start.cpp
@@ -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)
diff --git a/src/system/boot/platform/openfirmware/support.cpp 
b/src/system/boot/platform/openfirmware/support.cpp
index 9c9a101f1f..2c4f630473 100644
--- a/src/system/boot/platform/openfirmware/support.cpp
+++ b/src/system/boot/platform/openfirmware/support.cpp
@@ -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)
diff --git a/src/system/kernel/platform/openfirmware/openfirmware.cpp 
b/src/system/kernel/platform/openfirmware/openfirmware.cpp
index 5594c98f09..d7d46bb7ee 100644
--- a/src/system/kernel/platform/openfirmware/openfirmware.cpp
+++ b/src/system/kernel/platform/openfirmware/openfirmware.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2003, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx. All rights reserved.
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
  * 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);
diff --git a/src/system/kernel/platform/openfirmware/openfirmware_devices.cpp 
b/src/system/kernel/platform/openfirmware/openfirmware_devices.cpp
index 35348d6406..03875e5ca8 100644
--- a/src/system/kernel/platform/openfirmware/openfirmware_devices.cpp
+++ b/src/system/kernel/platform/openfirmware/openfirmware_devices.cpp
@@ -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.


Other related posts:

  • » [haiku-commits] haiku: hrev53360 - src/system/kernel/platform/openfirmware headers/private/kernel/platform/openfirmware src/system/boot/platform/openfirmware - waddlesplash