]> git.corax.cc Git - corax/commitdiff
Add assembly stubs, definitions, and prototypes for mmap() and munmap() syscalls
authorMatthias Kruk <m@m10k.eu>
Wed, 18 Dec 2019 09:24:13 +0000 (18:24 +0900)
committerMatthias Kruk <m@m10k.eu>
Wed, 18 Dec 2019 09:24:13 +0000 (18:24 +0900)
include/corax/syscall.h
include/sys/mman.h [new file with mode: 0644]
kernel/klibc/posixcall.S

index ba3961876344ee8ef684e8e2ed1154d40b6d2bbc..ca456c2a95ac6eb32a45fa644d52807fb8f4ad10 100644 (file)
@@ -24,6 +24,8 @@
 #define SYS_SETSID     6
 #define SYS_SLEEP      7
 #define SYS_SBRK       8
+#define SYS_MMAP       9
+#define SYS_MUNMAP     10
 
 /* Corax-specific variations of POSIX syscalls */
 #define SYS_EXECFVE    128
diff --git a/include/sys/mman.h b/include/sys/mman.h
new file mode 100644 (file)
index 0000000..fc27a03
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+
+#include <sys/types.h>
+
+#define PROT_READ  (1 << 2)
+#define PROT_WRITE (1 << 1)
+#define PROT_EXEC  (1 << 0)
+#define PROT_NONE  (0)
+
+#define MAP_PHYS (1 << 31)
+
+extern void* mmap(void*, size_t, int, int, int, size_t);
+extern int   munmap(void*, size_t);
+
+#endif /* _SYS_MMAN_H */
index f54608b778e516e70497c94cce1a25800ffa3d98..faa10f7209a505b75fdb598253c4ca79eee6f80d 100644 (file)
@@ -11,6 +11,8 @@
        .global execfve
        .global brk
        .global sbrk
+       .global mmap
+       .global munmap
 
 fork:
        pushl   %ebx
@@ -61,4 +63,32 @@ sbrk:
        popl    %ebx
        ret
 
+mmap:
+       pushl   %ebx
+       pushl   %ebp
+
+       movl    $SYS_MMAP, %eax
+       movl    12(%esp), %ebx
+       movl    16(%esp), %ecx
+       movl    20(%esp), %edx
+       movl    24(%esp), %esi
+       movl    28(%esp), %edi
+       movl    32(%esp), %ebp
+       int             $SYSCALL_POSIX
+
+       popl    %ebp
+       popl    %ebx
+       ret
+
+munmap:
+       pushl   %ebx
+
+       movl    $SYS_MUNMAP, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_POSIX
+
+       popl    %ebx
+       ret
+
 #endif /* FEATURE(POSIX) */