Skip to content

Commit

Permalink
add libhddboot original code
Browse files Browse the repository at this point in the history
Co-Authored-By: Liu Woon Yung <ysai187@yahoo.com>
  • Loading branch information
israpps and sp193 committed Apr 16, 2024
1 parent 8d637d3 commit cb5ab75
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions ee/hddboot/Makefile
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions ee/hddboot/include/hdd_boot.h
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions ee/hddboot/src/erl_support.c
Original file line number Diff line number Diff line change
@@ -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 <erl.h>

char * erl_id = "libhddboot";
char * erl_dependancies[] = {
"libkernel",
"libc",
0
};
51 changes: 51 additions & 0 deletions ee/hddboot/src/hddboot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <kernel.h>
#include <loadfile.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#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;
}
}

0 comments on commit cb5ab75

Please sign in to comment.