aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2002-09-15 12:03:22 +0000
committergermeier <germeier>2002-09-15 12:03:22 +0000
commita9c7d297c5244f6ffc5ac0f977b56f7e19d14cd1 (patch)
tree9fcfa9442c1574c9c7dee5b8ff4dd0560888e881
parentf8ffc3a54f0f6dce3929b32fb582a77d871e87a3 (diff)
downloadmpiosh-a9c7d297c5244f6ffc5ac0f977b56f7e19d14cd1.tar.gz
mpiosh-a9c7d297c5244f6ffc5ac0f977b56f7e19d14cd1.tar.bz2
mpiosh-a9c7d297c5244f6ffc5ac0f977b56f7e19d14cd1.zip
added model identification
use 0x80 for external memory on the DMG line added code to dump first 0x100 sectors of memory
-rw-r--r--ChangeLog10
-rw-r--r--libmpio/defs.h28
-rw-r--r--libmpio/io.c42
-rw-r--r--libmpio/io.h4
-rw-r--r--libmpio/mpio.c48
-rw-r--r--libmpio/mpio.h5
-rw-r--r--mpiosh/callback.c20
-rw-r--r--mpiosh/callback.h3
-rw-r--r--mpiosh/mpiosh.c5
9 files changed, 137 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index c4c52df..8de45e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-09-15 Markus Germeier <mager@tzi.de>
+
+ * mpiosh/callback.c (mpiosh_cmd_debug_mem): added function
+ call "debug_memory" in mpiosh
+ * libmpio/io.c (model2externalmem): added function
+ (mpio_io_set_cmdpacket): use model2externalmem
+ * libmpio/mpio.c (mpio_init): added code to identify different
+ models
+ (mpio_memory_debug): added function for debugging purposes
+
2002-09-15 Andreas Buesching <crunchy@tzi.de>
* mpiosh/mpiosh.c: add a debug message, displaying the executed
diff --git a/libmpio/defs.h b/libmpio/defs.h
index ad4177c..0032893 100644
--- a/libmpio/defs.h
+++ b/libmpio/defs.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: defs.h,v 1.3 2002/09/11 00:18:34 germeier Exp $
+ * $Id: defs.h,v 1.4 2002/09/15 12:03:23 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -38,6 +38,22 @@ typedef unsigned int DWORD;
typedef enum { MPIO_INTERNAL_MEM = 0x01,
MPIO_EXTERNAL_MEM = 0x10 } mpio_mem_t;
+/* model type */
+typedef enum { MPIO_MODEL_DME = 0x00,
+ MPIO_MODEL_DMG = 0x01,
+ MPIO_MODEL_DMB = 0x02,
+ MPIO_MODEL_DMB_PLUS = 0x03,
+ MPIO_MODEL_DMK = 0x04,
+ MPIO_MODEL_UNKNOWN = 0x05 } mpio_model_t;
+
+static BYTE *mpio_model_name[] = {
+ "MPIO-DME",
+ "MPIO-DMG",
+ "MPIO-DMB",
+ "MPIO-DMB+",
+ "MPIO-DMK",
+ "unknown" };
+
/* USB commands */
typedef enum { GET_VERSION = 0x01,
GET_BLOCK = 0x02,
@@ -84,12 +100,14 @@ typedef enum { FTYPE_CONF = 'C',
/* get formatted information, about the MPIO player */
typedef struct {
- BYTE firmware_id[INFO_LINE];
+ BYTE firmware_id[INFO_LINE];
BYTE firmware_version[INFO_LINE];
BYTE firmware_date[INFO_LINE];
- BYTE firmware_mem_internal[INFO_LINE];
- BYTE firmware_mem_external[INFO_LINE];
+ BYTE model[INFO_LINE];
+
+ BYTE mem_internal[INFO_LINE];
+ BYTE mem_external[INFO_LINE];
} mpio_info_t;
@@ -152,6 +170,8 @@ typedef struct {
mpio_firmware_t firmware;
+ mpio_model_t model;
+
mpio_smartmedia_t internal;
mpio_smartmedia_t external;
} mpio_t;
diff --git a/libmpio/io.c b/libmpio/io.c
index f4a5daf..ebce296 100644
--- a/libmpio/io.c
+++ b/libmpio/io.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.c,v 1.11 2002/09/11 13:44:30 germeier Exp $
+ * $Id: io.c,v 1.12 2002/09/15 12:03:23 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -44,11 +44,28 @@
#include "debug.h"
#include "ecc.h"
+BYTE model2externalmem(mpio_model_t);
WORD index2blockaddress(WORD);
WORD cluster2blockaddress(DWORD, BYTE);
int cluster2block(int mem, int sector);
void fatentry2hw(mpio_fatentry_t *, BYTE *, DWORD *);
+BYTE
+model2externalmem(mpio_model_t model)
+{
+ BYTE m;
+
+ switch(model)
+ {
+ case MPIO_MODEL_DMG:
+ m = 0x80;
+ default:
+ m = 0x10;
+ }
+
+ return m;
+}
+
void
fatentry2hw(mpio_fatentry_t *f, BYTE *chip, DWORD *address)
{
@@ -222,15 +239,20 @@ cluster2blockaddress(DWORD index, BYTE size)
*/
int
-mpio_io_set_cmdpacket(mpio_cmd_t cmd, mpio_mem_t mem, DWORD index,
+mpio_io_set_cmdpacket(mpio_t *m, mpio_cmd_t cmd, mpio_mem_t mem, DWORD index,
BYTE size, BYTE wsize, BYTE *buffer)
{
+ BYTE memory;
/* clear cmdpacket*/
memset(buffer, 0, 0x40);
*buffer = cmd;
- *(buffer + 0x01) = mem;
+ memory = mem;
+ if (mem == MPIO_EXTERNAL_MEM)
+ memory = model2externalmem(m->model);
+
+ *(buffer + 0x01) = memory;
*(buffer + 0x03) = (BYTE) (index & 0x00ff);
*(buffer + 0x04) = (BYTE)((index & 0xff00) >> 8);
/* SM cards with less or equal 32 MB only need 2 Bytes
@@ -340,7 +362,7 @@ mpio_io_version_read(mpio_t *m, BYTE *buffer)
BYTE cmdpacket[CMD_SIZE], status[CMD_SIZE];
/* Send command packet to MPIO */
- mpio_io_set_cmdpacket (GET_VERSION, 0, 0, 0xff, 0, cmdpacket);
+ mpio_io_set_cmdpacket (m, GET_VERSION, 0, 0, 0xff, 0, cmdpacket);
debugn (5, ">>> MPIO\n");
hexdump (cmdpacket, sizeof(cmdpacket));
@@ -404,7 +426,7 @@ mpio_io_sector_read(mpio_t *m, BYTE mem, DWORD index, BYTE *output)
exit (-1);
}
- mpio_io_set_cmdpacket (GET_SECTOR, mem, index, sm->size, 0, cmdpacket);
+ mpio_io_set_cmdpacket (m, GET_SECTOR, mem, index, sm->size, 0, cmdpacket);
debugn (5, "\n>>> MPIO\n");
hexdump (cmdpacket, sizeof(cmdpacket));
@@ -488,7 +510,7 @@ mpio_io_sector_write(mpio_t *m, BYTE mem, DWORD index, BYTE *input)
exit (-1);
}
- mpio_io_set_cmdpacket(PUT_SECTOR, mem, index, sm->size, 0, cmdpacket);
+ mpio_io_set_cmdpacket(m, PUT_SECTOR, mem, index, sm->size, 0, cmdpacket);
debugn (5, "\n>>> MPIO\n");
hexdump (cmdpacket, sizeof(cmdpacket));
@@ -564,7 +586,7 @@ mpio_io_block_read(mpio_t *m, BYTE mem, mpio_fatentry_t *f, BYTE *output)
fatentry2hw(f, &chip, &address);
- mpio_io_set_cmdpacket(GET_BLOCK, chip, address, sm->size, 0, cmdpacket);
+ mpio_io_set_cmdpacket(m, GET_BLOCK, chip, address, sm->size, 0, cmdpacket);
debugn(5, "\n>>> MPIO\n");
hexdump(cmdpacket, sizeof(cmdpacket));
@@ -654,7 +676,7 @@ mpio_io_spare_read(mpio_t *m, BYTE area, DWORD index, BYTE size,
for (chip = 1; chip <= chips; chip++)
{
- mpio_io_set_cmdpacket(GET_SPARE_AREA, chip, index, size,
+ mpio_io_set_cmdpacket(m, GET_SPARE_AREA, chip, index, size,
wsize, cmdpacket);
debugn(5, "\n>>> MPIO\n");
hexdump(cmdpacket, sizeof(cmdpacket));
@@ -706,7 +728,7 @@ mpio_io_block_delete(mpio_t *m, BYTE mem, mpio_fatentry_t *f)
/* Send command packet to MPIO */
- mpio_io_set_cmdpacket(DEL_BLOCK, chip, address, sm->size, 0, cmdpacket);
+ mpio_io_set_cmdpacket(m, DEL_BLOCK, chip, address, sm->size, 0, cmdpacket);
debugn (5, ">>> MPIO\n");
hexdump (cmdpacket, sizeof(cmdpacket));
@@ -803,7 +825,7 @@ mpio_io_block_write(mpio_t *m, BYTE mem, mpio_fatentry_t *f, BYTE *data)
}
}
- mpio_io_set_cmdpacket(PUT_BLOCK, chip, address, sm->size, 0x48 , cmdpacket);
+ mpio_io_set_cmdpacket(m, PUT_BLOCK, chip, address, sm->size, 0x48 , cmdpacket);
debugn(5, "\n>>> MPIO\n");
hexdump(cmdpacket, sizeof(cmdpacket));
diff --git a/libmpio/io.h b/libmpio/io.h
index 0f97eed..330a494 100644
--- a/libmpio/io.h
+++ b/libmpio/io.h
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.h,v 1.5 2002/09/10 12:31:09 germeier Exp $
+ * $Id: io.h,v 1.6 2002/09/15 12:03:23 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -34,7 +34,7 @@
#include "defs.h"
/* real I/O */
-int mpio_io_set_cmdpacket(mpio_cmd_t, mpio_mem_t,
+int mpio_io_set_cmdpacket(mpio_t *, mpio_cmd_t, mpio_mem_t,
DWORD, BYTE, BYTE, BYTE *);
int mpio_io_bulk_read (int, BYTE *, int);
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index f65b47e..51a2894 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.16 2002/09/14 22:54:41 germeier Exp $
+ * $Id: mpio.c,v 1.17 2002/09/15 12:03:23 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -158,7 +158,6 @@ mpio_init(void)
mpio_io_version_read(new_mpio, new_mpio->version);
/* fill in values */
- /* TODO: check for different versions !! */
snprintf(new_mpio->firmware.id, 12, "%s", new_mpio->version);
snprintf(new_mpio->firmware.major, 3, "%s", new_mpio->version + 0x0c);
snprintf(new_mpio->firmware.minor, 3, "%s", new_mpio->version + 0x0e);
@@ -166,6 +165,27 @@ mpio_init(void)
snprintf(new_mpio->firmware.month, 3, "%s", new_mpio->version + 0x14);
snprintf(new_mpio->firmware.day, 3, "%s", new_mpio->version + 0x16);
+ /* identify different versions */
+ switch (new_mpio->version[5])
+ {
+ case 'E':
+ new_mpio->model = MPIO_MODEL_DME;
+ break ;
+ case 'K':
+ new_mpio->model = MPIO_MODEL_DMK;
+ break ;
+ case 'G':
+ new_mpio->model = MPIO_MODEL_DMG;
+ break ;
+ case 'B':
+ new_mpio->model = MPIO_MODEL_DMB;
+ if (new_mpio->version[6] == 'P')
+ new_mpio->model = MPIO_MODEL_DMB_PLUS;
+ break;
+ default:
+ new_mpio->model = MPIO_MODEL_UNKNOWN;
+ }
+
/* internal init */
mpio_init_internal(new_mpio);
@@ -225,14 +245,15 @@ mpio_get_info(mpio_t *m, mpio_info_t *info)
m->firmware.major, m->firmware.minor);
snprintf(info->firmware_date, max, "%s.%s.%s",
m->firmware.day, m->firmware.month, m->firmware.year);
+ snprintf(info->model, max, "%s", mpio_model_name[m->model]);
if (m->internal.chips == 1)
{
- snprintf(info->firmware_mem_internal, max, "%3dMB (%s)",
+ snprintf(info->mem_internal, max, "%3dMB (%s)",
mpio_id2mem(m->internal.id),
mpio_id2manufacturer(m->internal.manufacturer));
} else {
- snprintf(info->firmware_mem_internal, max, "%3dMB (%s) - %d chips",
+ snprintf(info->mem_internal, max, "%3dMB (%s) - %d chips",
mpio_id2mem(m->internal.id)*m->internal.chips,
mpio_id2manufacturer(m->internal.manufacturer),
m->internal.chips);
@@ -240,11 +261,11 @@ mpio_get_info(mpio_t *m, mpio_info_t *info)
if (m->external.id)
{
- snprintf(info->firmware_mem_external, max, "%3dMB (%s)",
+ snprintf(info->mem_external, max, "%3dMB (%s)",
mpio_id2mem(m->external.id),
mpio_id2manufacturer(m->external.manufacturer));
} else {
- snprintf(info->firmware_mem_external, max, "not available");
+ snprintf(info->mem_external, max, "not available");
}
}
@@ -666,5 +687,20 @@ mpio_sync(mpio_t *m, mpio_mem_t mem)
mpio_fat_write(m, mem);
}
+int
+mpio_memory_debug(mpio_t *m, mpio_mem_t mem)
+{
+ BYTE block[BLOCK_SIZE];
+ int i;
+
+ for (i = 0 ; i<=0x100 ; i++)
+ mpio_io_sector_read(m, mem, i, block);
+
+ return 0;
+}
+
+
+
+
diff --git a/libmpio/mpio.h b/libmpio/mpio.h
index 0acf8c9..6ace073 100644
--- a/libmpio/mpio.h
+++ b/libmpio/mpio.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: mpio.h,v 1.3 2002/09/14 22:54:41 germeier Exp $
+ * $Id: mpio.h,v 1.4 2002/09/15 12:03:23 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -91,6 +91,9 @@ int mpio_memory_format(mpio_t *, mpio_mem_t, BYTE (*)(int, int));
/* context, memory bank */
int mpio_sync(mpio_t *, mpio_mem_t);
+/* context, memory bank */
+int mpio_memory_debug(mpio_t *, mpio_mem_t);
+
/*
* timeline:
* ---------
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index cc520d5..ca89a82 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.6 2002/09/14 22:54:41 germeier Exp $
+ * $Id: callback.c,v 1.7 2002/09/15 12:03:23 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -151,9 +151,10 @@ mpiosh_cmd_info(char *args[])
printf("firmware %s\n", info.firmware_id);
printf(" version : %s\n", info.firmware_version);
printf(" date : %s\n", info.firmware_date);
+ printf("model : %s\n", info.model);
printf("memory\n");
- printf(" internal: %s\n", info.firmware_mem_internal);
- printf(" external: %s\n", info.firmware_mem_external);
+ printf(" internal: %s\n", info.mem_internal);
+ printf(" external: %s\n", info.mem_external);
}
void
@@ -525,6 +526,19 @@ mpiosh_cmd_switch(char *args[])
}
void
+mpiosh_cmd_debug_mem(char *args[])
+{
+
+ MPIOSH_CHECK_CONNECTION_CLOSED;
+
+ UNUSED(args);
+
+ mpio_memory_debug(mpiosh.dev, mpiosh.card);
+
+}
+
+
+void
mpiosh_cmd_ldir(char *args[])
{
char dir_buf[NAME_MAX];
diff --git a/mpiosh/callback.h b/mpiosh/callback.h
index 622ab00..92642fa 100644
--- a/mpiosh/callback.h
+++ b/mpiosh/callback.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.h,v 1.2 2002/09/13 15:20:25 crunchy Exp $
+ * $Id: callback.h,v 1.3 2002/09/15 12:03:23 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -46,6 +46,7 @@ void mpiosh_cmd_dump(char *args[]);
void mpiosh_cmd_free(char *args[]);
void mpiosh_cmd_format(char *args[]);
void mpiosh_cmd_switch(char *args[]);
+void mpiosh_cmd_debug_mem(char *args[]);
/* local command callbacks */
void mpiosh_cmd_ldir(char *args[]);
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c
index 098adaa..30a773c 100644
--- a/mpiosh/mpiosh.c
+++ b/mpiosh/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.10 2002/09/14 23:34:49 crunchy Exp $
+ * $Id: mpiosh.c,v 1.11 2002/09/15 12:03:23 germeier Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -124,6 +124,9 @@ mpiosh_cmd_t commands[] = {
{ "lmkdir", NULL,
"create a local directory",
mpiosh_cmd_lmkdir },
+ { "debug_memory", NULL,
+ "dump the first 0x100 of the selected memory card",
+ mpiosh_cmd_debug_mem },
{ NULL, NULL, NULL, NULL }
};