changeset 359:b4ac28efcdf4

Reorganize files
author Windel Bouwman
date Fri, 14 Mar 2014 15:41:55 +0100
parents 5ef1cb1bb54f
children 42343d189e14
files kernel/arm.yaml kernel/io.c3 kernel/kernel.c3 kernel/memory.c3 kernel/process.c3 kernel/schedule.c3 kernel/src/io.c3 kernel/src/kernel.c3 kernel/src/memory.c3 kernel/src/process.c3 kernel/src/schedule.c3 kernel/src/syscall.c3 kernel/syscall.c3 python/ppci/target/arm/__init__.py python/ppci/target/arm/arm.brg test/testhexfile.py
diffstat 16 files changed, 231 insertions(+), 233 deletions(-) [+]
line wrap: on
line diff
--- a/kernel/arm.yaml	Fri Mar 14 15:17:49 2014 +0100
+++ b/kernel/arm.yaml	Fri Mar 14 15:41:55 2014 +0100
@@ -5,12 +5,9 @@
        source: startup_a9.asm
        machine: arm
     - compile:
-       sources: [kernel.c3, syscall.c3, schedule.c3, 'arch/vexpressA9.c3', io.c3]
-       includes: [memory.c3, process.c3]
-       machine: arm
-    - compile:
-       sources: [memory.c3, process.c3]
-       includes: [kernel.c3, syscall.c3, schedule.c3, 'arch/vexpressA9.c3', io.c3]
+       sources: ['src/kernel.c3', 'src/syscall.c3', 'src/schedule.c3', 
+            'arch/vexpressA9.c3', 'src/io.c3', 'src/memory.c3', 'src/process.c3']
+       includes: []
        machine: arm
   layout:
      code: 0x60010000
