changeset 410:6aa9743ed362 tip

Reflect change in c3 public modifier
author Windel Bouwman
date Mon, 23 Feb 2015 21:06:04 +0100
parents ad6be5454067
children
files kernel/arch/qemu_vexpress/vexpressA9.c3 kernel/build.xml kernel/io.c3 kernel/kernel.c3 kernel/memory.c3 kernel/process.c3 make.sh user/lib/ipc.c3 user/lib/lib.c3
diffstat 9 files changed, 50 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/kernel/arch/qemu_vexpress/vexpressA9.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/arch/qemu_vexpress/vexpressA9.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -2,7 +2,7 @@
 import io;
 
 
-function void init()
+public function void init()
 {
     io.print2("PFR0 = ", pfr0());
     io.print2("PFR1 = ", pfr1());
@@ -12,14 +12,14 @@
     // io.print2("MPUIR = ", arch.mpuir());
 }
 
-function void putc(int c)
+public function void putc(int c)
 {
     var int *UART0DR;
     UART0DR = cast<int*>(0x109000); // UART0 DR register when remapped at 1MB
     *UART0DR = c;
 }
 
-function void halt()
+public function void halt()
 {
     while(true)
     {
@@ -27,7 +27,7 @@
 }
 
 // Functions implemented in assembly:
-function byte* get_image_address();
+public function byte* get_image_address();
 function int pfr0();
 function int pfr1();
 function int mmfr0();
--- a/kernel/build.xml	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/build.xml	Mon Feb 23 21:06:04 2015 +0100
@@ -1,5 +1,6 @@
 
 <project name="lcfos-kernel" default="vexpress">
+    <import name="ppci.buildtasks" />
 
     <property name="src" value="src" />
     <property name="arch" value="arm" />
@@ -10,7 +11,9 @@
             target="arm" output="obj/start.o" />
 
         <compile target="arm" sources='*.c3;arch/qemu_vexpress/vexpressA9.c3'
-            output="obj/kernel.o" />
+            output="obj/kernel.o"
+            listing="kernel.lst"
+            />
 
         <link output="obj/kernel.elf"
             target="arm"
--- a/kernel/io.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/io.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -1,7 +1,7 @@
 module io;
 import arch;
 
-function void println(string txt)
+public function void println(string txt)
 {
     print(txt);
     arch.putc(10); // Newline!
@@ -44,7 +44,7 @@
     arch.putc(10); // Newline!
 }
 
-function void print2(string label, int value)
+public function void print2(string label, int value)
 {
     print(label);
     print_int(value);
--- a/kernel/kernel.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/kernel.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -20,7 +20,7 @@
 }
 
 // Called in total stress:
-function void panic()
+public function void panic()
 {
     io.println("Kernel panic!");
     arch.halt();
@@ -35,14 +35,11 @@
 function void load_init_process()
 {
     // Load image:
-    var byte* image_addr;
-    image_addr = arch.get_image_address();
+    var byte* image_addr = arch.get_image_address();
     io.print2("ramdisk address: ", cast<int>(image_addr));
 
-    var ramdisk_header_t* ramdisk_header;
-    ramdisk_header = image_addr;
-    var byte* image_ptr;
-    image_ptr = image_addr;
+    var ramdisk_header_t* ramdisk_header = image_addr;
+    var byte* image_ptr = image_addr;
     if (0x1337 == ramdisk_header->magic)
     {
         image_ptr += 8;
@@ -50,8 +47,7 @@
         if (ramdisk_header->num_images > 0)
         {
             io.println("Loading init");
-            var int init_size;
-            init_size = *(cast<int*>(image_ptr));
+            var int init_size = *(cast<int*>(image_ptr));
             io.print2("Init size:", init_size);
             image_ptr += 4;
 
--- 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);
     }
 }
 
+
--- a/kernel/process.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/kernel/process.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -16,7 +16,7 @@
 var int next_pid;
 var process_t* current;
 
-function void init()
+public function void init()
 {
     next_pid = 0;
     first_process = 0;
@@ -26,7 +26,7 @@
 /*
     Create a new process.
 */
-function process_t* create()
+public function process_t* create()
 {
     var process_t* p;
 
@@ -64,16 +64,16 @@
     // clean memory
 }
 
-function process_t* byId(int id)
+public function process_t* byId(int id)
 {
     // Perform lookup
     return 0;
 }
 
 
-function void execute_next()
+public function void execute_next()
 {
-    var process.process_t *old;
+    var process_t *old;
 
     old = 0;
 
--- a/make.sh	Sat Feb 21 12:17:47 2015 +0100
+++ b/make.sh	Mon Feb 23 21:06:04 2015 +0100
@@ -1,5 +1,6 @@
 #!/bin/bash
 
 export PYTHONPATH=../ppci
-../ppci/bin/ppci-build.py --log debug build
+#../ppci/bin/ppci-build.py --log debug build
+../ppci/bin/ppci-build.py
 
--- a/user/lib/ipc.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/user/lib/ipc.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -18,7 +18,7 @@
     // TODO: make this in assembler?
 }
 
-function void SendMessage(Msg *msg)
+public function void SendMessage(Msg *msg)
 {
     var int x;
     x=kernelTrap(MSG_SEND, 1, 0)
--- a/user/lib/lib.c3	Sat Feb 21 12:17:47 2015 +0100
+++ b/user/lib/lib.c3	Mon Feb 23 21:06:04 2015 +0100
@@ -13,7 +13,7 @@
     *UART0DR = c;
 }
 
-function void print(string txt)
+public function void print(string txt)
 {
     // TODO
     var ipc.Msg msg;