summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/test/fat/Makefile43
-rw-r--r--firmware/test/fat/README7
-rw-r--r--firmware/test/fat/ata-sim.c8
-rw-r--r--firmware/test/fat/main.c16
-rw-r--r--firmware/test/fat/test.sh5
5 files changed, 38 insertions, 41 deletions
diff --git a/firmware/test/fat/Makefile b/firmware/test/fat/Makefile
index cb7d1a70ee..74d2628ab7 100644
--- a/firmware/test/fat/Makefile
+++ b/firmware/test/fat/Makefile
@@ -8,57 +8,46 @@ export TARGET_INC=-I$(FIRMWARE)/target/arm/ipod/video -I$(FIRMWARE)/target/arm/i
8DRIVERS = ../../drivers 8DRIVERS = ../../drivers
9EXPORT = ../../export 9EXPORT = ../../export
10 10
11INCLUDE = -I$(EXPORT) 11INCLUDE = -I$(EXPORT) -I$(FIRMWARE)/include
12 12
13RINCLUDE = -I$(FIRMWARE)/include 13DEFINES = -DTEST_FAT -DDEBUG -DCRT_DISPLAY -DDISK_WRITE -DHAVE_FAT16SUPPORT -D__PCTOOL__
14DEFINES = -DTEST_FAT -DDEBUG -DCRT_DISPLAY -DDISK_WRITE -DHAVE_FAT16SUPPORT
15 14
16CFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) $(RINCLUDE) $(BUILDDATE) 15CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) $(BUILDDATE) -I$(FIRMWARE)/libc/include
17SIMFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) 16SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE)
18 17
19TARGET = fat 18TARGET = fat
20 19
20all: $(TARGET)
21 21
22$(TARGET): fat.o ata-sim.o main.o disk.o debug.o dir.o file.o ctype.o 22$(TARGET): fat.o ata-sim.o main.o disk.o dir.o file.o ctype.o unicode.o strlcpy.o
23 gcc -g -o fat $+ -lfl 23 gcc -g -o fat $+ -lfl
24 24
25fat.o: $(DRIVERS)/fat.c $(EXPORT)/fat.h $(EXPORT)/ata.h 25fat.o: $(DRIVERS)/fat.c $(EXPORT)/fat.h $(EXPORT)/ata.h
26 $(CC) $(CFLAGS) -DSIMULATOR -c $< -o $@ 26 $(CC) $(CFLAGS) -c $< -o $@
27 27
28ctype.o: $(FIRMWARE)/common/ctype.c 28ctype.o: $(FIRMWARE)/libc/ctype.c
29 $(CC) $(CFLAGS) -c $< -o $@ 29 $(CC) $(CFLAGS) -c $< -o $@
30 30
31disk.o: $(FIRMWARE)/common/disk.c 31disk.o: $(FIRMWARE)/common/disk.c
32 $(CC) $(CFLAGS) -c $< -o $@ 32 $(CC) $(CFLAGS) -c $< -o $@
33 33
34dir.o: $(FIRMWARE)/common/dir.c 34dir.o: $(FIRMWARE)/common/dir_uncached.c
35 $(CC) $(CFLAGS) -c $< -o $@ 35 $(CC) $(CFLAGS) -c $< -o $@
36 36
37file.o: $(FIRMWARE)/common/file.c 37file.o: $(FIRMWARE)/common/file.c
38 $(CC) $(CFLAGS) -c $< -o $@ 38 $(CC) $(CFLAGS) -c $< -o $@
39 39
40debug.o: $(FIRMWARE)/debug.c 40unicode.o: $(FIRMWARE)/common/unicode.c
41 $(CC) $(SIMFLAGS) -DSIMULATOR -c $< -o $@ 41 $(CC) $(CFLAGS) -c $< -o $@
42
43ata-sim.o: ata-sim.c $(EXPORT)/ata.h
44 $(CC) $(SIMFLAGS) -DSIMULATOR -c $< -o $@
45 42
46dir.h: $(FIRMWARE)/include/dir.h 43strlcpy.o: $(FIRMWARE)/common/strlcpy.c
47 ln -s $(FIRMWARE)/include/dir.h . 44 $(CC) $(CFLAGS) -c $< -o $@
48 45
49file.h: $(FIRMWARE)/include/file.h 46ata-sim.o: ata-sim.c $(EXPORT)/ata.h
50 ln -s $(FIRMWARE)/include/file.h . 47 $(CC) $(SIMFLAGS) -c $< -o $@
51 48
52main.o: main.c $(EXPORT)/ata.h dir.h file.h 49main.o: main.c $(EXPORT)/ata.h
53 $(CC) $(SIMFLAGS) -c $< -o $@ 50 $(CC) $(SIMFLAGS) -c $< -o $@
54 51
55clean: 52clean:
56 rm -f *.o $(TARGET) 53 rm -f *.o $(TARGET)
57 rm -f *~
58 rm -f cmd.tab.h lex.yy.c cmd.tab.c
59 rm -f core
60 rm -f dir.h file.h
61
62tar:
63 rm -f $(TARGET).tar
64 tar cvf $(TARGET).tar -C .. fat
diff --git a/firmware/test/fat/README b/firmware/test/fat/README
index 76141c0044..58ffe7ffa8 100644
--- a/firmware/test/fat/README
+++ b/firmware/test/fat/README
@@ -16,6 +16,13 @@ To mount the image, your linux kernel must include the loopback device:
16 16
17Now copy some test data to the disk, umount it and start testing. 17Now copy some test data to the disk, umount it and start testing.
18 18
19The test script mounts the disk image in order to initialize it will a number
20of dummy files. Since users are no longer allowed to mount loopback devices,
21you can either run the test script as root (not recommended) or add a line to
22your fstab file:
23
24/path/to/disk.img /mnt/dummy vfat loop,users,noauto 0 0
25
19 26
20Test code 27Test code
21--------- 28---------
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index d8ed079759..98fd5adc28 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -9,7 +9,7 @@ static FILE* file;
9 9
10void panicf( const char *fmt, ... ); 10void panicf( const char *fmt, ... );
11 11
12int ata_read_sectors(unsigned long start, int count, void* buf) 12int storage_read_sectors(unsigned long start, int count, void* buf)
13{ 13{
14 if ( count > 1 ) 14 if ( count > 1 )
15 DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n", 15 DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n",
@@ -22,14 +22,14 @@ int ata_read_sectors(unsigned long start, int count, void* buf)
22 return -1; 22 return -1;
23 } 23 }
24 if(!fread(buf,BLOCK_SIZE,count,file)) { 24 if(!fread(buf,BLOCK_SIZE,count,file)) {
25 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf ); 25 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
26 perror("fread"); 26 perror("fread");
27 panicf("Disk error\n"); 27 panicf("Disk error\n");
28 } 28 }
29 return 0; 29 return 0;
30} 30}
31 31
32int ata_write_sectors(unsigned long start, int count, void* buf) 32int storage_write_sectors(unsigned long start, int count, void* buf)
33{ 33{
34 if ( count > 1 ) 34 if ( count > 1 )
35 DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n", 35 DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n",
@@ -45,7 +45,7 @@ int ata_write_sectors(unsigned long start, int count, void* buf)
45 return -1; 45 return -1;
46 } 46 }
47 if(!fwrite(buf,BLOCK_SIZE,count,file)) { 47 if(!fwrite(buf,BLOCK_SIZE,count,file)) {
48 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf ); 48 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
49 perror("fwrite"); 49 perror("fwrite");
50 panicf("Disk error\n"); 50 panicf("Disk error\n");
51 } 51 }
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c
index 1cb53deb6e..a9220d15b7 100644
--- a/firmware/test/fat/main.c
+++ b/firmware/test/fat/main.c
@@ -8,14 +8,15 @@
8#include "disk.h" 8#include "disk.h"
9#include "dir.h" 9#include "dir.h"
10#include "file.h" 10#include "file.h"
11#include "ata.h"
11 12
12void dbg_dump_sector(int sec); 13void dbg_dump_sector(int sec);
13void dbg_dump_buffer(unsigned char *buf, int len, int offset); 14void dbg_dump_buffer(unsigned char *buf, int len, int offset);
14void dbg_console(void); 15void dbg_console(void);
15 16
16void mutex_init(void* l) {} 17void mutex_init(struct mutex* l) {}
17void mutex_lock(void* l) {} 18void mutex_lock(struct mutex* l) {}
18void mutex_unlock(void* l) {} 19void mutex_unlock(struct mutex* l) {}
19 20
20void panicf( char *fmt, ...) 21void panicf( char *fmt, ...)
21{ 22{
@@ -49,7 +50,7 @@ void dbg_dump_sector(int sec)
49{ 50{
50 unsigned char buf[512]; 51 unsigned char buf[512];
51 52
52 ata_read_sectors(sec,1,buf); 53 storage_read_sectors(sec,1,buf);
53 DEBUGF("---< Sector %d >-----------------------------------------\n", sec); 54 DEBUGF("---< Sector %d >-----------------------------------------\n", sec);
54 dbg_dump_buffer(buf, 512, 0); 55 dbg_dump_buffer(buf, 512, 0);
55} 56}
@@ -92,8 +93,7 @@ void dbg_dir(char* currdir)
92 if (dir) 93 if (dir)
93 { 94 {
94 while ( (entry = readdir(dir)) ) { 95 while ( (entry = readdir(dir)) ) {
95 DEBUGF("%15s (%d bytes) %x\n", 96 DEBUGF("%15s %lx\n", entry->d_name, entry->startcluster);
96 entry->d_name, entry->size, entry->startcluster);
97 } 97 }
98 closedir(dir); 98 closedir(dir);
99 } 99 }
@@ -508,7 +508,7 @@ int dbg_mkdir(char* name)
508{ 508{
509 int fd; 509 int fd;
510 510
511 fd = mkdir(name, 0); 511 fd = mkdir(name);
512 if (fd<0) { 512 if (fd<0) {
513 DEBUGF("Failed creating directory\n"); 513 DEBUGF("Failed creating directory\n");
514 return -1; 514 return -1;
@@ -565,7 +565,7 @@ int dbg_cmd(int argc, char *argv[])
565 if (!strcasecmp(cmd, "ds")) 565 if (!strcasecmp(cmd, "ds"))
566 { 566 {
567 if ( arg1 ) { 567 if ( arg1 ) {
568 DEBUGF("secnum: %d\n", strtol(arg1, NULL, 0)); 568 DEBUGF("secnum: %ld\n", strtol(arg1, NULL, 0));
569 dbg_dump_sector(strtol(arg1, NULL, 0)); 569 dbg_dump_sector(strtol(arg1, NULL, 0));
570 } 570 }
571 } 571 }
diff --git a/firmware/test/fat/test.sh b/firmware/test/fat/test.sh
index 921a0c80bf..ca0a1db067 100644
--- a/firmware/test/fat/test.sh
+++ b/firmware/test/fat/test.sh
@@ -25,9 +25,10 @@ try() {
25 25
26buildimage() { 26buildimage() {
27 /sbin/mkdosfs -F 32 -s $1 $IMAGE > /dev/null 27 /sbin/mkdosfs -F 32 -s $1 $IMAGE > /dev/null
28 mount -o loop $IMAGE $MOUNT 28 #mount -o loop $IMAGE $MOUNT
29 mount $MOUNT
29 echo "Filling it with /etc files" 30 echo "Filling it with /etc files"
30 find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \; 31 find /etc -maxdepth 1 -type f -readable -exec cp {} $MOUNT \;
31 for i in `seq 1 120`; 32 for i in `seq 1 120`;
32 do 33 do
33 echo apa > "$MOUNT/very $i long test filename so we can make sure they.work" 34 echo apa > "$MOUNT/very $i long test filename so we can make sure they.work"