func (pcidevice *PciDevice) Attach(vm *platform.Vm, model *Model) error { // Find our pcibus. var ok bool var pcibus *PciBus for _, device := range model.devices { pcibus, ok = device.(*PciBus) if pcibus != nil && ok { break } } if pcibus == nil { return PciBusNotFound } // Rebuild our capabilities. pcidevice.RebuildCapabilities() // FIXME: Everything uses interrupt 1. // This is gross, but we hard-coded the line to 1 // unless you're using MSI. This really should be // fixed (if we actually plan on using PCI devices). pcidevice.Config.Set8(PciConfigOffsetInterruptLine, 1) pcidevice.Config.Set8(PciConfigOffsetInterruptPin, 1) pcidevice.std_interrupt = func() error { vm.Interrupt(platform.Irq(1), true) vm.Interrupt(platform.Irq(1), false) return nil } // Attach to the PciBus. return pcibus.AddDevice(pcidevice) }