Bare minimum createAddressArbiter HLE

This commit is contained in:
wheremyfoodat 2022-09-15 18:43:20 +03:00
parent cd168bca56
commit e0204a1eff
7 changed files with 56 additions and 7 deletions

View file

@ -43,9 +43,11 @@ else()
message(FATAL_ERROR "THIS IS NOT x64 WAIT FOR THE KVM IMPLEMENTATION")
endif()
set(SOURCE_FILES src/main.cpp src/emulator.cpp src/core/CPU/cpu_dynarmic.cpp src/core/memory.cpp src/core/elf.cpp)
set(SOURCE_FILES src/main.cpp src/emulator.cpp src/core/CPU/cpu_dynarmic.cpp src/core/memory.cpp src/core/elf.cpp
src/core/kernel.cpp
)
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp include/termcolor.hpp
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp include/kernel.hpp
)
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp

View file

@ -3,12 +3,14 @@
#include "dynarmic/interface/A32/a32.h"
#include "dynarmic/interface/A32/config.h"
#include "helpers.hpp"
#include "kernel.hpp"
#include "memory.hpp"
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
public:
u64 ticks_left = 0;
Memory& mem;
Kernel& kernel;
u8 MemoryRead8(u32 vaddr) override {
return mem.read8(vaddr);
@ -49,7 +51,7 @@ public:
}
void CallSVC(u32 swi) override {
Helpers::panic("Called SVC %d", swi);
kernel.serviceSVC(swi);
}
void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override {
@ -68,7 +70,7 @@ public:
return ticks_left;
}
MyEnvironment(Memory& mem) : mem(mem) {}
MyEnvironment(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
};
class CPU {
@ -77,7 +79,7 @@ class CPU {
Memory& mem;
public:
CPU(Memory& mem);
CPU(Memory& mem, Kernel& kernel);
void reset();
void setReg(int index, u32 value) {

View file

@ -11,13 +11,15 @@
class Emulator {
CPU cpu;
Memory memory;
Kernel kernel;
sf::RenderWindow window;
static constexpr u32 width = 400;
static constexpr u32 height = 240 * 2; // * 2 because 2 screens
public:
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
cpu(memory) {
kernel(cpu.regs(), memory), cpu(memory, kernel) {
reset();
window.setActive(true);
}

22
include/kernel.hpp Normal file
View file

@ -0,0 +1,22 @@
#pragma once
#include <array>
#include "helpers.hpp"
#include "memory.hpp"
namespace SVCResult {
enum : u32 {
Success = 0
};
}
class Kernel {
std::array<u32, 16>& regs;
Memory& mem;
public:
Kernel(std::array<u32, 16>& regs, Memory& mem) : regs(regs), mem(mem) {}
void serviceSVC(u32 svc);
void reset();
void createAddressArbiter();
};

View file

@ -1,7 +1,7 @@
#ifdef CPU_DYNARMIC
#include "cpu_dynarmic.hpp"
CPU::CPU(Memory& mem) : mem(mem), env(mem) {}
CPU::CPU(Memory& mem, Kernel& kernel) : mem(mem), env(mem, kernel) {}
void CPU::reset() {
// ARM mode, all flags disabled, interrupts and aborts all enabled, user mode

20
src/core/kernel.cpp Normal file
View file

@ -0,0 +1,20 @@
#include "kernel.hpp"
void Kernel::serviceSVC(u32 svc) {
switch (svc) {
case 0x21: createAddressArbiter(); break;
default: Helpers::panic("Unimplemented svc: %x", svc); break;
}
}
void Kernel::reset() {
}
// Result CreateAddressArbiter(Handle* arbiter)
// in: r0 -> Pointer to Handle object
// out: r0 -> result
void Kernel::createAddressArbiter() {
printf("Stubbed call to CreateAddressArbiter. Handle address: %08X\n", regs[0]);
regs[0] = SVCResult::Success;
}

View file

@ -2,6 +2,7 @@
void Emulator::reset() {
cpu.reset();
kernel.reset();
}
void Emulator::step() {}