Skip to content

Commit 87b1ad2

Browse files
committed
modify libhddboot to be more generic
1 parent cb5ab75 commit 87b1ad2

2 files changed

Lines changed: 58 additions & 21 deletions

File tree

ee/hddboot/include/hdd_boot.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
#ifndef H_HDDBOOT_INC
22
#define H_HDDBOOT_INC
33

4-
void CheckHDDUpdate(int device, const char *SysExecFolder);
4+
/**
5+
* @brief Executes the HDDLOAD module from a file
6+
* @param path path to the HDDLOAD IRX Module
7+
* @param ret integer pointer to obtain the Module return value. it should return 0 on successfull load
8+
* @return Module ID. if 0 or larger, success. if negative number, then MODLOAD refused to load the module (see kerr.h)
9+
*/
10+
int BootHDDLoadFile(char* path, int* ret);
11+
12+
/**
13+
* @brief Executes the HDDLOAD module from a buffer on EE
14+
* @param irx Pointer to the buffer holding HDDLOAD IRX Module
15+
* @param size Size of the HDDLOAD IRX Module buffer
16+
* @param ret integer pointer to obtain the Module return value. it should return 0 on successfull load
17+
* @return Module ID. if 0 or larger, success. if negative number, then MODLOAD refused to load the module (see kerr.h)
18+
*/
19+
int BootHDDLoadBuffer(void* irx, unsigned int size, int* ret);
20+
21+
/**
22+
* @brief Internal check for the HDDLOAD Status
23+
* @return 1 if module loaded successfully
24+
*/
525
int GetHddSupportEnabledStatus(void);
26+
27+
/**
28+
* @brief Checks if the HDDLOAD Module thread has completed the DMA Transfer of the MBR.KELF from HDD to RAM
29+
* @note once it is done, check with the ::DetermineHDDLoadStatus function
30+
*/
631
int GetHddUpdateStatus(void);
32+
33+
/**
34+
* @brief Returns the status of the HDDLOAD thread execution
35+
* @return 1 if module Completed it's task
36+
*/
737
void DetermineHDDLoadStatus(void);
838

939
#endif

ee/hddboot/src/hddboot.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,37 @@
55
#include <stdio.h>
66
#include <errno.h>
77

8-
#include "HDDSupport.h"
8+
#include "hdd_boot.h"
99

1010
static volatile unsigned int HDDLoadStatArea[4] ALIGNED(16);
1111
static unsigned char IsHddSupportEnabled=0, HddSupportStatus=0;
12+
char CmdStr[34];
13+
14+
static void construct_params() {
15+
memset(&CmdStr, 0, sizeof(CmdStr));
16+
strcpy(CmdStr, "-osd");
17+
strcpy(&CmdStr[5], "0x00100000");
18+
strcpy(&CmdStr[16], "-stat");
19+
sprintf(&CmdStr[22], "%p", HDDLoadStatArea);
20+
CmdStr[sizeof(CmdStr)-1]='\0';
21+
}
1222

13-
void CheckHDDUpdate(int device, const char *SysExecFolder){
14-
char CmdStr[34], ModulePath[40];
15-
16-
sprintf(ModulePath, "mc%u:/%s/dev9.irx", device, SysExecFolder);
17-
if(SifLoadModule(ModulePath, 0, NULL)>=0){
18-
sprintf(ModulePath, "mc%u:/%s/atad.irx", device, SysExecFolder);
19-
if(SifLoadModule(ModulePath, 0, NULL)>=0){
20-
strcpy(CmdStr, "-osd");
21-
strcpy(&CmdStr[5], "0x00100000");
22-
strcpy(&CmdStr[16], "-stat");
23-
sprintf(&CmdStr[22], "%p", HDDLoadStatArea);
24-
CmdStr[sizeof(CmdStr)-1]='\0';
25-
26-
sprintf(ModulePath, "mc%u:/%s/hddload.irx", device, SysExecFolder);
27-
if(SifLoadModule(ModulePath, sizeof(CmdStr), CmdStr)>=0){
28-
IsHddSupportEnabled = 1;
29-
}
30-
}
31-
}
23+
int BootHDDLoadBuffer(void* irx, unsigned int size, int* ret){
24+
int id, rett;
25+
construct_params();
26+
id = SifExecModuleBuffer(irx, size, sizeof(CmdStr), CmdStr, rett);
27+
if (id > 0 && rett != 1) IsHddSupportEnabled = 1;
28+
if (ret != NULL) *ret = rett;
29+
return id;
30+
}
31+
32+
int BootHDDLoadFile(char* path, int* ret){
33+
int id, rett;
34+
construct_params();
35+
id = SifLoadStartModule(path, sizeof(CmdStr), CmdStr, rett);
36+
if (id > 0 && rett != 1) IsHddSupportEnabled = 1;
37+
if (ret != NULL) *ret = rett;
38+
return id;
3239
}
3340

3441
int GetHddSupportEnabledStatus(void){

0 commit comments

Comments
 (0)