forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simplified mmap() and munmap() syscalls.
- Loading branch information
1 parent
a5caf7c
commit 9a296d6
Showing
13 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
*.swp | ||
Serenity.config | ||
Serenity.creator | ||
Serenity.creator.user | ||
Serenity.files | ||
Serenity.includes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ OBJS = \ | |
unistd.o \ | ||
string.o \ | ||
process.o \ | ||
mman.o \ | ||
entry.o | ||
|
||
LIBRARY = LibC.a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "mman.h" | ||
#include <Kernel/Syscall.h> | ||
|
||
extern "C" { | ||
|
||
void* mmap(void* addr, size_t size) | ||
{ | ||
return (void*)Syscall::invoke(Syscall::PosixMmap, (dword)addr, (dword)size); | ||
} | ||
|
||
int munmap(void* addr, size_t size) | ||
{ | ||
return Syscall::invoke(Syscall::PosixMunmap, (dword)addr, (dword)size); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "types.h" | ||
|
||
extern "C" { | ||
|
||
void* mmap(void*, size_t); | ||
int munmap(void*, size_t); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
id | ||
sh | ||
ps | ||
ls | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <LibC/stdio.h> | ||
#include <LibC/unistd.h> | ||
#include <LibC/mman.h> | ||
|
||
int main(int c, char** v) | ||
{ | ||
int fd = open("/"); | ||
if (fd == -1) { | ||
printf("failed to open / :(\n"); | ||
return 1; | ||
} | ||
|
||
byte* memory = (byte*)mmap(nullptr, 16384); | ||
printf("%p\n", memory); | ||
memory[0] = 'H'; | ||
memory[1] = 'i'; | ||
memory[2] = '!'; | ||
memory[3] = '\0'; | ||
printf("%p : %s\n", memory, memory); | ||
return 0; | ||
} |