Fix uninitialized warning and remove header pollution

This commit is contained in:
wheremyfoodat 2025-08-07 21:30:25 +03:00
commit 90a048afc2
14 changed files with 60 additions and 91 deletions

View file

@ -1,71 +1,51 @@
#pragma once #pragma once
#include "dynarmic/interface/A32/a32.h"
#include "dynarmic/interface/A32/config.h" #include "dynarmic/interface/A32/config.h"
#include "dynarmic/interface/A32/coprocessor.h" #include "dynarmic/interface/A32/coprocessor.h"
#include "helpers.hpp" #include "helpers.hpp"
#include "memory.hpp"
class CP15 final : public Dynarmic::A32::Coprocessor { class CP15 final : public Dynarmic::A32::Coprocessor {
using Callback = Dynarmic::A32::Coprocessor::Callback; using Callback = Dynarmic::A32::Coprocessor::Callback;
using CoprocReg = Dynarmic::A32::CoprocReg; using CoprocReg = Dynarmic::A32::CoprocReg;
using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord; using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord;
using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords; using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords;
u32 threadStoragePointer; // Pointer to thread-local storage u32 threadStoragePointer; // Pointer to thread-local storage
u32 dummy; // MCR writes here for registers whose values are ignored u32 dummy; // MCR writes here for registers whose values are ignored
std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1, std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1, CoprocReg CRd, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override {
CoprocReg CRd, CoprocReg CRn, return std::nullopt;
CoprocReg CRm, unsigned opc2) override { }
return std::nullopt;
}
CallbackOrAccessOneWord CompileSendOneWord(bool two, unsigned opc1, CoprocReg CRn, CallbackOrAccessOneWord CompileSendOneWord(bool two, unsigned opc1, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override {
CoprocReg CRm, unsigned opc2) override { if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 4) {
if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 4) { return &dummy; // Normally inserts a "Data Synchronization Barrier"
return &dummy; // Normally inserts a "Data Synchronization Barrier" }
}
if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 5) { if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 5) {
return &dummy; // Normally inserts a "Data Memory Barrier" return &dummy; // Normally inserts a "Data Memory Barrier"
} }
Helpers::panic("CP15: CompileSendOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); Helpers::panic("CP15: CompileSendOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2);
} }
CallbackOrAccessTwoWords CompileSendTwoWords(bool two, unsigned opc, CoprocReg CRm) override { CallbackOrAccessOneWord CompileGetOneWord(bool two, unsigned opc1, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override {
return std::monostate{}; // Stores a pointer to thread-local storage, accessed via mrc p15, 0, rd, c13, c0, 3
} if (!two && CRn == CoprocReg::C13 && opc1 == 0 && CRm == CoprocReg::C0 && opc2 == 3) {
return &threadStoragePointer;
}
CallbackOrAccessOneWord CompileGetOneWord(bool two, unsigned opc1, CoprocReg CRn, Helpers::panic("CP15: CompileGetOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2);
CoprocReg CRm, unsigned opc2) override { }
// Stores a pointer to thread-local storage, accessed via mrc p15, 0, rd, c13, c0, 3
if (!two && CRn == CoprocReg::C13 && opc1 == 0 && CRm == CoprocReg::C0 && opc2 == 3) {
return &threadStoragePointer;
}
Helpers::panic("CP15: CompileGetOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); CallbackOrAccessTwoWords CompileSendTwoWords(bool two, unsigned opc, CoprocReg CRm) override { return std::monostate{}; }
} CallbackOrAccessTwoWords CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) override { return std::monostate{}; }
CallbackOrAccessTwoWords CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) override { std::optional<Callback> CompileLoadWords(bool two, bool long_transfer, CoprocReg CRd, std::optional<u8> option) override { return std::nullopt; }
return std::monostate{}; std::optional<Callback> CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, std::optional<u8> option) override { return std::nullopt; }
}
std::optional<Callback> CompileLoadWords(bool two, bool long_transfer, CoprocReg CRd, public:
std::optional<u8> option) override { void setTLSBase(u32 value) { threadStoragePointer = value; }
return std::nullopt;
}
std::optional<Callback> CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, // Currently does nothing but may be needed in the future
std::optional<u8> option) override { void reset() {}
return std::nullopt;
}
public:
void setTLSBase(u32 value) {
threadStoragePointer = value;
}
// Currently does nothing but may be needed in the future
void reset() {}
}; };

