Turn SysCalls into a C++ file

This commit is contained in:
Björn Gaier
2023-10-06 10:27:03 +02:00
parent 37e63d66f4
commit 074e2d073f
12 changed files with 228 additions and 227 deletions

View File

@@ -2,12 +2,12 @@
#include "../../internal-include/CD/cd_internal.hpp"
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/memory_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/System/syscalls.hpp>
namespace JabyEngine {
namespace CD {
namespace internal {
extern InterrupCallback callback;
extern SysCall::InterrupCallback callback;
}
}
@@ -21,11 +21,11 @@ namespace JabyEngine {
static constexpr auto DebugScale = 1.0;
__debug_boot_color_at(::JabyEngine::GPU::Color24::White(), DebugX, DebugY, DebugScale);
__syscall_EnterCriticalSection();
SysCall::EnterCriticalSection();
Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::create());
Memory_IO::CD_DELAY.write(Memory_IO::CD_DELAY::create());
__syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback);
SysCall::SysEnqIntRP(SysCall::Priority::CdromIoIrq, &::JabyEngine::CD::internal::callback);
CD_IO::PortIndex1::change_to();
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
@@ -34,7 +34,7 @@ namespace JabyEngine {
Interrupt::enable_irq(Interrupt::CDROM);
Interrupt::ack_irq(Interrupt::CDROM);
__syscall_ExitCriticalSection();
SysCall::ExitCriticalSection();
__debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale);
CD_IO::PortIndex0::change_to();

View File

@@ -3,6 +3,7 @@
#include <PSX/Auxiliary/lz4_decompressor.hpp>
#include <PSX/File/Processor/file_processor.hpp>
#include <PSX/GPU/gpu.hpp>
#include <PSX/System/syscalls.hpp>
#include <stdio.h>
#ifdef JABYENGINE_PAL
@@ -16,7 +17,7 @@ extern "C" uint32_t __boot_loader_end;
namespace JabyEngine {
namespace GPU {
namespace internal {
extern InterrupCallback callback;
extern SysCall::InterrupCallback callback;
}
}
@@ -72,10 +73,10 @@ namespace JabyEngine {
GPU::internal::wait_ready_for_CMD();
GPU::internal::quick_fill_fast(Color24::Black(), {PositionU16::create(0, 0), SizeU16::create(Display::Width, Display::Height)});
__syscall_EnterCriticalSection();
__syscall_SysEnqIntRP(VblankIrq, &::JabyEngine::GPU::internal::callback);
SysCall::EnterCriticalSection();
SysCall::SysEnqIntRP(SysCall::Priority::VblankIrq, &::JabyEngine::GPU::internal::callback);
Interrupt::enable_irq(Interrupt::VBlank);
__syscall_ExitCriticalSection();
SysCall::ExitCriticalSection();
}
}
}

View File

