mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 13:45:03 -05:00
Make fat test tool build again, and make its sector size configurable.
Change-Id: Icfe7c4bb880c2f10918a7809f0f1f1c3838f6f48
This commit is contained in:
parent
062801e3ed
commit
da94b6303e
3 changed files with 10 additions and 11 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
SECTOR_SIZE = 512
|
||||||
FIRMWARE = ../..
|
FIRMWARE = ../..
|
||||||
|
|
||||||
DRIVERS = ../../drivers
|
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
|
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__
|
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
|
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)
|
SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) -DSECTOR_SIZE=$(SECTOR_SIZE)
|
||||||
|
|
||||||
TARGET = fat
|
TARGET = fat
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define BLOCK_SIZE 512
|
|
||||||
|
|
||||||
static FILE* file;
|
static FILE* file;
|
||||||
|
|
||||||
void panicf( const char *fmt, ... );
|
void panicf( const char *fmt, ... );
|
||||||
|
|
@ -17,11 +15,11 @@ int storage_read_sectors(unsigned long start, int count, void* buf)
|
||||||
else
|
else
|
||||||
DEBUGF("[Reading block 0x%lx]\n", start);
|
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");
|
perror("fseek");
|
||||||
return -1;
|
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 );
|
DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
|
||||||
perror("fread");
|
perror("fread");
|
||||||
panicf("Disk error\n");
|
panicf("Disk error\n");
|
||||||
|
|
@ -40,11 +38,11 @@ int storage_write_sectors(unsigned long start, int count, void* buf)
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
panicf("Writing on sector 0!\n");
|
panicf("Writing on sector 0!\n");
|
||||||
|
|
||||||
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
|
if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
|
||||||
perror("fseek");
|
perror("fseek");
|
||||||
return -1;
|
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 );
|
DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
|
||||||
perror("fwrite");
|
perror("fwrite");
|
||||||
panicf("Disk error\n");
|
panicf("Disk error\n");
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@ void ldebugf(const char* file, int line, const char *fmt, ...)
|
||||||
|
|
||||||
void dbg_dump_sector(int sec)
|
void dbg_dump_sector(int sec)
|
||||||
{
|
{
|
||||||
unsigned char buf[512];
|
unsigned char buf[SECTOR_SIZE];
|
||||||
|
|
||||||
storage_read_sectors(sec,1,buf);
|
storage_read_sectors(sec,1,buf);
|
||||||
DEBUGF("---< Sector %d >-----------------------------------------\n", sec);
|
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)
|
void dbg_dump_buffer(unsigned char *buf, int len, int offset)
|
||||||
|
|
@ -427,7 +427,7 @@ void dbg_tail(char* name)
|
||||||
return;
|
return;
|
||||||
DEBUGF("Got file descriptor %d\n",fd);
|
DEBUGF("Got file descriptor %d\n",fd);
|
||||||
|
|
||||||
rc = lseek(fd,-512,SEEK_END);
|
rc = lseek(fd,-SECTOR_SIZE,SEEK_END);
|
||||||
if ( rc >= 0 ) {
|
if ( rc >= 0 ) {
|
||||||
rc = read(fd, buf, SECTOR_SIZE);
|
rc = read(fd, buf, SECTOR_SIZE);
|
||||||
if( rc > 0 )
|
if( rc > 0 )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue