|
|
| version 1.7, 2004/01/05 12:54:56 | version 1.16, 2005/02/07 14:46:11 |
|---|---|
| Line 4 | Line 4 |
| #include "cpucore.h" | #include "cpucore.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "bios.h" | #include "sxsibios.h" |
| #include "sxsi.h" | #if defined(SUPPORT_HOSTDRV) |
| // #include "hostdrv.h" | #include "hostdrv.h" |
| // #include "hostdir.h" | #endif |
| #define NP2SYSP_VER "B" | #define NP2SYSP_VER "C" |
| // #define NP2SYSP_CREDIT "" // 要るなら・・・ | // #define NP2SYSP_CREDIT "" // 要るなら・・・ |
| #define OPEN_HOSTDRV 0 | |
| #define INTR_HOSTDRV 1 | |
| #define CLOSE_HOSTDRV 2 | |
| // NP2依存ポート | // NP2依存ポート |
| // port:07edh np2 value comm | // port:07edh np2 value comm |
| // port:07efh np2 string comm | // port:07efh np2 string comm |
| Line 37 | Line 33 |
| typedef struct { | typedef struct { |
| const char *key; | const char *key; |
| void (*func)(const void *arg1, const void *arg2); | void (*func)(const void *arg1, long arg2); |
| const void *arg1; | const void *arg1; |
| const void *arg2; | long arg2; |
| } SYSPCMD; | } SYSPCMD; |
| static const char str_80286[] = "80286"; | static const char str_80286[] = "80286"; |
| Line 48 static const char str_pentium[] = "PENTI | Line 44 static const char str_pentium[] = "PENTI |
| static const char str_mhz[] = "%uMHz"; | static const char str_mhz[] = "%uMHz"; |
| static void np2sysp_outstr(const void *arg1, const void *arg2) { | void np2sysp_outstr(const void *arg1, long arg2) { |
| milstr_ncpy(np2sysp.outstr, (char *)arg1, sizeof(np2sysp.outstr)); | milstr_ncpy(np2sysp.outstr, (char *)arg1, sizeof(np2sysp.outstr)); |
| np2sysp.outpos = 0; | np2sysp.outpos = 0; |
| (void)arg2; | (void)arg2; |
| } | } |
| static void np2sysp_pwroff(const void *arg1, const void *arg2) { | static void np2sysp_poweroff(const void *arg1, long arg2) { |
| taskmng_exit(); | taskmng_exit(); |
| (void)arg1; | (void)arg1; |
| (void)arg2; | (void)arg2; |
| } | } |
| static void np2sysp_cpu(const void *arg1, const void *arg2) { | static void np2sysp_cpu(const void *arg1, long arg2) { |
| // CPUを返す | // CPUを返す |
| #if 1 // 80286 or V30 | #if 1 // 80286 or V30 |
| if (!(CPU_TYPE & CPUTYPE_V30)) { | if (!(CPU_TYPE & CPUTYPE_V30)) { |
| np2sysp_outstr(str_80286, NULL); | np2sysp_outstr(str_80286, 0); |
| } | } |
| else { | else { |
| np2sysp_outstr(str_v30, NULL); | np2sysp_outstr(str_v30, 0); |
| } | } |
| #else | #else |
| // 386機以降の場合 V30モードはエミュレーションだから固定(?) | // 386機以降の場合 V30モードはエミュレーションだから固定(?) |
| np2sysp_outstr(str_pentium, NULL); | np2sysp_outstr(str_pentium, 0); |
| #endif | #endif |
| (void)arg1; | (void)arg1; |
| (void)arg2; | (void)arg2; |
| } | } |
| static void np2sysp_clock(const void *arg1, const void *arg2) { | static void np2sysp_clock(const void *arg1, long arg2) { |
| SPRINTF(np2sysp.outstr, str_mhz, (pc.realclock + 500000) / 1000000); | SPRINTF(np2sysp.outstr, str_mhz, (pccore.realclock + 500000) / 1000000); |
| np2sysp.outpos = 0; | np2sysp.outpos = 0; |
| (void)arg1; | (void)arg1; |
| (void)arg2; | (void)arg2; |
| } | } |
| static void np2sysp_mul(const void *arg1, const void *arg2) { | static void np2sysp_multiple(const void *arg1, long arg2) { |
| SPRINTF(np2sysp.outstr, str_u, pc.multiple); | SPRINTF(np2sysp.outstr, str_u, pccore.multiple); |
| np2sysp.outpos = 0; | np2sysp.outpos = 0; |
| (void)arg1; | (void)arg1; |
| (void)arg2; | (void)arg2; |
| } | } |
| typedef struct { | static void np2sysp_hwreset(const void *arg1, long arg2) { |
| UINT16 r_ax; | |
| UINT16 r_bx; | |
| UINT16 r_cx; | |
| UINT16 r_dx; | |
| UINT16 r_bp; | |
| UINT16 r_es; | |
| } B1BREG; | |
| static void np2sysp_sxsi(const void *arg1, const void *arg2) { | |
| B1BREG org; | |
| UINT32 esbase_org; | |
| B1BREG r; | |
| UINT8 ret; | |
| REG8 flag; | |
| TRACEOUT(("np2sysp_sxsi")); | |
| org.r_ax = CPU_AX; | |
| org.r_cx = CPU_CX; | |
| org.r_dx = CPU_DX; | |
| org.r_bx = CPU_BX; | |
| org.r_bp = CPU_BP; | |
| org.r_es = CPU_ES; | |
| esbase_org = ES_BASE; | |
| i286_memstr_read(CPU_SS, CPU_SP, &r, sizeof(r)); | |
| CPU_AX = r.r_ax; | |
| CPU_BX = r.r_bx; | |
| CPU_CX = r.r_cx; | |
| CPU_DX = r.r_dx; | |
| CPU_BP = r.r_bp; | |
| CPU_ES = r.r_es; | |
| ES_BASE = r.r_es << 4; | |
| switch(r.r_ax & 0xf0) { | |
| case 0x00: | |
| case 0x20: | |
| ret = sxsi_operate(HDDTYPE_SASI); | |
| break; | |
| case 0x80: | |
| case 0xa0: | |
| ret = sxsi_operate(HDDTYPE_SCSI); | |
| break; | |
| default: | |
| ret = 0x40; | |
| break; | |
| } | |
| r.r_ax = CPU_AL + (ret << 8); | |
| r.r_bx = CPU_BX; | |
| r.r_cx = CPU_CX; | |
| r.r_dx = CPU_DX; | |
| i286_memstr_write(CPU_SS, CPU_SP, &r, 8); | |
| flag = i286_membyte_read(CPU_SS, CPU_SP + 0x16) & 0xfe; | |
| if (ret >= 0x20) { | |
| flag += 1; | |
| } | |
| i286_membyte_write(CPU_SS, CPU_SP + 0x16, flag); | |
| CPU_AX = org.r_ax; | |
| CPU_CX = org.r_cx; | |
| CPU_DX = org.r_dx; | |
| CPU_BX = org.r_bx; | |
| CPU_BP = org.r_bp; | |
| CPU_ES = org.r_es; | |
| ES_BASE = esbase_org; | |
| } | |
| #if 0 | |
| static void np2sysp_hostdrv(const void *arg1, const void *arg2) { | |
| switch((DWORD)arg1) { | |
| case OPEN_HOSTDRV: | |
| if(open_hostdrv()) | |
| np2sysp_outstr("ok", NULL); | |
| else | |
| np2sysp_outstr("ng", NULL); | |
| break; | |
| case INTR_HOSTDRV: | |
| intr_hostdrv(); | |
| break; | |
| case CLOSE_HOSTDRV: | hardwarereset = TRUE; |
| close_hostdrv(); | (void)arg1; |
| break; | (void)arg2; |
| } | |
| } | } |
| #endif | |
| // ---- | |
| static const char str_np2[] = "NP2"; | static const char str_np2[] = "NP2"; |
| static const char str_ver[] = "ver"; | static const char str_ver[] = "ver"; |
| static const char str_poweroff[] = "poweroff"; | static const char str_poweroff[] = "poweroff"; |
| Line 196 static const char str_credit[] = "credit | Line 109 static const char str_credit[] = "credit |
| static const char str_cpu[] = "cpu"; | static const char str_cpu[] = "cpu"; |
| static const char str_clock[] = "clock"; | static const char str_clock[] = "clock"; |
| static const char str_multiple[] = "multiple"; | static const char str_multiple[] = "multiple"; |
| static const char str_sxsibios[] = "sxsibios"; | static const char str_hwreset[] = "hardwarereset"; |
| static const char str_sasibios[] = "sasibios"; | |
| static const char str_scsibios[] = "scsibios"; | |
| static const char str_scsidev[] = "scsi_dev"; | |
| static const char str_hdrvcheck[] = "check_hostdrv"; | |
| static const char str_hdrvopen[] = "open_hostdrv"; | |
| static const char str_hdrvclose[] = "close_hostdrv"; | |
| static const char str_hdrvintr[] = "intr_hostdrv"; | |
| #if defined(NP2SYSP_VER) | #if defined(NP2SYSP_VER) |
| static const char str_syspver[] = NP2SYSP_VER; | static const char str_syspver[] = NP2SYSP_VER; |
| Line 212 static const char str_syspcredit[] = NP2 | Line 133 static const char str_syspcredit[] = NP2 |
| static const SYSPCMD np2spcmd[] = { | static const SYSPCMD np2spcmd[] = { |
| {str_np2, np2sysp_outstr, str_np2, NULL}, | {str_np2, np2sysp_outstr, str_np2, 0}, |
| {str_ver, np2sysp_outstr, str_syspver, NULL}, | {str_ver, np2sysp_outstr, str_syspver, 0}, |
| // version:A | // version:A |
| {str_poweroff, np2sysp_pwroff, NULL, NULL}, | {str_poweroff, np2sysp_poweroff, NULL, 0}, |
| // version:B | // version:B |
| {str_credit, np2sysp_outstr, str_syspcredit, NULL}, | {str_credit, np2sysp_outstr, str_syspcredit, 0}, |
| {str_cpu, np2sysp_cpu, NULL, NULL}, | {str_cpu, np2sysp_cpu, NULL, 0}, |
| {str_clock, np2sysp_clock, NULL, NULL}, | {str_clock, np2sysp_clock, NULL, 0}, |
| {str_multiple, np2sysp_mul, NULL, NULL}, | {str_multiple, np2sysp_multiple, NULL, 0}, |
| // version:C | // version:C |
| {str_sxsibios, np2sysp_sxsi, NULL, NULL}, | {str_hwreset, np2sysp_hwreset, NULL, 0}, |
| // extension | |
| #if defined(SUPPORT_IDEIO) || defined(SUPPORT_SASI) | |
| {str_sasibios, np2sysp_sasi, NULL, 0}, | |
| #endif | |
| #if defined(SUPPORT_SCSI) | |
| {str_scsibios, np2sysp_scsi, NULL, 0}, | |
| {str_scsidev, np2sysp_scsidev, NULL, 0}, | |
| #endif | |
| #if 0 | #if defined(SUPPORT_HOSTDRV) |
| // hostdrv | {str_hdrvcheck, np2sysp_outstr, "0.74", 0}, |
| {"check_hostdrv", np2sysp_outstr, "supported", | {str_hdrvopen, hostdrv_mount, NULL, 0}, |
| NULL}, | {str_hdrvclose, hostdrv_unmount, NULL, 0}, |
| {"open_hostdrv", np2sysp_hostdrv, (void *)OPEN_HOSTDRV, | {str_hdrvintr, hostdrv_intr, NULL, 0}, |
| NULL}, | |
| {"intr_hostdrv", np2sysp_hostdrv, (void *)INTR_HOSTDRV, | |
| NULL}, | |
| {"close_hostdrv", np2sysp_hostdrv, (void *)CLOSE_HOSTDRV, | |
| NULL}, | |
| {hostdir_check, np2sysp_outstr, hostdir_check, NULL}, | |
| {"hostdir_reset", hostdir_reset, NULL, NULL}, | |
| {"hostdir_band", hostdir_band, NULL, NULL}, | |
| {"hostdir_int", hostdir_int, NULL, NULL}, | |
| #endif | #endif |
| }; | }; |
| Line 269 static BOOL np2syspcmp(const char *p) { | Line 189 static BOOL np2syspcmp(const char *p) { |
| static void IOOUTCALL np2sysp_o7ed(UINT port, REG8 dat) { | static void IOOUTCALL np2sysp_o7ed(UINT port, REG8 dat) { |
| np2sysp.outval = (dat << 24) + (np2sysp.outval >> 8); | np2sysp.outval = (dat << 24) + (np2sysp.outval >> 8); |
| (void)port; | |
| } | } |
| static void IOOUTCALL np2sysp_o7ef(UINT port, REG8 dat) { | static void IOOUTCALL np2sysp_o7ef(UINT port, REG8 dat) { |
| Line 278 const SYSPCMD *cmdterm; | Line 199 const SYSPCMD *cmdterm; |
| np2sysp.substr[np2sysp.strpos] = (char)dat; | np2sysp.substr[np2sysp.strpos] = (char)dat; |
| cmd = np2spcmd; | cmd = np2spcmd; |
| cmdterm = cmd + (sizeof(np2spcmd) / sizeof(SYSPCMD)); | cmdterm = cmd + NELEMENTS(np2spcmd); |
| while(cmd < cmdterm) { | while(cmd < cmdterm) { |
| if (!np2syspcmp(cmd->key)) { | if (!np2syspcmp(cmd->key)) { |
| cmd->func(cmd->arg1, cmd->arg2); | cmd->func(cmd->arg1, cmd->arg2); |
| Line 297 static REG8 IOINPCALL np2sysp_i7ed(UINT | Line 218 static REG8 IOINPCALL np2sysp_i7ed(UINT |
| ret = (REG8)(np2sysp.inpval & 0xff); | ret = (REG8)(np2sysp.inpval & 0xff); |
| np2sysp.inpval = (ret << 24) + (np2sysp.inpval >> 8); | np2sysp.inpval = (ret << 24) + (np2sysp.inpval >> 8); |
| (void)port; | |
| return(ret); | return(ret); |
| } | } |