diff --git a/arch/mips.c b/arch/mips.c index 51881b6..ea77a02 100644 --- a/arch/mips.c +++ b/arch/mips.c @@ -56,4 +56,35 @@ uint32_t fork(){ ); return (uint32_t)rtn; } + +int32_t openat(int32_t fd, const char* filename, uint32_t flags, uint32_t mode) { + int32_t file = 0; + asm volatile ( + "move $a0, %1\n" + "move $a1, %2\n" + "move $a2, %3\n" + "move $a3, %4\n" + "li $v0, 4288\n" + "syscall\n" + "move %0, $v0\n" + : "=r"(file) + : "r"(fd), "r"(filename), "r"(flags), "r"(mode) + : "a0", "a1", "a2", "a3", "v0" + ); + /* + asm volatile ( + "move $a0, %1\n" + "move $a1, %2\n" + "move $a2, %3\n" + "li $v0, 4005\n" + "syscall\n" + "move %0, $v0\n" + : "=r"(file) + : "r"(filename), "r"(flags), "r"(mode) + : "a0", "a1", "a2", "a3", "v0" + ); + */ + return file; +} + #endif diff --git a/buildtest.c b/buildtest.c index 8f0d30e..ab2c52f 100644 --- a/buildtest.c +++ b/buildtest.c @@ -33,7 +33,7 @@ int main() { write(STDIO, input_buffer, n_read); // Test the open syscall - #if defined(__x86_64__) + #if defined(__x86_64__) || defined(__mips__) int32_t file = open("/proc/version", O_RDONLY); int i = read(file, input_buffer, INPUT_BUFFER_LEN); while(i > 0) {