--- np2/bios/sxsibios.c 2004/01/22 04:59:48 1.2 +++ np2/bios/sxsibios.c 2004/02/13 08:01:12 1.10 @@ -6,6 +6,7 @@ #include "sxsibios.h" #include "scsicmd.h" #include "sxsi.h" +#include "timing.h" typedef REG8 (*SXSIFUNC)(UINT type, SXSIDEV sxsi); @@ -111,7 +112,25 @@ static REG8 sxsibios_format(UINT type, S long pos; if (CPU_AH & 0x80) { - ret = 0xd0; + if (type == SXSIBIOS_SCSI) { // とりあえずSCSIのみ + UINT count; + long posmax; + count = timing_getcount(); // 時間を止める + ret = 0; + pos = 0; + posmax = sxsi->surfaces * sxsi->cylinders; + while(pos < posmax) { + ret = sxsi_format(CPU_AL, pos * sxsi->sectors); + if (ret) { + break; + } + pos++; + } + timing_setcount(count); // 再開 + } + else { + ret = 0xd0; + } } else { if (CPU_DL) { @@ -177,7 +196,7 @@ static REG8 sasibios_sense(UINT type, SX CPU_DH = sxsi->surfaces; CPU_DL = sxsi->sectors; } - return(0x00); + return(0x0f); } } @@ -201,19 +220,24 @@ static const SXSIFUNC sasifunc[16] = { REG8 sasibios_operate(void) { - SXSIDEV sxsi; UINT type; + SXSIDEV sxsi; - sxsi = sxsi_getptr(CPU_AL); - if (sxsi == NULL) { - return(0x60); + if (pccore.hddif & PCHDD_IDE) { + type = SXSIBIOS_IDE; } - type = SXSIBIOS_IDE; #if defined(SUPPORT_SASI) - if (pccore.hddif & PCHDD_SASI) { + else if (pccore.hddif & PCHDD_SASI) { type = SXSIBIOS_SASI; } #endif + else { + return(0x60); + } + sxsi = sxsi_getptr(CPU_AL); + if (sxsi == NULL) { + return(0x60); + } return((*sasifunc[CPU_AH & 0x0f])(type, sxsi)); } @@ -221,11 +245,39 @@ REG8 sasibios_operate(void) { // ---- scsi #if defined(SUPPORT_SCSI) + +static void scsibios_set(REG8 drv, REG8 sectors, REG8 surfaces, + REG16 cylinders, REG16 size, BOOL hwsec) { + + BYTE *scsiinf; + UINT16 inf; + + scsiinf = mem + 0x00460 + ((drv & 7) * 4); + inf = 0; + + inf = (UINT16)(cylinders & 0xfff); + if (cylinders >= 0x1000) { + inf |= 0x4000; + surfaces |= (cylinders >> 8) & 0xf0; + } + if (size == 512) { + inf |= 0x1000; + } + else if (size == 1024) { + inf |= 0x2000; + } + if (hwsec) { + inf |= 0x8000; + } + scsiinf[0] = (UINT8)sectors; + scsiinf[1] = (UINT8)surfaces; + STOREINTELWORD(scsiinf + 2, inf); +} + static REG8 scsibios_init(UINT type, SXSIDEV sxsi) { UINT8 i; UINT8 bit; - UINT16 w; mem[MEMB_DISK_EQUIPS] = 0; ZeroMemory(&mem[0x00460], 0x20); @@ -233,24 +285,8 @@ static REG8 scsibios_init(UINT type, SXS sxsi = sxsi_getptr((REG8)(0x20 + i)); if ((sxsi) && (sxsi->fname[0])) { mem[MEMB_DISK_EQUIPS] |= bit; - mem[0x00460+i*4] = sxsi->sectors; - mem[0x00461+i*4] = sxsi->surfaces; - switch(sxsi->size) { - case 256: - w = 0 << 12; - break; - - case 512: - w = 1 << 12; - break; - - default: - w = 2 << 12; - break; - } - w |= 0xc000; - w |= sxsi->cylinders; - SETBIOSMEM16(0x00462+i*4, w); + scsibios_set(i, sxsi->sectors, sxsi->surfaces, + sxsi->cylinders, sxsi->size, TRUE); } } (void)type; @@ -259,16 +295,26 @@ static REG8 scsibios_init(UINT type, SXS static REG8 scsibios_sense(UINT type, SXSIDEV sxsi) { - if (CPU_AH == 0x44) { - CPU_BX = 1; + BYTE *scsiinf; + + scsiinf = mem + 0x00460 + ((CPU_AL & 7) * 4); + if (CPU_AH == 0x24) { + scsibios_set(CPU_AL, CPU_DL, CPU_DH, CPU_CX, CPU_BX, FALSE); + } + else if (CPU_AH == 0x44) { + CPU_BX = (scsiinf[3] & 0x80)?2:1; } else if (CPU_AH == 0x84) { - CPU_BX = sxsi->size; - CPU_CX = sxsi->cylinders; - CPU_DH = sxsi->surfaces; - CPU_DL = sxsi->sectors; + CPU_DL = scsiinf[0]; + CPU_DH = scsiinf[1] & 0x0f; + CPU_CX = scsiinf[2] + ((scsiinf[3] & 0xf) << 8); + if (scsiinf[3] & 0x40) { + CPU_CX += (scsiinf[1] & 0xf0) << 8; + } + CPU_BX = 256 << ((scsiinf[3] >> 4) & 3); } (void)type; + (void)sxsi; return(0x00); } @@ -311,6 +357,9 @@ REG8 scsibios_operate(void) { SXSIDEV sxsi; + if (!(pccore.hddif & PCHDD_SCSI)) { + return(0x60); + } sxsi = sxsi_getptr(CPU_AL); if (sxsi == NULL) { return(0x60);