In emulating guests with a simple, flat memory model, we frequently need
to translate a guest physical address (GPA) into a host virtual address
(HVA). This is a hot path operation that must be efficient as possible.
This commit introduces gpa_to_hva(), a static inline helper function
designed for this purpose. The implementation relies on the fundamental
pre-condition that the guest's physical RAM is backed by a single,
contiguous region of host virtual memory (typically acquired via mmap).
It treats the GPA not as a pointer but as a direct byte offset from the
base of this host mapping.
This approach is optimal for performance for two key reasons:
1. The translation is a single pointer-offset calculation, which
typically compiles to a single LEA intruction on x86-64.
2. It preserves memory access locality. When a guest performs
sequential accesses, the host's accesses are also sequential,
allowing the host CPU's hardware prefetcher to function effectively.
This helper provides the fast path for simple RAM accesses. More
complex address spaces involving discontiguous memory or MMIO regions
will require a slower, lookup-based translation mechanism. This
function is not intended for those cases.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The initial vCPU state for AArch64 had a couple of architectural
inaccuracies that this commit corrects.
First, AArch64 has 32 general-purpose registers (X0-X31), not 31.
The stack pointer (SP) is not a separate special-purpose register
but is an alias for register X31. The dedicated `sp` field in
vcpu_state_t was therefore redundant and architecturally incorrect.
This change increases GP_REGISTERS to 32 and removes the separate
`sp` field. The SP should be managed via `r[31]`.
Second, to support floating-point and SIMD instructions, the vCPU
state must include the vector registers. This adds the definitions
and storage for the 32 128-bit FP/SIMD registers (V0-V31).
Signed-off-by: Ronald Caesar <github43132@proton.me>
Introduce the basic data structures required to manage the architectural
state of an emulated ARMv8 guest. This is a foundational patch for a
forthcoming emulator framework.
The core of this change is the `vcpu_state_t` structure, which holds
the essential user-visible state of a single virtual CPU (vCPU),
including the general-purpose registers, stack pointer, program counter,
and PSTATE.
The state for all vCPUs is aligned to the CPU L1 cache line. This design
choice ensures that there is no false sharing between physical host
cores running separate vCPU emulation threads.
Signed-off-by: Ronald Caesar <github43132@proton.me>
arena_init() has been given the parameter `size_t capacity`, however,
docs amd some definitions wasn't changed to reflect this.
The definition MEMORY_CAPACITY was replaced by `size_t capacity` but
it wasn't removed.
Signed-off-by: Ronald Caesar <github43132@proton.me>
gui::init() was removed in favour of gui::init_imgui() and the docs for
gui_t was not updated to reflect the change.
Signed-off-by: Ronald Caesar <github43132@proton.me>
This is because the source code is objected oriented which is not cpu cache
friendly, making the program slower than it has to be. Yuzu's entire
codebase is written in a objected oriented way and I wonder how much faster
it could if they had use DoD principles from the very beginning.
That's why I want to instill DoD fundamentals early on so this won't be a
problem going forward.
Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit removes a custom mmap() function which was supposed
to support both windows and linux but the linux and macOS builds
failed to compile.
The custom mmap() function will be replaced by malloc() for windows
and linux's native mmap().
Signed-off-by: Ronald Caesar <github43132@proton.me>
- Create modular GUI architecture with base Panel class
- Implement GUIManager to handle window lifecycle and panel management
- Add Window wrapper class for SDL3/OpenGL context management
- Create specialized panels:
- ConsolePanel: Colored log output with timestamps
- CPUPanel: CPU debugging with tabs for registers, memory, and disassembly
- PerformancePanel: Real-time FPS and frame time monitoring
- Apply modern dark theme with purple accents
- Add comprehensive menu bar (File, Emulation, View, Tools, Help)
- Update CMakeLists.txt to include new gui/ directory structure
- Refactor main.cpp to use the new GUI system
- Cutom theme on switch colors
I wanted a fast and predictable memory allocator before I start working on the virtual filesystem.
Functions like malloc and realloc will not be used anymore, instead, the allocator will
need to be passed as a function parameter when doing any kind of heap allocation. For example
char* create_string(Memory::Arena *allocator);
int* create_int_array(Memory::Arena *allocator, int size);
The definition MEMORY_CAPACITY in arena.h sets the amount of memory the arena can use.
The number can be increased as needed.
Signed-off-by: Ronald Caesar <github43132@proton.me>