Skip to content

Commit

Permalink
modify libhddboot to be more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps committed Apr 16, 2024
1 parent e709a46 commit 0f2a40d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 21 deletions.
32 changes: 31 additions & 1 deletion ee/hddboot/include/hdd_boot.h
Original file line number Diff line number Diff line change
@@ -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
47 changes: 27 additions & 20 deletions ee/hddboot/src/hddboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@
#include <stdio.h>
#include <errno.h>

#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){
Expand Down

0 comments on commit 0f2a40d

Please sign in to comment.