Correct CS:IP initialisation on 286+ reset. Patch from Greatpsycho.

This commit is contained in:
SarahW 2018-01-08 20:50:48 +00:00
commit 8a5b552a9a
2 changed files with 36 additions and 5 deletions

View file

@ -628,7 +628,6 @@ void resetx86()
stack32=0;
// i86_Reset();
// cs=0xFFFF0;
cpu_state.pc=0;
msw=0;
if (is486)
cr0 = 1 << 30;
@ -639,8 +638,18 @@ void resetx86()
cr4 = 0;
eflags=0;
cgate32=0;
loadcs(0xFFFF);
rammask = AT ? 0xFFFFFFFF : 0xfffff;
if (AT)
{
loadcs(0xF000);
cpu_state.pc = 0xFFF0;
rammask = cpu_16bitbus ? 0xFFFFFF : 0xFFFFFFFF;
}
else
{
loadcs(0xFFFF);
cpu_state.pc = 0;
rammask = 0xfffff;
}
idt.base = 0;
flags=2;
makeznptable();
@ -667,13 +676,23 @@ void softresetx86()
cpu_cur_status = 0;
// i86_Reset();
// cs=0xFFFF0;
cpu_state.pc=0;
msw=0;
cr0=0;
cr4 = 0;
eflags=0;
cgate32=0;
loadcs(0xFFFF);
if (AT)
{
loadcs(0xF000);
cpu_state.pc = 0xFFF0;
rammask = cpu_16bitbus ? 0xFFFFFF : 0xFFFFFFFF;
}
else
{
loadcs(0xFFFF);
cpu_state.pc = 0;
rammask = 0xfffff;
}
//rammask=0xFFFFFFFF;
flags=2;
idt.base = 0;

View file

@ -68,6 +68,18 @@ static void seg_reset(x86seg *s)
s->limit = 0xFFFF;
s->limit_low = 0;
s->limit_high = 0xffff;
if (s == &_cs)
{
// TODO - When the PC is reset, initialization of the CS descriptor must be like the annotated line below.
//s->base = AT ? (cpu_16bitbus ? 0xFF0000 : 0xFFFF0000) : 0xFFFF0;
s->base = AT ? 0xF0000 : 0xFFFF0;
s->seg = AT ? 0xF000 : 0xFFFF;
}
else
{
s->base = 0;
s->seg = 0;
}
}
void x86seg_reset()