home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / dev.txt < prev    next >
Text File  |  2003-04-13  |  4KB  |  113 lines

  1. 1 Introduction
  2. ==============
  3. This document lists all the needed tools and compilers to build the lxapi32
  4. OS/2 device driver.
  5. It also tries to give some informations about the architecture of the driver
  6. and explain some technical details.
  7.  
  8. 2 Required tools
  9. ================
  10. - Watcom C/C++ version 11.0c
  11. - ALP 4.x (IBM assembler; comes with ddk)
  12. - IBM OS/2 DDK (http://service.boulder.ibm.com/ddk/)
  13.   - Base header/libraries/tools (combase.zip)
  14.   - MMPM/2 base (mmpmdd.zip)
  15.   - PDD & MMPM/2 driver reference
  16.  
  17. 3 Recommended tools for debugging
  18. =================================
  19. - ICAT debugger (follow link from IBM DDK page)
  20. - OS/2 Debug kernel
  21.  
  22. 4 Building the driver
  23. =====================
  24. You need some environment variables for build:
  25. DDK should point to the DDK directory
  26. LXAPI32DEV should point to the directory, where LXAPI32 source files are installed
  27. WATCOM should point to the Watcom directories
  28.  
  29. You can build the driver from the main directory by executing:
  30. build.cmd
  31. This will create the debug version of the driver.
  32. Parameters to build.cmd:
  33. clean   Clean up all directories
  34. release Make release version (without debug)
  35. debug   Make debug version (default)
  36. all     Rebuild all files
  37.  
  38. 5 LXAPI32 driver architecture
  39. =============================
  40. LXAPI32 contains a lot of Linux function calls.
  41. At initialization time a driver should attach to LXAPI32 and get all function
  42. entry points via IDC calls. After this, all functions can be called directly.
  43. The SKELETON directory contains a simple skeleton driver that shows you how
  44. to attach to LXAPI32 and get the function entry points.
  45.  
  46.  
  47. There are some differences between linux and LXAPI32:
  48.  
  49. timer
  50. -------
  51. LXAPI32 registers a timer handler at init time. While processing a timer
  52. interrupt LXAPI32 calls every timer. Also schedules() are solved with a timer
  53. interrupt. A thread that calls schedule() will block. In the timer interrupt
  54. handler all (scheduled) blocked threads will be unblocked. The timer interrupt
  55. handler also manages all registered threads (see below).
  56.  
  57. threads
  58. --------
  59. It is impossible to provide kernel threads in OS/2. Threads in LXAPI32 are
  60. implemented with timer interrupts. At every timer tick LXAPI32 calls the
  61. function that was registered with the kernel_thread() function. This function
  62. should not block or stay in an endless loop. Instead it should be redesigned
  63. to give up (return) as needed. An Example:
  64. // Original thread code:
  65. static int stopThread=0;
  66. int myThread(void *data)
  67. {
  68.  while(stopThread==0)
  69.  {
  70.   // Do something
  71.   schedule();
  72.   // Do something different
  73.   schedule();
  74.  }
  75. }
  76.  
  77. // Modified thread code:
  78. static int stopThread=0;
  79. static int loopMode;
  80. int myThread(void *data)
  81. {
  82.  switch(loopMode)
  83.   {
  84.    case 0:
  85.      // Do something
  86.      loopMode=1;
  87.      break;
  88.    case 1:
  89.      // Do something different
  90.      loopMode=0;
  91.      break;
  92.   }
  93.  if(stopThread)
  94.   return 1;
  95.  else
  96.   return 0;
  97. }
  98.  
  99. As you can see it is necessary to provide an extra variable to save the
  100. thread's current state. This is used in a switch/case to decide which function
  101. to call.
  102.  
  103. Resource requests
  104. -----------------------
  105. Calls to request_irq() and and all request_* functions as defined in sched.h
  106. needs as an extra parameter a pointer to a struct lxrm_resource. This pointer
  107. is needed to support OS2 Resource Manager.
  108.  
  109. 6 SKELETON sample driver
  110. ========================
  111. In the directory SKELETON you'll find a sample device driver. If you plan to
  112. write an own driver based on LXAPI32.SYS you can use this sample as a template.
  113.