Skip to content

Commit

Permalink
Merge pull request #160 from rickgaiser/for-ps2dev
Browse files Browse the repository at this point in the history
GCC10 required updates
  • Loading branch information
fjtrujy authored Jan 8, 2021
2 parents e70ff12 + 1f478e9 commit 2120771
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Compile project
run: |
make clean all install
ln -sf "$PS2SDK/ee/lib/libps2sdkc.a" "$PS2DEV/ee/ee/lib/libps2sdkc.a"
ln -sf "$PS2SDK/ee/lib/libkernel.a" "$PS2DEV/ee/ee/lib/libkernel.a"
ln -sf "$PS2SDK/ee/lib/libps2sdkc.a" "$PS2DEV/ee/mips64r5900el-ps2-elf/lib/libps2sdkc.a"
ln -sf "$PS2SDK/ee/lib/libkernel.a" "$PS2DEV/ee/mips64r5900el-ps2-elf/lib/libkernel.a"
- name: Compile samples
if: ${{ success() }}
Expand Down
2 changes: 1 addition & 1 deletion Defs.make
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Definitions for the EE toolchain.
#

EE_TOOL_PREFIX ?= ee-
EE_TOOL_PREFIX ?= mips64r5900el-ps2-elf-
EE_CC = $(EE_TOOL_PREFIX)gcc
EE_CXX = $(EE_TOOL_PREFIX)g++
EE_AS = $(EE_TOOL_PREFIX)as
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ COPY . /src

RUN apk add build-base
RUN cd /src && make all install clean
RUN ln -sf "$PS2SDK/ee/lib/libps2sdkc.a" "$PS2DEV/ee/ee/lib/libps2sdkc.a"
RUN ln -sf "$PS2SDK/ee/lib/libkernel.a" "$PS2DEV/ee/ee/lib/libkernel.a"
RUN ln -sf "$PS2SDK/ee/lib/libps2sdkc.a" "$PS2DEV/ee/mips64r5900el-ps2-elf/lib/libps2sdkc.a"
RUN ln -sf "$PS2SDK/ee/lib/libkernel.a" "$PS2DEV/ee/mips64r5900el-ps2-elf/lib/libkernel.a"

# Second stage of Dockerfile
FROM alpine:latest
Expand Down
4 changes: 1 addition & 3 deletions common/sbus/src/sif2cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ This file contains all common code for both EE and IOP SIF management.
#define SIF2_XFER_RECV (0)
#define SIF2_XFER_SEND (1)

extern int sio_printf(const char *format, ...);

static u32 _sif2_req_type = 0;
static u32 _sif2_req_addr = 0;
static u32 _sif2_req_size = 0;
Expand Down Expand Up @@ -107,7 +105,7 @@ void _sif2_irq_exec(void)
else
{
#ifdef _EE
sio_printf("unknown command: %d!\n", cid);
//printf("unknown command: %d!\n", cid);
#endif
}
}
Expand Down
6 changes: 3 additions & 3 deletions common/tcpip/lwip-2.0.0/src/core/pbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ struct pbuf*
pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
{
struct pbuf *q;
err_t err;
//err_t err;
if (p->next == NULL) {
return p;
}
Expand All @@ -1243,8 +1243,8 @@ pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
/* @todo: what do we do now? */
return p;
}
err = pbuf_copy(q, p);
LWIP_ASSERT("pbuf_copy failed", err == ERR_OK);
/*err =*/ pbuf_copy(q, p);
//LWIP_ASSERT("pbuf_copy failed", err == ERR_OK);
pbuf_free(p);
return q;
}
Expand Down
4 changes: 2 additions & 2 deletions ee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

SUBDIRS = erl kernel kernel-nopatch libc rpc debug \
SUBDIRS = erl kernel kernel-nopatch libc rpc startup debug \
eedebug sbv dma graph math3d \
packet packet2 draw erl-loader mpeg libgs \
packet packet2 draw libgs \
libvux font input inputx network iopreboot \
elf-loader

