diff options
| author | Joursoir <chat@joursoir.net> | 2023-04-25 16:39:54 +0400 | 
|---|---|---|
| committer | Joursoir <chat@joursoir.net> | 2023-04-25 16:39:54 +0400 | 
| commit | 21cbc15a690e7c82d778de3eff973084f4198b4e (patch) | |
| tree | 4317d7ea1432e89a820e1218861e415e560ec907 /cpui-drv.c | |
| download | cpui-drv-21cbc15a690e7c82d778de3eff973084f4198b4e.tar.gz cpui-drv-21cbc15a690e7c82d778de3eff973084f4198b4e.tar.bz2 cpui-drv-21cbc15a690e7c82d778de3eff973084f4198b4e.zip | |
initial commit
Diffstat (limited to 'cpui-drv.c')
| -rw-r--r-- | cpui-drv.c | 36 | 
1 files changed, 36 insertions, 0 deletions
| 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 <linux/module.h> + +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 | 
