mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 00:15:10 +01:00
remove IOS 202 code
This commit is contained in:
parent
8157e9b064
commit
bcfa3dde62
@ -90,9 +90,7 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(TTFFILES:.ttf=.ttf.o) $(LANGFILES:.lang=.lang.o) \
|
||||
$(PNGFILES:.png=.png.o) \
|
||||
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o) \
|
||||
$(CURDIR)/source/utils/ehcmodule.elf.o
|
||||
|
||||
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o)
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -313,14 +313,6 @@ void MountAllFAT()
|
||||
***************************************************************************/
|
||||
bool MountDVD(bool silent)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if(IOS_GetVersion() != 202)
|
||||
{
|
||||
ErrorPrompt("Please install IOS 202 for DVD support.");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool mounted = false;
|
||||
int retry = 1;
|
||||
|
||||
|
@ -4302,6 +4302,15 @@ MainMenu (int menu)
|
||||
if(!LoadPrefs())
|
||||
SavePrefs(SILENT);
|
||||
|
||||
#ifdef HW_RVL
|
||||
static bool checkIOS = true;
|
||||
|
||||
if(checkIOS && !SaneIOS())
|
||||
ErrorPrompt("The current IOS has been altered (fake-signed). Functionality and/or stability may be adversely affected.");
|
||||
|
||||
checkIOS = false;
|
||||
#endif
|
||||
|
||||
// Load palettes
|
||||
LoadPalettes();
|
||||
|
||||
|
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
extern const u8 ehcmodule_elf_end[];
|
||||
extern const u8 ehcmodule_elf[];
|
||||
extern const u32 ehcmodule_elf_size;
|
@ -1,262 +0,0 @@
|
||||
/* mload.c (for PPC) (c) 2009, Hermes
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <gccore.h>
|
||||
#include "unistd.h"
|
||||
#include "ehcmodule_elf.h"
|
||||
|
||||
#define MLOAD_GET_IOS_BASE 0x4D4C4401
|
||||
#define MLOAD_GET_MLOAD_VERSION 0x4D4C4402
|
||||
#define MLOAD_RUN_THREAD 0x4D4C4482
|
||||
#define MLOAD_MEMSET 0x4D4C4491
|
||||
|
||||
#define getbe32(x) ((adr[x]<<24) | (adr[x+1]<<16) | (adr[x+2]<<8) | (adr[x+3]))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 ident0;
|
||||
u32 ident1;
|
||||
u32 ident2;
|
||||
u32 ident3;
|
||||
u32 machinetype;
|
||||
u32 version;
|
||||
u32 entry;
|
||||
u32 phoff;
|
||||
u32 shoff;
|
||||
u32 flags;
|
||||
u16 ehsize;
|
||||
u16 phentsize;
|
||||
u16 phnum;
|
||||
u16 shentsize;
|
||||
u16 shnum;
|
||||
u16 shtrndx;
|
||||
} elfheader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 type;
|
||||
u32 offset;
|
||||
u32 vaddr;
|
||||
u32 paddr;
|
||||
u32 filesz;
|
||||
u32 memsz;
|
||||
u32 flags;
|
||||
u32 align;
|
||||
} elfphentry;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *start;
|
||||
int prio;
|
||||
void *stack;
|
||||
int size_stack;
|
||||
} data_elf;
|
||||
|
||||
static const char mload_fs[] ATTRIBUTE_ALIGN(32) = "/dev/mload";
|
||||
|
||||
static s32 mload_fd = -1;
|
||||
static s32 hid = -1;
|
||||
|
||||
int mloadVersion = -1;
|
||||
int iosBase = -1;
|
||||
|
||||
// to close the device (remember call it when rebooting the IOS!)
|
||||
int mload_close()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (hid >= 0)
|
||||
{
|
||||
iosDestroyHeap(hid);
|
||||
hid = -1;
|
||||
}
|
||||
|
||||
if (mload_fd < 0)
|
||||
return -1;
|
||||
|
||||
ret = IOS_Close(mload_fd);
|
||||
mload_fd = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// to init/test if the device is running
|
||||
int mload_init()
|
||||
{
|
||||
int n;
|
||||
|
||||
if (hid < 0)
|
||||
hid = iosCreateHeap(0x800);
|
||||
|
||||
if (hid < 0)
|
||||
{
|
||||
if (mload_fd >= 0)
|
||||
IOS_Close(mload_fd);
|
||||
|
||||
mload_fd = -1;
|
||||
return hid;
|
||||
}
|
||||
|
||||
if (mload_fd >= 0)
|
||||
return 0;
|
||||
|
||||
for (n = 0; n < 20; n++) // try 5 seconds
|
||||
{
|
||||
mload_fd = IOS_Open(mload_fs, 0);
|
||||
|
||||
if (mload_fd >= 0)
|
||||
break;
|
||||
|
||||
usleep(250 * 1000);
|
||||
}
|
||||
|
||||
if (mload_fd < 0)
|
||||
return mload_close();
|
||||
|
||||
mloadVersion = IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_MLOAD_VERSION, ":");
|
||||
iosBase = IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_IOS_BASE, ":");
|
||||
|
||||
return mload_fd;
|
||||
}
|
||||
|
||||
// fix starlet address to read/write (uses SEEK_SET, etc as mode)
|
||||
static int mload_seek(int offset, int mode)
|
||||
{
|
||||
if (mload_init() < 0)
|
||||
return -1;
|
||||
|
||||
return IOS_Seek(mload_fd, offset, mode);
|
||||
}
|
||||
|
||||
// write bytes from starlet (it update the offset)
|
||||
static int mload_write(const void * buf, u32 size)
|
||||
{
|
||||
if (mload_init() < 0)
|
||||
return -1;
|
||||
|
||||
return IOS_Write(mload_fd, buf, size);
|
||||
}
|
||||
|
||||
// fill a block (similar to memset)
|
||||
static int mload_memset(void *starlet_addr, int set, int len)
|
||||
{
|
||||
if (mload_init() < 0)
|
||||
return -1;
|
||||
|
||||
return IOS_IoctlvFormat(hid, mload_fd, MLOAD_MEMSET, "iii:", starlet_addr, set, len);
|
||||
}
|
||||
|
||||
// load a module from the PPC
|
||||
// the module must be a elf made with stripios
|
||||
static int mload_elf(void *my_elf, data_elf *data_elf)
|
||||
{
|
||||
int n, m;
|
||||
int p;
|
||||
u8 *adr;
|
||||
u32 elf = (u32) my_elf;
|
||||
|
||||
if (elf & 3)
|
||||
return -1; // aligned to 4 please!
|
||||
|
||||
elfheader *head = (void *) elf;
|
||||
elfphentry *entries;
|
||||
|
||||
if (head->ident0 != 0x7F454C46)
|
||||
return -1;
|
||||
if (head->ident1 != 0x01020161)
|
||||
return -1;
|
||||
if (head->ident2 != 0x01000000)
|
||||
return -1;
|
||||
|
||||
p = head->phoff;
|
||||
|
||||
data_elf->start = (void *) head->entry;
|
||||
|
||||
for (n = 0; n < head->phnum; n++)
|
||||
{
|
||||
entries = (void *) (elf + p);
|
||||
p += sizeof(elfphentry);
|
||||
|
||||
if (entries->type == 4)
|
||||
{
|
||||
adr = (void *) (elf + entries->offset);
|
||||
|
||||
if (getbe32(0) != 0)
|
||||
return -2; // bad info (sure)
|
||||
|
||||
for (m = 4; m < entries->memsz; m += 8)
|
||||
{
|
||||
switch (getbe32(m))
|
||||
{
|
||||
case 0x9:
|
||||
data_elf->start = (void *) getbe32(m+4);
|
||||
break;
|
||||
case 0x7D:
|
||||
data_elf->prio = getbe32(m+4);
|
||||
break;
|
||||
case 0x7E:
|
||||
data_elf->size_stack = getbe32(m+4);
|
||||
break;
|
||||
case 0x7F:
|
||||
data_elf->stack = (void *) (getbe32(m+4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entries->type == 1 && entries->memsz != 0 && entries->vaddr != 0)
|
||||
{
|
||||
if (mload_memset((void *) entries->vaddr, 0, entries->memsz) < 0)
|
||||
return -1;
|
||||
if (mload_seek(entries->vaddr, SEEK_SET) < 0)
|
||||
return -1;
|
||||
if (mload_write((void *) (elf + entries->offset), entries->filesz) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// run one thread (you can use to load modules or binary files)
|
||||
static int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority)
|
||||
{
|
||||
if (mload_init() < 0)
|
||||
return -1;
|
||||
|
||||
return IOS_IoctlvFormat(hid, mload_fd, MLOAD_RUN_THREAD, "iiii:", starlet_addr, starlet_top_stack, stack_size, priority);
|
||||
}
|
||||
|
||||
bool load_ehci_module()
|
||||
{
|
||||
data_elf elf;
|
||||
memset(&elf, 0, sizeof(data_elf));
|
||||
|
||||
if(mload_elf((void *) ehcmodule_elf, &elf) != 0)
|
||||
return false;
|
||||
|
||||
if(mload_run_thread(elf.start, elf.stack, elf.size_stack, elf.prio) < 0)
|
||||
return false;
|
||||
|
||||
usleep(5000);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
/* mload.c (for PPC) (c) 2009, Hermes
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __MLOAD_H__
|
||||
#define __MLOAD_H__
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern int mloadVersion;
|
||||
extern int iosBase;
|
||||
|
||||
int mload_init();
|
||||
bool load_ehci_module();
|
||||
int mload_close();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,364 +0,0 @@
|
||||
/****************************************************************************
|
||||
* WiiMC
|
||||
* usb2storage.c -- USB mass storage support, inside starlet
|
||||
* Copyright (C) 2008 Kwiirk
|
||||
* Improved for homebrew by rodries and Tantric
|
||||
*
|
||||
* IOS 202 and the ehcmodule must be loaded before using this!
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#include <gccore.h>
|
||||
|
||||
#include <ogc/lwp_heap.h>
|
||||
#include <malloc.h>
|
||||
#include <ogc/disc_io.h>
|
||||
#include <ogc/usbstorage.h>
|
||||
#include <ogc/mutex.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
//#define DEBUG_USB2
|
||||
|
||||
#ifdef DEBUG_USB2
|
||||
#define debug_printf(fmt, args...) \
|
||||
fprintf(stderr, "%s:%d:" fmt, __FUNCTION__, __LINE__, ##args)
|
||||
#else
|
||||
#define debug_printf(fmt, args...)
|
||||
#endif // DEBUG_USB2
|
||||
|
||||
#define UMS_BASE (('U'<<24)|('M'<<16)|('S'<<8))
|
||||
#define USB_IOCTL_UMS_INIT (UMS_BASE+0x1)
|
||||
#define USB_IOCTL_UMS_GET_CAPACITY (UMS_BASE+0x2)
|
||||
#define USB_IOCTL_UMS_READ_SECTORS (UMS_BASE+0x3)
|
||||
#define USB_IOCTL_UMS_WRITE_SECTORS (UMS_BASE+0x4)
|
||||
#define USB_IOCTL_UMS_READ_STRESS (UMS_BASE+0x5)
|
||||
#define USB_IOCTL_UMS_SET_VERBOSE (UMS_BASE+0x6)
|
||||
#define USB_IOCTL_UMS_IS_INSERTED (UMS_BASE+0x7)
|
||||
#define USB_IOCTL_UMS_USB_MODE (UMS_BASE+0x8)
|
||||
#define USB_IOCTL_UMS_GET_USBLAN_PORT (UMS_BASE+0x9)
|
||||
|
||||
#define USB_IOCTL_UMS_UMOUNT (UMS_BASE+0x10)
|
||||
#define USB_IOCTL_UMS_START (UMS_BASE+0x11)
|
||||
#define USB_IOCTL_UMS_STOP (UMS_BASE+0x12)
|
||||
#define USB_IOCTL_UMS_EXIT (UMS_BASE+0x16)
|
||||
|
||||
#define UMS_HEAPSIZE 2*1024
|
||||
#define UMS_MAXPATH 16
|
||||
|
||||
static s32 hId = -1;
|
||||
static s32 __usb2fd = -1;
|
||||
static u32 sector_size;
|
||||
static mutex_t usb2_mutex = LWP_MUTEX_NULL;
|
||||
static u8 *fixed_buffer = NULL;
|
||||
|
||||
#define ROUNDDOWN32(v) (((u32)(v)-0x1f)&~0x1f)
|
||||
#define USB2_BUFFER 128*1024
|
||||
static heap_cntrl usb2_heap;
|
||||
static u8 __usb2_heap_created = 0;
|
||||
|
||||
static DISC_INTERFACE __io_usb1storage;
|
||||
static int usb1disc_inited = 0;
|
||||
extern const DISC_INTERFACE __io_usb2storage;
|
||||
|
||||
static s32 USB2CreateHeap()
|
||||
{
|
||||
u32 level;
|
||||
void *usb2_heap_ptr;
|
||||
|
||||
if (__usb2_heap_created != 0)
|
||||
return IPC_OK;
|
||||
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
usb2_heap_ptr = (void *) ROUNDDOWN32(((u32)SYS_GetArena2Hi() - (USB2_BUFFER+(4*1024))));
|
||||
if ((u32) usb2_heap_ptr < (u32) SYS_GetArena2Lo())
|
||||
{
|
||||
_CPU_ISR_Restore(level);
|
||||
return IPC_ENOMEM;
|
||||
}
|
||||
SYS_SetArena2Hi(usb2_heap_ptr);
|
||||
__lwp_heap_init(&usb2_heap, usb2_heap_ptr, (USB2_BUFFER + (4 * 1024)), 32);
|
||||
__usb2_heap_created = 1;
|
||||
_CPU_ISR_Restore(level);
|
||||
return IPC_OK;
|
||||
}
|
||||
|
||||
static s32 USB2Storage_Initialize()
|
||||
{
|
||||
if(__usb2fd > 0)
|
||||
return 0;
|
||||
|
||||
char *devicepath = NULL;
|
||||
|
||||
if (usb2_mutex == LWP_MUTEX_NULL)
|
||||
LWP_MutexInit(&usb2_mutex, false);
|
||||
|
||||
if (hId == -1)
|
||||
hId = iosCreateHeap(UMS_HEAPSIZE);
|
||||
|
||||
if (hId < 0)
|
||||
{
|
||||
debug_printf("error IPC_ENOMEM\n");
|
||||
return IPC_ENOMEM;
|
||||
}
|
||||
|
||||
if (USB2CreateHeap() != IPC_OK)
|
||||
{
|
||||
debug_printf("error USB2 IPC_ENOMEM\n");
|
||||
return IPC_ENOMEM;
|
||||
}
|
||||
|
||||
if (fixed_buffer == NULL)
|
||||
fixed_buffer = __lwp_heap_allocate(&usb2_heap, USB2_BUFFER);
|
||||
|
||||
if (__usb2fd <= 0)
|
||||
{
|
||||
LWP_MutexLock(usb2_mutex);
|
||||
devicepath = iosAlloc(hId, UMS_MAXPATH);
|
||||
if (devicepath == NULL)
|
||||
{
|
||||
LWP_MutexUnlock(usb2_mutex);
|
||||
return IPC_ENOMEM;
|
||||
}
|
||||
|
||||
snprintf(devicepath, USB_MAXPATH, "/dev/usb2");
|
||||
__usb2fd = IOS_Open(devicepath, 0);
|
||||
iosFree(hId, devicepath);
|
||||
LWP_MutexUnlock(usb2_mutex);
|
||||
}
|
||||
|
||||
if(__usb2fd <= 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static s32 USB2Storage_Open()
|
||||
{
|
||||
s32 ret = USB_OK;
|
||||
u32 size = 0;
|
||||
|
||||
if(USB2Storage_Initialize() < 0)
|
||||
return -1;
|
||||
|
||||
ret = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_INIT, ":");
|
||||
debug_printf("usb2 init value: %i\n", ret);
|
||||
|
||||
if (ret < 0)
|
||||
debug_printf("usb2 error init\n");
|
||||
else
|
||||
size = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_GET_CAPACITY, ":i",
|
||||
§or_size);
|
||||
debug_printf("usb2 GET_CAPACITY: %d\n", size);
|
||||
|
||||
if (size == 0)
|
||||
ret = -2012;
|
||||
else
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void USB2Storage_Close()
|
||||
{
|
||||
if(__usb2fd <= 0)
|
||||
return;
|
||||
|
||||
IOS_Close(__usb2fd);
|
||||
__usb2fd = -1;
|
||||
}
|
||||
|
||||
static inline int is_MEM2_buffer(const void *buffer)
|
||||
{
|
||||
u32 high_addr = ((u32) buffer) >> 24;
|
||||
return (high_addr == 0x90) || (high_addr == 0xD0);
|
||||
}
|
||||
|
||||
void USB2Enable(bool enable)
|
||||
{
|
||||
if(!usb1disc_inited)
|
||||
{
|
||||
usb1disc_inited = 1;
|
||||
memcpy(&__io_usb1storage, &__io_usbstorage, sizeof(DISC_INTERFACE));
|
||||
}
|
||||
|
||||
if(!enable)
|
||||
{
|
||||
memcpy(&__io_usbstorage, &__io_usb1storage, sizeof(DISC_INTERFACE));
|
||||
}
|
||||
else
|
||||
{
|
||||
USB2Storage_Initialize();
|
||||
memcpy(&__io_usbstorage, &__io_usb2storage, sizeof(DISC_INTERFACE));
|
||||
}
|
||||
}
|
||||
|
||||
static bool __usb2storage_Startup(void)
|
||||
{
|
||||
if(USB2Storage_Open() < 0)
|
||||
return false;
|
||||
|
||||
if(__usb2fd > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool __usb2storage_IsInserted(void)
|
||||
{
|
||||
if (USB2Storage_Open() < 0)
|
||||
return false;
|
||||
|
||||
if(usb2_mutex == LWP_MUTEX_NULL)
|
||||
return false;
|
||||
|
||||
if (__usb2fd > 0)
|
||||
{
|
||||
LWP_MutexLock(usb2_mutex);
|
||||
int retval = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_IS_INSERTED, ":");
|
||||
LWP_MutexUnlock(usb2_mutex);
|
||||
debug_printf("isinserted usb2 retval: %d \n",retval);
|
||||
|
||||
if (retval > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool __usb2storage_ReadSectors(u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
s32 ret = 1;
|
||||
u32 sectors = 0;
|
||||
uint8_t *dest = buffer;
|
||||
|
||||
if (__usb2fd < 1 || usb2_mutex == LWP_MUTEX_NULL)
|
||||
return false;
|
||||
|
||||
LWP_MutexLock(usb2_mutex);
|
||||
|
||||
while (numSectors > 0)
|
||||
{
|
||||
if (numSectors * sector_size > USB2_BUFFER)
|
||||
sectors = USB2_BUFFER / sector_size;
|
||||
else
|
||||
sectors = numSectors;
|
||||
|
||||
if (!is_MEM2_buffer(dest)) //libfat is not providing us good buffers :-(
|
||||
{
|
||||
ret = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d",
|
||||
sector, sectors, fixed_buffer, sector_size * sectors);
|
||||
memcpy(dest, fixed_buffer, sector_size * sectors);
|
||||
}
|
||||
else
|
||||
ret = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d",
|
||||
sector, sectors, dest, sector_size * sectors);
|
||||
|
||||
dest += sector_size * sectors;
|
||||
if (ret < 1) break;
|
||||
|
||||
sector += sectors;
|
||||
numSectors -= sectors;
|
||||
}
|
||||
if(ret<1) USB2Storage_Close();
|
||||
LWP_MutexUnlock(usb2_mutex);
|
||||
if (ret < 1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool __usb2storage_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
|
||||
{
|
||||
s32 ret = 1;
|
||||
u32 sectors = 0;
|
||||
uint8_t *dest = (uint8_t *) buffer;
|
||||
|
||||
if (__usb2fd < 1 || usb2_mutex == LWP_MUTEX_NULL)
|
||||
return false;
|
||||
|
||||
LWP_MutexLock(usb2_mutex);
|
||||
while (numSectors > 0 && ret > 0)
|
||||
{
|
||||
if (numSectors * sector_size > USB2_BUFFER)
|
||||
sectors = USB2_BUFFER / sector_size;
|
||||
else
|
||||
sectors = numSectors;
|
||||
|
||||
numSectors -= sectors;
|
||||
|
||||
if (!is_MEM2_buffer(dest)) // libfat is not providing us good buffers :-(
|
||||
{
|
||||
memcpy(fixed_buffer, dest, sector_size * sectors);
|
||||
ret = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_WRITE_SECTORS,
|
||||
"ii:d", sector, sectors, fixed_buffer, sector_size
|
||||
* sectors);
|
||||
}
|
||||
else
|
||||
ret = IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_WRITE_SECTORS,
|
||||
"ii:d", sector, sectors, dest, sector_size * sectors);
|
||||
if (ret < 1)break;
|
||||
|
||||
dest += sector_size * sectors;
|
||||
sector += sectors;
|
||||
}
|
||||
LWP_MutexUnlock(usb2_mutex);
|
||||
if(ret < 1 ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool __usb2storage_ClearStatus(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool __usb2storage_Shutdown(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetUSB2Mode(int mode)
|
||||
{
|
||||
USB2Storage_Initialize();
|
||||
IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_USB_MODE, "b:",(u8)mode);
|
||||
}
|
||||
|
||||
int GetUSB2LanPort()
|
||||
{
|
||||
USB2Storage_Initialize();
|
||||
return IOS_IoctlvFormat(hId, __usb2fd, USB_IOCTL_UMS_GET_USBLAN_PORT, ":");
|
||||
}
|
||||
|
||||
const DISC_INTERFACE __io_usb2storage = {
|
||||
DEVICE_TYPE_WII_USB,
|
||||
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_WII_USB,
|
||||
(FN_MEDIUM_STARTUP) & __usb2storage_Startup,
|
||||
(FN_MEDIUM_ISINSERTED) & __usb2storage_IsInserted,
|
||||
(FN_MEDIUM_READSECTORS) & __usb2storage_ReadSectors,
|
||||
(FN_MEDIUM_WRITESECTORS) & __usb2storage_WriteSectors,
|
||||
(FN_MEDIUM_CLEARSTATUS) & __usb2storage_ClearStatus,
|
||||
(FN_MEDIUM_SHUTDOWN) & __usb2storage_Shutdown
|
||||
};
|
||||
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
/****************************************************************************
|
||||
* WiiMC
|
||||
* usb2storage.h -- USB mass storage support, inside starlet
|
||||
* Copyright (C) 2008 Kwiirk
|
||||
* Improved for homebrew by rodries and Tantric
|
||||
*
|
||||
* IOS 202 and the ehcimodule must be loaded before using this!
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __USB2STORAGE_H__
|
||||
#define __USB2STORAGE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void USB2Enable(bool e);
|
||||
void USB2Storage_Close();
|
||||
int GetUSB2LanPort();
|
||||
void SetUSB2Mode(int mode);
|
||||
//mode 0: port0 disabled & port1 disabled
|
||||
//mode 1: port0 enabled & port1 disabled
|
||||
//mode 2: port0 disabled & port1 enabled
|
||||
//mode 3: port0 enabled & port1 enabled
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -119,7 +119,6 @@ bool fxOn = false;
|
||||
bool windowOn = false;
|
||||
int frameCount = 0;
|
||||
char buffer[1024];
|
||||
FILE *out = NULL;
|
||||
u32 lastTime = 0;
|
||||
int count = 0;
|
||||
|
||||
@ -3378,41 +3377,6 @@ void CPUInterrupt()
|
||||
biosProtected[3] = 0xe5;
|
||||
}
|
||||
|
||||
void log(const char *defaultMsg, ...)
|
||||
{
|
||||
char buffer[2048];
|
||||
va_list valist;
|
||||
|
||||
va_start(valist, defaultMsg);
|
||||
vsprintf(buffer, defaultMsg, valist);
|
||||
|
||||
if(out == NULL) {
|
||||
out = fopen("sd:/trace.log","w");
|
||||
}
|
||||
|
||||
fprintf(out,"%s\n",buffer);
|
||||
|
||||
va_end(valist);
|
||||
}
|
||||
|
||||
void winlog(const char *defaultMsg, ...)
|
||||
{
|
||||
char buffer[2048];
|
||||
va_list valist;
|
||||
|
||||
va_start(valist, defaultMsg);
|
||||
vsprintf(buffer, defaultMsg, valist);
|
||||
|
||||
if(out == NULL) {
|
||||
out = fopen("sd:/trace.log","w");
|
||||
}
|
||||
|
||||
fprintf(out,"%s\n",buffer);
|
||||
//fputs(buffer, out);
|
||||
|
||||
va_end(valist);
|
||||
}
|
||||
|
||||
void CPULoop(int ticks)
|
||||
{
|
||||
int clockTicks;
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "video.h"
|
||||
#include "gamesettings.h"
|
||||
#include "mem2.h"
|
||||
#include "utils/usb2storage.h"
|
||||
#include "utils/mload.h"
|
||||
#include "utils/FreeTypeGX.h"
|
||||
|
||||
#include "vba/gba/Globals.h"
|
||||
@ -42,6 +40,7 @@
|
||||
|
||||
extern "C" {
|
||||
extern void __exception_setreload(int t);
|
||||
extern u32 __di_check_ahbprot(void);
|
||||
}
|
||||
|
||||
extern int emulating;
|
||||
@ -55,8 +54,6 @@ int ExitRequested = 0;
|
||||
char appPath[1024] = { 0 };
|
||||
char loadedFile[1024] = { 0 };
|
||||
|
||||
extern FILE *out;
|
||||
|
||||
/****************************************************************************
|
||||
* Shutdown / Reboot / Exit
|
||||
***************************************************************************/
|
||||
@ -65,8 +62,6 @@ static void ExitCleanup()
|
||||
{
|
||||
ShutdownAudio();
|
||||
StopGX();
|
||||
if (out) fclose(out);
|
||||
|
||||
HaltDeviceThread();
|
||||
UnmountAllFAT();
|
||||
|
||||
@ -180,7 +175,7 @@ static void ipl_set_config(unsigned char c)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* IOS 202
|
||||
* IOS Check
|
||||
***************************************************************************/
|
||||
#ifdef HW_RVL
|
||||
static bool FindIOS(u32 ios)
|
||||
@ -220,6 +215,52 @@ static bool FindIOS(u32 ios)
|
||||
free(titles);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SaneIOS()
|
||||
{
|
||||
bool res = false;
|
||||
u32 num_titles=0;
|
||||
u32 tmd_size;
|
||||
u32 ios = IOS_GetVersion();
|
||||
u8 tmdbuffer[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
if (ES_GetNumTitles(&num_titles) < 0)
|
||||
return false;
|
||||
|
||||
if(num_titles < 1)
|
||||
return false;
|
||||
|
||||
u64 *titles = (u64 *)memalign(32, num_titles * sizeof(u64) + 32);
|
||||
|
||||
if (ES_GetTitles(titles, num_titles) < 0)
|
||||
{
|
||||
free(titles);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(u32 n=0; n < num_titles; n++)
|
||||
{
|
||||
if((titles[n] & 0xFFFFFFFF) != ios)
|
||||
continue;
|
||||
|
||||
if (ES_GetStoredTMDSize(titles[n], &tmd_size) < 0)
|
||||
break;
|
||||
|
||||
if (tmd_size > 4096)
|
||||
break;
|
||||
|
||||
if (ES_GetStoredTMD(titles[n], (signed_blob *)tmdbuffer, tmd_size) < 0)
|
||||
break;
|
||||
|
||||
if (tmdbuffer[1] || tmdbuffer[2])
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(titles);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* USB Gecko Debugging
|
||||
@ -290,21 +331,19 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifdef HW_RVL
|
||||
// try to load IOS 202
|
||||
if(FindIOS(202))
|
||||
IOS_ReloadIOS(202);
|
||||
else if(IOS_GetVersion() < 61 && FindIOS(61))
|
||||
IOS_ReloadIOS(61);
|
||||
// only reload IOS if AHBPROT is not enabled
|
||||
u32 version = IOS_GetVersion();
|
||||
|
||||
if(IOS_GetVersion() == 202)
|
||||
if(version != 58 && __di_check_ahbprot() != 1)
|
||||
{
|
||||
// enable DVD and USB2
|
||||
if(FindIOS(58))
|
||||
IOS_ReloadIOS(58);
|
||||
else if((version < 61 || version >= 200) && FindIOS(61))
|
||||
IOS_ReloadIOS(61);
|
||||
}
|
||||
|
||||
DI_LoadDVDX(false);
|
||||
DI_Init();
|
||||
|
||||
if(mload_init() >= 0 && load_ehci_module())
|
||||
USB2Enable(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
InitDeviceThread();
|
||||
|
@ -89,6 +89,7 @@ struct SGCSettings{
|
||||
|
||||
void ExitApp();
|
||||
void ShutdownWii();
|
||||
bool SaneIOS();
|
||||
extern struct SGCSettings GCSettings;
|
||||
extern int ScreenshotRequested;
|
||||
extern int ConfigRequested;
|
||||
|
Loading…
Reference in New Issue
Block a user