Skip to content

Commit

Permalink
Merge branch 'logging_improvement' of https://github.com/bitsh1ft3r/X…
Browse files Browse the repository at this point in the history
…enon into logging_improvement
  • Loading branch information
bitsh1ft3r committed Jan 29, 2025
2 parents b9f41f0 + fc90903 commit d2b3ca6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
34 changes: 11 additions & 23 deletions Xenon/Core/RootBus/HostBridge/PCIBridge/PCIBridge.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright 2025 Xenon Emulator Project

#include "Base/Logging/Log.h"

#include "PCIBridge.h"
#include "PCIBridgeConfig.h"

Expand Down Expand Up @@ -110,8 +112,7 @@ bool PCIBridge::isAddressMappedinBAR(u32 address) {
}

void PCIBridge::addPCIDevice(PCIDevice *device) {
std::cout << "PCI Bus > New device attatched: " << device->GetDeviceName()
<< std::endl;
LOG_INFO(PCIBridge, "PCI Bus > New device attatched: {}", device->GetDeviceName());

connectedPCIDevices.push_back(device);
}
Expand Down Expand Up @@ -140,8 +141,7 @@ bool PCIBridge::Read(u64 readAddress, u64 *data, u8 byteCount) {
*data = pciBridgeState.PRIO_REG_SFCX.hexData;
break;
default:
std::cout << "PCI Bridge: Unknown reg being read: 0x" << readAddress
<< std::endl;
LOG_ERROR(PCIBridge, "Unknown reg being read: 0x{}", readAddress);
break;
}
return true;
Expand Down Expand Up @@ -200,8 +200,7 @@ bool PCIBridge::Write(u64 writeAddress, u64 data, u8 byteCount) {
pciBridgeState.PRIO_REG_SFCX.cpuIRQ = cpuIRQ;
break;
default:
std::cout << "PCI Bridge: Unknown reg being written: 0x" << writeAddress
<< ", 0x" << data << std::endl;
LOG_ERROR(PCIBridge, "Unknown reg being written: 0x{}, 0x{}", writeAddress, data);
break;
}
return true;
Expand Down Expand Up @@ -271,25 +270,20 @@ void PCIBridge::ConfigRead(u64 readAddress, u64 *data, u8 byteCount) {
currentDevName = "5841";
break;
default:
std::cout << "PCI Config Space Read: Unknown device accessed: Dev 0x"
<< configAddr.devNum << " Reg 0x" << configAddr.regOffset
<< std::endl;
LOG_ERROR(PCIBridge, "PCI Config Space Read: Unknown device accessed: Dev 0x{}, Reg 0x{}", configAddr.devNum, configAddr.regOffset);
return;
break;
}

for (auto &device : connectedPCIDevices) {
if (device->GetDeviceName() == currentDevName) {
// Hit!
std::cout << "PCI Bus -> Config read, device: " << currentDevName
<< " addr = 0x" << configAddr.regOffset << std::endl;
LOG_INFO(PCIBridge, "PCI Bus -> Config read, device: {} addr = 0x{}", currentDevName, configAddr.regOffset);
device->ConfigRead(readAddress, data, byteCount);
return;
}
}

std::cout << "PCI Read to unimplemented device: " << currentDevName.c_str()
<< std::endl;
LOG_ERROR(PCIBridge, "PCI Read to unimplemented device: {}", currentDevName.c_str());
*data = 0xFFFFFFFFFFFFFFFF;
}

Expand Down Expand Up @@ -346,24 +340,18 @@ void PCIBridge::ConfigWrite(u64 writeAddress, u64 data, u8 byteCount) {
currentDevName = "5841";
break;
default:
std::cout << "PCI Config Space Write: Unknown device accessed: Dev 0x"
<< configAddr.devNum << " Func 0x" << configAddr.functNum
<< " Reg 0x" << configAddr.regOffset << " data = 0x" << data
<< std::endl;
LOG_ERROR(PCIBridge, "PCI Config Space Write: Unknown device accessed: Dev 0x{} Func 0x{} Reg 0x{} data = 0x{}", configAddr.devNum, configAddr.functNum, configAddr.regOffset, data);
return;
break;
}

for (auto &device : connectedPCIDevices) {
if (device->GetDeviceName() == currentDevName) {
// Hit!
std::cout << "PCI Bus -> Config write, device: " << currentDevName
<< " addr = 0x" << configAddr.regOffset << " data = 0x" << data
<< std::endl;
LOG_ERROR(PCIBridge, "PCI Bus -> Config write, device: {} addr = 0x{} data = 0x{}", currentDevName, configAddr.regOffset, data);
device->ConfigWrite(writeAddress, data, byteCount);
return;
}
}
std::cout << "PCI Write to unimplemented device: " << currentDevName.c_str()
<< " data = 0x" << data << std::endl;
LOG_ERROR(PCIBridge, "PCI Write to unimplemented device: {} data = 0x{}", currentDevName.c_str(), data);
}
8 changes: 3 additions & 5 deletions Xenon/Core/XCPU/Interpreter/PPC_System.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2025 Xenon Emulator Project

#include <iostream>
#include "Base/Logging/Log.h"

#include "PPCInterpreter.h"

Expand Down Expand Up @@ -652,7 +652,7 @@ void PPCInterpreter::PPCInterpreter_mfspr(PPU_STATE *hCore) {
value = hCore->SPR.CTRL;
break;
default:
std::cout << "mfspr: Unknown SPR: 0x" << std::hex << sprNum << std::endl;
LOG_ERROR(Xenon_PostBus, "mfspr: Unknown SPR: 0x{0:#x}", sprNum);
break;
}

Expand Down Expand Up @@ -792,9 +792,7 @@ void PPCInterpreter::PPCInterpreter_mtspr(PPU_STATE *hCore) {
(hCore->ppuThread[hCore->currentThread].GPR[rD] << 32);
break;
default:
std::cout << hCore->ppuName << " SPR " << std::dec << spr << " = 0x"
<< std::hex << hCore->ppuThread[hCore->currentThread].GPR[rD]
<< std::endl;
LOG_ERROR(Xenon_PostBus, "{} SPR {0:#d} = 0x{0:#x}", hCore->ppuName, spr, hCore->ppuThread[hCore->currentThread].GPR[rD]);
break;
}
}
Expand Down

0 comments on commit d2b3ca6

Please sign in to comment.