syscallabi

package
v0.0.0-...-057c053 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolFromUintptr

func BoolFromUintptr(v uintptr) bool

BoolFromUintptr extracts a boolean stored as a uintptr for syscall arguments or return values.

func BoolToUintptr

func BoolToUintptr(v bool) uintptr

BoolToUintptr stores a boolean as a uintptr for syscall arguments or return values.

func ErrErrno

func ErrErrno(err error) uintptr

func ErrnoErr

func ErrnoErr(e uintptr) error

ErrnoErr returns common boxed Errno values, to prevent allocations at runtime.

func Setup

func Setup()

Setup configures the gosim runtime to allocate a Syscall struct for each goroutine.

Types

type ByteSliceView

type ByteSliceView = SliceView[byte]

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

The Dispatcher is the bridge between user space code and OS code. User space goroutines call Dispatcher.Dispatch and the dispatcher runs OS.HandleSyscall on the OS goroutine.

func NewDispatcher

func NewDispatcher() Dispatcher

NewDispatcher creates a new Dispatcher.

func (Dispatcher) Dispatch

func (b Dispatcher) Dispatch(syscall *Syscall)

func (Dispatcher) Run

func (b Dispatcher) Run()

type OS

type OS interface {
	HandleSyscall(*Syscall)
}

OS is the interface for types that implement the syscall logic.

Implementations of this interface are generated by gensyscall.

type PollDesc

type PollDesc struct {
	// contains filtered or unexported fields
}

PollDesc is a poll descriptor like the go runtime's netpoll descriptors.

Blocking operations pass poll descriptors to the OS, which tracks those descriptors and marks them as readable or writable using a Pollers.

func AllocPollDesc

func AllocPollDesc(fd int) *PollDesc

func (*PollDesc) Close

func (pd *PollDesc) Close()

func (*PollDesc) FD

func (pd *PollDesc) FD() int

func (*PollDesc) Reset

func (pd *PollDesc) Reset(mode int) int

func (*PollDesc) SetDeadline

func (pd *PollDesc) SetDeadline(d int64, mode int)

func (*PollDesc) Unblock

func (pd *PollDesc) Unblock()

func (*PollDesc) Wait

func (pd *PollDesc) Wait(mode int) int

func (*PollDesc) WaitCanceled

func (pd *PollDesc) WaitCanceled(mode int)

type Pollers

type Pollers struct {
	// contains filtered or unexported fields
}

func (*Pollers) Add

func (ps *Pollers) Add(p *PollDesc)

func (*Pollers) NotifyCanRead

func (ps *Pollers) NotifyCanRead(can bool)

func (*Pollers) NotifyCanWrite

func (ps *Pollers) NotifyCanWrite(can bool)

func (*Pollers) Remove

func (ps *Pollers) Remove(p *PollDesc)

type SliceView

type SliceView[T any] struct {
	Ptr []T
}

SliceView is a OS-wrapper around slices passed from user space. It lets the OS access user space memory without triggering the race detector.

func NewSliceView

func NewSliceView[T any](ptr *T, len uintptr) SliceView[T]

func (SliceView[T]) Len

func (b SliceView[T]) Len() int

func (SliceView[T]) Read

func (b SliceView[T]) Read(into []T) int

func (SliceView[T]) Slice

func (b SliceView[T]) Slice(from, to int) SliceView[T]

func (SliceView[T]) SliceFrom

func (b SliceView[T]) SliceFrom(from int) SliceView[T]

func (SliceView[T]) Write

func (b SliceView[T]) Write(from []T) int

type Syscall

type Syscall struct {
	OS OS

	Trap                               uintptr
	Int0, Int1, Int2, Int3, Int4, Int5 uintptr
	Ptr0, Ptr1, Ptr2, Ptr3, Ptr4       any
	R0, R1                             uintptr
	RPtr0                              any
	Errno                              uintptr

	Sema uint32
}

Syscall holds the arguments and return values of gosim syscalls.

Syscalls are calls from user code to high-level system calls in the os package. To prevent allocations, each goroutine has a single Syscall that gets reused and be retrieved using GetGoroutineLocalSyscall.

Syscalls are different from upcalls, which calls in this package from user goroutines that execute code on the scheduler goroutine.

func GetGoroutineLocalSyscall

func GetGoroutineLocalSyscall() *Syscall

GetGoroutineLocalSyscall returns the per-goroutine pre-allocated Syscall struct.

Sharing Syscalls is safe because each goroutine invokes at most one syscall at a time.

TODO: Just pool them instead?

func (*Syscall) Complete

func (u *Syscall) Complete()

Complete marks the system call completed and lets Wait return.

func (*Syscall) Wait

func (u *Syscall) Wait()

Wait waits for the system call to be completed.

type ValueView

type ValueView[T any] struct {
	// contains filtered or unexported fields
}

ValueView is a OS-wrapper around pointers passed from user space. It lets the OS access user space memory without triggering the race detector.

func NewValueView

func NewValueView[T any](ptr *T) ValueView[T]

func (ValueView[T]) Get

func (s ValueView[T]) Get() T

func (ValueView[T]) Set

func (s ValueView[T]) Set(v T)

func (ValueView[T]) UnsafePointer

func (s ValueView[T]) UnsafePointer() unsafe.Pointer

Jump to

Keyboard shortcuts

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