From 907449094bb6e0b7bce87c503ce90584cb0d090b Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Fri, 28 Jan 2011 02:09:07 +0000 Subject: [PATCH] sector buffer in ewram for writing from arm7 (DSi SD fix) --- source/disc.c | 6 ++++++ source/partition.c | 14 ++++---------- source/partition.h | 3 --- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/disc.c b/source/disc.c index 1fac0ed..5f626b6 100755 --- a/source/disc.c +++ b/source/disc.c @@ -54,6 +54,7 @@ static const DISC_INTERFACE* get_io_usbstorage (void) { static const DISC_INTERFACE* get_io_gcsda (void) { return &__io_gcsda; } + static const DISC_INTERFACE* get_io_gcsdb (void) { return &__io_gcsdb; } @@ -87,7 +88,12 @@ const INTERFACE_ID _FAT_disc_interfaces[] = { #elif defined (NDS) #include +static const DISC_INTERFACE* get_io_dsisd (void) { + return &__io_dsisd; +} + const INTERFACE_ID _FAT_disc_interfaces[] = { + {"sd", get_io_dsisd}, {"fat", dldiGetInternal}, {NULL, NULL} }; diff --git a/source/partition.c b/source/partition.c index d4072cc..7f68f00 100644 --- a/source/partition.c +++ b/source/partition.c @@ -38,11 +38,6 @@ #include #include -/* -This device name, as known by devkitPro toolchains -*/ -const char* DEVICE_NAME = "fat"; - /* 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_SIG2[4] = {'r', 'r', 'A', 'a'}; +static uint8_t sectorBuffer[BYTES_PER_READ] __attribute__((aligned(32))); sec_t FindFirstValidPartition(const DISC_INTERFACE* disc) { @@ -115,8 +111,6 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc) uint8_t *ptr; int i; - uint8_t sectorBuffer[BYTES_PER_READ] = {0}; - // Read first sector of disc if (!_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) { return 0; @@ -168,9 +162,9 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc) return 0; } + PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector) { PARTITION* partition; - uint8_t sectorBuffer[BYTES_PER_READ] = {0}; // Read first sector of disc 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; } } - + // Now verify that this is indeed a FAT partition if (memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) && memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) { return NULL; } - + partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION)); if (partition == NULL) { return NULL; diff --git a/source/partition.h b/source/partition.h index b8ad0b1..24f2067 100644 --- a/source/partition.h +++ b/source/partition.h @@ -34,9 +34,6 @@ #include "cache.h" #include "lock.h" -// Device name -extern const char* DEVICE_NAME; - // Filesystem type typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE;