From a976c4e530d4b9c5fd5cd671907180d4bdb9fe4c Mon Sep 17 00:00:00 2001 From: "e.bovendeur" Date: Tue, 13 Oct 2009 21:19:23 +0000 Subject: [PATCH] * Added SDHC support (issue 672) * Added support for larget WBFS drives, as found by Wiimm (http://gbatemp.net/index.php?showtopic=185428). --- source/fatmounter.c | 11 ++++++++--- source/libwbfs/libwbfs.c | 3 +++ source/usbloader/wbfs.c | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/fatmounter.c b/source/fatmounter.c index 6141f768..6c9a1ca2 100644 --- a/source/fatmounter.c +++ b/source/fatmounter.c @@ -6,12 +6,15 @@ #include #include +#include "usbloader/sdhc.h" #include "usbloader/usbstorage.h" //these are the only stable and speed is good #define CACHE 8 #define SECTORS 64 +extern DISC_INTERFACE __io_sdhc; + int USBDevice_Init() { //closing all open Files write back the cache and then shutdown em! fatUnmount("USB:/"); @@ -32,20 +35,22 @@ void USBDevice_deInit() { } int isSdInserted() { - return __io_wiisd.isInserted(); + return __io_sdhc.isInserted() || __io_wiisd.isInserted(); } int isInserted(const char *path) { if (!strncmp(path, "USB:", 4)) return 1; - return __io_wiisd.isInserted(); + return __io_sdhc.isInserted() || __io_wiisd.isInserted(); } int SDCard_Init() { //closing all open Files write back the cache and then shutdown em! fatUnmount("SD:/"); //right now mounts first FAT-partition - if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) + if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE)) + return 1; + else if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) return 1; return -1; } diff --git a/source/libwbfs/libwbfs.c b/source/libwbfs/libwbfs.c index 382fd7c2..8b840a66 100644 --- a/source/libwbfs/libwbfs.c +++ b/source/libwbfs/libwbfs.c @@ -50,6 +50,9 @@ wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector, // verify there is the magic. if (head->magic == wbfs_htonl(WBFS_MAGIC)) { + // Override the sector size by the sector size in the wbfs header... + hd_sector_size = 1 << head->hd_sec_sz_s; + wbfs_t*p = wbfs_open_partition(read_hdsector,write_hdsector, callback_data,hd_sector_size,0,part_lba,reset); return p; diff --git a/source/usbloader/wbfs.c b/source/usbloader/wbfs.c index f84d2fe1..127d0681 100644 --- a/source/usbloader/wbfs.c +++ b/source/usbloader/wbfs.c @@ -313,6 +313,9 @@ s32 WBFS_Open(void) { if (!hdd) return -1; + // Save the new sector size, so it will be used in read and write calls + sector_size = hdd->head->hd_sec_sz_s; + return 0; }