CoolPotOS/apps/include/syscall.h

31 lines
801 B
C
Raw Normal View History

2024-08-30 16:12:44 +08:00
#ifndef CRASHPOWEROS_SYSCALL_H
#define CRASHPOWEROS_SYSCALL_H
#define SYSCALL_PUTCHAR 1
#define SYSCALL_PRINT 2
2024-08-31 01:23:06 +08:00
#define SYSCALL_GETC 3
2024-08-30 16:12:44 +08:00
#include <stdint.h>
static inline void syscall_print(char* c){
uint32_t rets;
uint32_t __arg1 = c;
register uint32_t ebx asm("ebx") = __arg1;
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_PRINT), "r"(ebx) : "memory", "cc");
}
static inline void syscall_putchar(char c){
uint32_t rets;
uint32_t __arg1 = (uint32_t)(c);
register uint32_t ebx asm("ebx") = __arg1;
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_PUTCHAR), "r"(ebx) : "memory", "cc");
}
2024-08-31 01:23:06 +08:00
static inline char syscall_getc(){
uint32_t rets;
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_GETC) : "memory", "cc");
return rets;
}
2024-08-30 16:12:44 +08:00
#endif