diff options
author | germeier <germeier> | 2002-09-09 13:29:52 +0000 |
---|---|---|
committer | germeier <germeier> | 2002-09-09 13:29:52 +0000 |
commit | 3a5afefa2a788b242bfeb4dce330202e24a1ca77 (patch) | |
tree | e5bffe1435d8e7e7aeabe0449f387af7a65576a9 /libmpio | |
parent | 5ff4c310b3da74510b91d09814682442174ef6a0 (diff) | |
download | mpiosh-3a5afefa2a788b242bfeb4dce330202e24a1ca77.tar.gz mpiosh-3a5afefa2a788b242bfeb4dce330202e24a1ca77.tar.bz2 mpiosh-3a5afefa2a788b242bfeb4dce330202e24a1ca77.zip |
fixed cluster to block mapping with 32 MB SmartMedia cards
added debug messages in case of ECC errors
fixed some errors if no SM card is inserted (this time for real!)
Diffstat (limited to 'libmpio')
-rw-r--r-- | libmpio/ecc.c | 4 | ||||
-rw-r--r-- | libmpio/io.c | 35 | ||||
-rw-r--r-- | libmpio/mpio.c | 11 |
3 files changed, 32 insertions, 18 deletions
diff --git a/libmpio/ecc.c b/libmpio/ecc.c index e7429a5..5175a32 100644 --- a/libmpio/ecc.c +++ b/libmpio/ecc.c @@ -1,6 +1,6 @@ /* * - * $Id: ecc.c,v 1.1 2002/08/28 16:10:51 salmoon Exp $ + * $Id: ecc.c,v 1.2 2002/09/09 13:29:52 germeier Exp $ * * Library for USB MPIO-* * @@ -193,6 +193,8 @@ mpio_ecc_256_check(BYTE *data, BYTE *ecc) debugn(2, "ECC Correction code not in place yet, Sorry\n"); debugn(3, "got ECC: %2x %2x %2x\n", ecc[0], ecc[1], ecc[2]); debugn(3, "calc. ECC: %2x %2x %2x\n", own_ecc[0], own_ecc[1], own_ecc[2]); + + return 1; } return 0; diff --git a/libmpio/io.c b/libmpio/io.c index 10346d6..6a4c0f1 100644 --- a/libmpio/io.c +++ b/libmpio/io.c @@ -2,7 +2,7 @@ /* * - * $Id: io.c,v 1.3 2002/09/03 21:20:53 germeier Exp $ + * $Id: io.c,v 1.4 2002/09/09 13:29:52 germeier Exp $ * * Library for USB MPIO-* * @@ -63,8 +63,11 @@ cluster2block(int mem, int sector) if (mem == 32) { - if (sector >= 998) - a += 22; + /* I'm so large in *not* knowing! */ + if (sector >= 830) + a++; + if (a >= 1001) + a += 21; } if (mem == 64) @@ -354,10 +357,11 @@ mpio_io_sector_read(mpio_t *m, BYTE mem, DWORD index, BYTE *output) /* check ECC Area information */ if (mem==MPIO_EXTERNAL_MEM) { - mpio_ecc_256_check (recvbuff, - (recvbuff + SECTOR_SIZE + 13)); - mpio_ecc_256_check ((recvbuff + (SECTOR_SIZE / 2)), - (recvbuff + SECTOR_SIZE + 8)); + if (mpio_ecc_256_check (recvbuff, + (recvbuff + SECTOR_SIZE + 13)) || + mpio_ecc_256_check ((recvbuff + (SECTOR_SIZE / 2)), + (recvbuff + SECTOR_SIZE + 8)) ) + debug ("ECC error @ (%02x : %06x)\n", mem, index); } if (mem==MPIO_INTERNAL_MEM) @@ -489,8 +493,8 @@ mpio_io_block_read(mpio_t *m, BYTE mem, mpio_fatentry_t *f, BYTE *output) if (mem == MPIO_INTERNAL_MEM) { sm = &m->internal; - hexdump(&f->entry, 4); - hexdump(&f->hw_address, 4); + hexdump((char *)&f->entry, 4); + hexdump((char *)&f->hw_address, 4); chip = f->hw_address / 0x1000000; address = f->hw_address & 0x0ffffff; } @@ -537,11 +541,14 @@ mpio_io_block_read(mpio_t *m, BYTE mem, mpio_fatentry_t *f, BYTE *output) { /* check ECC Area information */ if (mem==MPIO_EXTERNAL_MEM) { - mpio_ecc_256_check ((recvbuff + (i * SECTOR_TRANS)), - ((recvbuff +(i * SECTOR_TRANS) + SECTOR_SIZE +13))); - - mpio_ecc_256_check ((recvbuff + (i * SECTOR_TRANS) + (SECTOR_SIZE / 2)), - ((recvbuff +(i * SECTOR_TRANS) + SECTOR_SIZE + 8))); + if (mpio_ecc_256_check ((recvbuff + (i * SECTOR_TRANS)), + ((recvbuff +(i * SECTOR_TRANS) + + SECTOR_SIZE +13))) || + mpio_ecc_256_check ((recvbuff + (i * SECTOR_TRANS) + + (SECTOR_SIZE / 2)), + ((recvbuff +(i * SECTOR_TRANS) + + SECTOR_SIZE + 8)))) + debug ("ECC error @ (%02x : %06x)\n", chip, address); } diff --git a/libmpio/mpio.c b/libmpio/mpio.c index 8c8152d..f6cfd84 100644 --- a/libmpio/mpio.c +++ b/libmpio/mpio.c @@ -1,6 +1,6 @@ /* * - * $Id: mpio.c,v 1.4 2002/09/08 23:22:48 germeier Exp $ + * $Id: mpio.c,v 1.5 2002/09/09 13:29:52 germeier Exp $ * * Library for USB MPIO-* * @@ -181,13 +181,18 @@ mpio_init(void) int mpio_memory_free(mpio_t *m, mpio_mem_t mem, int *free) { - *free=mpio_fat_free_clusters(m, mem); if (mem==MPIO_INTERNAL_MEM) { + *free=mpio_fat_free_clusters(m, mem); return (m->internal.geo.SumSector * SECTOR_SIZE / 1000 * m->internal.chips); } if (mem==MPIO_EXTERNAL_MEM) { + if (!m->external.size) { + *free=0; + return 0; + } + *free=mpio_fat_free_clusters(m, mem); return (m->external.geo.SumSector * SECTOR_SIZE / 1000); } @@ -230,7 +235,7 @@ mpio_get_info(mpio_t *m, mpio_info_t *info) m->internal.chips); } - if (m->internal.id) + if (m->external.id) { snprintf(info->firmware_mem_external, max, "%3dMB (%s)", mpio_id2mem(m->external.id), |