aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source/fat
diff options
context:
space:
mode:
authorNeil Millstone2007-01-19 21:47:10 +0000
committerNeil Millstone2007-01-19 21:47:10 +0000
commitfe9682ac55a385242440ace28a16223bd67b5032 (patch)
tree9fa8a0c609fbabf8a8c370299419b7b6c11755c7 /backends/platform/ds/arm9/source/fat
parent31abbc14aef7e3a8088b4c2ad11ee43e67bc5a92 (diff)
downloadscummvm-rg350-fe9682ac55a385242440ace28a16223bd67b5032.tar.gz
scummvm-rg350-fe9682ac55a385242440ace28a16223bd67b5032.tar.bz2
scummvm-rg350-fe9682ac55a385242440ace28a16223bd67b5032.zip
Adding libcartreset, fixing CD audio bug, adding DLDI support (defined out all other fat drivers)
svn-id: r25124
Diffstat (limited to 'backends/platform/ds/arm9/source/fat')
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c27
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.h37
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.h34
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.s70
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3sd.c4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_njsd.c2
-rw-r--r--backends/platform/ds/arm9/source/fat/io_scsd.c3
-rw-r--r--backends/platform/ds/arm9/source/fat/io_scsd.h31
8 files changed, 168 insertions, 40 deletions
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c
index 69befa09b7..988810073d 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.c
+++ b/backends/platform/ds/arm9/source/fat/disc_io.c
@@ -77,6 +77,8 @@
#include "io_mmcf.h"
#endif
+#include "io_dldi.h"
+
// Keep a pointer to the active interface
LPIO_INTERFACE active_interface = 0;
@@ -104,6 +106,8 @@ static struct {
u32 count;
} cache[ DISC_CACHE_COUNT ];
+FATDevice currentDevice;
+
static u32 disc_CacheFind(u32 sector) {
u32 i;
@@ -245,6 +249,7 @@ bool disc_setGbaSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set M3 SD as default IO
+ currentDevice = DEVICE_M3SD;
return true ;
} ;
}
@@ -259,6 +264,7 @@ bool disc_setGbaSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set MMCF as default IO
+ currentDevice = DEVICE_MMCF;
return true ;
} ;
#endif
@@ -271,6 +277,7 @@ bool disc_setGbaSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set M3 CF as default IO
+ currentDevice = DEVICE_M3CF;
return true ;
} ;
#endif
@@ -282,6 +289,7 @@ bool disc_setGbaSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set GBAMP as default IO
+ currentDevice = DEVICE_MPCF;
return true ;
} ;
#endif
@@ -293,6 +301,7 @@ bool disc_setGbaSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set SC CF as default IO
+ currentDevice = DEVICE_SCCF;
return true ;
} ;
#endif
@@ -325,6 +334,11 @@ bool disc_setGbaSlotInterface (void)
return false;
}
+
+FATDevice disc_getDeviceId() {
+ return currentDevice;
+}
+
#ifdef NDS
// Check the DS card slot for a valid memory card interface
// If an interface is found, it is set as the default interace
@@ -339,6 +353,16 @@ bool disc_setDsSlotInterface (void)
WAIT_CR |= (1<<11);
#endif
+ active_interface = DLDI_GetInterface();
+
+ if (active_interface->fn_StartUp()) {
+ consolePrintf("DLDI Driver Initialised OK!\n");
+ currentDevice = DEVICE_DLDI;
+ return true;
+ } else {
+ consolePrintf("DLDI Initialise failed.\n");
+ }
+
#ifdef SUPPORT_SCSD
// check if we have a SuperCard SD plugged in
if (discDetect == 2) {
@@ -347,6 +371,7 @@ bool disc_setDsSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set SC SD as default IO
+ currentDevice = DEVICE_SCSD;
return true ;
} ;
}
@@ -358,6 +383,7 @@ bool disc_setDsSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set NJSD as default IO
+ currentDevice = DEVICE_NJSD;
return true ;
} ;
#endif
@@ -368,6 +394,7 @@ bool disc_setDsSlotInterface (void)
if (active_interface->fn_StartUp())
{
// set Neoflash MK2 / MK3 as default IO
+ currentDevice = DEVICE_NMMC;
return true ;
} ;
#endif
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.h b/backends/platform/ds/arm9/source/fat/disc_io.h
index e904071c37..2fff7f3bd5 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.h
+++ b/backends/platform/ds/arm9/source/fat/disc_io.h
@@ -15,16 +15,18 @@
// Device support options, added by www.neoflash.com
-#define SUPPORT_NMMC // comment out this line to remove Neoflash MK2 MMC Card support
-#define SUPPORT_MPCF // comment out this line to remove GBA Movie Player support
-#define SUPPORT_M3CF // comment out this line to remove M3 Perfect CF support
-#define SUPPORT_M3SD // comment out this line to remove M3 Perfect SD support
-#define SUPPORT_SCCF // comment out this line to remove Supercard CF support
-#define SUPPORT_SCSD // comment out this line to remove Supercard SD support
+//#define SUPPORT_MPCF // comment out this line to remove GBA Movie Player support
+//#define SUPPORT_M3CF // comment out this line to remove M3 Perfect CF support
+//#define SUPPORT_M3SD // comment out this line to remove M3 Perfect SD support
+//#define SUPPORT_SCCF // comment out this line to remove Supercard CF support
+//#define SUPPORT_SCSD // comment out this line to remove Supercard SD support
+//#define SUPPORT_NJSD
+//#define SUPPORT_MMCF
+
//#define SUPPORT_EFA2 // comment out this line to remove EFA2 linker support
-#define SUPPORT_FCSR // comment out this line to remove GBA Flash Cart support
-#define SUPPORT_NJSD
-#define SUPPORT_MMCF
+//#define SUPPORT_FCSR // comment out this line to remove GBA Flash Cart support
+//#define SUPPORT_NMMC // comment out this line to remove Neoflash MK2 MMC Card support
+
// Disk caching options, added by www.neoflash.com
// Each additional sector cache uses 512 bytes of memory
@@ -72,6 +74,20 @@
extern "C" {
#endif
+
+typedef enum {
+ DEVICE_NONE = 0,
+ DEVICE_M3SD,
+ DEVICE_MMCF,
+ DEVICE_M3CF,
+ DEVICE_MPCF,
+ DEVICE_SCCF,
+ DEVICE_NJSD,
+ DEVICE_SCSD,
+ DEVICE_NMMC,
+ DEVICE_DLDI
+} FATDevice;
+
/*-----------------------------------------------------------------
disc_Init
Detects the inserted hardware and initialises it if necessary
@@ -88,6 +104,8 @@ extern bool disc_IsInserted(void) ;
extern void disc_setEnable(int en);
+extern FATDevice disc_getDeviceId();
+
/*-----------------------------------------------------------------
disc_ReadSectors
Read 512 byte sector numbered "sector" into "buffer"
@@ -161,6 +179,7 @@ static inline bool disc_CacheFlush(void)
#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, u8 numSecs, void* buffer) ;
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h
new file mode 100644
index 0000000000..6f97ca7b45
--- /dev/null
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.h
@@ -0,0 +1,34 @@
+/*
+ io_dldi.h
+
+ Reserved space for new drivers
+
+ This software is completely free. No warranty is provided.
+ If you use it, please give me credit and email me about your
+ project at chishm@hotmail.com
+
+ See gba_nds_fat.txt for help and license details.
+*/
+
+#ifndef IO_DLDI_H
+#define IO_DLDI_H
+
+// 'DLDI'
+#define DEVICE_TYPE_DLDD 0x49444C44
+
+#include "disc_io.h"
+#ifdef NDS
+#include <nds/memory.h>
+#endif
+
+extern IO_INTERFACE _io_dldi;
+
+// export interface
+static inline LPIO_INTERFACE DLDI_GetInterface(void) {
+#ifdef NDS
+ WAIT_CR &= ~(ARM9_OWNS_ROM | ARM9_OWNS_CARD);
+#endif // defined NDS
+ return &_io_dldi;
+}
+
+#endif // define IO_DLDI_H
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.s b/backends/platform/ds/arm9/source/fat/io_dldi.s
new file mode 100644
index 0000000000..8d21522baf
--- /dev/null
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.s
@@ -0,0 +1,70 @@
+@---------------------------------------------------------------------------------
+ .align 4
+ .arm
+ .global _io_dldi
+@---------------------------------------------------------------------------------
+.equ FEATURE_MEDIUM_CANREAD, 0x00000001
+.equ FEATURE_MEDIUM_CANWRITE, 0x00000002
+.equ FEATURE_SLOT_GBA, 0x00000010
+.equ FEATURE_SLOT_NDS, 0x00000020
+
+
+@---------------------------------------------------------------------------------
+@ Driver patch file standard header -- 16 bytes
+ .word 0xBF8DA5ED @ Magic number to identify this region
+ .asciz " Chishm" @ Identifying Magic string (8 bytes with null terminator)
+ .byte 0x01 @ Version number
+ .byte 0x0F @32KiB @ Log [base-2] of the size of this driver in bytes.
+ .byte 0x00 @ Sections to fix
+ .byte 0x0F @32KiB @ Log [base-2] of the allocated space in bytes.
+
+@---------------------------------------------------------------------------------
+@ Text identifier - can be anything up to 47 chars + terminating null -- 16 bytes
+ .align 4
+ .asciz "Default (No interface)"
+
+@---------------------------------------------------------------------------------
+@ Offsets to important sections within the data -- 32 bytes
+ .align 6
+ .word 0x00000000 @ data start
+ .word 0x00000000 @ data end
+ .word 0x00000000 @ Interworking glue start -- Needs address fixing
+ .word 0x00000000 @ Interworking glue end
+ .word 0x00000000 @ GOT start -- Needs address fixing
+ .word 0x00000000 @ GOT end
+ .word 0x00000000 @ bss start -- Needs setting to zero
+ .word 0x00000000 @ bss end
+
+@---------------------------------------------------------------------------------
+@ IO_INTERFACE data -- 32 bytes
+_io_dldi:
+ .ascii "DLDI" @ ioType
+ .word 0x00000000 @ Features
+ .word _DLDI_startup @
+ .word _DLDI_isInserted @
+ .word _DLDI_readSectors @ Function pointers to standard device driver functions
+ .word _DLDI_writeSectors @
+ .word _DLDI_clearStatus @
+ .word _DLDI_shutdown @
+
+@---------------------------------------------------------------------------------
+
+_DLDI_startup:
+_DLDI_isInserted:
+_DLDI_readSectors:
+_DLDI_writeSectors:
+_DLDI_clearStatus:
+_DLDI_shutdown:
+ mov r0, #0x00 @ Return false for every function
+ bx lr
+
+
+
+@---------------------------------------------------------------------------------
+ .align
+ .pool
+
+.space 32632 @ Fill to 32KiB
+
+ .end
+@---------------------------------------------------------------------------------
diff --git a/backends/platform/ds/arm9/source/fat/io_m3sd.c b/backends/platform/ds/arm9/source/fat/io_m3sd.c
index fba264a438..914b83e06e 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3sd.c
+++ b/backends/platform/ds/arm9/source/fat/io_m3sd.c
@@ -1,7 +1,7 @@
#define io_M3SD_c
#include "io_m3sd.h"
-
+#ifdef SUPPORT_M3SD
//M3-SD interface SD card.
#define DMA3SAD *(volatile u32*)0x040000D4
@@ -379,3 +379,5 @@ LPIO_INTERFACE M3SD_GetInterface(void)
{
return &io_m3sd ;
}
+
+#endif
diff --git a/backends/platform/ds/arm9/source/fat/io_njsd.c b/backends/platform/ds/arm9/source/fat/io_njsd.c
index 8c06b468c7..fbb223d560 100644
--- a/backends/platform/ds/arm9/source/fat/io_njsd.c
+++ b/backends/platform/ds/arm9/source/fat/io_njsd.c
@@ -35,6 +35,7 @@
#include "io_njsd.h"
+#ifdef SUPPORT_NJSD
#ifdef NDS
#include <nds.h>
@@ -677,3 +678,4 @@ LPIO_INTERFACE NJSD_GetInterface(void) {
} ;
#endif // defined NDS
+#endif \ No newline at end of file
diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.c b/backends/platform/ds/arm9/source/fat/io_scsd.c
index 9904a0ac28..9359fefb6d 100644
--- a/backends/platform/ds/arm9/source/fat/io_scsd.c
+++ b/backends/platform/ds/arm9/source/fat/io_scsd.c
@@ -26,6 +26,8 @@
#include "io_scsd.h"
+#ifdef SUPPORT_SCSD
+
/*-----------------------------------------------------------------
Since all CF addresses and commands are the same for the GBAMP,
simply use it's functions instead.
@@ -101,3 +103,4 @@ LPIO_INTERFACE SCSD_GetInterface(void) {
return &io_scsd ;
} ;
+#endif \ No newline at end of file
diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.h b/backends/platform/ds/arm9/source/fat/io_scsd.h
index 1e4e17dbb8..75115b8d62 100644
--- a/backends/platform/ds/arm9/source/fat/io_scsd.h
+++ b/backends/platform/ds/arm9/source/fat/io_scsd.h
@@ -26,33 +26,4 @@
// export interface
extern LPIO_INTERFACE SCSD_GetInterface(void) ;
-#endif // define IO_SCSD_H
-/*
- io_scsd.h by SaTa.
- based on io_sccf.h
-
-
-*/
-
-/*
- io_sccf.h
-
- Hardware Routines for reading a compact flash card
- using the GBA Movie Player
-
- This software is completely free. No warranty is provided.
- If you use it, please give me credit and email me about your
- project at chishm@hotmail.com
-
- See gba_nds_fat.txt for help and license details.
-*/
-
-#ifndef IO_SCSD_H
-#define IO_SCSD_H
-
-#include "disc_io.h"
-
-// export interface
-extern LPIO_INTERFACE SCSD_GetInterface(void) ;
-
-#endif // define IO_SCSD_H
+#endif // define IO_SCSD_H \ No newline at end of file