29#include <EASTL/functional.h>
32#include <source_location>
50static constexpr bool debugMode =
false;
52static constexpr bool debugMode =
true;
56static inline uint32_t getCop0Status() {
58 asm(
"mfc0 %0, $12 ; nop" :
"=r"(
r));
62static inline void setCop0Status(
uint32_t r) {
asm(
"mtc0 %0, $12 ; nop" : :
"r"(
r)); }
64[[noreturn]]
void abort(
const char* msg, std::source_location location = std::source_location::current());
65[[noreturn]]
void abort();
75static inline void fastEnterCriticalSection() {
asm volatile(
"mtc0 %0, $12 ; nop ; nop" : :
"r"(0x40000000)); }
82static inline void fastLeaveCriticalSection() {
asm volatile(
"mtc0 %0, $12" : :
"r"(0x40000401)); }
84enum class DMA :
unsigned {
95enum class IRQ :
unsigned {
113[[noreturn]]
static inline void abort(
const char* msg,
114 std::source_location location = std::source_location::current()) {
115 if constexpr (debugMode) {
117 }
else if constexpr (!debugMode) {
311void addOnFrame(eastl::function<
void()>&& lambda);
319inline void assert(
bool condition,
const char* message,
320 std::source_location location = std::source_location::current()) {
321 if constexpr (debugMode) {
326 }
else if constexpr (!debugMode) {
The application class.
Definition application.hh:49
uint32_t r
Definition cpu.c:222
void pumpCallbacks()
Definition kernel.cpp:407
void prepare(Application &)
Definition kernel.cpp:319
void crashHandler(uint32_t exceptionCode, uint32_t *kernelRegisters)
Definition crash-handler.cpp:145
void addOnFrame(eastl::function< void()> &&lambda)
Definition kernel.cpp:427
void beginFrame()
Definition kernel.cpp:431
void addInitializer(eastl::function< void(Application &)> &&lambda)
Definition kernel.cpp:285
void abort()
Definition kernel.cpp:202
uint32_t openEvent(uint32_t classId, uint32_t spec, uint32_t mode, eastl::function< void()> &&lambda)
A C++ wrapper around the openEvent syscall.
Definition kernel.cpp:209
void queueCallbackFromISR(eastl::function< void()> &&lambda)
Queues a callback to be called from the main thead.
Definition kernel.cpp:401
void assert(bool condition, const char *message, std::source_location location=std::source_location::current())
A simple assert macro.
Definition kernel.hh:319
unsigned registerDmaEvent(DMA channel, eastl::function< void()> &&lambda)
Sets an ISR callback for a given DMA channel.
Definition kernel.cpp:218
DMA
Definition kernel.hh:84
void queuePsyqoBreakHandler(eastl::function< bool(uint32_t)> &&handler)
Queues a break handler for psyqo's reserved category.
Definition kernel.cpp:111
void disableDma(DMA channel)
Disables the given DMA channel.
Definition kernel.cpp:254
void installCrashHandler()
Installs a crash handler for the application.
Definition kernel.cpp:173
void setBreakHandler(unsigned category, eastl::function< bool(uint32_t)> &&handler)
Sets a break handler for a given category.
Definition kernel.cpp:105
void flushCache()
Flushes the i-cache.
IRQ
Definition kernel.hh:95
void queueCallback(eastl::function< void()> &&lambda)
Queues a callback to be called from the main thead.
Definition kernel.cpp:394
void unregisterDmaEvent(unsigned slot)
Frees the given DMA callback slot.
Definition kernel.cpp:267
bool isKernelTakenOver()
Returns whether the kernel has been taken over.
Definition kernel.cpp:115
void enableDma(DMA channel, unsigned priority=7)
Enables the given DMA channel.
Definition kernel.cpp:236
void queueIRQHandler(IRQ irq, eastl::function< void()> &&lambda)
Queues an IRQ handler to be called from the exception handler.
Definition kernel.cpp:185
void takeOverKernel()
Takes over the kernel. Can only be called once inside the main function.
Definition kernel.cpp:140
static uint32_t spec
Definition syscalls.h:363
static uint32_t uint32_t void(* handler)())
Definition syscalls.h:370
static void uint32_t mode
Definition syscalls.h:230
void uint32_t(classId, spec)