Make fat test tool build again, and make its sector size configurable.

Change-Id: Icfe7c4bb880c2f10918a7809f0f1f1c3838f6f48
This commit is contained in:
Frank Gevaerts 2014-01-03 23:55:39 +01:00
parent 062801e3ed
commit da94b6303e
3 changed files with 10 additions and 11 deletions

View file

@ -1,3 +1,4 @@
SECTOR_SIZE = 512
FIRMWARE = ../..
DRIVERS = ../../drivers
@ -7,8 +8,8 @@ BUILDDATE=$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d')
INCLUDE = -I$(EXPORT) -I$(FIRMWARE)/include -I$(FIRMWARE)/target/hosted -I$(FIRMWARE)/target/hosted/sdl
DEFINES = -DTEST_FAT -DDEBUG -DDISK_WRITE -DHAVE_FAT16SUPPORT -D__PCTOOL__
CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include
SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE)
CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include -DROCKBOX_DIR='".rockbox"' -DSECTOR_SIZE=$(SECTOR_SIZE)
SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) -DSECTOR_SIZE=$(SECTOR_SIZE)
TARGET = fat

View file

@ -3,8 +3,6 @@
#include <string.h>
#include "debug.h"
#define BLOCK_SIZE 512
static FILE* file;
void panicf( const char *fmt, ... );
@ -17,11 +15,11 @@ int storage_read_sectors(unsigned long start, int count, void* buf)
else
DEBUGF("[Reading block 0x%lx]\n", start);
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
perror("fseek");
return -1;
}
if(!fread(buf,BLOCK_SIZE,count,file)) {
if(!fread(buf,SECTOR_SIZE,count,file)) {
DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
perror("fread");
panicf("Disk error\n");
@ -40,11 +38,11 @@ int storage_write_sectors(unsigned long start, int count, void* buf)
if (start == 0)
panicf("Writing on sector 0!\n");
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
perror("fseek");
return -1;
}
if(!fwrite(buf,BLOCK_SIZE,count,file)) {
if(!fwrite(buf,SECTOR_SIZE,count,file)) {
DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
perror("fwrite");
panicf("Disk error\n");

View file

@ -49,11 +49,11 @@ void ldebugf(const char* file, int line, const char *fmt, ...)
void dbg_dump_sector(int sec)
{
unsigned char buf[512];
unsigned char buf[SECTOR_SIZE];
storage_read_sectors(sec,1,buf);
DEBUGF("---< Sector %d >-----------------------------------------\n", sec);
dbg_dump_buffer(buf, 512, 0);
dbg_dump_buffer(buf, SECTOR_SIZE, 0);
}
void dbg_dump_buffer(unsigned char *buf, int len, int offset)
@ -427,7 +427,7 @@ void dbg_tail(char* name)
return;
DEBUGF("Got file descriptor %d\n",fd);
rc = lseek(fd,-512,SEEK_END);
rc = lseek(fd,-SECTOR_SIZE,SEEK_END);
if ( rc >= 0 ) {
rc = read(fd, buf, SECTOR_SIZE);
if( rc > 0 )