github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/golang.org/x/sys/unix/asm_zos_s390x.s (about)

     1  // Copyright 2020 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  //go:build zos && s390x && gc
     6  
     7  #include "textflag.h"
     8  
     9  #define PSALAA            1208(R0)
    10  #define GTAB64(x)           80(x)
    11  #define LCA64(x)            88(x)
    12  #define CAA(x)               8(x)
    13  #define EDCHPXV(x)        1016(x)       // in the CAA
    14  #define SAVSTACK_ASYNC(x)  336(x)       // in the LCA
    15  
    16  // SS_*, where x=SAVSTACK_ASYNC
    17  #define SS_LE(x)             0(x)
    18  #define SS_GO(x)             8(x)
    19  #define SS_ERRNO(x)         16(x)
    20  #define SS_ERRNOJR(x)       20(x)
    21  
    22  #define LE_CALL BYTE $0x0D; BYTE $0x76; // BL R7, R6
    23  
    24  TEXT ·clearErrno(SB),NOSPLIT,$0-0
    25  	BL	addrerrno<>(SB)
    26  	MOVD	$0, 0(R3)
    27  	RET
    28  
    29  // Returns the address of errno in R3.
    30  TEXT addrerrno<>(SB),NOSPLIT|NOFRAME,$0-0
    31  	// Get library control area (LCA).
    32  	MOVW	PSALAA, R8
    33  	MOVD	LCA64(R8), R8
    34  
    35  	// Get __errno FuncDesc.
    36  	MOVD	CAA(R8), R9
    37  	MOVD	EDCHPXV(R9), R9
    38  	ADD	$(0x156*16), R9
    39  	LMG	0(R9), R5, R6
    40  
    41  	// Switch to saved LE stack.
    42  	MOVD	SAVSTACK_ASYNC(R8), R9
    43  	MOVD	0(R9), R4
    44  	MOVD	$0, 0(R9)
    45  
    46  	// Call __errno function.
    47  	LE_CALL
    48  	NOPH
    49  
    50  	// Switch back to Go stack.
    51  	XOR	R0, R0      // Restore R0 to $0.
    52  	MOVD	R4, 0(R9)   // Save stack pointer.
    53  	RET
    54  
    55  TEXT ·syscall_syscall(SB),NOSPLIT,$0-56
    56  	BL	runtime·entersyscall(SB)
    57  	MOVD	a1+8(FP), R1
    58  	MOVD	a2+16(FP), R2
    59  	MOVD	a3+24(FP), R3
    60  
    61  	// Get library control area (LCA).
    62  	MOVW	PSALAA, R8
    63  	MOVD	LCA64(R8), R8
    64  
    65  	// Get function.
    66  	MOVD	CAA(R8), R9
    67  	MOVD	EDCHPXV(R9), R9
    68  	MOVD	trap+0(FP), R5
    69  	SLD	$4, R5
    70  	ADD	R5, R9
    71  	LMG	0(R9), R5, R6
    72  
    73  	// Restore LE stack.
    74  	MOVD	SAVSTACK_ASYNC(R8), R9
    75  	MOVD	0(R9), R4
    76  	MOVD	$0, 0(R9)
    77  
    78  	// Call function.
    79  	LE_CALL
    80  	NOPH
    81  	XOR	R0, R0      // Restore R0 to $0.
    82  	MOVD	R4, 0(R9)   // Save stack pointer.
    83  
    84  	MOVD	R3, r1+32(FP)
    85  	MOVD	R0, r2+40(FP)
    86  	MOVD	R0, err+48(FP)
    87  	MOVW	R3, R4
    88  	CMP	R4, $-1
    89  	BNE	done
    90  	BL	addrerrno<>(SB)
    91  	MOVWZ	0(R3), R3
    92  	MOVD	R3, err+48(FP)
    93  done:
    94  	BL	runtime·exitsyscall(SB)
    95  	RET
    96  
    97  TEXT ·syscall_rawsyscall(SB),NOSPLIT,$0-56
    98  	MOVD	a1+8(FP), R1
    99  	MOVD	a2+16(FP), R2
   100  	MOVD	a3+24(FP), R3
   101  
   102  	// Get library control area (LCA).
   103  	MOVW	PSALAA, R8
   104  	MOVD	LCA64(R8), R8
   105  
   106  	// Get function.
   107  	MOVD	CAA(R8), R9
   108  	MOVD	EDCHPXV(R9), R9
   109  	MOVD	trap+0(FP), R5
   110  	SLD	$4, R5
   111  	ADD	R5, R9
   112  	LMG	0(R9), R5, R6
   113  
   114  	// Restore LE stack.
   115  	MOVD	SAVSTACK_ASYNC(R8), R9
   116  	MOVD	0(R9), R4
   117  	MOVD	$0, 0(R9)
   118  
   119  	// Call function.
   120  	LE_CALL
   121  	NOPH
   122  	XOR	R0, R0      // Restore R0 to $0.
   123  	MOVD	R4, 0(R9)   // Save stack pointer.
   124  
   125  	MOVD	R3, r1+32(FP)
   126  	MOVD	R0, r2+40(FP)
   127  	MOVD	R0, err+48(FP)
   128  	MOVW	R3, R4
   129  	CMP	R4, $-1
   130  	BNE	done
   131  	BL	addrerrno<>(SB)
   132  	MOVWZ	0(R3), R3
   133  	MOVD	R3, err+48(FP)
   134  done:
   135  	RET
   136  
   137  TEXT ·syscall_syscall6(SB),NOSPLIT,$0-80
   138  	BL	runtime·entersyscall(SB)
   139  	MOVD	a1+8(FP), R1
   140  	MOVD	a2+16(FP), R2
   141  	MOVD	a3+24(FP), R3
   142  
   143  	// Get library control area (LCA).
   144  	MOVW	PSALAA, R8
   145  	MOVD	LCA64(R8), R8
   146  
   147  	// Get function.
   148  	MOVD	CAA(R8), R9
   149  	MOVD	EDCHPXV(R9), R9
   150  	MOVD	trap+0(FP), R5
   151  	SLD	$4, R5
   152  	ADD	R5, R9
   153  	LMG	0(R9), R5, R6
   154  
   155  	// Restore LE stack.
   156  	MOVD	SAVSTACK_ASYNC(R8), R9
   157  	MOVD	0(R9), R4
   158  	MOVD	$0, 0(R9)
   159  
   160  	// Fill in parameter list.
   161  	MOVD	a4+32(FP), R12
   162  	MOVD	R12, (2176+24)(R4)
   163  	MOVD	a5+40(FP), R12
   164  	MOVD	R12, (2176+32)(R4)
   165  	MOVD	a6+48(FP), R12
   166  	MOVD	R12, (2176+40)(R4)
   167  
   168  	// Call function.
   169  	LE_CALL
   170  	NOPH
   171  	XOR	R0, R0      // Restore R0 to $0.
   172  	MOVD	R4, 0(R9)   // Save stack pointer.
   173  
   174  	MOVD	R3, r1+56(FP)
   175  	MOVD	R0, r2+64(FP)
   176  	MOVD	R0, err+72(FP)
   177  	MOVW	R3, R4
   178  	CMP	R4, $-1
   179  	BNE	done
   180  	BL	addrerrno<>(SB)
   181  	MOVWZ	0(R3), R3
   182  	MOVD	R3, err+72(FP)
   183  done:
   184  	BL	runtime·exitsyscall(SB)
   185  	RET
   186  
   187  TEXT ·syscall_rawsyscall6(SB),NOSPLIT,$0-80
   188  	MOVD	a1+8(FP), R1
   189  	MOVD	a2+16(FP), R2
   190  	MOVD	a3+24(FP), R3
   191  
   192  	// Get library control area (LCA).
   193  	MOVW	PSALAA, R8
   194  	MOVD	LCA64(R8), R8
   195  
   196  	// Get function.
   197  	MOVD	CAA(R8), R9
   198  	MOVD	EDCHPXV(R9), R9
   199  	MOVD	trap+0(FP), R5
   200  	SLD	$4, R5
   201  	ADD	R5, R9
   202  	LMG	0(R9), R5, R6
   203  
   204  	// Restore LE stack.
   205  	MOVD	SAVSTACK_ASYNC(R8), R9
   206  	MOVD	0(R9), R4
   207  	MOVD	$0, 0(R9)
   208  
   209  	// Fill in parameter list.
   210  	MOVD	a4+32(FP), R12
   211  	MOVD	R12, (2176+24)(R4)
   212  	MOVD	a5+40(FP), R12
   213  	MOVD	R12, (2176+32)(R4)
   214  	MOVD	a6+48(FP), R12
   215  	MOVD	R12, (2176+40)(R4)
   216  
   217  	// Call function.
   218  	LE_CALL
   219  	NOPH
   220  	XOR	R0, R0      // Restore R0 to $0.
   221  	MOVD	R4, 0(R9)   // Save stack pointer.
   222  
   223  	MOVD	R3, r1+56(FP)
   224  	MOVD	R0, r2+64(FP)
   225  	MOVD	R0, err+72(FP)
   226  	MOVW	R3, R4
   227  	CMP	R4, $-1
   228  	BNE	done
   229  	BL	·rrno<>(SB)
   230  	MOVWZ	0(R3), R3
   231  	MOVD	R3, err+72(FP)
   232  done:
   233  	RET
   234  
   235  TEXT ·syscall_syscall9(SB),NOSPLIT,$0
   236  	BL	runtime·entersyscall(SB)
   237  	MOVD	a1+8(FP), R1
   238  	MOVD	a2+16(FP), R2
   239  	MOVD	a3+24(FP), R3
   240  
   241  	// Get library control area (LCA).
   242  	MOVW	PSALAA, R8
   243  	MOVD	LCA64(R8), R8
   244  
   245  	// Get function.
   246  	MOVD	CAA(R8), R9
   247  	MOVD	EDCHPXV(R9), R9
   248  	MOVD	trap+0(FP), R5
   249  	SLD	$4, R5
   250  	ADD	R5, R9
   251  	LMG	0(R9), R5, R6
   252  
   253  	// Restore LE stack.
   254  	MOVD	SAVSTACK_ASYNC(R8), R9
   255  	MOVD	0(R9), R4
   256  	MOVD	$0, 0(R9)
   257  
   258  	// Fill in parameter list.
   259  	MOVD	a4+32(FP), R12
   260  	MOVD	R12, (2176+24)(R4)
   261  	MOVD	a5+40(FP), R12
   262  	MOVD	R12, (2176+32)(R4)
   263  	MOVD	a6+48(FP), R12
   264  	MOVD	R12, (2176+40)(R4)
   265  	MOVD	a7+56(FP), R12
   266  	MOVD	R12, (2176+48)(R4)
   267  	MOVD	a8+64(FP), R12
   268  	MOVD	R12, (2176+56)(R4)
   269  	MOVD	a9+72(FP), R12
   270  	MOVD	R12, (2176+64)(R4)
   271  
   272  	// Call function.
   273  	LE_CALL
   274  	NOPH
   275  	XOR	R0, R0      // Restore R0 to $0.
   276  	MOVD	R4, 0(R9)   // Save stack pointer.
   277  
   278  	MOVD	R3, r1+80(FP)
   279  	MOVD	R0, r2+88(FP)
   280  	MOVD	R0, err+96(FP)
   281  	MOVW	R3, R4
   282  	CMP	R4, $-1
   283  	BNE	done
   284  	BL	addrerrno<>(SB)
   285  	MOVWZ	0(R3), R3
   286  	MOVD	R3, err+96(FP)
   287  done:
   288          BL	runtime·exitsyscall(SB)
   289          RET
   290  
   291  TEXT ·syscall_rawsyscall9(SB),NOSPLIT,$0
   292  	MOVD	a1+8(FP), R1
   293  	MOVD	a2+16(FP), R2
   294  	MOVD	a3+24(FP), R3
   295  
   296  	// Get library control area (LCA).
   297  	MOVW	PSALAA, R8
   298  	MOVD	LCA64(R8), R8
   299  
   300  	// Get function.
   301  	MOVD	CAA(R8), R9
   302  	MOVD	EDCHPXV(R9), R9
   303  	MOVD	trap+0(FP), R5
   304  	SLD	$4, R5
   305  	ADD	R5, R9
   306  	LMG	0(R9), R5, R6
   307  
   308  	// Restore LE stack.
   309  	MOVD	SAVSTACK_ASYNC(R8), R9
   310  	MOVD	0(R9), R4
   311  	MOVD	$0, 0(R9)
   312  
   313  	// Fill in parameter list.
   314  	MOVD	a4+32(FP), R12
   315  	MOVD	R12, (2176+24)(R4)
   316  	MOVD	a5+40(FP), R12
   317  	MOVD	R12, (2176+32)(R4)
   318  	MOVD	a6+48(FP), R12
   319  	MOVD	R12, (2176+40)(R4)
   320  	MOVD	a7+56(FP), R12
   321  	MOVD	R12, (2176+48)(R4)
   322  	MOVD	a8+64(FP), R12
   323  	MOVD	R12, (2176+56)(R4)
   324  	MOVD	a9+72(FP), R12
   325  	MOVD	R12, (2176+64)(R4)
   326  
   327  	// Call function.
   328  	LE_CALL
   329  	NOPH
   330  	XOR	R0, R0      // Restore R0 to $0.
   331  	MOVD	R4, 0(R9)   // Save stack pointer.
   332  
   333  	MOVD	R3, r1+80(FP)
   334  	MOVD	R0, r2+88(FP)
   335  	MOVD	R0, err+96(FP)
   336  	MOVW	R3, R4
   337  	CMP	R4, $-1
   338  	BNE	done
   339  	BL	addrerrno<>(SB)
   340  	MOVWZ	0(R3), R3
   341  	MOVD	R3, err+96(FP)
   342  done:
   343  	RET
   344  
   345  // func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64)
   346  TEXT ·svcCall(SB),NOSPLIT,$0
   347  	BL	runtime·save_g(SB)   // Save g and stack pointer
   348  	MOVW	PSALAA, R8
   349  	MOVD	LCA64(R8), R8
   350  	MOVD	SAVSTACK_ASYNC(R8), R9
   351  	MOVD	R15, 0(R9)
   352  
   353  	MOVD	argv+8(FP), R1       // Move function arguments into registers
   354  	MOVD	dsa+16(FP), g
   355  	MOVD	fnptr+0(FP), R15
   356  
   357  	BYTE	$0x0D                // Branch to function
   358  	BYTE	$0xEF
   359  
   360  	BL	runtime·load_g(SB)   // Restore g and stack pointer
   361  	MOVW	PSALAA, R8
   362  	MOVD	LCA64(R8), R8
   363  	MOVD	SAVSTACK_ASYNC(R8), R9
   364  	MOVD	0(R9), R15
   365  
   366  	RET
   367  
   368  // func svcLoad(name *byte) unsafe.Pointer
   369  TEXT ·svcLoad(SB),NOSPLIT,$0
   370  	MOVD	R15, R2          // Save go stack pointer
   371  	MOVD	name+0(FP), R0   // Move SVC args into registers
   372  	MOVD	$0x80000000, R1
   373  	MOVD	$0, R15
   374  	BYTE	$0x0A            // SVC 08 LOAD
   375  	BYTE	$0x08
   376  	MOVW	R15, R3          // Save return code from SVC
   377  	MOVD	R2, R15          // Restore go stack pointer
   378  	CMP	R3, $0           // Check SVC return code
   379  	BNE	error
   380  
   381  	MOVD	$-2, R3          // Reset last bit of entry point to zero
   382  	AND	R0, R3
   383  	MOVD	R3, addr+8(FP)   // Return entry point returned by SVC
   384  	CMP	R0, R3           // Check if last bit of entry point was set
   385  	BNE	done
   386  
   387  	MOVD	R15, R2          // Save go stack pointer
   388  	MOVD	$0, R15          // Move SVC args into registers (entry point still in r0 from SVC 08)
   389  	BYTE	$0x0A            // SVC 09 DELETE
   390  	BYTE	$0x09
   391  	MOVD	R2, R15          // Restore go stack pointer
   392  
   393  error:
   394  	MOVD	$0, addr+8(FP)   // Return 0 on failure
   395  done:
   396  	XOR	R0, R0           // Reset r0 to 0
   397  	RET
   398  
   399  // func svcUnload(name *byte, fnptr unsafe.Pointer) int64
   400  TEXT ·svcUnload(SB),NOSPLIT,$0
   401  	MOVD	R15, R2          // Save go stack pointer
   402  	MOVD	name+0(FP), R0   // Move SVC args into registers
   403  	MOVD	addr+8(FP), R15
   404  	BYTE	$0x0A            // SVC 09
   405  	BYTE	$0x09
   406  	XOR	R0, R0           // Reset r0 to 0
   407  	MOVD	R15, R1          // Save SVC return code
   408  	MOVD	R2, R15          // Restore go stack pointer
   409  	MOVD	R1, rc+0(FP)     // Return SVC return code
   410  	RET
   411  
   412  // func gettid() uint64
   413  TEXT ·gettid(SB), NOSPLIT, $0
   414  	// Get library control area (LCA).
   415  	MOVW PSALAA, R8
   416  	MOVD LCA64(R8), R8
   417  
   418  	// Get CEECAATHDID
   419  	MOVD CAA(R8), R9
   420  	MOVD 0x3D0(R9), R9
   421  	MOVD R9, ret+0(FP)
   422  
   423  	RET