mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-25 19:36:52 +01:00
add libogc port and nitroFS support
This commit is contained in:
parent
5b9bfaecf0
commit
46df48ba21
@ -57,12 +57,17 @@ extern "C" {
|
||||
# include <nds/ndstypes.h>
|
||||
# else
|
||||
# include "gba_types.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef NDS
|
||||
typedef enum {PI_DEFAULT, PI_SLOT_1, PI_SLOT_2, PI_CUSTOM} PARTITION_INTERFACE;
|
||||
#else
|
||||
typedef enum {PI_CART_SLOT} PARTITION_INTERFACE;
|
||||
#if defined( __wii__ )
|
||||
typedef enum {PI_DEFAULT, PI_SDGECKO_A, PI_SDGECKO_B, PI_INTERNAL_SD, PI_CUSTOM, PI_MAX_PARTITIONS } PARTITION_INTERFACE;
|
||||
#elif defined(__gamecube__)
|
||||
typedef enum {PI_DEFAULT, PI_SDGECKO_A, PI_SDGECKO_B, PI_CUSTOM, PI_MAX_PARTITIONS } PARTITION_INTERFACE;
|
||||
#elif defined(NDS)
|
||||
typedef enum {PI_DEFAULT, PI_SLOT_1, PI_SLOT_2, PI_CUSTOM, PI_MAX_PARTITIONS} PARTITION_INTERFACE;
|
||||
#elif defined(GBA)
|
||||
typedef enum {PI_CART_SLOT, PI_MAX_PARTITIONS} PARTITION_INTERFACE;
|
||||
#endif
|
||||
|
||||
struct IO_INTERFACE_STRUCT ;
|
||||
|
@ -1 +1 @@
|
||||
<Project name="libfat"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="source" path="source\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="disc_io" path="disc_io\"><File path="io_cf_common.c"></File><File path="io_cf_common.h"></File><File path="io_dldi.h"></File><File path="io_efa2.c"></File><File path="io_efa2.h"></File><File path="io_fcsr.c"></File><File path="io_fcsr.h"></File><File path="io_m3cf.c"></File><File path="io_m3cf.h"></File><File path="io_m3sd.c"></File><File path="io_m3sd.h"></File><File path="io_m3_common.c"></File><File path="io_m3_common.h"></File><File path="io_mpcf.c"></File><File path="io_mpcf.h"></File><File path="io_njsd.c"></File><File path="io_njsd.h"></File><File path="io_nmmc.c"></File><File path="io_nmmc.h"></File><File path="io_sccf.c"></File><File path="io_sccf.h"></File><File path="io_scsd.c"></File><File path="io_scsd.h"></File><File path="io_sc_common.c"></File><File path="io_sc_common.h"></File><File path="io_sd_common.c"></File><File path="io_sd_common.h"></File></MagicFolder><File path="bit_ops.h"></File><File path="cache.c"></File><File path="cache.h"></File><File path="common.h"></File><File path="directory.c"></File><File path="directory.h"></File><File path="disc.c"></File><File path="disc.h"></File><File path="fatdir.c"></File><File path="fatdir.h"></File><File path="fatfile.c"></File><File path="fatfile.h"></File><File path="filetime.c"></File><File path="filetime.h"></File><File path="file_allocation_table.c"></File><File path="file_allocation_table.h"></File><File path="libfat.c"></File><File path="mem_allocate.h"></File><File path="partition.c"></File><File path="partition.h"></File></MagicFolder><Folder name="nds"><Folder name="include"><File path="nds\include\fat.h"></File></Folder><File path="nds\Makefile"></File></Folder><Folder name="libogc"><Folder name="include"><File path="libogc\include\fat.h"></File></Folder><File path="libogc\Makefile"></File></Folder><Folder name="gba"><Folder name="include"><File path="gba\include\fat.h"></File></Folder><File path="gba\Makefile"></File></Folder><File path="Makefile"></File></Project>
|
||||
<Project name="libfat"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="source" path="source\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="disc_io" path="disc_io\"><File path="disc.c"></File><File path="io_cf_common.c"></File><File path="io_cf_common.h"></File><File path="io_dldi.h"></File><File path="io_efa2.c"></File><File path="io_efa2.h"></File><File path="io_fcsr.c"></File><File path="io_fcsr.h"></File><File path="io_m3cf.c"></File><File path="io_m3cf.h"></File><File path="io_m3sd.c"></File><File path="io_m3sd.h"></File><File path="io_m3_common.c"></File><File path="io_m3_common.h"></File><File path="io_mpcf.c"></File><File path="io_mpcf.h"></File><File path="io_njsd.c"></File><File path="io_njsd.h"></File><File path="io_nmmc.c"></File><File path="io_nmmc.h"></File><File path="io_sccf.c"></File><File path="io_sccf.h"></File><File path="io_scsd.c"></File><File path="io_scsd.h"></File><File path="io_sc_common.c"></File><File path="io_sc_common.h"></File><File path="io_sd_common.c"></File><File path="io_sd_common.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="ogc_io" path="ogc_io\"><File path="disc.c"></File><File path="gcsd.c"></File><File path="gcsd.h"></File><File path="wiisd.c"></File><File path="wiisd.h"></File></MagicFolder><File path="bit_ops.h"></File><File path="cache.c"></File><File path="cache.h"></File><File path="common.h"></File><File path="directory.c"></File><File path="directory.h"></File><File path="disc.h"></File><File path="fatdir.c"></File><File path="fatdir.h"></File><File path="fatfile.c"></File><File path="fatfile.h"></File><File path="filetime.c"></File><File path="filetime.h"></File><File path="file_allocation_table.c"></File><File path="file_allocation_table.h"></File><File path="libfat.c"></File><File path="mem_allocate.h"></File><File path="partition.c"></File><File path="partition.h"></File></MagicFolder><Folder name="nds"><Folder name="include"><File path="nds\include\fat.h"></File><File path="nds\include\nitrofs.h"></File></Folder><Folder name="source"><File path="nds\source\nitrofs.c"></File></Folder><File path="nds\Makefile"></File></Folder><Folder name="libogc"><Folder name="include"><File path="libogc\include\fat.h"></File></Folder><File path="libogc\Makefile"></File></Folder><Folder name="gba"><Folder name="include"><File path="gba\include\fat.h"></File></Folder><File path="gba\Makefile"></File></Folder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"><File path="fat.h"></File></MagicFolder><File path="Makefile"></File></Project>
|
@ -22,7 +22,7 @@ endif
|
||||
# all directories are relative to this makefile
|
||||
#---------------------------------------------------------------------------------
|
||||
BUILD ?= wii_release
|
||||
SOURCES := ../source source
|
||||
SOURCES := ../source ../source/ogc_io
|
||||
INCLUDES := ../include
|
||||
DATA :=
|
||||
LIBDIR := $(TOPDIR)/libogc/lib
|
||||
|
@ -37,7 +37,11 @@ extern "C" {
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
typedef enum {PI_CART_SLOT} PARTITION_INTERFACE;
|
||||
#if defined(__wii__)
|
||||
typedef enum {PI_DEFAULT, PI_SDGECKO_A, PI_SDGECKO_B, PI_INTERNAL_SD, PI_CUSTOM } PARTITION_INTERFACE;
|
||||
#else
|
||||
typedef enum {PI_DEFAULT, PI_SDGECKO_A, PI_SDGECKO_B, PI_CUSTOM } PARTITION_INTERFACE;
|
||||
#endif
|
||||
|
||||
struct IO_INTERFACE_STRUCT ;
|
||||
|
||||
|
@ -16,7 +16,7 @@ include $(DEVKITARM)/ds_rules
|
||||
# all directories are relative to this makefile
|
||||
#---------------------------------------------------------------------------------
|
||||
BUILD ?= release
|
||||
SOURCES := ../source ../source/disc_io
|
||||
SOURCES := ../source ../source/disc_io source
|
||||
INCLUDES := ../include
|
||||
DATA :=
|
||||
LIB := $(TOPDIR)/nds/lib
|
||||
@ -104,7 +104,7 @@ dist-bin:
|
||||
|
||||
install:
|
||||
cp lib/libfat.a $(DEVKITPRO)/libnds/lib
|
||||
cp include/fat.h $(DEVKITPRO)/libnds/include
|
||||
cp include/fat.h include/nitrofs.h $(DEVKITPRO)/libnds/include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
@ -40,7 +40,7 @@ extern "C" {
|
||||
#define NDS
|
||||
#endif
|
||||
|
||||
#include <nds/jtypes.h>
|
||||
#include <nds/ndstypes.h>
|
||||
|
||||
typedef enum {PI_DEFAULT, PI_SLOT_1, PI_SLOT_2, PI_CUSTOM} PARTITION_INTERFACE;
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "cache.h"
|
||||
#include "disc_io/disc.h"
|
||||
#include "disc.h"
|
||||
|
||||
#include "mem_allocate.h"
|
||||
#include "bit_ops.h"
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define _CACHE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "disc_io/disc_io.h"
|
||||
#include "disc.h"
|
||||
|
||||
#define CACHE_PAGE_SIZE BYTES_PER_READ
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#else
|
||||
# ifdef NDS
|
||||
#include <nds/ndstypes.h>
|
||||
#include <nds/system.h>
|
||||
|
||||
# else
|
||||
#include "gba_types.h"
|
||||
# endif
|
||||
@ -55,4 +57,6 @@
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#include <fat.h>
|
||||
|
||||
#endif // _COMMON_H
|
||||
|
@ -33,32 +33,67 @@
|
||||
#ifndef _DISC_H
|
||||
#define _DISC_H
|
||||
|
||||
#include "../common.h"
|
||||
#include "disc_io.h"
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
Search for a block based device in the GBA slot.
|
||||
Return a pointer to a usable interface if one is found,
|
||||
NULL if not.
|
||||
*/
|
||||
extern const IO_INTERFACE* _FAT_disc_gbaSlotFindInterface (void);
|
||||
//----------------------------------------------------------------------
|
||||
// Customisable features
|
||||
|
||||
/*
|
||||
Search for a block based device in the DS slot.
|
||||
Return a pointer to a usable interface if one is found,
|
||||
NULL if not.
|
||||
*/
|
||||
#ifdef NDS
|
||||
extern const IO_INTERFACE* _FAT_disc_dsSlotFindInterface (void);
|
||||
// Use DMA to read the card, remove this line to use normal reads/writes
|
||||
// #define _IO_USE_DMA
|
||||
|
||||
// Allow buffers not alligned to 16 bits when reading files.
|
||||
// Note that this will slow down access speed, so only use if you have to.
|
||||
// It is also incompatible with DMA
|
||||
#define _IO_ALLOW_UNALIGNED
|
||||
|
||||
#if defined _IO_USE_DMA && defined _IO_ALLOW_UNALIGNED
|
||||
#error "You can't use both DMA and unaligned memory"
|
||||
#endif
|
||||
|
||||
#define DEVICE_TYPE_WII 0
|
||||
#define DEVICE_TYPE_GC 1
|
||||
|
||||
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
||||
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
||||
#define FEATURE_SLOT_GBA 0x00000010
|
||||
#define FEATURE_SLOT_NDS 0x00000020
|
||||
#define FEATURE_GAMECUBE_SLOTA 0x00000010
|
||||
#define FEATURE_GAMECUBE_SLOTB 0x00000020
|
||||
|
||||
typedef bool (* FN_MEDIUM_STARTUP)(void) ;
|
||||
typedef bool (* FN_MEDIUM_ISINSERTED)(void) ;
|
||||
typedef bool (* FN_MEDIUM_READSECTORS)(u32 sector, u32 numSectors, void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_WRITESECTORS)(u32 sector, u32 numSectors, const void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ;
|
||||
typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ;
|
||||
|
||||
struct IO_INTERFACE_STRUCT {
|
||||
unsigned long ioType ;
|
||||
unsigned long features ;
|
||||
FN_MEDIUM_STARTUP fn_startup ;
|
||||
FN_MEDIUM_ISINSERTED fn_isInserted ;
|
||||
FN_MEDIUM_READSECTORS fn_readSectors ;
|
||||
FN_MEDIUM_WRITESECTORS fn_writeSectors ;
|
||||
FN_MEDIUM_CLEARSTATUS fn_clearStatus ;
|
||||
FN_MEDIUM_SHUTDOWN fn_shutdown ;
|
||||
} ;
|
||||
|
||||
typedef struct IO_INTERFACE_STRUCT IO_INTERFACE ;
|
||||
|
||||
/*
|
||||
Search for a block based device in the both slots.
|
||||
Search for a block based device in all available slots.
|
||||
Return a pointer to a usable interface if one is found,
|
||||
NULL if not.
|
||||
*/
|
||||
extern const IO_INTERFACE* _FAT_disc_findInterface (void);
|
||||
|
||||
/*
|
||||
Search for a block based device in a specific slot.
|
||||
Return a pointer to a usable interface if one is found,
|
||||
NULL if not.
|
||||
*/
|
||||
extern const IO_INTERFACE* _FAT_disc_findInterfaceSlot (PARTITION_INTERFACE partitionNumber);
|
||||
|
||||
/*
|
||||
Check if a disc is inserted
|
||||
Return true if a disc is inserted and ready, false otherwise
|
@ -73,13 +73,13 @@
|
||||
* Removed FCSR
|
||||
*/
|
||||
|
||||
#include "disc.h"
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
#ifdef NDS
|
||||
#include <nds.h>
|
||||
#endif
|
||||
|
||||
#include <fat.h>
|
||||
|
||||
// Include known io-interfaces:
|
||||
#include "io_dldi.h"
|
||||
@ -182,3 +182,29 @@ const IO_INTERFACE* _FAT_disc_findInterface (void)
|
||||
return _FAT_disc_gbaSlotFindInterface();
|
||||
}
|
||||
#endif
|
||||
|
||||
const IO_INTERFACE* _FAT_disc_findInterfaceSlot (PARTITION_INTERFACE partitionNumber)
|
||||
{
|
||||
|
||||
#ifdef NDS
|
||||
switch (partitionNumber) {
|
||||
case PI_SLOT_1:
|
||||
// Mount the disc in slot 1
|
||||
return _FAT_disc_dsSlotFindInterface ();
|
||||
break;
|
||||
case PI_SLOT_2:
|
||||
// Mount the disc in slot 2
|
||||
return _FAT_disc_gbaSlotFindInterface ();
|
||||
break;
|
||||
case PI_DEFAULT:
|
||||
case PI_CUSTOM:
|
||||
default:
|
||||
// Anything else has to be handled specially
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
return _FAT_disc_gbaSlotFindInterface ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
disc_io.h
|
||||
Interface template for low level disc functions.
|
||||
|
||||
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:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
2006-07-11 - Chishm
|
||||
* Original release
|
||||
|
||||
2006-07-16 - Chishm
|
||||
* Renamed _CF_USE_DMA to _IO_USE_DMA
|
||||
* Renamed _CF_ALLOW_UNALIGNED to _IO_ALLOW_UNALIGNED
|
||||
*/
|
||||
|
||||
#ifndef _DISC_IO_H
|
||||
#define _DISC_IO_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Customisable features
|
||||
|
||||
// Use DMA to read the card, remove this line to use normal reads/writes
|
||||
// #define _IO_USE_DMA
|
||||
|
||||
// Allow buffers not alligned to 16 bits when reading files.
|
||||
// Note that this will slow down access speed, so only use if you have to.
|
||||
// It is also incompatible with DMA
|
||||
#define _IO_ALLOW_UNALIGNED
|
||||
|
||||
#if defined _IO_USE_DMA && defined _IO_ALLOW_UNALIGNED
|
||||
#error "You can't use both DMA and unaligned memory"
|
||||
#endif
|
||||
|
||||
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
||||
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
||||
#define FEATURE_SLOT_GBA 0x00000010
|
||||
#define FEATURE_SLOT_NDS 0x00000020
|
||||
|
||||
typedef bool (* FN_MEDIUM_STARTUP)(void) ;
|
||||
typedef bool (* FN_MEDIUM_ISINSERTED)(void) ;
|
||||
typedef bool (* FN_MEDIUM_READSECTORS)(u32 sector, u32 numSectors, void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_WRITESECTORS)(u32 sector, u32 numSectors, const void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ;
|
||||
typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ;
|
||||
|
||||
struct IO_INTERFACE_STRUCT {
|
||||
unsigned long ioType ;
|
||||
unsigned long features ;
|
||||
FN_MEDIUM_STARTUP fn_startup ;
|
||||
FN_MEDIUM_ISINSERTED fn_isInserted ;
|
||||
FN_MEDIUM_READSECTORS fn_readSectors ;
|
||||
FN_MEDIUM_WRITESECTORS fn_writeSectors ;
|
||||
FN_MEDIUM_CLEARSTATUS fn_clearStatus ;
|
||||
FN_MEDIUM_SHUTDOWN fn_shutdown ;
|
||||
} ;
|
||||
|
||||
typedef struct IO_INTERFACE_STRUCT IO_INTERFACE ;
|
||||
|
||||
#endif // define _DISC_IO_H
|
@ -38,7 +38,7 @@
|
||||
#ifndef IO_CF_COMMON_H
|
||||
#define IO_CF_COMMON_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
typedef struct {
|
||||
vu16* data;
|
||||
|
@ -36,7 +36,7 @@
|
||||
// 'DLDI'
|
||||
#define DEVICE_TYPE_DLDI 0x49444C44
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_dldi ;
|
||||
|
@ -15,7 +15,7 @@
|
||||
// 'EFA2'
|
||||
#define DEVICE_TYPE_EFA2 0x32414645
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_efa2;
|
||||
|
@ -36,7 +36,7 @@
|
||||
// 'FCSR'
|
||||
#define DEVICE_TYPE_FCSR 0x52534346
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_fcsr ;
|
||||
|
@ -36,7 +36,7 @@
|
||||
#ifndef IO_M3_COMMON_H
|
||||
#define IO_M3_COMMON_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// Values for changing mode
|
||||
#define M3_MODE_ROM 0x00400004
|
||||
|
@ -37,7 +37,7 @@
|
||||
// 'M3CF'
|
||||
#define DEVICE_TYPE_M3CF 0x4643334D
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_m3cf ;
|
||||
|
@ -40,7 +40,7 @@
|
||||
// 'M3SD'
|
||||
#define DEVICE_TYPE_M3SD 0x4453334D
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_m3sd ;
|
||||
|
@ -37,7 +37,7 @@
|
||||
// 'MPCF'
|
||||
#define DEVICE_TYPE_MPCF 0x4643504D
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_mpcf ;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#ifndef IO_NJSD_H
|
||||
#define IO_NJSD_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
#ifdef NDS
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#ifndef IO_NMMC_H
|
||||
#define IO_NMMC_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
#ifdef NDS
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#ifndef IO_SC_COMMON_H
|
||||
#define IO_SC_COMMON_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// Values for changing mode
|
||||
#define SC_MODE_FLASH 0x1510
|
||||
|
@ -37,7 +37,7 @@
|
||||
// 'SCCF'
|
||||
#define DEVICE_TYPE_SCCF 0x46434353
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_sccf;
|
||||
|
@ -40,7 +40,7 @@
|
||||
// 'SCSD'
|
||||
#define DEVICE_TYPE_SCSD 0x44534353
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
// export interface
|
||||
extern const IO_INTERFACE _io_scsd ;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#ifndef IO_SD_COMMON_H
|
||||
#define IO_SD_COMMON_H
|
||||
|
||||
#include "disc_io.h"
|
||||
#include "../disc.h"
|
||||
|
||||
/* SD commands */
|
||||
#define GO_IDLE_STATE 0
|
||||
|
@ -46,15 +46,18 @@
|
||||
|
||||
#include <sys/iosupport.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "partition.h"
|
||||
#include "fatfile.h"
|
||||
#include "fatdir.h"
|
||||
|
||||
#define GBA_DEFAULT_CACHE_PAGES 2
|
||||
#define NDS_DEFAULT_CACHE_PAGES 8
|
||||
|
||||
#ifdef GBA
|
||||
#define DEFAULT_CACHE_PAGES 2
|
||||
#else
|
||||
#define DEFAULT_CACHE_PAGES 8
|
||||
#endif
|
||||
|
||||
const devoptab_t dotab_fat = {
|
||||
"fat",
|
||||
@ -80,50 +83,52 @@ const devoptab_t dotab_fat = {
|
||||
};
|
||||
|
||||
bool fatInit (u32 cacheSize, bool setAsDefaultDevice) {
|
||||
#ifdef NDS
|
||||
bool slot1Device, slot2Device;
|
||||
|
||||
// Try mounting both slots
|
||||
slot1Device = _FAT_partition_mount (PI_SLOT_1, cacheSize);
|
||||
slot2Device = _FAT_partition_mount (PI_SLOT_2, cacheSize);
|
||||
int i;
|
||||
bool device = false, setDefault = false;
|
||||
|
||||
if ( PI_MAX_PARTITIONS == 1 ) {
|
||||
if ( _FAT_partition_mount ( 0 , cacheSize) ) {
|
||||
_FAT_partition_setDefaultInterface (0);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Choose the default device
|
||||
if (slot1Device) {
|
||||
_FAT_partition_setDefaultInterface (PI_SLOT_1);
|
||||
} else if (slot2Device) {
|
||||
_FAT_partition_setDefaultInterface (PI_SLOT_2);
|
||||
} else {
|
||||
return false;
|
||||
|
||||
for ( i = 1; i < PI_MAX_PARTITIONS; i++ ) {
|
||||
device = _FAT_partition_mount ( i , cacheSize);
|
||||
if ( device && !setDefault ) {
|
||||
_FAT_partition_setDefaultInterface (i);
|
||||
setDefault = true;
|
||||
}
|
||||
}
|
||||
if ( !setDefault ) return false;
|
||||
}
|
||||
|
||||
#else // not defined NDS
|
||||
bool cartSlotDevice;
|
||||
|
||||
cartSlotDevice = _FAT_partition_mount (PI_CART_SLOT, cacheSize);
|
||||
|
||||
if (cartSlotDevice) {
|
||||
_FAT_partition_setDefaultInterface (PI_CART_SLOT);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // defined NDS
|
||||
|
||||
AddDevice (&dotab_fat);
|
||||
|
||||
if (setAsDefaultDevice) {
|
||||
chdir ("fat:/");
|
||||
char filePath[MAXPATHLEN * 2] = "fat:/";
|
||||
#ifndef GBA
|
||||
if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 ) {
|
||||
char ch, *ptr = filePath, *lastSlash = NULL;
|
||||
strcpy(filePath, __system_argv->argv[0]);
|
||||
do {
|
||||
ch = *(ptr);
|
||||
if (ch == '/') lastSlash=ptr;
|
||||
ptr++;
|
||||
} while (ch);
|
||||
if ( NULL != lastSlash) *lastSlash = 0;
|
||||
}
|
||||
#endif
|
||||
chdir (filePath);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool fatInitDefault (void) {
|
||||
#ifdef NDS
|
||||
return fatInit (NDS_DEFAULT_CACHE_PAGES, true);
|
||||
#else
|
||||
return fatInit (GBA_DEFAULT_CACHE_PAGES, true);
|
||||
#endif
|
||||
return fatInit (DEFAULT_CACHE_PAGES, true);
|
||||
}
|
||||
|
||||
bool fatMountNormalInterface (PARTITION_INTERFACE partitionNumber, u32 cacheSize) {
|
||||
|
170
source/ogc_io/disc.c
Normal file
170
source/ogc_io/disc.c
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
|
||||
disc.c
|
||||
|
||||
uniformed io-interface to work with Chishm's FAT library
|
||||
|
||||
Written by MightyMax
|
||||
|
||||
|
||||
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:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
2005-11-06 - Chishm
|
||||
* Added WAIT_CR modifications for NDS
|
||||
|
||||
2006-02-03 www.neoflash.com
|
||||
* Added SUPPORT_* defines, comment out any of the SUPPORT_* defines in disc_io.h to remove support
|
||||
for the given interface and stop code being linked to the binary
|
||||
|
||||
* Added support for MK2 MMC interface
|
||||
|
||||
* Added disc_Cache* functions
|
||||
|
||||
2006-02-05 - Chishm
|
||||
* Added Supercard SD support
|
||||
|
||||
2006-02-26 - Cytex
|
||||
* Added EFA2 support
|
||||
|
||||
2006-05-18 - Chishm
|
||||
* Rewritten for FATlib disc.c
|
||||
|
||||
2006-06-19 - Chishm
|
||||
* Changed read and write interface to accept a u32 instead of a u8 for the number of sectors
|
||||
|
||||
2006-07-11 - Chishm
|
||||
* Removed disc_Cache* functions, since there is now a proper unified cache
|
||||
* Removed SUPPORT_* defines
|
||||
* Rewrote device detection functions
|
||||
* First libfat release
|
||||
|
||||
2006-07-25 - Chishm
|
||||
* Changed IO_INTERFACEs to const
|
||||
|
||||
2006-08-02 - Chishm
|
||||
* Added NinjaDS
|
||||
|
||||
2006-12-25 - Chishm
|
||||
* Added DLDI
|
||||
* Removed experimental interfaces
|
||||
|
||||
2007-05-01 - Chishm
|
||||
* Removed FCSR
|
||||
*/
|
||||
|
||||
#include "../disc.h"
|
||||
#include "wiisd.h"
|
||||
#include "gcsd.h"
|
||||
|
||||
|
||||
const IO_INTERFACE* ioInterfaces[] = {
|
||||
&__io_gcsda,
|
||||
&__io_gcsdb,
|
||||
#ifdef __wii__
|
||||
&__io_wiisd
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __wii__
|
||||
const IO_INTERFACE* _FAT_disc_wiiFindInterface(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
|
||||
if ((ioInterfaces[i]->ioType == DEVICE_TYPE_WII) && (ioInterfaces[i]->fn_startup())) {
|
||||
return ioInterfaces[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
const IO_INTERFACE* _FAT_disc_gcFindInterface(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
|
||||
if ((ioInterfaces[i]->ioType == DEVICE_TYPE_GC) && (ioInterfaces[i]->fn_startup())) {
|
||||
return ioInterfaces[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const IO_INTERFACE* _FAT_disc_gcFindInterfaceSlot(int slot)
|
||||
{
|
||||
int i;
|
||||
int mask;
|
||||
|
||||
if(slot == 0)
|
||||
mask = FEATURE_GAMECUBE_SLOTA;
|
||||
else if(slot == 1)
|
||||
mask = FEATURE_GAMECUBE_SLOTB;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
|
||||
if ((ioInterfaces[i]->ioType == DEVICE_TYPE_GC) && (ioInterfaces[i]->features & mask) && (ioInterfaces[i]->fn_startup())) {
|
||||
return ioInterfaces[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const IO_INTERFACE* _FAT_disc_findInterface(void)
|
||||
{
|
||||
#ifdef __wii__
|
||||
const IO_INTERFACE *disc;
|
||||
|
||||
disc = _FAT_disc_wiiFindInterface();
|
||||
if(disc == NULL)
|
||||
disc = _FAT_disc_gcFindInterface();
|
||||
return disc;
|
||||
#else
|
||||
return _FAT_disc_gcFindInterface();
|
||||
#endif
|
||||
}
|
||||
|
||||
const IO_INTERFACE* _FAT_disc_findInterfaceSlot (PARTITION_INTERFACE partitionNumber)
|
||||
{
|
||||
switch(partitionNumber)
|
||||
{
|
||||
case PI_SDGECKO_A:
|
||||
return _FAT_disc_gcFindInterfaceSlot(0);
|
||||
break;
|
||||
case PI_SDGECKO_B:
|
||||
return _FAT_disc_gcFindInterfaceSlot(1);
|
||||
break;
|
||||
#ifdef __wii__
|
||||
case PI_INTERNAL_SD:
|
||||
return _FAT_disc_wiiFindInterface();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
}
|
187
source/ogc_io/gcsd.c
Normal file
187
source/ogc_io/gcsd.c
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
|
||||
gcsd.h
|
||||
|
||||
Hardware routines for reading and writing to SD geckos connected
|
||||
to the memory card ports.
|
||||
|
||||
These functions are just wrappers around libsdcard's functions.
|
||||
|
||||
Copyright (c) 2008 Sven "svpe" Peter <svpe@gmx.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gcsd.h"
|
||||
|
||||
#include <sdcard/card_cmn.h>
|
||||
#include <sdcard/card_io.h>
|
||||
#include <sdcard/card_buf.h>
|
||||
|
||||
static int __gcsd_init = 0;
|
||||
|
||||
bool __gcsd_isInserted(int n)
|
||||
{
|
||||
if(sdgecko_readStatus(n) == CARDIO_ERROR_NOCARD)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __gcsd_startup(int n)
|
||||
{
|
||||
if(__gcsd_init == 1)
|
||||
return __gcsd_isInserted(n);
|
||||
sdgecko_initBufferPool();
|
||||
sdgecko_initIODefault();
|
||||
__gcsd_init = 1;
|
||||
return __gcsd_isInserted(n);
|
||||
}
|
||||
|
||||
|
||||
bool __gcsd_readSectors(int n, u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
s32 i;
|
||||
s32 ret;
|
||||
|
||||
for(i = 0; i < numSectors; i++)
|
||||
{
|
||||
ret = sdgecko_readSector(n, sector + i, buffer + (i * 512), 512);
|
||||
if(ret != CARDIO_ERROR_READY)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ret == CARDIO_ERROR_READY)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool __gcsd_writeSectors(int n, u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
s32 i;
|
||||
s32 ret;
|
||||
|
||||
for(i = 0; i < numSectors; i++)
|
||||
{
|
||||
ret = sdgecko_writeSector(n, sector + i, buffer + (i * 512), 512);
|
||||
if(ret != CARDIO_ERROR_READY)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ret == CARDIO_ERROR_READY)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool __gcsd_clearStatus(int n)
|
||||
{
|
||||
return true; // FIXME
|
||||
}
|
||||
|
||||
bool __gcsd_shutdown(int n)
|
||||
{
|
||||
sdgecko_doUnmount(n);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool __gcsda_startup(void)
|
||||
{
|
||||
return __gcsd_startup(0);
|
||||
}
|
||||
|
||||
bool __gcsda_isInserted(void)
|
||||
{
|
||||
return __gcsd_isInserted(0);
|
||||
}
|
||||
|
||||
bool __gcsda_readSectors(u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
return __gcsd_readSectors(0, sector, numSectors, buffer);
|
||||
}
|
||||
|
||||
bool __gcsda_writeSectors(u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
return __gcsd_writeSectors(0, sector, numSectors, buffer);
|
||||
}
|
||||
|
||||
bool __gcsda_clearStatus(void)
|
||||
{
|
||||
return __gcsd_clearStatus(0);
|
||||
}
|
||||
|
||||
bool __gcsda_shutdown(void)
|
||||
{
|
||||
return __gcsd_shutdown(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool __gcsdb_startup(void)
|
||||
{
|
||||
return __gcsd_startup(1);
|
||||
}
|
||||
|
||||
bool __gcsdb_isInserted(void)
|
||||
{
|
||||
return __gcsd_isInserted(1);
|
||||
}
|
||||
|
||||
bool __gcsdb_readSectors(u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
return __gcsd_readSectors(1, sector, numSectors, buffer);
|
||||
}
|
||||
|
||||
bool __gcsdb_writeSectors(u32 sector, u32 numSectors, void *buffer)
|
||||
{
|
||||
return __gcsd_writeSectors(1, sector, numSectors, buffer);
|
||||
}
|
||||
|
||||
bool __gcsdb_clearStatus(void)
|
||||
{
|
||||
return __gcsd_clearStatus(1);
|
||||
}
|
||||
|
||||
bool __gcsdb_shutdown(void)
|
||||
{
|
||||
return __gcsd_shutdown(1);
|
||||
}
|
||||
|
||||
const IO_INTERFACE __io_gcsda = {
|
||||
DEVICE_TYPE_GC,
|
||||
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTA,
|
||||
(FN_MEDIUM_STARTUP)&__gcsda_startup,
|
||||
(FN_MEDIUM_ISINSERTED)&__gcsda_isInserted,
|
||||
(FN_MEDIUM_READSECTORS)&__gcsda_readSectors,
|
||||
(FN_MEDIUM_WRITESECTORS)&__gcsda_writeSectors,
|
||||
(FN_MEDIUM_CLEARSTATUS)&__gcsda_clearStatus,
|
||||
(FN_MEDIUM_SHUTDOWN)&__gcsda_shutdown
|
||||
} ;
|
||||
const IO_INTERFACE __io_gcsdb = {
|
||||
DEVICE_TYPE_GC,
|
||||
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTB,
|
||||
(FN_MEDIUM_STARTUP)&__gcsdb_startup,
|
||||
(FN_MEDIUM_ISINSERTED)&__gcsdb_isInserted,
|
||||
(FN_MEDIUM_READSECTORS)&__gcsdb_readSectors,
|
||||
(FN_MEDIUM_WRITESECTORS)&__gcsdb_writeSectors,
|
||||
(FN_MEDIUM_CLEARSTATUS)&__gcsdb_clearStatus,
|
||||
(FN_MEDIUM_SHUTDOWN)&__gcsdb_shutdown
|
||||
} ;
|
43
source/ogc_io/gcsd.h
Normal file
43
source/ogc_io/gcsd.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
gcsd.h
|
||||
|
||||
Hardware routines for reading and writing to SD geckos connected
|
||||
to the memory card ports.
|
||||
|
||||
These functions are just wrappers around libsdcard's functions.
|
||||
|
||||
Copyright (c) 2008 Sven "svpe" Peter <svpe@gmx.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __GCSD_H__
|
||||
#define __GCSD_H__
|
||||
|
||||
#include <gccore.h>
|
||||
#include "../disc.h"
|
||||
|
||||
extern const IO_INTERFACE __io_gcsda;
|
||||
extern const IO_INTERFACE __io_gcsdb;
|
||||
|
||||
#endif
|
52
source/ogc_io/wiisd.c
Normal file
52
source/ogc_io/wiisd.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
|
||||
wiisd.c
|
||||
|
||||
Hardware routines for reading and writing to the Wii's internal
|
||||
SD slot.
|
||||
|
||||
Most of those functions are based on the sd loading code in twilight hack elf
|
||||
loader by bushing, marcan, segher and tmbinc
|
||||
|
||||
Copyright (c) 2008 Sven "svpe" Peter <svpe@gmx.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifdef __wii__
|
||||
#include "wiisd.h"
|
||||
|
||||
#include <gccore.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
|
||||
|
||||
const IO_INTERFACE __io_wiisd = {
|
||||
DEVICE_TYPE_WII,
|
||||
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE,
|
||||
(FN_MEDIUM_STARTUP)&sdio_Startup,
|
||||
(FN_MEDIUM_ISINSERTED)&sdio_IsInserted,
|
||||
(FN_MEDIUM_READSECTORS)&sdio_ReadSectors,
|
||||
(FN_MEDIUM_WRITESECTORS)&sdio_WriteSectors,
|
||||
(FN_MEDIUM_CLEARSTATUS)&sdio_ClearStatus,
|
||||
(FN_MEDIUM_SHUTDOWN)&sdio_Shutdown
|
||||
};
|
||||
|
||||
#endif
|
41
source/ogc_io/wiisd.h
Normal file
41
source/ogc_io/wiisd.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
|
||||
wiisd.c
|
||||
|
||||
Hardware routines for reading and writing to the Wii's internal
|
||||
SD slot.
|
||||
|
||||
Copyright (c) 2008 Sven "svpe" Peter <svpe@gmx.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __WIISD_H__
|
||||
#define __WIISD_H__
|
||||
|
||||
#include <gccore.h>
|
||||
#include "../disc.h"
|
||||
|
||||
|
||||
extern const IO_INTERFACE __io_wiisd;
|
||||
|
||||
#endif
|
@ -48,7 +48,7 @@
|
||||
#include "mem_allocate.h"
|
||||
|
||||
/*
|
||||
This device name, as known by DevKitPro
|
||||
This device name, as known by devkitPro toolchains
|
||||
*/
|
||||
const char* DEVICE_NAME = "fat";
|
||||
|
||||
@ -102,14 +102,16 @@ enum BPB {
|
||||
BPB_bootSig_AA = 0x1FF
|
||||
};
|
||||
|
||||
|
||||
#ifdef NDS
|
||||
#if defined(__wii__)
|
||||
#define MAXIMUM_PARTITIONS 5
|
||||
#elif defined(__gamecube__)
|
||||
#define MAXIMUM_PARTITIONS 4
|
||||
#elif defined(NDS)
|
||||
#define MAXIMUM_PARTITIONS 4
|
||||
PARTITION* _FAT_partitions[MAXIMUM_PARTITIONS] = {NULL};
|
||||
#else // not defined NDS
|
||||
#define MAXIMUM_PARTITIONS 1
|
||||
PARTITION* _FAT_partitions[MAXIMUM_PARTITIONS] = {NULL};
|
||||
#endif // defined NDS
|
||||
PARTITION* _FAT_partitions[MAXIMUM_PARTITIONS] = {NULL};
|
||||
|
||||
// Use a single static buffer for the partitions
|
||||
|
||||
@ -235,7 +237,6 @@ static void _FAT_partition_destructor (PARTITION* partition) {
|
||||
}
|
||||
|
||||
bool _FAT_partition_mount (PARTITION_INTERFACE partitionNumber, u32 cacheSize) {
|
||||
#ifdef NDS
|
||||
int i;
|
||||
const IO_INTERFACE* disc = NULL;
|
||||
|
||||
@ -243,23 +244,7 @@ bool _FAT_partition_mount (PARTITION_INTERFACE partitionNumber, u32 cacheSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (partitionNumber) {
|
||||
case PI_SLOT_1:
|
||||
// Mount the disc in slot 1
|
||||
disc = _FAT_disc_dsSlotFindInterface ();
|
||||
break;
|
||||
case PI_SLOT_2:
|
||||
// Mount the disc in slot 2
|
||||
disc = _FAT_disc_gbaSlotFindInterface ();
|
||||
break;
|
||||
case PI_DEFAULT:
|
||||
case PI_CUSTOM:
|
||||
default:
|
||||
// Anything else has to be handled specially
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
disc = _FAT_disc_findInterfaceSlot (partitionNumber);
|
||||
if (disc == NULL) {
|
||||
return false;
|
||||
}
|
||||
@ -278,33 +263,25 @@ bool _FAT_partition_mount (PARTITION_INTERFACE partitionNumber, u32 cacheSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#else // not defined NDS
|
||||
const IO_INTERFACE* disc = NULL;
|
||||
|
||||
if (_FAT_partitions[partitionNumber] != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only ever one partition on GBA
|
||||
disc = _FAT_disc_gbaSlotFindInterface ();
|
||||
_FAT_partitions[partitionNumber] = _FAT_partition_constructor (disc, cacheSize);
|
||||
|
||||
#endif // defined NDS
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _FAT_partition_mountCustomInterface (const IO_INTERFACE* device, u32 cacheSize) {
|
||||
#ifdef NDS
|
||||
|
||||
|
||||
#ifdef GBA
|
||||
if (_FAT_partitions[0] != NULL) return false;
|
||||
|
||||
if (device == NULL) return false;
|
||||
|
||||
// Only ever one partition on GBA
|
||||
_FAT_partitions[0] = _FAT_partition_constructor (device, cacheSize);
|
||||
#else
|
||||
int i;
|
||||
|
||||
if (_FAT_partitions[PI_CUSTOM] != NULL) {
|
||||
return false;
|
||||
}
|
||||
if (_FAT_partitions[PI_CUSTOM] != NULL) return false;
|
||||
|
||||
if (device == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (device == NULL) return false;
|
||||
|
||||
// See if that disc is already in use, if so, then just copy the partition pointer
|
||||
for (i = 0; i < MAXIMUM_PARTITIONS; i++) {
|
||||
@ -319,26 +296,12 @@ bool _FAT_partition_mountCustomInterface (const IO_INTERFACE* device, u32 cacheS
|
||||
if (_FAT_partitions[PI_CUSTOM] == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#else // not defined NDS
|
||||
if (_FAT_partitions[PI_CART_SLOT] != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (device == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only ever one partition on GBA
|
||||
_FAT_partitions[PI_CART_SLOT] = _FAT_partition_constructor (device, cacheSize);
|
||||
|
||||
#endif // defined NDS
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _FAT_partition_setDefaultInterface (PARTITION_INTERFACE partitionNumber) {
|
||||
#ifdef NDS // Can only set the default partition when there is more than 1, so doesn't apply to GBA
|
||||
#ifndef GBA // Can only set the default partition when there is more than 1, so doesn't apply to GBA
|
||||
if ((partitionNumber < 1) || (partitionNumber >= MAXIMUM_PARTITIONS)) {
|
||||
return false;
|
||||
}
|
||||
@ -353,7 +316,7 @@ bool _FAT_partition_setDefaultInterface (PARTITION_INTERFACE partitionNumber) {
|
||||
}
|
||||
|
||||
bool _FAT_partition_setDefaultPartition (PARTITION* partition) {
|
||||
#ifdef NDS // Can only set the default partition when there is more than 1, so doesn't apply to GBA
|
||||
#ifndef GBA // Can only set the default partition when there is more than 1, so doesn't apply to GBA
|
||||
int i;
|
||||
|
||||
if (partition == NULL) {
|
||||
@ -424,7 +387,10 @@ bool _FAT_partition_unsafeUnmount (PARTITION_INTERFACE partitionNumber) {
|
||||
}
|
||||
|
||||
PARTITION* _FAT_partition_getPartitionFromPath (const char* path) {
|
||||
#ifdef NDS
|
||||
|
||||
#ifdef GBA
|
||||
return _FAT_partitions[0];
|
||||
#else
|
||||
int namelen;
|
||||
int partitionNumber;
|
||||
|
||||
@ -454,8 +420,5 @@ PARTITION* _FAT_partition_getPartitionFromPath (const char* path) {
|
||||
}
|
||||
|
||||
return _FAT_partitions[partitionNumber];
|
||||
#else // not defined NDS
|
||||
// Only one possible partition on GBA
|
||||
return _FAT_partitions[PI_CART_SLOT];
|
||||
#endif // defined NDS
|
||||
#endif
|
||||
}
|
||||
|
@ -34,8 +34,6 @@
|
||||
#define _PARTITION_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "disc_io/disc.h"
|
||||
#include "cache.h"
|
||||
|
||||
// Device name
|
||||
@ -44,11 +42,6 @@ extern const char* DEVICE_NAME;
|
||||
// Filesystem type
|
||||
typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE;
|
||||
|
||||
#ifdef NDS
|
||||
typedef enum {PI_DEFAULT, PI_SLOT_1, PI_SLOT_2, PI_CUSTOM} PARTITION_INTERFACE;
|
||||
#else
|
||||
typedef enum {PI_CART_SLOT} PARTITION_INTERFACE;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
u32 fatStart;
|
||||
|
Loading…
Reference in New Issue
Block a user