aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2002-09-08 23:22:48 +0000
committergermeier <germeier>2002-09-08 23:22:48 +0000
commita14db4165ee76dac3d04b815ba258f3f6a3f7f40 (patch)
treec6ce63f8e051e1dad4ad338bef2d6067a59ea393
parent13d3be139c5209a0c0d20159c85c91f59906a471 (diff)
downloadmpiosh-a14db4165ee76dac3d04b815ba258f3f6a3f7f40.tar.gz
mpiosh-a14db4165ee76dac3d04b815ba258f3f6a3f7f40.tar.bz2
mpiosh-a14db4165ee76dac3d04b815ba258f3f6a3f7f40.zip
fixed some issues for MPIOs with more than one internal chip
-rw-r--r--ChangeLog15
-rw-r--r--libmpio/directory.c9
-rw-r--r--libmpio/fat.c100
-rw-r--r--libmpio/fat.h5
-rw-r--r--libmpio/mpio.c12
5 files changed, 101 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 179167a..a5dd083 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-09-09 Markus Germeier <mager@informatik.uni-bremen.de>
+
+
+2002-09-09 Markus Germeier <mager@tzi.de>
+
+ * mpio_tool/mpiosh.c:
+ (mpiosh_cmd_mput):
+ (mpiosh_cmd_mget):
+ make info texts consistent with get and put
+ * libmpio/mpio.c (mpio_init_internal):
+ fixed max_clusters for internal memory with more
+ then one chip
+ * libmpio/fat.c (mpio_fatentry_hw2entry): added function
+ * libmpio/fat.c (mpio_fatentry_entry2hw): added function
+
2002-09-08 Markus Germeier <mager@tzi.de>
* mpio_tool/mpiosh.c:
diff --git a/libmpio/directory.c b/libmpio/directory.c
index 10a4af0..e532376 100644
--- a/libmpio/directory.c
+++ b/libmpio/directory.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: directory.c,v 1.3 2002/09/03 21:20:53 germeier Exp $
+ * $Id: directory.c,v 1.4 2002/09/08 23:22:48 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -331,11 +331,8 @@ mpio_dentry_get_startcluster(mpio_t *m, mpio_mem_t mem, BYTE *p)
if (mem == MPIO_INTERNAL_MEM)
{
- cluster *= 0x20;
- cluster +=
- 0x01000000 * ((cluster / 0x20 / (m->internal.fat_size * SECTOR_SIZE /
- 0x10 / m->internal.chips)) + 1);
- new->hw_address=cluster;
+ new->entry=cluster;
+ mpio_fatentry_entry2hw(m, new);
}
return new;
diff --git a/libmpio/fat.c b/libmpio/fat.c
index 29a44fe..554a620 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.c,v 1.3 2002/09/03 21:20:53 germeier Exp $
+ * $Id: fat.c,v 1.4 2002/09/08 23:22:48 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -30,6 +30,68 @@
#include <string.h>
#include <stdlib.h>
+void
+mpio_fatentry_hw2entry(mpio_t *m, mpio_fatentry_t *f)
+{
+ mpio_smartmedia_t *sm;
+ BYTE chip;
+ DWORD value;
+
+ if (f->mem == MPIO_INTERNAL_MEM)
+ {
+ sm = &m->internal;
+
+ if (f->hw_address == 0xffffffff)
+ return ;
+
+ value = f->hw_address;
+ chip = value >> 24;
+
+ value &= 0xffffff;
+ value /= 0x20;
+ value += (chip-1) * (sm->max_cluster / sm->chips);
+
+ f->entry = value;
+
+ return;
+ }
+
+ debug("This should never happen!\n");
+ exit(-1);
+
+ return;
+}
+
+
+void
+mpio_fatentry_entry2hw(mpio_t *m, mpio_fatentry_t *f)
+{
+ mpio_smartmedia_t *sm;
+ DWORD cluster;
+ BYTE chip;
+
+ if (f->mem == MPIO_INTERNAL_MEM)
+ {
+ sm = &m->internal;
+
+ chip = f->entry / (sm->max_cluster / sm->chips);
+ cluster = f->entry - ((sm->max_cluster / sm->chips) * chip);
+ cluster *= 0x20;
+ cluster += 0x01000000 * (chip+1);
+
+ f->hw_address=cluster;
+
+ return;
+ }
+
+ debug("This should never happen!\n");
+ exit(-1);
+
+ return;
+}
+
+
+
int
mpio_bootblocks_read (mpio_t *m, mpio_mem_t mem)
{
@@ -391,54 +453,36 @@ mpio_fatentry_next_entry(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f)
mpio_smartmedia_t *sm;
DWORD value;
DWORD endvalue;
- BYTE chip;
value = mpio_fatentry_read(m, mem, f);
- f->entry = value;
if (mem == MPIO_INTERNAL_MEM)
{
- sm = &m->internal;
+ sm = &m->internal;
f->hw_address = value;
- if (value == 0xffffffff)
- return 0;
-
- chip = value >> 24;
+ mpio_fatentry_hw2entry(m, f);
- value &= 0xffffff;
- value /= 0x20;
- value += (chip-1)
- * (m->internal.fat_size * SECTOR_SIZE / 0x10 / m->internal.chips);
-
-
-/* this is the opposite code in mpio_dentry_get_startcluster */
-/* cluster += */
-/* 0x01000000 * ((cluster / 0x20 / (m->internal.fat_size * SECTOR_SIZE / */
-/* 0x10 / m->internal.chips)) + 1); */
-
-
- f->entry = value;
-
+ endvalue = 0xffffffff;
}
if (mem == MPIO_EXTERNAL_MEM)
{
- sm = &m->external;
+ sm = &m->external;
+ f->entry = value;
if (sm->size==128)
{
endvalue = 0xfff8;
} else {
endvalue = 0xff8;
- }
-
- if (value >= endvalue)
- return 0;
-
+ }
}
+ if (value >= endvalue)
+ return 0;
+
return 1;
}
diff --git a/libmpio/fat.h b/libmpio/fat.h
index 1afa2c4..d392050 100644
--- a/libmpio/fat.h
+++ b/libmpio/fat.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.h,v 1.2 2002/09/03 21:20:53 germeier Exp $
+ * $Id: fat.h,v 1.3 2002/09/08 23:22:48 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -50,4 +50,7 @@ int mpio_fatentry_write(mpio_t *, mpio_mem_t, mpio_fatentry_t *,
int mpio_fat_internal_find_startsector(mpio_t *, BYTE);
+void mpio_fatentry_hw2entry(mpio_t *, mpio_fatentry_t *);
+void mpio_fatentry_entry2hw(mpio_t *, mpio_fatentry_t *);
+
#endif /* _MPIO_FAT_H_ */
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 5b69c06..8c8152d 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.3 2002/09/03 21:20:53 germeier Exp $
+ * $Id: mpio.c,v 1.4 2002/09/08 23:22:48 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -54,7 +54,6 @@ mpio_init_internal(mpio_t *m)
sm->manufacturer = m->version[i_offset];
sm->id = m->version[i_offset+1];
sm->size = mpio_id2mem(sm->id);
- sm->max_cluster = sm->size/16*1024;
sm->chips = 1;
/* look for a second installed memory chip */
@@ -74,9 +73,12 @@ mpio_init_internal(mpio_t *m)
/* used for size calculations (see mpio_memory_free) */
mpio_id2geo(sm->id, &sm->geo);
- /* read FAT information from spare area */
- sm->fat_size=sm->size*2; /* the *2 is need here! */
- sm->fat=malloc(sm->fat_size*SECTOR_SIZE);
+ /* read FAT information from spare area */
+ sm->max_cluster = sm->size/16*1024; /* 1 cluster == 16 KB */
+ debugn(2,"max_cluster: %d\n", sm->max_cluster);
+ /* 16 bytes per cluster */
+ sm->fat_size = sm->max_cluster*16/SECTOR_SIZE;
+ sm->fat = malloc(sm->fat_size*SECTOR_SIZE);
mpio_fat_read(m, MPIO_INTERNAL_MEM);
/* Read directory from internal memory */