aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2002-10-13 12:03:50 +0000
committergermeier <germeier>2002-10-13 12:03:50 +0000
commit01470454b01b386c48645a2d76c643d1d327dbfd (patch)
treebb7697cd5be1355522c992b1d94b6e6d3ca5d07f
parent141157486f76c858a3f983f3a2c3d63f452693fb (diff)
downloadmpiosh-01470454b01b386c48645a2d76c643d1d327dbfd.tar.gz
mpiosh-01470454b01b386c48645a2d76c643d1d327dbfd.tar.bz2
mpiosh-01470454b01b386c48645a2d76c643d1d327dbfd.zip
finished support for external memory!
-rw-r--r--ChangeLog4
-rw-r--r--libmpio/fat.c6
-rw-r--r--libmpio/io.c114
-rw-r--r--libmpio/mpio.c4
-rw-r--r--mpiosh/callback.c6
5 files changed, 82 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index ea0e704..eb0232e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2002-10-13 Markus Germeier <mager@tzi.de>
+ * all operations on external memory should work now!
+
+2002-10-13 Markus Germeier <mager@tzi.de>
+
* libmpio/mpio.c (mpio_init): fixed segv when external memory
was selected
* formatting of external memory is now completly supported
diff --git a/libmpio/fat.c b/libmpio/fat.c
index fdb6965..ad9f9dd 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.c,v 1.17 2002/10/13 08:57:31 germeier Exp $
+ * $Id: fat.c,v 1.18 2002/10/13 12:03:51 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -837,10 +837,10 @@ mpio_fat_write(mpio_t *m, mpio_mem_t mem)
for (i = 0; i < (sm->dir_offset + DIR_NUM) ; i++) {
/* before writing to a new block delete it! */
if (((i / 0x20) * 0x20) == i) {
- block = mpio_zone_block_find_seq(m, mem, i);
+ block = mpio_zone_block_find_seq(m, mem, (i/0x20));
if (block == MPIO_BLOCK_NOT_FOUND)
{
- block = mpio_zone_block_find_free_seq(m, mem, i);
+ block = mpio_zone_block_find_free_seq(m, mem, (i/0x20));
}
if (block == MPIO_BLOCK_NOT_FOUND)
{
diff --git a/libmpio/io.c b/libmpio/io.c
index 856f453..87b74fe 100644
--- a/libmpio/io.c
+++ b/libmpio/io.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.c,v 1.19 2002/10/13 08:57:31 germeier Exp $
+ * $Id: io.c,v 1.20 2002/10/13 12:03:51 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -440,8 +440,13 @@ mpio_zone_block_find_free_seq(mpio_t *m, mpio_cmd_t mem, DWORD lblock)
WORD
mpio_zone_block_get_logical(mpio_t *m, mpio_cmd_t mem, DWORD pblock)
{
-
- return 0;
+ int zone, block, pb;
+
+ pb = pblock / BLOCK_SECTORS;
+ zone = pb / MPIO_ZONE_PBLOCKS;
+ block = pb % MPIO_ZONE_PBLOCKS;
+
+ return m->external.zonetable[zone][block];
}
@@ -761,49 +766,54 @@ mpio_io_sector_write(mpio_t *m, BYTE mem, DWORD index, BYTE *input)
* - calculate the logical block for zone management
*/
- if (index==MPIO_BLOCK_DEFECT)
- {
- block_address = 0;
- pvalue = 0;
- } else {
- if ((index>=MPIO_BLOCK_CIS) && (index<(MPIO_BLOCK_CIS + BLOCK_SECTORS)))
+ if (mem == MPIO_EXTERNAL_MEM)
+ {
+ if (index==MPIO_BLOCK_DEFECT)
{
block_address = 0;
- if (index==MPIO_BLOCK_CIS)
+ pvalue = 0;
+ } else {
+ if ((index>=MPIO_BLOCK_CIS) &&
+ (index<(MPIO_BLOCK_CIS + BLOCK_SECTORS)))
{
- pvalue=mpio_zone_block_find_free_seq(m, mem, index);
- } else {
- /* find the block from the block list! */
- pvalue=mpio_zone_block_find_seq(m, mem, MPIO_BLOCK_CIS);
+ block_address = 0;
+ if (index==MPIO_BLOCK_CIS)
+ {
+ pvalue=mpio_zone_block_find_free_seq(m, mem, index);
+ } else {
+ /* find the block from the block list! */
+ pvalue=mpio_zone_block_find_seq(m, mem, MPIO_BLOCK_CIS);
+ }
+ if (pvalue != MPIO_BLOCK_NOT_FOUND)
+ pvalue = pvalue + index - MPIO_BLOCK_CIS;
+
+ } else {
+ block_address = blockaddress_encode(index / BLOCK_SECTORS);
+ if ((index % BLOCK_SECTORS) == 0)
+ {
+ /* this is the first write to the block: allocate a new one */
+ /* ... and mark it with the block_address */
+ pvalue=mpio_zone_block_find_free_seq(m, mem,
+ (index / BLOCK_SECTORS));
+ } else {
+ /* find the block from the block list! */
+ pvalue=mpio_zone_block_find_seq(m, mem, (index / BLOCK_SECTORS));
+ }
+ if (pvalue != MPIO_BLOCK_NOT_FOUND)
+ pvalue = pvalue + (index % BLOCK_SECTORS);
+
}
- if (pvalue != MPIO_BLOCK_NOT_FOUND)
- pvalue = pvalue + index - MPIO_BLOCK_CIS;
- } else {
- block_address = blockaddress_encode(index / BLOCK_SECTORS);
- if ((index % BLOCK_SECTORS) == 0)
+ if (pvalue == MPIO_BLOCK_NOT_FOUND)
{
- /* this is the first write to the block, so allocate a new one */
- /* ... and mark it with the block_address */
- pvalue=mpio_zone_block_find_free_seq(m, mem,
- (index / BLOCK_SECTORS));
- } else {
- /* find the block from the block list! */
- pvalue=mpio_zone_block_find_seq(m, mem, (index / BLOCK_SECTORS));
- }
- if (pvalue != MPIO_BLOCK_NOT_FOUND)
- pvalue = pvalue + (index % BLOCK_SECTORS);
-
+ debug ("Oops, this should never happen! (%6x : %6x)\n",
+ index, block_address);
+ exit (-1);
+ }
}
-
- if (pvalue == MPIO_BLOCK_NOT_FOUND)
- {
- debug ("Oops, this should never happen! (%6x : %6x)\n",
- index, block_address);
- exit (-1);
- }
+ } else {
+ pvalue = index;
}
-
mpio_io_set_cmdpacket(m, PUT_SECTOR, mem, pvalue, sm->size, 0, cmdpacket);
@@ -1028,6 +1038,12 @@ mpio_io_block_delete(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f)
fatentry2hw(f, &chip, &address);
+ if (address == MPIO_BLOCK_NOT_FOUND)
+ {
+ debug("hmm, what happens here? (%4x)\n", f->entry);
+ return 0;
+ }
+
return (mpio_io_block_delete_phys(m, chip, address));
}
@@ -1083,7 +1099,7 @@ mpio_io_block_delete_phys(mpio_t *m, BYTE chip, DWORD address)
if (chip == MPIO_EXTERNAL_MEM)
{
sm = &m->external;
- mpio_zone_block_set_free_phys(m, chip, address);
+ mpio_zone_block_set_defect_phys(m, chip, address);
}
}
@@ -1101,10 +1117,19 @@ mpio_io_block_write(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f, BYTE *data)
BYTE chip=0;
DWORD address;
- if (mem == MPIO_INTERNAL_MEM) sm = &m->internal;
- if (mem == MPIO_EXTERNAL_MEM) sm = &m->external;
-
- fatentry2hw(f, &chip, &address);
+ if (mem == MPIO_INTERNAL_MEM)
+ {
+ sm = &m->internal;
+ fatentry2hw(f, &chip, &address);
+ }
+
+ if (mem == MPIO_EXTERNAL_MEM)
+ {
+ sm = &m->external;
+ /* find free physical block */
+ chip = MPIO_EXTERNAL_MEM;
+ address = mpio_zone_block_find_free_log(m, mem, f->entry);
+ }
/* build block for transfer to MPIO */
for (i = 0; i < BLOCK_SECTORS; i++)
@@ -1129,7 +1154,8 @@ mpio_io_block_write(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f, BYTE *data)
/* fill in block information */
if (mem == MPIO_EXTERNAL_MEM)
{
-/* block_address = cluster2blockaddress(address, sm->size); */
+ block_address = mpio_zone_block_get_logical(m, mem, address);
+ block_address = blockaddress_encode(block_address);
ba = (block_address / 0x100) & 0xff;
sendbuff[(i * SECTOR_TRANS) + SECTOR_SIZE + 0x06] = ba;
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 8ca99e5..11ae5c7 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.32 2002/10/13 08:57:31 germeier Exp $
+ * $Id: mpio.c,v 1.33 2002/10/13 12:03:51 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -837,7 +837,7 @@ mpio_file_del(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
}
} while (mpio_fatentry_next_entry(m, mem, f));
- mpio_io_block_delete(m, mem, &backup);
+/* mpio_io_block_delete(m, mem, &backup); */
mpio_fatentry_set_free(m, mem, &backup);
free(f);
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index 3c59f4d..126199d 100644
--- a/mpiosh/callback.c
+++ b/mpiosh/callback.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.c,v 1.23 2002/10/13 08:57:31 germeier Exp $
+ * $Id: callback.c,v 1.24 2002/10/13 12:03:51 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -181,8 +181,8 @@ mpiosh_cmd_mem(char *args[])
printf("Support for external memory is work in progress!!\n");
printf("Assumed status:\n");
printf("reading : works (untested)\n");
- printf("deleting : broken\n");
- printf("writing : broken\n");
+ printf("deleting : works (untested)\n");
+ printf("writing : works (untested)\n");
printf("formatting: complete (untested)\n");
printf("external memory card is selected\n");
} else {