Save progress
This commit is contained in:
parent
ec6b93942c
commit
7824a2d916
|
@ -19,6 +19,18 @@ namespace JabyEngine {
|
||||||
|
|
||||||
__declare_io_port_global(ComplexBitMap<uint32_t>, Status, 0x1F801070);
|
__declare_io_port_global(ComplexBitMap<uint32_t>, Status, 0x1F801070);
|
||||||
__declare_io_port_global(ComplexBitMap<uint32_t>, Mask, 0x1F801074);
|
__declare_io_port_global(ComplexBitMap<uint32_t>, Mask, 0x1F801074);
|
||||||
|
|
||||||
|
static bool is_irq(Bit<uint32_t> irq) {
|
||||||
|
return Status.read().is_bit_set(irq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ack_irg(Bit<uint32_t> irq) {
|
||||||
|
//Status.write(Status.read().clear_bit(irq));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void enable_irq(Bit<uint32_t> irq) {
|
||||||
|
//Mask.write(Mask.read().set_bit(irq));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,15 @@ namespace JabyEngine {
|
||||||
__io_port_inherit_complex_bit_map(CounterMode);
|
__io_port_inherit_complex_bit_map(CounterMode);
|
||||||
|
|
||||||
static constexpr auto SyncEnable = Bit<uint32_t>(0);
|
static constexpr auto SyncEnable = Bit<uint32_t>(0);
|
||||||
|
static constexpr auto FreeRun = !SyncEnable;
|
||||||
static constexpr auto SyncMode = BitRange<uint32_t>::from_to(1, 2);
|
static constexpr auto SyncMode = BitRange<uint32_t>::from_to(1, 2);
|
||||||
static constexpr auto ResetAfterTarget = Bit<uint32_t>(3);
|
static constexpr auto ResetAfterTarget = Bit<uint32_t>(3);
|
||||||
static constexpr auto IRQAtTarget = Bit<uint32_t>(4);
|
static constexpr auto IRQAtTarget = Bit<uint32_t>(4);
|
||||||
static constexpr auto IRQAtMax = Bit<uint32_t>(5);
|
static constexpr auto IRQAtMax = Bit<uint32_t>(5);
|
||||||
static constexpr auto IRQOneShot = !Bit<uint32_t>(6);
|
|
||||||
static constexpr auto IRQEveryTime = Bit<uint32_t>(6);
|
static constexpr auto IRQEveryTime = Bit<uint32_t>(6);
|
||||||
static constexpr auto IRQPulse = !Bit<uint32_t>(7);
|
static constexpr auto IRQOneShot = !IRQEveryTime;
|
||||||
static constexpr auto IRQToggle = Bit<uint32_t>(7);
|
static constexpr auto IRQToggle = Bit<uint32_t>(7);
|
||||||
|
static constexpr auto IRQPulse = !IRQToggle;
|
||||||
static constexpr auto ClockSource = BitRange<uint32_t>::from_to(8, 9);
|
static constexpr auto ClockSource = BitRange<uint32_t>::from_to(8, 9);
|
||||||
static constexpr auto HasIRQRequest = Bit<uint32_t>(10);
|
static constexpr auto HasIRQRequest = Bit<uint32_t>(10);
|
||||||
static constexpr auto IsTargetReached = Bit<uint32_t>(11);
|
static constexpr auto IsTargetReached = Bit<uint32_t>(11);
|
||||||
|
|
|
@ -37,14 +37,16 @@ enum __syscall_PriorityChain {
|
||||||
DefInt = 3
|
DefInt = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
static __constexpr const uint32_t SkipHandler = 0;
|
enum InterruptVerifierResult {
|
||||||
static __constexpr const uint32_t ExecuteHandler = 1;
|
SkipHandler = 0,
|
||||||
|
ExecuteHandler = 1
|
||||||
|
};
|
||||||
|
|
||||||
typedef uint32_t (*InterruptVerifier)();
|
typedef InterruptVerifierResult (*InterruptVerifier)();
|
||||||
typedef uint32_t (*InterruptHandler)(uint32_t);
|
typedef uint32_t (*InterruptHandler)(uint32_t);
|
||||||
|
|
||||||
struct __no_align __syscall_InterruptElement {
|
struct __no_align InterrupCallback {
|
||||||
struct __syscall_InterruptElement* next;
|
struct InterrupCallback* next;
|
||||||
InterruptHandler handler_function;
|
InterruptHandler handler_function;
|
||||||
InterruptVerifier verifier_function;
|
InterruptVerifier verifier_function;
|
||||||
uint32_t notUsed;
|
uint32_t notUsed;
|
||||||
|
@ -99,18 +101,18 @@ static __always_inline void __syscall_ReturnFromException() {
|
||||||
__syscall_function_cast(__syscall_Table_B, void(*)())();
|
__syscall_function_cast(__syscall_Table_B, void(*)())();
|
||||||
}
|
}
|
||||||
|
|
||||||
static __always_inline int __syscall_SysEnqIntRP(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement* interElm) {
|
static __always_inline int __syscall_SysEnqIntRP(enum __syscall_PriorityChain prio, struct InterrupCallback* interElm) {
|
||||||
register uint32_t FuncID asm("t1") = 0x02;
|
register uint32_t FuncID asm("t1") = 0x02;
|
||||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||||
|
|
||||||
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm))(prio, interElm);
|
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct InterrupCallback *interElm))(prio, interElm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __always_inline int __syscall_SysDeqIntRP(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm) {
|
static __always_inline int __syscall_SysDeqIntRP(enum __syscall_PriorityChain prio, struct InterrupCallback *interElm) {
|
||||||
register uint32_t FuncID asm("t1") = 0x03;
|
register uint32_t FuncID asm("t1") = 0x03;
|
||||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||||
|
|
||||||
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm))(prio, interElm);
|
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct InterrupCallback *interElm))(prio, interElm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __always_inline uint32_t __syscall_EnterCriticalSection() {
|
static __always_inline uint32_t __syscall_EnterCriticalSection() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace JabyEngine {
|
||||||
enable_DMA();
|
enable_DMA();
|
||||||
|
|
||||||
SPU::stop_voices();
|
SPU::stop_voices();
|
||||||
|
Timer::setup();
|
||||||
|
|
||||||
GPU::setup();
|
GPU::setup();
|
||||||
GPU::display_logo();
|
GPU::display_logo();
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
|
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||||
#include <PSX/System/IOPorts/timer_io.hpp>
|
#include <PSX/System/IOPorts/timer_io.hpp>
|
||||||
|
#include <PSX/System/syscalls.h>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace Timer {
|
namespace Timer {
|
||||||
void setup() {
|
extern InterrupCallback IRQCallback;
|
||||||
// Just testing around
|
|
||||||
static constexpr auto wuff = CounterMode::with(CounterMode::IRQAtMax, Counter0::SyncMode::Zero_At_Hblank);
|
|
||||||
|
|
||||||
Counter[0].mode = wuff;
|
void setup() {
|
||||||
Counter[0].mode = wuff;
|
static constexpr auto Mode = CounterMode::with(CounterMode::FreeRun, Counter2::SyncMode::Freerun, CounterMode::ResetAfterTarget, CounterMode::IRQAtTarget, CounterMode::IRQEveryTime, Counter2::Source::System_Clock_Div_8);
|
||||||
Counter[0].mode = wuff;
|
static constexpr uint16_t Target = 0x1234;
|
||||||
|
|
||||||
|
//Counter[2].target.ref().set(CounterTarget::CounterTargetValue.with(Target));
|
||||||
|
|
||||||
|
__syscall_EnterCriticalSection();
|
||||||
|
__syscall_SysEnqIntRP(Timer2Irq, &IRQCallback);
|
||||||
|
__syscall_ExitCriticalSection();
|
||||||
|
Interrupt::enable_irq(Interrupt::Timer2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,21 +8,29 @@ namespace JabyEngine {
|
||||||
size_t GlobalTime :: global_counter = 0;
|
size_t GlobalTime :: global_counter = 0;
|
||||||
|
|
||||||
namespace Timer {
|
namespace Timer {
|
||||||
uint32_t interrupt_verifier() {
|
InterruptVerifierResult interrupt_verifier() {
|
||||||
const auto irq_status = Interrupt::Status.read();
|
const auto irq_status = Interrupt::Status.read();
|
||||||
|
|
||||||
if(irq_status.is_bit_set(Interrupt::Timer0)) {
|
if(Interrupt::is_irq(Interrupt::Timer2)) {
|
||||||
return ExecuteHandler;
|
return InterruptVerifierResult::ExecuteHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
return SkipHandler;
|
return InterruptVerifierResult::SkipHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t interrupt_handler(uint32_t) {
|
uint32_t interrupt_handler(uint32_t) {
|
||||||
GlobalTime::global_counter++;
|
GlobalTime::global_counter++;
|
||||||
return 0;
|
|
||||||
}
|
Interrupt::ack_irg(Interrupt::Timer2);
|
||||||
|
__syscall_ReturnFromException();
|
||||||
|
}
|
||||||
|
|
||||||
|
InterrupCallback IRQCallback = {
|
||||||
|
.next = nullptr,
|
||||||
|
.handler_function = interrupt_handler,
|
||||||
|
.verifier_function = interrupt_verifier
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue