Skip to content

Commit

Permalink
fix: IOP gp register access on newer compiler
Browse files Browse the repository at this point in the history
Now the respective functions are always exposed
  • Loading branch information
uyjulian committed Aug 29, 2024
1 parent 304b840 commit f66c151
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions iop/kernel/include/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,38 @@ extern "C" {
#define KSEG1ADDR(a) ((__typeof__(a))(((u32)(a) & 0x1fffffff) | KSEG1))

#if !defined(USE_GP_REGISTER)
#if __GNUC__ > 3
#define USE_GP_REGISTER 0
#else
#define USE_GP_REGISTER 1
#endif
#endif

#if USE_GP_REGISTER
static __inline__ void *ChangeGP(void *gp)
{
void *OldGP;

__asm__ volatile( "move %0, $gp\n"
"move $gp, %1"
: "=&r"(OldGP)
: "r"(gp)
: "gp", "memory");

return OldGP;
}

static __inline__ void SetGP(void *gp)
{
__asm__ volatile( "move $gp, %0"
:
: "r"(gp)
: "gp", "memory");
register void *gpReg __asm__("gp");

gpReg = gp;
__asm__ __volatile__(" " ::"r"(gpReg));
}

extern void *_gp;
#define SetModuleGP() ChangeGP(&_gp)

static __inline__ void *GetGP(void)
{
void *gp;
register void *gpReg __asm__("gp");

__asm__ volatile( "move %0, $gp"
: "=r"(gp)
:
: "memory");
__asm__ __volatile__(" " : "=r"(gpReg));
return gpReg;
}

static __inline__ void *ChangeGP(void *gp)
{
void *OldGP;

return gp;
OldGP = GetGP();
SetGP(gp);

return OldGP;
}
#endif

#define SetModuleGP() ChangeGP(&_gp)

static inline void *iop_memcpy(void *dest, const void *src, int size)
{
Expand Down

0 comments on commit f66c151

Please sign in to comment.