github.com/usbarmory/GoTEE@v0.0.0-20240405084336-c52770d9fcdb/monitor/syscall_riscv64.go (about)

     1  // Copyright (c) WithSecure Corporation
     2  // https://foundry.withsecure.com
     3  //
     4  // Use of this source code is governed by the license
     5  // that can be found in the LICENSE file.
     6  
     7  package monitor
     8  
     9  // A0 returns the register treated as first argument for GoTEE secure monitor
    10  // calls.
    11  func (ctx *ExecCtx) A0() uint {
    12  	return uint(ctx.X10)
    13  }
    14  
    15  // A1 returns the register treated as second argument for GoTEE secure monitor
    16  // calls.
    17  func (ctx *ExecCtx) A1() uint {
    18  	return uint(ctx.X11)
    19  }
    20  
    21  // A2 returns the register treated as third argument for GoTEE secure monitor
    22  // calls.
    23  func (ctx *ExecCtx) A2() uint {
    24  	return uint(ctx.X12)
    25  }
    26  
    27  // Ret sets the return value for GoTEE secure monitor calls.
    28  func (ctx *ExecCtx) Ret(val interface{}) {
    29  	switch v := val.(type) {
    30  	case uint64:
    31  		ctx.X10 = v
    32  	case uint:
    33  		ctx.X10 = uint64(v)
    34  	case int64:
    35  		ctx.X10 = uint64(v)
    36  	case int:
    37  		ctx.X10 = uint64(v)
    38  	default:
    39  		panic("invalid return type")
    40  	}
    41  }