Skip to content

Commit

Permalink
Added alarm-management function patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
sp193 committed Jun 27, 2017
1 parent bb6b792 commit 4884b1f
Show file tree
Hide file tree
Showing 15 changed files with 541 additions and 7 deletions.
28 changes: 25 additions & 3 deletions ee/kernel/Makefile
Expand Up @@ -51,6 +51,8 @@ LIBOSD_OBJS = libosd.o libosd_full.o libosd_common.o osdsrc_bin.o

TLBFUNC_OBJS = tlbfunc.o tlbsrc_bin.o

ALARM_OBJS = alarm.o srcfile_bin.o eenull_bin.o

TIMER_OBJS = cpu_ticks.o

GETKERNEL_OBJS = GetSyscallHandler.o GetSyscall.o GetExceptionHandler.o GetInterruptHandler.o
Expand All @@ -66,8 +68,8 @@ KERNEL_OBJS = ResetEE.o SetGsCrt.o Exit.o LoadExecPS2.o ExecPS2.o \
SetVTLBRefillHandler.o SetVCommonHandler.o SetVInterruptHandler.o \
AddIntcHandler.o AddIntcHandler2.o RemoveIntcHandler.o AddDmacHandler.o AddDmacHandler2.o \
RemoveDmacHandler.o _EnableIntc.o _DisableIntc.o _EnableDmac.o _DisableDmac.o \
SetAlarm.o ReleaseAlarm.o _iEnableIntc.o _iDisableIntc.o _iEnableDmac.o \
_iDisableDmac.o iSetAlarm.o iReleaseAlarm.o CreateThread.o DeleteThread.o \
_SetAlarm.o SetAlarm.o _ReleaseAlarm.o ReleaseAlarm.o _iEnableIntc.o _iDisableIntc.o _iEnableDmac.o \
_iDisableDmac.o _iSetAlarm.o iSetAlarm.o _iReleaseAlarm.o iReleaseAlarm.o CreateThread.o DeleteThread.o \
StartThread.o ExitThread.o ExitDeleteThread.o TerminateThread.o \
iTerminateThread.o DisableDispatchThread.o EnableDispatchThread.o \
ChangeThreadPriority.o iChangeThreadPriority.o RotateThreadReadyQueue.o \
Expand Down Expand Up @@ -97,7 +99,7 @@ KERNEL_OBJS = ResetEE.o SetGsCrt.o Exit.o LoadExecPS2.o ExecPS2.o \
EE_OBJS = $(KERNEL_OBJS) $(SIFCMD_OBJS) $(SIFRPC_OBJS) $(FILEIO_OBJS) \
$(LOADFILE_OBJS) $(IOPHEAP_OBJS) $(IOPCONTROL_OBJS) $(CONFIG_OBJS) \
$(GLUE_OBJS) $(SIO_OBJS) $(TIMER_OBJS) $(GETKERNEL_OBJS) $(LIBOSD_OBJS) \
$(TLBFUNC_OBJS) $(SETUP_OBJS) $(INITSYS_OBJS) erl-support.o
$(TLBFUNC_OBJS) $(ALARM_OBJS) $(SETUP_OBJS) $(INITSYS_OBJS) erl-support.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/ee/Rules.lib.make
Expand Down Expand Up @@ -161,6 +163,12 @@ $(EE_OBJS_DIR)tibfunc.o: $(EE_SRC_DIR)tlbfunc.c
$(EE_OBJS_DIR)tlbsrc_bin.o: $(EE_OBJS_DIR)tlbsrc_bin.c
$(EE_C_COMPILE) $< -c -o $@

$(EE_OBJS_DIR)srcfile_bin.o: $(EE_OBJS_DIR)srcfile_bin.c
$(EE_C_COMPILE) $< -c -o $@

$(EE_OBJS_DIR)eenull_bin.o: $(EE_OBJS_DIR)eenull_bin.c
$(EE_C_COMPILE) $< -c -o $@

$(PS2SDKSRC)/tools/bin2c/bin/bin2c: $(PS2SDKSRC)/tools/bin2c
make -C $<

Expand All @@ -176,6 +184,20 @@ $(EE_SRC_DIR)tlbsrc/bin/tlbsrc.bin: $(EE_SRC_DIR)tlbsrc
$(EE_OBJS_DIR)tlbsrc_bin.c: $(EE_SRC_DIR)tlbsrc/bin/tlbsrc.bin $(PS2SDKSRC)/tools/bin2c/bin/bin2c
$(PS2SDKSRC)/tools/bin2c/bin/bin2c $< $@ tlbsrc

