summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2014-01-03 23:55:39 +0100
committerFrank Gevaerts <frank@gevaerts.be>2014-01-03 23:57:32 +0100
commitda94b6303ea75f2b7b8e0b08fb9a96c730c894a4 (patch)
treef52dd76bb5f6ee2feaf7c5189e6d389e2ef456cb
parent062801e3ed560418264a0fc7954a2008102a4713 (diff)
downloadrockbox-da94b6303ea75f2b7b8e0b08fb9a96c730c894a4.tar.gz
rockbox-da94b6303ea75f2b7b8e0b08fb9a96c730c894a4.zip
Make fat test tool build again, and make its sector size configurable.
Change-Id: Icfe7c4bb880c2f10918a7809f0f1f1c3838f6f48
-rw-r--r--firmware/test/fat/Makefile5
-rw-r--r--firmware/test/fat/ata-sim.c10
-rw-r--r--firmware/test/fat/main.c6
3 files changed, 10 insertions, 11 deletions
diff --git a/firmware/test/fat/Makefile b/firmware/test/fat/Makefile
index 77c299dfca..38bce0bde1 100644
--- a/firmware/test/fat/Makefile
+++ b/firmware/test/fat/Makefile
@@ -1,3 +1,4 @@
1SECTOR_SIZE = 512
1FIRMWARE = ../.. 2FIRMWARE = ../..
2 3
3DRIVERS = ../../drivers 4DRIVERS = ../../drivers
@@ -7,8 +8,8 @@ BUILDDATE=$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d')
7INCLUDE = -I$(EXPORT) -I$(FIRMWARE)/include -I$(FIRMWARE)/target/hosted -I$(FIRMWARE)/target/hosted/sdl 8INCLUDE = -I$(EXPORT) -I$(FIRMWARE)/include -I$(FIRMWARE)/target/hosted -I$(FIRMWARE)/target/hosted/sdl
8DEFINES = -DTEST_FAT -DDEBUG -DDISK_WRITE -DHAVE_FAT16SUPPORT -D__PCTOOL__ 9DEFINES = -DTEST_FAT -DDEBUG -DDISK_WRITE -DHAVE_FAT16SUPPORT -D__PCTOOL__
9 10
10CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include 11CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include -DROCKBOX_DIR='".rockbox"' -DSECTOR_SIZE=$(SECTOR_SIZE)
11SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) 12SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) -DSECTOR_SIZE=$(SECTOR_SIZE)
12 13
13TARGET = fat 14TARGET = fat
14 15
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index 98fd5adc28..07b772f433 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -3,8 +3,6 @@
3#include <string.h> 3#include <string.h>
4#include "debug.h" 4#include "debug.h"
5 5
6#define BLOCK_SIZE 512
7
8static FILE* file; 6static FILE* file;
9 7
10void panicf( const char *fmt, ... ); 8void panicf( const char *fmt, ... );
@@ -17,11 +15,11 @@ int storage_read_sectors(unsigned long start, int count, void* buf)
17 else 15 else
18 DEBUGF("[Reading block 0x%lx]\n", start); 16 DEBUGF("[Reading block 0x%lx]\n", start);
19 17
20 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 18 if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
21 perror("fseek"); 19 perror("fseek");
22 return -1; 20 return -1;
23 } 21 }
24 if(!fread(buf,BLOCK_SIZE,count,file)) { 22 if(!fread(buf,SECTOR_SIZE,count,file)) {
25 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf ); 23 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
26 perror("fread"); 24 perror("fread");
27 panicf("Disk error\n"); 25 panicf("Disk error\n");
@@ -40,11 +38,11 @@ int storage_write_sectors(unsigned long start, int count, void* buf)
40 if (start == 0) 38 if (start == 0)
41 panicf("Writing on sector 0!\n"); 39 panicf("Writing on sector 0!\n");
42 40
43 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 41 if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
44 perror("fseek"); 42 perror("fseek");
45 return -1; 43 return -1;
46 } 44 }
47 if(!fwrite(buf,BLOCK_SIZE,count,file)) { 45 if(!fwrite(buf,SECTOR_SIZE,count,file)) {
48 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf ); 46 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
49 perror("fwrite"); 47 perror("fwrite");
50 panicf("Disk error\n"); 48 panicf("Disk error\n");
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c
index 96a95a8b2a..e838682b0b 100644
--- a/firmware/test/fat/main.c
+++ b/firmware/test/fat/main.c
@@ -49,11 +49,11 @@ void ldebugf(const char* file, int line, const char *fmt, ...)
49 49
50void dbg_dump_sector(int sec) 50void dbg_dump_sector(int sec)
51{ 51{
52 unsigned char buf[512]; 52 unsigned char buf[SECTOR_SIZE];
53 53
54 storage_read_sectors(sec,1,buf); 54 storage_read_sectors(sec,1,buf);
55 DEBUGF("---< Sector %d >-----------------------------------------\n", sec); 55 DEBUGF("---< Sector %d >-----------------------------------------\n", sec);
56 dbg_dump_buffer(buf, 512, 0); 56 dbg_dump_buffer(buf, SECTOR_SIZE, 0);
57} 57}
58 58
59void dbg_dump_buffer(unsigned char *buf, int len, int offset) 59void dbg_dump_buffer(unsigned char *buf, int len, int offset)
@@ -427,7 +427,7 @@ void dbg_tail(char* name)
427 return; 427 return;
428 DEBUGF("Got file descriptor %d\n",fd); 428 DEBUGF("Got file descriptor %d\n",fd);
429 429
430 rc = lseek(fd,-512,SEEK_END); 430 rc = lseek(fd,-SECTOR_SIZE,SEEK_END);
431 if ( rc >= 0 ) { 431 if ( rc >= 0 ) {
432 rc = read(fd, buf, SECTOR_SIZE); 432 rc = read(fd, buf, SECTOR_SIZE);
433 if( rc > 0 ) 433 if( rc > 0 )