| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 |
|
| 18 | (define-module (gnu installer hardware)
|
| 19 | #:use-module (gnu build linux-modules)
|
| 20 | #:use-module (guix i18n)
|
| 21 | #:use-module (srfi srfi-1)
|
| 22 | #:use-module (srfi srfi-71)
|
| 23 | #:export (unsupported-pci-device?
|
| 24 | pci-device-description))
|
| 25 |
|
| 26 | (define %unsupported-linux-modules
|
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | '( |
| 37 | "brcmfmac"
|
| 38 | "ipw2100"
|
| 39 | "ipw2200"
|
| 40 | "iwlwifi"
|
| 41 | "mwl8k"
|
| 42 | "rtl8188ee"
|
| 43 | "rtl818x_pci"
|
| 44 | "rtl8192ce"
|
| 45 | "rtl8192de"
|
| 46 | "rtl8192ee"
|
| 47 |
|
| 48 | |
| 49 | "bnx2"
|
| 50 | "bnx2x"
|
| 51 | "liquidio"
|
| 52 |
|
| 53 | |
| 54 | "amdgpu"
|
| 55 | "radeon"
|
| 56 |
|
| 57 | |
| 58 | "ivtv"))
|
| 59 |
|
| 60 | (define unsupported-pci-device?
|
| 61 | |
| 62 | (let ((aliases (delay (known-module-aliases))))
|
| 63 | (lambda (device)
|
| 64 | "Return true if DEVICE is known to not be supported by free software."
|
| 65 | (any (lambda (module)
|
| 66 | (member module %unsupported-linux-modules))
|
| 67 | (matching-modules (pci-device-module-alias device)
|
| 68 | (force aliases))))))
|
| 69 |
|
| 70 | (define (pci-device-description pci-database)
|
| 71 | "Return a procedure that, given a PCI device, returns a string describing
|
| 72 | it."
|
| 73 | (define (with-fallback lookup)
|
| 74 | (lambda (vendor-id id)
|
| 75 | (let ((vendor name (lookup vendor-id id)))
|
| 76 | (values (or vendor (number->string vendor-id 16))
|
| 77 | (or name (number->string id 16))))))
|
| 78 |
|
| 79 | (define pci-lookup
|
| 80 | (with-fallback (load-pci-device-database pci-database)))
|
| 81 |
|
| 82 | (lambda (device)
|
| 83 | (let ((vendor name (pci-lookup (pci-device-vendor device)
|
| 84 | (pci-device-id device))))
|
| 85 | (if (network-pci-device? device)
|
| 86 | |
| 87 | |
| 88 | (format #f (G_ "~a ~a (networking device)")
|
| 89 | vendor name)
|
| 90 | (string-append vendor " " name)))))
|