Expand Down
46 changes: 23 additions & 23 deletions ee/debug/src/callstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,36 +199,36 @@ void ps2GetStackTrace(unsigned int* results,int max)
}
else if (inst == RETURN)
ra_limit = ra + 2;
ra++;
ra++;
}

if (sp_adjust == 0 && (found_const_upper || found_const_lower))
sp_adjust = (const_upper << 16) | const_lower;
rc->raOffset = ra_offset;
rc->spAdjust = sp_adjust;
}
/* if something went wrong, punt */
if (rc->spAdjust <= 0)
{
*results++ = 0;
break;
}
rc->raOffset = ra_offset;
rc->spAdjust = sp_adjust;
}
/* if something went wrong, punt */
if (rc->spAdjust <= 0)
{
*results++ = 0;
break;
}

ra = (unsigned int *) sp[rc->raOffset>>2];
sp += rc->spAdjust >> 2;
ra = (unsigned int *) sp[rc->raOffset>>2];
sp += rc->spAdjust >> 2;

if (ra == 0)
{
*results++ = 0;
break;
}
if (ra == 0)
{
*results++ = 0;
break;
}

*results++ = ((unsigned int) ra) - 8;
if (ra[-2] == mainCall)
{
*results++ = 0;
break;
}
*results++ = ((unsigned int) ra) - 8;
if (ra[-2] == mainCall)
{
*results++ = 0;
break;
}
max--;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ee/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GLUE_OBJS += SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o
### SIO objects

SIO_OBJS = sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o \
sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o sio_printf.o
sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o

### Config objects

Expand Down Expand Up @@ -155,7 +155,7 @@ KERNEL_OBJS = ResetEE.o SetGsCrt.o $(EXEC_SYSCALLS) \
SifGetReg.o $(EXECOSD_SYSCALL) Deci2Call.o PSMode.o MachineType.o GetMemorySize.o _GetGsDxDyOffset.o \
_InitTLB.o SetMemoryMode.o \
SifWriteBackDCache.o _SyncDCache.o _InvalidDCache.o __errno.o errno.o \
strncpy.o strlen.o memcpy.o memset.o __syscall.o
strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o

EE_OBJS = $(KERNEL_OBJS) $(SIFCMD_OBJS) $(SIFRPC_OBJS) $(FILEIO_OBJS) \
$(LOADFILE_OBJS) $(IOPHEAP_OBJS) $(IOPCONTROL_OBJS) $(CONFIG_OBJS) \
Expand Down
37 changes: 4 additions & 33 deletions ee/kernel/include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,14 @@

#define ALIGNED(x) __attribute__((aligned((x))))

// GP macros
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");
}
// GP functions
void *ChangeGP(void *gp);
void SetGP(void *gp);
void *GetGP(void);

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

static __inline__ void *GetGP(void)
{
void *gp;

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

return gp;
}

/** Special thread ID for referring to the running thread.
Unlike the IOP kernel, this is only supported by ReferThreadStatus() and ChangeThreadPriority().
It can also be used by the iWakeupThread() _syscall_.
Expand Down
3 changes: 0 additions & 3 deletions ee/kernel/include/sio.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ char *sio_gets(char *str);
/** Flushes the input buffer. */
void sio_flush(void);

/** standard printf function to sio */
int sio_printf(const char *format, ...);

#ifdef __cplusplus
}
#endif
Expand Down
26 changes: 26 additions & 0 deletions ee/kernel/src/kernel.S
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,32 @@ SYSCALL(_InitTLB)
SYSCALL(SetMemoryMode)
#endif

#ifdef F_GPfuncs
.text
.align 2
.globl ChangeGP
.ent ChangeGP
ChangeGP:
move $v0, $gp
jr $ra
move $gp, $a0
.end ChangeGP

.globl SetGP
.ent SetGP
SetGP:
jr $ra
move $gp, $a0
.end SetGP

