Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created June 24, 2021 03:54
Show Gist options
  • Select an option

  • Save zhuowei/c712df9ce13d8eabf4c49968d6c6cb2b to your computer and use it in GitHub Desktop.

Select an option

Save zhuowei/c712df9ce13d8eabf4c49968d6c6cb2b to your computer and use it in GitHub Desktop.
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
#define ACTLR_EL1_EnTSO (1ULL << 1)
static void pokeit(void* turnOn) {
u64 actlr = read_sysreg(actlr_el1);
if (turnOn) {
actlr |= ACTLR_EL1_EnTSO;
} else {
actlr &= ~ACTLR_EL1_EnTSO;
}
write_sysreg(actlr, actlr_el1);
}
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!\n");
on_each_cpu(pokeit, "yes", true);
return 0; // Non-zero return means that the module couldn't be loaded.
}
static void __exit hello_cleanup(void)
{
on_each_cpu(pokeit, NULL, true);
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment