blob: ca75d4b3851ef5f3ddf6db568aced50a0e1431d5 [file] [log] [blame]
Vladimir Serbinenko3129f792014-10-15 21:51:47 +02001package main
2
3import "fmt"
4
5var supportedPCIDevices map[uint32]PCIDevice = map[uint32]PCIDevice{}
6var PCIMap map[PCIAddr]PCIDevData = map[PCIAddr]PCIDevData{}
7
8func 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
39func RegisterPCI(VenID uint16, DevID uint16, dev PCIDevice) {
40 vendevid := (uint32(DevID) << 16) | uint32(VenID)
41 supportedPCIDevices[vendevid] = dev
42}