Skip to content

Commit 7a49b26

Browse files
committed
simx86: separate exit_pending from CEmuStat
The flags for exit_pending are now exit_*, and no longer borrow the CEmuStat flags. For the common ones only CeS_INHI was kept (as it needs to keep some state and doesn't always come from a signal or exit from compiled code).
1 parent dcc72b7 commit 7a49b26

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

src/base/emu-i386/simx86/codegen-sim.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
31283128
/* non-segment GPF handled in interpreter */
31293129
assert(!(V86MODE() && IOPL!=3 && !(TheCPU.cr[4] & CR4_VME)));
31303130
if (temp & TF)
3131-
exit_pending_or(CeS_TRAP);
3131+
exit_pending_or(exit_TRAP);
31323132
if (debug_level('e')>1) {
31333133
e_printf("IRET: ret=%04x:%08x\n",TheCPU.cs,TheCPU.eip);
31343134
}
@@ -3165,7 +3165,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
31653165
assert(!(V86MODE() && IOPL!=3 && !(TheCPU.cr[4] & CR4_VME)));
31663166
temp = data;
31673167
if (temp & TF)
3168-
exit_pending_or(CeS_TRAP);
3168+
exit_pending_or(exit_TRAP);
31693169
if (V86MODE()) {
31703170
stack_return_from_vm86:
31713171
if (debug_level('e')>1)
@@ -3196,7 +3196,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
31963196
if (debug_level('e')>1)
31973197
e_printf("Return for STI fl=%08x\n",
31983198
EFLAGS);
3199-
exit_pending_or(CeS_STI);
3199+
exit_pending_or(exit_STI);
32003200
}
32013201
}
32023202
}
@@ -3224,7 +3224,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
32243224
if (debug_level('e')>1)
32253225
e_printf("Return for STI fl=%08x\n",
32263226
EFLAGS);
3227-
exit_pending_or(CeS_STI);
3227+
exit_pending_or(exit_STI);
32283228
}
32293229
}
32303230
*flags = (EFLAGS & EFLAGS_CC) | (*flags & ~EFLAGS_CC);
@@ -3254,7 +3254,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
32543254
if (debug_level('e')>1)
32553255
e_printf("Return for STI fl=%08x\n",
32563256
EFLAGS);
3257-
exit_pending_or(CeS_STI);
3257+
exit_pending_or(exit_STI);
32583258
}
32593259
}
32603260
else {
@@ -3270,7 +3270,7 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
32703270
e_printf("Return for STI ASAP fl=%08x\n",
32713271
EFLAGS);
32723272
/* force exit after next compiled block execution */
3273-
exit_pending_or(CeS_RPIC|CeS_INHI);
3273+
exit_pending_or(exit_RPIC|exit_INHI);
32743274
}
32753275
}
32763276
break;

