home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / A / BIN / _BIN.TAR / usr / doc / modules / modules.doc next >
Encoding:
Text File  |  1994-12-31  |  1.8 KB  |  52 lines

  1. 1.  What is a module?
  2.  
  3. A module is a collection of code which can be dynamicly linked into the
  4. kernel.  Modules can contain things such as device drivers, system calls,
  5. and file system types [system calls are actually nolonger permitted].
  6.  
  7.  
  8. 2.  How do I create a module?
  9.  
  10. A module consists of a normal .o file.  If you have multiple source
  11. files, combine them into a single .o file using "ld -r".
  12.  
  13.  
  14. 3.  How does the kernel know to use my module?
  15.  
  16. Your code must contain a routine named "init_module" and a routine named
  17. "cleanup_module".  These routines are defined as:
  18.  
  19.     "C" int init_module(void);
  20.     "C" void cleanup_module(void);
  21.  
  22. "Init_module" will be called when the module is loaded.  It should return
  23. zero on success and -1 on failure.  "Cleanup_module" will be called before
  24. the module is deleted.  It should undo the operations performed by
  25. "init_module".  For example, if a module defines a special device type
  26. "init_module" should register the device major number and and
  27. "cleanup_module" should remove it.
  28.  
  29.  
  30. 4.  Show me a simple example!
  31.  
  32. See drv_hello.c in this directory. Note the use count checking macros,
  33. these prevent the module being freed while it is still running!
  34. Also note for the module to be installed it must contain a string
  35. kernel_version[] that matches the release of the current kernel (i.e.
  36. matches uname -r).
  37.  
  38.  
  39. 5.  How do I load and unload modules?
  40.  
  41. "insmod object_file" will install a module into the kernel.  The name
  42. of the module consists of the name of the object file with the .o and
  43. any directory names removed.
  44.  
  45. "lsmod" will produce a list of modules currently in the kernel,
  46. including the module name and size in pages.
  47.  
  48. "rmmod name" will remove a module.  The argument should be the module
  49. name, not the object file name.
  50.  
  51. [Written by Jon Tombs or Bas Larhooven?]
  52.