github.com/usbarmory/GoTEE@v0.0.0-20240405084336-c52770d9fcdb/monitor/syscall_arm.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.R0)
    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.R1)
    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.R2)
    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.R0 = uint32(v & 0xffffffff)
    32  		ctx.R1 = uint32(v >> 32)
    33  	case uint:
    34  		ctx.R0 = uint32(v)
    35  	case int64:
    36  		ctx.R0 = uint32(v & 0xffffffff)
    37  		ctx.R1 = uint32(v >> 32)
    38  	case int:
    39  		ctx.R0 = uint32(v)
    40  	default:
    41  		panic("invalid return type")
    42  	}
    43  }