aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2002-09-10 13:41:21 +0000
committergermeier <germeier>2002-09-10 13:41:21 +0000
commit196525ab0a4c2350cce745bfb1e6b340ced89d3c (patch)
treed0016a7ab1b1dfdaaa9ac2c06c83a81e6fb504b4
parentaead174ddcfc61eafa706c7fdff0c8b84dbd2128 (diff)
downloadmpiosh-196525ab0a4c2350cce745bfb1e6b340ced89d3c.tar.gz
mpiosh-196525ab0a4c2350cce745bfb1e6b340ced89d3c.tar.bz2
mpiosh-196525ab0a4c2350cce745bfb1e6b340ced89d3c.zip
support for deleting and formating of internal memory added
BEWARE: this might well kill your player !!!!
-rw-r--r--ChangeLog13
-rw-r--r--TODO6
-rw-r--r--libmpio/fat.c110
-rw-r--r--libmpio/io.c11
-rw-r--r--libmpio/mpio.c25
5 files changed, 106 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 4981b2c..cfc2395 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
-2002-09-10 Markus Germeier <mager@informatik.uni-bremen.de>
+2002-09-10 Markus Germeier <mager@tzi.de>
+
+ * libmpio/mpio.c (mpio_memory_format):
+ formatting works for internal and external memory now
+ BEWARE: No config files are written, you might ruin your
+ player!!!
+ * libmpio/mpio.c (mpio_file_del):
+ deleting works for internal and external memory now (BEWARE !!!)
+ * support for deleting/formatting added to various parts of
+ fat.c and io.c
+
+2002-09-10 Markus Germeier <mager@tzi.de>
* libmpio/fat.c (mpio_fatentry_set_free)
(mpio_fatentry_set_defect): added functions
diff --git a/TODO b/TODO
index 9bad0b7..87aea47 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.6 2002/09/09 15:48:56 germeier Exp $
+$Id: TODO,v 1.7 2002/09/10 13:41:21 germeier Exp $
* Kernel Module
- the MPIO can no multitasking, so:
@@ -12,13 +12,15 @@ $Id: TODO,v 1.6 2002/09/09 15:48:56 germeier Exp $
- implement ECC code (we want a GPL code for this)
[error checking works, TODO: error correction)
- use ECC code for every read/write operation!! [done]
- - implement reading of files
+ - implement reading of files [DONE]
- implement writing of files
+ - implement deleting of files [DONE]
If everything is done:
- implement formating of external memory [partially done]
* write code to fix defective CIS (??), MBR, PBR
- implement formating of internal memory (BEWARE !!!!)
+ [DONE: BEWARE no config files are written!!!!]
* mpio_tool [is deprecated, use mpiosh]
diff --git a/libmpio/fat.c b/libmpio/fat.c
index 170ab6c..3a5a087 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.c,v 1.7 2002/09/10 12:31:09 germeier Exp $
+ * $Id: fat.c,v 1.8 2002/09/10 13:41:21 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -226,13 +226,21 @@ mpio_fatentry_plus_plus(mpio_fatentry_t *f)
f->entry++;
if (f->mem == MPIO_INTERNAL_MEM) {
- if (f->entry > f->m->internal.max_cluster)
- return 0;
+ if (f->entry >= f->m->internal.max_cluster)
+ {
+ f->entry--;
+ mpio_fatentry_entry2hw(f->m, f);
+ return 0;
+ }
+ mpio_fatentry_entry2hw(f->m, f);
}
if (f->mem == MPIO_EXTERNAL_MEM) {
if (f->entry > f->m->external.max_cluster)
- return 0;
+ {
+ f->entry--;
+ return 0;
+ }
}
return 1;
@@ -414,7 +422,8 @@ mpio_fat_free_clusters(mpio_t *m, mpio_mem_t mem)
do
{
- if (mpio_fatentry_free(m, mem, f)) e++;
+ if (mpio_fatentry_free(m, mem, f))
+ e++;
} while (mpio_fatentry_plus_plus(f));
free(f);
@@ -503,11 +512,16 @@ int
mpio_fat_clear(mpio_t *m, mpio_mem_t mem)
{
mpio_smartmedia_t *sm;
+ mpio_fatentry_t *f;
- if (mem == MPIO_INTERNAL_MEM) {
+ if (mem == MPIO_INTERNAL_MEM) {
sm = &m->internal;
- debug("clearing of the internal FAT not yet supported , sorry\n");
- return 0;
+
+ f = mpio_fatentry_new(m, mem, 1);
+ do {
+ mpio_fatentry_set_free(m, mem, f) ;
+ } while(mpio_fatentry_plus_plus(f));
+ free(f);
}
if (mem == MPIO_EXTERNAL_MEM) {
@@ -540,41 +554,59 @@ mpio_fat_write(mpio_t *m, mpio_mem_t mem)
if (mem == MPIO_INTERNAL_MEM) {
sm = &m->internal;
- debug("ERROR: internal FAT is written during block or sector writes!\n");
- exit(-1);
+
+ f=mpio_fatentry_new(m, mem, 0);
+ mpio_io_block_delete(m, mem, f);
+ free(f);
+
+ memset(dummy, 0x00, BLOCK_SIZE);
+
+ for (i= 0; i< 0x20; i++)
+ {
+
+ if (i<DIR_NUM)
+ {
+ mpio_io_sector_write(m, mem, i, (sm->dir + SECTOR_SIZE * i));
+ } else {
+ mpio_io_sector_write(m, mem, i, dummy);
+ }
+ }
}
- if (mem == MPIO_EXTERNAL_MEM) sm=&m->external;
+ if (mem == MPIO_EXTERNAL_MEM)
+ {
+ sm=&m->external;
- memset(dummy, 0xff, BLOCK_SIZE);
+ memset(dummy, 0xff, BLOCK_SIZE);
- for (i = 0x40; i < (sm->dir_offset + DIR_NUM) ; i++) {
- if (((i / 0x20) * 0x20) == i) {
- /* yuck */
- f=mpio_fatentry_new(m, mem,
- ((i / 0x20) -
- ((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2 )));
- mpio_io_block_delete(m, mem, f);
- free(f);
- }
-
- if (i == 0x40)
- mpio_io_sector_write(m, mem, 0x40, sm->mbr);
- if ((i > 0x40) && (i < sm->pbr_offset))
- mpio_io_sector_write(m, mem, i, dummy);
-
- if (i == sm->pbr_offset)
- mpio_io_sector_write(m, mem, sm->pbr_offset, sm->pbr);
-
- if ((i >= sm->fat_offset) && (i < (sm->fat_offset + (2 * sm->fat_size))))
- mpio_io_sector_write(m, mem, i,
- (sm->fat + SECTOR_SIZE *
- ((i - sm->fat_offset) % sm->fat_size)));
-
- if (i>=sm->dir_offset)
- mpio_io_sector_write(m, mem, i,
- (sm->dir + (i - sm->dir_offset) * SECTOR_SIZE));
- }
+ for (i = 0x40; i < (sm->dir_offset + DIR_NUM) ; i++) {
+ if (((i / 0x20) * 0x20) == i) {
+ /* yuck */
+ f=mpio_fatentry_new(m, mem,
+ ((i / 0x20) -
+ ((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2 )));
+ mpio_io_block_delete(m, mem, f);
+ free(f);
+ }
+
+ if (i == 0x40)
+ mpio_io_sector_write(m, mem, 0x40, sm->mbr);
+ if ((i > 0x40) && (i < sm->pbr_offset))
+ mpio_io_sector_write(m, mem, i, dummy);
+
+ if (i == sm->pbr_offset)
+ mpio_io_sector_write(m, mem, sm->pbr_offset, sm->pbr);
+
+ if ((i >= sm->fat_offset) && (i < (sm->fat_offset + (2 * sm->fat_size))))
+ mpio_io_sector_write(m, mem, i,
+ (sm->fat + SECTOR_SIZE *
+ ((i - sm->fat_offset) % sm->fat_size)));
+
+ if (i>=sm->dir_offset)
+ mpio_io_sector_write(m, mem, i,
+ (sm->dir + (i - sm->dir_offset) * SECTOR_SIZE));
+ }
+ }
return 0;
}
diff --git a/libmpio/io.c b/libmpio/io.c
index 95692fe..126e111 100644
--- a/libmpio/io.c
+++ b/libmpio/io.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.c,v 1.7 2002/09/10 12:31:09 germeier Exp $
+ * $Id: io.c,v 1.8 2002/09/10 13:41:21 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -488,11 +488,9 @@ mpio_io_sector_write(mpio_t *m, BYTE mem, DWORD index, BYTE *input)
sendbuff[SECTOR_SIZE + 0x0c] = ba;
}
+ /* easy but working, we write back the FAT info we read before */
if (mem==MPIO_INTERNAL_MEM)
- {
- debug("WARNING, code for internal FAT entry (in ECC area)"
- " not yet in place!!\n");
- }
+ memcpy((sendbuff+SECTOR_SIZE), sm->fat, 0x10);
debugn (5, "\n>>> MPIO\n");
hexdump(sendbuff, SECTOR_TRANS);
@@ -688,7 +686,8 @@ mpio_io_block_delete(mpio_t *m, BYTE mem, mpio_fatentry_t *f)
if (status[0] != 0xc0)
{
- debug ("error formatting Block %04x\n", index);
+ debug ("error formatting Block (%04x) %02x:%06x\n",
+ f->entry, chip, address);
return 0;
}
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 552c126..67d2ddb 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.7 2002/09/10 12:31:09 germeier Exp $
+ * $Id: mpio.c,v 1.8 2002/09/10 13:41:21 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -442,6 +442,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
2002, 8, 13,
2, 12, fsize, startsector);
+ /* this writes the FAT *and* the root directory */
mpio_fat_write(m, mem);
return fsize-filesize;
@@ -460,9 +461,7 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem,
if (mem == MPIO_INTERNAL_MEM)
{
sm=&m->internal;
- data_offset=0x00;
- debug("formatting of internal memory is not yet supported, sorry\n");
- return 0;
+ data_offset = 0x01;
}
if (mem == MPIO_EXTERNAL_MEM)
@@ -489,15 +488,18 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem,
} while (mpio_fatentry_plus_plus(f));
free(f);
- /* format CIS area */
- f = mpio_fatentry_new(m, mem, /* yuck */
- (1 - ((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2 )));
- mpio_io_block_delete(m, mem, f);
- free(f);
- mpio_io_sector_write(m, mem, 0x20, sm->cis);
- mpio_io_sector_write(m, mem, 0x21, sm->cis);
+ if (mem == MPIO_EXTERNAL_MEM) {
+ /* format CIS area */
+ f = mpio_fatentry_new(m, mem, /* yuck */
+ (1-((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2)));
+ mpio_io_block_delete(m, mem, f);
+ free(f);
+ mpio_io_sector_write(m, mem, 0x20, sm->cis);
+ mpio_io_sector_write(m, mem, 0x21, sm->cis);
+ }
mpio_rootdir_clear(m, mem);
+ /* this writes the FAT *and* the root directory */
mpio_fat_write(m, mem);
if (progress_callback)
@@ -563,6 +565,7 @@ mpio_file_del(mpio_t *m, mpio_mem_t mem, BYTE *filename,
}
mpio_dentry_delete(m, mem, filename);
+ /* this writes the FAT *and* the root directory */
mpio_fat_write(m, mem);
return (fsize-filesize);