ao486: support for CD image mounting from core.

This commit is contained in:
sorgelig
2020-10-02 03:17:07 +08:00
parent 86fa5ed02d
commit 84487caf9c
3 changed files with 35 additions and 0 deletions

View File

@@ -1192,6 +1192,24 @@ void cdrom_handle_pkt(ide_config *ide)
}
}
static void prep_FA_cmd(ide_config *ide)
{
ide->prepcnt = ide->regs.sector_count;
if (!ide->prepcnt || ide->prepcnt > ide_io_max_size) ide->prepcnt = ide_io_max_size;
ide->regs.status = ATA_STATUS_RDY | ATA_STATUS_DRQ | ATA_STATUS_IRQ;
if (ide->state == IDE_STATE_INIT_RW)
{
ide->regs.status &= ~ATA_STATUS_IRQ;
ide->null = 1;
}
ide->state = IDE_STATE_WAIT_WR;
ide->regs.pkt_io_size = ide->prepcnt * 256;
ide_set_regs(ide);
}
int cdrom_handle_cmd(ide_config *ide)
{
uint8_t drv;
@@ -1211,6 +1229,11 @@ int cdrom_handle_cmd(ide_config *ide)
ide->state = IDE_STATE_WAIT_END;
break;
case 0xFA: // mount image
ide->state = IDE_STATE_INIT_RW;
prep_FA_cmd(ide);
break;
case 0xEC: // identify (fail)
dbg_printf("identify (CD)\n");
ide->regs.sector = 1;

View File

@@ -101,12 +101,15 @@ void ide_set_regs(ide_config *ide)
void x86_ide_set(uint32_t num, uint32_t baseaddr, fileTYPE *f, int ver, int cd)
{
int drvnum = num;
int drv = (ver == 3) ? (num & 1) : 0;
if (ver == 3) num >>= 1;
drive_t *drive = &ide_inst[num].drive[drv];
ide_inst[num].base = baseaddr;
ide_inst[num].drive[drv].drvnum = drvnum;
drive->f = f;
drive->cylinders = 0;
@@ -449,6 +452,14 @@ static void process_write(ide_config *ide)
ide->regs.cylinder = lba;
lba >>= 16;
ide->regs.head = lba & 0xF;
if (ide->regs.cmd == 0xFA)
{
ide->regs.sector_count = 0;
char* filename = user_io_make_filepath(HomeDir(), (char*)ide_buf);
printf("Request for new image for drive %d: %s\n", ide->drive[ide->regs.drv].drvnum, filename);
x86_set_image(ide->drive[ide->regs.drv].drvnum + 2, filename);
}
}
static int handle_hdd(ide_config *ide)

View File

@@ -72,6 +72,7 @@ typedef struct
{
fileTYPE *f;
uint8_t present;
uint8_t drvnum;
uint16_t cylinders;
uint16_t heads;