Text file
src/runtime/sys_linux_loong64.s
Documentation: runtime
1// Copyright 2022 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//
6// System calls and other sys.stuff for loong64, Linux
7//
8
9#include "go_asm.h"
10#include "go_tls.h"
11#include "textflag.h"
12#include "cgo/abi_loong64.h"
13
14#define AT_FDCWD -100
15#define CLOCK_REALTIME 0
16#define CLOCK_MONOTONIC 1
17
18#define SYS_exit 93
19#define SYS_read 63
20#define SYS_write 64
21#define SYS_close 57
22#define SYS_getpid 172
23#define SYS_kill 129
24#define SYS_mmap 222
25#define SYS_munmap 215
26#define SYS_setitimer 103
27#define SYS_clone 220
28#define SYS_nanosleep 101
29#define SYS_sched_yield 124
30#define SYS_rt_sigreturn 139
31#define SYS_rt_sigaction 134
32#define SYS_rt_sigprocmask 135
33#define SYS_sigaltstack 132
34#define SYS_madvise 233
35#define SYS_mincore 232
36#define SYS_gettid 178
37#define SYS_futex 98
38#define SYS_sched_getaffinity 123
39#define SYS_exit_group 94
40#define SYS_tgkill 131
41#define SYS_openat 56
42#define SYS_clock_gettime 113
43#define SYS_brk 214
44#define SYS_pipe2 59
45#define SYS_timer_create 107
46#define SYS_timer_settime 110
47#define SYS_timer_delete 111
48
49// func exit(code int32)
50TEXT runtime·exit<ABIInternal>(SB),NOSPLIT,$0
51 MOVV $SYS_exit_group, R11
52 SYSCALL
53 RET
54
55// func exitThread(wait *atomic.Uint32)
56TEXT runtime·exitThread<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
57 // We're done using the stack.
58 DBAR $0x12 // StoreRelease barrier
59 MOVW R0, (R4)
60 MOVW $0, R4 // exit code
61 MOVV $SYS_exit, R11
62 SYSCALL
63 JMP 0(PC)
64
65// func open(name *byte, mode, perm int32) int32
66TEXT runtime·open<ABIInternal>(SB),NOSPLIT,$0
67 // before:
68 // R4: name, R5: mode, R6: perm
69 // after:
70 // R4: AT_FDCWD, R5: name, R6: mode, R7: perm
71 MOVW R6, R7
72 MOVW R5, R6
73 MOVV R4, R5
74 MOVW $AT_FDCWD, R4 // AT_FDCWD, so this acts like open
75
76 MOVV $SYS_openat, R11
77 SYSCALL
78 MOVW $-4096, R5
79 BGEU R5, R4, 2(PC)
80 MOVW $-1, R4
81 RET
82
83// func closefd(fd int32) int32
84TEXT runtime·closefd<ABIInternal>(SB),NOSPLIT,$0
85 MOVV $SYS_close, R11
86 SYSCALL
87 MOVW $-4096, R5
88 BGEU R5, R4, 2(PC)
89 MOVW $-1, R4
90 RET
91
92// func write1(fd uintptr, p unsafe.Pointer, n int32) int32
93TEXT runtime·write1<ABIInternal>(SB),NOSPLIT,$0
94 MOVV $SYS_write, R11
95 SYSCALL
96 RET
97
98// func read(fd int32, p unsafe.Pointer, n int32) int32
99TEXT runtime·read<ABIInternal>(SB),NOSPLIT,$0
100 MOVV $SYS_read, R11
101 SYSCALL
102 RET
103
104// func pipe2(flags int32) (r, w int32, errno int32)
105TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
106 MOVV $r+8(FP), R4
107 MOVW flags+0(FP), R5
108 MOVV $SYS_pipe2, R11
109 SYSCALL
110 MOVW R4, errno+16(FP)
111 RET
112
113// func usleep(usec uint32)
114TEXT runtime·usleep<ABIInternal>(SB),NOSPLIT,$16
115 MOVV $1000, R6
116 MULVU R6, R4, R4
117 MOVV $1000000000, R6
118
119 DIVVU R6, R4, R5 // ts->tv_sec
120 REMVU R6, R4, R8 // ts->tv_nsec
121 MOVV R5, 8(R3)
122 MOVV R8, 16(R3)
123
124 // nanosleep(&ts, 0)
125 ADDV $8, R3, R4
126 MOVV R0, R5
127 MOVV $SYS_nanosleep, R11
128 SYSCALL
129 RET
130
131// func gettid() uint32
132TEXT runtime·gettid<ABIInternal>(SB),NOSPLIT,$0
133 MOVV $SYS_gettid, R11
134 SYSCALL
135 RET
136
137// func raise(sig uint32)
138TEXT runtime·raise<ABIInternal>(SB),NOSPLIT,$0
139 MOVW R4, R24 // backup sig
140 MOVV $SYS_getpid, R11
141 SYSCALL
142 MOVW R4, R23
143 MOVV $SYS_gettid, R11
144 SYSCALL
145 MOVW R4, R5 // arg 2 tid
146 MOVW R23, R4 // arg 1 pid
147 MOVW R24, R6 // arg 3
148 MOVV $SYS_tgkill, R11
149 SYSCALL
150 RET
151
152// func raiseproc(sig uint32)
153TEXT runtime·raiseproc<ABIInternal>(SB),NOSPLIT,$0
154 MOVW R4, R24 // backup sig
155 MOVV $SYS_getpid, R11
156 SYSCALL
157 //MOVW R4, R4 // arg 1 pid
158 MOVW R24, R5 // arg 2
159 MOVV $SYS_kill, R11
160 SYSCALL
161 RET
162
163// func getpid() int
164TEXT ·getpid<ABIInternal>(SB),NOSPLIT,$0
165 MOVV $SYS_getpid, R11
166 SYSCALL
167 RET
168
169// func tgkill(tgid, tid, sig int)
170TEXT ·tgkill<ABIInternal>(SB),NOSPLIT,$0
171 MOVV $SYS_tgkill, R11
172 SYSCALL
173 RET
174
175// func setitimer(mode int32, new, old *itimerval)
176TEXT runtime·setitimer<ABIInternal>(SB),NOSPLIT,$0
177 MOVV $SYS_setitimer, R11
178 SYSCALL
179 RET
180
181// func timer_create(clockid int32, sevp *sigevent, timerid *int32) int32
182TEXT runtime·timer_create<ABIInternal>(SB),NOSPLIT,$0
183 MOVV $SYS_timer_create, R11
184 SYSCALL
185 RET
186
187// func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32
188TEXT runtime·timer_settime<ABIInternal>(SB),NOSPLIT,$0
189 MOVV $SYS_timer_settime, R11
190 SYSCALL
191 RET
192
193// func timer_delete(timerid int32) int32
194TEXT runtime·timer_delete<ABIInternal>(SB),NOSPLIT,$0
195 MOVV $SYS_timer_delete, R11
196 SYSCALL
197 RET
198
199// func mincore(addr unsafe.Pointer, n uintptr, dst *byte) int32
200TEXT runtime·mincore<ABIInternal>(SB),NOSPLIT,$0
201 MOVV $SYS_mincore, R11
202 SYSCALL
203 RET
204
205// func walltime() (sec int64, nsec int32)
206TEXT runtime·walltime<ABIInternal>(SB),NOSPLIT,$24
207 MOVV R3, R23 // R23 is unchanged by C code
208 MOVV R3, R25
209
210 MOVV g_m(g), R24 // R24 = m
211
212 // Set vdsoPC and vdsoSP for SIGPROF traceback.
213 // Save the old values on stack and restore them on exit,
214 // so this function is reentrant.
215 MOVV m_vdsoPC(R24), R11
216 MOVV m_vdsoSP(R24), R7
217 MOVV R11, 8(R3)
218 MOVV R7, 16(R3)
219
220 MOVV $ret-8(FP), R11 // caller's SP
221 MOVV R1, m_vdsoPC(R24)
222 MOVV R11, m_vdsoSP(R24)
223
224 MOVV m_curg(R24), R4
225 MOVV g, R5
226 BNE R4, R5, noswitch
227
228 MOVV m_g0(R24), R4
229 MOVV (g_sched+gobuf_sp)(R4), R25 // Set SP to g0 stack
230
231noswitch:
232 SUBV $16, R25
233 AND $~15, R25 // Align for C code
234 MOVV R25, R3
235
236 MOVW $CLOCK_REALTIME, R4
237 MOVV $0(R3), R5
238
239 MOVV runtime·vdsoClockgettimeSym(SB), R20
240 BEQ R20, fallback
241
242 // Store g on gsignal's stack, see sys_linux_arm64.s for detail
243 MOVBU runtime·iscgo(SB), R25
244 BNE R25, nosaveg
245
246 MOVV m_gsignal(R24), R25 // g.m.gsignal
247 BEQ R25, nosaveg
248 BEQ g, R25, nosaveg
249
250 MOVV (g_stack+stack_lo)(R25), R25 // g.m.gsignal.stack.lo
251 MOVV g, (R25)
252
253 JAL (R20)
254
255 MOVV R0, (R25)
256 JMP finish
257
258nosaveg:
259 JAL (R20)
260
261finish:
262 MOVV 0(R3), R4 // sec
263 MOVV 8(R3), R5 // nsec
264
265 MOVV R23, R3 // restore SP
266 // Restore vdsoPC, vdsoSP
267 // We don't worry about being signaled between the two stores.
268 // If we are not in a signal handler, we'll restore vdsoSP to 0,
269 // and no one will care about vdsoPC. If we are in a signal handler,
270 // we cannot receive another signal.
271 MOVV 16(R3), R25
272 MOVV R25, m_vdsoSP(R24)
273 MOVV 8(R3), R25
274 MOVV R25, m_vdsoPC(R24)
275
276 RET
277
278fallback:
279 MOVV $SYS_clock_gettime, R11
280 SYSCALL
281 JMP finish
282
283// func nanotime1() int64
284TEXT runtime·nanotime1<ABIInternal>(SB),NOSPLIT,$24
285 MOVV R3, R23 // R23 is unchanged by C code
286 MOVV R3, R25
287
288 MOVV g_m(g), R24 // R24 = m
289
290 // Set vdsoPC and vdsoSP for SIGPROF traceback.
291 // Save the old values on stack and restore them on exit,
292 // so this function is reentrant.
293 MOVV m_vdsoPC(R24), R11
294 MOVV m_vdsoSP(R24), R7
295 MOVV R11, 8(R3)
296 MOVV R7, 16(R3)
297
298 MOVV $ret-8(FP), R11 // caller's SP
299 MOVV R1, m_vdsoPC(R24)
300 MOVV R11, m_vdsoSP(R24)
301
302 MOVV m_curg(R24), R4
303 MOVV g, R5
304 BNE R4, R5, noswitch
305
306 MOVV m_g0(R24), R4
307 MOVV (g_sched+gobuf_sp)(R4), R25 // Set SP to g0 stack
308
309noswitch:
310 SUBV $16, R25
311 AND $~15, R25 // Align for C code
312 MOVV R25, R3
313
314 MOVW $CLOCK_MONOTONIC, R4
315 MOVV $0(R3), R5
316
317 MOVV runtime·vdsoClockgettimeSym(SB), R20
318 BEQ R20, fallback
319
320 // Store g on gsignal's stack, see sys_linux_arm64.s for detail
321 MOVBU runtime·iscgo(SB), R25
322 BNE R25, nosaveg
323
324 MOVV m_gsignal(R24), R25 // g.m.gsignal
325 BEQ R25, nosaveg
326 BEQ g, R25, nosaveg
327
328 MOVV (g_stack+stack_lo)(R25), R25 // g.m.gsignal.stack.lo
329 MOVV g, (R25)
330
331 JAL (R20)
332
333 MOVV R0, (R25)
334 JMP finish
335
336nosaveg:
337 JAL (R20)
338
339finish:
340 MOVV 0(R3), R7 // sec
341 MOVV 8(R3), R5 // nsec
342
343 MOVV R23, R3 // restore SP
344 // Restore vdsoPC, vdsoSP
345 // We don't worry about being signaled between the two stores.
346 // If we are not in a signal handler, we'll restore vdsoSP to 0,
347 // and no one will care about vdsoPC. If we are in a signal handler,
348 // we cannot receive another signal.
349 MOVV 16(R3), R25
350 MOVV R25, m_vdsoSP(R24)
351 MOVV 8(R3), R25
352 MOVV R25, m_vdsoPC(R24)
353
354 // sec is in R7, nsec in R5
355 // return nsec in R7
356 MOVV $1000000000, R4
357 MULVU R4, R7, R7
358 ADDVU R5, R7, R4
359 RET
360
361fallback:
362 MOVV $SYS_clock_gettime, R11
363 SYSCALL
364 JMP finish
365
366// func rtsigprocmask(how int32, new, old *sigset, size int32)
367TEXT runtime·rtsigprocmask<ABIInternal>(SB),NOSPLIT,$0
368 MOVV $SYS_rt_sigprocmask, R11
369 SYSCALL
370 MOVW $-4096, R5
371 BGEU R5, R4, 2(PC)
372 MOVV R0, 0xf1(R0) // crash
373 RET
374
375// func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
376TEXT runtime·rt_sigaction<ABIInternal>(SB),NOSPLIT,$0
377 MOVV $SYS_rt_sigaction, R11
378 SYSCALL
379 RET
380
381// Call the function stored in _cgo_sigaction using the GCC calling convention.
382TEXT runtime·callCgoSigaction<ABIInternal>(SB),NOSPLIT,$0
383 // R4: sig, R5: new, R6: old
384 MOVV _cgo_sigaction(SB), R7
385 SUBV $16, R3 // reserve 16 bytes for sp-8 where fp may be saved.
386 JAL (R7)
387 ADDV $16, R3
388 MOVW R4, R4
389 RET
390
391// func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
392TEXT runtime·sigfwd<ABIInternal>(SB),NOSPLIT,$0
393 // before:
394 // R4: fn, R5: sig, R6: info, R7: ctx
395 // after:
396 // R20: fn, R4: sig, R5: info, R6: ctx
397 MOVV R4, R20
398 MOVV R5, R4
399 MOVV R6, R5
400 MOVV R7, R6
401 JAL (R20)
402 RET
403
404// Called from c-abi, R4: sig, R5: info, R6: cxt
405// func sigtramp(signo, ureg, ctxt unsafe.Pointer)
406TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$168
407 // Save callee-save registers in the case of signal forwarding.
408 // Please refer to https://golang.org/issue/31827 .
409 SAVE_R22_TO_R31((4*8))
410 SAVE_F24_TO_F31((14*8))
411
412 // this might be called in external code context,
413 // where g is not set.
414 MOVB runtime·iscgo(SB), R7
415 BEQ R7, 2(PC)
416 JAL runtime·load_g(SB)
417
418 // R5 and R6 already contain info and ctx, respectively.
419 MOVV $runtime·sigtrampgo<ABIInternal>(SB), R7
420 JAL (R7)
421
422 // Restore callee-save registers.
423 RESTORE_R22_TO_R31((4*8))
424 RESTORE_F24_TO_F31((14*8))
425
426 RET
427
428// Called from c-abi, R4: sig, R5: info, R6: cxt
429TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$168
430 // Save callee-save registers because it's a callback from c code.
431 SAVE_R22_TO_R31((4*8))
432 SAVE_F24_TO_F31((14*8))
433
434 // R4, R5 and R6 already contain sig, info and ctx, respectively.
435 CALL runtime·sigprofNonGo<ABIInternal>(SB)
436
437 // Restore callee-save registers.
438 RESTORE_R22_TO_R31((4*8))
439 RESTORE_F24_TO_F31((14*8))
440 RET
441
442// Called from c-abi, R4: sig, R5: info, R6: cxt
443TEXT runtime·cgoSigtramp(SB),NOSPLIT|NOFRAME,$0
444 // The stack unwinder, presumably written in C, may not be able to
445 // handle Go frame correctly. So, this function is NOFRAME, and we
446 // save/restore LR manually.
447 MOVV R1, R12
448 // Save R30, g because they will be clobbered,
449 // we need to restore them before jump to sigtramp.
450 MOVV R30, R13
451 MOVV g, R14
452
453 // If no traceback function, do usual sigtramp.
454 MOVV runtime·cgoTraceback(SB), R15
455 BEQ R15, sigtramp
456
457 // If no traceback support function, which means that
458 // runtime/cgo was not linked in, do usual sigtramp.
459 MOVV _cgo_callers(SB), R15
460 BEQ R15, sigtramp
461
462 // Figure out if we are currently in a cgo call.
463 // If not, just do usual sigtramp.
464 CALL runtime·load_g(SB)
465 BEQ g, sigtrampnog // g == nil
466
467 MOVV g_m(g), R15
468 BEQ R15, sigtramp // g.m == nil
469 MOVW m_ncgo(R15), R16
470 BEQ R16, sigtramp // g.m.ncgo = 0
471 MOVV m_curg(R15), R16
472 BEQ R16, sigtramp // g.m.curg == nil
473 MOVV g_syscallsp(R16), R17
474 BEQ R17, sigtramp // g.m.curg.syscallsp == 0
475 MOVV m_cgoCallers(R15), R8 // R8 is the fifth arg in C calling convention.
476 BEQ R8, sigtramp // g.m.cgoCallers == nil
477 MOVW m_cgoCallersUse(R15), R16
478 BNE R16, sigtramp // g.m.cgoCallersUse != 0
479
480 // Jump to a function in runtime/cgo.
481 // That function, written in C, will call the user's traceback
482 // function with proper unwind info, and will then call back here.
483 // The first three arguments, and the fifth, are already in registers.
484 // Set the two remaining arguments now.
485 MOVV runtime·cgoTraceback(SB), R7
486 MOVV $runtime·sigtramp(SB), R9
487 MOVV _cgo_callers(SB), R15
488 MOVV R12, R1 // restore
489 MOVV R13, R30
490 MOVV R14, g
491 JMP (R15)
492
493sigtramp:
494 MOVV R12, R1 // restore
495 MOVV R13, R30
496 MOVV R14, g
497 JMP runtime·sigtramp(SB)
498
499sigtrampnog:
500 // Signal arrived on a non-Go thread. If this is SIGPROF, get a
501 // stack trace.
502 MOVW $27, R15 // 27 == SIGPROF
503 BNE R4, R15, sigtramp
504
505 MOVV $runtime·sigprofCallersUse(SB), R16
506 DBAR $0x14
507cas_again:
508 MOVV $1, R15
509 LL (R16), R17
510 BNE R17, fail
511 SC R15, (R16)
512 BEQ R15, cas_again
513 DBAR $0x14
514
515 // Jump to the traceback function in runtime/cgo.
516 // It will call back to sigprofNonGo, which will ignore the
517 // arguments passed in registers.
518 // First three arguments to traceback function are in registers already.
519 MOVV runtime·cgoTraceback(SB), R7
520 MOVV $runtime·sigprofCallers(SB), R8
521 MOVV $runtime·sigprofNonGoWrapper<>(SB), R9
522 MOVV _cgo_callers(SB), R15
523 MOVV R12, R1 // restore
524 MOVV R13, R30
525 MOVV R14, g
526 JMP (R15)
527
528fail:
529 DBAR $0x14
530 JMP sigtramp
531
532// func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int)
533TEXT runtime·sysMmap<ABIInternal>(SB),NOSPLIT,$0
534 MOVV $SYS_mmap, R11
535 SYSCALL
536 MOVW $-4096, R5
537 BGEU R5, R4, ok
538 SUBVU R4, R0, R5
539 MOVV $0, R4
540 RET
541ok:
542 MOVV $0, R5
543 RET
544
545// Call the function stored in _cgo_mmap using the GCC calling convention.
546// This must be called on the system stack.
547// func callCgoMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) uintptr
548TEXT runtime·callCgoMmap<ABIInternal>(SB),NOSPLIT,$0
549 MOVV _cgo_mmap(SB), R13
550 SUBV $16, R3 // reserve 16 bytes for sp-8 where fp may be saved.
551 JAL (R13)
552 ADDV $16, R3
553 MOVV R4, R4
554 RET
555
556// func sysMunmap(addr unsafe.Pointer, n uintptr)
557TEXT runtime·sysMunmap<ABIInternal>(SB),NOSPLIT,$0
558 MOVV $SYS_munmap, R11
559 SYSCALL
560 MOVW $-4096, R5
561 BGEU R5, R4, 2(PC)
562 MOVV R0, 0xf3(R0) // crash
563 RET
564
565// Call the function stored in _cgo_munmap using the GCC calling convention.
566// This must be called on the system stack.
567// func callCgoMunmap(addr unsafe.Pointer, n uintptr)
568TEXT runtime·callCgoMunmap<ABIInternal>(SB),NOSPLIT,$0
569 MOVV _cgo_munmap(SB), R13
570 SUBV $16, R3 // reserve 16 bytes for sp-8 where fp may be saved.
571 JAL (R13)
572 ADDV $16, R3
573 RET
574
575// func madvise(addr unsafe.Pointer, n uintptr, flags int32)
576TEXT runtime·madvise<ABIInternal>(SB),NOSPLIT,$0
577 MOVV $SYS_madvise, R11
578 SYSCALL
579 RET
580
581// func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32
582TEXT runtime·futex<ABIInternal>(SB),NOSPLIT,$0
583 MOVV $SYS_futex, R11
584 SYSCALL
585 RET
586
587// int64 clone(int32 flags, void *stk, M *mp, G *gp, void (*fn)(void));
588TEXT runtime·clone<ABIInternal>(SB),NOSPLIT,$0
589 // Copy mp, gp, fn off parent stack for use by child.
590 // Careful: Linux system call clobbers ???.
591 MOVV R6, R23
592 MOVV R7, R24
593 MOVV R8, R25
594
595 MOVV R23, -8(R5)
596 MOVV R24, -16(R5)
597 MOVV R25, -24(R5)
598 MOVV $1234, R23
599 MOVV R23, -32(R5)
600
601 MOVV $SYS_clone, R11
602 SYSCALL
603
604 // In parent, return.
605 BEQ R4, 2(PC)
606 RET
607
608 // In child, on new stack.
609 MOVV -32(R3), R23
610 MOVV $1234, R19
611 BEQ R23, R19, 2(PC)
612 MOVV R0, 0(R0)
613
614 // Initialize m->procid to Linux tid
615 MOVV $SYS_gettid, R11
616 SYSCALL
617
618 MOVV -24(R3), R25 // fn
619 MOVV -16(R3), R24 // g
620 MOVV -8(R3), R23 // m
621
622 BEQ R23, nog
623 BEQ R24, nog
624
625 MOVV R4, m_procid(R23)
626
627 // TODO: setup TLS.
628
629 // In child, set up new stack
630 MOVV R23, g_m(R24)
631 MOVV R24, g
632 //CALL runtime·stackcheck(SB)
633
634nog:
635 // Call fn
636 JAL (R25)
637
638 // It shouldn't return. If it does, exit that thread.
639 MOVW $111, R4
640 MOVV $SYS_exit, R11
641 SYSCALL
642 JMP -3(PC) // keep exiting
643
644// func sigaltstack(new, old *stackt)
645TEXT runtime·sigaltstack<ABIInternal>(SB),NOSPLIT,$0
646 MOVV $SYS_sigaltstack, R11
647 SYSCALL
648 MOVW $-4096, R5
649 BGEU R5, R4, 2(PC)
650 MOVV R0, 0xf1(R0) // crash
651 RET
652
653// func osyield()
654TEXT runtime·osyield<ABIInternal>(SB),NOSPLIT,$0
655 MOVV $SYS_sched_yield, R11
656 SYSCALL
657 RET
658
659// func sched_getaffinity(pid, len uintptr, buf *uintptr) int32
660TEXT runtime·sched_getaffinity<ABIInternal>(SB),NOSPLIT,$0
661 MOVV $SYS_sched_getaffinity, R11
662 SYSCALL
663 RET
664
665// func sbrk0() uintptr
666TEXT runtime·sbrk0<ABIInternal>(SB),NOSPLIT,$0
667 // Implemented as brk(NULL).
668 MOVV $0, R4
669 MOVV $SYS_brk, R11
670 SYSCALL
671 RET
672
673// unimplemented, only needed for android; declared in stubs_linux.go
674TEXT runtime·access(SB),$0-20
675 MOVV R0, 2(R0)
676 MOVW R0, ret+16(FP) // for vet
677 RET
678
679// unimplemented, only needed for android; declared in stubs_linux.go
680TEXT runtime·connect(SB),$0-28
681 MOVV R0, 2(R0)
682 MOVW R0, ret+24(FP) // for vet
683 RET
684
685// unimplemented, only needed for android; declared in stubs_linux.go
686TEXT runtime·socket(SB),$0-20
687 MOVV R0, 2(R0)
688 MOVW R0, ret+16(FP) // for vet
689 RET
690
691// func vgetrandom1(buf *byte, length uintptr, flags uint32, state uintptr, stateSize uintptr) int
692TEXT runtime·vgetrandom1<ABIInternal>(SB),NOSPLIT,$16
693 MOVV R3, R23
694
695 MOVV runtime·vdsoGetrandomSym(SB), R12
696
697 MOVV g_m(g), R24
698
699 MOVV m_vdsoPC(R24), R13
700 MOVV R13, 8(R3)
701 MOVV m_vdsoSP(R24), R13
702 MOVV R13, 16(R3)
703 MOVV R1, m_vdsoPC(R24)
704 MOVV $buf-8(FP), R13
705 MOVV R13, m_vdsoSP(R24)
706
707 AND $~15, R3
708
709 MOVBU runtime·iscgo(SB), R13
710 BNE R13, nosaveg
711 MOVV m_gsignal(R24), R13
712 BEQ R13, nosaveg
713 BEQ g, R13, nosaveg
714 MOVV (g_stack+stack_lo)(R13), R25
715 MOVV g, (R25)
716
717 JAL (R12)
718
719 MOVV R0, (R25)
720 JMP restore
721
722nosaveg:
723 JAL (R12)
724
725restore:
726 MOVV R23, R3
727 MOVV 16(R3), R25
728 MOVV R25, m_vdsoSP(R24)
729 MOVV 8(R3), R25
730 MOVV R25, m_vdsoPC(R24)
731 NOP R4 // Satisfy go vet, since the return value comes from the vDSO function.
732 RET
View as plain text