Improved control of CPU, INT, SEG and FAULT messages

This commit is contained in:
Jeff Parsons 2014-11-17 17:59:55 -08:00 committed by jeffpar
commit 23eeb37938
6 changed files with 56 additions and 45 deletions

View file

@ -4499,7 +4499,9 @@ ChipSet.prototype.setSpeaker = function(fOn)
ChipSet.prototype.messageDebugger = function(sMessage, bitsMessage, nIRQ)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage == null) bitsMessage = Debugger.MESSAGE.CHIPSET;
if (bitsMessage == null) {
bitsMessage = Debugger.MESSAGE.CHIPSET;
}
if (nIRQ !== undefined) {
bitsMessage |= (nIRQ == ChipSet.IRQ.TIMER0? Debugger.MESSAGE.TIMER : (nIRQ == ChipSet.IRQ.KBD? Debugger.MESSAGE.KBD : (nIRQ == ChipSet.IRQ.FDC? Debugger.MESSAGE.FDC : Debugger.MESSAGE.PIC)));
}

View file

@ -173,31 +173,33 @@ function Debugger(parmsDbg)
* Debugger message constants must always be defined, even when DEBUGGER is false, lest the Closure Compiler complain
*/
Debugger.MESSAGE = {
MEM: 0x00000001,
PORT: 0x00000002,
DMA: 0x00000004,
PIC: 0x00000008,
TIMER: 0x00000010,
CMOS: 0x00000020,
RTC: 0x00000040,
C8042: 0x00000080,
CHIPSET: 0x00000100,
KBD: 0x00000200,
KEYS: 0x00000400,
VIDEO: 0x00000800,
FDC: 0x00001000,
HDC: 0x00002000,
DISK: 0x00004000,
SERIAL: 0x00008000,
SPEAKER: 0x00010000,
STATE: 0x00020000,
MOUSE: 0x00040000,
COMPUTER: 0x00080000,
CPU: 0x00100000,
DOS: 0x00200000,
INT: 0x00400000,
CPU: 0x00000001,
INT: 0x00000002,
SEG: 0x00000004,
FAULT: 0x00000008,
MEM: 0x00000010,
PORT: 0x00000020,
DMA: 0x00000040,
PIC: 0x00000080,
TIMER: 0x00000100,
CMOS: 0x00000200,
RTC: 0x00000400,
C8042: 0x00000800,
CHIPSET: 0x00001000,
KBD: 0x00002000,
KEYS: 0x00004000,
VIDEO: 0x00008000,
FDC: 0x00010000,
HDC: 0x00020000,
DISK: 0x00040000,
SERIAL: 0x00080000,
SPEAKER: 0x00100000,
STATE: 0x00200000,
MOUSE: 0x00400000,
COMPUTER: 0x00800000,
LOG: 0x01000000,
HALT: 0x10000000
DOS: 0x02000000,
HALT: 0x80000000
};
if (DEBUGGER) {
@ -483,6 +485,10 @@ if (DEBUGGER) {
* something to be aware of).
*/
Debugger.MESSAGES = {
"cpu": Debugger.MESSAGE.CPU,
"int": Debugger.MESSAGE.INT,
"seg": Debugger.MESSAGE.SEG,
"fault": Debugger.MESSAGE.FAULT,
"mem": Debugger.MESSAGE.MEM,
"port": Debugger.MESSAGE.PORT,
"dma": Debugger.MESSAGE.DMA,
@ -503,10 +509,8 @@ if (DEBUGGER) {
"state": Debugger.MESSAGE.STATE,
"mouse": Debugger.MESSAGE.MOUSE,
"computer": Debugger.MESSAGE.COMPUTER,
"cpu": Debugger.MESSAGE.CPU,
"dos": Debugger.MESSAGE.DOS,
"int": Debugger.MESSAGE.INT,
"log": Debugger.MESSAGE.LOG,
"dos": Debugger.MESSAGE.DOS,
/*
* Now we turn to message actions rather than message types; for example, setting "halt"
* on or off doesn't enable "halt" messages, but rather halts the CPU on any message above.

View file

@ -1839,8 +1839,11 @@ Keyboard.prototype.keySimulateUpOrDown = function(keyCode, fDown, simCode)
Keyboard.prototype.messageDebugger = function(sMessage, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage == null) bitsMessage = Debugger.MESSAGE.KBD;
if (bitsMessage == Debugger.MESSAGE.PORT) bitsMessage |= Debugger.MESSAGE.KBD;
if (bitsMessage == null) {
bitsMessage = Debugger.MESSAGE.KBD;
} else {
bitsMessage |= Debugger.MESSAGE.KBD;
}
if (this.dbg.messageEnabled(bitsMessage)) this.dbg.message(sMessage);
}
};

View file

@ -2607,19 +2607,21 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
};
/**
* messageDebugger(sMessage)
* messageDebugger(sMessage, bitsMessage)
*
* This is a combination of the Debugger's messageEnabled(MESSAGE_MEM) and message() functions, for convenience.
* This is a combination of the Debugger's messageEnabled(MESSAGE_CPU) and message() functions, for convenience.
*
* @this {X86CPU}
* @param {string} sMessage is any caller-defined message string
* @param {number} [bitsMessage] is one or more Debugger MESSAGE_* category flag(s)
*/
X86CPU.prototype.messageDebugger = function(sMessage)
X86CPU.prototype.messageDebugger = function(sMessage, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this.dbg.messageEnabled(Debugger.MESSAGE.CPU)) {
this.dbg.message(sMessage);
if (bitsMessage == null) {
bitsMessage = Debugger.MESSAGE.CPU;
}
if (this.dbg.messageEnabled(bitsMessage)) this.dbg.message(sMessage);
}
};

View file

@ -511,13 +511,8 @@ var X86Help = {
*/
opHelpFaultMessage: function(nFault, nError, fHalt) {
if (DEBUGGER && this.dbg) {
/*
* NOTE: By using Debugger.message(), we have the option of setting "m halt on" and halting on messages like this.
*/
var bitsMessage = Debugger.MESSAGE.FAULT;
var bOpcode = this.bus.getByteDirect(this.regEIP);
if (this.dbg.messageEnabled(Debugger.MESSAGE.CPU)) {
this.dbg.message("Fault 0x" + str.toHexByte(nFault) + (nError != null? " (0x" + str.toHexWord(nError) + ")" : "") + " on opcode 0x" + str.toHexByte(bOpcode) + " at " + str.toHexAddr(this.regIP, this.segCS.sel) + " (%" + str.toHex(this.regEIP) + ")");
}
/*
* OS/2 1.0 uses an INT3 (0xCC) opcode in conjunction with an invalid IDT to trigger a triple-fault
* reset and return to real-mode, and these resets happen quite frequently during boot; for example, OS/2
@ -528,7 +523,12 @@ var X86Help = {
* advantage of the fact that all 3 faults comprising the triple-fault point to the INT3 (0xCC) opcode,
* and so whenever we see that opcode, we ignore the caller's fHalt flag.
*/
if (fHalt && bOpcode != X86.OPCODE.INT3) this.dbg.stopCPU();
if (bOpcode == X86.OPCODE.INT3) {
fHalt = false;
bitsMessage |= Debugger.MESSAGE.CPU;
}
this.messageDebugger("Fault 0x" + str.toHexByte(nFault) + (nError != null? " (0x" + str.toHexWord(nError) + ")" : "") + " on opcode 0x" + str.toHexByte(bOpcode) + " at " + str.toHexAddr(this.regIP, this.segCS.sel) + " (%" + str.toHex(this.regEIP) + ")", bitsMessage);
if (fHalt) this.dbg.stopCPU();
}
}
};

View file

@ -254,7 +254,7 @@ X86Seg.prototype.loadDesc6 = function(sel, addrDesc)
var limit = this.cpu.getWord(addrDesc + 4);
if (DEBUG) {
this.cpu.messageDebugger("loadDesc6(" + this.sName + "): base=" + str.toHex(base) + " limit=" + str.toHexWord(limit) + " acc=" + str.toHexWord(acc));
this.cpu.messageDebugger("loadDesc6(" + this.sName + "): base=" + str.toHex(base) + " limit=" + str.toHexWord(limit) + " acc=" + str.toHexWord(acc), Debugger.MESSAGE.SEG);
}
this.sel = sel;
@ -292,8 +292,8 @@ X86Seg.prototype.loadDesc8 = function(sel, addrDesc)
if (DEBUG) {
var ch = (this.sName.length < 3? " " : "");
this.cpu.messageDebugger("loadDesc8(" + this.sName + "):" + ch + " base=" + str.toHex(base) + " limit=" + str.toHexWord(limit) + " acc=" + str.toHexWord(acc) + (ext? " ext=" + str.toHexWord(ext) : ""));
// this.cpu.assert(!ext);
this.cpu.messageDebugger("loadDesc8(" + this.sName + "):" + ch + " base=" + str.toHex(base) + " limit=" + str.toHexWord(limit) + " acc=" + str.toHexWord(acc) + (ext? " ext=" + str.toHexWord(ext) : ""), Debugger.MESSAGE.SEG);
this.cpu.assert(!ext || ext == X86.DESC.EXT.AVAIL);
}
/*