Advertisement
wandrake

Untitled

Jun 25th, 2012
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/ioport.h> /* request_region, check_region, release_region */
  4. #include <linux/init.h>         /* Needed for the macros */
  5.  
  6. #define MAGICNUM 0x14000000
  7. #define DEVNAME "/dev/sgifazza"
  8.  
  9. int port;
  10.  
  11. static int __init hello_init(void) {
  12.     int result;
  13.     printk("<1>Crime driver TEST!\n");
  14.     port = check_region(MAGICNUM, 1);
  15.     if (port) {
  16.         printk("<1>sgifazza: cannot reserve 0x14000000\n");
  17.         result = port;
  18.         return -1;
  19.     }
  20.     request_region(MAGICNUM, 1, DEVNAME);
  21.     return 0;
  22. }
  23.  
  24. static void __exit hello_exit(void) {
  25.     /* Make port free! */
  26.     if (!port) {
  27.         release_region(MAGICNUM,1);
  28.     }
  29.     printk("<1> Bye, cruel world [Crime driver TEST]\n");
  30. }
  31.  
  32. module_init(hello_init);
  33. module_exit(hello_exit);
  34.  
  35. MODULE_AUTHOR("tua sorella");
  36. MODULE_DESCRIPTION("è un po'mignotta");
  37. MODULE_LICENSE("DTFYWL");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement