More debugger paging improvements

This commit is contained in:
Jeff Parsons 2015-05-08 12:58:53 -07:00 • committed by jeffpar
commit 83f2218e27
4 changed files with 24 additions and 15 deletions

View file

@ -78,7 +78,7 @@
"debugger": { "debugger": {
"id": "pc386.debugger", "id": "pc386.debugger",
"name": "", "name": "",
"commands": "", "commands": "bp F000:825F;g",
"messages": "" "messages": ""
} }
} }

View file

@ -2688,12 +2688,14 @@ if (DEBUGGER) {
if (nState >= 0 && this.aaOpcodeCounts.length) { if (nState >= 0 && this.aaOpcodeCounts.length) {
this.cInstructions++; this.cInstructions++;
var bOpcode = this.cpu.probeAddr(addr); var bOpcode = this.cpu.probeAddr(addr);
this.aaOpcodeCounts[bOpcode][1]++; if (bOpcode != null) {
var a = this.aOpcodeHistory[this.iOpcodeHistory]; this.aaOpcodeCounts[bOpcode][1]++;
a[0] = this.cpu.getIP(); var a = this.aOpcodeHistory[this.iOpcodeHistory];
a[1] = this.cpu.getCS(); a[0] = this.cpu.getIP();
a[2] = addr; a[1] = this.cpu.getCS();
if (++this.iOpcodeHistory == this.aOpcodeHistory.length) this.iOpcodeHistory = 0; a[2] = addr;
if (++this.iOpcodeHistory == this.aOpcodeHistory.length) this.iOpcodeHistory = 0;
}
} }
return false; return false;
}; };

View file

@ -737,9 +737,10 @@ X86CPU.prototype.enablePageBlocks = function()
* @this {X86CPU} * @this {X86CPU}
* @param {number} addr is a linear address * @param {number} addr is a linear address
* @param {boolean} fWrite (true if called for a write, false if for a read) * @param {boolean} fWrite (true if called for a write, false if for a read)
* @param {boolean} [fSuppress] (true if any faults, remapping, etc should be suppressed)
* @return {Memory|null} * @return {Memory|null}
*/ */
X86CPU.prototype.mapPageBlock = function(addr, fWrite) X86CPU.prototype.mapPageBlock = function(addr, fWrite, fSuppress)
{ {
var offPDE = (addr & X86.LADDR.PDE.MASK) >>> X86.LADDR.PDE.SHIFT; var offPDE = (addr & X86.LADDR.PDE.MASK) >>> X86.LADDR.PDE.SHIFT;
var addrPDE = this.regCR3 + offPDE; var addrPDE = this.regCR3 + offPDE;
@ -752,12 +753,12 @@ X86CPU.prototype.mapPageBlock = function(addr, fWrite)
var pde = blockPDE.readLong(offPDE); var pde = blockPDE.readLong(offPDE);
if (!(pde & X86.PTE.PRESENT)) { if (!(pde & X86.PTE.PRESENT)) {
X86.fnPageFault.call(this, addr, false, fWrite); if (!fSuppress) X86.fnPageFault.call(this, addr, false, fWrite);
return null; return null;
} }
if (!(pde & X86.PTE.USER) && this.segCS.cpl == 3) { if (!(pde & X86.PTE.USER) && this.segCS.cpl == 3) {
X86.fnPageFault.call(this, addr, true, fWrite); if (!fSuppress) X86.fnPageFault.call(this, addr, true, fWrite);
return null; return null;
} }
@ -771,13 +772,13 @@ X86CPU.prototype.mapPageBlock = function(addr, fWrite)
var blockPTE = this.aBusBlocks[(addrPTE & this.busMask) >>> this.blockShift]; var blockPTE = this.aBusBlocks[(addrPTE & this.busMask) >>> this.blockShift];
var pte = blockPTE.readLong(offPTE); var pte = blockPTE.readLong(offPTE);
if (!(pte & X86.PTE.PRESENT)) { if (!(pte & X86.PTE.PRESENT) && !fSuppress) {
X86.fnPageFault.call(this, addr, false, fWrite); if (!fSuppress) X86.fnPageFault.call(this, addr, false, fWrite);
return null; return null;
} }
if (!(pte & X86.PTE.USER) && this.segCS.cpl == 3) { if (!(pte & X86.PTE.USER) && this.segCS.cpl == 3) {
X86.fnPageFault.call(this, addr, true, fWrite); if (!fSuppress) X86.fnPageFault.call(this, addr, true, fWrite);
return null; return null;
} }
@ -786,6 +787,7 @@ X86CPU.prototype.mapPageBlock = function(addr, fWrite)
* TODO: Since we're immediately shifting addrPhys by blockShift, we could also skip adding the addr's offset. * TODO: Since we're immediately shifting addrPhys by blockShift, we could also skip adding the addr's offset.
*/ */
var blockPhys = this.aBusBlocks[(addrPhys & this.busMask) >>> this.blockShift]; var blockPhys = this.aBusBlocks[(addrPhys & this.busMask) >>> this.blockShift];
if (fSuppress) return blockPhys;
/* /*
* So we have the block containing the physical memory corresponding to the given linear address. * So we have the block containing the physical memory corresponding to the given linear address.
@ -2717,7 +2719,10 @@ X86CPU.prototype.setBinding = function(sHTMLType, sBinding, control)
X86CPU.prototype.probeAddr = function(addr) X86CPU.prototype.probeAddr = function(addr)
{ {
var block = this.aMemBlocks[(addr & this.memMask) >>> this.blockShift]; var block = this.aMemBlocks[(addr & this.memMask) >>> this.blockShift];
if (block.type == Memory.TYPE.UNPAGED) return null; if (block.type == Memory.TYPE.UNPAGED) {
block = this.mapPageBlock(addr, false, true);
if (!block) return null;
}
return block.readByteDirect(addr & this.blockLimit, addr); return block.readByteDirect(addr & this.blockLimit, addr);
}; };

View file

@ -39,6 +39,8 @@
bits 16 bits 16
PAGING equ 1
; ;
; If we built our data structures in RAM, we might use the first page of RAM (0x0000-0x0fff) like so: ; If we built our data structures in RAM, we might use the first page of RAM (0x0000-0x0fff) like so:
; ;
@ -264,7 +266,7 @@ initPT: stosd
goProt: o32 lgdt [cs:addrGDT] goProt: o32 lgdt [cs:addrGDT]
mov cr3,esi mov cr3,esi
mov eax,cr0 mov eax,cr0
%ifdef PAGING %if PAGING
or eax,CR0_MSW_PE | CR0_PG or eax,CR0_MSW_PE | CR0_PG
%else %else
or eax,CR0_MSW_PE or eax,CR0_MSW_PE