summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/sys_netbsd_amd64.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/sys_netbsd_amd64.s')
-rw-r--r--src/pkg/runtime/sys_netbsd_amd64.s181
1 files changed, 102 insertions, 79 deletions
diff --git a/src/pkg/runtime/sys_netbsd_amd64.s b/src/pkg/runtime/sys_netbsd_amd64.s
index 0b83cd4d8..e73e83ded 100644
--- a/src/pkg/runtime/sys_netbsd_amd64.s
+++ b/src/pkg/runtime/sys_netbsd_amd64.s
@@ -8,42 +8,24 @@
#include "zasm_GOOS_GOARCH.h"
-// int64 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
-TEXT runtime·rfork_thread(SB),7,$0
- MOVL flags+8(SP), DI
- MOVQ stack+16(SP), SI
-
- // Copy m, g, fn off parent stack for use by child.
- MOVQ mm+24(SP), R8
- MOVQ gg+32(SP), R9
- MOVQ fn+40(SP), R12
-
- MOVL $251, AX // sys_rfork
+// int32 lwp_create(void *context, uintptr flags, void *lwpid)
+TEXT runtime·lwp_create(SB),7,$0
+ MOVQ context+0(FP), DI
+ MOVQ flags+8(FP), SI
+ MOVQ lwpid+16(FP), DX
+ MOVL $309, AX // sys__lwp_create
SYSCALL
-
- // Return if rfork syscall failed
- JCC 3(PC)
+ JCC 2(PC)
NEGL AX
RET
- // In parent, return.
- CMPL AX, $0
- JEQ 2(PC)
- RET
-
- // In child, on new stack.
- MOVQ SI, SP
-
- // Initialize m->procid to thread ID
- MOVL $299, AX // sys_getthrid
- SYSCALL
- MOVQ AX, m_procid(R8)
-
+TEXT runtime·lwp_tramp(SB),7,$0
+
// Set FS to point at m->tls.
LEAQ m_tls(R8), DI
CALL runtime·settls(SB)
- // In child, set up new stack
+ // Set up new stack.
get_tls(CX)
MOVQ R8, m(CX)
MOVQ R9, g(CX)
@@ -52,29 +34,34 @@ TEXT runtime·rfork_thread(SB),7,$0
// Call fn
CALL R12
- // It shouldn't return. If it does, exit
- MOVL $302, AX // sys_threxit
+ // It shouldn't return. If it does, exit.
+ MOVL $310, AX // sys__lwp_exit
SYSCALL
JMP -3(PC) // keep exiting
TEXT runtime·osyield(SB),7,$0
- MOVL $298, AX // sys_sched_yield
+ MOVL $350, AX // sys_sched_yield
SYSCALL
RET
-TEXT runtime·thrsleep(SB),7,$0
- MOVQ 8(SP), DI // arg 1 - ident
- MOVL 16(SP), SI // arg 2 - clock_id
- MOVQ 24(SP), DX // arg 3 - tp
- MOVQ 32(SP), R10 // arg 4 - lock
- MOVL $300, AX // sys_thrsleep
+TEXT runtime·lwp_park(SB),7,$0
+ MOVQ 8(SP), DI // arg 1 - abstime
+ MOVL 16(SP), SI // arg 2 - unpark
+ MOVQ 24(SP), DX // arg 3 - hint
+ MOVQ 32(SP), R10 // arg 4 - unparkhint
+ MOVL $434, AX // sys__lwp_park
SYSCALL
RET
-TEXT runtime·thrwakeup(SB),7,$0
- MOVQ 8(SP), DI // arg 1 - ident
- MOVL 16(SP), SI // arg 2 - n
- MOVL $301, AX // sys_thrwakeup
+TEXT runtime·lwp_unpark(SB),7,$0
+ MOVQ 8(SP), DI // arg 1 - lwp
+ MOVL 16(SP), SI // arg 2 - hint
+ MOVL $321, AX // sys__lwp_unpark
+ SYSCALL
+ RET
+
+TEXT runtime·lwp_self(SB),7,$0
+ MOVL $311, AX // sys__lwp_self
SYSCALL
RET
@@ -83,13 +70,13 @@ TEXT runtime·exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 - exit status
MOVL $1, AX // sys_exit
SYSCALL
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·exit1(SB),7,$-8
- MOVL $302, AX // sys_threxit
+ MOVL $310, AX // sys__lwp_exit
SYSCALL
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·write(SB),7,$-8
@@ -112,16 +99,16 @@ TEXT runtime·usleep(SB),7,$16
MOVQ SP, DI // arg 1 - rqtp
MOVQ $0, SI // arg 2 - rmtp
- MOVL $240, AX // sys_nanosleep
+ MOVL $430, AX // sys_nanosleep
SYSCALL
RET
TEXT runtime·raisesigpipe(SB),7,$16
- MOVL $299, AX // sys_getthrid
+ MOVL $311, AX // sys__lwp_self
SYSCALL
- MOVQ AX, DI // arg 1 - pid
- MOVQ $13, SI // arg 2 - signum == SIGPIPE
- MOVL $37, AX // sys_kill
+ MOVQ AX, DI // arg 1 - target
+ MOVQ $13, SI // arg 2 - signo == SIGPIPE
+ MOVL $318, AX // sys__lwp_kill
SYSCALL
RET
@@ -129,72 +116,101 @@ TEXT runtime·setitimer(SB),7,$-8
MOVL 8(SP), DI // arg 1 - which
MOVQ 16(SP), SI // arg 2 - itv
MOVQ 24(SP), DX // arg 3 - oitv
- MOVL $83, AX // sys_setitimer
+ MOVL $425, AX // sys_setitimer
SYSCALL
RET
// func now() (sec int64, nsec int32)
TEXT time·now(SB), 7, $32
- LEAQ 8(SP), DI // arg 1 - tp
- MOVQ $0, SI // arg 2 - tzp
- MOVL $116, AX // sys_gettimeofday
+ MOVQ $0, DI // arg 1 - clock_id
+ LEAQ 8(SP), SI // arg 2 - tp
+ MOVL $427, AX // sys_clock_gettime
SYSCALL
MOVQ 8(SP), AX // sec
- MOVL 16(SP), DX // usec
+ MOVL 16(SP), DX // nsec
- // sec is in AX, usec in DX
+ // sec is in AX, nsec in DX
MOVQ AX, sec+0(FP)
- IMULQ $1000, DX
MOVL DX, nsec+8(FP)
RET
TEXT runtime·nanotime(SB),7,$32
- LEAQ 8(SP), DI // arg 1 - tp
- MOVQ $0, SI // arg 2 - tzp
- MOVL $116, AX // sys_gettimeofday
+ MOVQ $0, DI // arg 1 - clock_id
+ LEAQ 8(SP), SI // arg 2 - tp
+ MOVL $427, AX // sys_clock_gettime
SYSCALL
MOVQ 8(SP), AX // sec
- MOVL 16(SP), DX // usec
+ MOVL 16(SP), DX // nsec
- // sec is in AX, usec in DX
+ // sec is in AX, nsec in DX
// return nsec in AX
IMULQ $1000000000, AX
- IMULQ $1000, DX
ADDQ DX, AX
RET
+TEXT runtime·getcontext(SB),7,$-8
+ MOVQ 8(SP), DI // arg 1 - context
+ MOVL $307, AX // sys_getcontext
+ SYSCALL
+ JCC 2(PC)
+ MOVL $0xf1, 0xf1 // crash
+ RET
+
+TEXT runtime·sigprocmask(SB),7,$0
+ MOVL 8(SP), DI // arg 1 - how
+ MOVQ 16(SP), SI // arg 2 - set
+ MOVQ 24(SP), DX // arg 3 - oset
+ MOVL $293, AX // sys_sigprocmask
+ SYSCALL
+ JCC 2(PC)
+ MOVL $0xf1, 0xf1 // crash
+ RET
+
+TEXT runtime·sigreturn_tramp(SB),7,$-8
+ MOVQ R15, DI // Load address of ucontext
+ MOVQ $308, AX // sys_setcontext
+ SYSCALL
+ MOVQ $-1, DI // Something failed...
+ MOVL $1, AX // sys_exit
+ SYSCALL
+
TEXT runtime·sigaction(SB),7,$-8
MOVL 8(SP), DI // arg 1 - signum
MOVQ 16(SP), SI // arg 2 - nsa
MOVQ 24(SP), DX // arg 3 - osa
- MOVL $46, AX
+ // arg 4 - tramp
+ LEAQ runtime·sigreturn_tramp(SB), R10
+ MOVQ $2, R8 // arg 5 - vers
+ MOVL $340, AX // sys___sigaction_sigtramp
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
-
+
// check that m exists
MOVQ m(BX), BP
CMPQ BP, $0
- JNE 2(PC)
+ JNE 4(PC)
+ MOVQ DI, 0(SP)
CALL runtime·badsignal(SB)
+ RET
// save g
MOVQ g(BX), R10
MOVQ R10, 40(SP)
-
+
// g = m->signal
MOVQ m_gsignal(BP), BP
MOVQ BP, g(BX)
-
+
MOVQ DI, 0(SP)
MOVQ SI, 8(SP)
MOVQ DX, 16(SP)
MOVQ R10, 24(SP)
-
+
CALL runtime·sighandler(SB)
// restore g
@@ -213,7 +229,7 @@ TEXT runtime·mmap(SB),7,$0
SUBQ $16, SP
MOVQ R9, 8(SP) // arg 7 - offset (passed on stack)
MOVQ $0, R9 // arg 6 - pad
- MOVL $197, AX
+ MOVL $197, AX // sys_mmap
SYSCALL
JCC 2(PC)
NEGL AX
@@ -226,29 +242,36 @@ TEXT runtime·munmap(SB),7,$0
MOVL $73, AX // sys_munmap
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
+ RET
+
+
+TEXT runtime·madvise(SB),7,$0
+ MOVQ addr+0(FP), DI // arg 1 - addr
+ MOVQ len+8(FP), SI // arg 2 - len
+ MOVQ behav+16(FP), DX // arg 3 - behav
+ MOVQ $75, AX // sys_madvise
+ SYSCALL
+ // ignore failure - maybe pages are locked
RET
TEXT runtime·sigaltstack(SB),7,$-8
MOVQ new+8(SP), DI // arg 1 - nss
MOVQ old+16(SP), SI // arg 2 - oss
- MOVQ $288, AX // sys_sigaltstack
+ MOVQ $281, AX // sys___sigaltstack14
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
// set tls base to DI
TEXT runtime·settls(SB),7,$8
// adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
- ADDQ $16, DI
- MOVQ DI, 0(SP)
- MOVQ SP, SI
- MOVQ $12, DI // AMD64_SET_FSBASE (machine/sysarch.h)
- MOVQ $165, AX // sys_sysarch
+ ADDQ $16, DI // arg 1 - ptr
+ MOVQ $317, AX // sys__lwp_setprivate
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·sysctl(SB),7,$0