Skip to content

Commit

Permalink
Adding Some Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Xphalnos committed Jan 29, 2025
1 parent 2d1f1df commit bdde264
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 37 deletions.
9 changes: 4 additions & 5 deletions Xenon/Base/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ static bool isFullscreen = false;
Base::Log::Level currentLogLevel = Base::Log::Level::Info;

// SMC.
static int smcPowerOnReason =
0x11; // Valid values are: 0x11 (SMC_PWR_REAS_PWRBTN) and 0x12
// (SMC_PWR_REAS_EJECT).
static int smcPowerOnReason = 0x11; // Valid values are: 0x11 (SMC_PWR_REAS_PWRBTN) and 0x12
// (SMC_PWR_REAS_EJECT).
static int comPort = 2;
static std::string com = "";

Expand Down Expand Up @@ -156,9 +155,9 @@ void saveConfig(const std::filesystem::path &path) {
}
} else {
if (error) {
std::cout << "Filesystem error: " << error.message() << std::endl;
LOG_ERROR(Config, "Filesystem error: {}", error.message());
}
LOG_INFO(Config, "Config not found. Saving new configuration file: {}", path.string());
LOG_INFO(Config, "Config not found. Saving new configuration file: {}", path.string());
}

// General.
Expand Down
13 changes: 7 additions & 6 deletions Xenon/Core/NAND/NAND.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
// Copyright 2025 Xenon Emulator Project

#include "Base/Logging/Log.h"

#include "NAND.h"

