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