Skip to content

Commit

Permalink
Merge pull request #657 from uyjulian/gpfixes_iop
Browse files Browse the repository at this point in the history
Fix GP register access for IOP on newer toolchain
  • Loading branch information
rickgaiser authored Aug 30, 2024
2 parents 39b57b1 + f66c151 commit 2e2b277
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 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
3 changes: 2 additions & 1 deletion iop/network/smap/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <errno.h>
#endif
#include <stdio.h>
#include <defs.h>
#ifdef BUILDING_SMAP_PS2IP
#include <sysclib.h>
#endif
Expand Down Expand Up @@ -274,7 +275,7 @@ extern struct irx_export_table _exp_smap __attribute__((section("data")));
#endif

#ifdef BUILDING_SMAP_MODULAR
extern struct irx_export_table _exp_smapmodu;
extern struct irx_export_table _exp_smapmodu __attribute__((section("data")));
#endif

int _start(int argc, char *argv[])
Expand Down
1 change: 1 addition & 0 deletions iop/network/smap/src/smap.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <errno.h>
#include <stdio.h>
#include <defs.h>
#include <dmacman.h>
#include <dev9.h>
#include <intrman.h>
Expand Down
1 change: 1 addition & 0 deletions iop/usb/usbd/src/usbdpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "usbd.h"
#include "types.h"
#include "defs.h"

#define OHCI_REG_BASE 0xBF801600

Expand Down

0 comments on commit 2e2b277

Please sign in to comment.