Skip to content

Commit

Permalink
Fixed a bug with the cpu flags restored with a save state
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Apr 29, 2024
1 parent 0ce98d0 commit a27ad12
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion include/lib86cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ struct cpu_save_state_t {
uint8_t is_halted;
uint8_t microcode_updated;
uint32_t hflags;
uint32_t cpu_flags;
uint32_t a20_mask;
uint64_t tsc_offset;
};
Expand Down
5 changes: 2 additions & 3 deletions lib86cpu/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#endif

// This should be updated whenever cpu members that need to be saved are added/removed
#define SAVE_STATE_ID 5
#define SAVE_STATE_ID 6


void
Expand Down Expand Up @@ -103,7 +103,6 @@ cpu_save_state(cpu_t *cpu, cpu_save_state_t *cpu_state, ram_save_state_t *ram_st
cpu_state->is_halted = cpu->cpu_ctx.is_halted;
cpu_state->microcode_updated = cpu->microcode_updated;
cpu_state->hflags = (cpu->cpu_ctx.hflags & HFLG_SAVED_MASK);
cpu_state->cpu_flags = (cpu->cpu_flags & CPU_SAVED_FLG_MASK);
cpu_state->a20_mask = cpu->a20_mask;
uint32_t old_edx = cpu->cpu_ctx.regs.edx;
uint32_t old_eax = cpu->cpu_ctx.regs.eax;
Expand Down Expand Up @@ -134,7 +133,7 @@ cpu_load_state(cpu_t *cpu, cpu_save_state_t *cpu_state, ram_save_state_t *ram_st
cpu->cpu_ctx.is_halted = cpu->cpu_ctx.is_halted;
cpu->microcode_updated = cpu_state->microcode_updated;
cpu->cpu_ctx.hflags = cpu_state->hflags;
cpu->cpu_flags = cpu_state->cpu_flags;
cpu->cpu_flags &= CPU_PRESERVED_FLG_MASK;
cpu->a20_mask = cpu_state->a20_mask;
cpu->tsc_clock.offset = cpu_state->tsc_offset;
cpu->tsc_clock.last_host_ticks = get_current_time();
Expand Down
2 changes: 1 addition & 1 deletion lib86cpu/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define CPU_ALLOW_CODE_WRITE (1 << 8)
#define CPU_FORCE_INSERT (1 << 9)
#define CPU_SINGLE_STEP (1 << 10)
#define CPU_SAVED_FLG_MASK (CPU_SYNTAX_MASK | CPU_ABORT_ON_HLT)
#define CPU_PRESERVED_FLG_MASK (CPU_SYNTAX_MASK | CPU_TIMEOUT | CPU_SINGLE_STEP | CPU_DBG_PRESENT | CPU_ABORT_ON_HLT)

#define CPU_NUM_REGS 43

Expand Down

0 comments on commit a27ad12

Please sign in to comment.