forked from PoliEcho-holding-org/kern
Began work on proper terminal I/O
- Chenged Puts() syscall to Write() - Improved syscalls.h - added a new header in terminal/terminal.h - moved gfxMode into screen/gfxmode.h
This commit is contained in:
+10
-4
@@ -1,12 +1,18 @@
|
||||
#ifndef STDIO_H
|
||||
#define STDIO_H
|
||||
|
||||
void print(const char* s) { // Use Syscall(1) - Puts()
|
||||
__asm__ volatile ("int $0x80" : : "a"(1), "b"(s));
|
||||
#include <syscall.h>
|
||||
#include <string.h>
|
||||
|
||||
// TODO: Make a proper file descriptor table
|
||||
#define STDOUT 1
|
||||
|
||||
void print(const char* s) {
|
||||
write(STDOUT, s, strlen(s));
|
||||
}
|
||||
|
||||
void read(char* s) { // Use Syscall(2) - Gets()
|
||||
__asm__ volatile ("int $0x80" : : "a"(2), "b"(s));
|
||||
void read(char* s) {
|
||||
print("\x1b[1M[ ERROR: Read() Syscall not found! ]\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef SYSCALLNUMS_H
|
||||
#define SYSCALLNUMS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_SYSCALLS 5
|
||||
|
||||
typedef enum {
|
||||
SYS_SLEEP,
|
||||
SYS_WRITE,
|
||||
SYS_GETS,
|
||||
SYS_MALLOC,
|
||||
SYS_FREE,
|
||||
} SYSCALL_NUMBERS;
|
||||
|
||||
// TODO: Add malloc() and free() syscall wrappers??
|
||||
int32_t write(int32_t fd, const void* buf, uint32_t len) {
|
||||
int32_t result = -1;
|
||||
__asm__ volatile ("int $0x80" : "=a"(result) : "a"(SYS_WRITE), "b"(fd), "c"(buf), "d"(len));
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user