Commit graph

180 commits

Author SHA1 Message Date
Ronald Caesar
9224377fd9
arm64: Remove incomplete file 2025-08-16 18:54:02 -04:00
Ronald Caesar
97f2dcce45 Merge remote-tracking branch 'origin/aarch64'
Introduce the foundational support for emulating the AArch64 execution
state. This is the first major step towards running a guest operating
system.

    1. vCPU State: A structure that models the architectural state of an
       Arm64 vCPU. This includes the general-purpose registers, FP/SIMD
       vector registers, and the essential EL1 system registers
       (ELR_EL1, SPSR_EL1, ESR_EL1, FAR_EL1, VBAR_EL1) which are mandatory
       for handling exceptions.

    2. Guest Memory Model: A dedicated guest memory subsystem has been
       created to manage the emulated physical address space.

    3. Synchronous Exception Entry: This adds the core logic for taking
       synchronous exceptions. The new take_synchronous_exception() function
       emulates the hardware process of saving guest state, populating
       syndrome registers, and preparing the vCPU to enter an exception
       handler in EL1.

==========
GloriousTacoo (1):
      aarch64/cpu: added system registers to vcpu_state_t (#67)

Ronald Caesar (9):
      aarch64: Add core state structure for vCPU emulation
      aarch64: Correct vCPU register state and add FP/SIMD support
      aarch64/mem: Add fast GPA-to-HVA translation helper
      aarch64/mem: Fixed pointer arithmatic warning
      aarch64/mem: Introduce a dedicated guest memory access layer
      memory: Move arena allocator into pound::memory namespace
      aarch64/kernel: Add synchronous exception entry logic
      arm64: Renames the aarch64 directory to arm64
      arm64: Rename memory.h to guest.h

Sinan Karakaya (1):
      feat(aarch64): added system registers to vcpu_state_t

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 18:49:14 -04:00
Ronald Caesar
b11f04912d arm64: Rename memory.h to guest.h
The term "memory" is really ambiguous in the context of an emulator,
especially since the MMU is being developed. It can refer to host memory, or
guest memory, or both.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 18:17:59 -04:00
Ronald Caesar
58587bf754 arm64: Renames the aarch64 directory to arm64
The term "aarch64" is the formal name for Armv8-A architecture. However,
I found that the establish convention across the wider open source
ecosystem is to use the short name "arm64".

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 17:37:12 -04:00
Ronald Caesar
65f589e853 aarch64/kernel: Add synchronous exception entry logic
To handle faults such as data aborts, alignment faults, or supervisor
calls, the CPU must transition from the guest's context into a
privileged exception handler. This patch emulates the hardware sequence
for this entry process.

1. The vcpu_state_t struct includes the essential EL1 system registers
   required for exception handling (ELR_EL1, SPSR_EL1, ESR_EL1, FAR_EL1,
   and VBAR_EL1).

2. A new function, take_synchronous_exception(), is introduced. It
   models the requirements for entering an exception targeting EL1:
      - Saves the return address (PC) into ELR_EL1.
      - Saves the current proccess state (PSTATE) into SPSR_EL1.
      - Contructs the Exception Syndrome Register (ESR_EL1) from the
        provided Exception Class and ISS.
      - Saves the faulting address to FAR_EL1 for data aborts.
      - Updates the live PSTATE to a safe state for the handler.

This implementation is intentially partial. The final step of updating the
PC to jump to a handler in the guest's vector table (using VBAR_EL1) is
stubbed out. The vector table will contain assembly instructions so a
functional instruction decoder is required to fully complete the
exception handler.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 13:11:40 -04:00
Ronald Caesar
556ace64e8 memory: Move arena allocator into pound::memory namespace
The existing memory arena impelmentation is moved into the pound::memory
namespace to align with the pound::aarch64 namespace.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 12:58:51 -04:00
GloriousTacoo
3d8a69dd8e
aarch64/cpu: added system registers to vcpu_state_t (#67)
Sinan Karakaya says:

==============
 Adds the system registers for aarch64. They includes the one defined in Yuzu, but also include other from the armv8 specs that seems like they should be necessary for emulation.

Most of them might be subject to being removed in the future, if they turn out to not be required for emulation.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-14 20:42:41 -04:00
Ronald Caesar
e7b5349980 aarch64/mem: Introduce a dedicated guest memory access layer
This commit introduces a proper abstraction layer for all read and write
operations.

The previous approach of directly calculating a Host Virtual Address
(HVA) from a Guest Physical Address (GPA) via gpa_to_hva() forces every
part of the emulator that touches guest memory to be aware of the
underlying host pointer, which is poor design.

This new layer introduces a suite of guest_mem_read{b,w,l,q} and
guest_mem_write{b,w,l,q} fuctions. All future memory accesses from the
emulated CPU should be performed through these functions.

The code has also been moved into the pound::aarch64 namespace for
better organization.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-14 20:07:29 -04:00
Sinan Karakaya
883d676dd0
feat(aarch64): added system registers to vcpu_state_t 2025-08-14 02:01:17 +02:00
Ronald Caesar
c550b00dde aarch64/mem: Fixed pointer arithmatic warning
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-13 15:40:01 -04:00
Ronald Caesar
55af4bebda aarch64/mem: Add fast GPA-to-HVA translation helper
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>
2025-08-13 15:19:17 -04:00
Ronald Caesar
f15417802d aarch64: Correct vCPU register state and add FP/SIMD support
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>
2025-08-12 06:05:31 -04:00
Ronald Caesar
4456e23f7c aarch64: Add core state structure for vCPU emulation
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>
2025-08-10 19:01:26 -04:00
Sinan
a05e4c88a1
Feat: added support for std::allocator (#65)
* feat(memory): added arena_allocator for STL data types support
* fix(memory): fixed arena_allocate offset compute
2025-08-10 06:54:02 +00:00
Ronald Caesar
1300cc1535
aarch64: fix include file in jit
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:42:27 -04:00
Ronald Caesar
59e812bc63
aarch64: move cpu files to a new folder
The aarch64 folder will hold all cpu code from now on.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:25:47 -04:00
Ronald Caesar
b41e8b9d4f
memory: updated arena_init() docs
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>
2025-08-10 02:10:06 -04:00
Ronald Caesar
84c55b25a9
gui: initialize structs to default value
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:10:06 -04:00
Ronald Caesar
36bce8fa0a
gui: add asserts to guarantee behaviour
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:10:06 -04:00
Ronald Caesar
b38dce4ef1
gui: remove unnecessary blank line
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:10:06 -04:00
Ronald Caesar
6dbe756b2b
gui: updated gui_t code example docs
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>
2025-08-10 02:10:06 -04:00
Ronald Caesar
c89bb6ca7d
add .clang-format
This is to make the style of pound's code identical across all developers.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-10 02:10:06 -04:00
OwnedByWuigi
83d8045d2e
Update README.md 2025-08-08 00:18:47 +01:00
OwnedByWuigi
077c25d43e
re-add macOS ARM64 to the build.yml 2025-08-08 00:02:32 +01:00
OwnedByWuigi
4e090f9c89
Merge pull request #64 from Sinan-Karakaya/build/macos/arm
Build & Run support for MacOS ARM
2025-08-08 00:01:45 +01:00
Sinan Karakaya
fc7746e3a9
fix(gui): changed OpenGL version for macOS x64 and ARM 2025-08-06 17:58:42 +02:00
Sinan Karakaya
f5c383ffe6
feat(jit): added support for arm translate_and_run 2025-08-06 16:39:09 +02:00
OwnedByWuigi
33091fe066
Rewrite the entirety of Pound
feat!: rewrote program in a data oriented style.
2025-08-03 02:20:08 +01:00
Ronald Caesar
ba45834583
feat!: rewrote program in a data oriented style.
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>
2025-08-02 04:05:05 -04:00
Jack
653b84c264 new, better logo + fuck webp
lol
2025-07-25 12:41:18 -04:00
OwnedByWuigi
2dd3154dcb
Merge pull request #53 from EthanBoiLol/main
New logo change
2025-07-23 11:34:37 +01:00
Ethan_boi_dev
b86ed87605
Add files via upload 2025-07-22 20:20:53 -05:00
Ethan_boi_dev
c37b8feab6
Add files via upload
main svg file, for future use
2025-07-22 20:17:41 -05:00
OwnedByWuigi
56abf2eba6
Change from macos-14 (ARM) to macos-13 (x86-64) 2025-07-22 13:21:05 +01:00
OwnedByWuigi
ff2a43af86
Merge pull request #47 from Crazygamer212/patch-1
Update compguide.md
2025-07-22 13:18:20 +01:00
Crazygamer212
41a77dc458
Update compguide.md
the submodules need to be created on the ubuntu build as well
2025-07-19 21:14:47 +01:00
Xphalnos
ac472ea09a Update Submodules
imgui 1.92.0 -> 1.92.1
SDL3 3.2.16  -> 3.2.18
rem  -> latest
2025-07-15 11:53:57 +02:00
OwnedByWuigi
7918261214
Merge pull request #43 from GloriousTacoo/main
fix(memory): remove the inclusion of mman.h on windows.
2025-07-09 23:24:56 +01:00
Ronald Caesar
b603b978ea fix(memory): remove MAP_FAILED from windows builds
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-07-09 18:17:40 -04:00
Ronald Caesar
7897d0e2a2 fix(memory): remove the inclusion of mman.h on windows.
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-07-09 18:10:33 -04:00
Ronald Caesar
6ad2d300fb fix(memory): remove the inclusion of mman.h on windows.
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-07-09 17:56:39 -04:00
OwnedByWuigi
634e98f8d8
Merge pull request #42 from GloriousTacoo/main
fix(memory): Fixed missing mman.h include definitions
2025-07-09 22:48:23 +01:00
Ronald Caesar
d1ada1740a fix(memory): Fixed missing mman.h include definitions
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>
2025-07-09 17:38:10 -04:00
OwnedByWuigi
b9adfe0ff0
Merge pull request #41 from GloriousTacoo/revert-40-main
Revert "feat(gui): Enhance CPU panel with state management and GUI improvements"
2025-07-09 22:22:37 +01:00
GloriousTacoo
f69c918186
Revert "feat(gui): Enhance CPU panel with state management and GUI improvements" 2025-07-09 16:56:01 -04:00
OwnedByWuigi
5b432dbb0c
Merge pull request #40 from PezzottiCarlo/main
feat(gui): Enhance CPU panel with state management and GUI improvements
2025-07-09 10:59:26 +01:00
Carlo Pezzotti
6c84438948
Merge branch 'pound-emu:main' into main 2025-07-09 11:51:39 +02:00
Carlo Pezzotti
85559e249b feat(gui): Enhance CPU panel with state management and GUI improvements 2025-07-09 11:51:13 +02:00
OwnedByWuigi
94d0452a71
Merge pull request #39 from PezzottiCarlo/main
feat(gui): Extract and modularize GUI system from main.cpp
2025-07-09 08:19:40 +01:00
Carlo Pezzotti
2bb666a088 feat(gui): Extract and modularize GUI system from main.cpp
- 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
2025-07-09 09:07:32 +02:00