diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2002-10-15 14:36:52 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2002-10-15 14:36:52 +0000 |
| commit | eebd237d465352508192a2c8419c224f8c7bc7a9 (patch) | |
| tree | 6795d0fc550be76eba416f5bf00dcfdc7e83f5c6 | |
| parent | 016bea8e451664934edb14b79ee586a650724d8d (diff) | |
| download | rockbox-eebd237d465352508192a2c8419c224f8c7bc7a9.zip rockbox-eebd237d465352508192a2c8419c224f8c7bc7a9.tar.gz rockbox-eebd237d465352508192a2c8419c224f8c7bc7a9.tar.bz2 rockbox-eebd237d465352508192a2c8419c224f8c7bc7a9.tar.xz | |
Fat32 test code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2669 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/test/fat/Makefile | 16 | ||||
| -rw-r--r-- | firmware/test/fat/ata-sim.c | 7 | ||||
| -rw-r--r-- | firmware/test/fat/main.c | 19 |
3 files changed, 36 insertions, 6 deletions
diff --git a/firmware/test/fat/Makefile b/firmware/test/fat/Makefile index b47a724..fa9ac33 100644 --- a/firmware/test/fat/Makefile +++ b/firmware/test/fat/Makefile @@ -1,14 +1,22 @@ FIRMWARE = ../.. DRIVERS = ../../drivers -CFLAGS = -g -Wall -DTEST_FAT -I. -I$(DRIVERS) -I$(FIRMWARE)/common -I$(FIRMWARE) -DDEBUG -DCRT_DISPLAY +INCLUDE = -I$(DRIVERS) -I$(FIRMWARE) -I$(FIRMWARE)/common +RINCLUDE = -I$(FIRMWARE)/include +DEFINES = -DTEST_FAT -DDEBUG -DCRT_DISPLAY -DDISK_WRITE + +CFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) $(RINCLUDE) -DLITTLE_ENDIAN +SIMFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) TARGET = fat -$(TARGET): fat.o ata-sim.o main.o disk.o debug.o dir.o file.o +$(TARGET): fat.o ata-sim.o main.o disk.o debug.o dir.o file.o ctype.o gcc -g -o fat $+ -lfl fat.o: $(DRIVERS)/fat.c $(DRIVERS)/fat.h $(DRIVERS)/ata.h + $(CC) $(CFLAGS) -DSIMULATOR -c $< -o $@ + +ctype.o: $(FIRMWARE)/common/ctype.c $(CC) $(CFLAGS) -c $< -o $@ disk.o: $(FIRMWARE)/common/disk.c @@ -21,11 +29,13 @@ file.o: $(FIRMWARE)/common/file.c $(CC) $(CFLAGS) -c $< -o $@ debug.o: $(FIRMWARE)/debug.c - $(CC) $(CFLAGS) -DSIMULATOR -c $< -o $@ + $(CC) $(SIMFLAGS) -DSIMULATOR -c $< -o $@ ata-sim.o: ata-sim.c $(DRIVERS)/ata.h + $(CC) $(SIMFLAGS) -DSIMULATOR -c $< -o $@ main.o: main.c $(DRIVERS)/ata.h + $(CC) $(SIMFLAGS) -c $< -o $@ clean: rm -f *.o $(TARGET) diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c index 97abb33..ab7266d 100644 --- a/firmware/test/fat/ata-sim.c +++ b/firmware/test/fat/ata-sim.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "debug.h" #define BLOCK_SIZE 512 @@ -8,7 +9,7 @@ static FILE* file; int ata_read_sectors(unsigned long start, unsigned char count, void* buf) { - printf("Reading block 0x%lx\n",start); + DEBUGF("Reading block 0x%lx\n",start); if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { perror("fseek"); return -1; @@ -36,10 +37,12 @@ int ata_write_sectors(unsigned long start, unsigned char count, void* buf) int ata_init(char* filename) { + if (!filename) + filename = "disk.img"; /* check disk size */ file=fopen(filename,"r+"); if(!file) { - fprintf(stderr, "read_disk() - Could not find \"disk.img\"\n"); + fprintf(stderr, "read_disk() - Could not find \"%s\"\n",filename); return -1; } return 0; diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index fcd2dcc..4a11e0a 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c @@ -61,7 +61,8 @@ void dbg_dir(char* currdir) if (dir) { while ( (entry = readdir(dir)) ) { - DEBUGF("%15s (%d bytes)\n", entry->d_name, entry->size); + DEBUGF("%15s (%d bytes) %x\n", + entry->d_name, entry->size, entry->startcluster); } closedir(dir); } @@ -71,6 +72,20 @@ void dbg_dir(char* currdir) } } +void dbg_mkfile(char* name) +{ + char* text = "Detta är en dummy-text\n"; + int fd = open(name,O_WRONLY); + if (fd<0) { + DEBUGF("Failed creating file\n"); + return; + } + if (write(fd, text, strlen(text)) < 0) + DEBUGF("Failed writing data\n"); + + close(fd); +} + void dbg_type(char* name) { unsigned char buf[SECTOR_SIZE*5]; @@ -270,6 +285,8 @@ int main(int argc, char *argv[]) //dbg_console(); //dbg_tail("/fat.h"); + //dbg_dir("/"); + dbg_mkfile("/apa.txt"); dbg_dir("/"); return 0; |