Skip to content

Commit

Permalink
Various PowerPC fixes
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Yn0ga authored and waddlesplash committed Oct 6, 2023
1 parent 3f2abbc commit cbb8810
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 64 deletions.
2 changes: 2 additions & 0 deletions build/jam/images/CDBootImage
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
Expand Down
64 changes: 0 additions & 64 deletions headers/private/kernel/arch/ppc/arch_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions headers/private/kernel/platform/openfirmware/openfirmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
36 changes: 36 additions & 0 deletions src/system/kernel/platform/openfirmware/openfirmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit cbb8810

Please sign in to comment.