diff kernel/memory.c3 @ 410:6aa9743ed362 tip

Reflect change in c3 public modifier
author Windel Bouwman
date Mon, 23 Feb 2015 21:06:04 +0100
parents ad6be5454067
children
line wrap: on
line diff
--- a/kernel/memory.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/memory.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -3,16 +3,17 @@
 import arch;
 import io;
 
+const int pagesize = 4096;
 var int ptr;
 
 // Let the heap grow upwards..
 
-function void init()
+public function void init()
 {
     ptr = 0x60080000;
 }
 
-function byte* alloc(int size)
+public function byte* alloc(int size)
 {
     var int ptr2;
     ptr2 = ptr;
@@ -25,8 +26,27 @@
     return ptr2;
 }
 
+function bool is_marked(int page)
+{
+    return true;
+}
+
+function void set_mark(int page, bool mark)
+{
+
+}
+
 function byte* allocate_physical()
 {
+    var int i;
+    for (i = 0; i < 100; i += 1)
+    {
+        if (not is_marked(i))
+        {
+            return i * pagesize;
+        }
+    }
+
     return 0;
 }
 
@@ -37,14 +57,17 @@
     return address2;
 }
 
-function void memcpy(byte* dst, byte* src, int size)
+// Util function:
+public function void memcpy(byte* dst, byte* src, int size)
 {
     var int i;
     io.print2("memcpy to ", cast<int>(dst));
     io.print2("memcpy from ", cast<int>(src));
+    io.print2("memcpy size ", size);
     for (i = 0; i < size; i += 1)
     {
         *(dst + i) = *(src + i);
     }
 }
 
+