diff --git a/Makefile b/Makefile index c7e6122..60d3152 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ CC_OLD = tools/ido_recomp/linux/5.3/cc ASFLAGS = -EB -mtune=vr4300 -march=vr4300 -Iinclude # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Wab,-r4300_mul -D _LANGUAGE_C -woff 649,838,712 -mips2 +CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Wab,-r4300_mul -D _LANGUAGE_C -D F3DEX_GBI -woff 649,838,712 -mips2 LDFLAGS = -T undefined_syms.txt -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/$(TARGET).map --no-check-sections @@ -60,6 +60,7 @@ build/src/libultra/os/osSendMesg.c.o: OPTFLAGS := -O1 build/src/libultra/os/osStopThread.c.o: OPTFLAGS := -O1 build/src/libultra/os/osRecvMesg.c.o: OPTFLAGS := -O1 build/src/libultra/io/pigetcmdq.c.o: OPTFLAGS := -O1 +build/src/libultra/io/sptask.c.o: OPTFLAGS := -O1 default: all diff --git a/include/PR/rcp.h b/include/PR/rcp.h index 3795ff7..1cc898b 100644 --- a/include/PR/rcp.h +++ b/include/PR/rcp.h @@ -1,6 +1,10 @@ #ifndef _RCP_H_ #define _RCP_H_ +#ifdef _LANGUAGE_C +#define HW_REG(reg, type) *(volatile type*)((reg) | 0xA0000000) +#endif + /************************************************************************** * * * Copyright (C) 1995, Silicon Graphics, Inc. * @@ -600,7 +604,6 @@ The Indy development board use cartridge domain 1: #define VI_PAL_CLOCK 49656530 /* Hz = 49.656530 MHz */ #define VI_MPAL_CLOCK 48628316 /* Hz = 48.628316 MHz */ - /************************************************************************* * Audio Interface (AI) Registers * diff --git a/splat.yaml b/splat.yaml index 39f536b..61d00ef 100644 --- a/splat.yaml +++ b/splat.yaml @@ -166,7 +166,7 @@ segments: - [0x578F0, asm, libultra/gu/scale] - [0x57990, asm, libultra/gu/sinf] - [0x57B50, asm, libultra/al/sl] - - [0x57C10, asm, libultra/io/sptask] + - [0x57C10, c, libultra/io/sptask] - [0x57F00, asm, libultra/os/destroythread] - [0x58010, asm, libultra/libc/ll] - [0x582D0, asm, libultra/os/exceptasm] diff --git a/src/libultra/io/sptask.c b/src/libultra/io/sptask.c new file mode 100644 index 0000000..a0ebde9 --- /dev/null +++ b/src/libultra/io/sptask.c @@ -0,0 +1,60 @@ +#include + +#define _osVirtualToPhysical(ptr) \ + if (ptr != NULL) { \ + ptr = (void*)osVirtualToPhysical(ptr); \ + } + +extern OSTask sTmpTask; + +OSTask* _VirtualToPhysicalTask(OSTask* intp) { + OSTask* tp = &sTmpTask; + + _bcopy(intp, tp, sizeof(OSTask)); + + _osVirtualToPhysical(tp->t.ucode); + _osVirtualToPhysical(tp->t.ucode_data); + _osVirtualToPhysical(tp->t.dram_stack); + _osVirtualToPhysical(tp->t.output_buff); + _osVirtualToPhysical(tp->t.output_buff_size); + _osVirtualToPhysical(tp->t.data_ptr); + _osVirtualToPhysical(tp->t.yield_data_ptr); + + return tp; +} + +void osSpTaskLoad(OSTask* intp) { + OSTask* tp = _VirtualToPhysicalTask(intp); + + if (tp->t.flags & OS_TASK_YIELDED) { + tp->t.ucode_data = tp->t.yield_data_ptr; + tp->t.ucode_data_size = tp->t.yield_data_size; + intp->t.flags &= ~OS_TASK_YIELDED; + + if (tp->t.flags & OS_TASK_LOADABLE) { + tp->t.ucode = (u64*)HW_REG((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4, u32); + } + } + osWritebackDCache(tp, sizeof(OSTask)); + __osSpSetStatus(SP_CLR_SIG0 | SP_CLR_SIG1 | SP_CLR_SIG2 | SP_SET_INTR_BREAK); + + while (__osSpSetPc((void*)SP_IMEM_START) == -1) { + ; + } + while (__osSpRawStartDma(OS_WRITE, (void*)(SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) { + ; + } + while (__osSpDeviceBusy()) { + ; + } + while (__osSpRawStartDma(OS_WRITE, (void*)SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) { + ; + } +} + +void osSpTaskStartGo(OSTask* tp) { + while (__osSpDeviceBusy()) { + ; + } + __osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT); +} diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index b373b6f..db78df6 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -282,4 +282,8 @@ _timeToSamples = 0x8005FBDC; alUnlink = 0x80056F50; alLink = 0x80056F80; alClose = 0x80056FA4; -alInit = 0x80056FDC; \ No newline at end of file +alInit = 0x80056FDC; +_VirtualToPhysicalTask = 0x80057010; +osSpTaskLoad = 0x8005712C; +osSpTaskStartGo = 0x800572BC; +sTmpTask = 0x80102100; \ No newline at end of file