summary refs log tree commit diff
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2022-05-17 15:10:36 +0300
committerEfraim Flashner <efraim@flashner.co.il>2022-05-17 15:19:37 +0300
commit41ed6db81e7b52673e5f973a1edc88b69a274614 (patch)
treee5ea306ad2ab03657b89f04aebe4f2420af26566
parentedf86bacf294fea4decabeda77dd1cae9308b28e (diff)
downloadguix-41ed6db81e7b52673e5f973a1edc88b69a274614.tar.gz
guix: cpu: Add support for reading armhf/aarch64 CPUs.
* guix/cpu.scm (current-cpu): Set flags at the beginning of the loop.
Read from '/proc/cpuinfo' until the end of the file. Add match options
for discovering armhf/aarch64 cpu configurations.
-rw-r--r--guix/cpu.scm38
1 files changed, 29 insertions, 9 deletions
diff --git a/guix/cpu.scm b/guix/cpu.scm
index a44cd082f1..be516bd568 100644
--- a/guix/cpu.scm
+++ b/guix/cpu.scm
@@ -62,31 +62,51 @@
       (lambda (port)
         (let loop ((vendor #f)
                    (family #f)
-                   (model #f))
+                   (model #f)
+                   (flags (set)))
           (match (read-line port)
             ((? eof-object?)
-             #f)
+             (cpu (utsname:machine (uname))
+                  vendor family model flags))
+            ;; vendor for x86_64 and i686
             ((? (prefix? "vendor_id") str)
              (match (string-tokenize str)
                (("vendor_id" ":" vendor)
-                (loop vendor family model))))
+                (loop vendor family model flags))))
+            ;; vendor for aarch64 and armhf
+            ((? (prefix? "CPU implementer") str)
+             (match (string-tokenize str)
+               (("CPU" "implementer" ":" vendor)
+                (loop vendor family model flags))))
+            ;; family for x86_64 and i686
             ((? (prefix? "cpu family") str)
              (match (string-tokenize str)
                (("cpu" "family" ":" family)
-                (loop vendor (string->number family) model))))
+                (loop vendor (string->number family) model flags))))
+            ;; model for x86_64 and i686
             ((? (prefix? "model") str)
              (match (string-tokenize str)
                (("model" ":" model)
-                (loop vendor family (string->number model)))
+                (loop vendor family (string->number model) flags))
                (_
-                (loop vendor family model))))
+                (loop vendor family model flags))))
+            ;; model for aarch64 and armhf
+            ((? (prefix? "CPU part") str)
+             (match (string-tokenize str)
+               (("CPU" "part" ":" model)
+                (loop vendor family (string->number (string-drop model 2) 16) flags))))
+            ;; flags for x86_64 and i686
             ((? (prefix? "flags") str)
              (match (string-tokenize str)
                (("flags" ":" flags ...)
-                (cpu (utsname:machine (uname))
-                     vendor family model (list->set flags)))))
+                (loop vendor family model (list->set flags)))))
+            ;; flags for aarch64 and armhf
+            ((? (prefix? "Features") str)
+             (match (string-tokenize str)
+               (("Features" ":" flags ...)
+                (loop vendor family model (list->set flags)))))
             (_
-             (loop vendor family model))))))))
+             (loop vendor family model flags))))))))
 
 (define (cpu->gcc-architecture cpu)
   "Return the architecture name, suitable for GCC's '-march' flag, that