summaryrefslogtreecommitdiff
path: root/util/autoport/root.go
diff options
context:
space:
mode:
authorLeah Rowe <vimuser@noreply.codeberg.org>2024-03-18 23:59:32 +0000
committerLeah Rowe <vimuser@noreply.codeberg.org>2024-03-18 23:59:32 +0000
commit457a7037d8f421fc16eb12656d54c32ca4d232ec (patch)
treea208e8ff3e8b628b1615918cbb55b6ce351cfe54 /util/autoport/root.go
parentc578fe56c36f94af5c51a1be27a1a1c4b57a4289 (diff)
parent8cba237086dfbb312a5913bb75eef4f6046aeae5 (diff)
Merge pull request 'util: Import autoport with Haswell patches' (#195) from nic3-14159/lbmk:autoport-fork into master
Reviewed-on: https://codeberg.org/libreboot/lbmk/pulls/195
Diffstat (limited to 'util/autoport/root.go')
-rw-r--r--util/autoport/root.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/util/autoport/root.go b/util/autoport/root.go
new file mode 100644
index 00000000..7e9e8145
--- /dev/null
+++ b/util/autoport/root.go
@@ -0,0 +1,47 @@
+package main
+
+import "fmt"
+import "os"
+
+var supportedPCIDevices map[uint32]PCIDevice = map[uint32]PCIDevice{}
+var PCIMap map[PCIAddr]PCIDevData = map[PCIAddr]PCIDevData{}
+
+func ScanRoot(ctx Context) {
+ for _, pciDev := range ctx.InfoSource.GetPCIList() {
+ PCIMap[pciDev.PCIAddr] = pciDev
+ }
+ for _, pciDev := range ctx.InfoSource.GetPCIList() {
+ vendevid := (uint32(pciDev.PCIDevID) << 16) | uint32(pciDev.PCIVenID)
+
+ dev, ok := supportedPCIDevices[vendevid]
+ if !ok {
+ if pciDev.PCIAddr.Bus != 0 {
+ fmt.Printf("Unknown PCI device %04x:%04x, assuming removable\n",
+ pciDev.PCIVenID, pciDev.PCIDevID)
+ continue
+ }
+ fmt.Printf("Unsupported PCI device %04x:%04x\n",
+ pciDev.PCIVenID, pciDev.PCIDevID)
+ dev = GenericPCI{Comment: fmt.Sprintf("Unsupported PCI device %04x:%04x",
+ pciDev.PCIVenID, pciDev.PCIDevID)}
+ }
+ dev.Scan(ctx, pciDev)
+ }
+ if SouthBridge == nil {
+ fmt.Println("Could not detect southbridge. Aborting!")
+ os.Exit(1)
+ }
+ dmi := ctx.InfoSource.GetDMI()
+ if !dmi.IsLaptop {
+ NoEC(ctx)
+ } else if dmi.Vendor == "LENOVO" {
+ LenovoEC(ctx)
+ } else {
+ FIXMEEC(ctx)
+ }
+}
+
+func RegisterPCI(VenID uint16, DevID uint16, dev PCIDevice) {
+ vendevid := (uint32(DevID) << 16) | uint32(VenID)
+ supportedPCIDevices[vendevid] = dev
+}