$(EE_SRC_DIR)srcfile/bin/srcfile.bin: $(EE_SRC_DIR)srcfile
make -C $<

$(EE_OBJS_DIR)srcfile_bin.c: $(EE_SRC_DIR)srcfile/bin/srcfile.bin $(PS2SDKSRC)/tools/bin2c/bin/bin2c
$(PS2SDKSRC)/tools/bin2c/bin/bin2c $< $@ srcfile

$(EE_SRC_DIR)eenull/bin/eenull.bin: $(EE_SRC_DIR)eenull
make -C $<

$(EE_OBJS_DIR)eenull_bin.c: $(EE_SRC_DIR)eenull/bin/eenull.bin $(PS2SDKSRC)/tools/bin2c/bin/bin2c
$(PS2SDKSRC)/tools/bin2c/bin/bin2c $< $@ eenull

clean::
make -C $(EE_SRC_DIR)osdsrc clean
make -C $(EE_SRC_DIR)tlbsrc clean
make -C $(EE_SRC_DIR)srcfile clean
make -C $(EE_SRC_DIR)eenull clean
1 change: 1 addition & 0 deletions ee/kernel/include/alarm.h
@@ -0,0 +1 @@
void InitAlarm(void);
14 changes: 10 additions & 4 deletions ee/kernel/include/syscallnr.h
Expand Up @@ -7,8 +7,10 @@
#define __NR_ResetEE 1
#define __NR_SetGsCrt 2
#define __NR_Exit 4
#define __NR_ResumeIntrDispatch 5 //Arbitrarily named
#define __NR_LoadExecPS2 6
#define __NR_ExecPS2 7
#define __NR_ResumeT3IntrDispatch 8 //Arbitrarily named (used by alarm update)
#define __NR_RFU009 9
#define __NR_AddSbusIntcHandler 0xa
#define __NR_RemoveSbusIntcHandler 0xb
Expand All @@ -26,14 +28,18 @@
#define __NR__DisableIntc 0x15
#define __NR__EnableDmac 0x16
#define __NR__DisableDmac 0x17
#define __NR_SetAlarm 0x18
#define __NR_ReleaseAlarm 0x19
#define __NR__SetAlarm 0x18
#define __NR__ReleaseAlarm 0x19
#define __NR_SetAlarm 0xfc
#define __NR_ReleaseAlarm 0xfe
#define __NR__iEnableIntc (-0x1a)
#define __NR__iDisableIntc (-0x1b)
#define __NR__iEnableDmac (-0x1c)
#define __NR__iDisableDmac (-0x1d)
#define __NR_iSetAlarm (-0x1e)
#define __NR_iReleaseAlarm (-0x1f)
#define __NR__iSetAlarm (-0x1e)
#define __NR__iReleaseAlarm (-0x1f)
#define __NR_iSetAlarm (-0xfd)
#define __NR_iReleaseAlarm (-0xff)
#define __NR_CreateThread 0x20
#define __NR_DeleteThread 0x21
#define __NR_StartThread 0x22
Expand Down
48 changes: 48 additions & 0 deletions ee/kernel/src/alarm.c
@@ -0,0 +1,48 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

#include <kernel.h>
#include <stdio.h>

struct SyscallData{
int syscall;
void *function;
};

static const struct SyscallData SysEntry[]={
{0x5A, &kCopy},
{0x5B, (void*)0x80076000},
{0xFC, NULL}, //SetAlarm
{0xFD, NULL}, //iSetAlarm
{0xFE, NULL}, //ReleaseAlarm
{0xFF, NULL}, //iReleaseAlarm
{0x12C, NULL}, //Intc12Handler (overwrites INTC 12 handler entry)
{0x08, NULL}, //ResumeIntrDispatch (Syscall #8)
};

extern unsigned char srcfile[];
extern unsigned int size_srcfile;

extern unsigned char eenull[];
extern unsigned int size_eenull;

void InitAlarm(void)
{
int i;

setup(SysEntry[0].syscall, SysEntry[0].function);
Copy((void*)0x80076000, srcfile, size_srcfile);
Copy((void*)0x00082000, eenull, size_eenull);
FlushCache(0);
FlushCache(2);
setup(SysEntry[1].syscall, SysEntry[1].function);

for(i=2; i<8; i++)
setup(SysEntry[i].syscall, GetEntryAddress(SysEntry[i].syscall));
}
29 changes: 29 additions & 0 deletions ee/kernel/src/eenull/Makefile
@@ -0,0 +1,29 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

EE_BIN_DIR = bin/
EE_OBJS_DIR = obj/

