diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml new file mode 100644 index 0000000..1f91adf --- /dev/null +++ b/.github/workflows/compilation.yml @@ -0,0 +1,72 @@ +name: CI-compile + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + container: ps2dev/ps2dev:v1.0 + # instead of "ps2dev/ps2dev:latest" you can use different tags, for example for old projects you can use "ps2dev/ps2dev:v1.0" + steps: + - name: Install dependencies + run: | + apk add build-base git zip + + - uses: actions/checkout@v2 + - run: | + git fetch --prune --unshallow + + - name: Get short SHA and repository name + id: slug + run: | + echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + echo "::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" + + - name: Compile osd + run: | + make -C osd + ls -l osd + # zip HDDChecker-${{ steps.slug.outputs.sha8 }}.zip HDDChecker.elf lang/* + + - name: Compile kpatch + run: | + make -C kpatch/patch0100 + make -C kpatch/patch0101 + ls -l kpatch/patch0100 + ls -l kpatch/patch0101 + + - name: Upload artifacts + if: ${{ success() }} + uses: actions/upload-artifact@v2 + with: + path: | + osd/example.elf + kpatch/patch0100/osdsys.elf + kpatch/patch0101/osd110.elf + + - name: Create pre-release + if: github.ref == 'refs/heads/main' + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: true + automatic_release_tag: "latest" + title: "Development build" + files: | + osd/example.elf + kpatch/patch0100/osdsys.elf + kpatch/patch0101/osd110.elf + + - name: Create Tagged Release Draft + if: startsWith(github.ref, 'refs/tags/v') + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + draft: true + files: | + osd/example.elf + kpatch/patch0100/osdsys.elf + kpatch/patch0101/osd110.elf diff --git a/kpatch/Rules.patch.make b/kpatch/Rules.patch.make index 0e6c9ba..a1dbded 100644 --- a/kpatch/Rules.patch.make +++ b/kpatch/Rules.patch.make @@ -53,5 +53,5 @@ $(EE_BIN) : $(EE_OBJS) -o $(EE_BIN) $(EE_CRT0_OBJ) $(EE_OBJS) $(EE_LDFLAGS) $(EE_LIBS) $(EE_STRIP) -s -d -R .mdebug.eabi64 -R .reginfo -R .comment $(EE_BIN) -clean:: +clean: rm -f $(EE_BIN) $(EE_OBJS) $(MAPFILE) diff --git a/kpatch/crt0-eeload.s b/kpatch/crt0-eeload.s new file mode 100644 index 0000000..a86974d --- /dev/null +++ b/kpatch/crt0-eeload.s @@ -0,0 +1,94 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright (c) 2001-2007 ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +# +# Modified startup file for MBR EELOAD +# Removed libc initialization, support for C++ and kernel patches. + + .extern _heap_size + .extern _stack + .extern _stack_size + + .extern Exit + .extern FlushCache + + .set noat + .set noreorder + + .section .start + .align 2 + + .globl _start + .ent _start +_start: + +zerobss: + # clear bss area + + la $2, _fbss + la $3, _end + +1: + sltu $1, $2, $3 + beq $1, $0, 2f + nop + sq $0, ($2) + addiu $2, $2, 16 + j 1b + nop +2: + +setupthread: + # setup current thread + + la $4, _gp + la $5, _stack + la $6, _stack_size + la $7, _args + la $8, _root + move $gp, $4 + addiu $3, $0, 60 + syscall # SetupThread(_gp, _stack, _stack_size, _args, _root) + move $sp, $2 + + # initialize heap + + la $4, _end + la $5, _heap_size + addiu $3, $0, 61 + syscall # SetupHeap(_end, _heap_size) + + # writeback data cache + jal FlushCache # FlushCache(0) + move $4, $0 + + # call main + ei + + la $16, _args + lw $4, ($16) + jal main # main(argc, argv) + addiu $5, $16, 4 + + # call _exit + + j Exit # Exit(retval) (noreturn) + move $4, $2 + .end _start + + .align 3 + + .ent _root +_root: + addiu $3, $0, 35 + syscall # ExitThread() (noreturn) + .end _root + + .bss + .align 6 +_args: + .space 4+16*4+256 # argc, 16 arguments, 256 bytes payload diff --git a/kpatch/patch0100/EELOAD/EELOAD.c b/kpatch/patch0100/EELOAD/EELOAD.c index 08e267b..2042796 100644 --- a/kpatch/patch0100/EELOAD/EELOAD.c +++ b/kpatch/patch0100/EELOAD/EELOAD.c @@ -110,11 +110,11 @@ static void PatchOSDSYS(void) /* 0x000821d0 */ static void SyncSIF0(void) { - int i; - // If SIF0 has incoming data, initialize SIF0 and acknowledge incoming data. if (*DMA_REG_STAT & 0x20) { + int i; + SifSetDChain(); // Re-initialize SIF0 (IOP -> EE) *DMA_REG_STAT = 0x20; while (*R_EE_SBUS_REG40 & 0x3000) {}; @@ -198,7 +198,6 @@ static void BootError(const char *path) /* 0x00082440 */ int main(int argc, char *argv[]) { - const char *CommandString; int i; if (argc >= 2) @@ -219,6 +218,7 @@ int main(int argc, char *argv[]) while (argc > 0) { + const char *CommandString; if ((CommandString = IsSwitchCheck("-m ", argv[0])) != NULL) { SifLoadModule(CommandString, 0, NULL); diff --git a/kpatch/patch0101/EELOAD/EELOAD.c b/kpatch/patch0101/EELOAD/EELOAD.c index 59ca225..65b95f0 100644 --- a/kpatch/patch0101/EELOAD/EELOAD.c +++ b/kpatch/patch0101/EELOAD/EELOAD.c @@ -109,11 +109,11 @@ static void PatchOSDSYS(void) /* 0x00082180 */ static void SyncSIF0(void) { - int i; - // If SIF0 has incoming data, initialize SIF0 and acknowledge incoming data. if (*DMA_REG_STAT & 0x20) { + int i; + SifSetDChain(); // Re-initialize SIF0 (IOP -> EE) *DMA_REG_STAT = 0x20; while (*R_EE_SBUS_REG40 & 0x3000) {}; @@ -197,7 +197,6 @@ static void BootError(const char *path) // 0x000823d8 int main(int argc, char *argv[]) { - const char *CommandString; int i; if (argc >= 2) @@ -217,6 +216,7 @@ int main(int argc, char *argv[]) while (argc > 0) { + const char *CommandString; if ((CommandString = IsSwitchCheck("-m ", argv[0])) != NULL) { SifLoadModule(CommandString, 0, NULL); diff --git a/osd/common/OSDHistory.c b/osd/common/OSDHistory.c index c885929..9057fd8 100644 --- a/osd/common/OSDHistory.c +++ b/osd/common/OSDHistory.c @@ -284,10 +284,9 @@ static u16 GetTimestamp(void) static void AddHistoryRecord(const char *name) { - struct HistoryEntry *NewEntry; int i, value, LeastUsedRecord, LeastUsedRecordLaunchCount, LeastUsedRecordTimestamp, NewLaunchCount; u8 BlankSlotList[MAX_HISTORY_ENTRIES]; - int NumBlankSlots, NumSlotsUsed, IsNewRecord; + int IsNewRecord; LeastUsedRecord = 0; LeastUsedRecordTimestamp = INT_MAX; @@ -360,8 +359,7 @@ static void AddHistoryRecord(const char *name) if (IsNewRecord) { // Count and consolidate a list of blank slots. - NumBlankSlots = 0; - NumSlotsUsed = 0; + int NumBlankSlots = 0, NumSlotsUsed = 0; for (i = 0; i < MAX_HISTORY_ENTRIES; i++) { if (HistoryEntries[i].name[0] == '\0') @@ -378,6 +376,7 @@ static void AddHistoryRecord(const char *name) if (NumSlotsUsed != MAX_HISTORY_ENTRIES) { + struct HistoryEntry *NewEntry; if (NumBlankSlots > 0) { // Randomly choose an empty slot. NewEntry = &HistoryEntries[BlankSlotList[rand() % NumBlankSlots]]; diff --git a/osd/common/OSDInit.c b/osd/common/OSDInit.c index afbe6e8..9b3c9ca 100644 --- a/osd/common/OSDInit.c +++ b/osd/common/OSDInit.c @@ -53,10 +53,10 @@ char ConsoleROMVER[ROMVER_MAX_LEN]; static int InitMGRegion(void) { u32 stat; - int result; if (ConsoleRegionParamInitStatus == 0) { + int result; do { if ((result = sceCdReadRegionParams(ConsoleRegionData, &stat)) == 0) @@ -85,9 +85,9 @@ static int InitMGRegion(void) void OSDInitSystemPaths(void) { int region; - char regions[CONSOLE_REGION_COUNT] = {'I', 'A', 'E', 'C'}; + const char regions[CONSOLE_REGION_COUNT] = {'I', 'A', 'E', 'C'}; - region = OSDGetConsoleRegion(); + region = OSDGetConsoleRegion(); if (region >= 0 && region < CONSOLE_REGION_COUNT) { SystemDataFolder[1] = regions[region]; @@ -170,13 +170,14 @@ int OSDGetDVDPlayerRegion(char *region) static int GetConsoleRegion(void) { - char romver[16]; - int fd, result; + int result; if ((result = ConsoleRegion) < 0) { + int fd; if ((fd = open("rom0:ROMVER", O_RDONLY)) >= 0) { + char romver[16]; read(fd, romver, sizeof(romver)); close(fd); ConsoleRegionParamsInitPS1DRV(romver); @@ -235,10 +236,10 @@ static int CdReadOSDRegionParams(char *OSDVer) static int GetOSDRegion(void) { char OSDVer[16]; - int fd; if (ConsoleOSDRegionInitStatus == 0 || ConsoleOSDRegion == -1) { + int fd; ConsoleOSDRegionInitStatus = 1; if ((fd = open("rom0:OSDVER", O_RDONLY)) >= 0) { @@ -284,11 +285,9 @@ static int GetOSDRegion(void) static void InitOSDDefaultLanguage(int region, const char *language) { - int DefaultLang; - - DefaultLang = -1; if (ConsoleOSDLanguage == -1) { + int DefaultLang = -1; if (language != NULL) { if (strncmp(language, "jpn", 3) == 0) diff --git a/osd/common/libcdvd_add.c b/osd/common/libcdvd_add.c index 246e054..fa48add 100644 --- a/osd/common/libcdvd_add.c +++ b/osd/common/libcdvd_add.c @@ -28,7 +28,7 @@ int cdInitAdd(void) } } - // printf("Failed to get MECHACON version: %d 0x%x\n", result, status); + // printf("Failed to get MECHACON version: %d 0x%x\n", result, status); return -1; } diff --git a/osd/common/modelname.c b/osd/common/modelname.c index b326292..88f9885 100644 --- a/osd/common/modelname.c +++ b/osd/common/modelname.c @@ -16,7 +16,7 @@ extern char ConsoleROMVER[]; static int ReadModelName(char *name) { - int stat, result, fd; + int stat, result; /* This function is a hybrid between the late ROM browser program and the HDD Browser. In v2.20, there was only a simple null-terminate before calling sceCdRM(), as below. @@ -40,6 +40,7 @@ static int ReadModelName(char *name) strcpy(name, "SCPH-10000"); else { // For ROM v1.01 (Late SCPH-10000, and all SCPH-15000 units). + int fd; if ((fd = open("rom0:OSDSYS", O_RDONLY)) >= 0) { // The model name is located at this address. lseek(fd, 0x8C808, SEEK_SET); diff --git a/osd/common/ps1.c b/osd/common/ps1.c index 8baef6d..b77ea95 100644 --- a/osd/common/ps1.c +++ b/osd/common/ps1.c @@ -98,7 +98,6 @@ const char *PS1DRVGetVersion(void) static void CNFGetKey(char *cnf, char *line, const char *key) { - const char *pKey; int len; if ((len = strlen(key)) != 0) @@ -115,6 +114,7 @@ static void CNFGetKey(char *cnf, char *line, const char *key) if (*cnf == '=') { // Equals sign found + const char *pKey; ++cnf; for (; isspace(*cnf); cnf++) @@ -155,10 +155,8 @@ static void CNFGetKey(char *cnf, char *line, const char *key) static int ParseBootCNF(void) { - char system_cnf[2048], line[128]; - const char *pChar; u32 stat; - int fd, size, i, len; + int fd; strcpy(ps1drv_ver, "???"); strcpy(ps1drv_boot, "???"); @@ -192,6 +190,10 @@ static int ParseBootCNF(void) if ((fd = open("cdrom0:\\SYSTEM.CNF;1", O_RDWR)) >= 0) { + char system_cnf[2048], line[128]; + const char *pChar; + int size, i, len; + size = read(fd, system_cnf, sizeof(system_cnf)); close(fd); diff --git a/osd/common/ps2.c b/osd/common/ps2.c index cd0279a..99794e0 100644 --- a/osd/common/ps2.c +++ b/osd/common/ps2.c @@ -94,7 +94,7 @@ static const char *CNFGetKey(const char *line, char *key) return line; } -static int CNFCheckBootFile(char *value, const char *key) +static int CNFCheckBootFile(const char *value, const char *key) { int i; diff --git a/osd/main.c b/osd/main.c index b9917f6..5a050eb 100644 --- a/osd/main.c +++ b/osd/main.c @@ -89,9 +89,10 @@ static void InitPSX() int main(int argc, char *argv[]) { - int fd, OldDiscType, DiscType, ValidDiscInserted, result; + int OldDiscType, DiscType, ValidDiscInserted, result; u32 stat; #ifndef PSX + int fd; char romver[16], RomName[4]; #endif @@ -128,7 +129,7 @@ int main(int argc, char *argv[]) // The old IOP kernel has no support for LoadModuleBuffer. Apply the patch to enable it. sbv_patch_enable_lmb(); - /* Load the SIO2 modules. You may choose to use the ones from ROM, + /* Load the SIO2 modules. You may choose to use the ones from ROM, but they may not be supported by all PlayStation 2 variants. */ SifExecModuleBuffer(sio2man_irx, size_sio2man_irx, 0, NULL, NULL); SifExecModuleBuffer(mcman_irx, size_mcman_irx, 0, NULL, NULL);