aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--TODO4
-rw-r--r--libmpio/fat.c35
-rw-r--r--libmpio/io.c13
-rw-r--r--libmpio/mpio.c34
5 files changed, 68 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index ecadd8c..9eab880 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2002-09-11 Markus Germeier <mager@tzi.de>
+ * libmpio/mpio.c (mpio_file_put):
+ finished support for writing to internal memory
+ + changes to fat.c and io.c
+
+2002-09-11 Markus Germeier <mager@tzi.de>
+
* libmpio/io.c (cluster2blockaddress): added function
(mpio_io_block_write, mpio_io_sector_write):
fixed block address in spare area
diff --git a/TODO b/TODO
index 6e10988..71ce70e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.9 2002/09/11 11:55:36 germeier Exp $
+$Id: TODO,v 1.10 2002/09/11 13:44:29 germeier Exp $
* Kernel Module
- the MPIO can no multitasking, so:
@@ -14,7 +14,7 @@ $Id: TODO,v 1.9 2002/09/11 11:55:36 germeier Exp $
- use ECC code for every read/write operation!! [done]
- implement reading of files [DONE]
- implement writing of files [partially done]
- * writing to internal memory
+ * writing to internal memory [DONE]
* resolve remainig block addressing issues in spare area [DONE]
* fix 8.3 filenames
* fix timestamps of files
diff --git a/libmpio/fat.c b/libmpio/fat.c
index 5392bee..aead3a7 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.c,v 1.9 2002/09/11 00:18:34 germeier Exp $
+ * $Id: fat.c,v 1.10 2002/09/11 13:44:30 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -204,7 +204,7 @@ mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector)
{
mpio_smartmedia_t *sm;
mpio_fatentry_t *new;
-
+
new = malloc (sizeof(mpio_fatentry_t));
if (new)
@@ -212,6 +212,16 @@ mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector)
new->m = m;
new->mem = mem;
new->entry = sector;
+
+ /* init FAT entry */
+ memset(new->i_fat, 0xff, 0x10);
+ new->i_fat[0x00] = 0xaa; /* start of file */
+ new->i_fat[0x06] = 0x01; /* filetype, hmm ... */
+ new->i_fat[0x0b] = 0x00;
+ new->i_fat[0x0c] = 0x00;
+ new->i_fat[0x0d] = 0x00;
+ new->i_fat[0x0e] = 'P';
+ new->i_fat[0x0f] = 'C';
}
if (mem == MPIO_INTERNAL_MEM)
@@ -496,8 +506,12 @@ mpio_fatentry_next_free(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f)
while(mpio_fatentry_plus_plus(f))
{
- if (mpio_fatentry_free(m, mem, f))
- return 1;
+ if (mpio_fatentry_free(m, mem, f))
+ {
+ if (mem == MPIO_INTERNAL_MEM)
+ f->i_fat[0x00] = 0xee;
+ return 1;
+ }
}
/* no free entry found, restore entry */
@@ -705,8 +719,8 @@ mpio_fatentry_set_eof(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f)
{
sm = &m->internal;
e = f->entry * 0x10;
- memset((sm->fat+e), 0xff, 0x10);
memset((f->i_fat+0x07), 0xff, 4);
+ memcpy((sm->fat+e), f->i_fat, 0x10);
}
if (mem == MPIO_EXTERNAL_MEM)
@@ -729,10 +743,13 @@ mpio_fatentry_set_next(mpio_t *m, mpio_mem_t mem,
{
sm = &m->internal;
e = f->entry * 0x10;
- sm->fat[e+0x07]= value->hw_address / 0x1000000;
- sm->fat[e+0x08]=(value->hw_address / 0x10000 ) & 0xff;
- sm->fat[e+0x09]=(value->hw_address / 0x100 ) & 0xff;
- sm->fat[e+0x0a]= value->hw_address & 0xff;
+
+ f->i_fat[0x07]= value->hw_address / 0x1000000;
+ f->i_fat[0x08]=(value->hw_address / 0x10000 ) & 0xff;
+ f->i_fat[0x09]=(value->hw_address / 0x100 ) & 0xff;
+ f->i_fat[0x0a]= value->hw_address & 0xff;
+
+ memcpy((sm->fat+e), f->i_fat, 0x10);
}
if (mem == MPIO_EXTERNAL_MEM)
diff --git a/libmpio/io.c b/libmpio/io.c
index 4490a97..f4a5daf 100644
--- a/libmpio/io.c
+++ b/libmpio/io.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: io.c,v 1.10 2002/09/11 11:55:37 germeier Exp $
+ * $Id: io.c,v 1.11 2002/09/11 13:44:30 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -769,8 +769,15 @@ mpio_io_block_write(mpio_t *m, BYTE mem, mpio_fatentry_t *f, BYTE *data)
0xff, CMD_SIZE);
if (mem == MPIO_INTERNAL_MEM)
- memcpy((sendbuff+SECTOR_SIZE+(i * SECTOR_TRANS)),
- f->i_fat, 0x10);
+ {
+ if (i == 0)
+ {
+ memcpy((sendbuff+SECTOR_SIZE+(i * SECTOR_TRANS)),
+ f->i_fat, 0x10);
+/* debug("address %02x:%06x\n", chip, address); */
+/* hexdumpn(0, f->i_fat, 0x10); */
+ }
+ }
/* fill in block information */
if (mem == MPIO_EXTERNAL_MEM)
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index e2a319f..9354e64 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.10 2002/09/11 11:55:38 germeier Exp $
+ * $Id: mpio.c,v 1.11 2002/09/11 13:44:30 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -320,14 +320,15 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
BYTE (*progress_callback)(int, int))
{
mpio_smartmedia_t *sm;
- mpio_fatentry_t *f, current, start;
+ mpio_fatentry_t *f, current;
+ WORD start;
int data_offset;
BYTE block[BLOCK_SIZE];
int fd, toread;
struct stat file_stat;
BYTE *p=NULL;
- DWORD filesize, fsize, free;
+ DWORD filesize, fsize, free, blocks;
BYTE abort=0;
if (mem==MPIO_INTERNAL_MEM) sm=&m->internal;
@@ -364,15 +365,25 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
debug("could not free cluster for file!\n");
return 0;
} else {
- memcpy(&start, f, sizeof(mpio_fatentry_t));
- }
-
+ start=f->entry;
+ }
+
/* find file-id for internal memory */
if (mem==MPIO_INTERNAL_MEM)
{
- f->i_index=mpio_fat_internal_find_fileindex(m);
- debug("fileindex: %02x\n", f->i_index);
- }
+ f->i_index=mpio_fat_internal_find_fileindex(m);
+ debugn(2, "fileindex: %02x\n", f->i_index);
+ f->i_fat[0x01]= f->i_index;
+ start = f->i_index;
+
+ /* number of blocks needed for file */
+ blocks = filesize / 0x4000;
+ if (filesize % 0x4000)
+ blocks++;
+ debugn(2, "blocks: %02x\n", blocks);
+ f->i_fat[0x02]=(blocks / 0x100) & 0xff;
+ f->i_fat[0x03]= blocks & 0xff;
+ }
/* open file for writing */
fd = open(filename, O_RDONLY);
@@ -436,11 +447,14 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (progress_callback)
abort=(*progress_callback)((fsize-filesize), fsize);
+/* if (mem == MPIO_INTERNAL_MEM) */
+/* start.entry=start.i_index; */
+
/* FIXEME: add real values here!!! */
mpio_dentry_put(m, mem,
filename, strlen(filename),
2002, 8, 13,
- 2, 12, fsize, start.entry);
+ 2, 12, fsize, start);
/* this writes the FAT *and* the root directory */
mpio_fat_write(m, mem);