Add support for openat on mips
This commit is contained in:
parent
f5722b2c09
commit
47d317b977
31
arch/mips.c
31
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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user