View file

@ -24,12 +24,6 @@
#include "http_server.hpp" #include "http_server.hpp"
#endif #endif
#ifdef PANDA3DS_FRONTEND_QT
#include "gl/context.h"
#endif
struct SDL_Window;
enum class ROMType { enum class ROMType {
None, None,
ELF, ELF,

View file

@ -3,10 +3,8 @@
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <iostream> #include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <memory> #include <memory>
#include <string>
#include "termcolor.hpp" #include "termcolor.hpp"
@ -37,7 +35,7 @@ namespace Helpers {
return {}; return {};
} }
const auto buf = std::make_unique<char[]>(size); const auto buf = std::make_unique<char[]>(size);
std::snprintf(buf.get(), size, fmt.c_str(), args ...); std::snprintf(buf.get(), size, fmt.c_str(), args...);
return std::string(buf.get(), buf.get() + size - 1); return std::string(buf.get(), buf.get() + size - 1);
} }
@ -50,7 +48,7 @@ namespace Helpers {
exit(1); exit(1);
} }
#ifdef PANDA3DS_LIMITED_PANICS #ifdef PANDA3DS_LIMITED_PANICS
template <class... Args> template <class... Args>
static void panicDev(const char* fmt, Args&&... args) {} static void panicDev(const char* fmt, Args&&... args) {}

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <array> #include <array>
#include <cassert>
#include <limits>
#include <span> #include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@ -26,8 +24,10 @@ class Kernel {
CPU& cpu; CPU& cpu;
Memory& mem; Memory& mem;
public:
KFcram fcramManager; KFcram fcramManager;
private:
// The handle number for the next kernel object to be created // The handle number for the next kernel object to be created
u32 handleCounter; u32 handleCounter;
// A list of our OS threads, the max number of which depends on the resource limit (hardcoded 32 per process on retail it seems). // A list of our OS threads, the max number of which depends on the resource limit (hardcoded 32 per process on retail it seems).
@ -250,7 +250,6 @@ class Kernel {
} }
ServiceManager& getServiceManager() { return serviceManager; } ServiceManager& getServiceManager() { return serviceManager; }
KFcram& getFcramManager() { return fcramManager; }
Scheduler& getScheduler(); Scheduler& getScheduler();
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); } void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }

View file

