*Reverting some stuff to the OLD way before new IOS222

Now if you use 249 there is no change to R492 before 222.    
  So if you still get blackscreens it wasnt caused by that.
This commit is contained in:
dimok321 2009-06-13 23:39:42 +00:00
parent fc76b6a9c6
commit 587fdbbae2
11 changed files with 57 additions and 197 deletions

View File

@ -26,19 +26,9 @@ static u8 size_to_shift(u32 size)
}
return ret-1;
}
#define read_le32_unaligned(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24))
u32 WBFS_part_list[4]={0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
u32 wbfs_get_partition_LBA(int index)
{
return WBFS_part_list[index & 3];
}
wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector,
rw_sector_callback_t write_hdsector,
void *callback_data,
@ -47,109 +37,30 @@ wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector,
int i=num_hd_sector,ret;
u8 *ptr,*tmp_buffer = wbfs_ioalloc(hd_sector_size);
u8 part_table[16*4];
int l;
ret = read_hdsector(callback_data,0,1,tmp_buffer);
if(ret)
{
wbfs_iofree(tmp_buffer);
return 0;
}
//find wbfs partition
wbfs_memcpy(part_table,tmp_buffer+0x1be,16*4);
ptr = part_table;
for(l=0;l<4;l++) WBFS_part_list[l]=0xFFFFFFFF;
l=0;
for(i=0;i<4;i++,ptr+=16)
{
u32 part_lba = read_le32_unaligned(ptr+0x8);
wbfs_head_t *head = (wbfs_head_t *)tmp_buffer;
#if 1
if(head->magic != wbfs_htonl(WBFS_MAGIC))
if(ptr[4]==0) continue;
if(ptr[4]==0xf)
{
u32 part_lba2=part_lba;
u32 next_lba2=0;
int n;
for(n=0;n<8;n++) // max 8 logic partitions (i think it is sufficient!)
{
ret = read_hdsector(callback_data,part_lba+next_lba2 ,1,tmp_buffer);
if(ret)
{
wbfs_iofree(tmp_buffer);
return 0;
}
part_lba2=part_lba+next_lba2+read_le32_unaligned(tmp_buffer+0x1C6);
next_lba2=read_le32_unaligned(tmp_buffer+0x1D6);
ret = read_hdsector(callback_data,part_lba2,1,tmp_buffer);
if(ret)
{
wbfs_iofree(tmp_buffer);
return 0;
}
// verify there is the magic.
if (head->magic == wbfs_htonl(WBFS_MAGIC))
{
WBFS_part_list[l]=part_lba2;
if(l>0 && WBFS_part_list[l-1]==WBFS_part_list[l]) WBFS_part_list[l]=0xFFFFFFFF;
else l++; if(l>=4) break;
/*wbfs_t*p = wbfs_open_partition(read_hdsector,write_hdsector,
callback_data,hd_sector_size,0,part_lba2,reset);
return p;*/
}
if(next_lba2==0) break;
}
}
else
#endif
{
ret = read_hdsector(callback_data,part_lba,1,tmp_buffer);
if(ret)
{
wbfs_iofree(tmp_buffer);
return 0;
}
// verify there is the magic.
if (head->magic == wbfs_htonl(WBFS_MAGIC))
{
WBFS_part_list[l]=part_lba;
if(l>0 && WBFS_part_list[l-1]==WBFS_part_list[l]) WBFS_part_list[l]=0xFFFFFFFF;
else l++; if(l>=4) break;
/*
wbfs_t*p = wbfs_open_partition(read_hdsector,write_hdsector,
callback_data,hd_sector_size,0,part_lba,reset);
return p;*/
}
}
if(l>=4) break;
}
wbfs_iofree(tmp_buffer);
if(WBFS_part_list[0]==0xFFFFFFFF) return 0;
// open the first partition finded
wbfs_t*p = wbfs_open_partition(read_hdsector,write_hdsector,
callback_data,hd_sector_size,0,WBFS_part_list[0],reset);
return p;
}
}
if(reset)// XXX make a empty hd partition..
{
}
return 0;
}
wbfs_t*wbfs_open_partition(rw_sector_callback_t read_hdsector,
rw_sector_callback_t write_hdsector,
void *callback_data,

View File

@ -123,15 +123,6 @@ wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector,
void *callback_data,
int hd_sector_size, int num_hd_sector, int reset);
/* call wbfs_open_hd at first time to find the WBFS partition on the HDD (max 4 partitions)
wbfs_get_partition_LBA receive 0 to 3 as partition index (first, second...) and return 0xFFFFFFFF if WBFS partition is not finded
*/
u32 wbfs_get_partition_LBA(int index);
/*! @brief open a wbfs partition
@param read_hdsector,write_hdsector: accessors to the partition
@hd_sector_size: size of the hd sector. Can be set to zero if the partition in already initialized

View File

@ -15,7 +15,6 @@
#define wbfs_malloc(x) malloc(x)
#define wbfs_free(x) free(x)
#define wbfs_ioalloc(x) memalign(32, x)
#define wbfs_iofree(x) free(x) // XXX should allocate in a ios heap
#define wbfs_iofree(x) free(x)
#define wbfs_be16(x) (*((u16*)(x)))
#define wbfs_be32(x) (*((u32*)(x)))

View File

@ -1324,7 +1324,7 @@ static int MenuInstall()
int menu = MENU_NONE;
static struct discHdr headerdisc ATTRIBUTE_ALIGN(32);
Disc_SetUSB(NULL, GetPartition());
Disc_SetUSB(NULL);
int ret, choice = 0;
char *name;
@ -1582,10 +1582,7 @@ static int MenuFormat()
menu = MENU_SETTINGS;
} else {
for(int i = 0; i < 4; i++) {
ret = WBFS_Open2(i);
if(ret == 0) break;
}
ret = WBFS_Open();
sprintf(text, "%s %s", text,LANGUAGE.formated);
WindowPrompt(LANGUAGE.Success,text,LANGUAGE.ok,0,0,0);
menu = MENU_DISCLIST;
@ -1700,10 +1697,7 @@ static int MenuCheck()
Sys_LoadMenu();
}
for(i = 0; i < 4; i++) {
ret2 = WBFS_Open2(i);
if(ret2 == 0) break;
}
ret2 = WBFS_Open();
if (ret2 < 0) {
choice = WindowPrompt(LANGUAGE.NoWBFSpartitionfound,
LANGUAGE.Youneedtoformatapartition,
@ -1871,7 +1865,7 @@ int MainMenu(int menu)
Sys_IosReload(249);
}
}
ret = Disc_SetUSB(header->id, GetPartition());
ret = Disc_SetUSB(header->id);
if(ret < 0) Sys_BackToLoader();
ret = Disc_Open();
if(ret < 0) Sys_BackToLoader();

View File

@ -81,15 +81,14 @@ int Sys_IosReload(int IOS)
SDCard_deInit();
USBDevice_deInit();
mload_close();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
USBStorage_Deinit();
WDVD_Close();
USBStorage_Deinit();
if(IOS == 249 || IOS == 222 || IOS == 223) {
for(int i = 0; i < 10; i++) {
ret = IOS_ReloadIOS(IOS);
@ -102,12 +101,8 @@ int Sys_IosReload(int IOS)
}
if(ret>=0) {
ret = Disc_Init();
int i = 0;
if(ret>=0) {
for(i = 0; i < 4; i++) {
ret = WBFS_Open2(i);
if(ret == 0) break;
}
ret = WBFS_Open();
}
} else Sys_BackToLoader();
}

View File

@ -217,10 +217,10 @@ s32 Disc_Wait(void)
return 0;
}
s32 Disc_SetUSB(u8 *id, int ios222)
s32 Disc_SetUSB(u8 *id)
{
/* Set USB mode */
return WDVD_SetUSBMode(id, ios222);
return WDVD_SetUSBMode(id);
}
s32 Disc_ReadHeader(void *outbuf)

