| version 1.13, 2004/01/22 04:23:06 | version 1.24, 2007/11/11 12:46:07 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 | #include        "strres.h" | #include        "strres.h" | 
 |  | #if defined(OSLANG_UCS2) | 
 |  | #include        "oemtext.h" | 
 |  | #endif | 
 | #include        "taskmng.h" | #include        "taskmng.h" | 
 | #include        "cpucore.h" | #include        "cpucore.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
| Line 10 | Line 13 | 
 | #endif | #endif | 
 |  |  | 
 |  |  | 
| #define         NP2SYSP_VER                     "B" | #define         NP2SYSP_VER                     "C" | 
 | // #define      NP2SYSP_CREDIT          ""                                      // 要るなら・・・ | // #define      NP2SYSP_CREDIT          ""                                      // 要るなら・・・ | 
 |  |  | 
 | // NP2依存ポート | // NP2依存ポート | 
| Line 38  const void *arg1; | Line 41  const void *arg1; | 
 | long    arg2; | long    arg2; | 
 | } SYSPCMD; | } SYSPCMD; | 
 |  |  | 
| static const char str_80286[] = "80286"; | static const OEMCHAR str_80286[] = OEMTEXT("80286"); | 
| static const char str_v30[] = "V30"; | static const OEMCHAR str_v30[] = OEMTEXT("V30"); | 
| static const char str_pentium[] = "PENTIUM"; | static const OEMCHAR str_pentium[] = OEMTEXT("PENTIUM"); | 
| static const char str_mhz[] = "%uMHz"; | static const OEMCHAR str_mhz[] = OEMTEXT("%uMHz"); | 
 |  |  | 
 |  |  | 
| void np2sysp_outstr(const void *arg1, long arg2) { | static void setoutstr(const OEMCHAR *str) { | 
 |  |  | 
| milstr_ncpy(np2sysp.outstr, (char *)arg1, sizeof(np2sysp.outstr)); | #if defined(OSLANG_UCS2) | 
|  | oemtext_oemtosjis(np2sysp.outstr, sizeof(np2sysp.outstr), str, -1); | 
|  | #else | 
|  | milstr_ncpy(np2sysp.outstr, str, sizeof(np2sysp.outstr)); | 
|  | #endif | 
 | np2sysp.outpos = 0; | np2sysp.outpos = 0; | 
 |  | } | 
 |  |  | 
 |  | void np2sysp_outstr(const void *arg1, long arg2) { | 
 |  |  | 
 |  | setoutstr((OEMCHAR *)arg1); | 
 | (void)arg2; | (void)arg2; | 
 | } | } | 
 |  |  | 
| Line 63  static void np2sysp_cpu(const void *arg1 | Line 75  static void np2sysp_cpu(const void *arg1 | 
 | // 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, 0); | setoutstr(str_80286); | 
 | } | } | 
 | else { | else { | 
| np2sysp_outstr(str_v30, 0); | setoutstr(str_v30); | 
 | } | } | 
 | #else | #else | 
 | // 386機以降の場合 V30モードはエミュレーションだから固定(?) | // 386機以降の場合 V30モードはエミュレーションだから固定(?) | 
| np2sysp_outstr(str_pentium, 0); | setoutstr(str_pentium); | 
 | #endif | #endif | 
 | (void)arg1; | (void)arg1; | 
 | (void)arg2; | (void)arg2; | 
