root.go 1.2 KB

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