|
|
| version 1.14, 2004/02/19 03:04:01 | version 1.15, 2004/02/20 16:09:04 |
|---|---|
| Line 37 | Line 37 |
| /*------------------------------------------------------------------------------ | /*------------------------------------------------------------------------------ |
| * JMPfar_pm | * JMPfar_pm |
| */ | */ |
| static void JMPfar_pm_code_segment(selector_t *jmp_sel, DWORD new_ip); | static void JMPfar_pm_code_segment(selector_t *cs_sel, UINT32 new_ip); |
| static void JMPfar_pm_call_gate(selector_t *jmp_sel); | static void JMPfar_pm_call_gate(selector_t *callgate_sel); |
| static void JMPfar_pm_task_gate(selector_t *jmp_sel); | static void JMPfar_pm_task_gate(selector_t *taskgate_sel); |
| static void JMPfar_pm_tss(selector_t *jmp_sel); | static void JMPfar_pm_tss(selector_t *tss_sel); |
| void | void |
| JMPfar_pm(WORD selector, DWORD new_ip) | JMPfar_pm(UINT16 selector, UINT32 new_ip) |
| { | { |
| selector_t jmp_sel; | selector_t jmp_sel; |
| int rv; | int rv; |
| Line 106 JMPfar_pm(WORD selector, DWORD new_ip) | Line 106 JMPfar_pm(WORD selector, DWORD new_ip) |
| * JMPfar: code segment | * JMPfar: code segment |
| */ | */ |
| static void | static void |
| JMPfar_pm_code_segment(selector_t *cs_sel, DWORD new_ip) | JMPfar_pm_code_segment(selector_t *cs_sel, UINT32 new_ip) |
| { | { |
| VERBOSE(("JMPfar_pm: CODE-SEGMENT")); | VERBOSE(("JMPfar_pm: CODE-SEGMENT")); |
| Line 318 JMPfar_pm_tss(selector_t *tss_sel) | Line 318 JMPfar_pm_tss(selector_t *tss_sel) |
| /*------------------------------------------------------------------------------ | /*------------------------------------------------------------------------------ |
| * CALLfar_pm | * CALLfar_pm |
| */ | */ |
| static void CALLfar_pm_code_segment(selector_t *call_sel, DWORD new_ip); | static void CALLfar_pm_code_segment(selector_t *cs_sel, UINT32 new_ip); |
| static void CALLfar_pm_call_gate(selector_t *call_sel); | static void CALLfar_pm_call_gate(selector_t *callgate_sel); |
| static void CALLfar_pm_task_gate(selector_t *call_sel); | static void CALLfar_pm_task_gate(selector_t *taskgate_sel); |
| static void CALLfar_pm_tss(selector_t *call_sel); | static void CALLfar_pm_tss(selector_t *tss_sel); |
| void | void |
| CALLfar_pm(WORD selector, DWORD new_ip) | CALLfar_pm(UINT16 selector, UINT32 new_ip) |
| { | { |
| selector_t call_sel; | selector_t call_sel; |
| int rv; | int rv; |
| Line 387 CALLfar_pm(WORD selector, DWORD new_ip) | Line 387 CALLfar_pm(WORD selector, DWORD new_ip) |
| * CALLfar_pm: code segment | * CALLfar_pm: code segment |
| */ | */ |
| static void | static void |
| CALLfar_pm_code_segment(selector_t *cs_sel, DWORD new_ip) | CALLfar_pm_code_segment(selector_t *cs_sel, UINT32 new_ip) |
| { | { |
| DWORD sp; | UINT32 sp; |
| VERBOSE(("CALLfar_pm: CODE-SEGMENT")); | VERBOSE(("CALLfar_pm: CODE-SEGMENT")); |
| Line 531 CALLfar_pm_call_gate(selector_t *callgat | Line 531 CALLfar_pm_call_gate(selector_t *callgat |
| static void | static void |
| CALLfar_pm_call_gate_same_privilege(selector_t *callgate_sel, selector_t *cs_sel) | CALLfar_pm_call_gate_same_privilege(selector_t *callgate_sel, selector_t *cs_sel) |
| { | { |
| DWORD sp; | UINT32 sp; |
| VERBOSE(("CALLfar_pm: SAME-PRIVILEGE")); | VERBOSE(("CALLfar_pm: SAME-PRIVILEGE")); |
| Line 566 CALLfar_pm_call_gate_same_privilege(sele | Line 566 CALLfar_pm_call_gate_same_privilege(sele |
| static void | static void |
| CALLfar_pm_call_gate_more_privilege(selector_t *callgate_sel, selector_t *cs_sel) | CALLfar_pm_call_gate_more_privilege(selector_t *callgate_sel, selector_t *cs_sel) |
| { | { |
| DWORD param[32]; /* copy param */ | UINT32 param[32]; /* copy param */ |
| selector_t ss_sel; | selector_t ss_sel; |
| DWORD old_eip, old_esp; | UINT32 old_eip, old_esp; |
| DWORD new_esp; | UINT32 new_esp; |
| WORD old_cs, old_ss; | UINT16 old_cs, old_ss; |
| WORD new_ss; | UINT16 new_ss; |
| int param_count; | int param_count; |
| int i; | int i; |
| int rv; | int rv; |
| Line 643 CALLfar_pm_call_gate_more_privilege(sele | Line 643 CALLfar_pm_call_gate_more_privilege(sele |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP = new_esp; | CPU_ESP = new_esp; |
| } else { | } else { |
| CPU_SP = (WORD)new_esp; | CPU_SP = (UINT16)new_esp; |
| } | } |
| load_cs(cs_sel->selector, &cs_sel->desc, cs_sel->desc.dpl); | load_cs(cs_sel->selector, &cs_sel->desc, cs_sel->desc.dpl); |
| Line 673 CALLfar_pm_call_gate_more_privilege(sele | Line 673 CALLfar_pm_call_gate_more_privilege(sele |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP = new_esp; | CPU_ESP = new_esp; |
| } else { | } else { |
| CPU_SP = (WORD)new_esp; | CPU_SP = (UINT16)new_esp; |
| } | } |
| load_cs(cs_sel->selector, &cs_sel->desc, cs_sel->desc.dpl); | load_cs(cs_sel->selector, &cs_sel->desc, cs_sel->desc.dpl); |
| Line 786 CALLfar_pm_tss(selector_t *tss_sel) | Line 786 CALLfar_pm_tss(selector_t *tss_sel) |
| */ | */ |
| void | void |
| RETfar_pm(DWORD nbytes) | RETfar_pm(UINT nbytes) |
| { | { |
| selector_t cs_sel, ss_sel, temp_sel; | selector_t cs_sel, ss_sel, temp_sel; |
| DWORD sp; | UINT32 sp; |
| DWORD new_ip, new_sp; | UINT32 new_ip, new_sp; |
| WORD new_cs, new_ss; | UINT16 new_cs, new_ss; |
| int rv; | int rv; |
| int i; | int i; |
| Line 863 RETfar_pm(DWORD nbytes) | Line 863 RETfar_pm(DWORD nbytes) |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP += nbytes; | CPU_ESP += nbytes; |
| } else { | } else { |
| CPU_SP += (WORD)nbytes; | CPU_SP += (UINT16)nbytes; |
| } | } |
| load_cs(cs_sel.selector, &cs_sel.desc, CPU_STAT_CPL); | load_cs(cs_sel.selector, &cs_sel.desc, CPU_STAT_CPL); |
| Line 933 RETfar_pm(DWORD nbytes) | Line 933 RETfar_pm(DWORD nbytes) |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP = new_sp + nbytes; | CPU_ESP = new_sp + nbytes; |
| } else { | } else { |
| CPU_SP = (WORD)(new_sp + nbytes); | CPU_SP = (UINT16)(new_sp + nbytes); |
| } | } |
| /* check segment register */ | /* check segment register */ |
| Line 989 RETfar_pm(DWORD nbytes) | Line 989 RETfar_pm(DWORD nbytes) |
| * IRET_pm | * IRET_pm |
| */ | */ |
| static void IRET_pm_nested_task(void); | static void IRET_pm_nested_task(void); |
| static void IRET_pm_protected_mode_return(DWORD new_cs, DWORD new_ip, DWORD new_flags); | 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(selector_t *cs_sel, DWORD new_ip, DWORD new_flags); | static void IRET_pm_protected_mode_return_same_privilege(selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); |
| static void IRET_pm_protected_mode_return_outer_privilege(selector_t *cs_sel, DWORD new_ip, DWORD new_flags); | static void IRET_pm_protected_mode_return_outer_privilege(selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags); |
| static void IRET_pm_return_to_vm86(DWORD new_cs, DWORD new_ip, DWORD 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(DWORD new_cs, DWORD new_ip, DWORD new_flags); | static void IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); |
| void | void |
| IRET_pm(void) | IRET_pm(void) |
| { | { |
| DWORD sp; | UINT32 sp; |
| DWORD new_ip, new_flags; | UINT32 new_ip, new_flags; |
| WORD new_cs; | UINT16 new_cs; |
| // int rv; | |
| VERBOSE(("IRET_pm: old EIP = %04x:%08x, ESP = %04x:%08x", CPU_CS, CPU_PREV_EIP, CPU_SS, CPU_ESP)); | VERBOSE(("IRET_pm: old EIP = %04x:%08x, ESP = %04x:%08x", CPU_CS, CPU_PREV_EIP, CPU_SS, CPU_ESP)); |
| Line 1050 static void | Line 1049 static void |
| IRET_pm_nested_task(void) | IRET_pm_nested_task(void) |
| { | { |
| selector_t tss_sel; | selector_t tss_sel; |
| UINT16 new_tss; | |
| int rv; | int rv; |
| WORD new_tss; | |
| VERBOSE(("IRET_pm: TASK-RETURN: PE=1, VM=0, NT=1")); | VERBOSE(("IRET_pm: TASK-RETURN: PE=1, VM=0, NT=1")); |
| Line 1097 IRET_pm_nested_task(void) | Line 1096 IRET_pm_nested_task(void) |
| * IRET_pm: PROTECTED-MODE-RETURN | * IRET_pm: PROTECTED-MODE-RETURN |
| */ | */ |
| static void | static void |
| IRET_pm_protected_mode_return(DWORD new_cs, DWORD new_ip, DWORD new_flags) | IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) |
| { | { |
| selector_t cs_sel; | selector_t cs_sel; |
| int rv; | int rv; |
| Line 1105 IRET_pm_protected_mode_return(DWORD new_ | Line 1104 IRET_pm_protected_mode_return(DWORD new_ |
| /* PROTECTED-MODE-RETURN */ | /* PROTECTED-MODE-RETURN */ |
| VERBOSE(("IRET_pm: PE=1, VM=0 in flags image")); | VERBOSE(("IRET_pm: PE=1, VM=0 in flags image")); |
| rv = parse_selector(&cs_sel, (WORD)new_cs); | rv = parse_selector(&cs_sel, new_cs); |
| if (rv < 0) { | if (rv < 0) { |
| VERBOSE(("IRET_pm: parse_selector (selector = %04x, rv = %d)", cs_sel.selector, rv)); | VERBOSE(("IRET_pm: parse_selector (selector = %04x, rv = %d)", cs_sel.selector, rv)); |
| EXCEPTION(GP_EXCEPTION, cs_sel.idx); | EXCEPTION(GP_EXCEPTION, cs_sel.idx); |
| Line 1148 IRET_pm_protected_mode_return(DWORD new_ | Line 1147 IRET_pm_protected_mode_return(DWORD new_ |
| * IRET_pm: SAME-PRIVILEGE | * IRET_pm: SAME-PRIVILEGE |
| */ | */ |
| static void | static void |
| IRET_pm_protected_mode_return_same_privilege(selector_t *cs_sel, DWORD new_ip, DWORD new_flags) | IRET_pm_protected_mode_return_same_privilege(selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) |
| { | { |
| DWORD mask; | UINT32 mask; |
| DWORD stacksize; | UINT stacksize; |
| VERBOSE(("IRET_pm: RETURN-TO-SAME-PRIVILEGE-LEVEL")); | VERBOSE(("IRET_pm: RETURN-TO-SAME-PRIVILEGE-LEVEL")); |
| Line 1187 IRET_pm_protected_mode_return_same_privi | Line 1186 IRET_pm_protected_mode_return_same_privi |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP += stacksize; | CPU_ESP += stacksize; |
| } else { | } else { |
| CPU_SP += (WORD)stacksize; | CPU_SP += (UINT16)stacksize; |
| } | } |
| } | } |
| Line 1195 IRET_pm_protected_mode_return_same_privi | Line 1194 IRET_pm_protected_mode_return_same_privi |
| * IRET_pm: OUTER-PRIVILEGE | * IRET_pm: OUTER-PRIVILEGE |
| */ | */ |
| static void | static void |
| IRET_pm_protected_mode_return_outer_privilege(selector_t *cs_sel, DWORD new_ip, DWORD new_flags) | IRET_pm_protected_mode_return_outer_privilege(selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) |
| { | { |
| descriptor_t *dp; | descriptor_t *dp; |
| selector_t ss_sel; | selector_t ss_sel; |
| DWORD mask; | UINT32 mask; |
| DWORD sp; | UINT32 sp; |
| DWORD new_sp; | UINT32 new_sp; |
| WORD new_ss; | UINT16 new_ss; |
| int rv; | int rv; |
| int i; | int i; |
| Line 1288 IRET_pm_protected_mode_return_outer_priv | Line 1287 IRET_pm_protected_mode_return_outer_priv |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP = new_sp; | CPU_ESP = new_sp; |
| } else { | } else { |
| CPU_SP = (WORD)new_sp; | CPU_SP = (UINT16)new_sp; |
| } | } |
| /* check segment register */ | /* check segment register */ |
| Line 1300 IRET_pm_protected_mode_return_outer_priv | Line 1299 IRET_pm_protected_mode_return_outer_priv |
| /* segment register is invalid */ | /* segment register is invalid */ |
| CPU_REGS_SREG(i) = 0; | CPU_REGS_SREG(i) = 0; |
| CPU_STAT_SREG_CLEAR(i); | CPU_STAT_SREG_CLEAR(i); |
| continue; | |
| } | } |
| } | } |
| } | } |
| Line 1310 IRET_pm_protected_mode_return_outer_priv | Line 1308 IRET_pm_protected_mode_return_outer_priv |
| * IRET_pm: new_flags & VM_FLAG | * IRET_pm: new_flags & VM_FLAG |
| */ | */ |
| static void | static void |
| IRET_pm_return_to_vm86(DWORD new_cs, DWORD new_ip, DWORD new_flags) | IRET_pm_return_to_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) |
| { | { |
| WORD segsel[CPU_SEGREG_NUM]; | UINT16 segsel[CPU_SEGREG_NUM]; |
| DWORD sp; | UINT32 sp; |
| DWORD new_sp; | UINT32 new_sp; |
| int i; | int i; |
| VERBOSE(("IRET_pm: Interrupt procedure was in virtual-8086 mode: PE=1, VM=1 in flags image")); | VERBOSE(("IRET_pm: Interrupt procedure was in virtual-8086 mode: PE=1, VM=1 in flags image")); |
| Line 1339 IRET_pm_return_to_vm86(DWORD new_cs, DWO | Line 1337 IRET_pm_return_to_vm86(DWORD new_cs, DWO |
| segsel[CPU_DS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 24); | segsel[CPU_DS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 24); |
| segsel[CPU_FS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 28); | segsel[CPU_FS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 28); |
| segsel[CPU_GS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 32); | segsel[CPU_GS_INDEX] = cpu_vmemoryread_w(CPU_SS_INDEX, sp + 32); |
| segsel[CPU_CS_INDEX] = (WORD)new_cs; | segsel[CPU_CS_INDEX] = (UINT16)new_cs; |
| for (i = 0; i < CPU_SEGREG_NUM; i++) { | for (i = 0; i < CPU_SEGREG_NUM; i++) { |
| CPU_REGS_SREG(i) = segsel[i]; | CPU_REGS_SREG(i) = segsel[i]; |
| Line 1360 IRET_pm_return_to_vm86(DWORD new_cs, DWO | Line 1358 IRET_pm_return_to_vm86(DWORD new_cs, DWO |
| * IRET_pm: VM_FLAG | * IRET_pm: VM_FLAG |
| */ | */ |
| static void | static void |
| IRET_pm_return_from_vm86(DWORD new_cs, DWORD new_ip, DWORD new_flags) | IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) |
| { | { |
| DWORD stacksize; | UINT stacksize; |
| VERBOSE(("IRET_pm: virtual-8086 mode: VM=1")); | VERBOSE(("IRET_pm: virtual-8086 mode: VM=1")); |
| Line 1376 IRET_pm_return_from_vm86(DWORD new_cs, D | Line 1374 IRET_pm_return_from_vm86(DWORD new_cs, D |
| if (CPU_STAT_SS32) { | if (CPU_STAT_SS32) { |
| CPU_ESP += stacksize; | CPU_ESP += stacksize; |
| } else { | } else { |
| CPU_SP += (WORD)stacksize; | CPU_SP += (UINT16)stacksize; |
| } | } |
| set_eflags(new_flags, I_FLAG|RF_FLAG); | set_eflags(new_flags, I_FLAG|RF_FLAG); |
| CPU_SET_SEGREG(CPU_CS_INDEX, (WORD)new_cs); | CPU_SET_SEGREG(CPU_CS_INDEX, new_cs); |
| SET_EIP(new_ip); | SET_EIP(new_ip); |
| return; | return; |
| } | } |