src/base/emu-i386/simx86/codegen.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,10 @@ static void Exec_post(unsigned long flg, unsigned int mem_ref,
603603

604604
static void HandleEmuSignals(int tfset)
605605
{
606-
/* CeS_TRAP is used to signal that TF is set but
606+
/* exit_TRAP is used to signal that TF is set but
607607
we should not trap immediately after the
608608
popf/iret that does that */
609-
int e = exit_pending_xchg(0) & ~CeS_TRAP;
609+
int e = exit_pending_xchg(0);
610610
#if PROFILE
611611
if (debug_level('e')) EmuSignals++;
612612
#endif
@@ -620,16 +620,16 @@ static void HandleEmuSignals(int tfset)
620620
// TheCPU.err = EXCP01_SSTP;
621621
// }
622622
//}
623-
else if (e & CeS_SIGPEND) {
623+
else if (e & exit_SIGPEND) {
624624
/* force exit after signal */
625625
TheCPU.err=EXCP_SIGNAL;
626626
}
627-
else if (e & CeS_RPIC) {
627+
else if (e & exit_RPIC) {
628628
/* force exit for PIC */
629629
if (EFLAGS & EFLAGS_IF)
630630
TheCPU.err=EXCP_PICSIGNAL;
631631
}
632-
else if (e & CeS_STI) {
632+
else if (e & exit_STI) {
633633
/* force exit for IF set */
634634
TheCPU.err=EXCP_STISIGNAL;
635635
}
@@ -683,8 +683,8 @@ unsigned int DoExec(TNode *G, unsigned *pLastXKey)
683683
ecpu = CPUOFFS(0);
684684
if (debug_level('e')>1) {
685685
unsigned e = exit_pending();
686-
if (e & CeS_SIGPEND) e_printf("** SIGALRM is pending\n");
687-
if (e & CeS_RPIC) e_printf("** PIC is pending\n");
686+
if (e & exit_SIGPEND) e_printf("** SIGALRM is pending\n");
687+
if (e & exit_RPIC) e_printf("** PIC is pending\n");
688688
e_printf("==== Executing code at %p flg=%04x\n",
689689
G->addr,seqflg);
690690
}
@@ -745,11 +745,11 @@ unsigned int DoExec(TNode *G, unsigned *pLastXKey)
745745
/* exit_pending at this point is non-zero if there was ANY signal,
746746
* not just a SIGALRM
747747
*/
748-
if (((seqflg & F_INHI) || (exit_pending() & CeS_INHI)) && !block_inhibit) {
748+
if (((seqflg & F_INHI) || (exit_pending() & exit_INHI)) && !block_inhibit) {
749749
/* ignore signals and traps for movss/popss */
750750
CEmuStat |= CeS_INHI;
751-
if (exit_pending() & CeS_INHI)
752-
exit_pending_and(~CeS_INHI);
751+
if (exit_pending() & exit_INHI)
752+
exit_pending_and(~exit_INHI);
753753
} else {
754754
CEmuStat &= ~CeS_INHI;
755755
HandleEmuSignals(tfset);

src/base/emu-i386/simx86/cpu-emu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,20 +815,20 @@ void e_gen_sigalrm(void)
815815
/* here we come from the kernel with cs==UCODESEL, as
816816
* the passed context is that of dosemu, NOT that of the
817817
* emulated CPU! */
818-
exit_pending_or(CeS_SIGPEND);
818+
exit_pending_or(exit_SIGPEND);
819819

820820
/* this triggers calculation of paramaters for garbage collect */
821821
TheCPU.sigprof_pending = 1;
822822
}
823823

824824
void e_gen_sigalrm_from_thread(void)
825825
{
826-
exit_pending_or(CeS_SIGPEND);
826+
exit_pending_or(exit_SIGPEND);
827827
}
828828

829829
void e_gen_rpic_from_thread(void)
830830
{
831-
exit_pending_or(CeS_RPIC);
831+
exit_pending_or(exit_RPIC);
832832
}
833833

834834
static void enter_cpu_emu(void)

src/base/emu-i386/simx86/emu86.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,12 @@ extern int SpecPrejits;
681681
#define EXCP_MODESWITCH 68
682682
#define EXCP_EMULEAVE 69
683683

684+
#define exit_SIGPEND 0x01 /* signal pending mask */
685+
#define exit_RPIC 0x02 /* pic asks for interruption */
686+
#define exit_STI 0x04 /* STI shadow active */
687+
#define exit_INHI 0x08 /* inhibit interrupts(pop ss; pop sp et sim.) */
688+
#define exit_TRAP 0x10 /* INT01 Sstep set by POPF/IRET */
689+
684690
/////////////////////////////////////////////////////////////////////////////
685691

686692
#ifndef min

src/base/emu-i386/simx86/interp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static unsigned int FindExecCode(unsigned int PC)
390390
* a 'descheduling point' for checking signals.
391391
*/
392392
while (1) {
393-
if ((EFLAGS & TF) || (exit_pending() & CeS_RPIC))
393+
if ((EFLAGS & TF) || (exit_pending() & exit_RPIC))
394394
TheCPU.mode |= MSSTP;
395395
else
396396
TheCPU.mode &= ~MSSTP;

src/include/cpu-emu.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ extern void e_priv_iopl(int);
4747

4848
/* Cpuemu status register - pack as much info as possible here, so to
4949
* use a single test to check if we have to go further or not */
50-
#define CeS_SIGPEND 0x01 /* signal pending mask */
51-
#define CeS_RPIC 0x04 /* pic asks for interruption */
52-
#define CeS_STI 0x08 /* STI shadow active */
5350
#define CeS_INHI 0x800 /* inhibit interrupts(pop ss; pop sp et sim.) */
54-
#define CeS_TRAP 0x1000 /* INT01 Sstep set by POPF/IRET */
5551
#define CeS_DRTRAP 0x2000 /* Debug Registers active */
5652
#define CeS_INSTREMU_RM 0x4000
5753
#define CeS_INSTREMU_PM 0x8000

0 commit comments

Comments
 (0)