aboutsummaryrefslogtreecommitdiff
path: root/arch/i686
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-07-17 23:04:47 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-08-12 10:13:59 +0300
commit3973bfdf7936f4574aa28a97b7343319aa344bc3 (patch)
treefddaff0566b915be58fee0a7ad3af85906bcad67 /arch/i686
parentRemove duplicated linker.ld argument (diff)
downloadkernel-3973bfdf7936f4574aa28a97b7343319aa344bc3.tar.xz
Print version, compiler id and version, and cpuid on boot
Diffstat (limited to 'arch/i686')
-rw-r--r--arch/i686/include/sys/cpuid.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/i686/include/sys/cpuid.h b/arch/i686/include/sys/cpuid.h
new file mode 100644
index 0000000..f2ffe37
--- /dev/null
+++ b/arch/i686/include/sys/cpuid.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <cpuid.h>
+
+struct CPUVersion {
+ unsigned int stepping : 4;
+ unsigned int model : 4;
+ unsigned int family : 4;
+ unsigned int type : 2;
+ unsigned int __unused_1 : 2;
+ unsigned int model_ex : 4;
+ unsigned int family_ex : 8;
+ unsigned int __unused_2 : 4;
+} __attribute__((packed, aligned(__alignof__(unsigned int))));
+_Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int));
+
+unsigned int
+family(const struct CPUVersion v)
+{
+ if (v.family == 0x0f) return v.family + v.family_ex;
+ else
+ return v.family;
+}
+
+unsigned int
+model(const struct CPUVersion v)
+{
+ switch (v.family) {
+ case 0x06:
+ case 0x0f:
+ return ((unsigned int)v.model_ex << 4) | v.model;
+ default:
+ return v.model;
+ }
+}