git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: brk and sbrk (mmap based)
[lunaix-os.git]
/
lunaix-os
/
kernel
/
mm
/
dmm.c
diff --git
a/lunaix-os/kernel/mm/dmm.c
b/lunaix-os/kernel/mm/dmm.c
index 188bb0635eebf9a5771d979c55d3e04f642a74e0..cc75bd9be9b4d5f32b782b28733fbf7be54fbd31 100644
(file)
--- a/
lunaix-os/kernel/mm/dmm.c
+++ b/
lunaix-os/kernel/mm/dmm.c
@@
-1,18
+1,30
@@
-#include <lunaix/mm/
page
.h>
-#include <lunaix/
mm/vmm
.h>
+#include <lunaix/mm/
mmap
.h>
+#include <lunaix/
process
.h>
#include <lunaix/status.h>
#include <lunaix/spike.h>
#include <lunaix/syscall.h>
#include <lunaix/status.h>
#include <lunaix/spike.h>
#include <lunaix/syscall.h>
+#include <lunaix/syscall_utils.h>
-__DEFINE_LXSYSCALL1(
int, sbrk, size_t, size
)
+__DEFINE_LXSYSCALL1(
void*, sbrk, ssize_t, incr
)
{
{
- // TODO mem_remap to expand heap region
- return 0;
+ struct proc_mm* pvms = &__current->mm;
+ struct mm_region* heap = pvms->heap;
+
+ assert(heap);
+ int err = mem_adjust_inplace(&pvms->regions, heap, heap->end + incr);
+ if (err) {
+ return (void*)DO_STATUS(err);
+ }
+ return (void*)heap->end;
}
}
-__DEFINE_LXSYSCALL1(
void*
, brk, void*, addr)
+__DEFINE_LXSYSCALL1(
int
, brk, void*, addr)
{
{
- // TODO mem_remap to expand heap region
- return 0;
+ struct proc_mm* pvms = &__current->mm;
+ struct mm_region* heap = pvms->heap;
+
+ assert(heap);
+ int err = mem_adjust_inplace(&pvms->regions, heap, (ptr_t)addr);
+ return DO_STATUS(err);
}
\ No newline at end of file
}
\ No newline at end of file