github.com/jspc/eggos@v0.5.1-0.20221028160421-556c75c878a5/kernel/isyscall/syscall_amd64.go (about)

     1  package isyscall
     2  
     3  import "unsafe"
     4  
     5  // must sync with kernel.trapFrame
     6  type trapFrame struct {
     7  	AX, BX, CX, DX    uintptr
     8  	BP, SI, DI, R8    uintptr
     9  	R9, R10, R11, R12 uintptr
    10  	R13, R14, R15     uintptr
    11  
    12  	Trapno, Err uintptr
    13  
    14  	// pushed by hardware
    15  	IP, CS, FLAGS, SP, SS uintptr
    16  }
    17  
    18  func NewRequest(tf uintptr) Request {
    19  	return Request{
    20  		tf: (*trapFrame)(unsafe.Pointer(tf)),
    21  	}
    22  }
    23  
    24  //go:nosplit
    25  func (t *trapFrame) NO() uintptr {
    26  	return t.AX
    27  }
    28  
    29  //go:nosplit
    30  func (t *trapFrame) Arg(n int) uintptr {
    31  	switch n {
    32  	case 0:
    33  		return t.DI
    34  	case 1:
    35  		return t.SI
    36  	case 2:
    37  		return t.DX
    38  	case 3:
    39  		return t.R10
    40  	case 4:
    41  		return t.R8
    42  	case 5:
    43  		return t.R9
    44  	default:
    45  		return 0
    46  	}
    47  }
    48  
    49  //go:nosplit
    50  func (t *trapFrame) SetRet(v uintptr) {
    51  	t.AX = v
    52  }
    53  
    54  //go:nosplit
    55  func (t *trapFrame) Ret() uintptr {
    56  	return t.AX
    57  }