.globl GetGP
.ent GetGP
GetGP:
jr $ra
move $v0, $gp
.end GetGP
#endif

#ifdef F_SifWriteBackDCache

.globl SifWriteBackDCache
Expand Down
2 changes: 1 addition & 1 deletion ee/kernel/src/osdsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EE_OSDSRC_ELF := $(EE_OSDSRC_ELF:%=$(EE_BIN_DIR)%)
EE_OBJS = osdsrc.o osd.o ExecPS2.o

EE_INCS += -I$(PS2SDKSRC)/ee/rpc/cdvd/include
EE_CFLAGS += -mno-gpopt -DREUSE_EXECPS2
EE_CFLAGS += -mno-gpopt -DREUSE_EXECPS2 -fno-tree-loop-distribute-patterns

$(EE_OSDSRC_BIN): $(EE_OSDSRC_ELF)
$(EE_OBJCOPY) -Obinary $< $@
Expand Down
18 changes: 0 additions & 18 deletions ee/kernel/src/sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,3 @@ void sio_flush()
_lb(SIO_RXFIFO);
}
#endif

#ifdef F_sio_printf
#define SIO_PRINTF_STR_MAX 4096
int sio_printf(const char *format, ...)
{
static char buf[SIO_PRINTF_STR_MAX];
va_list args;
int size;

va_start(args, format);
size = vsnprintf(buf, PS2LIB_STR_MAX, format, args);
va_end(args);

sio_write(buf, size);

return size;
}
#endif
2 changes: 1 addition & 1 deletion ee/kernel/src/srcfile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EE_SRCFILE_ELF = srcfile.elf
EE_SRCFILE_ELF := $(EE_SRCFILE_ELF:%=$(EE_BIN_DIR)%)
EE_OBJS = srcfile.o alarm.o dispatch.o

EE_CFLAGS += -mno-gpopt
EE_CFLAGS += -mno-gpopt -fno-tree-loop-distribute-patterns

$(EE_SRCFILE_BIN): $(EE_SRCFILE_ELF)
$(EE_OBJCOPY) -Obinary $< $@
Expand Down
24 changes: 23 additions & 1 deletion ee/kernel/src/srcfile/src/dispatch.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ InvokeUserModeCallback:
daddu $v1, $zero, $a1
daddu $a0, $zero, $a2
daddu $a1, $zero, $a3
daddu $a2, $zero, $t0
daddu $a2, $zero, $a4
mfc0 $k0, $12
ori $k0, $k0, 0x12
mtc0 $k0, $12
Expand All @@ -42,6 +42,28 @@ ResumeIntrDispatch:
lw $sp, %lo(dispatch_sp)($k0)
.end ResumeIntrDispatch

.globl ChangeGP
.ent ChangeGP
ChangeGP:
move $v0, $gp
jr $ra
move $gp, $a0
.end ChangeGP

.globl SetGP
.ent SetGP
SetGP:
jr $ra
move $gp, $a0
.end SetGP

.globl GetGP
.ent GetGP
GetGP:
jr $ra
move $v0, $gp
.end GetGP

.data
dispatch_ra: .quad 0
dispatch_sp: .quad 0
2 changes: 1 addition & 1 deletion ee/libc/include/ps2sdkapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern int (*_ps2sdk_close)(int);
extern int (*_ps2sdk_open)(const char*, int, ...);
extern int (*_ps2sdk_read)(int, void*, int);
extern int (*_ps2sdk_lseek)(int, int, int);
extern long (*_ps2sdk_lseek64)(int, long, int);
extern int64_t (*_ps2sdk_lseek64)(int, int64_t, int);
extern int (*_ps2sdk_write)(int, const void*, int);
extern int (*_ps2sdk_ioctl)(int, int, void*);
extern int (*_ps2sdk_remove)(const char*);
Expand Down
Loading

0 comments on commit 2120771

Please sign in to comment.