--- a/kernel/io.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-module io;
-import arch;
-
-function void println(string txt)
-{
-    print(txt);
-    arch.putc(10); // Newline!
-}
-
-function void print(string txt)
-{
-    var int i;
-    i = 0;
-
-    while (i < txt->len)
-    {
-        arch.putc(cast<int>(txt->txt[i]));
-        i = i + 1;
-    }
-}
-
-// Print integer in hexadecimal notation:
-function void print_int(int i)
-{
-    print("0x");
-
-    // int txt[20];
-    var int b;
-    var int c;
-    var int d;
-    d = 12;
-
-    for (b = 28; b > 0; b = b - 4)
-    {
-        //c = 7; // (i >> b) & 0xF;
-        d = b;
-        c = (i >> d) & 0xF;
-        // c = (i >> b) & 0xF;
-        if (c < 10)
-        {
-            arch.putc( 48 + c );
-        }
-        else
-        {
-            arch.putc( 65 - 10 + c );
-        }
-        // arch.putc( 65 );
-
-    }
-
-    println("");
-}
-
--- a/kernel/kernel.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-module kernel;
-
-import memory;
-import process;
-import scheduler;
-import arch;
-import io;
-
-// Main entry point of the kernel:
-function void start()
-{
-    arch.init();
-
-    io.println("Welcome to lcfos!");
-
-    // io.print_int(0x1337);
-    // process.init();
-    //memory:init();
-
-    //Process proc = new process:Process();
-
-    //scheduler:queue(proc);
-    while(true) {}
-}
-
-function void panic()
-{
-    arch.halt();
-}
-
--- a/kernel/memory.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-module memory;
-
-import process;
-
-var int ptr;
-
-function u8* Alloc(int size)
-{
-    ptr = ptr + size;
-    return cast<u8*>(ptr);
-}
-
-
--- a/kernel/process.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-module process;
-
-import memory;
-import kernel;
-
-// process type definition:
-type struct {
-    int id;
-    int status;
-} process_t;
-
-// Or, use this list structure:
-// List<process_t> procs;
-
-// init is the root of all processes:
-var process_t* init_pid;
-var int next_pid;
-
-function void init()
-{
-    next_pid = 0;
-    init_pid = Create();
-}
-
-/*
-    Create a new process.
-*/
-function process_t* Create()
-{
-    var process_t* p;
-    //= memory.Alloc(sizeof(process_t));
-    p->id = next_pid;
-    next_pid = next_pid + 1;
-    return p;
-}
-
-
-function void Kill(process_t* p)
-{
-    // clean memory
-}
-
-function process_t* byId(int id)
-{
-    // Perform lookup
-    return 0;
-}
-
--- a/kernel/schedule.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-module scheduler;
-
-import process;
-
-var process.process_t *current;
-
-function void executeNext()
-{
-    var process.process_t *old;
-
-    if (old != current)
-    {
-        //execute(current);
-    }
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/io.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,53 @@
+module io;
+import arch;
+
+function void println(string txt)
+{
+    print(txt);
+    arch.putc(10); // Newline!
+}
+
+function void print(string txt)
+{
+    var int i;
+    i = 0;
+
+    while (i < txt->len)
+    {
+        arch.putc(cast<int>(txt->txt[i]));
+        i = i + 1;
+    }
+}
+
+// Print integer in hexadecimal notation:
+function void print_int(int i)
+{
+    print("0x");
+
+    // int txt[20];
+    var int b;
+    var int c;
+    var int d;
+    d = 12;
+
+    for (b = 28; b > 0; b = b - 4)
+    {
+        //c = 7; // (i >> b) & 0xF;
+        d = b;
+        c = (i >> d) & 0xF;
+        // c = (i >> b) & 0xF;
+        if (c < 10)
+        {
+            arch.putc( 48 + c );
+        }
+        else
+        {
+            arch.putc( 65 - 10 + c );
+        }
+        // arch.putc( 65 );
+
+    }
+
+    println("");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/kernel.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,30 @@
+module kernel;
+
+import memory;
+import process;
+import scheduler;
+import arch;
+import io;
+
+// Main entry point of the kernel:
+function void start()
+{
+    arch.init();
+
+    io.println("Welcome to lcfos!");
+
+    // io.print_int(0x1337);
+    // process.init();
+    //memory:init();
+
+    //Process proc = new process:Process();
+
+    //scheduler:queue(proc);
+    while(true) {}
+}
+
+function void panic()
+{
+    arch.halt();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/memory.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,13 @@
+module memory;
+
+import process;
+
+var int ptr;
+
+function u8* Alloc(int size)
+{
+    ptr = ptr + size;
+    return cast<u8*>(ptr);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/process.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,48 @@
+module process;
+
+import memory;
+import kernel;
+
+// process type definition:
+type struct {
+    int id;
+    int status;
+} process_t;
+
+// Or, use this list structure:
+// List<process_t> procs;
+
+// init is the root of all processes:
+var process_t* init_pid;
+var int next_pid;
+
+function void init()
+{
+    next_pid = 0;
+    init_pid = Create();
+}
+
+/*
+    Create a new process.
+*/
+function process_t* Create()
+{
+    var process_t* p;
+    //= memory.Alloc(sizeof(process_t));
+    p->id = next_pid;
+    next_pid = next_pid + 1;
+    return p;
+}
+
+
+function void Kill(process_t* p)
+{
+    // clean memory
+}
+
+function process_t* byId(int id)
+{
+    // Perform lookup
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/schedule.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,17 @@
+
+module scheduler;
+
+import process;
+
+var process.process_t *current;
+
+function void executeNext()
+{
+    var process.process_t *old;
+
+    if (old != current)
+    {
+        //execute(current);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/syscall.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,62 @@
+module syscall;
+
+/*
+    This module handles all the system calls from user space.
+*/
+
+import arch;
+import scheduler;
+import process;
+
+
+const int SendMsg = 1;
+const int ReceiveMsg = 2;
+const int Reboot = 3;
+
+
+// System call handlers. System calls are made from user space.
+function void handle_system_call(int callId, int a, int b)
+{
+    // Main entry, check what to do here
+    if (callId == 1)
+    {
+        handle_send_msg();
+        var process.process_t* proc;
+        proc = process.byId(a);
+        // proc.setMessage();
+        // scheduler.current.setState(Sleep);
+    }
+    else 
+    {
+        if (callId == 2)
+        {
+            handle_recv_msg();
+        }
+        else 
+        {
+            if (callId == 3)
+            {
+                //arch.reboot();
+            }
+            else
+            {
+                return 2;
+            }
+        }
+    }
+
+    return 0;
+}
+
+// Handle send message syscall
+function void handle_send_msg()
+{
+}
+
+function void handle_recv_msg()
+{
+    // Block until we have a message
+    //currentProc->setState(Sleep);
+    //scheduler.executeNext();
+}
+
--- a/kernel/syscall.c3	Fri Mar 14 15:17:49 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-module syscall;
-
-/*
-    This module handles all the system calls from user space.
-*/
-
-import arch;
-import scheduler;
-import process;
-
-
-const int SendMsg = 1;
-const int ReceiveMsg = 2;
-const int Reboot = 3;
-
-
-// System call handlers. System calls are made from user space.
-function void handle_system_call(int callId, int a, int b)
-{
-    // Main entry, check what to do here
-    if (callId == 1)
-    {
-        handle_send_msg();
-        var process.process_t* proc;
-        proc = process.byId(a);
-        // proc.setMessage();
-        // scheduler.current.setState(Sleep);
-    }
-    else 
-    {
-        if (callId == 2)
-        {
-            handle_recv_msg();
-        }
-        else 
-        {
-            if (callId == 3)
-            {
-                //arch.reboot();
-            }
-            else
-            {
-                return 2;
-            }
-        }
-    }
-
-    return 0;
-}
-
-// Handle send message syscall
-function void handle_send_msg()
-{
-}
-
-function void handle_recv_msg()
-{
-    // Block until we have a message
-    //currentProc->setState(Sleep);
-    //scheduler.executeNext();
-}
-
--- a/python/ppci/target/arm/__init__.py	Fri Mar 14 15:17:49 2014 +0100
+++ b/python/ppci/target/arm/__init__.py	Fri Mar 14 15:41:55 2014 +0100
@@ -4,7 +4,7 @@
 from ..arm.registers import R8, R9, R10, R11, R12, SP, LR, PC
 from ..arm.registers import register_range
 
-from .instructions import Dcd, Mov, Mov1, Add, Sub, Orr1, Mul, Mov2, Add1, Mul1
+from .instructions import Dcd, Mov, Mov1, Add, Add2, Sub, Orr1, Mul, Mov2, Add1, Mul1
 from .instructions import Lsr1, Lsl1, And1, Sub1
 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2
 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr
@@ -25,6 +25,7 @@
         self.add_lowering(Mov2, lambda im: Mov2(im.dst[0], im.src[0]))
         self.add_lowering(Cmp2, lambda im: Cmp2(im.src[0], im.src[1]))
         self.add_lowering(Add1, lambda im: Add1(im.dst[0], im.src[0], im.src[1]))
+        self.add_lowering(Add2, lambda im: Add2(im.dst[0], im.src[0], im.others[0]))
         self.add_lowering(Sub1, lambda im: Sub1(im.dst[0], im.src[0], im.src[1]))
         self.add_lowering(Mul1, lambda im: Mul1(im.dst[0], im.src[0], im.src[1]))
         self.add_lowering(Lsr1, lambda im: Lsr1(im.dst[0], im.src[0], im.src[1]))
--- a/python/ppci/target/arm/arm.brg	Fri Mar 14 15:17:49 2014 +0100
+++ b/python/ppci/target/arm/arm.brg	Fri Mar 14 15:41:55 2014 +0100
@@ -1,5 +1,5 @@
 
-from ppci.target.arm.instructions import Add1, Sub1, Mul1
+from ppci.target.arm.instructions import Add1, Add2, Sub1, Mul1
 from ppci.target.arm.instructions import Ldr1, Ldr3, Adr
 from ppci.target.arm.instructions import And1, Lsr1, Lsl1, Mov1
 
@@ -13,6 +13,8 @@
 %%
 
 reg: ADDI32(reg, reg)         2 'd = self.newTmp(); self.emit(Add1, dst=[d], src=[c0, c1]); return d'
+reg: ADDI32(reg, cn)          2 'return tree.children[1].value < 256' 'd = self.newTmp(); self.emit(Add2, dst=[d], src=[c0], others=[c1]); return d'
+reg: ADDI32(cn, reg)          2 'return tree.children[0].value < 256' 'd = self.newTmp(); self.emit(Add2, dst=[d], src=[c1], others=[c0]); return d'
 reg: SUBI32(reg, reg)         2 'd = self.newTmp(); self.emit(Sub1, dst=[d], src=[c0, c1]); return d'
 reg: MULI32(reg, reg)         2 'd = self.newTmp(); self.emit(Mul1, dst=[d], src=[c0, c1]); return d'
 reg: ANDI32(reg, reg)         2 'd = self.newTmp(); self.emit(And1, dst=[d], src=[c0, c1]); return d'
--- a/test/testhexfile.py	Fri Mar 14 15:17:49 2014 +0100
+++ b/test/testhexfile.py	Fri Mar 14 15:41:55 2014 +0100
@@ -28,13 +28,11 @@
         hf.addRegion(0xFFFE, bytes.fromhex('aabbcc'))
         self.saveload(hf)
 
-    @unittest.skip('Takes too long')
     def testSave4(self):
         hf = HexFile()
         hf.addRegion(0xF000, bytes.fromhex('ab')*0x10000)
         self.saveload(hf)
 
-    @unittest.skip('Takes too long')
     def testSave5(self):
         hf = HexFile()
         hf.addRegion(0xF003, bytes.fromhex('ab')*0x10000)