syscall

package
v0.0.0-...-c52770d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: BSD-3-Clause Imports: 4 Imported by: 4

Documentation

Overview

Package syscall provides support for system call for TamaGo unikernels launched in supervised mode through monitor.Exec (see monitor package).

This package is only meant to be used with `GOOS=tamago` as supported by the TamaGo framework for bare metal Go on ARM/RISC-V SoCs, see https://github.com/usbarmory/tamago.

Index

Constants

View Source
const (
	SYS_EXIT = iota
	SYS_WRITE
	SYS_NANOTIME
	SYS_GETRANDOM
	SYS_RPC_REQ
	SYS_RPC_RES
)

Variables

This section is empty.

Functions

func Call

func Call(serviceMethod string, args interface{}, reply interface{}) error

Call is a convenience method that issues an RPC call on a disposable client created with NewClient(), to avoid concurrent reads and writes a mutex is held to prevent interleaved invocations.

func Exit

func Exit()

Exit terminates the execution context scheduling through a system call to the supervisor.

func GetRandom

func GetRandom(b []byte, n uint)

GetRandom fills a byte array with random values through a system call to the supervisor.

func Nanotime

func Nanotime() int64

Nanotime returns the system time in nanoseconds through a system call to the supervisor.

func NewClient

func NewClient() *rpc.Client

NewClient returns a new client suitable for RPC calls to the supervisor. The client automatically closes after Call() is invoked on it the first time, therefore a new instance is needed for each call (also see Call()).

func Print

func Print(c byte)

Print prints a single character on standard output through a system call to the supervisor.

func Read

func Read(trap uint, p []byte, n uint) int

Read requests a transfer of n bytes into p from the supervisor through the syscall specified as first argument. It can be used to implement syscalls that require request/responses data streams, along with Write().

The underlying connection used by the RPC client (see NewClient()) is an example of such implementation.

func Supervisor

func Supervisor()

Supervisors triggers a supervisor call (SWI/SVC).

func Write

func Write(trap uint, p []byte, n uint)

Write requests a transfer of n bytes from p to the supervisor through the syscall specified as first argument. It can be used to implement syscalls that require request/responses data streams, along with Read().

The underlying connection used by the RPC client (see NewClient()) is an example of such implementation.

Types

type Stream

type Stream struct {
	// ReadSyscall is the syscall number associated to Read()
	ReadSyscall uint
	// ReadSyscall is the syscall number associated to Write()
	WriteSyscall uint
}

Stream implements a data stream interface to exchange data buffers between the security monitor and a lower privilege execution context over syscalls.

It is used by NewClient() to stream JSON-RPC calls from an applet and receive responses from the supervisor, over syscalls.

The implementation is not safe against concurrent reads and writes, which should be avoided.

func (*Stream) Close

func (s *Stream) Close() error

Close has no effect.

func (*Stream) Read

func (s *Stream) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes into p, it never returns an error. The read is requested, through the Stream ReadSyscall, to the supervisor.

func (*Stream) Write

func (s *Stream) Write(p []byte) (n int, err error)

Write writes len(p) bytes from p to the underlying data stream, it never returns an error. The write is issued, through the Stream WriteSyscall, to the supervisor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL