#include <arch/x86/decode.h>
#include <arch/x86/processor.h>
+const char *x86_vendor_name(enum x86_vendor v)
+{
+ static const char *const names[] =
+ {
+ [X86_VENDOR_INTEL] = "Intel",
+ [X86_VENDOR_AMD] = "AMD",
+ };
+
+ return (v < ARRAY_SIZE(names) && names[v]) ? names[v] : "Unknown";
+}
+
const char *x86_exc_short_name(unsigned int exc)
{
static const char *const names[] =
*/
uint8_t boot_stack[2 * PAGE_SIZE] __aligned(PAGE_SIZE);
uint32_t x86_features[FSCAPINTS];
+enum x86_vendor x86_vendor;
const char *environment_description = ENVIRONMENT_DESCRIPTION;
static void collect_cpuid(cpuid_count_fn_t cpuid_fn)
{
- unsigned int max, tmp;
+ unsigned int max, tmp, ebx, ecx, edx;
- cpuid_fn(0, 0, &max, &tmp, &tmp, &tmp);
+ cpuid_fn(0, 0, &max, &ebx, &ecx, &edx);
+
+ if ( ebx == 0x756e6547u && /* "GenuineIntel" */
+ ecx == 0x6c65746eu &&
+ edx == 0x49656e69u )
+ x86_vendor = X86_VENDOR_INTEL;
+
+ else if ( ebx == 0x68747541u && /* "AuthenticAMD" */
+ ecx == 0x444d4163u &&
+ edx == 0x69746e65u )
+ x86_vendor = X86_VENDOR_AMD;
+
+ else
+ x86_vendor = X86_VENDOR_UNKNOWN;
if ( max >= 1 )
cpuid_fn(1, 0, &tmp, &tmp,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx);
+enum x86_vendor
+{
+ X86_VENDOR_UNKNOWN,
+ X86_VENDOR_INTEL,
+ X86_VENDOR_AMD,
+};
+
+extern enum x86_vendor x86_vendor;
+
+static inline bool vendor_is(enum x86_vendor v)
+{
+ return x86_vendor == v;
+}
+
+#define vendor_is_intel vendor_is(X86_VENDOR_INTEL)
+#define vendor_is_amd vendor_is(X86_VENDOR_AMD)
+
+
#define cpufeat_word(idx) ((idx) / 32)
#define cpufeat_bit(idx) ((idx) % 32)
#define cpufeat_mask(idx) (_AC(1, U) << cpufeat_bit(idx))
/**
* @file include/arch/x86/decode.h
*
- * Helper routines for decoding x86 architectural state.
+ * Helper routines for decoding x86 state.
*/
#ifndef XTF_X86_DECODE_H
#define XTF_X86_DECODE_H
#include <xtf/types.h>
+#include <arch/x86/cpuid.h>
+
+/**
+ * String of the indentified vendor @p v.
+ *
+ * @param v Vendor.
+ * @return String.
+ */
+const char *x86_vendor_name(enum x86_vendor v);
+
/**
* String abbreviation of @p ev.
*