Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | var supportedPCIDevices map[uint32]PCIDevice = map[uint32]PCIDevice{} |
| 6 | var PCIMap map[PCIAddr]PCIDevData = map[PCIAddr]PCIDevData{} |
| 7 | |
| 8 | func ScanRoot(ctx Context) { |
| 9 | for _, pciDev := range ctx.InfoSource.GetPCIList() { |
| 10 | PCIMap[pciDev.PCIAddr] = pciDev |
| 11 | } |
| 12 | for _, pciDev := range ctx.InfoSource.GetPCIList() { |
| 13 | vendevid := (uint32(pciDev.PCIDevID) << 16) | uint32(pciDev.PCIVenID) |
| 14 | |
| 15 | dev, ok := supportedPCIDevices[vendevid] |
| 16 | if !ok { |
| 17 | if pciDev.PCIAddr.Bus != 0 { |
| 18 | fmt.Printf("Unknown PCI device %04x:%04x, assuming removable\n", |
| 19 | pciDev.PCIVenID, pciDev.PCIDevID) |
| 20 | continue |
| 21 | } |
| 22 | fmt.Printf("Unsupported PCI device %04x:%04x\n", |
| 23 | pciDev.PCIVenID, pciDev.PCIDevID) |
| 24 | dev = GenericPCI{Comment: fmt.Sprintf("Unsupported PCI device %04x:%04x", |
| 25 | pciDev.PCIVenID, pciDev.PCIDevID)} |
| 26 | } |
| 27 | dev.Scan(ctx, pciDev) |
| 28 | } |
| 29 | dmi := ctx.InfoSource.GetDMI() |
| 30 | if !dmi.IsLaptop { |
| 31 | NoEC(ctx) |
| 32 | } else if dmi.Vendor == "LENOVO" { |
| 33 | LenovoEC(ctx) |
| 34 | } else { |
| 35 | FIXMEEC(ctx) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func RegisterPCI(VenID uint16, DevID uint16, dev PCIDevice) { |
| 40 | vendevid := (uint32(DevID) << 16) | uint32(VenID) |
| 41 | supportedPCIDevices[vendevid] = dev |
| 42 | } |