--- np2/io/np2sysp.c 2003/12/28 14:33:34 1.5 +++ np2/io/np2sysp.c 2004/01/13 05:30:58 1.11 @@ -6,19 +6,16 @@ #include "iocore.h" #include "bios.h" #include "sxsi.h" -// #include "hostdrv.h" -// #include "hostdir.h" +#if defined(SUPPORT_HOSTDRV) +#include "hostdrv.h" +#endif #define NP2SYSP_VER "B" // #define NP2SYSP_CREDIT "" // 要るなら・・・ -#define OPEN_HOSTDRV 0 -#define INTR_HOSTDRV 1 -#define CLOSE_HOSTDRV 2 - // NP2依存ポート -// port:07edh reserved +// port:07edh np2 value comm // port:07efh np2 string comm // 基本的に STRINGでやり取りする @@ -37,9 +34,9 @@ typedef struct { const char *key; - void (*func)(const void *arg1, const void *arg2); + void (*func)(const void *arg1, long arg2); const void *arg1; -const void *arg2; + long arg2; } SYSPCMD; static const char str_80286[] = "80286"; @@ -48,88 +45,93 @@ static const char str_pentium[] = "PENTI static const char str_mhz[] = "%uMHz"; -static void np2sysp_outstr(const void *arg1, const void *arg2) { +static void cmd_outstr(const void *arg1, long arg2) { milstr_ncpy(np2sysp.outstr, (char *)arg1, sizeof(np2sysp.outstr)); np2sysp.outpos = 0; (void)arg2; } -static void np2sysp_pwroff(const void *arg1, const void *arg2) { +static void cmd_poweroff(const void *arg1, long arg2) { taskmng_exit(); (void)arg1; (void)arg2; } -static void np2sysp_cpu(const void *arg1, const void *arg2) { +static void cmd_cpu(const void *arg1, long arg2) { // CPUを返す #if 1 // 80286 or V30 if (!(CPU_TYPE & CPUTYPE_V30)) { - np2sysp_outstr(str_80286, NULL); + cmd_outstr(str_80286, 0); } else { - np2sysp_outstr(str_v30, NULL); + cmd_outstr(str_v30, 0); } #else // 386機以降の場合 V30モードはエミュレーションだから固定(?) - np2sysp_outstr(str_pentium, NULL); + cmd_outstr(str_pentium, 0); #endif (void)arg1; (void)arg2; } -static void np2sysp_clock(const void *arg1, const void *arg2) { +static void cmd_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; (void)arg1; (void)arg2; } -static void np2sysp_mul(const void *arg1, const void *arg2) { +static void cmd_multiple(const void *arg1, long arg2) { - SPRINTF(np2sysp.outstr, str_u, pc.multiple); + SPRINTF(np2sysp.outstr, str_u, pccore.multiple); np2sysp.outpos = 0; (void)arg1; (void)arg2; } + +// ---- SXSI BIOS + typedef struct { - UINT16 r_ax; - UINT16 r_bx; - UINT16 r_cx; - UINT16 r_dx; - UINT16 r_bp; - UINT16 r_es; + BYTE r_ax[2]; + BYTE r_bx[2]; + BYTE r_cx[2]; + BYTE r_dx[2]; + BYTE r_bp[2]; + BYTE r_es[2]; } B1BREG; -static void np2sysp_sxsi(const void *arg1, const void *arg2) { +static void cmd_sxsibios(const void *arg1, long arg2) { - B1BREG org; - UINT32 esbase_org; + UINT16 org_ax, org_cx, org_dx, org_bx, org_bp, org_es; + UINT32 org_esbase; B1BREG r; + REG16 tmp; UINT8 ret; REG8 flag; - 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; + org_ax = CPU_AX; + org_cx = CPU_CX; + org_dx = CPU_DX; + org_bx = CPU_BX; + org_bp = CPU_BP; + org_es = CPU_ES; + org_esbase = 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) { + CPU_AX = LOADINTELWORD(r.r_ax); + CPU_BX = LOADINTELWORD(r.r_bx); + CPU_CX = LOADINTELWORD(r.r_cx); + CPU_DX = LOADINTELWORD(r.r_dx); + CPU_BP = LOADINTELWORD(r.r_bp); + tmp = LOADINTELWORD(r.r_es); + CPU_ES = tmp; + ES_BASE = tmp << 4; + switch(CPU_AX & 0xf0) { case 0x00: case 0x20: ret = sxsi_operate(HDDTYPE_SASI); @@ -144,10 +146,11 @@ static void np2sysp_sxsi(const void *arg 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; + r.r_ax[0] = CPU_AL; + r.r_ax[1] = ret; + STOREINTELWORD(r.r_bx, CPU_BX); + STOREINTELWORD(r.r_cx, CPU_CX); + STOREINTELWORD(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) { @@ -155,38 +158,55 @@ static void np2sysp_sxsi(const void *arg } 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; + CPU_AX = org_ax; + CPU_CX = org_cx; + CPU_DX = org_dx; + CPU_BX = org_bx; + CPU_BP = org_bp; + CPU_ES = org_es; + ES_BASE = org_esbase; + + (void)arg1; + (void)arg2; } -#if 0 -static void np2sysp_hostdrv(const void *arg1, const void *arg2) { - switch((DWORD)arg1) { +#if defined(SUPPORT_HOSTDRV) +// ---- hostdrv + +enum { + OPEN_HOSTDRV = 0, + CLOSE_HOSTDRV = 1, + INTR_HOSTDRV = 2 +}; + +static void cmd_hostdrv(const void *arg1, long arg2) { + + switch(arg2) { case OPEN_HOSTDRV: - if(open_hostdrv()) - np2sysp_outstr("ok", NULL); - else - np2sysp_outstr("ng", NULL); + if (hostdrv_mount() == SUCCESS) { + cmd_outstr("ok", 0); + } + else { + cmd_outstr("ng", 0); + } break; - case INTR_HOSTDRV: - intr_hostdrv(); + case CLOSE_HOSTDRV: + hostdrv_unmount(); break; - case CLOSE_HOSTDRV: - close_hostdrv(); + case INTR_HOSTDRV: + hostdrv_intr(); break; } + (void)arg1; } #endif +// ---- + static const char str_np2[] = "NP2"; static const char str_ver[] = "ver"; static const char str_poweroff[] = "poweroff"; @@ -195,6 +215,11 @@ static const char str_cpu[] = "cpu"; static const char str_clock[] = "clock"; static const char str_multiple[] = "multiple"; static const char str_sxsibios[] = "sxsibios"; +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) static const char str_syspver[] = NP2SYSP_VER; @@ -210,36 +235,26 @@ static const char str_syspcredit[] = NP2 static const SYSPCMD np2spcmd[] = { - {str_np2, np2sysp_outstr, str_np2, NULL}, - {str_ver, np2sysp_outstr, str_syspver, NULL}, + {str_np2, cmd_outstr, str_np2, 0}, + {str_ver, cmd_outstr, str_syspver, 0}, // version:A - {str_poweroff, np2sysp_pwroff, NULL, NULL}, + {str_poweroff, cmd_poweroff, NULL, 0}, // version:B - {str_credit, np2sysp_outstr, str_syspcredit, NULL}, - {str_cpu, np2sysp_cpu, NULL, NULL}, - {str_clock, np2sysp_clock, NULL, NULL}, - {str_multiple, np2sysp_mul, NULL, NULL}, - -// version:C - {str_sxsibios, np2sysp_sxsi, NULL, NULL}, - -#if 0 -// hostdrv - {"check_hostdrv", np2sysp_outstr, "supported", - NULL}, - {"open_hostdrv", np2sysp_hostdrv, (void *)OPEN_HOSTDRV, - 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}, + {str_credit, cmd_outstr, str_syspcredit, 0}, + {str_cpu, cmd_cpu, NULL, 0}, + {str_clock, cmd_clock, NULL, 0}, + {str_multiple, cmd_multiple, NULL, 0}, + + +// extension + {str_sxsibios, cmd_sxsibios, NULL, 0}, +#if defined(SUPPORT_HOSTDRV) + {str_hdrvcheck, cmd_outstr, "supported", 0}, + {str_hdrvopen, cmd_hostdrv, NULL, OPEN_HOSTDRV}, + {str_hdrvclose, cmd_hostdrv, NULL, CLOSE_HOSTDRV}, + {str_hdrvintr, cmd_hostdrv, NULL, INTR_HOSTDRV}, #endif }; @@ -264,6 +279,12 @@ static BOOL np2syspcmp(const char *p) { return(FALSE); } +static void IOOUTCALL np2sysp_o7ed(UINT port, REG8 dat) { + + np2sysp.outval = (dat << 24) + (np2sysp.outval >> 8); + (void)port; +} + static void IOOUTCALL np2sysp_o7ef(UINT port, REG8 dat) { const SYSPCMD *cmd; @@ -284,6 +305,16 @@ const SYSPCMD *cmdterm; (void)port; } +static REG8 IOINPCALL np2sysp_i7ed(UINT port) { + + REG8 ret; + + ret = (REG8)(np2sysp.inpval & 0xff); + np2sysp.inpval = (ret << 24) + (np2sysp.inpval >> 8); + (void)port; + return(ret); +} + static REG8 IOINPCALL np2sysp_i7ef(UINT port) { REG8 ret; @@ -307,7 +338,9 @@ void np2sysp_reset(void) { void np2sysp_bind(void) { + iocore_attachout(0x07ef, np2sysp_o7ed); iocore_attachout(0x07ef, np2sysp_o7ef); + iocore_attachinp(0x07ef, np2sysp_i7ed); iocore_attachinp(0x07ef, np2sysp_i7ef); }