[syslinux:master] cpuid: Managing UNKNOWN CPU better

syslinux-bot for Erwan Velu erwanaliasr1 at gmail.com
Mon Apr 25 15:29:06 PDT 2011


Commit-ID:  629199e1eaa19e21a6da0769c163dd131aa80163
Gitweb:     http://syslinux.zytor.com/commit/629199e1eaa19e21a6da0769c163dd131aa80163
Author:     Erwan Velu <erwanaliasr1 at gmail.com>
AuthorDate: Thu, 14 Apr 2011 20:58:05 +0200
Committer:  Erwan Velu <erwanaliasr1 at gmail.com>
CommitDate: Thu, 14 Apr 2011 20:58:05 +0200

cpuid: Managing UNKNOWN CPU better

It's safe to manage the unknown cpu as a regular one. This will avoid
weird behavior when CPU isn't well detected.


---
 com32/gplinclude/cpuid.h |    4 ++--
 com32/gpllib/cpuid.c     |    8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/com32/gplinclude/cpuid.h b/com32/gplinclude/cpuid.h
index da0dc77..166e4f1 100644
--- a/com32/gplinclude/cpuid.h
+++ b/com32/gplinclude/cpuid.h
@@ -186,8 +186,8 @@ extern bool get_cpu_flag_value_from_name(s_cpu *cpu, const char * flag);
 #define X86_VENDOR_RISE 6
 #define X86_VENDOR_TRANSMETA 7
 #define X86_VENDOR_NSC 8
-#define X86_VENDOR_NUM 9
-#define X86_VENDOR_UNKNOWN 0xff
+#define X86_VENDOR_UNKNOWN 9 
+#define X86_VENDOR_NUM 10 
 
 #define cpu_has(c, bit)                test_bit(bit, (c)->x86_capability)
 
diff --git a/com32/gpllib/cpuid.c b/com32/gpllib/cpuid.c
index 37e00fe..471b716 100644
--- a/com32/gpllib/cpuid.c
+++ b/com32/gpllib/cpuid.c
@@ -101,6 +101,11 @@ static struct cpu_dev nsc_cpu_dev = {
     .c_ident = {"Geode by NSC"}
 };
 
+static struct cpu_dev unknown_cpu_dev = {
+    .c_vendor = "Unknown Vendor",
+    .c_ident = {"Unknown CPU"}
+};
+
 void init_cpu_devs(void)
 {
     cpu_devs[X86_VENDOR_INTEL] = &intel_cpu_dev;
@@ -112,6 +117,7 @@ void init_cpu_devs(void)
     cpu_devs[X86_VENDOR_RISE] = &rise_cpu_dev;
     cpu_devs[X86_VENDOR_TRANSMETA] = &transmeta_cpu_dev;
     cpu_devs[X86_VENDOR_NSC] = &nsc_cpu_dev;
+    cpu_devs[X86_VENDOR_UNKNOWN] = &unknown_cpu_dev;
 }
 
 void get_cpu_vendor(struct cpuinfo_x86 *c)
@@ -119,7 +125,7 @@ void get_cpu_vendor(struct cpuinfo_x86 *c)
     char *v = c->x86_vendor_id;
     int i;
     init_cpu_devs();
-    for (i = 0; i < X86_VENDOR_NUM; i++) {
+    for (i = 0; i < X86_VENDOR_NUM-1; i++) {
 	if (cpu_devs[i]) {
 	    if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
 		(cpu_devs[i]->c_ident[1] &&



More information about the Syslinux-commits mailing list