View File

@ -43,7 +43,7 @@ s32 Disc_Init(void);
s32 Disc_Open(void);
s32 Disc_Wait(void);
void __Disc_SetLowMem(void);
s32 Disc_SetUSB(u8 *, int ios222);
s32 Disc_SetUSB(u8 *);
s32 Disc_ReadHeader(void *);
s32 Disc_IsWii(void);
s32 Disc_BootPartition(u64, u8, u8, u8, u8, u8);

View File

@ -22,7 +22,6 @@ static wbfs_t *hdd = NULL;
/* WBFS callbacks */
static rw_sector_callback_t readCallback = NULL;
static rw_sector_callback_t writeCallback = NULL;
static int current_partition = 0;
/* Variables */
@ -77,35 +76,6 @@ wbfs_t *GetHddInfo(void)
return hdd;
}
s32 WBFS_Open2(int index) // index 0-3
{
u32 lba;
/* Close hard disk */
if (hdd)
wbfs_close(hdd);hdd=0;
lba = wbfs_get_partition_LBA(index);
current_partition = index & 3;
if(lba==0xFFFFFFFF)
{
if((index & 3)==0) return WBFS_Open();
return -1;
}
/* Open hard disk */
hdd = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, 0, lba, 0);
if (!hdd)
return -1;
return 0;
}
s32 GetPartition()
{
return current_partition;
}
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
{
void *buffer = NULL;

View File

@ -20,9 +20,7 @@ enum {
/* Prototypes */
s32 WBFS_Init(u32);
s32 WBFS_Open();
s32 WBFS_Open2(int partition);
s32 GetPartition();
s32 WBFS_Open(void);
s32 WBFS_Close(void);
s32 WBFS_Format(u32, u32);
s32 WBFS_GetCount(u32 *);
@ -37,6 +35,10 @@ s32 WBFS_DiskSpace(f32 *, f32 *);
s32 WBFS_RenameGame(u8 *, const void *);
f32 WBFS_EstimeGameSize(void);
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf);
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf);
#ifdef __cplusplus
}
#endif

View File

@ -322,7 +322,7 @@ s32 WDVD_DisableReset(u8 val)
}
/** Hermes **/
s32 WDVD_SetUSBMode(u8 *id, s32 partition)
s32 WDVD_SetUSBMode(u8 *id)
{
s32 ret;
@ -334,15 +334,13 @@ s32 WDVD_SetUSBMode(u8 *id, s32 partition)
/* Copy ID */
if (id)
{
if (id) {
memcpy(&inbuf[2], id, 6);
inbuf[5] = partition;
}
ret = IOS_Ioctl(di_fd, IOCTL_DI_SETUSBMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
if(ret!=1)
{ // Try old cIOS 222
if(ret!=1) {
// Try old cIOS 222
/* Set USB mode */
inbuf[0] = DI_SETWBFSMODE << 24;
ret = IOS_Ioctl(di_fd, DI_SETWBFSMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));

View File

@ -23,7 +23,7 @@ s32 WDVD_Read(void *, u32, u64);
s32 WDVD_WaitForDisc(void);
s32 WDVD_GetCoverStatus(u32 *);
s32 WDVD_DisableReset(u8);
s32 WDVD_SetUSBMode(u8 *, s32);
s32 WDVD_SetUSBMode(u8 *);
#ifdef __cplusplus
}