/*
 * hello_world.c 
 * 
 * Author: Konstantinos Chasapis 
 * 	e-mail: konstantinos.chasapis@informatik.uni-hamburg.de
 * 
 * This file is part of the corse matirial „Kernel Programming“ 
 * Praktikum offered from the Scientific Computing group of the   
 * University of Hamburg, Germany. 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * For any commnet or complaint contact the author of the file. 
 *
 */

/* contains definitions and symbols need by loadable modules */
#include <linux/module.h>

/* contains macros for initilization and cleanup functions */
#include <linux/init.h>

/* KERN_ALERT */
#include <linux/kernel.h>

/* 
 * macro to declare that is module bears a free license. 
 * using this license you can call the functions implemented
 * inside the linux kernel.
 */
MODULE_LICENSE("DUAL BSD/GPL");

/* the modules author */
MODULE_AUTHOR("Someone you might know");

/* descripton of the module purpose */
MODULE_DESCRIPTION("This is the Hello World kernel module.");

/* the current version of the module */
MODULE_VERSION("1.0");

/* the initilization function of the module */
static int __init hello_init(void)
{
  /* printk is a subset of printf implemented in the linux kernel.
   * KERN_ALERT is the priority of the message.
   * the output is the function will be printed in the system log files.
   */
  printk(KERN_ALERT "Hello world from the kernel space!\n");

  return 0; /* success */
}

/* the shutdown function of the module */
static void __exit hello_exit(void)
{
  printk(KERN_ALERT "Goodbye, I hope you will load me again!\n");
}

/* declares which function will be invoked when the module is loaded */
module_init(hello_init);

/* declares which function will be invoked when the module is removed */
module_exit(hello_exit);

