| version 1.20, 2008/03/22 04:03:07 | version 1.25, 2012/02/05 06:31:44 | 
| Line 1 | Line 1 | 
 | /*      $Id$    */ |  | 
 |  |  | 
 | /* | /* | 
 | * Copyright (c) 2003 NONAKA Kimihiro | * Copyright (c) 2003 NONAKA Kimihiro | 
 | * All rights reserved. | * All rights reserved. | 
| Line 35 | Line 33 | 
 | /*------------------------------------------------------------------------------ | /*------------------------------------------------------------------------------ | 
 | * JMPfar_pm | * JMPfar_pm | 
 | */ | */ | 
| static void JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); | static void CPUCALL 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 CPUCALL JMPfar_pm_call_gate(const selector_t *callgate_sel); | 
| static void JMPfar_pm_task_gate(selector_t *taskgate_sel); | static void CPUCALL JMPfar_pm_task_gate(selector_t *taskgate_sel); | 
| static void JMPfar_pm_tss(selector_t *tss_sel); | static void CPUCALL JMPfar_pm_tss(selector_t *tss_sel); | 
 |  |  | 
| void | void CPUCALL | 
 | JMPfar_pm(UINT16 selector, UINT32 new_ip) | JMPfar_pm(UINT16 selector, UINT32 new_ip) | 
 | { | { | 
 | selector_t jmp_sel; | selector_t jmp_sel; | 
| Line 103  JMPfar_pm(UINT16 selector, UINT32 new_ip | Line 101  JMPfar_pm(UINT16 selector, UINT32 new_ip | 
 | /*--- | /*--- | 
 | * JMPfar: code segment | * JMPfar: code segment | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) | JMPfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) | 
 | { | { | 
 |  |  | 
| Line 112  JMPfar_pm_code_segment(const selector_t | Line 110  JMPfar_pm_code_segment(const selector_t | 
 | /* check privilege level */ | /* check privilege level */ | 
 | if (!SEG_IS_CONFORMING_CODE(&cs_sel->desc)) { | if (!SEG_IS_CONFORMING_CODE(&cs_sel->desc)) { | 
 | VERBOSE(("JMPfar_pm: NON-CONFORMING-CODE-SEGMENT")); | VERBOSE(("JMPfar_pm: NON-CONFORMING-CODE-SEGMENT")); | 
| /* イシエャ p.119 4.8.1.1. */ | /* 荳句キサ p.119 4.8.1.1. */ | 
 | if (cs_sel->rpl > CPU_STAT_CPL) { | if (cs_sel->rpl > CPU_STAT_CPL) { | 
 | VERBOSE(("JMPfar_pm: RPL(%d) > CPL(%d)", cs_sel->rpl, CPU_STAT_CPL)); | VERBOSE(("JMPfar_pm: RPL(%d) > CPL(%d)", cs_sel->rpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | 
| Line 123  JMPfar_pm_code_segment(const selector_t | Line 121  JMPfar_pm_code_segment(const selector_t | 
 | } | } | 
 | } else { | } else { | 
 | VERBOSE(("JMPfar_pm: CONFORMING-CODE-SEGMENT")); | VERBOSE(("JMPfar_pm: CONFORMING-CODE-SEGMENT")); | 
| /* イシエャ p.120 4.8.1.2. */ | /* 荳句キサ p.120 4.8.1.2. */ | 
 | if (cs_sel->desc.dpl > CPU_STAT_CPL) { | if (cs_sel->desc.dpl > CPU_STAT_CPL) { | 
 | VERBOSE(("JMPfar_pm: DPL(%d) > CPL(%d)", cs_sel->desc.dpl, CPU_STAT_CPL)); | VERBOSE(("JMPfar_pm: DPL(%d) > CPL(%d)", cs_sel->desc.dpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | 
| Line 149  JMPfar_pm_code_segment(const selector_t | Line 147  JMPfar_pm_code_segment(const selector_t | 
 | /*--- | /*--- | 
 | * JMPfar: call gate | * JMPfar: call gate | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | JMPfar_pm_call_gate(const selector_t *callgate_sel) | JMPfar_pm_call_gate(const selector_t *callgate_sel) | 
 | { | { | 
 | selector_t cs_sel; | selector_t cs_sel; | 
| Line 192  JMPfar_pm_call_gate(const selector_t *ca | Line 190  JMPfar_pm_call_gate(const selector_t *ca | 
 |  |  | 
 | /* check privilege level */ | /* check privilege level */ | 
 | if (!SEG_IS_CONFORMING_CODE(&cs_sel.desc)) { | if (!SEG_IS_CONFORMING_CODE(&cs_sel.desc)) { | 
| /* イシエャ p.119 4.8.1.1. */ | /* 荳句キサ p.119 4.8.1.1. */ | 
 | if (cs_sel.rpl > CPU_STAT_CPL) { | if (cs_sel.rpl > CPU_STAT_CPL) { | 
 | VERBOSE(("JMPfar_pm: RPL(%d) > CPL(%d)", cs_sel.rpl, CPU_STAT_CPL)); | VERBOSE(("JMPfar_pm: RPL(%d) > CPL(%d)", cs_sel.rpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | 
| Line 202  JMPfar_pm_call_gate(const selector_t *ca | Line 200  JMPfar_pm_call_gate(const selector_t *ca | 
 | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | 
 | } | } | 
 | } else { | } else { | 
| /* イシエャ p.120 4.8.1.2. */ | /* 荳句キサ p.120 4.8.1.2. */ | 
 | if (cs_sel.desc.dpl > CPU_STAT_CPL) { | if (cs_sel.desc.dpl > CPU_STAT_CPL) { | 
 | VERBOSE(("JMPfar_pm: DPL(%d) > CPL(%d)", cs_sel.desc.dpl, CPU_STAT_CPL)); | VERBOSE(("JMPfar_pm: DPL(%d) > CPL(%d)", cs_sel.desc.dpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | 
| Line 228  JMPfar_pm_call_gate(const selector_t *ca | Line 226  JMPfar_pm_call_gate(const selector_t *ca | 
 | /*--- | /*--- | 
 | * JMPfar: task gate | * JMPfar: task gate | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | JMPfar_pm_task_gate(selector_t *taskgate_sel) | JMPfar_pm_task_gate(selector_t *taskgate_sel) | 
 | { | { | 
 | selector_t tss_sel; | selector_t tss_sel; | 
| Line 282  JMPfar_pm_task_gate(selector_t *taskgate | Line 280  JMPfar_pm_task_gate(selector_t *taskgate | 
 | } | } | 
 |  |  | 
 | task_switch(&tss_sel, TASK_SWITCH_JMP); | task_switch(&tss_sel, TASK_SWITCH_JMP); | 
 |  |  | 
 |  | /* out of range */ | 
 |  | if (CPU_EIP > CPU_STAT_CS_LIMIT) { | 
 |  | VERBOSE(("JMPfar_pm: new_ip is out of range. new_ip = %08x, limit = %08x", CPU_EIP, CPU_STAT_CS_LIMIT)); | 
 |  | EXCEPTION(GP_EXCEPTION, 0); | 
 |  | } | 
 | } | } | 
 |  |  | 
 | /*--- | /*--- | 
 | * JMPfar: TSS | * JMPfar: TSS | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | JMPfar_pm_tss(selector_t *tss_sel) | JMPfar_pm_tss(selector_t *tss_sel) | 
 | { | { | 
 |  |  | 
| Line 310  JMPfar_pm_tss(selector_t *tss_sel) | Line 314  JMPfar_pm_tss(selector_t *tss_sel) | 
 | } | } | 
 |  |  | 
 | task_switch(tss_sel, TASK_SWITCH_JMP); | task_switch(tss_sel, TASK_SWITCH_JMP); | 
 |  |  | 
 |  | /* out of range */ | 
 |  | if (CPU_EIP > CPU_STAT_CS_LIMIT) { | 
 |  | VERBOSE(("JMPfar_pm: new_ip is out of range. new_ip = %08x, limit = %08x", CPU_EIP, CPU_STAT_CS_LIMIT)); | 
 |  | EXCEPTION(GP_EXCEPTION, 0); | 
 |  | } | 
 | } | } | 
 |  |  | 
 |  |  | 
 | /*------------------------------------------------------------------------------ | /*------------------------------------------------------------------------------ | 
 | * CALLfar_pm | * CALLfar_pm | 
 | */ | */ | 
| static void CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip); | static void CPUCALL 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 CPUCALL CALLfar_pm_call_gate(const selector_t *callgate_sel); | 
| static void CALLfar_pm_task_gate(selector_t *taskgate_sel); | static void CPUCALL CALLfar_pm_task_gate(selector_t *taskgate_sel); | 
| static void CALLfar_pm_tss(selector_t *tss_sel); | static void CPUCALL CALLfar_pm_tss(selector_t *tss_sel); | 
 |  |  | 
| void | void CPUCALL | 
 | CALLfar_pm(UINT16 selector, UINT32 new_ip) | CALLfar_pm(UINT16 selector, UINT32 new_ip) | 
 | { | { | 
 | selector_t call_sel; | selector_t call_sel; | 
| Line 384  CALLfar_pm(UINT16 selector, UINT32 new_i | Line 394  CALLfar_pm(UINT16 selector, UINT32 new_i | 
 | /*--- | /*--- | 
 | * CALLfar_pm: code segment | * CALLfar_pm: code segment | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) | CALLfar_pm_code_segment(const selector_t *cs_sel, UINT32 new_ip) | 
 | { | { | 
 | UINT32 sp; | UINT32 sp; | 
| Line 394  CALLfar_pm_code_segment(const selector_t | Line 404  CALLfar_pm_code_segment(const selector_t | 
 | /* check privilege level */ | /* check privilege level */ | 
 | if (!SEG_IS_CONFORMING_CODE(&cs_sel->desc)) { | if (!SEG_IS_CONFORMING_CODE(&cs_sel->desc)) { | 
 | VERBOSE(("CALLfar_pm: NON-CONFORMING-CODE-SEGMENT")); | VERBOSE(("CALLfar_pm: NON-CONFORMING-CODE-SEGMENT")); | 
| /* イシエャ p.119 4.8.1.1. */ | /* 荳句キサ p.119 4.8.1.1. */ | 
 | if (cs_sel->rpl > CPU_STAT_CPL) { | if (cs_sel->rpl > CPU_STAT_CPL) { | 
 | VERBOSE(("CALLfar_pm: RPL(%d) > CPL(%d)", cs_sel->rpl, CPU_STAT_CPL)); | VERBOSE(("CALLfar_pm: RPL(%d) > CPL(%d)", cs_sel->rpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | 
| Line 405  CALLfar_pm_code_segment(const selector_t | Line 415  CALLfar_pm_code_segment(const selector_t | 
 | } | } | 
 | } else { | } else { | 
 | VERBOSE(("CALLfar_pm: CONFORMING-CODE-SEGMENT")); | VERBOSE(("CALLfar_pm: CONFORMING-CODE-SEGMENT")); | 
| /* イシエャ p.120 4.8.1.2. */ | /* 荳句キサ p.120 4.8.1.2. */ | 
 | if (cs_sel->desc.dpl > CPU_STAT_CPL) { | if (cs_sel->desc.dpl > CPU_STAT_CPL) { | 
 | VERBOSE(("CALLfar_pm: DPL(%d) > CPL(%d)", cs_sel->desc.dpl, CPU_STAT_CPL)); | VERBOSE(("CALLfar_pm: DPL(%d) > CPL(%d)", cs_sel->desc.dpl, CPU_STAT_CPL)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | EXCEPTION(GP_EXCEPTION, cs_sel->idx); | 
| Line 454  CALLfar_pm_code_segment(const selector_t | Line 464  CALLfar_pm_code_segment(const selector_t | 
 | /*--- | /*--- | 
 | * CALLfar_pm: call gate | * CALLfar_pm: call gate | 
 | */ | */ | 
| static void CALLfar_pm_call_gate_same_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 CALLfar_pm_call_gate_more_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) | CALLfar_pm_call_gate(const selector_t *callgate_sel) | 
 | { | { | 
 | selector_t cs_sel; | selector_t cs_sel; | 
| Line 526  CALLfar_pm_call_gate(const selector_t *c | Line 536  CALLfar_pm_call_gate(const selector_t *c | 
 | /*--- | /*--- | 
 | * CALLfar_pm: call gate (SAME-PRIVILEGE) | * 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) | CALLfar_pm_call_gate_same_privilege(const selector_t *callgate_sel, selector_t *cs_sel) | 
 | { | { | 
 | UINT32 sp; | UINT32 sp; | 
| Line 557  CALLfar_pm_call_gate_same_privilege(cons | Line 567  CALLfar_pm_call_gate_same_privilege(cons | 
 | /*--- | /*--- | 
 | * CALLfar_pm: call gate (MORE-PRIVILEGE) | * 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) | CALLfar_pm_call_gate_more_privilege(const selector_t *callgate_sel, selector_t *cs_sel) | 
 | { | { | 
 | UINT32 param[32];       /* copy param */ | UINT32 param[32];       /* copy param */ | 
| Line 700  CALLfar_pm_call_gate_more_privilege(cons | Line 710  CALLfar_pm_call_gate_more_privilege(cons | 
 | /*--- | /*--- | 
 | * CALLfar_pm: task gate | * CALLfar_pm: task gate | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | CALLfar_pm_task_gate(selector_t *taskgate_sel) | CALLfar_pm_task_gate(selector_t *taskgate_sel) | 
 | { | { | 
 | selector_t tss_sel; | selector_t tss_sel; | 
| Line 754  CALLfar_pm_task_gate(selector_t *taskgat | Line 764  CALLfar_pm_task_gate(selector_t *taskgat | 
 | } | } | 
 |  |  | 
 | task_switch(&tss_sel, TASK_SWITCH_CALL); | task_switch(&tss_sel, TASK_SWITCH_CALL); | 
 |  |  | 
 |  | /* out of range */ | 
 |  | if (CPU_EIP > CPU_STAT_CS_LIMIT) { | 
 |  | VERBOSE(("JMPfar_pm: new_ip is out of range. new_ip = %08x, limit = %08x", CPU_EIP, CPU_STAT_CS_LIMIT)); | 
 |  | EXCEPTION(GP_EXCEPTION, 0); | 
 |  | } | 
 | } | } | 
 |  |  | 
 | /*--- | /*--- | 
 | * CALLfar_pm: TSS | * CALLfar_pm: TSS | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | CALLfar_pm_tss(selector_t *tss_sel) | CALLfar_pm_tss(selector_t *tss_sel) | 
 | { | { | 
 |  |  | 
| Line 782  CALLfar_pm_tss(selector_t *tss_sel) | Line 798  CALLfar_pm_tss(selector_t *tss_sel) | 
 | } | } | 
 |  |  | 
 | task_switch(tss_sel, TASK_SWITCH_CALL); | task_switch(tss_sel, TASK_SWITCH_CALL); | 
 |  |  | 
 |  | /* out of range */ | 
 |  | if (CPU_EIP > CPU_STAT_CS_LIMIT) { | 
 |  | VERBOSE(("JMPfar_pm: new_ip is out of range. new_ip = %08x, limit = %08x", CPU_EIP, CPU_STAT_CS_LIMIT)); | 
 |  | EXCEPTION(GP_EXCEPTION, 0); | 
 |  | } | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 789  CALLfar_pm_tss(selector_t *tss_sel) | Line 811  CALLfar_pm_tss(selector_t *tss_sel) | 
 | * RETfar_pm | * RETfar_pm | 
 | */ | */ | 
 |  |  | 
| void | void CPUCALL | 
 | RETfar_pm(UINT nbytes) | RETfar_pm(UINT nbytes) | 
 | { | { | 
 | selector_t cs_sel, ss_sel, temp_sel; | selector_t cs_sel, ss_sel, temp_sel; | 
| Line 819  RETfar_pm(UINT nbytes) | Line 841  RETfar_pm(UINT nbytes) | 
 |  |  | 
 | rv = parse_selector(&cs_sel, new_cs); | rv = parse_selector(&cs_sel, new_cs); | 
 | if (rv < 0) { | if (rv < 0) { | 
| VERBOSE(("RETfar_pm: parse_selector (selector = %04x, rv = %d, %s)", cs_sel.selector, rv)); | VERBOSE(("RETfar_pm: parse_selector (selector = %04x, rv = %d)", cs_sel.selector, rv)); | 
 | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | EXCEPTION(GP_EXCEPTION, cs_sel.idx); | 
 | } | } | 
 |  |  | 
| Line 951  RETfar_pm(UINT nbytes) | Line 973  RETfar_pm(UINT nbytes) | 
 | && (CPU_STAT_CPL > sdp->dpl)) { | && (CPU_STAT_CPL > sdp->dpl)) { | 
 | /* current segment descriptor is invalid */ | /* current segment descriptor is invalid */ | 
 | CPU_REGS_SREG(i) = 0; | CPU_REGS_SREG(i) = 0; | 
| segdesc_clear(sdp); | memset(sdp, 0, sizeof(*sdp)); | 
 | continue; | continue; | 
 | } | } | 
 |  |  | 
| Line 960  RETfar_pm(UINT nbytes) | Line 982  RETfar_pm(UINT nbytes) | 
 | if (rv < 0) { | if (rv < 0) { | 
 | /* segment register is invalid */ | /* segment register is invalid */ | 
 | CPU_REGS_SREG(i) = 0; | CPU_REGS_SREG(i) = 0; | 
| segdesc_clear(sdp); | memset(sdp, 0, sizeof(*sdp)); | 
 | continue; | continue; | 
 | } | } | 
 |  |  | 
| Line 977  RETfar_pm(UINT nbytes) | Line 999  RETfar_pm(UINT nbytes) | 
 | && (CPU_STAT_CPL > temp_sel.desc.dpl))) { | && (CPU_STAT_CPL > temp_sel.desc.dpl))) { | 
 | /* segment descriptor is invalid */ | /* segment descriptor is invalid */ | 
 | CPU_REGS_SREG(i) = 0; | CPU_REGS_SREG(i) = 0; | 
| segdesc_clear(sdp); | memset(sdp, 0, sizeof(*sdp)); | 
 | } | } | 
 | } | } | 
 | } | } | 
| Line 990  RETfar_pm(UINT nbytes) | Line 1012  RETfar_pm(UINT 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(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 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_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 CPUCALL 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 CPUCALL 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_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags); | 
 |  |  | 
 | void | void | 
 | IRET_pm(void) | IRET_pm(void) | 
| Line 1091  IRET_pm_nested_task(void) | Line 1113  IRET_pm_nested_task(void) | 
 | } | } | 
 |  |  | 
 | task_switch(&tss_sel, TASK_SWITCH_IRET); | task_switch(&tss_sel, TASK_SWITCH_IRET); | 
 |  |  | 
 |  | /* out of range */ | 
 |  | if (CPU_EIP > CPU_STAT_CS_LIMIT) { | 
 |  | VERBOSE(("JMPfar_pm: new_ip is out of range. new_ip = %08x, limit = %08x", CPU_EIP, CPU_STAT_CS_LIMIT)); | 
 |  | EXCEPTION(GP_EXCEPTION, 0); | 
 |  | } | 
 | } | } | 
 |  |  | 
 | /*--- | /*--- | 
 | * IRET_pm: PROTECTED-MODE-RETURN | * IRET_pm: PROTECTED-MODE-RETURN | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) | IRET_pm_protected_mode_return(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) | 
 | { | { | 
 | selector_t cs_sel; | selector_t cs_sel; | 
| Line 1147  IRET_pm_protected_mode_return(UINT16 new | Line 1175  IRET_pm_protected_mode_return(UINT16 new | 
 | /*--- | /*--- | 
 | * IRET_pm: SAME-PRIVILEGE | * 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) | IRET_pm_protected_mode_return_same_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) | 
 | { | { | 
 | UINT32 mask; | UINT32 mask; | 
| Line 1195  IRET_pm_protected_mode_return_same_privi | Line 1223  IRET_pm_protected_mode_return_same_privi | 
 | /*--- | /*--- | 
 | * IRET_pm: OUTER-PRIVILEGE | * 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) | IRET_pm_protected_mode_return_outer_privilege(const selector_t *cs_sel, UINT32 new_ip, UINT32 new_flags) | 
 | { | { | 
 | descriptor_t *sdp; | descriptor_t *sdp; | 
| Line 1306  IRET_pm_protected_mode_return_outer_priv | Line 1334  IRET_pm_protected_mode_return_outer_priv | 
 | && (sdp->dpl < CPU_STAT_CPL)) { | && (sdp->dpl < CPU_STAT_CPL)) { | 
 | /* segment register is invalid */ | /* segment register is invalid */ | 
 | CPU_REGS_SREG(i) = 0; | CPU_REGS_SREG(i) = 0; | 
| segdesc_clear(sdp); | memset(sdp, 0, sizeof(*sdp)); | 
 | } | } | 
 | } | } | 
 | } | } | 
| Line 1315  IRET_pm_protected_mode_return_outer_priv | Line 1343  IRET_pm_protected_mode_return_outer_priv | 
 | /*--- | /*--- | 
 | * IRET_pm: new_flags & VM_FLAG | * 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) | IRET_pm_return_to_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) | 
 | { | { | 
 | UINT16 segsel[CPU_SEGREG_NUM]; | UINT16 segsel[CPU_SEGREG_NUM]; | 
| Line 1362  IRET_pm_return_to_vm86(UINT16 new_cs, UI | Line 1390  IRET_pm_return_to_vm86(UINT16 new_cs, UI | 
 | /*--- | /*--- | 
 | * IRET_pm: VM_FLAG | * IRET_pm: VM_FLAG | 
 | */ | */ | 
| static void | static void CPUCALL | 
 | IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) | IRET_pm_return_from_vm86(UINT16 new_cs, UINT32 new_ip, UINT32 new_flags) | 
 | { | { | 
 | UINT stacksize; | UINT stacksize; |