Add a function to return vendor_id string
authorRonald G. Minnich <rminnich@google.com>
Fri, 31 Jan 2014 15:55:32 +0000 (07:55 -0800)
committerRonald G. Minnich <rminnich@google.com>
Fri, 31 Jan 2014 15:55:32 +0000 (07:55 -0800)
Needed so we can figure out what we are.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/arch/x86/arch.h
kern/arch/x86/cpuinfo.c

index 075dab5..5816c5d 100644 (file)
@@ -41,6 +41,7 @@ void send_ipi(uint32_t os_coreid, uint8_t vector);
 /* in cpuinfo.c */
 void print_cpuinfo(void);
 void show_mapping(uintptr_t start, size_t size);
+int vendor_id(char *);
 
 /* declared in smp.c */
 extern int hw_coreid_lookup[MAX_NUM_CPUS];
index 6aafd3f..07baf60 100644 (file)
@@ -213,3 +213,21 @@ void show_mapping(uintptr_t start, size_t size)
                }
        }
 }
+
+/* return 0 if ok, -1 if it failed for some reason.
+ * Be sensible and call it with 16 bytes.
+ */
+int vendor_id(char *vid)
+{
+       uint32_t eax, ebx, ecx, edx;
+
+       asm volatile ("cpuid;"
+                 "movl    %%ebx, (%2);"
+                 "movl    %%edx, 4(%2);"
+                 "movl    %%ecx, 8(%2);"
+                : "=a"(eax)
+                : "a"(0), "D"(vid)
+                : "%ebx", "%ecx", "%edx");
+
+       vid[12] = '\0';
+}