From 08fb37a94df7d40eabcb54dfb789f7e16bd68d9d Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 9 Aug 2010 03:45:17 +0000 Subject: [PATCH] remove IOS 202 code --- Makefile.wii | 4 +- source/fileop.cpp | 8 - source/menu.cpp | 9 + source/snes9xgx.cpp | 73 +++++-- source/snes9xgx.h | 1 + source/utils/ehcmodule.elf.o | Bin 20668 -> 0 bytes source/utils/ehcmodule_elf.h | 3 - source/utils/mload.c | 262 ------------------------- source/utils/mload.h | 32 --- source/utils/usb2storage.c | 364 ----------------------------------- source/utils/usb2storage.h | 30 --- 11 files changed, 69 insertions(+), 717 deletions(-) delete mode 100644 source/utils/ehcmodule.elf.o delete mode 100644 source/utils/ehcmodule_elf.h delete mode 100644 source/utils/mload.c delete mode 100644 source/utils/mload.h delete mode 100644 source/utils/usb2storage.c delete mode 100644 source/utils/usb2storage.h diff --git a/Makefile.wii b/Makefile.wii index 1fcd605..617746b 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -86,9 +86,7 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.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 #--------------------------------------------------------------------------------- diff --git a/source/fileop.cpp b/source/fileop.cpp index f330528..7f0dca2 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -315,14 +315,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; diff --git a/source/menu.cpp b/source/menu.cpp index 150c890..8291cff 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -3840,6 +3840,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 + #ifndef NO_SOUND bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG); bgMusic->SetVolume(GCSettings.MusicVolume); diff --git a/source/snes9xgx.cpp b/source/snes9xgx.cpp index 71c495c..143721f 100644 --- a/source/snes9xgx.cpp +++ b/source/snes9xgx.cpp @@ -40,8 +40,6 @@ #include "filebrowser.h" #include "input.h" #include "mem2.h" -#include "utils/usb2storage.h" -#include "utils/mload.h" #include "utils/FreeTypeGX.h" #include "snes9x/snes9x.h" @@ -60,6 +58,7 @@ static int currentMode; extern "C" { extern void __exception_setreload(int t); +extern u32 __di_check_ahbprot(void); } extern void S9xInitSync(); @@ -212,7 +211,7 @@ void setFrameTimerMethod() } /**************************************************************************** - * IOS 202 + * IOS Check ***************************************************************************/ #ifdef HW_RVL static bool FindIOS(u32 ios) @@ -252,6 +251,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 @@ -318,21 +363,19 @@ 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 - DI_LoadDVDX(false); - DI_Init(); - - if(mload_init() >= 0 && load_ehci_module()) - USB2Enable(true); + if(FindIOS(58)) + IOS_ReloadIOS(58); + else if((version < 61 || version >= 200) && FindIOS(61)) + IOS_ReloadIOS(61); } + + DI_LoadDVDX(false); + DI_Init(); #endif InitDeviceThread(); diff --git a/source/snes9xgx.h b/source/snes9xgx.h index fece547..c34dab2 100644 --- a/source/snes9xgx.h +++ b/source/snes9xgx.h @@ -108,6 +108,7 @@ struct SGCSettings{ void ExitApp(); void ShutdownWii(); +bool SaneIOS(); extern struct SGCSettings GCSettings; extern int ScreenshotRequested; extern int ConfigRequested; diff --git a/source/utils/ehcmodule.elf.o b/source/utils/ehcmodule.elf.o deleted file mode 100644 index f88d988c66d541c4888d3edf932e7b6dd2bf2cdd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20668 zcmcJ13wTt=mF9i)?Wg*s7O2&Ifu54UD<|>nCd+0#naLz;XRr}d@~z;-|f2fI(6#QsZ-~iI#(aR``$KHQ5t|? z`2Zd&^T|2w#d|NF=M<$6iSqH-_HV!a)5D7L)58(v-7hUw&fZvx#d^G-J&UsP^SUzh znST9%mQnI9JOpeq@6BVb$rO4ASOB>Qa&wTYv4-s$f{uKH^}n(| z7_7PP2Vyj{5oIy7@q;=+JRv+`P%nZfil_F7kMX`~1uZq(XZ>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2IAGQh{bWtxK3_veYrZ8@_)SVF`g;AKu(6cZfKKKMz5c`@ zak5TLO_loacTaEI8&E!LMLP8xnXi-iDVhHEiu@(nZt)fA0@+U1PaT)})3Ti+Q@<>) zz+ZiTN9yS<8=l#`5g#g(q2&0Z^M>M{@$I3qvHS7V<}F)#QX4l z&+x9l-%k?Fh#YR&9JXcEAJx$xp+oOFW$<^kcGscKi|75?Ek+xHr{ST$X3X^g{w97> z@;!>Q3=6MozJMR+*k$~ju+XHPaOlJ1!DHZY;fdh!;c>ug$Cr3B!b9=Qf9PBulQ%%V zJcn}L0iO>>W1|n&5`RE~@^$o1e=?u0st0ol9)5J==8rzQebcUu#IMsu)wxGEer$vC F{{WkqWKjSB diff --git a/source/utils/ehcmodule_elf.h b/source/utils/ehcmodule_elf.h deleted file mode 100644 index e2729ca..0000000 --- a/source/utils/ehcmodule_elf.h +++ /dev/null @@ -1,3 +0,0 @@ -extern const u8 ehcmodule_elf_end[]; -extern const u8 ehcmodule_elf[]; -extern const u32 ehcmodule_elf_size; diff --git a/source/utils/mload.c b/source/utils/mload.c deleted file mode 100644 index 19864d7..0000000 --- a/source/utils/mload.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#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 diff --git a/source/utils/mload.h b/source/utils/mload.h deleted file mode 100644 index aa01daf..0000000 --- a/source/utils/mload.h +++ /dev/null @@ -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 diff --git a/source/utils/usb2storage.c b/source/utils/usb2storage.c deleted file mode 100644 index 4f3c374..0000000 --- a/source/utils/usb2storage.c +++ /dev/null @@ -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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#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 diff --git a/source/utils/usb2storage.h b/source/utils/usb2storage.h deleted file mode 100644 index d7bed91..0000000 --- a/source/utils/usb2storage.h +++ /dev/null @@ -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