basic scheduling, basic syscall, (added .data copy)
[cortex-from-scratch] / lib / syscall.c
index 106c235..d844b43 100644 (file)
@@ -1,4 +1,3 @@
-
 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
  * 
  * $LOG$
 
 #include <lib/syscall.h>
 
+/* Arguments are placed in r0, r1, r2 by convention
+ * And "parsed" to the the kernel
+ * Right after the svc call, r0 contains status
+ * of call (ie. OK, NOTOK */
 
-//__attribute__ ((naked))
-static int theos_syscall(int SYSCALL_N, int SYSCALL_N2) {
+int theos_uptime() {
 
-       asm volatile ("svc 11");
-       
-       return 0;
+       asm volatile("svc 6");
+       int ret;
+       asm volatile("mov %0, r0" : "=r" (ret));        
+       return ret;
 }
 
-//__attribute__ ((naked))
-void theos_test(int dummy, int dummy2) {
+       
+int theos_init(uint32_t * p) {
+       asm volatile("svc 1");
 
-       theos_syscall(0xB1, 0xB2);
+       return -1;
 }
 
-/* void theos_cputs(const char * str, size_t len) {
+__attribute__ ((naked))
+int theos_switch(uint32_t * p1, uint32_t * p2) {
+
+       asm volatile("push {lr}");
+       asm volatile("svc 4");
+       asm volatile("pop {lr}");
+       asm volatile("bx lr");
+       // should not be here
+       for(;;);
+       
+}
 
-       //syscall(#, 0, 0, 0 ..);
-       theos_syscall(22, 44);
-} */
+int theos_test(int arg1, int arg2, int arg3) {
+       
+       asm volatile("svc 11");
+       int ret;
+       asm volatile("mov %0, r0" : "=r" (ret));        
+       return ret;
+}