cleanup debug code
This commit is contained in:
david
2009-06-08 17:22:37 +02:00
parent 8e1e5ea072
commit f832f0f72b
6 changed files with 77 additions and 60 deletions

View File

@@ -17,5 +17,6 @@
#define SHARED_MAX_SIZE 512
#define SHARED_ADDR 0x3d0000
#undef MMIO_DEBUG
#undef FATFS_DEBUG
#undef MMIO_DEBUG
#undef FATFS_DEBUG
#define DISKIO_DEBUG 1

View File

@@ -1,6 +1,7 @@
#include "integer.h"
#include "diskio.h"
#include "config.h"
static volatile
DSTATUS Stat = STA_NOINIT; /* Disk status */
@@ -47,7 +48,7 @@ DSTATUS disk_initialize (BYTE drv) {
int fd = open(IMAGE_NAME, O_RDWR);
if (fd == -1) {
perror("DISKIO::disk_initialize: Error opening file for writing");
perror("BSNES::disk_initialize: Error opening file for writing");
exit(EXIT_FAILURE);
}
@@ -55,12 +56,12 @@ DSTATUS disk_initialize (BYTE drv) {
lseek(fd,0,SEEK_SET);
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);
#ifdef DISKIO_DEBUG
printf("BSNES::disk_initialize: Open Image (size %i) %p\n",size,image_addr);
#endif
if (image_addr == MAP_FAILED) {
close(fd);
perror("DISKIO::disk_initialize: Error mmapping the file");
perror("BSNES::disk_initialize: Error mmapping the file");
exit(EXIT_FAILURE);
}
@@ -96,13 +97,13 @@ DRESULT disk_read (
DWORD offset = sector * 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);
//#endif
#ifdef DISKIO_DEBUG
printf("BSNES::disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
printf("BSNES::disk_read: %02x %02x %02x %02x\n",buff[0],buff[1],buff[2],buff[3]);
#endif
memcpy(buff,image_addr + offset,size);
printf("%x %x %x %x\n",buff[0],buff[1],buff[2],buff[3]);
#ifdef MMIO_DEBUG
printf("DISKIO::disk_read: done\n");
#ifdef DISKIO_DEBUG
printf("BSNES::disk_read: done\n");
#endif
return RES_OK;
}
@@ -125,8 +126,8 @@ DRESULT disk_write (
DWORD offset = sector * 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);
#ifdef DISKIO_DEBUG
printf("BSNES::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);
return RES_OK;
@@ -152,22 +153,22 @@ DRESULT disk_ioctl (
switch (ctrl) {
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
#ifdef MMIO_DEBUG
printf("disk_ioctl: GET_SECTOR_COUNT\n");
#ifdef DISKIO_DEBUG
printf("BSNES::disk_ioctl: GET_SECTOR_COUNT\n");
#endif
ofs = 60; w = 2; n = 0;
break;
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
#ifdef MMIO_DEBUG
printf("disk_ioctl: GET_SECTOR_SIZE\n");
#ifdef DISKIO_DEBUG
printf("BSNES::disk_ioctl: GET_SECTOR_SIZE\n");
#endif
*(WORD*)buff = 512;
return RES_OK;
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
#ifdef MMIO_DEBUG
printf("disk_ioctl: GET_BLOCK_SIZE\n");
#ifdef DISKIO_DEBUG
printf("BSNES::disk_ioctl: GET_BLOCK_SIZE\n");
#endif
*(DWORD*)buff = 32;
return RES_OK;

View File

@@ -6,8 +6,6 @@
#include "diskio.h"
#include "config.h"
void FATFS::init() {
command = CMD_NONE;
sector = 0;
@@ -61,7 +59,7 @@ uint8 FATFS::mmio_read(unsigned addr) {
addr &= 0xffff;
if (addr == MMIO_RETVAL){
#ifdef FATFS_DEBUG
printf("FATFS::mmio_read retal=%i\n",retval);
printf("BSNES::mmio_read retal=%i\n",retval);
#endif
return retval;
}
@@ -71,33 +69,33 @@ uint8 FATFS::mmio_read(unsigned addr) {
void FATFS::mmio_write(unsigned addr, uint8 data) {
addr &= 0xffff;
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
printf("BSNES::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
#endif
if (addr == 0x3010){
switch(data){
case CMD_INIT:
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write CMD_INIT \n");
printf("BSNES::mmio_write CMD_INIT \n");
#endif
command = CMD_INIT;
retval = disk_initialize(0);
break;
case CMD_READ:
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write CMD_READ \n");
printf("BSNES::mmio_write CMD_READ \n");
#endif
command = CMD_READ;
break;
case CMD_WRITE:
command = CMD_WRITE;
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write CMD_WRITE \n");
printf("BSNES::mmio_write CMD_WRITE \n");
#endif
break;
default:
command = CMD_NONE;
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write CMD_NONE \n");
printf("BSNES::mmio_write CMD_NONE \n");
#endif
break;
}
@@ -106,13 +104,13 @@ void FATFS::mmio_write(unsigned addr, uint8 data) {
if (addr >= MMIO_SECTOR01 && addr <= MMIO_SECTOR04){
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("BSNES::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - MMIO_SECTOR01)),data,sector);
#endif
}
if (addr == MMIO_COUNT){
count = data;
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write set count: count=%i \n",count);
printf("BSNES::mmio_write set count: count=%i \n",count);
#endif
if (command == CMD_READ) {
retval = disk_read (0, (BYTE*)scratch_buffer, sector, count);
@@ -123,13 +121,13 @@ void FATFS::mmio_write(unsigned addr, uint8 data) {
retval = disk_write (0, (BYTE*)scratch_buffer, sector, count);
} else{
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write set offset: no command to trigger \n");
printf("BSNES::mmio_write set offset: no command to trigger \n");
#endif
}
}
if (addr == MMIO_RETVAL){
#ifdef FATFS_DEBUG
printf("FATFS::mmio_write reg 0x3016 reset\n");
printf("BSNES::mmio_write reg 0x3016 reset\n");
#endif
retval = STA_VOID;
}

Binary file not shown.