Skip to content

Instantly share code, notes, and snippets.

@abertschi
Last active February 4, 2025 13:44
Show Gist options
  • Select an option

  • Save abertschi/2055b6cc93573ad1c0e3c4621ac979dd to your computer and use it in GitHub Desktop.

Select an option

Save abertschi/2055b6cc93573ad1c0e3c4621ac979dd to your computer and use it in GitHub Desktop.
Read ID_AA64PFR0_EL1
obj-m := read_sysreg.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/sysreg.h>
static int __init read_sysreg_init(void)
{
u64 pfr0 = read_sysreg(ID_AA64PFR0_EL1);
printk(KERN_INFO "ID_AA64PFR0_EL1: 0x%llx\n", pfr0);
return 0;
}
static void __exit read_sysreg_exit(void)
{
printk(KERN_INFO "Module unloaded.\n");
}
module_init(read_sysreg_init);
module_exit(read_sysreg_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("");
MODULE_DESCRIPTION("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment