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] 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){