From 8d637d3cd473f4af939753f644de145ea47db2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:20:37 -0300 Subject: [PATCH 1/6] add HDDLOAD module Co-Authored-By: Liu Woon Yung --- iop/hdd/Makefile | 3 +- iop/hdd/hddload/Makefile | 15 ++ iop/hdd/hddload/src/hddload.c | 248 ++++++++++++++++++++++++++++++ iop/hdd/hddload/src/imports.lst | 52 +++++++ iop/hdd/hddload/src/irx_imports.h | 19 +++ 5 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 iop/hdd/hddload/Makefile create mode 100644 iop/hdd/hddload/src/hddload.c create mode 100644 iop/hdd/hddload/src/imports.lst create mode 100644 iop/hdd/hddload/src/irx_imports.h diff --git a/iop/hdd/Makefile b/iop/hdd/Makefile index 118fccff972..f36aadca504 100644 --- a/iop/hdd/Makefile +++ b/iop/hdd/Makefile @@ -19,7 +19,8 @@ SUBDIRS = \ hdck \ hdsk \ fsck \ - fssk + fssk \ + hddload include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/Rules.make diff --git a/iop/hdd/hddload/Makefile b/iop/hdd/hddload/Makefile new file mode 100644 index 00000000000..154daf57c22 --- /dev/null +++ b/iop/hdd/hddload/Makefile @@ -0,0 +1,15 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2024, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +IOP_BIN ?= hddload.irx +IOP_OBJS = hddload.o imports.o exports.o + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/iop/Rules.bin.make +include $(PS2SDKSRC)/iop/Rules.make +include $(PS2SDKSRC)/iop/Rules.release \ No newline at end of file diff --git a/iop/hdd/hddload/src/hddload.c b/iop/hdd/hddload/src/hddload.c new file mode 100644 index 00000000000..1ee21c85e15 --- /dev/null +++ b/iop/hdd/hddload/src/hddload.c @@ -0,0 +1,248 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int DMATxBuffer[4]; +static int DMATransferID; +static u32 OSDAddr; +static u32 OSDStatAddr; +static u32 SectorBuffer[128]; + +//Function prototypes +static void SendResultCode(int result); +static void HDDBootError(int result); +static void FinishHDDLoad(int result); +static int ReadMBR(unsigned char *buffer, unsigned int lba, unsigned int count); +static void HDDLOADThread(void *arg); + +int _start(int argc, char *argv[]) +{ + int i, result, ThreadID; + iop_thread_t ThreadData; + + FlushDcache(); + OSDStatAddr = 0; + OSDAddr = 0; + + if(argc>0) + { + i=0; + + do{ + printf("arg %d %s %s\n", i, argv[0], argv[1]); + + if(strcmp(argv[0], "-osd") == 0) + { + i++; + argv++; + OSDAddr=strtol(*argv, NULL, 0); + printf("osd addr %lx\n", OSDAddr); + } + else if(strcmp(argv[0], "-stat") == 0) + { + i++; + argv++; + OSDStatAddr=strtol(*argv, NULL, 0); + printf("stat addr %lx\n", OSDStatAddr); + } + + i++; + argv++; + }while(i 0) + { + StartThread(ThreadID, NULL); + result = MODULE_RESIDENT_END; + } + else + { + dev9Shutdown(); + result = MODULE_NO_RESIDENT_END; + } + } + + return result; +} + +static void SendResultCode(int result) +{ + int OldState; + SifDmaTransfer_t dmat; + + while(sceSifDmaStat(DMATransferID) >= 0){}; + + DMATxBuffer[0] = result; + + dmat.src=DMATxBuffer; + dmat.size=0x10; + dmat.attr=0; + dmat.dest=(void*)OSDStatAddr; + + CpuSuspendIntr(&OldState); + DMATransferID = sceSifSetDma(&dmat, 1); + CpuResumeIntr(OldState); +} + +static void HDDBootError(int result) +{ + dev9Shutdown(); + SendResultCode(result); + SleepThread(); +} + +static void FinishHDDLoad(int result) +{ + u8 value; + + value=*(*(vu8 **)0x000003c0); //Access the system configuration storage, which is set up by EECONF. + + if(!(value&2)) dev9Shutdown(); //If HDD support is disabled, switch off the DEV9 interface. + SendResultCode(result); + SleepThread(); +} + +static int ReadMBR(unsigned char *buffer, unsigned int lba, unsigned int count) +{ + int NumSectorsToRead, BufferOffset; + + BufferOffset=0; + while(count>0) + { + NumSectorsToRead=(count<0x81)?count:0x80; + + if(ata_device_sector_io(0, buffer+BufferOffset, lba, NumSectorsToRead, ATA_DIR_READ)!=0) + { + printf("cannot read sector 0\n"); + return -1; + } + + count-=NumSectorsToRead; + lba+=NumSectorsToRead; + buffer+=(NumSectorsToRead * 512); + } + + return 0; +} + +static void HDDLOADThread(void *arg) +{ + ata_devinfo_t *devinfo; + int i, OldState, BufferSize; + u32 stat; + u8 iLinkID[0x20]; + u8 *buffer; + void *DecryptedKELF; + + printf("HDL:hdd load thread start.(01/06/10)\n"); + + SendResultCode(0); + + printf("HDL:init ata\n"); + if((devinfo = ata_get_devinfo(0)) == NULL){ + printf("HDL:ATA initialization failed.\n"); + HDDBootError(-1); + } + + for(i=0x1F; i>=0; i--) iLinkID[i] = 0; + + sceCdRI(iLinkID, &stat); + + if(ata_device_sce_sec_unlock(0, iLinkID) != 0) + { + printf("cannot unlock password\n"); + HDDBootError(-2); + } + + printf("HDL:read 0 sec\n"); + if(ata_device_sector_io(0, SectorBuffer, 0, 1, ATA_DIR_READ) != 0) + { + printf("cannot read sector 0\n"); + HDDBootError(-3); + } + + printf("HDL:osdstart %lx osdsize %lx\n", SectorBuffer[76], SectorBuffer[77]); + + BufferSize=SectorBuffer[77]<<9; + + CpuSuspendIntr(&OldState); + buffer=AllocSysMemory(ALLOC_LAST, BufferSize, NULL); + CpuResumeIntr(OldState); + + if(buffer==NULL) + { + printf("cannot alloc memory\n"); + HDDBootError(-6); + } + + if(ReadMBR(buffer, SectorBuffer[76], SectorBuffer[77]) < 0) + { + printf("cannot read data \n"); + CpuSuspendIntr(&OldState); + FreeSysMemory(buffer); + CpuResumeIntr(OldState); + HDDBootError(-4); + } + + if((buffer[0] == 1) && (buffer[3] & 0x04)) + { + printf("HDL:securiyt decript.\n"); + + if((DecryptedKELF=SecrDiskBootFile(buffer))==NULL) + { + printf("cannot secur data \n"); + CpuSuspendIntr(&OldState); + FreeSysMemory(buffer); + CpuResumeIntr(OldState); + HDDBootError(-5); + } + + SifDmaTransfer_t dmat; + + dmat.src=DecryptedKELF; + dmat.size=BufferSize; + dmat.attr=0; + dmat.dest=(void*)OSDAddr; + + CpuSuspendIntr(&OldState); + sceSifSetDma(&dmat, 1); + CpuResumeIntr(OldState); + + CpuSuspendIntr(&OldState); + FreeSysMemory(buffer); + CpuResumeIntr(OldState); + + printf("HDL:END ver.1.00\n"); + + FinishHDDLoad(1); + } + else{ + printf("HDL:security contents error.\n"); + CpuSuspendIntr(&OldState); + FreeSysMemory(buffer); + CpuResumeIntr(OldState); + HDDBootError(-5); + } +} diff --git a/iop/hdd/hddload/src/imports.lst b/iop/hdd/hddload/src/imports.lst new file mode 100644 index 00000000000..36cc1416acf --- /dev/null +++ b/iop/hdd/hddload/src/imports.lst @@ -0,0 +1,52 @@ +dev9_IMPORTS_start +I_dev9Shutdown +dev9_IMPORTS_end + +atad_IMPORTS_start +I_ata_get_devinfo +I_ata_device_sector_io +I_ata_device_sce_sec_unlock +atad_IMPORTS_end + +cdvdman_IMPORTS_start +I_sceCdRI +cdvdman_IMPORTS_end + +intrman_IMPORTS_start +I_CpuSuspendIntr +I_CpuResumeIntr +I_CpuEnableIntr +intrman_IMPORTS_end + +loadcore_IMPORTS_start +I_FlushDcache +loadcore_IMPORTS_end + +sifman_IMPORTS_start +I_sceSifSetDma +I_sceSifDmaStat +sifman_IMPORTS_end + +stdio_IMPORTS_start +I_printf +stdio_IMPORTS_end + +sysclib_IMPORTS_start +I_strcmp +I_strtol +sysclib_IMPORTS_end + +secrman_IMPORTS_start +I_SecrDiskBootFile +secrman_IMPORTS_end + +sysmem_IMPORTS_start +I_AllocSysMemory +I_FreeSysMemory +sysmem_IMPORTS_end + +thbase_IMPORTS_start +I_SleepThread +I_CreateThread +I_StartThread +thbase_IMPORTS_end diff --git a/iop/hdd/hddload/src/irx_imports.h b/iop/hdd/hddload/src/irx_imports.h new file mode 100644 index 00000000000..1e5068fd1d7 --- /dev/null +++ b/iop/hdd/hddload/src/irx_imports.h @@ -0,0 +1,19 @@ +#ifndef IOP_IRX_IMPORTS_H +#define IOP_IRX_IMPORTS_H + +#include + +/* Please keep these in an alphabetical order! */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* IOP_IRX_IMPORTS_H */ From cb5ab759308711d8a28d5d37e68549c73063ef56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:33:26 -0300 Subject: [PATCH 2/6] add libhddboot original code Co-Authored-By: Liu Woon Yung --- ee/Makefile | 3 ++- ee/hddboot/Makefile | 14 ++++++++++ ee/hddboot/include/hdd_boot.h | 9 +++++++ ee/hddboot/src/erl_support.c | 20 ++++++++++++++ ee/hddboot/src/hddboot.c | 51 +++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 ee/hddboot/Makefile create mode 100644 ee/hddboot/include/hdd_boot.h create mode 100644 ee/hddboot/src/erl_support.c create mode 100644 ee/hddboot/src/hddboot.c diff --git a/ee/Makefile b/ee/Makefile index 01d7b094a33..30f1d97ee1b 100644 --- a/ee/Makefile +++ b/ee/Makefile @@ -11,7 +11,8 @@ SUBDIRS = startup erl kernel libcglue libpthreadglue rpc debug \ packet packet2 draw libgs \ libvux font input inputx network iopreboot \ mpeg \ - elf-loader elf-loader-nocolour + elf-loader elf-loader-nocolour \ + hddboot include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/Rules.make diff --git a/ee/hddboot/Makefile b/ee/hddboot/Makefile new file mode 100644 index 00000000000..1b747bb78b0 --- /dev/null +++ b/ee/hddboot/Makefile @@ -0,0 +1,14 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2024, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +EE_OBJS = hddboot.o erl_support.o + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/ee/Rules.lib.make +include $(PS2SDKSRC)/ee/Rules.make +include $(PS2SDKSRC)/ee/Rules.release \ No newline at end of file diff --git a/ee/hddboot/include/hdd_boot.h b/ee/hddboot/include/hdd_boot.h new file mode 100644 index 00000000000..11b1b7ed924 --- /dev/null +++ b/ee/hddboot/include/hdd_boot.h @@ -0,0 +1,9 @@ +#ifndef H_HDDBOOT_INC +#define H_HDDBOOT_INC + +void CheckHDDUpdate(int device, const char *SysExecFolder); +int GetHddSupportEnabledStatus(void); +int GetHddUpdateStatus(void); +void DetermineHDDLoadStatus(void); + +#endif \ No newline at end of file diff --git a/ee/hddboot/src/erl_support.c b/ee/hddboot/src/erl_support.c new file mode 100644 index 00000000000..a1f75dfe32a --- /dev/null +++ b/ee/hddboot/src/erl_support.c @@ -0,0 +1,20 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +# +# The erl-tags support +*/ + +#include + +char * erl_id = "libhddboot"; +char * erl_dependancies[] = { + "libkernel", + "libc", + 0 +}; \ No newline at end of file diff --git a/ee/hddboot/src/hddboot.c b/ee/hddboot/src/hddboot.c new file mode 100644 index 00000000000..a93f19349fb --- /dev/null +++ b/ee/hddboot/src/hddboot.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include + +#include "HDDSupport.h" + +static volatile unsigned int HDDLoadStatArea[4] ALIGNED(16); +static unsigned char IsHddSupportEnabled=0, HddSupportStatus=0; + +void CheckHDDUpdate(int device, const char *SysExecFolder){ + char CmdStr[34], ModulePath[40]; + + sprintf(ModulePath, "mc%u:/%s/dev9.irx", device, SysExecFolder); + if(SifLoadModule(ModulePath, 0, NULL)>=0){ + sprintf(ModulePath, "mc%u:/%s/atad.irx", device, SysExecFolder); + if(SifLoadModule(ModulePath, 0, NULL)>=0){ + strcpy(CmdStr, "-osd"); + strcpy(&CmdStr[5], "0x00100000"); + strcpy(&CmdStr[16], "-stat"); + sprintf(&CmdStr[22], "%p", HDDLoadStatArea); + CmdStr[sizeof(CmdStr)-1]='\0'; + + sprintf(ModulePath, "mc%u:/%s/hddload.irx", device, SysExecFolder); + if(SifLoadModule(ModulePath, sizeof(CmdStr), CmdStr)>=0){ + IsHddSupportEnabled = 1; + } + } + } +} + +int GetHddSupportEnabledStatus(void){ + return IsHddSupportEnabled; +} + +int GetHddUpdateStatus(void){ + return HddSupportStatus; +} + +void DetermineHDDLoadStatus(void){ + int result; + + if((result=*(int *)UNCACHED_SEG(HDDLoadStatArea))==1){ + HddSupportStatus = 1; + } + else if(result<0){ + IsHddSupportEnabled = 0; + } +} From e709a469b6ab6cb657009f10e4d89dd532461750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:57:57 -0300 Subject: [PATCH 3/6] add README to HDDLOAD module --- iop/hdd/hddload/README.MD | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 iop/hdd/hddload/README.MD diff --git a/iop/hdd/hddload/README.MD b/iop/hdd/hddload/README.MD new file mode 100644 index 00000000000..4fee5944994 --- /dev/null +++ b/iop/hdd/hddload/README.MD @@ -0,0 +1,85 @@ +# HDDLOAD +The HDDLOAD module is used for loading a bootstrap program from the `__mbr` partition of the attached HDD unit. The program is expected to be an ELF file, headerless, with load address `0x00100000` and appropriately-flagged KELF. (`kelftool encrypt mbr ELF KELF`) + +Some PlayStation 2 consoles like the `SCPH-10000`, `SCPH-15000` and `SCPH-18000` do not support their HDD units, the Sony HDD Utility Disc may be used to install a "System Driver Update" that adds the ability to boot from the HDD. + +While not intended by Sony, it is possible to use this system to boot a HDD update on the `SCPH-700xx`. + +This update will boot a HDDLOAD module, which works similarly to the one found in the boot ROM (`rom0:HDDLOAD` on expansion bay models). + +This package contains the source code a clone of the HDDLOAD module, based on a module from the 1.60 ROM. + +# Dependencies + +It depends on `dev9.irx` and `atad.irx` tp function. + + +## Workflow +- Call either `BootHDDLoadFile()` or `BootHDDLoadBuffer()` depending if the module will be loaded from a file or buffer. This will attempt to load `hddload.irx`, on the given memory card. If an update can be loaded, the update will be loaded to `0x00100000`. +This will take some time as the HDD may be spun up, so you could consider doing this in another thread. Otherwise, the user will be greeted with a black screen. Sony renders the "Sony Computer Entertainment" boot screen as this is being done. +- Call `DetermineHDDLoadStatus()`. +- Call `GetHddSupportEnabledStatus()` and `GetHddUpdateStatus()` to determine whether HDD booting was enabled and if an update was successfully booted. +- If both return 1, then boot the executable can be executed from `0x00100000`. + + +## Configuration +The IOP side will access the configuration storage area which is set up by EELOAD, which resides at `0x000003c0`. This is loaded from the MECHACON's NVRAM storage. + +- Bits: +``` + 1 = Disable ATAD. By default, this is not set. + 2 = Disable HDD support. PS2 consoles come with this bit set. +``` +So if the HDD browser was never installed on the PS2, HDD support is disabled. Which results in HDDLOAD switching off the HDD immediately after the program is loaded. + + +## ATAD check +As described above, the `ATAD` module from the boot ROM is a combination of `DEV9` and `ATAD` from the Sony PS2 SDK. It will also check whether `ATAD` is enabled. +This bit is not set by default (`ATAD` is enabled by default). This is what the `ATAD` module checks: +```c +static int CheckATADEnabled(void){ + return(!((*(*(vu8 **)0x000003c0))&1)); +} +``` + +## Enabling HDD support +As shown in the FMCB Installer, the following can be done from the EE to enable HDD booting on the PS2. This should be done during installation: + +```c +static int EnableHDDBooting(void){ + int OpResult, result; + unsigned char OSDConfigBuffer[15]; + + do { + sceCdOpenConfig(0, 0, 1, &OpResult); + } while(OpResult&9); + + do { + result=sceCdReadConfig(OSDConfigBuffer, &OpResult); + } while(OpResult&9 || result==0); + + do { + result=sceCdCloseConfig(&OpResult); + } while(OpResult&9 || result==0); + + if ((OSDConfigBuffer[0]&3)!=2) { //If ATAD support and HDD booting are not already activated. + OSDConfigBuffer[0]=(OSDConfigBuffer[0]&~3)|2; + + do { + sceCdOpenConfig(0, 1, 1, &OpResult); + } while(OpResult&9); + + do { + result = sceCdWriteConfig(OSDConfigBuffer, &OpResult); + } while(OpResult&9 || result==0); + + do { + result = sceCdCloseConfig(&OpResult); + } while(OpResult&9 || result==0); + + result = 0; + } else result = 1; + + return result; +} +``` From 0f2a40dd554fdf578c946fad6e8b494677073e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:46:37 -0300 Subject: [PATCH 4/6] modify libhddboot to be more generic --- ee/hddboot/include/hdd_boot.h | 32 +++++++++++++++++++++++- ee/hddboot/src/hddboot.c | 47 ++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/ee/hddboot/include/hdd_boot.h b/ee/hddboot/include/hdd_boot.h index 11b1b7ed924..1ead0656765 100644 --- a/ee/hddboot/include/hdd_boot.h +++ b/ee/hddboot/include/hdd_boot.h @@ -1,9 +1,39 @@ #ifndef H_HDDBOOT_INC #define H_HDDBOOT_INC -void CheckHDDUpdate(int device, const char *SysExecFolder); +/** + * @brief Executes the HDDLOAD module from a file + * @param path path to the HDDLOAD IRX Module + * @param ret integer pointer to obtain the Module return value. it should return 0 on successfull load + * @return Module ID. if 0 or larger, success. if negative number, then MODLOAD refused to load the module (see kerr.h) +*/ +int BootHDDLoadFile(char* path, int* ret); + +/** + * @brief Executes the HDDLOAD module from a buffer on EE + * @param irx Pointer to the buffer holding HDDLOAD IRX Module + * @param size Size of the HDDLOAD IRX Module buffer + * @param ret integer pointer to obtain the Module return value. it should return 0 on successfull load + * @return Module ID. if 0 or larger, success. if negative number, then MODLOAD refused to load the module (see kerr.h) +*/ +int BootHDDLoadBuffer(void* irx, unsigned int size, int* ret); + +/** + * @brief Internal check for the HDDLOAD Status + * @return 1 if module loaded successfully +*/ int GetHddSupportEnabledStatus(void); + +/** + * @brief Checks if the HDDLOAD Module thread has completed the DMA Transfer of the MBR.KELF from HDD to RAM + * @note once it is done, check with the ::DetermineHDDLoadStatus function +*/ int GetHddUpdateStatus(void); + +/** + * @brief Returns the status of the HDDLOAD thread execution + * @return 1 if module Completed it's task +*/ void DetermineHDDLoadStatus(void); #endif \ No newline at end of file diff --git a/ee/hddboot/src/hddboot.c b/ee/hddboot/src/hddboot.c index a93f19349fb..b3a00b646bd 100644 --- a/ee/hddboot/src/hddboot.c +++ b/ee/hddboot/src/hddboot.c @@ -5,30 +5,37 @@ #include #include -#include "HDDSupport.h" +#include "hdd_boot.h" static volatile unsigned int HDDLoadStatArea[4] ALIGNED(16); static unsigned char IsHddSupportEnabled=0, HddSupportStatus=0; +char CmdStr[34]; + +static void construct_params() { + memset(&CmdStr, 0, sizeof(CmdStr)); + strcpy(CmdStr, "-osd"); + strcpy(&CmdStr[5], "0x00100000"); + strcpy(&CmdStr[16], "-stat"); + sprintf(&CmdStr[22], "%p", HDDLoadStatArea); + CmdStr[sizeof(CmdStr)-1]='\0'; +} -void CheckHDDUpdate(int device, const char *SysExecFolder){ - char CmdStr[34], ModulePath[40]; - - sprintf(ModulePath, "mc%u:/%s/dev9.irx", device, SysExecFolder); - if(SifLoadModule(ModulePath, 0, NULL)>=0){ - sprintf(ModulePath, "mc%u:/%s/atad.irx", device, SysExecFolder); - if(SifLoadModule(ModulePath, 0, NULL)>=0){ - strcpy(CmdStr, "-osd"); - strcpy(&CmdStr[5], "0x00100000"); - strcpy(&CmdStr[16], "-stat"); - sprintf(&CmdStr[22], "%p", HDDLoadStatArea); - CmdStr[sizeof(CmdStr)-1]='\0'; - - sprintf(ModulePath, "mc%u:/%s/hddload.irx", device, SysExecFolder); - if(SifLoadModule(ModulePath, sizeof(CmdStr), CmdStr)>=0){ - IsHddSupportEnabled = 1; - } - } - } +int BootHDDLoadBuffer(void* irx, unsigned int size, int* ret){ + int id, rett; + construct_params(); + id = SifExecModuleBuffer(irx, size, sizeof(CmdStr), CmdStr, &rett); + if (id > 0 && rett != 1) IsHddSupportEnabled = 1; + if (ret != NULL) *ret = rett; + return id; +} + +int BootHDDLoadFile(char* path, int* ret){ + int id, rett; + construct_params(); + id = SifLoadStartModule(path, sizeof(CmdStr), CmdStr, &rett); + if (id > 0 && rett != 1) IsHddSupportEnabled = 1; + if (ret != NULL) *ret = rett; + return id; } int GetHddSupportEnabledStatus(void){ From 5ef0d46198abee7915d0d8d3c3d1c43ed4f1d9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:50:19 -0300 Subject: [PATCH 5/6] [hddload] fix DEV9 header include --- iop/hdd/hddload/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iop/hdd/hddload/Makefile b/iop/hdd/hddload/Makefile index 154daf57c22..d921220f321 100644 --- a/iop/hdd/hddload/Makefile +++ b/iop/hdd/hddload/Makefile @@ -8,8 +8,9 @@ IOP_BIN ?= hddload.irx IOP_OBJS = hddload.o imports.o exports.o +IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/dev9/include include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make include $(PS2SDKSRC)/iop/Rules.make -include $(PS2SDKSRC)/iop/Rules.release \ No newline at end of file +include $(PS2SDKSRC)/iop/Rules.release From 21d68a3a07792ef5a05a452e31ded24c669a05dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:19:15 -0300 Subject: [PATCH 6/6] [hddload] add missing search directory --- iop/hdd/hddload/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iop/hdd/hddload/Makefile b/iop/hdd/hddload/Makefile index d921220f321..74f0824b28e 100644 --- a/iop/hdd/hddload/Makefile +++ b/iop/hdd/hddload/Makefile @@ -8,7 +8,7 @@ IOP_BIN ?= hddload.irx IOP_OBJS = hddload.o imports.o exports.o -IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/dev9/include +IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/dev9/include -I -I$(PS2SDKSRC)/iop/dev9/atad/include include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make