| Line 78  static void np2sysp_cpu(const void *arg1 | Line 90  static void np2sysp_cpu(const void *arg1 | 
 |  |  | 
 | static void np2sysp_clock(const void *arg1, long arg2) { | static void np2sysp_clock(const void *arg1, long arg2) { | 
 |  |  | 
| SPRINTF(np2sysp.outstr, str_mhz, (pccore.realclock + 500000) / 1000000); | OEMCHAR str[16]; | 
| np2sysp.outpos = 0; |  | 
|  | OEMSPRINTF(str, str_mhz, (pccore.realclock + 500000) / 1000000); | 
|  | setoutstr(str); | 
 | (void)arg1; | (void)arg1; | 
 | (void)arg2; | (void)arg2; | 
 | } | } | 
 |  |  | 
 | static void np2sysp_multiple(const void *arg1, long arg2) { | static void np2sysp_multiple(const void *arg1, long arg2) { | 
 |  |  | 
| SPRINTF(np2sysp.outstr, str_u, pccore.multiple); | OEMCHAR str[16]; | 
| np2sysp.outpos = 0; |  | 
|  | OEMSPRINTF(str, str_u, pccore.multiple); | 
|  | setoutstr(str); | 
|  | (void)arg1; | 
|  | (void)arg2; | 
|  | } | 
|  |  | 
|  | static void np2sysp_hwreset(const void *arg1, long arg2) { | 
|  |  | 
|  | pcstat.hardwarereset = TRUE; | 
 | (void)arg1; | (void)arg1; | 
 | (void)arg2; | (void)arg2; | 
 | } | } | 
| Line 95  static void np2sysp_multiple(const void | Line 118  static void np2sysp_multiple(const void | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static const char str_np2[] = "NP2"; | static const char cmd_np2[] = "NP2"; | 
| static const char str_ver[] = "ver"; | static const OEMCHAR rep_np2[] = OEMTEXT("NP2"); | 
| static const char str_poweroff[] = "poweroff"; |  | 
| static const char str_credit[] = "credit"; |  | 
| static const char str_cpu[] = "cpu"; |  | 
| static const char str_clock[] = "clock"; |  | 
| static const char str_multiple[] = "multiple"; |  | 
| 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"; |  | 
 |  |  | 
 |  | static const char cmd_ver[] = "ver"; | 
 |  | static const char cmd_poweroff[] = "poweroff"; | 
 |  | static const char cmd_credit[] = "credit"; | 
 |  | static const char cmd_cpu[] = "cpu"; | 
 |  | static const char cmd_clock[] = "clock"; | 
 |  | static const char cmd_multiple[] = "multiple"; | 
 |  | static const char cmd_hwreset[] = "hardwarereset"; | 
 |  | #if defined(SUPPORT_IDEIO) || defined(SUPPORT_SASI) | 
 |  | static const char cmd_sasibios[] = "sasibios"; | 
 |  | #endif | 
 |  | #if defined(SUPPORT_SCSI) | 
 |  | static const char cmd_scsibios[] = "scsibios"; | 
 |  | static const char cmd_scsidev[] = "scsi_dev"; | 
 |  | #endif | 
 |  | #if defined(SUPPORT_HOSTDRV) | 
 |  | static const char cmd_hdrvcheck[] = "check_hostdrv"; | 
 |  | static const char cmd_hdrvopen[] = "open_hostdrv"; | 
 |  | static const char cmd_hdrvclose[] = "close_hostdrv"; | 
 |  | static const char cmd_hdrvintr[] = "intr_hostdrv"; | 
 |  | static const OEMCHAR rep_hdrvcheck[] = OEMTEXT("0.74"); | 
 |  | #endif | 
 |  |  | 
 | #if defined(NP2SYSP_VER) | #if defined(NP2SYSP_VER) | 
| static const char str_syspver[] = NP2SYSP_VER; | static const OEMCHAR str_syspver[] = OEMTEXT(NP2SYSP_VER); | 
 | #else | #else | 
 | #define str_syspver             str_null | #define str_syspver             str_null | 
 | #endif | #endif | 
 |  |  | 
 | #if defined(NP2SYSP_CREDIT) | #if defined(NP2SYSP_CREDIT) | 
| static const char str_syspcredit[] = NP2SYSP_CREDIT; | static const OEMCHAR str_syspcredit[] = OEMTEXT(NP2SYSP_CREDIT); | 
 | #else | #else | 
 | #define str_syspcredit  str_null | #define str_syspcredit  str_null | 
 | #endif | #endif | 
 |  |  | 
 |  |  | 
 | static const SYSPCMD np2spcmd[] = { | static const SYSPCMD np2spcmd[] = { | 
| {str_np2,               np2sysp_outstr,         str_np2,                0}, | {cmd_np2,               np2sysp_outstr,         rep_np2,                0}, | 
| {str_ver,               np2sysp_outstr,         str_syspver,    0}, | {cmd_ver,               np2sysp_outstr,         str_syspver,    0}, | 
 |  |  | 
 | // version:A | // version:A | 
| {str_poweroff,  np2sysp_poweroff,       NULL,                   0}, | {cmd_poweroff,  np2sysp_poweroff,       NULL,                   0}, | 
 |  |  | 
 | // version:B | // version:B | 
| {str_credit,    np2sysp_outstr,         str_syspcredit, 0}, | {cmd_credit,    np2sysp_outstr,         str_syspcredit, 0}, | 
| {str_cpu,               np2sysp_cpu,            NULL,                   0}, | {cmd_cpu,               np2sysp_cpu,            NULL,                   0}, | 
| {str_clock,             np2sysp_clock,          NULL,                   0}, | {cmd_clock,             np2sysp_clock,          NULL,                   0}, | 
| {str_multiple,  np2sysp_multiple,       NULL,                   0}, | {cmd_multiple,  np2sysp_multiple,       NULL,                   0}, | 
|  |  | 
|  | // version:C | 
|  | {cmd_hwreset,   np2sysp_hwreset,        NULL,                   0}, | 
 |  |  | 
 | // extension | // extension | 
| #if defined(SUPPORT_SASI) | #if defined(SUPPORT_IDEIO) || defined(SUPPORT_SASI) | 
| {str_sasibios,  np2sysp_sasi,           NULL,                   0}, | {cmd_sasibios,  np2sysp_sasi,           NULL,                   0}, | 
 | #endif | #endif | 
 | #if defined(SUPPORT_SCSI) | #if defined(SUPPORT_SCSI) | 
| {str_scsibios,  np2sysp_scsi,           NULL,                   0}, | {cmd_scsibios,  np2sysp_scsi,           NULL,                   0}, | 
| {str_scsidev,   np2sysp_scsidev,        NULL,                   0}, | {cmd_scsidev,   np2sysp_scsidev,        NULL,                   0}, | 
 | #endif | #endif | 
 |  |  | 
 | #if defined(SUPPORT_HOSTDRV) | #if defined(SUPPORT_HOSTDRV) | 
| {str_hdrvcheck, np2sysp_outstr,         "0.74",                 0}, | {cmd_hdrvcheck, np2sysp_outstr,         rep_hdrvcheck,  0}, | 
| {str_hdrvopen,  hostdrv_mount,          NULL,                   0}, | {cmd_hdrvopen,  hostdrv_mount,          NULL,                   0}, | 
| {str_hdrvclose, hostdrv_unmount,        NULL,                   0}, | {cmd_hdrvclose, hostdrv_unmount,        NULL,                   0}, | 
| {str_hdrvintr,  hostdrv_intr,           NULL,                   0}, | {cmd_hdrvintr,  hostdrv_intr,           NULL,                   0}, | 
 | #endif | #endif | 
 | }; | }; | 
 |  |  | 
 |  |  | 
| static BOOL np2syspcmp(const char *p) { | static BRESULT np2syspcmp(const char *p) { | 
 |  |  | 
 | int             len; | int             len; | 
 | int             pos; | int             pos; | 
 |  |  | 
| len = strlen(p); | len = (int)STRLEN(p); | 
 | if (!len) { | if (!len) { | 
| return(TRUE); | return(FAILURE); | 
 | } | } | 
 | pos = np2sysp.strpos; | pos = np2sysp.strpos; | 
 | while(len--) { | while(len--) { | 
 | if (p[len] != np2sysp.substr[pos]) { | if (p[len] != np2sysp.substr[pos]) { | 
| return(TRUE); | return(FAILURE); | 
 | } | } | 
 | pos--; | pos--; | 
 | pos &= NP2SYSP_MASK; | pos &= NP2SYSP_MASK; | 
 | } | } | 
| return(FALSE); | return(SUCCESS); | 
 | } | } | 
 |  |  | 
 | static void IOOUTCALL np2sysp_o7ed(UINT port, REG8 dat) { | static void IOOUTCALL np2sysp_o7ed(UINT port, REG8 dat) { | 
| Line 188  const SYSPCMD *cmdterm; | Line 223  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 224  static REG8 IOINPCALL np2sysp_i7ef(UINT | Line 259  static REG8 IOINPCALL np2sysp_i7ef(UINT | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
 |  | #if defined(NP2APPDEV) | 
 |  | static void IOOUTCALL np2sysp_o0e9(UINT port, REG8 dat) { | 
 |  |  | 
 |  | APPDEVOUT(dat); | 
 |  | (void)port; | 
 |  | } | 
 |  |  | 
 |  | static REG8 IOINPCALL np2sysp_i0e9(UINT port) { | 
 |  |  | 
 |  | return((UINT8)port); | 
 |  | } | 
 |  | #endif | 
 |  |  | 
 |  |  | 
 | // ---- I/F | // ---- I/F | 
 |  |  | 
| void np2sysp_reset(void) { | void np2sysp_reset(const NP2CFG *pConfig) { | 
 |  |  | 
 | ZeroMemory(&np2sysp, sizeof(np2sysp)); | ZeroMemory(&np2sysp, sizeof(np2sysp)); | 
 |  |  | 
 |  | (void)pConfig; | 
 | } | } | 
 |  |  | 
 | void np2sysp_bind(void) { | void np2sysp_bind(void) { | 
| Line 238  void np2sysp_bind(void) { | Line 288  void np2sysp_bind(void) { | 
 | iocore_attachout(0x07ef, np2sysp_o7ef); | iocore_attachout(0x07ef, np2sysp_o7ef); | 
 | iocore_attachinp(0x07ef, np2sysp_i7ed); | iocore_attachinp(0x07ef, np2sysp_i7ed); | 
 | iocore_attachinp(0x07ef, np2sysp_i7ef); | iocore_attachinp(0x07ef, np2sysp_i7ef); | 
 |  |  | 
 |  | #if defined(NP2APPDEV) | 
 |  | iocore_attachout(0x00e9, np2sysp_o0e9); | 
 |  | iocore_attachinp(0x00e9, np2sysp_i0e9); | 
 |  | #endif | 
 | } | } | 
 |  |  |