2009-10-01 01:10:58 +02:00
|
|
|
#include <fat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogc/lwp_watchdog.h>
|
|
|
|
#include <ogc/mutex.h>
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <ogc/usbstorage.h>
|
|
|
|
#include <sdcard/wiisd_io.h>
|
|
|
|
|
2009-10-13 23:19:23 +02:00
|
|
|
#include "usbloader/sdhc.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "usbloader/usbstorage.h"
|
|
|
|
|
|
|
|
//these are the only stable and speed is good
|
|
|
|
#define CACHE 8
|
|
|
|
#define SECTORS 64
|
|
|
|
|
2009-10-13 23:19:23 +02:00
|
|
|
extern DISC_INTERFACE __io_sdhc;
|
|
|
|
|
2009-10-01 01:10:58 +02:00
|
|
|
int USBDevice_Init() {
|
|
|
|
//closing all open Files write back the cache and then shutdown em!
|
|
|
|
fatUnmount("USB:/");
|
|
|
|
//right now mounts first FAT-partition
|
|
|
|
if (fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) {
|
|
|
|
//try first mount with cIOS
|
|
|
|
return 1;
|
|
|
|
} else if (fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) {
|
|
|
|
//try now mount with libogc
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void USBDevice_deInit() {
|
|
|
|
//closing all open Files write back the cache and then shutdown em!
|
|
|
|
fatUnmount("USB:/");
|
|
|
|
}
|
|
|
|
|
|
|
|
int isSdInserted() {
|
2009-10-13 23:19:23 +02:00
|
|
|
return __io_sdhc.isInserted() || __io_wiisd.isInserted();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int isInserted(const char *path) {
|
|
|
|
if (!strncmp(path, "USB:", 4))
|
|
|
|
return 1;
|
|
|
|
|
2009-10-13 23:19:23 +02:00
|
|
|
return __io_sdhc.isInserted() || __io_wiisd.isInserted();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
int SDCard_Init() {
|
|
|
|
//closing all open Files write back the cache and then shutdown em!
|
|
|
|
fatUnmount("SD:/");
|
|
|
|
//right now mounts first FAT-partition
|
2009-10-13 23:19:23 +02:00
|
|
|
if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE))
|
|
|
|
return 1;
|
|
|
|
else if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS))
|
2009-10-01 01:10:58 +02:00
|
|
|
return 1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDCard_deInit() {
|
|
|
|
//closing all open Files write back the cache and then shutdown em!
|
|
|
|
fatUnmount("SD:/");
|
|
|
|
}
|