-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHello_mod.c
More file actions
36 lines (30 loc) · 865 Bytes
/
Hello_mod.c
File metadata and controls
36 lines (30 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/printk.h>
MODULE_LICENSE("GPL v3");
MODULE_AUTHOR("AKhadhraoui47");
MODULE_DESCRIPTION("Hello World Module");
static uint32_t argc_k = 0;
static uint16_t argv_k[2] = {-1, -1};
module_param_array(argv_k, short, &argc_k, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
MODULE_PARM_DESC(argv_k, "My Array of short Integers");
static int __init hello_init(void)
{
uint8_t i = 0;
pr_info("Hello, world\n");
for (i = 0; i < ARRAY_SIZE(argv_k); i++)
{
pr_info("My argument [%hd] = %hd\n", i, argv_k[i]);
}
pr_info("Nb of arguments is %u\n", argc_k);
return 0;
}
static void __exit hello_exit(void)
{
pr_info("Goodbye, world\n");
}
module_init(hello_init);
module_exit(hello_exit);