aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--libmpio/defs.h4
-rw-r--r--libmpio/fat.c16
-rw-r--r--libmpio/io.c12
-rw-r--r--libmpio/mpio.c40
5 files changed, 57 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e39f3e..43de53c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-03-15 Markus Germeier <mager@tzi.de>
+
+ * libmpio/mpio.c (mpio_init_internal): detect up to four
+ internal memory chips
+ * libmpio/fat.c (mpio_fatentry_hw2entry, mpio_fatentry_entry2hw):
+ libmpio/io.c (mpio_io_block_delete_phys, mpio_io_spare_read):
+ changes to support four internal chips
+
2003-03-14 Andreas Buesching <crunchy@tzi.de>
* mpio.spec.in:
diff --git a/libmpio/defs.h b/libmpio/defs.h
index 97a1f9e..4403bb0 100644
--- a/libmpio/defs.h
+++ b/libmpio/defs.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: defs.h,v 1.15 2003/03/11 01:45:30 germeier Exp $
+ * $Id: defs.h,v 1.16 2003/03/15 13:24:58 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -179,7 +179,7 @@ typedef struct {
BYTE size; /* MB */
BYTE chips; /* this is the hack for
MPIO internal representation, because
- there might be two chips involved */
+ there might be up to four chips involved */
/* only needed for external SmartMedia cards */
mpio_disk_phy_t geo;
diff --git a/libmpio/fat.c b/libmpio/fat.c
index f712967..00ec0f7 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
- /*
+/*
*
- * $Id: fat.c,v 1.20 2002/11/14 00:00:59 germeier Exp $
+ * $Id: fat.c,v 1.21 2003/03/15 13:24:58 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -241,7 +241,7 @@ void
mpio_fatentry_hw2entry(mpio_t *m, mpio_fatentry_t *f)
{
mpio_smartmedia_t *sm;
- BYTE chip;
+ BYTE chip, t;
DWORD value;
if (f->mem == MPIO_INTERNAL_MEM)
@@ -252,11 +252,15 @@ mpio_fatentry_hw2entry(mpio_t *m, mpio_fatentry_t *f)
return ;
value = f->hw_address;
- chip = value >> 24;
+ t = value >> 24;
+ chip = 0;
+
+ while(t/=2)
+ chip++;
value &= 0xffffff;
value /= 0x20;
- value += (chip-1) * (sm->max_cluster / sm->chips);
+ value += chip * (sm->max_cluster / sm->chips);
f->entry = value;
@@ -284,7 +288,7 @@ mpio_fatentry_entry2hw(mpio_t *m, mpio_fatentry_t *f)
chip = f->entry / (sm->max_cluster / sm->chips);
cluster = f->entry - ((sm->max_cluster / sm->chips) * chip);
cluster *= 0x20;
- cluster += 0x01000000 * (chip+1);
+ cluster += 0x01000000 * (chip^2);
f->hw_address=cluster;
diff --git a/libmpio/io.c b/libmpio/io.c
index f41f018..d94b8d4 100644
--- a/libmpio/io.c
+++ b/libmpio/io.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.c,v 1.21 2002/10/23 00:03:42 germeier Exp $
+ * $Id: io.c,v 1.22 2003/03/15 13:24:58 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -982,8 +982,8 @@ mpio_io_spare_read(mpio_t *m, BYTE mem, DWORD index, BYTE size,
for (chip = 1; chip <= chips; chip++)
{
if (mem == MPIO_INTERNAL_MEM)
- mpio_io_set_cmdpacket(m, GET_SPARE_AREA, chip, index, size,
- wsize, cmdpacket);
+ mpio_io_set_cmdpacket(m, GET_SPARE_AREA, ((chip-1)^2),
+ index, size, wsize, cmdpacket);
if (mem == MPIO_EXTERNAL_MEM)
mpio_io_set_cmdpacket(m, GET_SPARE_AREA, mem, index, size,
wsize, cmdpacket);
@@ -1059,8 +1059,12 @@ mpio_io_block_delete_phys(mpio_t *m, BYTE chip, DWORD address)
/* Send command packet to MPIO */
if (chip == MPIO_INTERNAL_MEM) sm = &m->internal;
- /* uhoh, this breaks if we have more than two internal chips! */
+ /* hack to support 2+4 internal chips
+ * who ever allowed me to write code??? -mager
+ */
if (chip == (MPIO_INTERNAL_MEM+1)) sm = &m->internal;
+ if (chip == (MPIO_INTERNAL_MEM+3)) sm = &m->internal;
+ if (chip == (MPIO_INTERNAL_MEM+7)) sm = &m->internal;
if (chip == MPIO_EXTERNAL_MEM)
{
sm = &m->external;
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 594ba0a..679a57f 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.41 2003/03/11 01:45:30 germeier Exp $
+ * $Id: mpio.c,v 1.42 2003/03/15 13:24:59 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -42,6 +42,7 @@
#include "smartmedia.h"
#include "fat.h"
+void mpio_bail_out(void);
void mpio_init_internal(mpio_t *);
void mpio_init_external(mpio_t *);
int mpio_check_filename(mpio_filename_t);
@@ -92,6 +93,13 @@ static int _mpio_errno = 0;
MPIO_ERR_RETURN(MPIO_ERR_INT_STRING_INVALID); \
}
+void
+mpio_bail_out(void){
+ printf("I'm utterly confused and aborting now, sorry!");
+ printf("Please report this to: mpio-devel@lists.sourceforge.net\n");
+ exit(1);
+}
+
int
mpio_check_filename(mpio_filename_t filename)
{
@@ -129,19 +137,29 @@ mpio_init_internal(mpio_t *m)
}
- /* look for a second installed memory chip */
- if (mpio_id_valid(m->version[i_offset + 2]))
+ /* look for further installed memory chips
+ * models with 1, 2 and 4 chips are known
+ * (there _really_ shouldn't be any other versions out there ...)
+ */
+ while ((sm->chips < 4) &&
+ (mpio_id_valid(m->version[i_offset + (2 * sm->chips)])))
{
- if(mpio_id2mem(sm->id) != mpio_id2mem(m->version[i_offset + 3]))
+ if(mpio_id2mem(sm->id) !=
+ mpio_id2mem(m->version[i_offset + (2 * sm->chips) + 1]))
{
- printf("Found a MPIO with two chips with different size!");
- printf("I'm utterly confused and aborting now, sorry!");
- printf("Please report this to: mpio-devel@lists.sourceforge.net\n");
- exit(1);
+ printf("Found a MPIO with internal chips of different sizes!");
+ mpio_bail_out();
}
- sm->size = 2 * mpio_id2mem(sm->id);
- sm->chips = 2;
- }
+ sm->chips++;
+ }
+
+ if ((sm->chips == 3) || (sm->chips > 4))
+ {
+ printf("Found a MPIO with %d internal chips", sm->chips);
+ mpio_bail_out();
+ }
+
+ sm->size = sm->chips * mpio_id2mem(sm->id);
/* used for size calculations (see mpio_memory_free) */
mpio_id2geo(sm->id, &sm->geo);