diff --git a/samples/Kconfig b/samples/Kconfig index b0ddf5f3673887174da5a0a5c1d46f51003ebdf2..2d5861bf9c4e4e41e710d54101f228da58d8c2a0 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 0a551c2b33f430d639ad6f420b1e391a0599ccf7..485a0c503de0051dc82a62f0ff351ae01dd4ce34 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 0000000000000000000000000000000000000000..1f24a99a46f48e1f5225f3600b49a0af0a1d8711 --- /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 0000000000000000000000000000000000000000..870d5611c082e9683eca9b2c9a7d1aefbfb7e62c --- /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 0000000000000000000000000000000000000000..407d05f74238e64df15875f61a922080446d9274 --- /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 0000000000000000000000000000000000000000..9ea2c025032866fcd1f87e61c99f11582ef5380d --- /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 ");