From 21cbc15a690e7c82d778de3eff973084f4198b4e Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 25 Apr 2023 16:39:54 +0400 Subject: initial commit --- cpui-drv.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cpui-drv.c (limited to 'cpui-drv.c') diff --git a/cpui-drv.c b/cpui-drv.c new file mode 100644 index 0000000..bcb6dba --- /dev/null +++ b/cpui-drv.c @@ -0,0 +1,36 @@ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include + +static int __init cpui_init(void) +{ + char id_str[13]; + uint32_t eax = 0, ebx, ecx, edx; + + if (!have_cpuid_p()) { + pr_err("CPUID instruction is NOT supported. Aborting.\n"); + return 1; + } + + cpuid(0, &eax, &ebx, &ecx, &edx); + pr_info("CPUID instruction is supported.\n"); + pr_info("Maximum Input Value for Basic CPUID Information = %d\n", eax); + memcpy(&(id_str[0]), &ebx, 4); + memcpy(&(id_str[4]), &edx, 4); + memcpy(&(id_str[8]), &ecx, 4); + id_str[12] = '\0'; + pr_info("Identity string = %s\n", id_str); + return 0; +} + +static void __exit cpui_exit(void) +{ + pr_info("Exit complete\n"); +} + +module_init(cpui_init); +module_exit(cpui_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Joursoir"); +MODULE_DESCRIPTION("A driver that allows users to interact with various internal components of the CPU"); \ No newline at end of file -- cgit v1.2.3-18-g5258