Hello World functional
This commit is contained in:
128
include/PSX/System/syscalls.h
Normal file
128
include/PSX/System/syscalls.h
Normal file
@@ -0,0 +1,128 @@
|
||||
#ifndef __JABYENGINE_SYSCALLS__H
|
||||
#define __JABYENGINE_SYSCALLS__H
|
||||
#include "../jabyengine_defines.h"
|
||||
|
||||
/*
|
||||
R0 zr Constant Zero
|
||||
R1 at Reserved for the assembler
|
||||
R2-R3 v0-v1 Values for results and expression evaluation
|
||||
R4-R7 a0-a3 Arguments
|
||||
R8-R15 t0-t7 Temporaries (not preserved across call)
|
||||
R16-R23 s0-s7 Saved (preserved across call)
|
||||
R24-R25 t8-t9 More temporaries (not preserved across call)
|
||||
R26-R27 k0-k1 Reserved for OS Kernel
|
||||
R28 gp Global Pointer
|
||||
R29 sp Stack Pointer
|
||||
R30 fp Frame Pointer
|
||||
R31 ra Return address (set by function call)
|
||||
*/
|
||||
|
||||
static __constexpr const uint32_t __syscall_Table_A = 0xA0;
|
||||
static __constexpr const uint32_t __syscall_Table_B = 0xB0;
|
||||
static __constexpr const uint32_t __syscall_Table_C = 0xC0;
|
||||
|
||||
enum __syscall_PriorityChain {
|
||||
CdromDmaIrq = 0,
|
||||
CdromIoIrq = 0,
|
||||
SyscallException = 0,
|
||||
|
||||
CardSpecificIrq = 1,
|
||||
VblankIrq = 1,
|
||||
Timer2Irq = 1,
|
||||
Timer1Irq = 1,
|
||||
Timer0Irq = 1,
|
||||
|
||||
PadCardIrq = 2,
|
||||
|
||||
DefInt = 3
|
||||
};
|
||||
|
||||
static __constexpr const uint32_t SkipHandler = 0;
|
||||
static __constexpr const uint32_t ExecuteHandler = 1;
|
||||
|
||||
struct __no_align __syscall_InterruptElement {
|
||||
struct __syscall_InterruptElement *next;
|
||||
void (*handler)(uint32_t);
|
||||
uint32_t (*verifier)();
|
||||
uint32_t notUsed;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
reinterpret_cast<__VA_ARGS__>(table)
|
||||
#else
|
||||
#define __syscall_function_cast(table, ...) ((__VA_ARGS__)(void*)table)
|
||||
#endif
|
||||
|
||||
static __always_inline void* __syscall_memcpy(void *dst, const void *src, size_t len) {
|
||||
register uint32_t FuncID asm("t1") = 0x2A;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(__syscall_Table_A, void*(*)(void*, const void*, size_t))(dst, src, len);
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_InitPad(uint8_t *portA, uint32_t portASize, uint8_t *portB, uint32_t portBSize) {
|
||||
register uint32_t FuncID asm("t1") = 0x12;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(__syscall_Table_B, void(*)(uint8_t*, uint32_t, uint8_t*, uint32_t))(portA, portASize, portB, portBSize);
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_StartPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x13;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(__syscall_Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_StopPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x14;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(__syscall_Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_ChangeClearPad(int32_t _reserved) {
|
||||
register uint32_t FuncID asm("t1") = 0x5B;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(__syscall_Table_B, void(*)(int32_t))(_reserved);
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_ReturnFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x17;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(__syscall_Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline int __syscall_SysEnqIntRP(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement* interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x02;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline int __syscall_SysDeqIntRP(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x03;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(__syscall_Table_C, int(*)(enum __syscall_PriorityChain prio, struct __syscall_InterruptElement *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline uint32_t __syscall_EnterCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x01;
|
||||
register uint32_t returnValue asm("v0");
|
||||
|
||||
__asm__ volatile("syscall" : "=r"(FuncID), "=r"(returnValue) : "r"(FuncID) : "at", "v1", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", "memory");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_ExitCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x2;
|
||||
|
||||
__asm__ volatile("syscall" : "=r"(FuncID) : "r"(FuncID) : "at", "v0", "v1", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", "memory");
|
||||
}
|
||||
|
||||
int __syscall_printf(const char* txt, ...);
|
||||
|
||||
#endif //!__JABYENGINE_SYSCALLS__H
|
17
include/PSX/jabyengine_defines.h
Normal file
17
include/PSX/jabyengine_defines.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef __JABYENGINE_DEFINES__H
|
||||
#define __JABYENGINE_DEFINES__H
|
||||
#include "../stddef.h"
|
||||
|
||||
#define __keep __attribute__((used))
|
||||
#define __no_align __attribute__((packed))
|
||||
#define __no_inline __attribute__((noinline))
|
||||
#define __always_inline __attribute__((always_inline))
|
||||
#define __section(name) __attribute__((section(name)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __constexpr constexpr
|
||||
#else
|
||||
#define __constexpr
|
||||
#endif
|
||||
|
||||
#endif //!__JABYENGINE_DEFINES__H
|
Reference in New Issue
Block a user