Added ability to load an arbitrary binary from an ethernet server and launch it
[akaros.git] / user / parlib / src / syscall.c
index d1fa775..e0f6c5b 100644 (file)
@@ -12,26 +12,22 @@ static intreg_t syscall_sysenter(uint16_t num, intreg_t a1,
                                  intreg_t a4, intreg_t a5)
 {
        intreg_t ret;
-    asm volatile(
-            //"pushl %%ecx\n\t"
-            //"pushl %%edx\n\t"
-            "pushl %%ebp\n\t"
-                       "pushl %%esi\n\t"
-            "movl %%esp, %%ebp\n\t"
-            "leal after_sysenter, %%esi\n\t"
-            "sysenter\n\t"
-            "after_sysenter:\n\t"
-                       "popl %%esi\n\t"
-            "popl %%ebp\n\t"
-            //"popl %%edx\n\t"
-            //"popl %%ecx"
-            :"=a" (ret)
-            : "a" (num),
-                "d" (a1),
-                "c" (a2),
-                "b" (a3),
-                "D" (a4)
-        : "cc", "memory", "%esp");
+       asm volatile(
+           "pushl %%ebp\n\t"
+           "pushl %%esi\n\t"
+           "movl %%esp, %%ebp\n\t"
+           "leal after_sysenter, %%esi\n\t"
+           "sysenter\n\t"
+           "after_sysenter:\n\t"
+           "\tpopl %%esi\n"
+           "\tpopl %%ebp\n"
+           :"=a" (ret)
+           : "a" (num),
+             "d" (a1),
+             "c" (a2),
+             "b" (a3),
+             "D" (a4)
+           : "cc", "memory", "%esp");
        return ret;
 }
 
@@ -40,7 +36,7 @@ static intreg_t syscall_trap(uint16_t num, intreg_t a1,
                              intreg_t a4, intreg_t a5)
 {
        intreg_t ret;
-
+       
        // Generic system call: pass system call number in AX,
        // up to five parameters in DX, CX, BX, DI, SI.
        // Interrupt kernel with T_SYSCALL.
@@ -115,3 +111,21 @@ ssize_t sys_serial_read(void* buf, size_t len)
 {
        return syscall(SYS_serial_read, (intreg_t)buf, len, 0, 0, 0);
 }
+
+//Run a binary loaded at the specificed address with the specified arguments
+ssize_t sys_run_binary(void* binary_buf, void* arg, size_t len) 
+{
+       return syscall(SYS_run_binary, (intreg_t)binary_buf, (intreg_t)arg, len, 0, 0);
+}
+
+//Write a buffer over ethernet
+ssize_t sys_eth_write(void* buf, size_t len) 
+{
+       return syscall(SYS_eth_write, (intreg_t)buf, len, 0, 0, 0);
+}
+
+//Read a buffer via ethernet
+ssize_t sys_eth_read(void* buf, size_t len) 
+{
+       return syscall(SYS_eth_read, (intreg_t)buf, len, 0, 0, 0);
+}