Created
June 24, 2021 03:54
-
-
Save zhuowei/c712df9ce13d8eabf4c49968d6c6cb2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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