Documentation ¶
Index ¶
- Constants
- Variables
- func DriverUnknown(name string) error
- type Acpi
- type Apic
- type BaseDevice
- func (device *BaseDevice) Acquire()
- func (device *BaseDevice) Attach(vm *platform.Vm, model *Model) error
- func (device *BaseDevice) Debug(format string, v ...interface{})
- func (device *BaseDevice) Driver() string
- func (device *BaseDevice) Interrupt() error
- func (device *BaseDevice) IsDebugging() bool
- func (device *BaseDevice) Load(vm *platform.Vm) error
- func (device *BaseDevice) MmioHandlers() IoHandlers
- func (device *BaseDevice) Name() string
- func (device *BaseDevice) Pause(manual bool) error
- func (device *BaseDevice) PioHandlers() IoHandlers
- func (device *BaseDevice) Release()
- func (device *BaseDevice) Save(vm *platform.Vm) error
- func (device *BaseDevice) SetDebugging(debug bool)
- func (device *BaseDevice) Unpause(manual bool) error
- type Bios
- type Clock
- type Device
- func NewAcpi(info *DeviceInfo) (Device, error)
- func NewApic(info *DeviceInfo) (Device, error)
- func NewBios(info *DeviceInfo) (Device, error)
- func NewClock(info *DeviceInfo) (Device, error)
- func NewPciBus(info *DeviceInfo) (Device, error)
- func NewPciHostBridge(info *DeviceInfo) (Device, error)
- func NewPit(info *DeviceInfo) (Device, error)
- func NewRtc(info *DeviceInfo) (Device, error)
- func NewUart(info *DeviceInfo) (Device, error)
- func NewUserMemory(info *DeviceInfo) (Device, error)
- func NewVirtioMmioBlock(info *DeviceInfo) (Device, error)
- func NewVirtioMmioConsole(info *DeviceInfo) (Device, error)
- func NewVirtioMmioFs(info *DeviceInfo) (Device, error)
- func NewVirtioMmioNet(info *DeviceInfo) (Device, error)
- func NewVirtioPciBlock(info *DeviceInfo) (Device, error)
- func NewVirtioPciConsole(info *DeviceInfo) (Device, error)
- func NewVirtioPciFs(info *DeviceInfo) (Device, error)
- func NewVirtioPciNet(info *DeviceInfo) (Device, error)
- type DeviceInfo
- type Driver
- type InterruptMap
- type IoCache
- type IoEvent
- type IoHandler
- type IoHandlers
- type IoMap
- type IoOperations
- type IoQueue
- type IoRequest
- type MemoryMap
- func (memory *MemoryMap) Add(region *TypedMemoryRegion) error
- func (memory *MemoryMap) Allocate(memtype MemoryType, start platform.Paddr, end platform.Paddr, size uint64, ...) (platform.Paddr, []byte, error)
- func (memory *MemoryMap) Conflicts(start platform.Paddr, size uint64) bool
- func (memory *MemoryMap) Len() int
- func (memory *MemoryMap) Less(i int, j int) bool
- func (memory *MemoryMap) Load(start platform.Paddr, end platform.Paddr, data []byte, top bool) (platform.Paddr, error)
- func (memory *MemoryMap) Map(memtype MemoryType, addr platform.Paddr, size uint64, allocate bool) ([]byte, error)
- func (memory *MemoryMap) Max() platform.Paddr
- func (memory *MemoryMap) Reserve(vm *platform.Vm, device Device, memtype MemoryType, start platform.Paddr, ...) error
- func (memory *MemoryMap) Swap(i int, j int)
- type MemoryRegion
- type MemoryType
- type MmioDevice
- type MmioEvent
- type Model
- func (model *Model) CreateDevices(vm *platform.Vm, spec []DeviceInfo, debug bool) (Proxy, error)
- func (model *Model) DeviceInfo(vm *platform.Vm) ([]DeviceInfo, error)
- func (model *Model) Devices() []Device
- func (model *Model) Handle(vm *platform.Vm, cache *IoCache, handler *IoHandler, ioevent IoEvent, ...) error
- func (model *Model) HandleMmio(vm *platform.Vm, event *platform.ExitMmio) error
- func (model *Model) HandlePio(vm *platform.Vm, event *platform.ExitPio) error
- func (model *Model) Load(vm *platform.Vm) error
- func (model *Model) Pause(manual bool) error
- func (model *Model) Save(vm *platform.Vm) error
- func (model *Model) Unpause(manual bool) error
- type MsiXConf
- type MsiXDevice
- func (msix *MsiXDevice) Attach(vm *platform.Vm, model *Model) error
- func (msix *MsiXDevice) CheckAllPending()
- func (msix *MsiXDevice) CheckPending(vector int)
- func (msix *MsiXDevice) ClearPending(vector int)
- func (msix *MsiXDevice) FindEntry(vector int) *MsiXEntry
- func (msix *MsiXDevice) IsMSIXEnabled() bool
- func (msix *MsiXDevice) IsMasked(vector int) bool
- func (msix *MsiXDevice) IsPending(vector int) bool
- func (msix *MsiXDevice) Read(offset uint64, size uint) (uint64, error)
- func (msix *MsiXDevice) SendInterrupt(vector int) error
- func (msix *MsiXDevice) SetPending(vector int)
- func (msix *MsiXDevice) Write(offset uint64, size uint, value uint64) error
- type MsiXEntry
- type PciBarOps
- type PciBarSizes
- type PciBus
- type PciCapability
- type PciCapabilityMap
- type PciClass
- type PciConfAddr
- type PciConfData
- type PciDevice
- type PciDeviceId
- type PciRevision
- type PciSubsystemDeviceId
- type PciSubsystemVendorId
- type PciVendorId
- type PioDevice
- type PioEvent
- type Pit
- type Proxy
- type Ram
- func (ram *Ram) Get16(offset int) uint16
- func (ram *Ram) Get32(offset int) uint32
- func (ram *Ram) Get64(offset int) uint64
- func (ram *Ram) Get8(offset int) uint8
- func (ram *Ram) GrowTo(size int)
- func (ram *Ram) Read(offset uint64, size uint) (uint64, error)
- func (ram *Ram) Set16(offset int, data uint16)
- func (ram *Ram) Set32(offset int, data uint32)
- func (ram *Ram) Set64(offset int, data uint64)
- func (ram *Ram) Set8(offset int, data uint8)
- func (ram *Ram) Size() int
- func (ram *Ram) Write(offset uint64, size uint, value uint64) error
- type Register
- type Rtc
- type RtcAddr
- type RtcData
- type TypedMemoryRegion
- type Uart
- type UartData
- type UartIntr
- type UserMemory
- type UserMemorySegment
- type VirtioBlockDevice
- type VirtioBuffer
- func (buf *VirtioBuffer) Append(data []byte)
- func (buf *VirtioBuffer) CopyOut(offset int, output []byte) int
- func (buf *VirtioBuffer) Gather(offset int, length int) ([]unsafe.Pointer, []C.int)
- func (buf *VirtioBuffer) Length() int
- func (buf *VirtioBuffer) Map(offset int, length int) []byte
- func (buf *VirtioBuffer) PRead(fd int, fd_offset int64, buf_offset int, length int) (int, error)
- func (buf *VirtioBuffer) PWrite(fd int, fd_offset int64, buf_offset int, length int) (int, error)
- func (buf *VirtioBuffer) Read(fd int, buf_offset int, length int) (int, error)
- func (buf *VirtioBuffer) SetLength(length int)
- func (buf *VirtioBuffer) Write(fd int, buf_offset int, length int) (int, error)
- type VirtioBufferSet
- type VirtioChannel
- type VirtioChannelMap
- type VirtioChannelSafe
- type VirtioConf
- type VirtioConsoleDevice
- type VirtioDevice
- func (virtio *VirtioDevice) Attach(vm *platform.Vm, model *Model) error
- func (virtio *VirtioDevice) GetFeatures() uint32
- func (virtio *VirtioDevice) HasFeatures(features uint32) bool
- func (virtio *VirtioDevice) Interrupt() error
- func (virtio *VirtioDevice) IsMSIXEnabled() bool
- func (virtio *VirtioDevice) SetFeatures(features uint32)
- type VirtioFsDevice
- type VirtioMmioConf
- type VirtioMmioDevice
- type VirtioNetDevice
- type VirtioNotification
- type VirtioStream
- func (stream *VirtioStream) Read16() uint16
- func (stream *VirtioStream) Read32() uint32
- func (stream *VirtioStream) Read64() uint64
- func (stream *VirtioStream) Read8() uint8
- func (stream *VirtioStream) ReadBytes(length int) []byte
- func (stream *VirtioStream) ReadFromFd(fd int, offset int64, length int) (int, error)
- func (stream *VirtioStream) ReadLeft() int
- func (stream *VirtioStream) ReadN(size int) uint64
- func (stream *VirtioStream) ReadRewind()
- func (stream *VirtioStream) ReadString() string
- func (stream *VirtioStream) Write16(value uint16)
- func (stream *VirtioStream) Write32(value uint32)
- func (stream *VirtioStream) Write64(value uint64)
- func (stream *VirtioStream) Write8(value uint8)
- func (stream *VirtioStream) WriteBytes(data []byte)
- func (stream *VirtioStream) WriteLeft() int
- func (stream *VirtioStream) WriteN(size int, value uint64)
- func (stream *VirtioStream) WriteRewind()
- func (stream *VirtioStream) WriteString(value string)
- func (stream *VirtioStream) WriteToFd(fd int, offset int64, length int) (int, error)
- type WriteIoEvent
Constants ¶
const ( MemoryTypeReserved MemoryType = iota MemoryTypeUser = 1 MemoryTypeAcpi = 2 MemoryTypeSpecial = 3 )
const ( PciMsiXControlMasked = 0x4000 PciMsiXControlEnable = 0x8000 )
const ( PciClassStorage PciClass = 0x1 PciClassNetwork = 0x2 PciClassDisplay = 0x3 PciClassMultimedia = 0x4 PciClassMemory = 0x5 PciClassBridge = 0x6 PciClassCommunications = 0x7 PciClassBase = 0x8 PciClassInput = 0x9 PciClassDocking = 0xa PciClassProcessorts = 0xb PciClassSerial = 0xc PciClassMisc = 0xff )
const ( PciConfigOffsetVendorId = 0x0 PciConfigOffsetDeviceId = 0x2 PciConfigOffsetCommand = 0x4 PciConfigOffsetStatus = 0x6 PciConfigOffsetRevision = 0x8 PciConfigOffsetProgIf = 0x9 PciConfigOffsetSubclassId = 0xa PciConfigOffsetClassId = 0xb PciConfigOffsetHeaderType = 0xe PciConfigOffsetSubsystemVendorId = 0x2c PciConfigOffsetSubsystemDeviceId = 0x2e PciConfigOffsetCapabilities = 0x34 PciConfigOffsetInterruptLine = 0x3c PciConfigOffsetInterruptPin = 0x3d )
Configuration offsets.
const ( RtcSecond = 0x00 RtcSecondAlarm = 0x01 RtcMinute = 0x02 RtcMinuteAlarm = 0x03 RtcHour = 0x04 RtcHourAlarm = 0x05 RtcWeekday = 0x06 RtcDay = 0x07 RtcMonth = 0x08 RtcYear = 0x09 RtcStatusA = 0xa RtcStatusB = 0xb RtcIntr = 0xc RtcStatusD = 0xd RtcCentury = 0x32 )
const ( RtcStatusBDST = 0x01 RtcStatusB24HR = 0x02 RtcStatusBBIN = 0x04 RtcStatusBPINTR = 0x40 RtcStatusBHALT = 0x80 )
const ( UartDefaultRclk = 1843200 UartDefaultBaud = 9600 )
const ( UartIerERXRDY = 0x1 UartIerETXRDY = 0x2 UartIerERLS = 0x4 UartIerEMSC = 0x8 )
const ( UartIirIMASK = 0xf UartIirRXTOUT = 0xc UartIirBUSY = 0x7 UartIirRLS = 0x6 UartIirMLSC = 0x5 UartIirRXRDY = 0x4 UartIirTXRDY = 0x2 UartIirNOPEND = 0x1 )
const ( UartMsrPRESCALE = 0x80 UartMsrLOOPBACK = 0x10 UartMsrIE = 0x08 UartMsrDRS = 0x04 UartMsrRTS = 0x02 UartMsrMASK = 0xf )
const ( UartLsrFIFO = 0x80 UartLsrTEMT = 0x40 UartLsrTHRE = 0x20 UartLsrBI = 0x10 UartLsrFE = 0x08 UartLsrPE = 0x04 UartLsrOE = 0x02 UartLsrRXRDY = 0x01 )
const ( UartMsrDCD = 0x80 UartMsrRI = 0x40 UartMsrDSR = 0x20 UartMsrCTS = 0x10 UartMsrDDCD = 0x08 UartMsrTERI = 0x04 UartMsrDDSR = 0x02 UartMsrDCTS = 0x01 )
const ( VirtioStatusReboot = 0x0 VirtioStatusAck = 0x1 VirtioStatusDriver = 0x2 VirtioStatusDriverOk = 0x4 VirtioStatusFailed = 0x80 )
Virtio status.
const ( VirtioTypeNet = 1 VirtioTypeBlock = 2 VirtioTypeConsole = 3 VirtioTypeEntropy = 4 VirtioTypeBalloon = 5 VirtioTypeIoMemory = 6 VirtioTypeRpMsg = 7 VirtioTypeScsi = 8 VirtioType9p = 9 )
Virtio device types.
const ( VirtioOffsetHostCap = 0x00 VirtioOffsetGuestCap = 0x04 VirtioOffsetQueuePfn = 0x08 VirtioOffsetQueueSize = 0x0c VirtioOffsetQueueSel = 0x0e VirtioOffsetQueueNotify = 0x10 VirtioOffsetStatus = 0x12 VirtioOffsetIsr = 0x13 VirtioOffsetCfgVec = 0x14 VirtioOffsetQueueVec = 0x16 )
Our configuration space constants.
const ( VirtioBlockTIn = 0 VirtioBlockTOut = 1 VirtioBlockTFlush = 4 VirtioBlockTFlushOut = 5 VirtioBlockTBarrier = 0x80000000 )
Commands.
const ( VirtioBlockSOk = 0 VirtioBlockSIoErr = 1 VirtioBlockSUnsupported = 2 )
Status values.
const ( VirtioConsoleFSize = 1 VirtioConsoleFMultiPort = 2 )
const ( VirtioConsoleDeviceReady = 0 VirtioConsolePortAdd = 1 VirtioConsolePortRemove = 2 VirtioConsolePortReady = 3 VirtioConsolePortConsole = 4 VirtioConsolePortResize = 5 VirtioConsolePortOpen = 6 VirtioConsolePortName = 7 )
const ( VirtioNetFCsum uint32 = 1 << 0 VirtioNetFMac = 1 << 5 VirtioNetFHostTso4 = 1 << 11 VirtioNetFHostTso6 = 1 << 12 VirtioNetFHostEcn = 1 << 13 VirtioNetFHostUfo = 1 << 14 VirtioNetFStatus = 1 << 16 )
Virtio Net Features
const ( VirtioNetLinkUp = (1 << 0) VirtioNetAnnounce = (1 << 1) )
VirtioNet Status Bits
const ( VirtioNetMacOffset = 0 VirtioNetMacLen = 6 VirtioNetStatusOffset = (VirtioNetMacOffset + VirtioNetMacLen) VirtioNetStatusLen = 2 VirtioNetConfigLen = (VirtioNetMacLen + VirtioNetStatusLen) )
VirtioNet Config Space
const (
PciCapabilityMSIX = 0x11
)
const (
PciCapabilityPortRoot = 0x40
)
const (
PciFunctionVendor = 0
)
const (
PciMsiXEntryControlMasked = 0x01
)
const (
PciMsiXEntrySize = 0x10
)
const (
RtcStatusATUP = 0x80
)
const (
RtcStatusDPWR = 0x80
)
const (
UartFcrRXMASK = 0xc0
)
const (
UartLcrDLAB = 0x80
)
const (
VirtioFsFMount = 1
)
const (
VirtioNetHeaderSize = 10
)
VirtioNet VLAN support
const VirtioPciVendor = 0x1af4
Our vendor Id.
const (
VirtioRingFEventIdx = 1 << 29
)
Generic features.
Variables ¶
var Bin2Bcd = []uint8{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
}
var DeviceAlreadyPaused = errors.New("Device already paused!")
Basic errors.
var DeviceNotPaused = errors.New("Device not paused!")
var InterruptConflict = errors.New("Device interrupt conflict!")
Interrupt allocation errors.
var MemoryBusy = errors.New("Memory could not be allocated!")
var MemoryConflict = errors.New("Memory regions conflict!")
Memory allocation / layout errors.
var MemoryNotFound = errors.New("Memory region not found!")
var MemoryUnaligned = errors.New("Memory not aligned!")
var PciBusNotFound = errors.New("Requested PCI devices, but no bus found?")
var PciCapabilityMismatch = errors.New("Capability mismatch!")
var PciInvalidAddress = errors.New("Invalid PCI address!")
PCI errors.
var PciMSIError = errors.New("MSI internal error?")
var SaveIO = errors.New("Save I/O request (internal error).")
I/O memoize errors. This is an internal-only error which is returned from a write handler. When this is returned (and the cache has had a significant number of hits at that address) we will create an eventfd for that particular address and value. This will reduce the number of kernel-user switches necessary to handle that particular address.
var UartUnknown = errors.New("Unknown COM port.")
UART errors.
var UserMemoryNotFound = errors.New("No user memory found?")
var VirtioInvalidQueueSize = errors.New("Invalid VirtIO queue size!")
Virtio errors.
var VirtioUnsupportedVnetHeader = errors.New("Unsupported vnet header size.")
Functions ¶
Types ¶
type Acpi ¶
type Acpi struct { BaseDevice Addr platform.Paddr `json:"address"` Data []byte `json:"data"` }
type Apic ¶
type BaseDevice ¶
type BaseDevice struct {
// contains filtered or unexported fields
}
func (*BaseDevice) Acquire ¶
func (device *BaseDevice) Acquire()
func (*BaseDevice) Debug ¶
func (device *BaseDevice) Debug(format string, v ...interface{})
func (*BaseDevice) Driver ¶
func (device *BaseDevice) Driver() string
func (*BaseDevice) Interrupt ¶
func (device *BaseDevice) Interrupt() error
func (*BaseDevice) IsDebugging ¶
func (device *BaseDevice) IsDebugging() bool
func (*BaseDevice) MmioHandlers ¶
func (device *BaseDevice) MmioHandlers() IoHandlers
func (*BaseDevice) Name ¶
func (device *BaseDevice) Name() string
func (*BaseDevice) Pause ¶
func (device *BaseDevice) Pause(manual bool) error
func (*BaseDevice) PioHandlers ¶
func (device *BaseDevice) PioHandlers() IoHandlers
func (*BaseDevice) Release ¶
func (device *BaseDevice) Release()
func (*BaseDevice) SetDebugging ¶
func (device *BaseDevice) SetDebugging(debug bool)
func (*BaseDevice) Unpause ¶
func (device *BaseDevice) Unpause(manual bool) error
type Bios ¶
type Bios struct { BaseDevice // Our reserved TSS (for Intel VTX). TSSAddr platform.Paddr `json:"tss"` }
type Clock ¶
type Clock struct { BaseDevice // Our clock state. Clock platform.Clock `json:"clock"` }
type Device ¶
type Device interface { Name() string Driver() string PioHandlers() IoHandlers MmioHandlers() IoHandlers Attach(vm *platform.Vm, model *Model) error Load(vm *platform.Vm) error Save(vm *platform.Vm) error Pause(manual bool) error Unpause(manual bool) error Acquire() Release() Interrupt() error Debug(format string, v ...interface{}) IsDebugging() bool SetDebugging(debug bool) }
func NewAcpi ¶
func NewAcpi(info *DeviceInfo) (Device, error)
func NewApic ¶
func NewApic(info *DeviceInfo) (Device, error)
func NewBios ¶
func NewBios(info *DeviceInfo) (Device, error)
func NewClock ¶
func NewClock(info *DeviceInfo) (Device, error)
func NewPciBus ¶
func NewPciBus(info *DeviceInfo) (Device, error)
func NewPciHostBridge ¶
func NewPciHostBridge(info *DeviceInfo) (Device, error)
func NewPit ¶
func NewPit(info *DeviceInfo) (Device, error)
func NewRtc ¶
func NewRtc(info *DeviceInfo) (Device, error)
func NewUart ¶
func NewUart(info *DeviceInfo) (Device, error)
func NewUserMemory ¶
func NewUserMemory(info *DeviceInfo) (Device, error)
func NewVirtioMmioBlock ¶
func NewVirtioMmioBlock(info *DeviceInfo) (Device, error)
func NewVirtioMmioConsole ¶
func NewVirtioMmioConsole(info *DeviceInfo) (Device, error)
func NewVirtioMmioFs ¶
func NewVirtioMmioFs(info *DeviceInfo) (Device, error)
func NewVirtioMmioNet ¶
func NewVirtioMmioNet(info *DeviceInfo) (Device, error)
func NewVirtioPciBlock ¶
func NewVirtioPciBlock(info *DeviceInfo) (Device, error)
func NewVirtioPciConsole ¶
func NewVirtioPciConsole(info *DeviceInfo) (Device, error)
func NewVirtioPciFs ¶
func NewVirtioPciFs(info *DeviceInfo) (Device, error)
func NewVirtioPciNet ¶
func NewVirtioPciNet(info *DeviceInfo) (Device, error)
type DeviceInfo ¶
type DeviceInfo struct { // Friendly name. Name string `json:"name"` // Driver name. Driver string `json:"driver"` // Device-specific info. Data interface{} `json:"data"` // Debugging? Debug bool `json:"debug"` }
func NewDeviceInfo ¶
func NewDeviceInfo(device Device) (DeviceInfo, error)
func (DeviceInfo) Load ¶
func (info DeviceInfo) Load() (Device, error)
type InterruptMap ¶
type IoCache ¶
type IoCache struct {
// contains filtered or unexported fields
}
func NewIoCache ¶
func NewIoCache(handlers []IoHandlers, is_pio bool) *IoCache
type IoHandler ¶
type IoHandler struct { Device // contains filtered or unexported fields }
func NewIoHandler ¶
func NewIoHandler( device Device, start platform.Paddr, operations IoOperations) *IoHandler
type IoHandlers ¶
type IoHandlers map[MemoryRegion]*IoHandler
type IoMap ¶
type IoMap map[MemoryRegion]IoOperations
type IoOperations ¶
type MemoryMap ¶
type MemoryMap []*TypedMemoryRegion
MemoryMap --
Our collection of current memory regions.
func (*MemoryMap) Add ¶
func (memory *MemoryMap) Add(region *TypedMemoryRegion) error
type MemoryRegion ¶
MemoryRegion --
This is a serializable type. It is basically a specification for a region of memory, but it doesn't carry any information about what type of region it should be (or the owner). This is used to track the runtime state of the model, and will be recreated from state on resume.
func (*MemoryRegion) Contains ¶
func (region *MemoryRegion) Contains(start platform.Paddr, size uint64) bool
func (*MemoryRegion) End ¶
func (region *MemoryRegion) End() platform.Paddr
type MemoryType ¶
type MemoryType int
type MmioDevice ¶
type MmioDevice struct { BaseDevice // A map of our available I/O. IoMap `json:"-"` IoHandlers `json:"-"` // Our address in memory. Offset platform.Paddr `json:"address"` // Our assigned interrupt. InterruptNumber platform.Irq `json:"interrupt"` // contains filtered or unexported fields }
func (*MmioDevice) MmioHandlers ¶
func (mmio *MmioDevice) MmioHandlers() IoHandlers
type Model ¶
type Model struct { // Basic memory layout: // This is generally accessible from the loader, // and other modules that may need to tweak memory. MemoryMap // Basic interrupt layout: // This maps interrupts to devices. InterruptMap // contains filtered or unexported fields }
func (*Model) CreateDevices ¶
func (*Model) DeviceInfo ¶
func (model *Model) DeviceInfo(vm *platform.Vm) ([]DeviceInfo, error)
func (*Model) HandleMmio ¶
type MsiXConf ¶
type MsiXConf struct { *MsiXDevice `json:"-"` // The MSI control register. Control Register `json:"control"` // The table offset (& BAR). TableOffset Register `json:"table"` // The PBA offset (& BAR). PbaOffset Register `json:"pba"` }
type MsiXDevice ¶
type MsiXDevice struct { *PciDevice // Our Pci configuration. *MsiXConf // Our pending bit array. Pending *Ram `json:"pending"` // The entries are a device that we expose // to the PCI Bar as specified in the creation. Entries []MsiXEntry `json:"entries"` // contains filtered or unexported fields }
func NewMsiXDevice ¶
func NewMsiXDevice( pcidevice *PciDevice, barno uint, vectors uint) *MsiXDevice
func (*MsiXDevice) CheckAllPending ¶
func (msix *MsiXDevice) CheckAllPending()
func (*MsiXDevice) CheckPending ¶
func (msix *MsiXDevice) CheckPending(vector int)
func (*MsiXDevice) ClearPending ¶
func (msix *MsiXDevice) ClearPending(vector int)
func (*MsiXDevice) FindEntry ¶
func (msix *MsiXDevice) FindEntry(vector int) *MsiXEntry
func (*MsiXDevice) IsMSIXEnabled ¶
func (msix *MsiXDevice) IsMSIXEnabled() bool
func (*MsiXDevice) IsMasked ¶
func (msix *MsiXDevice) IsMasked(vector int) bool
func (*MsiXDevice) IsPending ¶
func (msix *MsiXDevice) IsPending(vector int) bool
func (*MsiXDevice) SendInterrupt ¶
func (msix *MsiXDevice) SendInterrupt(vector int) error
func (*MsiXDevice) SetPending ¶
func (msix *MsiXDevice) SetPending(vector int)
type MsiXEntry ¶
type MsiXEntry struct { *MsiXDevice `json:"-"` // The control dword. Control Register `json:"control"` // The lower address (+masked & pending bits). Address Register `json:"address"` // The Data. Data Register `json:"data"` }
type PciBarOps ¶
type PciBarOps map[uint]IoOperations
Our bar operations will be called when the system maps any given bar. (The system may choose to map a size that is larger or smaller than the given bar size, this has to be handled).
type PciBarSizes ¶
Our barsizes determine what we report for the size of each bar to the system.
type PciBus ¶
type PciBus struct { PioDevice // Our Mmio Handlers. IoHandlers `json:"-"` // Our pci hole in memory. Hole MemoryRegion `json:"hole"` // Our configuration address. Addr Register `json:"config-address"` // Our reserved high-mem region. MemoryRegion platform.Paddr `json:"reserved"` // contains filtered or unexported fields }
func (*PciBus) MmioHandlers ¶
func (pcibus *PciBus) MmioHandlers() IoHandlers
type PciCapability ¶
type PciCapability struct { // The pci capability id. Id byte `json:"id"` // The handlers. IoOperations `json:"-"` // The size of the data. Size uint64 `json:"size"` // The offset in configuration. // (NOTE: This does not include ptrs). Offset uint64 `json:"offset"` }
The capability is a generic set of IoHandlers, (typically a device itself or register) associated with some offset in the pci configuration space.
type PciCapabilityMap ¶
type PciCapabilityMap map[byte]*PciCapability
Our map of capabilities.
func (*PciCapabilityMap) MarshalJSON ¶
func (capmap *PciCapabilityMap) MarshalJSON() ([]byte, error)
func (*PciCapabilityMap) UnmarshalJSON ¶
func (capmap *PciCapabilityMap) UnmarshalJSON(data []byte) error
type PciConfAddr ¶
type PciConfAddr struct {
*PciBus
}
type PciConfData ¶
type PciConfData struct {
*PciBus
}
type PciDevice ¶
type PciDevice struct { MmioDevice // Packed configuration data. // (This encodes the vendor/device, etc.) Config *Ram `json:"config"` // Capabilities. // Once they have been built, we actually // call RefreshCapabilities to reload the map. Capabilities PciCapabilityMap `json:"capabilities"` // Bar sizes and operations. PciBarCount uint `json:"-"` PciBarSizes `json:"-"` PciBarOps `json:"-"` // contains filtered or unexported fields }
func NewPciDevice ¶
func NewPciDevice( info *DeviceInfo, vendor_id PciVendorId, device_id PciDeviceId, class PciClass, revision PciRevision, subsystem_vendor_id PciSubsystemVendorId, subsystem_device_id PciSubsystemDeviceId) (*PciDevice, error)
func (*PciDevice) RebuildBars ¶
func (pcidevice *PciDevice) RebuildBars()
func (*PciDevice) RebuildCapabilities ¶
func (pcidevice *PciDevice) RebuildCapabilities()
type PciDeviceId ¶
type PciDeviceId uint16
type PciRevision ¶
type PciRevision uint8
type PciSubsystemDeviceId ¶
type PciSubsystemDeviceId PciDeviceId
type PciSubsystemVendorId ¶
type PciSubsystemVendorId PciVendorId
type PciVendorId ¶
type PciVendorId uint16
type PioDevice ¶
type PioDevice struct { BaseDevice // A map of our available ports. IoMap `json:"-"` IoHandlers `json:"-"` // Our address in memory. Offset platform.Paddr `json:"base"` }
func (*PioDevice) PioHandlers ¶
func (pio *PioDevice) PioHandlers() IoHandlers
type Pit ¶
type Pit struct { BaseDevice // Our pit state. // Similar to the pit, we consider the platform // PIT to be an intrinsic part of our "pit". Pit platform.PitState `json:"pit"` }
type Proxy ¶
type Proxy interface { io.ReadWriteCloser }
type Register ¶
type Register struct { // The value of the register. Value uint64 `json:"value"` // contains filtered or unexported fields }
type Rtc ¶
type Rtc struct { PioDevice // The time. Now time.Time `json:"now"` // Registers. Addr uint8 `json:"selector"` AlarmSecond uint8 `json:"alarm-second"` AlarmMinute uint8 `json:"alarm-minute"` AlarmHour uint8 `json:"alarm-hour"` StatusA uint8 `json:"statusa"` StatusB uint8 `json:"statusb"` // contains filtered or unexported fields }
type TypedMemoryRegion ¶
type TypedMemoryRegion struct { MemoryRegion MemoryType // The owner. Device // contains filtered or unexported fields }
TypedMemoryRegion --
This is used for tracking runtime state. These TypedMemoryRegion's will be created and tracked in a MemoryMap (below) within the model, and relate directly to runtime platform state.
type Uart ¶
type Uart struct { PioDevice // Registers. Ier Register `json:"ier"` Iir Register `json:"iir"` Lcr Register `json:"lcr"` Mcr Register `json:"mcr"` Lsr Register `json:"lsr"` Msr Register `json:"msr"` Fcr Register `json:"fcr"` Scr Register `json:"scr"` Dll Register `json:"dll"` Dlh Register `json:"dlh"` // Our allocated interrupt. InterruptNumber platform.Irq `json:"interrupt"` }
type UserMemory ¶
type UserMemory struct { BaseDevice // As laid-out. // This is indexed by offset in the file, // and each offset points to the given region. Allocated []UserMemorySegment `json:"allocated"` // The offset in the file. Offset int64 `json:"offset"` // The FD to map for regions. Fd int `json:"fd"` // contains filtered or unexported fields }
UserMemory --
The user memory device allocates and maintains a mapping of user memory to a backing file. The file can be of any type (i.e. opening /dev/zero or any other temporary file) and we rely on the management stack to determine the best way to provide memory.
type UserMemorySegment ¶
type UserMemorySegment struct { // The offset in the file. Offset uint64 `json:"offset"` // The segment of virtual machine memory. Region MemoryRegion `json:"region"` }
UserMemorySegment --
This maps a file offset to a segment of user memory.
type VirtioBlockDevice ¶
type VirtioBlockDevice struct { *VirtioDevice // The device. Dev string `json:"dev"` // The backing file. Fd int `json:"fd"` }
type VirtioBuffer ¶
type VirtioBuffer struct {
// contains filtered or unexported fields
}
func NewVirtioBuffer ¶
func NewVirtioBuffer(index uint16, readonly bool) *VirtioBuffer
func (*VirtioBuffer) Append ¶
func (buf *VirtioBuffer) Append(data []byte)
func (*VirtioBuffer) Length ¶
func (buf *VirtioBuffer) Length() int
func (*VirtioBuffer) SetLength ¶
func (buf *VirtioBuffer) SetLength(length int)
type VirtioBufferSet ¶
The set of "in-progress" buffers. This is used for correctly suspending and resuming the active state of the device.
func (*VirtioBufferSet) MarshalJSON ¶
func (set *VirtioBufferSet) MarshalJSON() ([]byte, error)
func (*VirtioBufferSet) UnmarshalJSON ¶
func (set *VirtioBufferSet) UnmarshalJSON(data []byte) error
type VirtioChannel ¶
type VirtioChannel struct { *VirtioDevice `json:"-"` // Our channel number (set in Marshal()). Channel uint `json:"channel"` // What index have we consumed up to? Consumed uint16 `json:"consumed"` // Our outstanding buffers. Outstanding VirtioBufferSet `json:"outstanding"` // The queue size. QueueSize Register `json:"queue-size"` // The address written. QueueAddress Register `json:"queue-address"` // Our MSI-X Vectors. CfgVec Register `json:"config-vector"` QueueVec Register `json:"queue-vector"` // contains filtered or unexported fields }
func NewVirtioChannel ¶
func NewVirtioChannel(n uint, size uint) *VirtioChannel
func (*VirtioChannel) Interrupt ¶
func (vchannel *VirtioChannel) Interrupt(queue bool)
func (*VirtioChannel) ProcessIncoming ¶
func (vchannel *VirtioChannel) ProcessIncoming() error
func (*VirtioChannel) ProcessOutgoing ¶
func (vchannel *VirtioChannel) ProcessOutgoing() error
type VirtioChannelMap ¶
type VirtioChannelMap map[uint]*VirtioChannel
Our channel map is just queue# => channel object.
func (*VirtioChannelMap) MarshalJSON ¶
func (chanmap *VirtioChannelMap) MarshalJSON() ([]byte, error)
func (*VirtioChannelMap) UnmarshalJSON ¶
func (chanmap *VirtioChannelMap) UnmarshalJSON(data []byte) error
type VirtioChannelSafe ¶
type VirtioChannelSafe struct {
// contains filtered or unexported fields
}
func (*VirtioChannelSafe) MarshalJSON ¶
func (vchannel *VirtioChannelSafe) MarshalJSON() ([]byte, error)
func (*VirtioChannelSafe) UnmarshalJSON ¶
func (vchannel *VirtioChannelSafe) UnmarshalJSON(data []byte) error
type VirtioConf ¶
type VirtioConf struct {
*VirtioDevice
}
type VirtioConsoleDevice ¶
type VirtioConsoleDevice struct { *VirtioDevice Opened bool `json:"opened"` // contains filtered or unexported fields }
func (*VirtioConsoleDevice) Attach ¶
func (console *VirtioConsoleDevice) Attach(vm *platform.Vm, model *Model) error
func (*VirtioConsoleDevice) Close ¶
func (console *VirtioConsoleDevice) Close() error
type VirtioDevice ¶
type VirtioDevice struct { Device `json:"device"` // Our channels. // We expect that these will be configured // by the different devices. Channels VirtioChannelMap `json:"channels"` // Our configuration. Config *Ram `json:"config"` // Our virtio-specific registers. HostFeatures Register `json:"host-features"` GuestFeatures Register `json:"guest-features"` QueueSelect Register `json:"queue-select"` QueueNotify Register `json:"queue-notify"` DeviceStatus Register `json:"device-status"` IsrStatus Register `json:"isr-status"` // contains filtered or unexported fields }
We store the common configuration here and run a few different routines that allow us to multiplex onto the data channel. This abstracts all the H/W details away from the actual device logic.
func NewMmioVirtioDevice ¶
func NewMmioVirtioDevice( info *DeviceInfo, class int) (*VirtioDevice, error)
func NewPciVirtioDevice ¶
func NewPciVirtioDevice( info *DeviceInfo, class PciClass, subsystem_id PciSubsystemDeviceId, vectors uint) (*VirtioDevice, error)
func NewVirtioDevice ¶
func NewVirtioDevice(device Device) *VirtioDevice
func (*VirtioDevice) Attach ¶
func (virtio *VirtioDevice) Attach(vm *platform.Vm, model *Model) error
func (*VirtioDevice) GetFeatures ¶
func (virtio *VirtioDevice) GetFeatures() uint32
func (*VirtioDevice) HasFeatures ¶
func (virtio *VirtioDevice) HasFeatures(features uint32) bool
func (*VirtioDevice) Interrupt ¶
func (virtio *VirtioDevice) Interrupt() error
func (*VirtioDevice) IsMSIXEnabled ¶
func (virtio *VirtioDevice) IsMSIXEnabled() bool
func (*VirtioDevice) SetFeatures ¶
func (virtio *VirtioDevice) SetFeatures(features uint32)
type VirtioFsDevice ¶
type VirtioFsDevice struct { *VirtioDevice // Our filesystem tag. Tag string `json:"tag"` // Debug fs operations? Debugfs bool `json:"debugfs"` // Our plan9 server. plan9.Fs }
type VirtioMmioConf ¶
type VirtioMmioConf struct {
// contains filtered or unexported fields
}
type VirtioMmioDevice ¶
type VirtioMmioDevice struct {
MmioDevice
}
type VirtioNetDevice ¶
type VirtioNetDevice struct { *VirtioDevice // The tap device file descriptor. Fd int `json:"fd"` // The mac address. Mac string `json:"mac"` // Size of vnet header expected by the tap device. Vnet int `json:"vnet"` // Hardware offloads supported by tap device? Offload bool `json:"offload"` }
type VirtioStream ¶
type VirtioStream struct { *VirtioBuffer // contains filtered or unexported fields }
func NewVirtioStream ¶
func NewVirtioStream( buffer *VirtioBuffer, bookmark int) *VirtioStream
func (*VirtioStream) Read16 ¶
func (stream *VirtioStream) Read16() uint16
func (*VirtioStream) Read32 ¶
func (stream *VirtioStream) Read32() uint32
func (*VirtioStream) Read64 ¶
func (stream *VirtioStream) Read64() uint64
func (*VirtioStream) Read8 ¶
func (stream *VirtioStream) Read8() uint8
func (*VirtioStream) ReadBytes ¶
func (stream *VirtioStream) ReadBytes(length int) []byte
func (*VirtioStream) ReadFromFd ¶
func (*VirtioStream) ReadLeft ¶
func (stream *VirtioStream) ReadLeft() int
func (*VirtioStream) ReadN ¶
func (stream *VirtioStream) ReadN(size int) uint64
func (*VirtioStream) ReadRewind ¶
func (stream *VirtioStream) ReadRewind()
func (*VirtioStream) ReadString ¶
func (stream *VirtioStream) ReadString() string
func (*VirtioStream) Write16 ¶
func (stream *VirtioStream) Write16(value uint16)
func (*VirtioStream) Write32 ¶
func (stream *VirtioStream) Write32(value uint32)
func (*VirtioStream) Write64 ¶
func (stream *VirtioStream) Write64(value uint64)
func (*VirtioStream) Write8 ¶
func (stream *VirtioStream) Write8(value uint8)
func (*VirtioStream) WriteBytes ¶
func (stream *VirtioStream) WriteBytes(data []byte)
func (*VirtioStream) WriteLeft ¶
func (stream *VirtioStream) WriteLeft() int
func (*VirtioStream) WriteN ¶
func (stream *VirtioStream) WriteN(size int, value uint64)
func (*VirtioStream) WriteRewind ¶
func (stream *VirtioStream) WriteRewind()
func (*VirtioStream) WriteString ¶
func (stream *VirtioStream) WriteString(value string)
type WriteIoEvent ¶
type WriteIoEvent struct {
// contains filtered or unexported fields
}
func (*WriteIoEvent) GetData ¶
func (event *WriteIoEvent) GetData() uint64
func (*WriteIoEvent) IsWrite ¶
func (event *WriteIoEvent) IsWrite() bool
func (*WriteIoEvent) SetData ¶
func (event *WriteIoEvent) SetData(val uint64)
func (*WriteIoEvent) Size ¶
func (event *WriteIoEvent) Size() uint
Source Files ¶
- acpi.go
- apic.go
- bios.go
- cache.go
- clock.go
- device.go
- drivers.go
- entry.go
- errors.go
- eventfd.go
- interrupt.go
- io.go
- memory.go
- mmio.go
- model.go
- msix.go
- pci.go
- pcihost.go
- pio.go
- pit.go
- proxy.go
- ram.go
- register.go
- rtc.go
- state.go
- uart.go
- user.go
- virtio.go
- virtio_block.go
- virtio_buffer.go
- virtio_console.go
- virtio_fs.go
- virtio_net.go
- virtio_stream.go