mmio

package
v0.0.0-...-9c233c6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mmio implements a virtio-mmio device bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

func NewBus

func NewBus(devices []virtio.DeviceConfig, cfg Config) (*Bus, error)

NewBus creates a new bus and installs a device for for each of the given handlers. The configured MemAt callback is called when a device needs to access a virtqueue in guest memory. The configured Notify callback is called when a device needs to notify the guest of a config or buffer event.

Devices are assigned an IRQ and a 4K memory region. See the Devices method.

func (*Bus) Close

func (b *Bus) Close() error

Close closes all devices, returning the first error.

func (*Bus) Devices

func (b *Bus) Devices() []DeviceInfo

Devices returns a slice describing the installed devices.

func (*Bus) HandleMMIO

func (b *Bus) HandleMMIO(addr uint64, data []byte, isWrite bool) (found bool, err error)

HandleMMIO routes an MMIO event to the appropriate device. It returns (found=false, err=nil) if no device is found.

type Config

type Config struct {
	MemAt  func(addr uint64, size int) ([]byte, error)
	Notify func(irq int) error
}

type DeviceInfo

type DeviceInfo struct {
	Type virtio.DeviceID
	IRQ  int
	Addr uint64
	Size uint64
}

DeviceInfo describes an installed virtio-mmio device.

Jump to

Keyboard shortcuts

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