@@ -1,12 +1,12 @@
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/System/syscalls.hpp>
#define private public
#include <PSX/Timer/high_res_timer.hpp>
#undef private
namespace JabyEngine {
namespace Timer {
extern InterrupCallback IRQCallback;
extern SysCall::InterrupCallback IRQCallback;
}
namespace boot {
@@ -22,9 +22,9 @@ namespace JabyEngine {
// Having the interrupt fire every 10ms will slow us down slightly so we only do it on demand
Interrupt::disable_irq(Interrupt::Timer2);
__syscall_EnterCriticalSection();
__syscall_SysEnqIntRP(Timer2Irq, &IRQCallback);
__syscall_ExitCriticalSection();
SysCall::EnterCriticalSection();
SysCall::SysEnqIntRP(SysCall::Priority::Timer2Irq, &IRQCallback);
SysCall::ExitCriticalSection();
Counter2.set_target_value(HighResTime::TicksFor10ms);
Counter2.set_mode(Mode);

View File

@@ -1,26 +1,26 @@
#include "../../internal-include/CD/cd_internal.hpp"
#include <PSX/System/IOPorts/dma_io.hpp>
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/System/syscalls.hpp>
namespace JabyEngine {
namespace CD {
namespace internal {
static constexpr auto DataSectorMode = CD_IO::Mode::from(CD_IO::Mode::DoubleSpeed, CD_IO::Mode::DataSector);
static InterruptVerifierResult interrupt_verifier();
static void interrupt_handler(uint32_t);
static SysCall::InterruptVerifierResult interrupt_verifier();
static uint32_t interrupt_handler(uint32_t);
static SectorBufferAllocator sector_allocator;
static uint32_t cur_lba;
static uint32_t dst_lba;
CD_IO::Interrupt::Type last_interrupt = CD_IO::Interrupt::Type::None;
uint8_t cmd_interrupt_bit = 0;
State current_state = State::Free;
InterrupCallback callback = {
CD_IO::Interrupt::Type last_interrupt = CD_IO::Interrupt::Type::None;
uint8_t cmd_interrupt_bit = 0;
State current_state = State::Free;
SysCall::InterrupCallback callback = {
.next = nullptr,
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
.handler_function = interrupt_handler,
.verifier_function = interrupt_verifier
};
@@ -68,17 +68,17 @@ namespace JabyEngine {
// Doesn't seem to important when we can use DMA
}
static InterruptVerifierResult interrupt_verifier() {
static SysCall::InterruptVerifierResult interrupt_verifier() {
if(Interrupt::is_irq(Interrupt::CDROM)) {
return InterruptVerifierResult::ExecuteHandler;
return SysCall::InterruptVerifierResult::ExecuteHandler;
}
else {
return InterruptVerifierResult::SkipHandler;
return SysCall::InterruptVerifierResult::SkipHandler;
}
}
static void interrupt_handler(uint32_t) {
static uint32_t interrupt_handler(uint32_t) {
const auto old_status = CD_IO::IndexStatus.read();
CD_IO::PortIndex1::change_to();
@@ -114,7 +114,8 @@ namespace JabyEngine {
// No masking required because we can only write bit 0 - 2
CD_IO::IndexStatus.write(old_status);
Interrupt::ack_irq(Interrupt::CDROM);
__syscall_ReturnFromException();
SysCall::ReturnFromException();
__builtin_unreachable();
}
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator) {

View File

@@ -4,40 +4,41 @@
#include <PSX/Timer/frame_timer.hpp>
#undef private
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/System/syscalls.hpp>
namespace JabyEngine {
namespace GPU {
uint8_t Display :: current_id = 1; //< Setup will call exchange and set it to 0
namespace internal {
static InterruptVerifierResult interrupt_verifier();
static void interrupt_handler(uint32_t);
static SysCall::InterruptVerifierResult interrupt_verifier();
static uint32_t interrupt_handler(uint32_t);
static uint8_t vsync_counter = 0;
InterrupCallback callback = {
SysCall::InterrupCallback callback = {
.next = nullptr,
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
.handler_function = interrupt_handler,
.verifier_function = interrupt_verifier
};
static InterruptVerifierResult interrupt_verifier() {
static SysCall::InterruptVerifierResult interrupt_verifier() {
if(Interrupt::is_irq(Interrupt::VBlank)) {
return InterruptVerifierResult::ExecuteHandler;
return SysCall::InterruptVerifierResult::ExecuteHandler;
}
else {
return InterruptVerifierResult::SkipHandler;
return SysCall::InterruptVerifierResult::SkipHandler;
}
}
static void interrupt_handler(uint32_t) {
static uint32_t interrupt_handler(uint32_t) {
vsync_counter++;
MasterTime::value++;
Interrupt::ack_irq(Interrupt::VBlank);
__syscall_ReturnFromException();
SysCall::ReturnFromException();
__builtin_unreachable();
}
uint32_t Display :: exchange_buffer_and_display() {

View File

@@ -1,6 +1,6 @@
#define private public
#include <PSX/System/IOPorts/timer_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/System/syscalls.hpp>
#include <PSX/Timer/high_res_timer.hpp>
#undef private
@@ -8,26 +8,27 @@ namespace JabyEngine {
volatile uint16_t HighResTime :: global_counter_10ms = 0;
namespace Timer {
static InterruptVerifierResult interrupt_verifier() {
static SysCall::InterruptVerifierResult interrupt_verifier() {
if(Interrupt::is_irq(Interrupt::Timer2)) {
return InterruptVerifierResult::ExecuteHandler;
return SysCall::InterruptVerifierResult::ExecuteHandler;
}
else {
return InterruptVerifierResult::SkipHandler;
return SysCall::InterruptVerifierResult::SkipHandler;
}
}
static void interrupt_handler(uint32_t) {
static uint32_t interrupt_handler(uint32_t) {
HighResTime::global_counter_10ms = HighResTime::global_counter_10ms + 1;
Interrupt::ack_irq(Interrupt::Timer2);
__syscall_ReturnFromException();
SysCall::ReturnFromException();
__builtin_unreachable();
}
InterrupCallback IRQCallback = {
SysCall::InterrupCallback IRQCallback = {
.next = nullptr,
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
.handler_function = interrupt_handler,
.verifier_function = interrupt_verifier
};
}

View File

@@ -2,10 +2,10 @@
.set noreorder
.section .text, "ax", @progbits
.align 2
.global __syscall_printf
.type __syscall_printf, @function
.global _ZN10JabyEngine7SysCall6printfEPKcz
.type _ZN10JabyEngine7SysCall6printfEPKcz, @function
__syscall_printf:
_ZN10JabyEngine7SysCall6printfEPKcz:
li $t2, 0xa0
jr $t2
li $t1, 0x3f