--- np2/i386c/ia32/ctrlxfer.c 2011/12/21 18:07:57 1.23 +++ np2/i386c/ia32/ctrlxfer.c 2012/03/02 03:35:05 1.26 @@ -33,12 +33,12 @@ /*------------------------------------------------------------------------------ * JMPfar_pm */ -static void JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); -static void JMPfar_pm_call_gate(const selector_t *callgate_sel); -static void JMPfar_pm_task_gate(selector_t *taskgate_sel); -static void JMPfar_pm_tss(selector_t *tss_sel); +static void CPUCALL JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); +static void CPUCALL JMPfar_pm_call_gate(const selector_t *callgate_sel); +static void CPUCALL JMPfar_pm_task_gate(selector_t *taskgate_sel); +static void CPUCALL JMPfar_pm_tss(selector_t *tss_sel); -void +void CPUCALL JMPfar_pm(UINT16 selector, UINT32 new_ip) { selector_t jmp_sel; @@ -101,7 +101,7 @@ JMPfar_pm(UINT16 selector, UINT32 new_ip /*--- * JMPfar: code segment */ -static void +static void CPUCALL JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) { @@ -147,7 +147,7 @@ JMPfar_pm_code_segment(const selector_t /*--- * JMPfar: call gate */ -static void +static void CPUCALL JMPfar_pm_call_gate(const selector_t *callgate_sel) { selector_t cs_sel; @@ -226,7 +226,7 @@ JMPfar_pm_call_gate(const selector_t *ca /*--- * JMPfar: task gate */ -static void +static void CPUCALL JMPfar_pm_task_gate(selector_t *taskgate_sel) { selector_t tss_sel; @@ -291,7 +291,7 @@ JMPfar_pm_task_gate(selector_t *taskgate /*--- * JMPfar: TSS */ -static void +static void CPUCALL JMPfar_pm_tss(selector_t *tss_sel) { @@ -326,12 +326,12 @@ JMPfar_pm_tss(selector_t *tss_sel) /*------------------------------------------------------------------------------ * CALLfar_pm */ -static void CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); -static void CALLfar_pm_call_gate(const selector_t *callgate_sel); -static void CALLfar_pm_task_gate(selector_t *taskgate_sel); -static void CALLfar_pm_tss(selector_t *tss_sel); +static void CPUCALL CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); +static void CPUCALL CALLfar_pm_call_gate(const selector_t *callgate_sel); +static void CPUCALL CALLfar_pm_task_gate(selector_t *taskgate_sel); +static void CPUCALL CALLfar_pm_tss(selector_t *tss_sel); -void +void CPUCALL CALLfar_pm(UINT16 selector, UINT32 new_ip) { selector_t call_sel; @@ -394,7 +394,7 @@ CALLfar_pm(UINT16 selector, UINT32 new_i /*--- * CALLfar_pm: code segment */ -static void +static void CPUCALL CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) { UINT32 sp; @@ -464,10 +464,10 @@ CALLfar_pm_code_segment(const selector_t /*--- * CALLfar_pm: call gate */ -static void CALLfar_pm_call_gate_same_privilege(const selector_t *call_sel, selector_t *cs_sel); -static void CALLfar_pm_call_gate_more_privilege(const selector_t *call_sel, selector_t *cs_sel); +static void CPUCALL CALLfar_pm_call_gate_same_privilege(const selector_t *call_sel, selector_t *cs_sel); +static void CPUCALL CALLfar_pm_call_gate_more_privilege(const selector_t *call_sel, selector_t *cs_sel); -static void +static void CPUCALL CALLfar_pm_call_gate(const selector_t *callgate_sel) { selector_t cs_sel; @@ -536,7 +536,7 @@ CALLfar_pm_call_gate(const selector_t *c /*--- * CALLfar_pm: call gate (SAME-PRIVILEGE) */ -static void +static void CPUCALL CALLfar_pm_call_gate_same_privilege(const selector_t *callgate_sel, selector_t *cs_sel) { UINT32 sp; @@ -567,7 +567,7 @@ CALLfar_pm_call_gate_same_privilege(cons /*--- * CALLfar_pm: call gate (MORE-PRIVILEGE) */ -static void +static void CPUCALL CALLfar_pm_call_gate_more_privilege(const selector_t *callgate_sel, selector_t *cs_sel) { UINT32 param[32]; /* copy param */ @@ -710,7 +710,7 @@ CALLfar_pm_call_gate_more_privilege(cons /*--- * CALLfar_pm: task gate */ -static void +static void CPUCALL CALLfar_pm_task_gate(selector_t *taskgate_sel) { selector_t tss_sel; @@ -775,7 +775,7 @@ CALLfar_pm_task_gate(selector_t *taskgat /*--- * CALLfar_pm: TSS */ -static void +static void CPUCALL CALLfar_pm_tss(selector_t *tss_sel) { @@ -811,7 +811,7 @@ CALLfar_pm_tss(selector_t *tss_sel) * RETfar_pm */ -void +void CPUCALL RETfar_pm(UINT nbytes) { selector_t cs_sel, ss_sel, temp_sel; @@ -973,7 +973,7 @@ RETfar_pm(UINT nbytes) && (CPU_STAT_CPL > sdp->dpl)) { /* current segment descriptor is invalid */ CPU_REGS_SREG(i) = 0; - segdesc_clear(sdp); + memset(sdp, 0, sizeof(*sdp)); continue; } @@ -982,7 +982,7 @@ RETfar_pm(UINT nbytes) if (rv < 0) { /* segment register is invalid */ CPU_REGS_SREG(i) = 0; - segdesc_clear(sdp); + memset(sdp, 0, sizeof(*sdp)); continue; } @@ -999,7 +999,7 @@ RETfar_pm(UINT nbytes) && (CPU_STAT_CPL > temp_sel.desc.dpl))) { /* segment descriptor is invalid */ CPU_REGS_SREG(i) = 0; - segdesc_clear(sdp); + memset(sdp, 0, sizeof(*sdp)); } } } @@ -1012,11 +1012,11 @@ RETfar_pm(UINT nbytes) * IRET_pm */ static void IRET_pm_nested_task(void); -static void IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); -static void IRET_pm_protected_mode_return_same_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); -static void IRET_pm_protected_mode_return_outer_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); -static void IRET_pm_return_to_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); -static void IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); +static void CPUCALL IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); +static void CPUCALL IRET_pm_protected_mode_return_same_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); +static void CPUCALL IRET_pm_protected_mode_return_outer_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); +static void CPUCALL IRET_pm_return_to_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); +static void CPUCALL IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); void IRET_pm(void) @@ -1124,7 +1124,7 @@ IRET_pm_nested_task(void) /*--- * IRET_pm: PROTECTED-MODE-RETURN */ -static void +static void CPUCALL IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) { selector_t cs_sel; @@ -1175,7 +1175,7 @@ IRET_pm_protected_mode_return(UINT16 new /*--- * IRET_pm: SAME-PRIVILEGE */ -static void +static void CPUCALL IRET_pm_protected_mode_return_same_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) { UINT32 mask; @@ -1223,7 +1223,7 @@ IRET_pm_protected_mode_return_same_privi /*--- * IRET_pm: OUTER-PRIVILEGE */ -static void +static void CPUCALL IRET_pm_protected_mode_return_outer_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) { descriptor_t *sdp; @@ -1334,7 +1334,7 @@ IRET_pm_protected_mode_return_outer_priv && (sdp->dpl < CPU_STAT_CPL)) { /* segment register is invalid */ CPU_REGS_SREG(i) = 0; - segdesc_clear(sdp); + memset(sdp, 0, sizeof(*sdp)); } } } @@ -1343,7 +1343,7 @@ IRET_pm_protected_mode_return_outer_priv /*--- * IRET_pm: new_flags & VM_FLAG */ -static void +static void CPUCALL IRET_pm_return_to_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) { UINT16 segsel[CPU_SEGREG_NUM]; @@ -1364,10 +1364,6 @@ IRET_pm_return_to_vm86(UINT16 new_cs, UI } SS_POP_CHECK(sp, 36); - if (new_ip > 0xffff) { - EXCEPTION(GP_EXCEPTION, 0); - } - new_sp = cpu_vmemoryread_d(CPU_SS_INDEX, sp + 12); segsel[CPU_SS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 16); segsel[CPU_ES_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 20); @@ -1381,7 +1377,7 @@ IRET_pm_return_to_vm86(UINT16 new_cs, UI } CPU_ESP = new_sp; - CPU_EIP = new_ip; + CPU_EIP = new_ip & 0xffff; /* to VM86 mode */ set_eflags(new_flags, IOPL_FLAG|I_FLAG|VM_FLAG|RF_FLAG); @@ -1390,7 +1386,7 @@ IRET_pm_return_to_vm86(UINT16 new_cs, UI /*--- * IRET_pm: VM_FLAG */ -static void +static void CPUCALL IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) { UINT stacksize;