aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/mm.c
diff options
context:
space:
mode:
Diffstat (limited to 'extras/mini-os/mm.c')
-rw-r--r--extras/mini-os/mm.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/extras/mini-os/mm.c b/extras/mini-os/mm.c
index 11e249d421..f204fa66ec 100644
--- a/extras/mini-os/mm.c
+++ b/extras/mini-os/mm.c
@@ -360,6 +360,29 @@ void free_pages(void *pointer, int order)
}
+#ifdef HAVE_LIBC
+void *sbrk(ptrdiff_t increment)
+{
+ unsigned long old_brk = brk;
+ unsigned long new_brk = old_brk + increment;
+
+ if (new_brk > heap_end) {
+ printk("Heap exhausted: %p + %lx = %p > %p\n", old_brk, increment, new_brk, heap_end);
+ return NULL;
+ }
+
+ if (new_brk > heap_mapped) {
+ unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
+ do_map_zero(heap_mapped, n);
+ heap_mapped += n * PAGE_SIZE;
+ }
+
+ brk = new_brk;
+
+ return (void *) old_brk;
+}
+#endif
+
void init_mm(void)