fygue: support FXCP400 (work, but broken for BFile syscalls)

This commit is contained in:
Yann MAGNIN 2025-04-06 12:23:25 +02:00
parent d9b03e7052
commit a56d57ad61
No known key found for this signature in database
GPG key ID: D82629D933EADC59
7 changed files with 39 additions and 12 deletions

View file

@ -62,8 +62,8 @@ static int _fygue_flash_cluster_convert(
0xdd, 0xee, 0xee, 0xee, 0xdd, 0xee, 0xee, 0xee,
}; };
struct _bfile_cluster_metadata *meta[2] = { struct _bfile_cluster_metadata *meta[2] = {
(void*)(bfile_meta | 0x80000000),
(void*)(bfile_meta | 0xa0000000), (void*)(bfile_meta | 0xa0000000),
(void*)(bfile_meta | 0x80000000),
}; };
if (fcluster == NULL) if (fcluster == NULL)
return -1; return -1;
@ -87,12 +87,21 @@ static int _fygue_flash_cluster_convert(
continue; continue;
if (meta[i]->bitmask[0] != 0x11 && meta[i]->lcluster_id != 0xffff) if (meta[i]->bitmask[0] != 0x11 && meta[i]->lcluster_id != 0xffff)
continue; 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 ( if (
memcmp(&(meta[i]->constant), _constant1, 0x18) != 0 && memcmp(&(meta[i]->constant), _constant1, 0x18) != 0 &&
memcmp(&(meta[i]->constant), _constant2, 0x18) != 0 memcmp(&(meta[i]->constant), _constant2, 0x18) != 0
) { ) {
continue; continue;
} }
#endif
fcluster->lcluster_id = meta[i]->lcluster_id; fcluster->lcluster_id = meta[i]->lcluster_id;
fcluster->kind = meta[i]->bitmask[0]; fcluster->kind = meta[i]->bitmask[0];
fcluster->version = meta[i]->fcluster_version; fcluster->version = meta[i]->fcluster_version;
@ -121,9 +130,9 @@ int fygue_flash_cluster_geometry(
uint16_t *fsector_id, uint16_t *fsector_id,
uint16_t *fcluster_off uint16_t *fcluster_off
) { ) {
if ((addr & 0x0fffffff) < 0x00c80000) if ((addr & 0x0fffffff) < __FYGUE_FSECTOR_START_ADDR)
return -1; return -1;
addr = (addr & 0x0fffffff) - 0x00c80000; addr = (addr & 0x0fffffff) - __FYGUE_FSECTOR_START_ADDR;
if (fcluster_id != NULL) { if (fcluster_id != NULL) {
*fcluster_id = ((addr & 0xfffe0000) >> 17) * 32; *fcluster_id = ((addr & 0xfffe0000) >> 17) * 32;
*fcluster_id += ((addr & 0x0001ffff) >> 12); *fcluster_id += ((addr & 0x0001ffff) >> 12);
@ -162,13 +171,13 @@ int fygue_flash_cluster_get(
fcluster->lcluster_id = 0xffff; fcluster->lcluster_id = 0xffff;
fcluster->version = 0xffffffff; fcluster->version = 0xffffffff;
} else { } else {
bfile_meta = 0x00c80000; bfile_meta = __FYGUE_FSECTOR_START_ADDR;
bfile_meta += (fsector_id * 0x20000) + 0x1f000; bfile_meta += (fsector_id * 0x20000) + 0x1f000;
bfile_meta += (fcluster_off * 0x40); bfile_meta += (fcluster_off * 0x40);
if (_fygue_flash_cluster_convert(fcluster, bfile_meta) != 0) if (_fygue_flash_cluster_convert(fcluster, bfile_meta) != 0)
return -2; return -2;
} }
bfile_data = 0x00c80000; bfile_data = __FYGUE_FSECTOR_START_ADDR;
bfile_data += (fsector_id * 0x20000); bfile_data += (fsector_id * 0x20000);
bfile_data += (fcluster_off * 0x1000); bfile_data += (fcluster_off * 0x1000);
fcluster->data_p1 = bfile_data | 0xa0000000; fcluster->data_p1 = bfile_data | 0xa0000000;

View file

@ -121,9 +121,9 @@ int fygue_flash_cmap_init(struct fygue_flash_cmap *cmap)
} }
} }
if (cmap->lcluster == NULL) if (cmap->lcluster == NULL)
return -1; return -2;
if (cmap->lcluster[0].fcluster_id == 0xffff) if (cmap->lcluster[0].fcluster_id == 0xffff)
return -1; return -3;
return 0; return 0;
} }

View file

@ -2,10 +2,19 @@
#define FS_FYGUE_FLASH_H 1 #define FS_FYGUE_FLASH_H 1
#include <gint/defs/types.h> #include <gint/defs/types.h>
#include <gint/config.h>
/* __FYGUE_* - hardcoded fygue information */ /* __FYGUE_* - hardcoded fygue information */
#define __FYGUE_FSECTOR_COUNT (0x9c) //FIXME: change between OS version ?
#define __FYGUE_FCLUSTER_COUNT (__FYGUE_FSECTOR_COUNT * 32) #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 */ /* fygue_fcluster - generic flash cluster information */
struct fygue_flash_cluster struct fygue_flash_cluster

View file

@ -33,7 +33,7 @@ int fygue_mount(struct fygue_fsinfo **fsinfo, bool refresh)
} }
if (refresh && __fygue_fsinfo->dirty) { if (refresh && __fygue_fsinfo->dirty) {
if (fygue_fat_init_hot(&(__fygue_fsinfo->fat)) != 0) if (fygue_fat_init_hot(&(__fygue_fsinfo->fat)) != 0)
return -3; return -4;
__fygue_fsinfo->dirty = false; __fygue_fsinfo->dirty = false;
} }
*fsinfo = __fygue_fsinfo; *fsinfo = __fygue_fsinfo;

View file

@ -27,6 +27,7 @@ int fygue_open(char const *path, int flags, GUNUSED mode_t mode)
return -1; return -1;
} }
/* if opening fails and the previous check as not returned an error, /* 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 * it is certainly because of a creation request. We are a read-only
* file-system, so, fail */ * file-system, so, fail */

View file

@ -176,8 +176,7 @@ void hw_detect(void)
gint[HWCPUVR] = PVR; gint[HWCPUVR] = PVR;
gint[HWCPUPR] = PRR; gint[HWCPUPR] = PRR;
gint[HWCALC] = HWCALC_FXCP400; gint[HWCALC] = HWCALC_FXCP400;
// TODO: What filesystem implementation on the fx-CP 400? gint[HWFS] = HWFS_FUGUE;
gint[HWFS] = HWFS_NONE;
gint[HWRAM] = 16 << 20; gint[HWRAM] = 16 << 20;
// TOOD: How much ROM on the fx-CP 400? // TOOD: How much ROM on the fx-CP 400?
gint[HWROM] = 0; gint[HWROM] = 0;

View file

@ -289,4 +289,13 @@ ___VRAMRestore:
___Reset: ___Reset:
fixed(0xa0000000) fixed(0xa0000000)
_BFile_Size:
_BFile_Read:
_BFile_Seek:
_BFile_Write:
_BFile_Close:
_BFile_FindFirst:
_BFile_FindClose:
fixed(0xa0000000)
#endif /* GINT_OS_CP */ #endif /* GINT_OS_CP */