mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-13 13:37:02 +00:00
kvm: Add framework for machine types and MMIO dispatch
The core of the machine-type support is the new operations table, kvm_ops_t. This acts as a standard C-style virtual table decoupling the generic KVM core logic from target specific hardware emualtion. The kvm_t VM instance now points to an ops table, which defines the "personality" of the guest. A kvm_probe() factory function has been added to initialize a kvm_t instance with the correct ops table for a given machine type (eg, Switch 1). The ops table's .mmio_read and .mmio_write function pointers are the link between the armv8 CPU core and this new MMIO dispatcher. When a physical memory access is determined to be MMIO, the VM will call the appropriate function pointer, which in turn will use the MMIO dispatcher to find and execute the correct device handler. The initial implementation for the Switch 1 target (targets/switch1/hardware/probe.cpp) is a stub. The bootstrapping logic will be added in subsequent patches. Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
parent
dea94dc259
commit
c6706dd8a0
57 changed files with 533 additions and 70 deletions
111
src/common/Config.cpp
Normal file
111
src/common/Config.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2025 Pound Emulator Project. All rights reserved.
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
|
||||
static int widthWindow = 640;
|
||||
|
||||
static int heightWindow = 480;
|
||||
|
||||
static bool logAdvanced = false;
|
||||
|
||||
static std::string typeLog = "async";
|
||||
|
||||
int windowWidth()
|
||||
{
|
||||
return widthWindow;
|
||||
}
|
||||
|
||||
int windowHeight()
|
||||
{
|
||||
return heightWindow;
|
||||
}
|
||||
|
||||
bool isLogAdvanced()
|
||||
{
|
||||
return logAdvanced;
|
||||
}
|
||||
|
||||
std::string logType()
|
||||
{
|
||||
return typeLog;
|
||||
}
|
||||
|
||||
void Load(const std::filesystem::path& path)
|
||||
{
|
||||
/*
|
||||
// If the configuration file does not exist, create it and return
|
||||
std::error_code error;
|
||||
if (!std::filesystem::exists(path, error))
|
||||
{
|
||||
Save(path);
|
||||
return;
|
||||
}
|
||||
|
||||
toml::value data;
|
||||
|
||||
try
|
||||
{
|
||||
data = toml::parse(path);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
if (data.contains("General"))
|
||||
{
|
||||
const toml::value& general = data.at("General");
|
||||
|
||||
widthWindow = toml::find_or<int>(general, "Window Width", 640);
|
||||
heightWindow = toml::find_or<int>(general, "Window Height", 480);
|
||||
|
||||
logAdvanced = toml::find_or<bool>(general, "Advanced Log", false);
|
||||
typeLog = toml::find_or<std::string>(general, "Log Type", "async");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Save(const std::filesystem::path& path)
|
||||
{
|
||||
/*
|
||||
toml::ordered_value data;
|
||||
|
||||
std::error_code error;
|
||||
if (std::filesystem::exists(path, error))
|
||||
{
|
||||
try
|
||||
{
|
||||
data = toml::parse(path);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
fmt::print("Filesystem error: {}\n", error.message());
|
||||
}
|
||||
fmt::print("Saving new configuration file {}\n", path.string());
|
||||
}
|
||||
|
||||
data["General"]["Window Width"] = widthWindow;
|
||||
data["General"]["Window Height"] = heightWindow;
|
||||
data["General"]["Advanced Log"] = logAdvanced;
|
||||
data["General"]["Log Type"] = typeLog;
|
||||
|
||||
std::ofstream file(path, std::ios::binary);
|
||||
file << data;
|
||||
file.close();
|
||||
*/
|
||||
}
|
||||
|
||||
} // namespace Config
|
||||
Loading…
Add table
Add a link
Reference in a new issue