Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/sched.h> /* for wake_up_process() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/ftrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) extern void my_direct_func(struct task_struct *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) void my_direct_func(struct task_struct *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	trace_printk("waking up %s-%d\n", p->comm, p->pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern void my_tramp(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) asm (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) "	.pushsection    .text, \"ax\", @progbits\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) "	.type		my_tramp, @function\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) "	.globl		my_tramp\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) "   my_tramp:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) "	pushq %rbp\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) "	movq %rsp, %rbp\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) "	pushq %rdi\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) "	call my_direct_func\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) "	popq %rdi\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) "	leave\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) "	ret\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) "	.size		my_tramp, .-my_tramp\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) "	.popsection\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static int __init ftrace_direct_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	return register_ftrace_direct((unsigned long)wake_up_process,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 				     (unsigned long)my_tramp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static void __exit ftrace_direct_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	unregister_ftrace_direct((unsigned long)wake_up_process,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				 (unsigned long)my_tramp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) module_init(ftrace_direct_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) module_exit(ftrace_direct_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) MODULE_AUTHOR("Steven Rostedt");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) MODULE_DESCRIPTION("Example use case of using register_ftrace_direct()");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) MODULE_LICENSE("GPL");