...

Text file src/runtime/rt0_linux_riscv64.s

Documentation: runtime

     1// Copyright 2015 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#include "textflag.h"
     6
     7TEXT _rt0_riscv64_linux(SB),NOSPLIT|NOFRAME,$0
     8	MOV	0(X2), A0	// argc
     9	ADD	$8, X2, A1	// argv
    10	JMP	main(SB)
    11
    12// When building with -buildmode=c-shared, this symbol is called when the shared
    13// library is loaded.
    14TEXT _rt0_riscv64_linux_lib(SB),NOSPLIT,$224
    15	// Preserve callee-save registers, along with X1 (LR).
    16	MOV	X1, (8*3)(X2)
    17	MOV	X8, (8*4)(X2)
    18	MOV	X9, (8*5)(X2)
    19	MOV	X18, (8*6)(X2)
    20	MOV	X19, (8*7)(X2)
    21	MOV	X20, (8*8)(X2)
    22	MOV	X21, (8*9)(X2)
    23	MOV	X22, (8*10)(X2)
    24	MOV	X23, (8*11)(X2)
    25	MOV	X24, (8*12)(X2)
    26	MOV	X25, (8*13)(X2)
    27	MOV	X26, (8*14)(X2)
    28	MOV	g, (8*15)(X2)
    29	MOVD	F8, (8*16)(X2)
    30	MOVD	F9, (8*17)(X2)
    31	MOVD	F18, (8*18)(X2)
    32	MOVD	F19, (8*19)(X2)
    33	MOVD	F20, (8*20)(X2)
    34	MOVD	F21, (8*21)(X2)
    35	MOVD	F22, (8*22)(X2)
    36	MOVD	F23, (8*23)(X2)
    37	MOVD	F24, (8*24)(X2)
    38	MOVD	F25, (8*25)(X2)
    39	MOVD	F26, (8*26)(X2)
    40	MOVD	F27, (8*27)(X2)
    41
    42	// Initialize g as nil in case of using g later e.g. sigaction in cgo_sigaction.go
    43	MOV	X0, g
    44
    45	MOV	A0, _rt0_riscv64_linux_lib_argc<>(SB)
    46	MOV	A1, _rt0_riscv64_linux_lib_argv<>(SB)
    47
    48	// Synchronous initialization.
    49	MOV	$runtime·libpreinit(SB), T0
    50	JALR	RA, T0
    51
    52	// Create a new thread to do the runtime initialization and return.
    53	MOV	_cgo_sys_thread_create(SB), T0
    54	BEQZ	T0, nocgo
    55	MOV	$_rt0_riscv64_linux_lib_go(SB), A0
    56	MOV	$0, A1
    57	JALR	RA, T0
    58	JMP	restore
    59
    60nocgo:
    61	MOV	$0x800000, A0                     // stacksize = 8192KB
    62	MOV	$_rt0_riscv64_linux_lib_go(SB), A1
    63	MOV	A0, 8(X2)
    64	MOV	A1, 16(X2)
    65	MOV	$runtime·newosproc0(SB), T0
    66	JALR	RA, T0
    67
    68restore:
    69	// Restore callee-save registers, along with X1 (LR).
    70	MOV	(8*3)(X2), X1
    71	MOV	(8*4)(X2), X8
    72	MOV	(8*5)(X2), X9
    73	MOV	(8*6)(X2), X18
    74	MOV	(8*7)(X2), X19
    75	MOV	(8*8)(X2), X20
    76	MOV	(8*9)(X2), X21
    77	MOV	(8*10)(X2), X22
    78	MOV	(8*11)(X2), X23
    79	MOV	(8*12)(X2), X24
    80	MOV	(8*13)(X2), X25
    81	MOV	(8*14)(X2), X26
    82	MOV	(8*15)(X2), g
    83	MOVD	(8*16)(X2), F8
    84	MOVD	(8*17)(X2), F9
    85	MOVD	(8*18)(X2), F18
    86	MOVD	(8*19)(X2), F19
    87	MOVD	(8*20)(X2), F20
    88	MOVD	(8*21)(X2), F21
    89	MOVD	(8*22)(X2), F22
    90	MOVD	(8*23)(X2), F23
    91	MOVD	(8*24)(X2), F24
    92	MOVD	(8*25)(X2), F25
    93	MOVD	(8*26)(X2), F26
    94	MOVD	(8*27)(X2), F27
    95
    96	RET
    97
    98TEXT _rt0_riscv64_linux_lib_go(SB),NOSPLIT,$0
    99	MOV	_rt0_riscv64_linux_lib_argc<>(SB), A0
   100	MOV	_rt0_riscv64_linux_lib_argv<>(SB), A1
   101	MOV	$runtime·rt0_go(SB), T0
   102	JALR	ZERO, T0
   103
   104DATA _rt0_riscv64_linux_lib_argc<>(SB)/8, $0
   105GLOBL _rt0_riscv64_linux_lib_argc<>(SB),NOPTR, $8
   106DATA _rt0_riscv64_linux_lib_argv<>(SB)/8, $0
   107GLOBL _rt0_riscv64_linux_lib_argv<>(SB),NOPTR, $8
   108
   109
   110TEXT main(SB),NOSPLIT|NOFRAME,$0
   111	MOV	$runtime·rt0_go(SB), T0
   112	JALR	ZERO, T0

View as plain text