mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Commited some old changes, idk what they were
This commit is contained in:
+31
-13
@@ -1,23 +1,41 @@
|
||||
#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;
|
||||
#define MAX_SYSCALLS 9
|
||||
|
||||
// TODO: Add malloc() and free() syscall wrappers??
|
||||
int32_t write(int32_t fd, const void* buf, uint32_t len) {
|
||||
int32_t result = -1;
|
||||
|
||||
typedef enum {
|
||||
SYS_RESERVED,
|
||||
SYS_SLEEP,
|
||||
SYS_GETS,
|
||||
SYS_WRITE,
|
||||
SYS_OPEN,
|
||||
SYS_CLOSE,
|
||||
SYS_MALLOC,
|
||||
SYS_FREE,
|
||||
SYS_SEEK,
|
||||
} SYSCALL_NUMBERS;
|
||||
|
||||
typedef enum {
|
||||
O_CREAT = 0x1, // Create if does not exist
|
||||
O_RDONLY = 0x2, // Read only
|
||||
O_WRONLY = 0x4, // Write only
|
||||
O_RDWR = 0x8, // Read and write
|
||||
O_APPEND = 0x10, // Always writes at the end (appends)
|
||||
O_TRUNC = 0x20, // Truncate file size and position to 0 on Open
|
||||
} OFLAGS;
|
||||
|
||||
int write(int fd, const void* buf, unsigned int len) {
|
||||
int result = -1;
|
||||
__asm__ volatile ("int $0x80" : "=a"(result) : "a"(SYS_WRITE), "b"(fd), "c"(buf), "d"(len));
|
||||
return result;
|
||||
}
|
||||
|
||||
int open(const char* path, int oflag) {
|
||||
int result = -1;
|
||||
__asm__ volatile ("int $0x80" : "=a"(result) : "a"(SYS_OPEN), "b"(path), "c"(oflag));
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user