name and types
* scope all the function names * fix the fibonacci type to a long * variablize the fib input and print it out
This commit is contained in:
parent
e929dbcb6f
commit
b090072939
1 changed files with 22 additions and 16 deletions
38
mod_hello.c
38
mod_hello.c
|
@ -3,15 +3,15 @@
|
||||||
|
|
||||||
#include <linux/kallsyms.h>
|
#include <linux/kallsyms.h>
|
||||||
|
|
||||||
static char __initdata hellomsg[] = KERN_NOTICE "Hello, Kernel, I'm in\n";
|
static char __initdata hello_hellomsg[] = KERN_NOTICE "Hello, Kernel, I'm in\n";
|
||||||
static char __exitdata byemsg[] = KERN_NOTICE "Bye, I'm out\n";
|
static char __exitdata hello_byemsg[] = KERN_NOTICE "Bye, I'm out\n";
|
||||||
|
|
||||||
static int print_hello(void)
|
static int hello_print_hello(void)
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
char *symbol_name;
|
char *symbol_name;
|
||||||
|
|
||||||
printk(hellomsg);
|
printk(hello_hellomsg);
|
||||||
|
|
||||||
symbol_name = "free_pages";
|
symbol_name = "free_pages";
|
||||||
printk("looking up '%s'\n", symbol_name);
|
printk("looking up '%s'\n", symbol_name);
|
||||||
|
@ -21,12 +21,12 @@ static int print_hello(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fib(int times, int n1, int n2)
|
long hello_fib(long times, long n1, long n2)
|
||||||
{
|
{
|
||||||
int i = 0;
|
long i = 0;
|
||||||
int prev = n1;
|
long prev = n1;
|
||||||
int curr = n2;
|
long curr = n2;
|
||||||
int next = 0;
|
long next = 0;
|
||||||
|
|
||||||
while (i < times)
|
while (i < times)
|
||||||
{
|
{
|
||||||
|
@ -41,24 +41,30 @@ int fib(int times, int n1, int n2)
|
||||||
|
|
||||||
static int __init start_hello_world(void)
|
static int __init start_hello_world(void)
|
||||||
{
|
{
|
||||||
int f_int;
|
long f_int, f_cap, f_start1, f_start2;
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_AUTHOR("Vincent Batts <vbatts@hashbangbash.com>");
|
MODULE_AUTHOR("Vincent Batts <vbatts@hashbangbash.com>");
|
||||||
MODULE_DESCRIPTION("i am just reading headers");
|
MODULE_DESCRIPTION("just getting familiar");
|
||||||
MODULE_VERSION("1.0");
|
MODULE_VERSION("1.0");
|
||||||
print_hello();
|
hello_print_hello();
|
||||||
|
|
||||||
f_int = fib(10000000, 0, 1);
|
f_cap = 10000000;
|
||||||
|
f_start1 = 0;
|
||||||
|
f_start2 = 1;
|
||||||
|
f_int = hello_fib(f_cap, f_start1, f_start2);
|
||||||
|
|
||||||
|
printk("fib of %ld and %ld (up to %ld): %ld\n", f_start1, f_start2, f_cap, f_int);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit go_away(void)
|
static void __exit hello_go_away(void)
|
||||||
{
|
{
|
||||||
printk(byemsg);
|
printk(hello_byemsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(start_hello_world);
|
module_init(start_hello_world);
|
||||||
module_exit(go_away);
|
module_exit(hello_go_away);
|
||||||
|
|
||||||
// vim:set shiftwidth=4 softtabstop=4 expandtab:
|
// vim:set shiftwidth=4 softtabstop=4 expandtab:
|
||||||
|
|
Loading…
Reference in a new issue