]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: Add "ISA" field into lscpu_cputype and determine loongarch op-mode from its...
authorXi Ruoyao <xry111@xry111.site>
Wed, 22 Mar 2023 12:57:34 +0000 (20:57 +0800)
committerXi Ruoyao <xry111@xry111.site>
Wed, 22 Mar 2023 13:03:18 +0000 (21:03 +0800)
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
sys-utils/lscpu-cputype.c
sys-utils/lscpu.h

index 79805b540f815431288d40cdf631b4fa60be9748..3fd5f7a3c6d68ef765289367912acfffe039f3a8 100644 (file)
@@ -174,7 +174,8 @@ enum {
        PAT_TYPE,
        PAT_VARIANT,
        PAT_VENDOR,
-       PAT_CACHE
+       PAT_CACHE,
+       PAT_ISA,
 };
 
 /*
@@ -201,6 +202,7 @@ static const struct cpuinfo_pattern type_patterns[] =
        DEF_PAT_CPUTYPE( "CPU revision",        PAT_REVISION,   revision),      /* aarch64 */
        DEF_PAT_CPUTYPE( "CPU variant",         PAT_VARIANT,    stepping),      /* aarch64 */
        DEF_PAT_CPUTYPE( "Features",            PAT_FEATURES,   flags),         /* aarch64 */
+       DEF_PAT_CPUTYPE( "ISA",                 PAT_ISA,        isa),           /* loongarch */
        DEF_PAT_CPUTYPE( "Model Name",          PAT_MODEL_NAME, modelname),     /* loongarch */
        DEF_PAT_CPUTYPE( "address sizes",       PAT_ADDRESS_SIZES,      addrsz),/* x86 */
        DEF_PAT_CPUTYPE( "bogomips per cpu",    PAT_BOGOMIPS,   bogomips),      /* s390 */
@@ -646,6 +648,16 @@ struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt)
                        ar->bit32 = 1, ar->bit64 = 1;                   /* sparc64 */
        }
 
+       if (ct && ct->isa) {
+               char buf[BUFSIZ];
+
+               snprintf(buf, sizeof(buf), " %s ", ct->isa);
+               if (strstr(buf, " loongarch32 "))
+                       ar->bit32 = 1;
+               if (strstr(buf, " loongarch64 "))
+                       ar->bit64 = 1;
+       }
+
        if (ar->name && !cxt->noalive) {
                if (strcmp(ar->name, "ppc64") == 0)
                        ar->bit32 = 1, ar->bit64 = 1;
index ac73ea762abd899123dc0784ce356aa9ce99a9ca..1a8cfce64b95dd59f54ac31024e7d1de4a365ea9 100644 (file)
@@ -103,6 +103,8 @@ struct lscpu_cputype {
                        has_addresses : 1;
 
        size_t nr_socket_on_cluster; /* the number of sockets if the is_cluster is 1 */
+
+       char    *isa;   /* loongarch */
 };
 
 /* dispatching modes */