sector buffer in ewram for writing from arm7 (DSi SD fix)

This commit is contained in:
Dave Murphy 2011-01-28 02:09:07 +00:00
parent 93ec6aad6a
commit 907449094b
3 changed files with 10 additions and 13 deletions

View File

@ -54,6 +54,7 @@ static const DISC_INTERFACE* get_io_usbstorage (void) {
static const DISC_INTERFACE* get_io_gcsda (void) { static const DISC_INTERFACE* get_io_gcsda (void) {
return &__io_gcsda; return &__io_gcsda;
} }
static const DISC_INTERFACE* get_io_gcsdb (void) { static const DISC_INTERFACE* get_io_gcsdb (void) {
return &__io_gcsdb; return &__io_gcsdb;
} }
@ -87,7 +88,12 @@ const INTERFACE_ID _FAT_disc_interfaces[] = {
#elif defined (NDS) #elif defined (NDS)
#include <nds/arm9/dldi.h> #include <nds/arm9/dldi.h>
static const DISC_INTERFACE* get_io_dsisd (void) {
return &__io_dsisd;
}
const INTERFACE_ID _FAT_disc_interfaces[] = { const INTERFACE_ID _FAT_disc_interfaces[] = {
{"sd", get_io_dsisd},
{"fat", dldiGetInternal}, {"fat", dldiGetInternal},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -38,11 +38,6 @@
#include <ctype.h> #include <ctype.h>
#include <sys/iosupport.h> #include <sys/iosupport.h>
/*
This device name, as known by devkitPro toolchains
*/
const char* DEVICE_NAME = "fat";
/* /*
Data offsets Data offsets
*/ */
@ -108,6 +103,7 @@ static const char FAT_SIG[3] = {'F', 'A', 'T'};
static const char FS_INFO_SIG1[4] = {'R', 'R', 'a', 'A'}; static const char FS_INFO_SIG1[4] = {'R', 'R', 'a', 'A'};
static const char FS_INFO_SIG2[4] = {'r', 'r', 'A', 'a'}; static const char FS_INFO_SIG2[4] = {'r', 'r', 'A', 'a'};
static uint8_t sectorBuffer[BYTES_PER_READ] __attribute__((aligned(32)));
sec_t FindFirstValidPartition(const DISC_INTERFACE* disc) sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
{ {
@ -115,8 +111,6 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
uint8_t *ptr; uint8_t *ptr;
int i; int i;
uint8_t sectorBuffer[BYTES_PER_READ] = {0};
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) {
return 0; return 0;
@ -168,9 +162,9 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
return 0; return 0;
} }
PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector) { PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector) {
PARTITION* partition; PARTITION* partition;
uint8_t sectorBuffer[BYTES_PER_READ] = {0};
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
@ -196,14 +190,14 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
return NULL; return NULL;
} }
} }
// Now verify that this is indeed a FAT partition // Now verify that this is indeed a FAT partition
if (memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) && if (memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) &&
memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG)))
{ {
return NULL; return NULL;
} }
partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION)); partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION));
if (partition == NULL) { if (partition == NULL) {
return NULL; return NULL;

View File

@ -34,9 +34,6 @@
#include "cache.h" #include "cache.h"
#include "lock.h" #include "lock.h"
// Device name
extern const char* DEVICE_NAME;
// Filesystem type // Filesystem type
typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE; typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE;