pcisim

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package pcisim puts a gpudev.Device behind an emulated virtio-pci modern transport, in process: it implements go-virtio/common.Transport, so the go-virtio/gpu guest driver (or any driver written against that interface) can bring the device up and drive it with no VM.

Guest memory is a gpudev.RAM: AllocatePages hands out its pages, and the device reads the virtqueues and buffers from it by guest-physical address, as a hypervisor would. A doorbell write runs the queue synchronously, so the driver finds the used ring updated when its notify returns.

Reference: the virtio spec, transport-pci.tex — struct virtio_pci_cap (:143-153), struct virtio_pci_common_cfg (:302-328), the notification address cap.offset + queue_notify_off * notify_off_multiplier (:551).

Index

Constants

View Source
const MaxRequest = 16 << 20

MaxRequest bounds a control request the transport gathers; longer chains are answered with an error without being copied.

Variables

View Source
var ErrOutOfMemory = errors.New("pcisim: guest RAM exhausted")

ErrOutOfMemory: AllocatePages ran out of guest RAM.

Functions

This section is empty.

Types

type Transport

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

Transport is an emulated virtio-pci GPU function.

func New

func New(dev *gpudev.Device, ram *gpudev.RAM) *Transport

New returns a transport for dev, whose guest memory is ram (the same RAM the Device was made with).

func (*Transport) AllocatePages

func (t *Transport) AllocatePages(count int) (uint64, []byte, error)

AllocatePages hands out zeroed, page-aligned guest RAM.

func (*Transport) Err

func (t *Transport) Err() error

Err is the first ring error the device met (it then set NEEDS_RESET and stopped serving queues), or nil.

func (*Transport) Read8

func (t *Transport) Read8(bar uint8, off uint64) (uint8, error)

Read8 .. Write64 implement common.BARMemoryAccessor.

func (*Transport) Read16

func (t *Transport) Read16(bar uint8, off uint64) (uint16, error)

Read16 reads BAR memory.

func (*Transport) Read32

func (t *Transport) Read32(bar uint8, off uint64) (uint32, error)

Read32 reads BAR memory.

func (*Transport) Read64

func (t *Transport) Read64(bar uint8, off uint64) (uint64, error)

Read64 reads BAR memory.

func (*Transport) ReadConfig8

func (t *Transport) ReadConfig8(off uint8) (uint8, error)

ReadConfig8 reads PCI configuration space.

func (*Transport) ReadConfig16

func (t *Transport) ReadConfig16(off uint8) (uint16, error)

ReadConfig16 reads PCI configuration space.

func (*Transport) ReadConfig32

func (t *Transport) ReadConfig32(off uint8) (uint32, error)

ReadConfig32 reads PCI configuration space.

func (*Transport) Write8

func (t *Transport) Write8(bar uint8, off uint64, v uint8) error

Write8 writes BAR memory.

func (*Transport) Write16

func (t *Transport) Write16(bar uint8, off uint64, v uint16) error

Write16 writes BAR memory.

func (*Transport) Write32

func (t *Transport) Write32(bar uint8, off uint64, v uint32) error

Write32 writes BAR memory.

func (*Transport) Write64

func (t *Transport) Write64(bar uint8, off uint64, v uint64) error

Write64 writes BAR memory.

Jump to

Keyboard shortcuts

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