From da1281c5d1f7cac1e88805ae63542540f113accf Mon Sep 17 00:00:00 2001 From: germeier Date: Mon, 9 Sep 2002 15:48:55 +0000 Subject: updated code to format external SmartMedia cards fixed max_cluster issues --- libmpio/io.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'libmpio/io.c') diff --git a/libmpio/io.c b/libmpio/io.c index 6a4c0f1..d325053 100644 --- a/libmpio/io.c +++ b/libmpio/io.c @@ -2,7 +2,7 @@ /* * - * $Id: io.c,v 1.4 2002/09/09 13:29:52 germeier Exp $ + * $Id: io.c,v 1.5 2002/09/09 15:49:01 germeier Exp $ * * Library for USB MPIO-* * @@ -626,14 +626,37 @@ mpio_io_spare_read(mpio_t *m, BYTE area, DWORD index, BYTE size, } int -mpio_io_block_delete(mpio_t *m, BYTE mem, DWORD index, BYTE size) +mpio_io_block_delete(mpio_t *m, BYTE mem, mpio_fatentry_t *f) { + mpio_smartmedia_t *sm; int nwrite, nread; BYTE cmdpacket[CMD_SIZE], status[CMD_SIZE]; + BYTE chip=0; + DWORD address; + + if (mem == MPIO_INTERNAL_MEM) + { + sm = &m->internal; + hexdump((char *)&f->entry, 4); + hexdump((char *)&f->hw_address, 4); + chip = f->hw_address / 0x1000000; + address = f->hw_address & 0x0ffffff; + } + if (mem == MPIO_EXTERNAL_MEM) + { + sm = &m->external; + chip = MPIO_EXTERNAL_MEM; + address = cluster2block(sm->size, f->entry); + address *= BLOCK_SECTORS; + + /* add offset to start of "data" area! */ + address += (sm->dir_offset + DIR_NUM - (2 * BLOCK_SECTORS)); + + } /* Send command packet to MPIO */ - mpio_io_set_cmdpacket(DEL_BLOCK, mem, index, size, 0, cmdpacket); + mpio_io_set_cmdpacket(DEL_BLOCK, chip, address, sm->size, 0, cmdpacket); debugn (5, ">>> MPIO\n"); hexdump (cmdpacket, sizeof(cmdpacket)); -- cgit v1.2.3