cpu/i386: Use logmacro.h granular logging. (#11171)

This commit is contained in:
Luigi Thirty 2023-04-29 16:09:31 -05:00 committed by GitHub
parent e20d134dee
commit 47202637e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 243 additions and 228 deletions

View File

@ -36,10 +36,10 @@ uint64_t pentium_device::opcode_rdmsr(bool &valid_msr)
if (!(offset & ~0xf)) // 2-f are test registers
{
valid_msr = true;
logerror("RDMSR: Reading test MSR %x\n", offset);
LOGMASKED(LOG_MSR, "RDMSR: Reading test MSR %x\n", offset);
return 0;
}
logerror("RDMSR: invalid P5 MSR read %08x at %08x\n", offset, m_pc - 2);
LOGMASKED(LOG_MSR, "RDMSR: invalid P5 MSR read %08x at %08x\n", offset, m_pc - 2);
valid_msr = false;
return 0;
}
@ -84,10 +84,10 @@ void pentium_device::opcode_wrmsr(uint64_t data, bool &valid_msr)
if (!(offset & ~0xf)) // 2-f are test registers
{
valid_msr = true;
logerror("WRMSR: Writing test MSR %x\n", offset);
LOGMASKED(LOG_MSR, "WRMSR: Writing test MSR %x\n", offset);
break;
}
logerror("WRMSR: invalid MSR write %08x (%08x%08x) at %08x\n", offset, (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
LOGMASKED(LOG_MSR, "WRMSR: invalid MSR write %08x (%08x%08x) at %08x\n", offset, (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
valid_msr = false;
break;
}
@ -121,7 +121,7 @@ uint64_t pentium_pro_device::opcode_rdmsr(bool &valid_msr)
valid_msr = true;
return m_perfctr[1];
default:
logerror("RDMSR: unimplemented register called %08x at %08x\n", offset, m_pc - 2);
LOGMASKED(LOG_MSR, "RDMSR: unimplemented register called %08x at %08x\n", offset, m_pc - 2);
valid_msr = true;
return 0;
}
@ -150,7 +150,7 @@ void pentium_pro_device::opcode_wrmsr(uint64_t data, bool &valid_msr)
valid_msr = true;
break;
default:
logerror("WRMSR: unimplemented register called %08x (%08x%08x) at %08x\n", offset, (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
LOGMASKED(LOG_MSR, "WRMSR: unimplemented register called %08x (%08x%08x) at %08x\n", offset, (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
valid_msr = true;
break;
}
@ -158,13 +158,13 @@ void pentium_pro_device::opcode_wrmsr(uint64_t data, bool &valid_msr)
uint64_t pentium4_device::opcode_rdmsr(bool &valid_msr)
{
logerror("RDMSR: unimplemented register called %08x at %08x\n", REG32(ECX), m_pc - 2);
LOGMASKED(LOG_MSR, "RDMSR: unimplemented register called %08x at %08x\n", REG32(ECX), m_pc - 2);
valid_msr = true;
return 0;
}
void pentium4_device::opcode_wrmsr(uint64_t data, bool &valid_msr)
{
logerror("WRMSR: unimplemented register called %08x (%08x%08x) at %08x\n", REG32(ECX), (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
LOGMASKED(LOG_MSR, "WRMSR: unimplemented register called %08x (%08x%08x) at %08x\n", REG32(ECX), (uint32_t)(data >> 32), (uint32_t)data, m_pc - 2);
valid_msr = true;
}

View File

@ -28,6 +28,21 @@
#include "debug/debugcpu.h"
#include "debug/express.h"
#define LOG_MSR (1U << 1)
#define LOG_INVALID_OPCODE (1U << 2)
#define LOG_LIMIT_CHECK (1U << 3)
#define LOG_UNEMULATED (1U << 4)
#define LOG_PM_EVENTS (1U << 5)
#define LOG_PM_FAULT_GP (1U << 6)
#define LOG_PM_FAULT_SS (1U << 7)
#define LOG_PM_FAULT_NP (1U << 8)
#define LOG_PM_FAULT_TS (1U << 9)
#define LOG_PM_FAULT_DF (1U << 10)
#define LOG_PM_FAULT_UD (1U << 11)
//#define VERBOSE (LOG_PM_FAULT_GP)
#include "logmacro.h"
/* seems to be defined on mingw-gcc */
#undef i386
@ -1552,7 +1567,7 @@ void i386_device::build_cycle_table()
void i386_device::report_invalid_opcode()
{
#ifndef DEBUG_MISSING_OPCODE
logerror("i386: Invalid opcode %02X at %08X %s\n", m_opcode, m_pc - 1, m_lock ? "with lock" : "");
LOGMASKED(LOG_INVALID_OPCODE, "i386: Invalid opcode %02X at %08X %s\n", m_opcode, m_pc - 1, m_lock ? "with lock" : "");
#else
logerror("Invalid opcode");
for (int a = 0; a < m_opcode_bytes_length; a++)
@ -1567,7 +1582,7 @@ void i386_device::report_invalid_opcode()
void i386_device::report_invalid_modrm(const char* opcode, uint8_t modrm)
{
#ifndef DEBUG_MISSING_OPCODE
logerror("i386: Invalid %s modrm %01X at %08X\n", opcode, modrm, m_pc - 2);
LOGMASKED(LOG_INVALID_OPCODE, "i386: Invalid %s modrm %01X at %08X\n", opcode, modrm, m_pc - 2);
#else
logerror("Invalid %s modrm %01X", opcode, modrm);
for (int a = 0; a < m_opcode_bytes_length; a++)
@ -2792,7 +2807,7 @@ void i386_device::execute_run()
phys_addr = (m_cr[0] & (1 << 31)) ? translate_address(m_CPL, TR_FETCH, &m_dr[i], &error) : m_dr[i];
if(breakpoint_length != 0) // Not one byte in length? logerror it, I have no idea how this works on real processors.
{
logerror("i386: Breakpoint length not 1 byte on an instruction breakpoint\n");
LOGMASKED(LOG_INVALID_OPCODE, "i386: Breakpoint length not 1 byte on an instruction breakpoint\n");
}
if(m_pc == phys_addr)
{
@ -2878,20 +2893,20 @@ std::unique_ptr<util::disasm_interface> i386_device::create_disassembler()
void i386_device::opcode_cpuid()
{
logerror("CPUID called with unsupported EAX=%08x at %08x!\n", REG32(EAX), m_eip);
LOGMASKED(LOG_MSR, "CPUID called with unsupported EAX=%08x at %08x!\n", REG32(EAX), m_eip);
}
uint64_t i386_device::opcode_rdmsr(bool &valid_msr)
{
valid_msr = false;
logerror("RDMSR called with unsupported ECX=%08x at %08x!\n", REG32(ECX), m_eip);
LOGMASKED(LOG_MSR, "RDMSR called with unsupported ECX=%08x at %08x!\n", REG32(ECX), m_eip);
return -1;
}
void i386_device::opcode_wrmsr(uint64_t data, bool &valid_msr)
{
valid_msr = false;
logerror("WRMSR called with unsupported ECX=%08x (%08x%08x) at %08x!\n", REG32(ECX), (uint32_t)(data >> 32), (uint32_t)data, m_eip);
LOGMASKED(LOG_MSR, "WRMSR called with unsupported ECX=%08x (%08x%08x) at %08x!\n", REG32(ECX), (uint32_t)(data >> 32), (uint32_t)data, m_eip);
}
/*****************************************************************************/
@ -3386,7 +3401,7 @@ void pentium3_device::opcode_cpuid()
// (upper 32-bits part is in EAX=1 EAX return)
// NB: if this is triggered from an Arcade system then there's a very good chance
// that is trying to tie the serial as a form of copy protection cfr. gamecstl
logerror("CPUID with EAX=00000003 (Pentium III PSN?) at %08x!\n", m_eip);
LOGMASKED(LOG_MSR, "CPUID with EAX=00000003 (Pentium III PSN?) at %08x!\n", m_eip);
REG32(EAX) = 0x00000000;
REG32(EBX) = 0x00000000;
REG32(ECX) = 0x01234567;

View File

@ -1739,7 +1739,7 @@ void i386_device::i386_popf() // Opcode 0x9d
{
if(IOPL < 3)
{
logerror("POPFD(%08x): IOPL < 3 while in V86 mode.\n",m_pc);
LOGMASKED(LOG_PM_FAULT_GP, "POPFD(%08x): IOPL < 3 while in V86 mode.\n",m_pc);
FAULT(FAULT_GP,0) // #GP(0)
}
mask &= ~0x00003000; // IOPL cannot be changed while in V8086 mode
@ -3273,7 +3273,7 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
else
{
i386_trap(6, 0, 0);
logerror("i386: VERR: Exception - Running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: VERR: Exception - Running in real mode or virtual 8086 mode.\n");
}
break;
@ -3316,7 +3316,7 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
else
{
i386_trap(6, 0, 0);
logerror("i386: VERW: Exception - Running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: VERW: Exception - Running in real mode or virtual 8086 mode.\n");
}
break;
@ -3573,7 +3573,7 @@ void i386_device::i386_lar_r16_rm16() // Opcode 0x0f 0x02
if(seg.selector == 0)
{
SetZF(0); // not a valid segment
// logerror("i386 (%08x): LAR: Selector %04x is invalid type.\n",m_pc,seg.selector);
// LOGMASKED(LOG_PM_EVENTS, "i386 (%08x): LAR: Selector %04x is invalid type.\n",m_pc,seg.selector);
}
else
{
@ -3613,7 +3613,7 @@ void i386_device::i386_lar_r16_rm16() // Opcode 0x0f 0x02
{
// illegal opcode
i386_trap(6,0, 0);
logerror("i386: LAR: Exception - running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: LAR: Exception - running in real mode or virtual 8086 mode.\n");
}
}
@ -3753,7 +3753,7 @@ bool i386_device::i386_load_far_pointer16(int s)
uint16_t selector;
if( modrm >= 0xc0 ) {
//logerror("i386: load_far_pointer16 NYI\n"); // don't log, NT will use this a lot
//LOGMASKED(LOG_PM_EVENTS, "i386: load_far_pointer16 NYI\n"); // don't log, NT will use this a lot
i386_trap(6, 0, 0);
return false;
} else {

View File

@ -1589,7 +1589,7 @@ void i386_device::i386_popfd() // Opcode 0x9d
{
if(IOPL < 3)
{
logerror("POPFD(%08x): IOPL < 3 while in V86 mode.\n",m_pc);
LOGMASKED(LOG_PM_FAULT_GP, "POPFD(%08x): IOPL < 3 while in V86 mode.\n",m_pc);
FAULT(FAULT_GP,0) // #GP(0)
}
mask &= ~0x00003000; // IOPL cannot be changed while in V8086 mode
@ -3074,7 +3074,7 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
else
{
i386_trap(6, 0, 0);
logerror("i386: VERR: Exception - Running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: VERR: Exception - Running in real mode or virtual 8086 mode.\n");
}
break;
@ -3116,7 +3116,7 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
else
{
i386_trap(6, 0, 0);
logerror("i386: VERW: Exception - Running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: VERW: Exception - Running in real mode or virtual 8086 mode.\n");
}
break;
@ -3414,7 +3414,7 @@ void i386_device::i386_lar_r32_rm32() // Opcode 0x0f 0x02
{
// illegal opcode
i386_trap(6,0, 0);
logerror("i386: LAR: Exception - running in real mode or virtual 8086 mode.\n");
LOGMASKED(LOG_PM_EVENTS, "i386: LAR: Exception - running in real mode or virtual 8086 mode.\n");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ void i386_device::i486_cpuid() // Opcode 0x0F A2
if (m_cpuid_id0 == 0)
{
// this 486 doesn't support the CPUID instruction
logerror("CPUID not supported at %08x!\n", m_eip);
LOGMASKED(LOG_MSR, "CPUID not supported at %08x!\n", m_eip);
i386_trap(6, 0, 0);
}
else
@ -324,7 +324,7 @@ void i386_device::i486_group0F01_16() // Opcode 0x0f 01
FAULT(FAULT_GP,0)
if(modrm >= 0xc0)
{
logerror("i486: invlpg with modrm %02X\n", modrm);
LOGMASKED(LOG_PM_FAULT_UD, "i486: invlpg with modrm %02X\n", modrm);
FAULT(FAULT_UD,0)
}
ea = GetEA(modrm,-1);
@ -442,7 +442,7 @@ void i386_device::i486_group0F01_32() // Opcode 0x0f 01
FAULT(FAULT_GP,0)
if(modrm >= 0xc0)
{
logerror("i486: invlpg with modrm %02X\n", modrm);
LOGMASKED(LOG_PM_FAULT_UD, "i486: invlpg with modrm %02X\n", modrm);
FAULT(FAULT_UD,0)
}
ea = GetEA(modrm,-1);
@ -528,7 +528,7 @@ void i386_device::i486_mov_cr_r32() // Opcode 0x0f 22
break;
case 4: CYCLES(1); break; // TODO
default:
logerror("i386: mov_cr_r32 CR%d!\n", cr);
LOGMASKED(LOG_INVALID_OPCODE, "i386: mov_cr_r32 CR%d!\n", cr);
return;
}
m_cr[cr] = data;

View File

@ -111,7 +111,7 @@ void i386_device::pentium_rsm()
{
if(!m_smm)
{
logerror("i386: Invalid RSM outside SMM at %08X\n", m_pc - 1);
LOGMASKED(LOG_INVALID_OPCODE, "i386: Invalid RSM outside SMM at %08X\n", m_pc - 1);
i386_trap(6, 0, 0);
return;
}
@ -1011,7 +1011,7 @@ void i386_device::i386_cyrix_special() // Opcode 0x0f 3a-3d
void i386_device::i386_cyrix_unknown() // Opcode 0x0f 74
{
logerror("Unemulated 0x0f 0x74 opcode called\n");
LOGMASKED(LOG_UNEMULATED, "Unemulated 0x0f 0x74 opcode called\n");
CYCLES(1);
}
@ -2791,7 +2791,7 @@ void i386_device::sse_group_0fae() // Opcode 0f ae
{
uint8_t modm = FETCH();
if( modm == 0xf8 ) {
logerror("Unemulated SFENCE opcode called\n");
LOGMASKED(LOG_UNEMULATED, "Unemulated SFENCE opcode called\n");
CYCLES(1); // sfence instruction
} else if( modm == 0xf0 ) {
CYCLES(1); // mfence instruction

View File

@ -206,7 +206,7 @@ int i386_device::x87_check_exceptions(bool store)
if ((m_x87_sw & ~m_x87_cw) & 0x3f)
{
// m_device->execute().set_input_line(INPUT_LINE_FERR, RAISE_LINE);
logerror("Unmasked x87 exception (CW:%.4x, SW:%.4x)\n", m_x87_cw, m_x87_sw);
LOG("Unmasked x87 exception (CW:%.4x, SW:%.4x)\n", m_x87_cw, m_x87_sw);
// interrupt handler
m_x87_sw |= X87_SW_ES;
m_ferr_handler(1);