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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Provide kernel headers useful to build tracing programs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * such as for running eBPF tracing tools.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * (Borrowed code from kernel/configs.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kobject.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * Define kernel_headers_data and kernel_headers_data_end, within which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * compressed kernel headers are stored. The file is first compressed with xz.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) asm (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) "	.pushsection .rodata, \"a\"		\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) "	.global kernel_headers_data		\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) "kernel_headers_data:				\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) "	.incbin \"kernel/kheaders_data.tar.xz\"	\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) "	.global kernel_headers_data_end		\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) "kernel_headers_data_end:			\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) "	.popsection				\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) extern char kernel_headers_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) extern char kernel_headers_data_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ikheaders_read(struct file *file,  struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	       struct bin_attribute *bin_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	       char *buf, loff_t off, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	memcpy(buf, &kernel_headers_data + off, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct bin_attribute kheaders_attr __ro_after_init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	.attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		.name = "kheaders.tar.xz",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		.mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	.read = &ikheaders_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static int __init ikheaders_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	kheaders_attr.size = (&kernel_headers_data_end -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			      &kernel_headers_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return sysfs_create_bin_file(kernel_kobj, &kheaders_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static void __exit ikheaders_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	sysfs_remove_bin_file(kernel_kobj, &kheaders_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) module_init(ikheaders_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) module_exit(ikheaders_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_AUTHOR("Joel Fernandes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_DESCRIPTION("Echo the kernel header artifacts used to build the kernel");