mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 11:19:17 +01:00
*Revert of libfat it causes crashes for most people and doesn't really work. We will deal with it later. For now the old one is good.
*Removed a few compile flags which were duplicated. Changed to optimization Os.
This commit is contained in:
parent
787dd53a46
commit
0f945247dc
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>1.0 r947</version>
|
||||
<release_date>201009171621</release_date>
|
||||
<version>1.0 r948</version>
|
||||
<release_date>201009172243</release_date>
|
||||
<short_description>Loads games from USB-devices</short_description>
|
||||
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
|
||||
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.
|
||||
|
3
Makefile
3
Makefile
@ -55,8 +55,7 @@ INCLUDES := source
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -ffast-math -g -O3 -pipe -mrvl -mcpu=750 -meabi -mhard-float -Wall $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H -DGEKKO \
|
||||
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
||||
CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
||||
CXXFLAGS = -Xassembler -aln=$@.lst $(CFLAGS)
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80B00000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
|
||||
-include $(PROJECTDIR)/Make.config
|
||||
|
@ -26,8 +26,8 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _BIT_OPS_H
|
||||
#define _BIT_OPS_H
|
||||
#ifndef __BIT_OPS_H
|
||||
#define __BIT_OPS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -26,54 +26,23 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
#ifndef __COMMON_H
|
||||
#define __COMMON_H
|
||||
|
||||
#define BYTES_PER_READ 512
|
||||
#include "fat.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "libfat/fat.h"
|
||||
|
||||
// When compiling for NDS, make sure NDS is defined
|
||||
#ifndef NDS
|
||||
#if defined ARM9 || defined ARM7
|
||||
#define NDS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Platform specific includes
|
||||
#if defined(__gamecube__) || defined (__wii__)
|
||||
#include <gctypes.h>
|
||||
#include <ogc/disc_io.h>
|
||||
#include <gccore.h>
|
||||
#elif defined(NDS)
|
||||
#include <nds/ndstypes.h>
|
||||
#include <nds/system.h>
|
||||
#include <nds/disc_io.h>
|
||||
#elif defined(GBA)
|
||||
#include <gba_types.h>
|
||||
#include <disc_io.h>
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <ogc/disc_io.h>
|
||||
#include <gccore.h>
|
||||
// Platform specific options
|
||||
#if defined (__wii__)
|
||||
#define DEFAULT_CACHE_PAGES 4
|
||||
#define DEFAULT_SECTORS_PAGE 64
|
||||
#define USE_LWP_LOCK
|
||||
#define USE_RTC_TIME
|
||||
#elif defined (__gamecube__)
|
||||
#define DEFAULT_CACHE_PAGES 4
|
||||
#define DEFAULT_SECTORS_PAGE 64
|
||||
#define USE_LWP_LOCK
|
||||
#define USE_RTC_TIME
|
||||
#elif defined (NDS)
|
||||
#define DEFAULT_CACHE_PAGES 4
|
||||
#define DEFAULT_SECTORS_PAGE 8
|
||||
#define USE_RTC_TIME
|
||||
#elif defined (GBA)
|
||||
#define DEFAULT_CACHE_PAGES 2
|
||||
#define DEFAULT_SECTORS_PAGE 8
|
||||
#define LIMIT_SECTORS 128
|
||||
#endif
|
||||
#define DEFAULT_CACHE_PAGES 4
|
||||
#define DEFAULT_SECTORS_PAGE 64
|
||||
#define USE_LWP_LOCK
|
||||
#define USE_RTC_TIME
|
||||
|
||||
#endif // _COMMON_H
|
||||
|
@ -329,8 +329,7 @@ bool _FAT_directory_getNextEntry (PARTITION* partition, DIR_ENTRY* entry) {
|
||||
}
|
||||
lfn[lfnPos] = '\0'; // Set end of lfn to null character
|
||||
lfnChkSum = entryData[LFN_offset_checkSum];
|
||||
}
|
||||
if (lfnChkSum != entryData[LFN_offset_checkSum]) {
|
||||
} if (lfnChkSum != entryData[LFN_offset_checkSum]) {
|
||||
lfnExists = false;
|
||||
}
|
||||
if (lfnExists) {
|
||||
@ -418,49 +417,6 @@ bool _FAT_directory_getRootEntry (PARTITION* partition, DIR_ENTRY* entry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _FAT_directory_getVolumeLabel (PARTITION* partition, char *label) {
|
||||
DIR_ENTRY entry;
|
||||
DIR_ENTRY_POSITION entryEnd;
|
||||
uint8_t entryData[DIR_ENTRY_DATA_SIZE];
|
||||
int i;
|
||||
bool end;
|
||||
|
||||
_FAT_directory_getRootEntry(partition, &entry);
|
||||
|
||||
entryEnd = entry.dataEnd;
|
||||
|
||||
// Make sure we are using the correct root directory, in case of FAT32
|
||||
if (entryEnd.cluster == FAT16_ROOT_DIR_CLUSTER) {
|
||||
entryEnd.cluster = partition->rootDirCluster;
|
||||
}
|
||||
|
||||
label[0]='\0';
|
||||
label[11]='\0';
|
||||
end = false;
|
||||
//this entry should be among the first 3 entries in the root directory table, if not, then system can have trouble displaying the right volume label
|
||||
while(!end) {
|
||||
if (_FAT_directory_incrementDirEntryPosition (partition, &entryEnd, false) == false) {
|
||||
end = true;
|
||||
}
|
||||
|
||||
if(!_FAT_cache_readPartialSector (partition->cache, entryData,
|
||||
_FAT_fat_clusterToSector(partition, entryEnd.cluster) + entryEnd.sector,
|
||||
entryEnd.offset * DIR_ENTRY_DATA_SIZE, DIR_ENTRY_DATA_SIZE))
|
||||
{ //error reading
|
||||
return false;
|
||||
}
|
||||
if (entryData[DIR_ENTRY_attributes] == ATTRIB_VOL && entryData[0] != DIR_ENTRY_FREE) {
|
||||
for (i = 0; i < 11; i++) {
|
||||
label[i] = entryData[DIR_ENTRY_name + i];
|
||||
}
|
||||
return true;
|
||||
} else if (entryData[0] == DIR_ENTRY_LAST) {
|
||||
end = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _FAT_directory_entryFromPosition (PARTITION* partition, DIR_ENTRY* entry) {
|
||||
DIR_ENTRY_POSITION entryStart = entry->dataStart;
|
||||
DIR_ENTRY_POSITION entryEnd = entry->dataEnd;
|
||||
|
@ -27,8 +27,8 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _DIRECTORY_H
|
||||
#define _DIRECTORY_H
|
||||
#ifndef __DIRECTORY_H
|
||||
#define __DIRECTORY_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -170,9 +170,4 @@ Fill in a stat struct based on a file entry
|
||||
*/
|
||||
void _FAT_directory_entryStat (PARTITION* partition, DIR_ENTRY* entry, struct stat *st);
|
||||
|
||||
/*
|
||||
Get volume label
|
||||
*/
|
||||
bool _FAT_directory_getVolumeLabel (PARTITION* partition, char *label);
|
||||
|
||||
#endif // _DIRECTORY_H
|
||||
|
@ -27,7 +27,7 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "disc.h"
|
||||
#include "disc_fat.h"
|
||||
|
||||
/*
|
||||
The list of interfaces consists of a series of name/interface pairs.
|
||||
@ -39,16 +39,15 @@ The list is terminated by a NULL/NULL entry.
|
||||
*/
|
||||
|
||||
/* ====================== Wii ====================== */
|
||||
#if defined (__wii__)
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <ogc/usbstorage.h>
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include <sdcard/gcsd.h>
|
||||
|
||||
static const DISC_INTERFACE* get_io_wiisd (void) {
|
||||
return &__io_wiisd;
|
||||
}
|
||||
static const DISC_INTERFACE* get_io_usbstorage (void) {
|
||||
return &__io_usbstorage;
|
||||
return &__io_usbstorage2;
|
||||
}
|
||||
|
||||
static const DISC_INTERFACE* get_io_gcsda (void) {
|
||||
@ -66,40 +65,3 @@ const INTERFACE_ID _FAT_disc_interfaces[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* ==================== Gamecube ==================== */
|
||||
#elif defined (__gamecube__)
|
||||
#include <sdcard/gcsd.h>
|
||||
|
||||
static const DISC_INTERFACE* get_io_gcsda (void) {
|
||||
return &__io_gcsda;
|
||||
}
|
||||
static const DISC_INTERFACE* get_io_gcsdb (void) {
|
||||
return &__io_gcsdb;
|
||||
}
|
||||
|
||||
const INTERFACE_ID _FAT_disc_interfaces[] = {
|
||||
{"carda", get_io_gcsda},
|
||||
{"cardb", get_io_gcsdb},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* ====================== NDS ====================== */
|
||||
#elif defined (NDS)
|
||||
#include <nds/arm9/dldi.h>
|
||||
|
||||
const INTERFACE_ID _FAT_disc_interfaces[] = {
|
||||
{"fat", dldiGetInternal},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* ====================== GBA ====================== */
|
||||
#elif defined (GBA)
|
||||
#include <disc.h>
|
||||
|
||||
const INTERFACE_ID _FAT_disc_interfaces[] = {
|
||||
{"fat", discGetInterface},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -2,9 +2,7 @@
|
||||
fat.h
|
||||
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
||||
|
||||
Copyright (c) 2006 - 2009
|
||||
Michael "Chishm" Chisholm
|
||||
Dave "WinterMute" Murphy
|
||||
Copyright (c) 2006 Michael "Chishm" Chisholm
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
@ -36,24 +34,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// When compiling for NDS, make sure NDS is defined
|
||||
#ifndef NDS
|
||||
#if defined ARM9 || defined ARM7
|
||||
#define NDS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__gamecube__) || defined (__wii__)
|
||||
# include <ogc/disc_io.h>
|
||||
#else
|
||||
# ifdef NDS
|
||||
# include "nds/disc_io.h"
|
||||
# else
|
||||
# include "disc_io.h"
|
||||
# endif
|
||||
#endif
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
/*
|
||||
Initialise any inserted block-devices.
|
||||
@ -85,18 +67,12 @@ cacheSize specifies the number of pages to allocate for the cache.
|
||||
This will not startup the disc, so you need to call interface->startup(); first.
|
||||
*/
|
||||
extern bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage);
|
||||
|
||||
/*
|
||||
Unmount the partition specified by name.
|
||||
If there are open files, it will attempt to synchronise them to disc.
|
||||
*/
|
||||
extern void fatUnmount (const char* name);
|
||||
|
||||
/*
|
||||
Get Volume Label
|
||||
*/
|
||||
extern void fatGetVolumeLabel (const char* name, char *label);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -37,8 +37,8 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "cache.h"
|
||||
#include "disc.h"
|
||||
#include "fat_cache.h"
|
||||
#include "disc_fat.h"
|
||||
|
||||
#include "mem_allocate.h"
|
||||
#include "bit_ops.h"
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include "fatdir.h"
|
||||
|
||||
#include "cache.h"
|
||||
#include "fat_cache.h"
|
||||
#include "file_allocation_table.h"
|
||||
#include "partition.h"
|
||||
#include "directory.h"
|
||||
|
@ -29,8 +29,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FATDIR_H
|
||||
#define _FATDIR_H
|
||||
#ifndef __FATDIR_H
|
||||
#define __FATDIR_H
|
||||
|
||||
#include <sys/reent.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cache.h"
|
||||
#include "fat_cache.h"
|
||||
#include "file_allocation_table.h"
|
||||
#include "bit_ops.h"
|
||||
#include "filetime.h"
|
||||
|
@ -27,8 +27,8 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _FAT_H
|
||||
#define _FAT_H
|
||||
#ifndef __FAT_H
|
||||
#define __FAT_H
|
||||
|
||||
#include "common.h"
|
||||
#include "partition.h"
|
||||
|
@ -26,8 +26,8 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _FILETIME_H
|
||||
#define _FILETIME_H
|
||||
#ifndef __FILETIME_H
|
||||
#define __FILETIME_H
|
||||
|
||||
#include "common.h"
|
||||
#include <sys/types.h>
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "fatdir.h"
|
||||
#include "lock.h"
|
||||
#include "mem_allocate.h"
|
||||
#include "disc.h"
|
||||
#include "disc_fat.h"
|
||||
|
||||
static const devoptab_t dotab_fat = {
|
||||
"fat",
|
||||
@ -69,17 +69,17 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
|
||||
devoptab_t* devops;
|
||||
char* nameCopy;
|
||||
|
||||
if(!name || !interface)
|
||||
return false;
|
||||
|
||||
if(!interface->startup())
|
||||
return false;
|
||||
|
||||
if(!interface->isInserted())
|
||||
if(!interface->isInserted()) {
|
||||
interface->shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
devops = _FAT_mem_allocate (sizeof(devoptab_t) + strlen(name) + 1);
|
||||
if (!devops) {
|
||||
interface->shutdown();
|
||||
return false;
|
||||
}
|
||||
// Use the space allocated at the end of the devoptab struct for storing the name
|
||||
@ -89,6 +89,7 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
|
||||
partition = _FAT_partition_constructor (interface, cacheSize, SectorsPerPage, startSector);
|
||||
if (!partition) {
|
||||
_FAT_mem_free (devops);
|
||||
interface->shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -110,9 +111,7 @@ bool fatMountSimple (const char* name, const DISC_INTERFACE* interface) {
|
||||
void fatUnmount (const char* name) {
|
||||
devoptab_t *devops;
|
||||
PARTITION* partition;
|
||||
|
||||
if(!name)
|
||||
return;
|
||||
const DISC_INTERFACE *disc;
|
||||
|
||||
devops = (devoptab_t*)GetDeviceOpTab (name);
|
||||
if (!devops) {
|
||||
@ -129,8 +128,10 @@ void fatUnmount (const char* name) {
|
||||
}
|
||||
|
||||
partition = (PARTITION*)devops->deviceData;
|
||||
disc = partition->disc;
|
||||
_FAT_partition_destructor (partition);
|
||||
_FAT_mem_free (devops);
|
||||
disc->shutdown();
|
||||
}
|
||||
|
||||
bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) {
|
||||
@ -193,49 +194,4 @@ bool fatInitDefault (void) {
|
||||
return fatInit (DEFAULT_CACHE_PAGES, true);
|
||||
}
|
||||
|
||||
void fatGetVolumeLabel (const char* name, char *label) {
|
||||
devoptab_t *devops;
|
||||
PARTITION* partition;
|
||||
char *buf;
|
||||
int namelen,i;
|
||||
|
||||
if(!name || !label)
|
||||
return;
|
||||
|
||||
namelen = strlen(name);
|
||||
buf=(char*)_FAT_mem_allocate(sizeof(char)*namelen+2);
|
||||
strcpy(buf,name);
|
||||
|
||||
if (name[namelen-1] == '/') {
|
||||
buf[namelen-1]='\0';
|
||||
namelen--;
|
||||
}
|
||||
|
||||
if (name[namelen-1] != ':') {
|
||||
buf[namelen]=':';
|
||||
buf[namelen+1]='\0';
|
||||
}
|
||||
|
||||
devops = (devoptab_t*)GetDeviceOpTab(buf);
|
||||
|
||||
for(i=0;buf[i]!='\0' && buf[i]!=':';i++);
|
||||
if (!devops || strncasecmp(buf,devops->name,i)) {
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
// Perform a quick check to make sure we're dealing with a libfat controlled device
|
||||
if (devops->open_r != dotab_fat.open_r) {
|
||||
return;
|
||||
}
|
||||
|
||||
partition = (PARTITION*)devops->deviceData;
|
||||
|
||||
if(!_FAT_directory_getVolumeLabel(partition, label)) {
|
||||
strncpy(label,partition->label,11);
|
||||
label[11]='\0';
|
||||
}
|
||||
if(!strncmp(label, "NO NAME", 7)) label[0]='\0';
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _LOCK_H
|
||||
#define _LOCK_H
|
||||
#ifndef __LOCK_H
|
||||
#define __LOCK_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -28,8 +28,8 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _MEM_ALLOCATE_H
|
||||
#define _MEM_ALLOCATE_H
|
||||
#ifndef __MEM_ALLOCATE_H_
|
||||
#define __MEM_ALLOCATE_H_
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
@ -38,6 +38,7 @@ static inline void* _FAT_mem_allocate (size_t size) {
|
||||
}
|
||||
|
||||
static inline void* _FAT_mem_align (size_t size) {
|
||||
|
||||
return memalign (32, size);
|
||||
}
|
||||
|
||||
|
@ -205,16 +205,10 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Init the partition lock
|
||||
_FAT_lock_init(&partition->lock);
|
||||
|
||||
_FAT_startSector = startSector;
|
||||
|
||||
if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)))
|
||||
strncpy(partition->label, (char*)(sectorBuffer + BPB_FAT16_volumeLabel), 11);
|
||||
else
|
||||
strncpy(partition->label, (char*)(sectorBuffer + BPB_FAT32_volumeLabel), 11);
|
||||
partition->label[11] = '\0';
|
||||
// Init the partition lock
|
||||
_FAT_lock_init(&partition->lock);
|
||||
|
||||
// Set partition's disc interface
|
||||
partition->disc = disc;
|
||||
|
@ -27,11 +27,11 @@
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
#ifndef __PARTITION_H
|
||||
#define __PARTITION_H
|
||||
|
||||
#include "common.h"
|
||||
#include "cache.h"
|
||||
#include "fat_cache.h"
|
||||
#include "lock.h"
|
||||
|
||||
// Device name
|
||||
@ -67,7 +67,6 @@ typedef struct {
|
||||
struct _FILE_STRUCT* firstOpenFile; // The start of a linked list of files
|
||||
mutex_t lock; // A lock for partition operations
|
||||
bool readOnly; // If this is set, then do not try writing to the disc
|
||||
char label[12]; // Volume label
|
||||
} PARTITION;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user