From c654565e8263d1dbadb8e3bef8b46d2b00dd5961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E4=BD=B3=E9=91=AB?= Date: Tue, 23 Jul 2024 19:54:53 +0800 Subject: [PATCH] hck for linux-6.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱佳鑫 --- samples/Kconfig | 23 ++++++++++++++++++ samples/Makefile | 1 + samples/hck/Makefile | 6 +++++ samples/hck/call.c | 24 +++++++++++++++++++ samples/hck/register.c | 48 ++++++++++++++++++++++++++++++++++++++ samples/hck/register_one.c | 31 ++++++++++++++++++++++++ 6 files changed, 133 insertions(+) create mode 100644 samples/hck/Makefile create mode 100644 samples/hck/call.c create mode 100644 samples/hck/register.c create mode 100644 samples/hck/register_one.c diff --git a/samples/Kconfig b/samples/Kconfig index b0ddf5f36738..2d5861bf9c4e 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -287,6 +287,29 @@ config SAMPLE_KMEMLEAK source "samples/rust/Kconfig" +config SAMPLE_HCK + bool "HCK sample" + help + HCK sample + +config SAMPLE_HCK_CALL + bool "HCK call sample" + depends on SAMPLE_HCK + help + HCK call sample + +config SAMPLE_HCK_REGISTER + bool "HCK register sample" + depends on SAMPLE_HCK + help + HCK register sample + +config SAMPLE_HCK_REGISTER_ONE + bool "HCK register one interface sample" + depends on SAMPLE_HCK + help + HCK register sample + endif # SAMPLES config HAVE_SAMPLE_FTRACE_DIRECT diff --git a/samples/Makefile b/samples/Makefile index 0a551c2b33f4..485a0c503de0 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -38,3 +38,4 @@ obj-$(CONFIG_SAMPLE_KMEMLEAK) += kmemleak/ obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG) += coresight/ obj-$(CONFIG_SAMPLE_FPROBE) += fprobe/ obj-$(CONFIG_SAMPLES_RUST) += rust/ +obj-$(CONFIG_SAMPLE_HCK) += hck/ diff --git a/samples/hck/Makefile b/samples/hck/Makefile new file mode 100644 index 000000000000..1f24a99a46f4 --- /dev/null +++ b/samples/hck/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +ccflags-y += -I$(src) + +obj-$(CONFIG_SAMPLE_HCK_CALL) += call.o +obj-$(CONFIG_SAMPLE_HCK_REGISTER) += register.o +obj-$(CONFIG_SAMPLE_HCK_REGISTER_ONE) += register_one.o \ No newline at end of file diff --git a/samples/hck/call.c b/samples/hck/call.c new file mode 100644 index 000000000000..870d5611c082 --- /dev/null +++ b/samples/hck/call.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sample Call HCK + * + */ +#include +#include +#include + +static int __init samplecallhck_init(void) +{ + int val = 0; + + pr_info("hck sample: call\n"); + + CALL_HCK_LITE_HOOK(get_boot_config_lhck, &val); + pr_info("hck sample val changed: %d\n", val); + + CALL_HCK_LITE_HOOK(set_boot_stat_lhck, val); + pr_info("hck sample val not changed: %d\n", val); + + return 0; +} +late_initcall(samplecallhck_init); \ No newline at end of file diff --git a/samples/hck/register.c b/samples/hck/register.c new file mode 100644 index 000000000000..407d05f74238 --- /dev/null +++ b/samples/hck/register.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sample HCK + * + */ +#include +#include +#include +#include + +static struct sample_hck_data data = { + .stat = 999, + .name = "sample tesst", +}; + +void get_boot_config(int* info) +{ + pr_info("hck sample: %s\n", __func__); + *info = 1; +} + +void set_boot_stat(void* data, int info) +{ + pr_info("hck sample: %s\n", __func__); + info = 2; + struct sample_hck_data *hdata = data; + + pr_info("hck data: stat = %d, name = %s\n", hdata->stat, hdata->name); +} + +static int __init samplehck_init(void) +{ + pr_info("hck sample register\n"); + + REGISTER_HCK_LITE_HOOK(get_boot_config_lhck, get_boot_config); + REGISTER_HCK_LITE_DATA_HOOK(set_boot_stat_lhck, set_boot_stat, &data); + + return 0; +} + +static void __exit samplehck_exit(void) +{ +} + +module_init(samplehck_init); +module_exit(samplehck_exit); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("zhujiaxin "); diff --git a/samples/hck/register_one.c b/samples/hck/register_one.c new file mode 100644 index 000000000000..9ea2c0250328 --- /dev/null +++ b/samples/hck/register_one.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sample HCK + * + */ +#include +#include +#include + +void get_boot_power_config(int* info) +{ + pr_info("hck sample: intf-2 run\n"); + *info = 2; +} + +static int __init samplehckone_init(void) +{ + pr_info("hck sample register_one\n"); + REGISTER_HCK_LITE_HOOK(get_boot_config_lhck, get_boot_power_config); + + return 0; +} + +static void __exit samplehckone_exit(void) +{ +} + +module_init(samplehckone_init); +module_exit(samplehckone_exit); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("zhujiaxin "); -- Gitee