/********************Responsible for loading the NAND file********************/
bool NAND::Load(const std::string filePath) {
std::cout << "NAND: Loading file " << filePath.c_str() << std::endl;
LOG_INFO(System, "NAND: Loading file {}", filePath.c_str());

if (fopen_s(&inputFile, filePath.c_str(), "rb") != 0) {
std::cout << "NAND: Unable to load file!" << std::endl;
LOG_CRITICAL(System, "NAND: Unable to load file!");
return false;
}

fseek(inputFile, 0, SEEK_END);
rawFileSize = ftell(inputFile);
fseek(inputFile, 0, SEEK_SET);

std::cout << "NAND: File size = 0x" << rawFileSize << " bytes." << std::endl;
LOG_INFO(System, "NAND: File size = 0x{} bytes.", rawFileSize);

CheckMagic();

if (!CheckMagic()) {
std::cout << "NAND: wrong magic found, Xbox 360 Retail NAND magic"
<< "is 0xFF4F and Devkit NAND magic 0x0F4F." << std::endl;
LOG_ERROR(System, "NAND: wrong magic found, Xbox 360 Retail NAND magic is 0xFF4F and Devkit NAND magic 0x0F4F.");
return false;
}

Expand All @@ -37,7 +38,7 @@ bool NAND::Load(const std::string filePath) {
CheckSpare();

if (hasSpare) {
std::cout << "NAND: Image has spare." << std::endl;
LOG_INFO(System, "NAND: Image has spare.");

// Check Meta Type
imageMetaType = DetectSpareType();
Expand Down
1 change: 0 additions & 1 deletion Xenon/Core/NAND/NAND.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

#include <fstream>
#include <iostream>

#include "Base/SystemDevice.h"

Expand Down
26 changes: 11 additions & 15 deletions Xenon/Core/RootBus/HostBridge/PCIBridge/SFCX/SFCX.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2025 Xenon Emulator Project

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

#include "SFCX.h"

Expand All @@ -13,7 +12,7 @@ SFCX::SFCX(const std::string nandLoadPath, PCIBridge *parentPCIBridge) {
pciConfigSpace.configSpaceHeader.reg0.vendorID = 0x1414;
pciConfigSpace.configSpaceHeader.reg0.deviceID = 0x580B;

std::cout << "Xenon Secure Flash Controller for Xbox" << std::endl;
LOG_INFO(SFCX, "Xenon Secure Flash Controller for Xbox.");

// Set the registers as a dump from my Corona 16MB. These were dumped at POR
// via Xell before SFCX Init. These are also readable via JRunner and
Expand All @@ -35,20 +34,18 @@ SFCX::SFCX(const std::string nandLoadPath, PCIBridge *parentPCIBridge) {
sfcxState.commandReg = NO_CMD;

// Load the NAND dump.
std::cout << "SFCX: Loading NAND from path: " << nandLoadPath << std::endl;
LOG_INFO(SFCX, "Loading NAND from path: {}", nandLoadPath);

fopen_s(&nandFile, nandLoadPath.c_str(), "rb");

if (!nandFile) {
std::cout << "SFCX: Fatal error, check your nand dump path." << std::endl;
LOG_CRITICAL(SFCX, "Fatal error, check your nand dump path.");
system("PAUSE");
}

// Check file magic.
if (!checkMagic()) {
std::cout << "SFCX: Fatal error, loaded faile magic does'nt correspond to "
"Xbox 360 NAND."
<< std::endl;
LOG_CRITICAL(SFCX, "Fatal error, loaded faile magic does'nt correspond to Xbox 360 NAND.");
system("PAUSE");
}

Expand Down Expand Up @@ -166,7 +163,7 @@ void SFCX::Read(u64 readAddress, u64 *data, u8 byteCount) {
*data = sfcxState.mmcIDReg;
break;
default:
std::cout << "SFCX: Read from unknown register 0x" << reg << std::endl;
LOG_ERROR(SFCX, "Read from unknown register 0x{}", reg);
break;
}
}
Expand Down Expand Up @@ -212,7 +209,7 @@ void SFCX::Write(u64 writeAddress, u64 data, u8 byteCount) {
sfcxState.mmcIDReg = (u32)data;
break;
default:
std::cout << "SFCX: Write to unknown register 0x" << reg << std::endl;
LOG_ERROR(SFCX, "Write from unknown register 0x{}", reg);
break;
}
}
Expand Down Expand Up @@ -272,8 +269,7 @@ void SFCX::sfcxMainLoop() {
// case UNLOCK_CMD_1:
// break;
default:
std::cout << "SFCX: Unrecognized command was issued. 0x"
<< sfcxState.commandReg << std::endl;
LOG_ERROR(SFCX, "Unrecognized command was issued. 0x{}", sfcxState.commandReg);
break;
}

Expand All @@ -298,15 +294,15 @@ bool SFCX::checkMagic() {
// Older Devkit Nand's magic is 0x0F3F.

if (magic[0] == (char)0xff && magic[1] == (char)0x4f) {
std::cout << "SFCX: Retail NAND Magic found." << std::endl;
LOG_INFO(SFCX, "Retail NAND Magic found.");
return true;
}
if (magic[0] == (char)0x0f && magic[1] == (char)0x4f) {
std::cout << "SFCX: Devkit NAND Magic found." << std::endl;
LOG_INFO(SFCX, "Devkit NAND Magic found.");
return true;
}
if (magic[0] == (char)0x0f && magic[1] == (char)0x3f) {
std::cout << "SFCX: Old Devkit NAND Magic found." << std::endl;
LOG_INFO(SFCX, "Old Devkit NAND Magic found.");
return true;
}
return false;
Expand Down
1 change: 0 additions & 1 deletion Xenon/Core/RootBus/HostBridge/PCIBridge/SFCX/SFCX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <iostream>
#include <thread>

#include "Core/RootBus/HostBridge/PCIBridge/PCIBridge.h"
Expand Down
10 changes: 3 additions & 7 deletions Xenon/Core/XCPU/Xenon.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2025 Xenon Emulator Project

#include <chrono>
#include <fstream>
#include "Base/Logging/Log.h"

#include "Xenon.h"

Expand Down Expand Up @@ -32,9 +31,7 @@ Xenon::Xenon(RootBus *inBus, const std::string blPath, eFuses inFuseSet) {
fopen_s(&inputFile, blPath.c_str(), "rb");

if (!inputFile) {
std::cout << "Xenon: Unable to open file: " << blPath
<< " for reading. Check your file path. System Stopped!"
<< std::endl;
LOG_CRITICAL(Xenon, "Unable to open file: {} for reading. Check your file path. System Stopped!", blPath);
system("PAUSE");
} else {
fseek(inputFile, 0, SEEK_END);
Expand All @@ -43,8 +40,7 @@ Xenon::Xenon(RootBus *inBus, const std::string blPath, eFuses inFuseSet) {

if (fileSize == XE_SROM_SIZE) {
fread(xenonContext.SROM, 1, XE_SROM_SIZE, inputFile);

std::cout << "Xenon: * 1BL loaded." << std::endl;
LOG_INFO(Xenon, "1BL Loaded.");
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Xenon/Core/XGPU/XGPU.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2025 Xenon Emulator Project

#include <iostream>

#include "XGPU.h"
#include "XGPUConfig.h"
#include "XenosRegisters.h"
Expand Down
1 change: 1 addition & 0 deletions Xenon/Xe_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ int main(int argc, char *argv[]) {

// First initialize the logging backend.
Base::Log::Initialize();
Base::Log::Start();

// Load configuration.
const auto user_dir = Base::FS::GetUserPath(Base::FS::PathType::UserDir);
Expand Down

0 comments on commit bdde264

Please sign in to comment.