github.com/usbarmory/GoTEE@v0.0.0-20240405084336-c52770d9fcdb/syscall/syscall.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 syscall provides support for system call for TamaGo unikernels
     8  // launched in supervised mode through monitor.Exec (see monitor package).
     9  //
    10  // This package is only meant to be used with `GOOS=tamago` as supported by the
    11  // TamaGo framework for bare metal Go on ARM/RISC-V SoCs, see
    12  // https://github.com/usbarmory/tamago.
    13  package syscall
    14  
    15  // defined in syscall_*.s
    16  
    17  // Supervisors triggers a supervisor call (SWI/SVC).
    18  func Supervisor()
    19  
    20  // Exit terminates the execution context scheduling through a system call to
    21  // the supervisor.
    22  func Exit()
    23  
    24  // Print prints a single character on standard output through a system call to
    25  // the supervisor.
    26  func Print(c byte)
    27  
    28  // Nanotime returns the system time in nanoseconds through a system call to the
    29  // supervisor.
    30  func Nanotime() int64
    31  
    32  // GetRandom fills a byte array with random values through a system call to the
    33  // supervisor.
    34  func GetRandom(b []byte, n uint) {
    35  	Write(SYS_GETRANDOM, b, n)
    36  }
    37  
    38  // Read requests a transfer of n bytes into p from the supervisor through the
    39  // syscall specified as first argument. It can be used to implement syscalls
    40  // that require request/responses data streams, along with Write().
    41  //
    42  // The underlying connection used by the RPC client (see NewClient()) is an
    43  // example of such implementation.
    44  func Read(trap uint, p []byte, n uint) int
    45  
    46  // Write requests a transfer of n bytes from p to the supervisor through the
    47  // syscall specified as first argument. It can be used to implement syscalls
    48  // that require request/responses data streams, along with Read().
    49  //
    50  // The underlying connection used by the RPC client (see NewClient()) is an
    51  // example of such implementation.
    52  func Write(trap uint, p []byte, n uint)