diff --git a/src/fs/fygue/flash/cluster.c b/src/fs/fygue/flash/cluster.c index d681cf7..866e72c 100644 --- a/src/fs/fygue/flash/cluster.c +++ b/src/fs/fygue/flash/cluster.c @@ -62,8 +62,8 @@ static int _fygue_flash_cluster_convert( 0xdd, 0xee, 0xee, 0xee, }; struct _bfile_cluster_metadata *meta[2] = { - (void*)(bfile_meta | 0x80000000), (void*)(bfile_meta | 0xa0000000), + (void*)(bfile_meta | 0x80000000), }; if (fcluster == NULL) return -1; @@ -87,12 +87,21 @@ static int _fygue_flash_cluster_convert( continue; if (meta[i]->bitmask[0] != 0x11 && meta[i]->lcluster_id != 0xffff) continue; +#if GINT_HW_CP + // on the fxcp400, only some flash sector have the constants used + // in other device. Casio check an CRC that is performed on the + // whole cluster + // TODO: CRC check + (void)_constant1; + (void)_constant2; +#else if ( memcmp(&(meta[i]->constant), _constant1, 0x18) != 0 && memcmp(&(meta[i]->constant), _constant2, 0x18) != 0 ) { continue; } +#endif fcluster->lcluster_id = meta[i]->lcluster_id; fcluster->kind = meta[i]->bitmask[0]; fcluster->version = meta[i]->fcluster_version; @@ -121,9 +130,9 @@ int fygue_flash_cluster_geometry( uint16_t *fsector_id, uint16_t *fcluster_off ) { - if ((addr & 0x0fffffff) < 0x00c80000) + if ((addr & 0x0fffffff) < __FYGUE_FSECTOR_START_ADDR) return -1; - addr = (addr & 0x0fffffff) - 0x00c80000; + addr = (addr & 0x0fffffff) - __FYGUE_FSECTOR_START_ADDR; if (fcluster_id != NULL) { *fcluster_id = ((addr & 0xfffe0000) >> 17) * 32; *fcluster_id += ((addr & 0x0001ffff) >> 12); @@ -162,13 +171,13 @@ int fygue_flash_cluster_get( fcluster->lcluster_id = 0xffff; fcluster->version = 0xffffffff; } else { - bfile_meta = 0x00c80000; + bfile_meta = __FYGUE_FSECTOR_START_ADDR; bfile_meta += (fsector_id * 0x20000) + 0x1f000; bfile_meta += (fcluster_off * 0x40); if (_fygue_flash_cluster_convert(fcluster, bfile_meta) != 0) return -2; } - bfile_data = 0x00c80000; + bfile_data = __FYGUE_FSECTOR_START_ADDR; bfile_data += (fsector_id * 0x20000); bfile_data += (fcluster_off * 0x1000); fcluster->data_p1 = bfile_data | 0xa0000000; diff --git a/src/fs/fygue/flash/cmap.c b/src/fs/fygue/flash/cmap.c index 1def9dd..96923a2 100644 --- a/src/fs/fygue/flash/cmap.c +++ b/src/fs/fygue/flash/cmap.c @@ -121,9 +121,9 @@ int fygue_flash_cmap_init(struct fygue_flash_cmap *cmap) } } if (cmap->lcluster == NULL) - return -1; + return -2; if (cmap->lcluster[0].fcluster_id == 0xffff) - return -1; + return -3; return 0; } diff --git a/src/fs/fygue/flash/flash.h b/src/fs/fygue/flash/flash.h index e58f43e..89545d5 100644 --- a/src/fs/fygue/flash/flash.h +++ b/src/fs/fygue/flash/flash.h @@ -2,10 +2,19 @@ #define FS_FYGUE_FLASH_H 1 #include +#include /* __FYGUE_* - hardcoded fygue information */ -#define __FYGUE_FSECTOR_COUNT (0x9c) -#define __FYGUE_FCLUSTER_COUNT (__FYGUE_FSECTOR_COUNT * 32) +//FIXME: change between OS version ? +#if GINT_HW_CP +# define __FYGUE_FSECTOR_START_ADDR (0x01a20000) +# define __FYGUE_FSECTOR_COUNT (0xf2) +# define __FYGUE_FCLUSTER_COUNT (__FYGUE_FSECTOR_COUNT * 32) +#else +# define __FYGUE_FSECTOR_START_ADDR (0x00c80000) +# define __FYGUE_FSECTOR_COUNT (0x9c) +# define __FYGUE_FCLUSTER_COUNT (__FYGUE_FSECTOR_COUNT * 32) +#endif /* fygue_fcluster - generic flash cluster information */ struct fygue_flash_cluster diff --git a/src/fs/fygue/fygue.c b/src/fs/fygue/fygue.c index 7bfd5b1..7932e04 100644 --- a/src/fs/fygue/fygue.c +++ b/src/fs/fygue/fygue.c @@ -33,7 +33,7 @@ int fygue_mount(struct fygue_fsinfo **fsinfo, bool refresh) } if (refresh && __fygue_fsinfo->dirty) { if (fygue_fat_init_hot(&(__fygue_fsinfo->fat)) != 0) - return -3; + return -4; __fygue_fsinfo->dirty = false; } *fsinfo = __fygue_fsinfo; diff --git a/src/fs/fygue/fygue_open.c b/src/fs/fygue/fygue_open.c index c25b4c2..2f95b86 100644 --- a/src/fs/fygue/fygue_open.c +++ b/src/fs/fygue/fygue_open.c @@ -27,6 +27,7 @@ int fygue_open(char const *path, int flags, GUNUSED mode_t mode) return -1; } + /* if opening fails and the previous check as not returned an error, * it is certainly because of a creation request. We are a read-only * file-system, so, fail */ diff --git a/src/kernel/hardware.c b/src/kernel/hardware.c index 68d3d08..31b8635 100644 --- a/src/kernel/hardware.c +++ b/src/kernel/hardware.c @@ -176,8 +176,7 @@ void hw_detect(void) gint[HWCPUVR] = PVR; gint[HWCPUPR] = PRR; gint[HWCALC] = HWCALC_FXCP400; - // TODO: What filesystem implementation on the fx-CP 400? - gint[HWFS] = HWFS_NONE; + gint[HWFS] = HWFS_FUGUE; gint[HWRAM] = 16 << 20; // TOOD: How much ROM on the fx-CP 400? gint[HWROM] = 0; diff --git a/src/kernel/syscalls.S b/src/kernel/syscalls.S index fa71e9c..70e94e8 100644 --- a/src/kernel/syscalls.S +++ b/src/kernel/syscalls.S @@ -289,4 +289,13 @@ ___VRAMRestore: ___Reset: fixed(0xa0000000) +_BFile_Size: +_BFile_Read: +_BFile_Seek: +_BFile_Write: +_BFile_Close: +_BFile_FindFirst: +_BFile_FindClose: + fixed(0xa0000000) + #endif /* GINT_OS_CP */