117 lines
4.3 KiB
Plaintext
117 lines
4.3 KiB
Plaintext
define CREATE_WINDOW = 1
|
|
define DRAW_TEXT = 2
|
|
define EXIT = 3
|
|
define OPEN = 4
|
|
define CLOSE = 5
|
|
define READ = 6
|
|
define WRITE = 7
|
|
define SEEK = 8
|
|
define TELL = 9
|
|
define SIZE = 10
|
|
define MKDIR = 11
|
|
define REMOVE = 12
|
|
define OPENDIR = 13
|
|
define READDIR = 14
|
|
define CLOSEDIR = 15
|
|
define STAT = 16
|
|
define WAIT_WINDOW = 17
|
|
define SERIAL_PUTS = 18
|
|
define LOAD_SO = 19
|
|
define SO_CALL1 = 20
|
|
define GET_WINBUF = 21
|
|
define WIN_FLUSH = 22
|
|
define POLL_EVENT = 23
|
|
define SET_CURSOR = 24
|
|
|
|
define YIELD = 25
|
|
define SET_TITLE = 26
|
|
define SET_GEOMETRY = 27
|
|
define SPAWN = 28
|
|
define MMAP = 29
|
|
define MUNMAP = 30
|
|
define SET_RESIZABLE = 31
|
|
define GET_WIN_SIZE = 32
|
|
define THREAD_CREATE = 33
|
|
define THREAD_EXIT = 34
|
|
|
|
# SYSCALL_* 别名(vpsdk.stdlib 等模块引用;数值与内核 VKernel/intr/syscall.vp 一致)
|
|
define SYSCALL_MMAP = 29
|
|
|
|
def _syscall0(num: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11])
|
|
return ret
|
|
|
|
def _syscall1(num: uint64, a1: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rdi, {asminp(a1, ASM_DESCR.REG_ANY)}
|
|
mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11, ASM_DESCR.CLOBBER_RDI])
|
|
return ret
|
|
|
|
def _syscall2(num: uint64, a1: uint64, a2: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rdi, {asminp(a1, ASM_DESCR.REG_ANY)}
|
|
mov rsi, {asminp(a2, ASM_DESCR.REG_ANY)}
|
|
mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11, ASM_DESCR.CLOBBER_RDI,
|
|
ASM_DESCR.CLOBBER_RSI])
|
|
return ret
|
|
|
|
def _syscall3(num: uint64, a1: uint64, a2: uint64, a3: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rdi, {asminp(a1, ASM_DESCR.REG_ANY)}
|
|
mov rsi, {asminp(a2, ASM_DESCR.REG_ANY)}
|
|
mov rdx, {asminp(a3, ASM_DESCR.REG_ANY)}
|
|
mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11, ASM_DESCR.CLOBBER_RDI,
|
|
ASM_DESCR.CLOBBER_RSI, ASM_DESCR.CLOBBER_RDX])
|
|
return ret
|
|
|
|
def _syscall5(num: uint64, a1: uint64, a2: uint64, a3: uint64, a4: uint64, a5: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rdi, {asminp(a1, ASM_DESCR.REG_ANY)}
|
|
mov rsi, {asminp(a2, ASM_DESCR.REG_ANY)}
|
|
mov rdx, {asminp(a3, ASM_DESCR.REG_ANY)}
|
|
mov r10, {asminp(a4, ASM_DESCR.REG_ANY)}
|
|
mov r8, {asminp(a5, ASM_DESCR.REG_ANY)}
|
|
mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11, ASM_DESCR.CLOBBER_RDI,
|
|
ASM_DESCR.CLOBBER_RSI, ASM_DESCR.CLOBBER_RDX,
|
|
ASM_DESCR.CLOBBER_R10, ASM_DESCR.CLOBBER_R8])
|
|
return ret
|
|
|
|
def _syscall6(num: uint64, a1: uint64, a2: uint64, a3: uint64, a4: uint64, a5: uint64, a6: uint64) -> uint64:
|
|
ret: uint64
|
|
__asm__(f"""mov rdi, {asminp(a1, ASM_DESCR.REG_ANY)}
|
|
mov rsi, {asminp(a2, ASM_DESCR.REG_ANY)}
|
|
mov rdx, {asminp(a3, ASM_DESCR.REG_ANY)}
|
|
mov r10, {asminp(a4, ASM_DESCR.REG_ANY)}
|
|
mov r8, {asminp(a5, ASM_DESCR.REG_ANY)}
|
|
mov r9, {asminp(a6, ASM_DESCR.REG_ANY)}
|
|
mov rax, {asminp(num, ASM_DESCR.REG_ANY)}
|
|
syscall""",
|
|
out=[asmout(ret, ASM_DESCR.OUTPUT_REG)],
|
|
op=[ASM_DESCR.CLOBBER_MEMORY, ASM_DESCR.CLOBBER_RCX,
|
|
ASM_DESCR.CLOBBER_R11, ASM_DESCR.CLOBBER_RDI,
|
|
ASM_DESCR.CLOBBER_RSI, ASM_DESCR.CLOBBER_RDX,
|
|
ASM_DESCR.CLOBBER_R10, ASM_DESCR.CLOBBER_R8,
|
|
ASM_DESCR.CLOBBER_R9])
|
|
return ret
|