EE_EENULL_BIN = eenull.bin
EE_EENULL_BIN := $(EE_EENULL_BIN:%=$(EE_BIN_DIR)%)
EE_EENULL_ELF = eenull.elf
EE_EENULL_ELF := $(EE_EENULL_ELF:%=$(EE_BIN_DIR)%)
EE_OBJS = eenull.o

EE_CFLAGS += -mno-gpopt

$(EE_EENULL_BIN): $(EE_EENULL_ELF)
$(EE_OBJCOPY) -Obinary $< $@

clean:
rm -f -r $(EE_OBJS_DIR) $(EE_BIN_DIR)

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/ee/Rules.make

$(EE_EENULL_ELF): $(EE_OBJS) | $(EE_BIN_DIR)
$(EE_CC) $(EE_CFLAGS) -o $@ $^ -nostartfiles -Tlinkfile -s $(EE_LIBS)
27 changes: 27 additions & 0 deletions ee/kernel/src/eenull/linkfile
@@ -0,0 +1,27 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

ENTRY(UModeCallbackDispatcher);

SECTIONS {
.text 0x00082000: {
_ftext = . ;
*(.text)
*(.text.*)
*(.gnu.linkonce.t*)
QUAD(0)
}

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
}
}
21 changes: 21 additions & 0 deletions ee/kernel/src/eenull/src/eenull.s
@@ -0,0 +1,21 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

.set noreorder

#Will be executed in user mode, but with interrupts disabled.
#Set stack address to 0x00081fc0
.globl UModeCallbackDispatcher
.ent UModeCallbackDispatcher
UModeCallbackDispatcher:
lui $sp, 0x0008
jalr $v1
addiu $sp, $sp, 0x1fc0
addiu $v1, $zero, -8
syscall
.end UModeCallbackDispatcher
.p2align 4
2 changes: 2 additions & 0 deletions ee/kernel/src/initsys.c
Expand Up @@ -8,11 +8,13 @@
*/

#include "kernel.h"
#include "alarm.h"
#include "libosd.h"
#include "tlbfunc.h"

void _InitSys(void)
{
InitAlarm();
InitThread();
InitExecPS2();
InitTLBFunctions();
Expand Down
16 changes: 16 additions & 0 deletions ee/kernel/src/kernel.S
Expand Up @@ -174,10 +174,18 @@ SYSCALL(_EnableDmac)
SYSCALL(_DisableDmac)
#endif

#ifdef F__SetAlarm
SYSCALL(_SetAlarm)
#endif

#ifdef F_SetAlarm
SYSCALL(SetAlarm)
#endif

#ifdef F__ReleaseAlarm
SYSCALL(_ReleaseAlarm)
#endif

#ifdef F_ReleaseAlarm
SYSCALL(ReleaseAlarm)
#endif
Expand All @@ -198,10 +206,18 @@ SYSCALL(_iEnableDmac)
SYSCALL(_iDisableDmac)
#endif

#ifdef F__iSetAlarm
SYSCALL(_iSetAlarm)
#endif

#ifdef F_iSetAlarm
SYSCALL(iSetAlarm)
#endif

#ifdef F__iReleaseAlarm
SYSCALL(_iReleaseAlarm)
#endif

#ifdef F_iReleaseAlarm
SYSCALL(iReleaseAlarm)
#endif
Expand Down
29 changes: 29 additions & 0 deletions ee/kernel/src/srcfile/Makefile
@@ -0,0 +1,29 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

EE_BIN_DIR = bin/
EE_OBJS_DIR = obj/

EE_SRCFILE_BIN = srcfile.bin
EE_SRCFILE_BIN := $(EE_SRCFILE_BIN:%=$(EE_BIN_DIR)%)
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_SRCFILE_BIN): $(EE_SRCFILE_ELF)
$(EE_OBJCOPY) -Obinary $< $@

clean:
rm -f -r $(EE_OBJS_DIR) $(EE_BIN_DIR)

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/ee/Rules.make

$(EE_SRCFILE_ELF): $(EE_OBJS) | $(EE_BIN_DIR)
$(EE_CC) $(EE_CFLAGS) -o $@ $^ -nostartfiles -Tlinkfile -s $(EE_LIBS)
27 changes: 27 additions & 0 deletions ee/kernel/src/srcfile/linkfile
@@ -0,0 +1,27 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

ENTRY(_start);

SECTIONS {
.text 0x80076000: {
_ftext = . ;
*(.text)
*(.text.*)
*(.gnu.linkonce.t*)
QUAD(0)
}

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
}
}

0 comments on commit 4884b1f

Please sign in to comment.