Mark and Matthew
Not sure how to document/report this but I added support for LBA mode (I
think) into the ide.c file, I have done a fair few other hacks (like getting
rid of the 'skip512' code which was probably in there to deal with a
misunderstanding of how LBA mode works - counts from 0 not 1 as CHS - which
breaks all existing hd4 files J - so better not publish that) so here are
the relevant bits;
Added 'int lba_mode' to ide struct
/*
* Return the sector offset for the current register values
*/
//prm support LBA or CHS addressing
static off64_t
ide_get_sector(void)
{
int heads = ide.hpc[ide.drive | ide.board];
int sectors = ide.spt[ide.drive | ide.board];
int skip = ide.skip512[ide.drive | ide.board];
if (ide.lba_mode)
{
// from ATA-3 head is bits 27:24, cyl is 23:8, sec is 7:0
return (off64_t)((ide.head << 24) | (ide.cylinder << 8) | ide.sector);
}
else
return ((((off64_t) ide.cylinder * heads) + ide.head) *
sectors) + (ide.sector - 1) + skip;
}
/**
* Move to the next sector using CHS addressing
*/
//prm support LBA or CHS addressing
static void
ide_next_sector(void)
{
if (ide.lba_mode)
{
int lba = (ide.head << 24) | (ide.cylinder << 8) | ide.sector;
lba++;
ide.head = (lba >> 24) & 0xF;
ide.cylinder = (lba >> 8) & 0xFFFF;
ide.sector = (lba >> 0) & 0xFF;
}
else
{
ide.sector++;
if (ide.sector == (ide.spt[ide.drive | ide.board] + 1)) {
ide.sector = 1;
ide.head++;
if (ide.head == ide.hpc[ide.drive |
ide.board]) {
ide.head = 0;
ide.cylinder++;
}
}
}
}
In writeide, captured LBA flag in command
case 0x1F6: /* Drive/Head */
ide.head=val&0xF;
ide.lba_mode = val & 0x40; //prm bit 6 is LBA addressing
flag, per command
Is this useful ?
Should I send it a different way ?
Phil.
_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu