vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

syscall.c (785B)


      1 
      2 static inline int32_t
      3 syscall(int num, int check, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
      4 {
      5 	int32_t ret;
      6 
      7 	// Generic system call: pass system call number in AX,
      8 	// up to five parameters in DX, CX, BX, DI, SI.
      9 	// Interrupt kernel with T_SYSCALL.
     10 	//
     11 	// The "volatile" tells the assembler not to optimize
     12 	// this instruction away just because we don't use the
     13 	// return value.
     14 	// 
     15 	// The last clause tells the assembler that this can
     16 	// potentially change the condition codes and arbitrary
     17 	// memory locations.
     18 
     19 	asm volatile("syscall\n"
     20 		: "=a" (ret)
     21 		: "a" (num),
     22 		  "d" (a1),
     23 		  "c" (a2),
     24 		  "b" (a3),
     25 		  "D" (a4),
     26 		  "S" (a5)
     27 		: "cc", "memory");
     28 	
     29 	if(check && ret > 0)
     30 		panic("syscall %d returned %d (> 0)", num, ret);
     31 
     32 	return ret;
     33 }
     34