haiku/headers/private/kernel/platform/openfirmware/openfirmware.h
PulkoMandy d5cd4a9d51 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>
2019-08-10 17:59:04 +00:00

90 lines
2.6 KiB
C++

/*
* 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
#define OPEN_FIRMWARE_H
#include <SupportDefs.h>
#define OF_FAILED (-1)
/* global device tree/properties access */
extern intptr_t gChosen;
template<typename AddressType>
struct of_region {
AddressType base;
uint32 size;
} _PACKED;
struct of_arguments {
const char *name;
intptr_t num_args;
intptr_t num_returns;
intptr_t data[0];
#ifdef __cplusplus
intptr_t &Argument(int index) { return data[index]; }
intptr_t &ReturnValue(int index) { return data[num_args + index]; }
#endif
};
#ifdef __cplusplus
extern "C" {
#endif
extern status_t of_init(intptr_t (*openFirmwareEntry)(void *));
/* device tree functions */
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 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 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 intptr_t of_release(void *virtualAddress, intptr_t size);
extern void *of_claim(void *virtualAddress, intptr_t size, intptr_t align);
/* misc functions */
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
}
#endif
#endif /* OPEN_FIRMWARE_H */