Re: [hatari-devel] Blitter / IDE issue with Hatari |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On sunnuntai 28 syyskuu 2014, Nicolas Pomarède wrote:
> Le 28/09/2014 21:02, Eero Tamminen a écrit :
> > Corrected the subject (there's another issue reported by AtariZoll,
> > related to Blitter / IDE).
>
> For this one, I submitted a change to the blitter, let's see if it works
> better with Falcon's IDE.
AtariZoll provided a test image for that a bit earlier in
that thread (DOAB_IDE.rar IDE disk image).
I tried that, but it still doesn't work with Hatari
Falcon emulation:
$ hatari -m --conout 2 --trace gemdos \
--machine falcon --tos tos404.img --ide-master DOAB_IDE.img
The file system on image seems to be fine as I can boot from it
with IDE emulation when using EmuTOS instead of the driver on
the image itself (EmuTOS has builtin IDE HD support, also for
other machines that Falcon).
Related to that, I changed ide.c debug prints to new trace
option. Does the attached patch look OK to commit?
- Eero
diff -r 7a5973eb8ae1 src/debug/log.c
--- a/src/debug/log.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/debug/log.c Sun Sep 28 22:03:29 2014 +0300
@@ -138,6 +138,9 @@
{ TRACE_MIDI , "midi" } ,
+ { TRACE_IDE , "ide" } ,
+ { TRACE_IDE_IO , "ide_io" } ,
+
{ TRACE_ALL , "all" }
};
#endif /* ENABLE_TRACING */
diff -r 7a5973eb8ae1 src/debug/log.h
--- a/src/debug/log.h Sat Sep 27 20:45:55 2014 +0200
+++ b/src/debug/log.h Sun Sep 28 22:03:29 2014 +0300
@@ -168,6 +168,9 @@
#define TRACE_MIDI (1ll<<49)
+#define TRACE_IDE (1ll<<50)
+#define TRACE_IDE_IO (1ll<<51)
+
#define TRACE_NONE (0)
#define TRACE_ALL (~0)
diff -r 7a5973eb8ae1 src/ide.c
--- a/src/ide.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/ide.c Sun Sep 28 22:03:29 2014 +0300
@@ -31,14 +31,6 @@
struct IDEState;
-#define IDE_DEBUG 0
-
-#if IDE_DEBUG
-#define Dprintf(a) printf a
-#else
-#define Dprintf(a)
-#endif
-
static struct IDEState *opaque_ide_if;
static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val);
@@ -91,7 +83,7 @@
int ideport;
uint8_t retval;
- Dprintf(("IdeMem_bget($%x)\n", addr));
+ LOG_TRACE(TRACE_IDE_IO, "IDE: bget($%x) ", addr);
addr &= 0x00ffffff; /* Use a 24 bit address */
@@ -99,6 +91,7 @@
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_READ);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return -1;
}
@@ -117,6 +110,7 @@
retval = 0xFF;
}
+ LOG_TRACE(TRACE_IDE_IO, "= $%02x\n", retval);
return retval;
}
@@ -128,14 +122,15 @@
{
uint16_t retval;
+ LOG_TRACE(TRACE_IDE_IO, "IDE: wget($%x) ", addr);
+
addr &= 0x00ffffff; /* Use a 24 bit address */
if (addr >= 0xf00040 || !ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_READ);
- if (ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
- fprintf(stderr, "Illegal IDE IO memory access: IdeMem_wget($%x)\n", addr);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return -1;
}
@@ -148,9 +143,7 @@
retval = 0xFFFF;
}
- Dprintf(("IdeMem_wget($%x) = $%04x\n", addr, retval));
-
-
+ LOG_TRACE(TRACE_IDE_IO, "= $%04x\n", retval);
return retval;
}
@@ -162,14 +155,15 @@
{
uint32_t retval;
+ LOG_TRACE(TRACE_IDE_IO, "IDE: lget($%x) ", addr);
+
addr &= 0x00ffffff; /* Use a 24 bit address */
if (addr >= 0xf00040 || !ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_READ);
- if (ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
- fprintf(stderr, "Illegal IDE IO memory access: IdeMem_lget($%x)\n", addr);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return -1;
}
@@ -185,7 +179,7 @@
/* word swap for long access to data register */
retval = ((retval >> 16) & 0x0000ffff) | ((retval & 0x0000ffff) << 16);
- Dprintf(("IdeMem_lget($%x) = $%08x\n", addr, retval));
+ LOG_TRACE(TRACE_IDE_IO, "= $%08x\n", retval);
return retval;
}
@@ -198,16 +192,16 @@
{
int ideport;
+ LOG_TRACE(TRACE_IDE_IO, "IDE: bput($%x)\n", addr);
+
addr &= 0x00ffffff; /* Use a 24 bit address */
val &= 0x0ff;
- Dprintf(("IdeMem_bput($%x, $%x)\n", addr, val));
-
if (addr >= 0xf00040 || !ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_WRITE);
- //fprintf(stderr, "Illegal IDE IO memory access: IdeMem_bput($%x)\n", addr);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return;
}
@@ -229,16 +223,16 @@
*/
void Ide_Mem_wput(uaecptr addr, uae_u32 val)
{
+ LOG_TRACE(TRACE_IDE_IO, "IDE: wput($%x)\n", addr);
+
addr &= 0x00ffffff; /* Use a 24 bit address */
val &= 0x0ffff;
- Dprintf(("IdeMem_wput($%x, $%x)\n", addr, val));
-
if (addr >= 0xf00040 || !ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_WRITE);
- //fprintf(stderr, "Illegal IDE IO memory access: IdeMem_wput($%x)\n", addr);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return;
}
@@ -254,15 +248,15 @@
*/
void Ide_Mem_lput(uaecptr addr, uae_u32 val)
{
+ LOG_TRACE(TRACE_IDE_IO, "IDE: lput($%x)\n", addr);
+
addr &= 0x00ffffff; /* Use a 24 bit address */
- Dprintf(("IdeMem_lput($%x, $%x)\n", addr, val));
-
if (addr >= 0xf00040 || !ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
{
/* invalid memory addressing --> bus error */
M68000_BusError(addr, BUS_ERROR_WRITE);
- //fprintf(stderr, "Illegal IDE IO memory access: IdeMem_lput($%x)\n", addr);
+ LOG_TRACE(TRACE_IDE_IO, "-> BUS ERROR at PC 0x%X\n", M68000_GetPC());
return;
}
@@ -510,7 +504,7 @@
ret = fread(buf, 1, len, bs->fhndl);
if (ret != len)
{
- fprintf(stderr,"IDE bdrv_read error: (%d != %d length) at sector %lu!\n", ret, len, (unsigned long)sector_num);
+ fprintf(stderr,"IDE: bdrv_read error (%d != %d length) at sector %lu!\n", ret, len, (unsigned long)sector_num);
return -EINVAL;
}
else
@@ -544,7 +538,7 @@
ret = fwrite(buf, 1, len, bs->fhndl);
if (ret != len)
{
- fprintf(stderr,"IDE bdrv_write error: (%d != %d length) at sector %lu!\n", ret, len, (unsigned long)sector_num);
+ fprintf(stderr,"IDE: bdrv_write error (%d != %d length) at sector %lu!\n", ret, len, (unsigned long)sector_num);
return -EIO;
}
else
@@ -603,11 +597,7 @@
}
-/* debug IDE devices */
-// #define DEBUG_IDE
-// #define DEBUG_IDE_ATAPI
-
-// #define USE_DMA_CDROM
+#define USE_DMA_CDROM
/* Bits of HD_STATUS */
#define ERR_STAT 0x01
@@ -1223,9 +1213,8 @@
}
else
{
-#if defined(DEBUG_IDE)
- printf("IDE read sector=%Ld\n", sector_num);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: read sector=%Ld\n", sector_num);
+
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
ret = bdrv_read(s->bs, sector_num, s->io_buffer, n);
@@ -1250,9 +1239,8 @@
s->status = READY_STAT | SEEK_STAT;
sector_num = ide_get_sector(s);
-#if defined(DEBUG_IDE)
- printf("IDE write sector=%Ld\n", sector_num);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: write sector=%Ld\n", sector_num);
+
n = s->nsector;
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
@@ -1292,9 +1280,8 @@
static void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc)
{
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE atapi_cmd_error: sense=0x%x asc=0x%x\n", sense_key, asc);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI cmd error sense=0x%x asc=0x%x\n", sense_key, asc);
+
s->error = sense_key << 4;
s->status = READY_STAT | ERR_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
@@ -1394,12 +1381,12 @@
static void ide_atapi_cmd_reply_end(IDEState *s)
{
int byte_count_limit, size, ret;
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE reply: tx_size=%d elem_tx_size=%d index=%d\n",
+
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI reply tx_size=%d elem_tx_size=%d index=%d\n",
s->packet_transfer_size,
s->elementary_transfer_size,
s->io_buffer_index);
-#endif
+
if (s->packet_transfer_size <= 0)
{
/* end of transfer */
@@ -1407,9 +1394,7 @@
s->status = READY_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s);
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE status=0x%x\n", s->status);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI status=0x%x\n", s->status);
}
else
{
@@ -1444,9 +1429,8 @@
/* a new transfer is needed */
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO;
byte_count_limit = s->lcyl | (s->hcyl << 8);
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE byte_count_limit=%d\n", byte_count_limit);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI byte_count_limit=%d\n", byte_count_limit);
+
if (byte_count_limit == 0xffff)
byte_count_limit--;
size = s->packet_transfer_size;
@@ -1472,9 +1456,8 @@
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_set_irq(s);
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE status=0x%x\n", s->status);
-#endif
+
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI status=0x%x\n", s->status);
}
}
}
@@ -1498,9 +1481,8 @@
static void ide_atapi_cmd_read(IDEState *s, int lba, int nb_sectors,
int sector_size)
{
-#ifdef DEBUG_IDE_ATAPI
- printf("IDE read pio: LBA=%d nb_sectors=%d\n", lba, nb_sectors);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: ATAPI read pio LBA=%d nb_sectors=%d\n", lba, nb_sectors);
+
s->lba = lba;
s->packet_transfer_size = nb_sectors * sector_size;
s->elementary_transfer_size = 0;
@@ -1520,17 +1502,17 @@
packet = s->io_buffer;
buf = s->io_buffer;
-#ifdef DEBUG_IDE_ATAPI
+ if (LOG_TRACE_LEVEL(TRACE_IDE))
{
int i;
- printf("IDE ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl << 8));
+ LOG_TRACE_PRINT("IDE: ATAPI limit=0x%x packet", s->lcyl | (s->hcyl << 8));
for (i = 0; i < ATAPI_PACKET_SIZE; i++)
{
printf(" %02x", packet[i]);
}
printf("\n");
}
-#endif
+
switch (s->io_buffer[0])
{
case GPCMD_TEST_UNIT_READY:
@@ -1972,9 +1954,7 @@
int unit, n;
int lba48 = 0;
-#ifdef DEBUG_IDE
- printf("IDE: write addr=0x%x val=0x%02x\n", addr, val);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: write addr=0x%x val=0x%02x\n", addr, val);
addr &= 7;
switch (addr)
@@ -2029,9 +2009,8 @@
default:
case 7:
/* command */
-#if defined(DEBUG_IDE)
- printf("IDE: CMD=%02x\n", val);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: CMD=%02x\n", val);
+
s = ide_if->cur_drive;
/* ignore commands to non existent slave */
if (s != ide_if && !s->bs)
@@ -2376,9 +2355,7 @@
MFP_GPIP |= 0x20;
break;
}
-#ifdef DEBUG_IDE
- printf("IDE: read addr=0x%x val=%02x\n", addr1, ret);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: read addr=0x%x val=%02x\n", addr1, ret);
return ret;
}
@@ -2393,9 +2370,8 @@
ret = 0;
else
ret = s->status;
-#ifdef DEBUG_IDE
- printf("IDE: read status addr=0x%x val=%02x\n", addr, ret);
-#endif
+
+ LOG_TRACE(TRACE_IDE, "IDE: read status addr=0x%x val=%02x\n", addr, ret);
return ret;
}
@@ -2405,9 +2381,8 @@
IDEState *s;
int i;
-#ifdef DEBUG_IDE
- printf("IDE: write control addr=0x%x val=%02x\n", addr, val);
-#endif
+ LOG_TRACE(TRACE_IDE, "IDE: write control addr=0x%x val=%02x\n", addr, val);
+
/* common for both drives */
if (!(ide_if[0].cmd & IDE_CMD_RESET) &&
(val & IDE_CMD_RESET))
@@ -2575,10 +2550,8 @@
*pheads = heads;
*psectors = sectors;
*pcylinders = cylinders;
-#if 0
- printf("IDE guessed geometry: LCHS=%d %d %d\n",
+ LOG_TRACE(TRACE_IDE, "IDE: guessed geometry LCHS=%d %d %d\n",
cylinders, heads, sectors);
-#endif
qemu_free(buf);
return 0;
}