o cleanup debug
This commit is contained in:
parent
dfcf4016b1
commit
3ecc61adf4
@ -16,3 +16,6 @@
|
|||||||
|
|
||||||
#define SHARED_SIZE 512
|
#define SHARED_SIZE 512
|
||||||
#define SHARED_ADDR 0x3f0000
|
#define SHARED_ADDR 0x3f0000
|
||||||
|
|
||||||
|
|
||||||
|
#undef MMIO_DEBUG
|
||||||
|
|||||||
@ -31,23 +31,26 @@ void debug_enable(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void _print_char(word y,word x, unsigned char c){
|
||||||
|
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
||||||
|
}
|
||||||
|
|
||||||
void _print_screen(word y, char *buffer){
|
void _print_screen(word y, char *buffer){
|
||||||
char i;
|
|
||||||
char l;
|
char l;
|
||||||
|
char x = 0;
|
||||||
l = strlen(buffer);
|
l = strlen(buffer);
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
|
while(*buffer){
|
||||||
for(i=0; i<32; i++) {
|
if (*buffer == '\n' ) {
|
||||||
if (buffer[i] == '\n' ) {
|
while(x++<32)
|
||||||
|
_print_char(y,x,' ');
|
||||||
|
x = 0;
|
||||||
y++;
|
y++;
|
||||||
continue;
|
}
|
||||||
}
|
_print_char(y,x,*buffer);
|
||||||
if (i<l)
|
x++;
|
||||||
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
buffer++;
|
||||||
else
|
}
|
||||||
VRAMByteWrite((byte) (' '-32), (word) (0x4000+i+(y*0x20)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _print_console(const char *buffer){
|
void _print_console(const char *buffer){
|
||||||
@ -55,8 +58,6 @@ void _print_console(const char *buffer){
|
|||||||
*(byte*) 0x3000=*buffer++;
|
*(byte*) 0x3000=*buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* keep the linker happy */
|
/* keep the linker happy */
|
||||||
int open(const char * _name, int _mode){
|
int open(const char * _name, int _mode){
|
||||||
_print_console("open called\n");
|
_print_console("open called\n");
|
||||||
|
|||||||
@ -39,16 +39,24 @@ DSTATUS Stat = 0 ; //STA_NOINIT; /* Disk status */
|
|||||||
DSTATUS disk_initialize (BYTE drv) {
|
DSTATUS disk_initialize (BYTE drv) {
|
||||||
|
|
||||||
byte retval;
|
byte retval;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize called drv=%i stat=%i\n",drv,Stat);
|
printfc("SNES::disk_initialize called drv=%i stat=%i\n",drv,Stat);
|
||||||
|
#endif
|
||||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
Stat |= STA_NOINIT;
|
Stat |= STA_NOINIT;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize stat=%i\n",Stat);
|
printfc("SNES::disk_initialize stat=%i\n",Stat);
|
||||||
|
#endif
|
||||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
*(byte*) MMIO_CMD = CMD_INIT;
|
*(byte*) MMIO_CMD = CMD_INIT;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize poll retval\n");
|
printfc("SNES::disk_initialize poll retval\n");
|
||||||
|
#endif
|
||||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize done Stat=%i\n",Stat);
|
printfc("SNES::disk_initialize done Stat=%i\n",Stat);
|
||||||
|
#endif
|
||||||
return Stat;
|
return Stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +87,17 @@ DRESULT disk_read (
|
|||||||
byte retval;
|
byte retval;
|
||||||
word i;
|
word i;
|
||||||
|
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
|
printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
|
||||||
|
#endif
|
||||||
if (drv || !count) return RES_PARERR;
|
if (drv || !count) return RES_PARERR;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read drv ok\n");
|
printfc("SNES::disk_read drv ok\n");
|
||||||
|
#endif
|
||||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read sta ok\n");
|
printfc("SNES::disk_read sta ok\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
*(byte*) MMIO_CMD = CMD_READ;
|
*(byte*) MMIO_CMD = CMD_READ;
|
||||||
@ -95,18 +109,25 @@ DRESULT disk_read (
|
|||||||
|
|
||||||
*(byte*) MMIO_COUNT = count;
|
*(byte*) MMIO_COUNT = count;
|
||||||
|
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read poll retval\n");
|
printfc("SNES::disk_read poll retval\n");
|
||||||
|
#endif
|
||||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read copy buffer to %06lx\n",SHARED_ADDR);
|
printfc("SNES::disk_read copy buffer to %06lx\n",SHARED_ADDR);
|
||||||
|
#endif
|
||||||
for (i=0;i<(count*512);i++){
|
for (i=0;i<(count*512);i++){
|
||||||
buff[i] = *(byte*)(SHARED_ADDR+i);
|
buff[i] = *(byte*)(SHARED_ADDR+i);
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
if ( i < 8)
|
if ( i < 8)
|
||||||
printfc("0x%02x ",buff[i]);
|
printfc("0x%02x ",buff[i]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printfc("\n");
|
printfc("\n");
|
||||||
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1368,14 +1368,12 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
} else {
|
} else {
|
||||||
vol = 0; /* No drive number is given, use drive number 0 as default */
|
vol = 0; /* No drive number is given, use drive number 0 as default */
|
||||||
}
|
}
|
||||||
printfc("auto_mount drv %i\n",vol);
|
|
||||||
/* Check if the logical drive number is valid or not */
|
/* Check if the logical drive number is valid or not */
|
||||||
if (vol >= _DRIVES) return FR_INVALID_DRIVE; /* Is the drive number valid? */
|
if (vol >= _DRIVES) return FR_INVALID_DRIVE; /* Is the drive number valid? */
|
||||||
*rfs = fs = FatFs[vol]; /* Returen pointer to the corresponding file system object */
|
*rfs = fs = FatFs[vol]; /* Returen pointer to the corresponding file system object */
|
||||||
if (!fs) return FR_NOT_ENABLED; /* Is the file system object registered? */
|
if (!fs) return FR_NOT_ENABLED; /* Is the file system object registered? */
|
||||||
|
|
||||||
ENTER_FF(fs); /* Lock file system */
|
ENTER_FF(fs); /* Lock file system */
|
||||||
printfc("auto_mount ok enter_ff\n");
|
|
||||||
|
|
||||||
if (fs->fs_type) { /* If the logical drive has been mounted */
|
if (fs->fs_type) { /* If the logical drive has been mounted */
|
||||||
stat = disk_status(fs->drive);
|
stat = disk_status(fs->drive);
|
||||||
@ -1388,13 +1386,11 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printfc("auto_mount mount now\n");
|
|
||||||
/* The logical drive must be re-mounted. Following code attempts to mount the volume */
|
/* The logical drive must be re-mounted. Following code attempts to mount the volume */
|
||||||
|
|
||||||
fs->fs_type = 0; /* Clear the file system object */
|
fs->fs_type = 0; /* Clear the file system object */
|
||||||
fs->drive = LD2PD(vol); /* Bind the logical drive and a physical drive */
|
fs->drive = LD2PD(vol); /* Bind the logical drive and a physical drive */
|
||||||
stat = disk_initialize(fs->drive); /* Initialize low level disk I/O layer */
|
stat = disk_initialize(fs->drive); /* Initialize low level disk I/O layer */
|
||||||
printfc("auto_mount disk_initialize return %i\n",stat);
|
|
||||||
if (stat & STA_NOINIT) /* Check if the drive is ready */
|
if (stat & STA_NOINIT) /* Check if the drive is ready */
|
||||||
return FR_NOT_READY;
|
return FR_NOT_READY;
|
||||||
#if _MAX_SS != 512 /* Get disk sector size if needed */
|
#if _MAX_SS != 512 /* Get disk sector size if needed */
|
||||||
@ -1405,7 +1401,6 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
|
if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
|
||||||
return FR_WRITE_PROTECTED;
|
return FR_WRITE_PROTECTED;
|
||||||
#endif
|
#endif
|
||||||
printfc("auto_mount search fat now\n");
|
|
||||||
/* Search FAT partition on the drive */
|
/* Search FAT partition on the drive */
|
||||||
fmt = check_fs(fs, bsect = 0); /* Check sector 0 as an SFD format */
|
fmt = check_fs(fs, bsect = 0); /* Check sector 0 as an SFD format */
|
||||||
if (fmt == 1) { /* Not an FAT boot record, it may be patitioned */
|
if (fmt == 1) { /* Not an FAT boot record, it may be patitioned */
|
||||||
|
|||||||
@ -119,8 +119,10 @@ void main(void) {
|
|||||||
|
|
||||||
debug_enable();
|
debug_enable();
|
||||||
printfs(0,"FATFS ");
|
printfs(0,"FATFS ");
|
||||||
|
printfs(2,"FATFS ");
|
||||||
//halt();
|
printfs(3,"FATFS ");
|
||||||
|
printfs(4,"FATFS ");
|
||||||
|
halt();
|
||||||
printfc("SNES::main: Try to init disk\n");
|
printfc("SNES::main: Try to init disk\n");
|
||||||
put_rc(f_mount(0, &fatfs[0]));
|
put_rc(f_mount(0, &fatfs[0]));
|
||||||
|
|
||||||
@ -129,7 +131,6 @@ void main(void) {
|
|||||||
res = f_getfree("", &p2, &fs);
|
res = f_getfree("", &p2, &fs);
|
||||||
if (res)
|
if (res)
|
||||||
put_rc(res);
|
put_rc(res);
|
||||||
//halt();
|
|
||||||
|
|
||||||
printfc("SNES::main: printf fs results\n");
|
printfc("SNES::main: printf fs results\n");
|
||||||
printfc("FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
printfc("FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
||||||
@ -150,7 +151,35 @@ void main(void) {
|
|||||||
acc_files, acc_size, acc_dirs,
|
acc_files, acc_size, acc_dirs,
|
||||||
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
|
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
|
||||||
|
|
||||||
while(1){
|
res = f_opendir(&dir, "");
|
||||||
|
if (res)
|
||||||
|
put_rc(res);
|
||||||
|
|
||||||
|
p1 = s1 = s2 = 0;
|
||||||
|
printfc("SNES::main: read dir\n");
|
||||||
|
for(;;) {
|
||||||
|
res = f_readdir(&dir, &finfo);
|
||||||
|
if ((res != FR_OK) || !finfo.fname[0]) break;
|
||||||
|
if (finfo.fattrib & AM_DIR) {
|
||||||
|
s2++;
|
||||||
|
} else {
|
||||||
|
s1++; p1 += finfo.fsize;
|
||||||
|
}
|
||||||
|
printfc("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s\n",
|
||||||
|
(finfo.fattrib & AM_DIR) ? 'D' : '-',
|
||||||
|
(finfo.fattrib & AM_RDO) ? 'R' : '-',
|
||||||
|
(finfo.fattrib & AM_HID) ? 'H' : '-',
|
||||||
|
(finfo.fattrib & AM_SYS) ? 'S' : '-',
|
||||||
|
(finfo.fattrib & AM_ARC) ? 'A' : '-',
|
||||||
|
(finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
|
||||||
|
(finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
|
||||||
|
finfo.fsize, &(finfo.fname[0]));
|
||||||
|
}
|
||||||
|
printfc("%4u FILES, %10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||||
|
if (f_getfree("", &p1, &fs) == FR_OK)
|
||||||
|
printfc(", %10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||||
|
|
||||||
|
while(1){
|
||||||
while(!pad1.start) {
|
while(!pad1.start) {
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
pad1 = readPad((byte) 0);
|
pad1 = readPad((byte) 0);
|
||||||
|
|||||||
@ -16,3 +16,6 @@
|
|||||||
|
|
||||||
#define SHARED_SIZE 512
|
#define SHARED_SIZE 512
|
||||||
#define SHARED_ADDR 0x3f0000
|
#define SHARED_ADDR 0x3f0000
|
||||||
|
|
||||||
|
#undef MMIO_DEBUG
|
||||||
|
#undef FATFS_DEBUG
|
||||||
|
|||||||
@ -55,11 +55,13 @@ DSTATUS disk_initialize (BYTE drv) {
|
|||||||
lseek(fd,0,SEEK_SET);
|
lseek(fd,0,SEEK_SET);
|
||||||
|
|
||||||
image_addr = (BYTE*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
image_addr = (BYTE*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("DISKIO::disk_initialize: Open Image (size %i) %p\n",size,image_addr);
|
printf("DISKIO::disk_initialize: Open Image (size %i) %p\n",size,image_addr);
|
||||||
|
#endif
|
||||||
if (image_addr == MAP_FAILED) {
|
if (image_addr == MAP_FAILED) {
|
||||||
close(fd);
|
close(fd);
|
||||||
perror("DISKIO::disk_initialize: Error mmapping the file");
|
perror("DISKIO::disk_initialize: Error mmapping the file");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||||
@ -94,9 +96,13 @@ DRESULT disk_read (
|
|||||||
|
|
||||||
DWORD offset = sector * 512;
|
DWORD offset = sector * 512;
|
||||||
int size = count * 512;
|
int size = count * 512;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("DISKIO::disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
printf("DISKIO::disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
||||||
|
#endif
|
||||||
memcpy(buff,image_addr + offset,size);
|
memcpy(buff,image_addr + offset,size);
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("DISKIO::disk_read: done\n");
|
printf("DISKIO::disk_read: done\n");
|
||||||
|
#endif
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +124,9 @@ DRESULT disk_write (
|
|||||||
|
|
||||||
DWORD offset = sector * 512;
|
DWORD offset = sector * 512;
|
||||||
int size = count * 512;
|
int size = count * 512;
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("disk_write: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
printf("disk_write: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
||||||
|
#endif
|
||||||
memcpy(image_addr + offset,buff,size);
|
memcpy(image_addr + offset,buff,size);
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
@ -143,17 +151,23 @@ DRESULT disk_ioctl (
|
|||||||
|
|
||||||
switch (ctrl) {
|
switch (ctrl) {
|
||||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("disk_ioctl: GET_SECTOR_COUNT\n");
|
printf("disk_ioctl: GET_SECTOR_COUNT\n");
|
||||||
|
#endif
|
||||||
ofs = 60; w = 2; n = 0;
|
ofs = 60; w = 2; n = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("disk_ioctl: GET_SECTOR_SIZE\n");
|
printf("disk_ioctl: GET_SECTOR_SIZE\n");
|
||||||
|
#endif
|
||||||
*(WORD*)buff = 512;
|
*(WORD*)buff = 512;
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
||||||
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
||||||
|
#ifdef MMIO_DEBUG
|
||||||
printf("disk_ioctl: GET_BLOCK_SIZE\n");
|
printf("disk_ioctl: GET_BLOCK_SIZE\n");
|
||||||
|
#endif
|
||||||
*(DWORD*)buff = 32;
|
*(DWORD*)buff = 32;
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
||||||
|
|||||||
@ -47,16 +47,22 @@ void FATFS::fetchMem() {
|
|||||||
void FATFS::pushMem() {
|
void FATFS::pushMem() {
|
||||||
for ( int i=0;i<SHARED_SIZE;i++){
|
for ( int i=0;i<SHARED_SIZE;i++){
|
||||||
bus.write(SHARED_ADDR + i,scratch_buffer[i]);
|
bus.write(SHARED_ADDR + i,scratch_buffer[i]);
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
if ( i < 8)
|
if ( i < 8)
|
||||||
printf("0x%02x ",scratch_buffer[i]);
|
printf("0x%02x ",scratch_buffer[i]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 FATFS::mmio_read(unsigned addr) {
|
uint8 FATFS::mmio_read(unsigned addr) {
|
||||||
addr &= 0xffff;
|
addr &= 0xffff;
|
||||||
if (addr == MMIO_RETVAL){
|
if (addr == MMIO_RETVAL){
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_read retal=%i\n",retval);
|
printf("FATFS::mmio_read retal=%i\n",retval);
|
||||||
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return cpu.regs.mdr;
|
return cpu.regs.mdr;
|
||||||
@ -64,36 +70,50 @@ uint8 FATFS::mmio_read(unsigned addr) {
|
|||||||
|
|
||||||
void FATFS::mmio_write(unsigned addr, uint8 data) {
|
void FATFS::mmio_write(unsigned addr, uint8 data) {
|
||||||
addr &= 0xffff;
|
addr &= 0xffff;
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
|
printf("FATFS::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
|
||||||
|
#endif
|
||||||
if (addr == 0x3010){
|
if (addr == 0x3010){
|
||||||
switch(data){
|
switch(data){
|
||||||
case CMD_INIT:
|
case CMD_INIT:
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write CMD_INIT \n");
|
printf("FATFS::mmio_write CMD_INIT \n");
|
||||||
|
#endif
|
||||||
command = CMD_INIT;
|
command = CMD_INIT;
|
||||||
retval = disk_initialize(0);
|
retval = disk_initialize(0);
|
||||||
break;
|
break;
|
||||||
case CMD_READ:
|
case CMD_READ:
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write CMD_READ \n");
|
printf("FATFS::mmio_write CMD_READ \n");
|
||||||
|
#endif
|
||||||
command = CMD_READ;
|
command = CMD_READ;
|
||||||
break;
|
break;
|
||||||
case CMD_WRITE:
|
case CMD_WRITE:
|
||||||
command = CMD_WRITE;
|
command = CMD_WRITE;
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write CMD_WRITE \n");
|
printf("FATFS::mmio_write CMD_WRITE \n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
command = CMD_NONE;
|
command = CMD_NONE;
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write CMD_NONE \n");
|
printf("FATFS::mmio_write CMD_NONE \n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
if (addr >= MMIO_SECTOR01 && addr <= MMIO_SECTOR04){
|
if (addr >= MMIO_SECTOR01 && addr <= MMIO_SECTOR04){
|
||||||
sector = data << ( (3 - ( addr - MMIO_SECTOR01)) << 3);
|
sector = data << ( (3 - ( addr - MMIO_SECTOR01)) << 3);
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - MMIO_SECTOR01)),data,sector);
|
printf("FATFS::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - MMIO_SECTOR01)),data,sector);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (addr == MMIO_COUNT){
|
if (addr == MMIO_COUNT){
|
||||||
count = data;
|
count = data;
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write set count: count=%i \n",count);
|
printf("FATFS::mmio_write set count: count=%i \n",count);
|
||||||
|
#endif
|
||||||
if (command == CMD_READ) {
|
if (command == CMD_READ) {
|
||||||
retval = disk_read (0, (BYTE*)scratch_buffer, sector, count);
|
retval = disk_read (0, (BYTE*)scratch_buffer, sector, count);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
@ -102,11 +122,15 @@ void FATFS::mmio_write(unsigned addr, uint8 data) {
|
|||||||
fetchMem();
|
fetchMem();
|
||||||
retval = disk_write (0, (BYTE*)scratch_buffer, sector, count);
|
retval = disk_write (0, (BYTE*)scratch_buffer, sector, count);
|
||||||
} else{
|
} else{
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write set offset: no command to trigger \n");
|
printf("FATFS::mmio_write set offset: no command to trigger \n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addr == MMIO_RETVAL){
|
if (addr == MMIO_RETVAL){
|
||||||
|
#ifdef FATFS_DEBUG
|
||||||
printf("FATFS::mmio_write reg 0x3016 reset\n");
|
printf("FATFS::mmio_write reg 0x3016 reset\n");
|
||||||
|
#endif
|
||||||
retval = STA_VOID;
|
retval = STA_VOID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user