Various PowerPC fixes

* Removed atomic operations placeholders for modern ones
* Fix chrpscript & hfsmaps location for CDBootImage (haiku-boot-cd target)
* add of_blocks & of_blocksize openfirmware call

Change-Id: Iaaddc2c566d108976ac5e5e08caea1fc59523e06
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6987
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Yn0ga 2023-10-05 21:16:53 +00:00 committed by waddlesplash
parent 3f2abbc390
commit cbb88108d5
4 changed files with 40 additions and 64 deletions

View File

@ -24,6 +24,8 @@ if $(TARGET_ARCH) = ppc {
local chrpscript = ofboot.chrp ;
# HFS creator and application type mapping for mkisofs
local hfsmaps = hfs.map ;
SEARCH on $(chrpscript) = [ FDirName $(HAIKU_TOP) data boot openfirmware ] ;
SEARCH on $(hfsmaps) = [ FDirName $(HAIKU_TOP) data boot openfirmware ] ;
BuildCDBootPPCImage $(HAIKU_CD_BOOT_IMAGE) : $(hfsmaps)
: $(elfloader) : $(coffloader) : $(chrpscript) : $(extras) ;

View File

@ -43,68 +43,4 @@ memory_full_barrier_inline(void)
#define memory_full_barrier memory_full_barrier_inline
static inline void
atomic_set_inline(int32* value, int32 newValue)
{
memory_write_barrier();
*(volatile int32*)value = newValue;
}
static inline int32
atomic_get_and_set_inline(int32* value, int32 newValue)
{
// BIG TODO: PowerPC Atomic get and set
// asm volatile("xchgl %0, (%1)"
// : "+r" (newValue)
// : "r" (value)
// : "memory");
return newValue;
}
static inline int32
atomic_test_and_set_inline(int32* value, int32 newValue, int32 testAgainst)
{
// BIG TODO: PowerPC Atomic test and set inline
// asm volatile("lock; cmpxchgl %2, (%3)"
// : "=a" (newValue)
// : "0" (testAgainst), "r" (newValue), "r" (value)
// : "memory");
return newValue;
}
static inline int32
atomic_add_inline(int32* value, int32 newValue)
{
// BIG TODO: PowerPC Atomic add inline
// asm volatile("lock; xaddl %0, (%1)"
// : "+r" (newValue)
// : "r" (value)
// : "memory");
return newValue;
}
static inline int32
atomic_get_inline(int32* value)
{
int32 newValue = *(volatile int32*)value;
memory_read_barrier();
return newValue;
}
#define atomic_set atomic_set_inline
#define atomic_get_and_set atomic_get_and_set_inline
#ifndef atomic_test_and_set
# define atomic_test_and_set atomic_test_and_set_inline
#endif
#ifndef atomic_add
# define atomic_add atomic_add_inline
#endif
#define atomic_get atomic_get_inline
#endif // _KERNEL_ARCH_PPC_ATOMIC_H

View File

@ -66,6 +66,8 @@ 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);
extern intptr_t of_blocks(intptr_t handle);
extern intptr_t of_block_size(intptr_t handle);
/* memory functions */
extern intptr_t of_release(void *virtualAddress, intptr_t size);

View File

@ -493,6 +493,42 @@ of_seek(intptr_t handle, off_t pos)
}
intptr_t
of_blocks(intptr_t handle)
{
struct {
const char *name;
intptr_t num_args;
intptr_t num_returns;
intptr_t handle;
intptr_t result;
intptr_t blocks;
} args = {"#blocks", 2, 1, handle, 0, 0};
if (gCallOpenFirmware(&args) == OF_FAILED)
return OF_FAILED;
return args.blocks;
}
intptr_t
of_block_size(intptr_t handle)
{
struct {
const char *name;
intptr_t num_args;
intptr_t num_returns;
intptr_t handle;
intptr_t result;
intptr_t size;
} args = {"block-size", 2, 1, handle, 0, 0};
if (gCallOpenFirmware(&args) == OF_FAILED)
return OF_FAILED;
return args.size;
}
// memory functions