@ -2,10 +2,8 @@
#include <array> #include <array>
#include <cstring> #include <cstring>
#include "fs/archive_base.hpp"
#include "handles.hpp" #include "handles.hpp"
#include "helpers.hpp" #include "helpers.hpp"
#include "result/result.hpp"
enum class KernelObjectType : u8 { enum class KernelObjectType : u8 {
AddressArbiter, AddressArbiter,

View file

@ -9,10 +9,6 @@
#include "PICA/regs.hpp" #include "PICA/regs.hpp"
#include "helpers.hpp" #include "helpers.hpp"
#ifdef PANDA3DS_FRONTEND_QT
#include "gl/context.h"
#endif
enum class RendererType : s8 { enum class RendererType : s8 {
// Todo: Auto = -1, // Todo: Auto = -1,
Null = 0, Null = 0,
@ -23,7 +19,6 @@ enum class RendererType : s8 {
}; };
struct EmulatorConfig; struct EmulatorConfig;
struct SDL_Window;
class GPU; class GPU;
class ShaderUnit; class ShaderUnit;

View file

@ -2,6 +2,8 @@
#include <Metal/Metal.hpp> #include <Metal/Metal.hpp>
#include "helpers.hpp"
namespace Metal { namespace Metal {
struct RenderState { struct RenderState {
MTL::RenderPipelineState* renderPipelineState = nullptr; MTL::RenderPipelineState* renderPipelineState = nullptr;

View file

@ -2,6 +2,7 @@
#include <map> #include <map>
#include "helpers.hpp"
#include "pica_to_mtl.hpp" #include "pica_to_mtl.hpp"
using namespace PICA; using namespace PICA;
@ -17,7 +18,6 @@ namespace Metal {
class DepthStencilCache { class DepthStencilCache {
public: public:
DepthStencilCache() = default; DepthStencilCache() = default;
~DepthStencilCache() { reset(); } ~DepthStencilCache() { reset(); }
void set(MTL::Device* dev) { device = dev; } void set(MTL::Device* dev) { device = dev; }

View file

@ -2,6 +2,7 @@
#include <map> #include <map>
#include "helpers.hpp"
#include "objc_helper.hpp" #include "objc_helper.hpp"
#include "pica_to_mtl.hpp" #include "pica_to_mtl.hpp"

View file

@ -2,19 +2,22 @@
#include <Metal/Metal.hpp> #include <Metal/Metal.hpp>
#include "helpers.hpp"
namespace Metal { namespace Metal {
class LutTexture { class LutTexture {
public: public:
LutTexture(MTL::Device* device, MTL::TextureType type, MTL::PixelFormat pixelFormat, u32 width, u32 height, const char* name); LutTexture(MTL::Device* device, MTL::TextureType type, MTL::PixelFormat pixelFormat, u32 width, u32 height, const char* name);
~LutTexture(); ~LutTexture();
u32 getNextIndex(); u32 getNextIndex();
MTL::Texture* getTexture() { return texture; } MTL::Texture* getTexture() { return texture; }
u32 getCurrentIndex() { return currentIndex; } u32 getCurrentIndex() { return currentIndex; }
private:
MTL::Texture* texture;
u32 currentIndex = 0;
};
} // namespace Metal private:
MTL::Texture* texture;
u32 currentIndex = 0;
};
} // namespace Metal

View file

@ -5,7 +5,6 @@
#include "helpers.hpp" #include "helpers.hpp"
#include "pica_to_mtl.hpp" #include "pica_to_mtl.hpp"
using namespace PICA; using namespace PICA;
namespace Metal { namespace Metal {

View file

@ -3,6 +3,7 @@
#include <Metal/Metal.hpp> #include <Metal/Metal.hpp>
#include "PICA/regs.hpp" #include "PICA/regs.hpp"
#include "helpers.hpp"
// TODO: remove dependency on OpenGL // TODO: remove dependency on OpenGL
#include "opengl.hpp" #include "opengl.hpp"

View file

@ -4,7 +4,6 @@
#include <limits> #include <limits>
#include "helpers.hpp" #include "helpers.hpp"
#include "logger.hpp"
struct Scheduler { struct Scheduler {
enum class EventType { enum class EventType {

View file

@ -20,8 +20,8 @@ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
Emulator::Emulator() Emulator::Emulator()
: config(getConfigPath()), kernel(cpu, memory, gpu, config, lua), cpu(memory, kernel, *this), gpu(memory, config), : config(getConfigPath()), kernel(cpu, memory, gpu, config, lua), cpu(memory, kernel, *this), gpu(memory, config),
memory(kernel.getFcramManager(), config), cheats(memory, kernel.getServiceManager().getHID()), audioDevice(config.audioDeviceConfig), memory(kernel.fcramManager, config), cheats(memory, kernel.getServiceManager().getHID()), audioDevice(config.audioDeviceConfig), lua(*this),
lua(*this), running(false) running(false)
#ifdef PANDA3DS_ENABLE_HTTP_SERVER #ifdef PANDA3DS_ENABLE_HTTP_SERVER
, ,
httpServer(this) httpServer(this)