home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / miscpmos.def < prev    next >
Text File  |  1998-01-27  |  6KB  |  126 lines

  1. DEFINITION MODULE MiscPMOS;
  2.  
  3.         (************************************************)
  4.         (*                                              *)
  5.         (*      Miscellaneous PMOS procedures           *)
  6.         (*                                              *)
  7.         (*  Programmer:         P. Moylan               *)
  8.         (*  Last edited:        8 May 1997              *)
  9.         (*  Status:             OK                      *)
  10.         (*                                              *)
  11.         (************************************************)
  12.  
  13. IMPORT SYSTEM;
  14.  
  15. TYPE RegisterPacket =
  16.                 (* We don't bother covering everything here, just       *)
  17.                 (* the registers we have a need for.                    *)
  18.                 RECORD
  19.                     CASE :BOOLEAN OF
  20.                      | FALSE:   AL, AH, BL, BH, CL, CH, DL, DH: SYSTEM.BYTE;
  21.                      | TRUE:    AX, BX, CX, DX, BP, SI, DI, DS, ES: CARDINAL;
  22.                     END (*CASE*);
  23.                 END (*RECORD*);
  24.  
  25.      CMOSaddress = CARDINAL[0..63];
  26.  
  27. (************************************************************************)
  28. (*                              STRING COPY                             *)
  29. (************************************************************************)
  30.  
  31. PROCEDURE CopyString (source: ARRAY OF CHAR;  VAR (*OUT*) dest: ARRAY OF CHAR);
  32.  
  33.     (* Copies a string, with truncation or null termination as needed.  *)
  34.     (* This function is provided in order to help software portability, *)
  35.     (* i.e. to avoid having to rewrite code for no reason other than    *)
  36.     (* a change of compilers.                                           *)
  37.  
  38. (************************************************************************)
  39. (*                          STRING COMPARISON                           *)
  40. (************************************************************************)
  41.  
  42. PROCEDURE Compare (first, second: ARRAY OF SYSTEM.LOC): INTEGER;
  43.  
  44.     (* Returns >0 if first>second, 0 if first=second, <0 if             *)
  45.     (* first<second.  The comparison is bytewise, from the left,        *)
  46.     (* treating each byte as an unsigned number.                        *)
  47.  
  48. (************************************************************************)
  49. (*                   MISCELLANEOUS LOW-LEVEL OPERATIONS                 *)
  50. (************************************************************************)
  51.  
  52. PROCEDURE EnterCriticalSection(): CARDINAL;
  53.  
  54.     (* Saves the processor flags word, including the current "interrupt *)
  55.     (* enable" status, on the caller's stack, and returns with          *)
  56.     (* interrupts disabled.   NOTE: this procedure and the following    *)
  57.     (* one should be used as a matched pair.                            *)
  58.  
  59. PROCEDURE LeaveCriticalSection (savedPSW: CARDINAL);
  60.  
  61.     (* Restores the processor flags word, including the "interrupt      *)
  62.     (* enable" status, from the stack.  NOTE: this procedure and the    *)
  63.     (* one above should be used as a matched pair.                      *)
  64.  
  65. (************************************************************************)
  66. (*       The remaining procedures in this module are unavailable,       *)
  67. (*             because of incompatibility with OS/2                     *)
  68. (************************************************************************)
  69.  
  70. (*
  71. (************************************************************************)
  72. (*                      PROCEDURES TO ACCESS CMOS                       *)
  73. (************************************************************************)
  74. (*                                                                      *)
  75. (*  The first 14 bytes of CMOS are used for the real-time clock - see   *)
  76. (*  module TimeOfDay for details.                                       *)
  77. (*                                                                      *)
  78. (*  The contents of the remaining bytes would take too long to describe *)
  79. (*  here, so only the ones of current interest are mentioned:           *)
  80. (*                                                                      *)
  81. (*      10H     Diskette drive type.  The high order 4 bits describe    *)
  82. (*              drive A, the lower order 4 bits describe drive B.       *)
  83. (*              The encoding is:                                        *)
  84. (*                      0       no drive present                        *)
  85. (*                      1       double sided drive, 48 TPI              *)
  86. (*                      2       high capacity drive, 96 TPI             *)
  87. (*                      4       3.5" 1.44MB drive                       *)
  88. (*                  (other values are reserved).                        *)
  89. (*                                                                      *)
  90. (************************************************************************)
  91.  
  92. PROCEDURE ReadCMOS (location: CMOSaddress): SYSTEM.BYTE;
  93.  
  94.     (* Returns the value at the given CMOS location.    *)
  95.  
  96. PROCEDURE WriteCMOS (location: CMOSaddress;  value: SYSTEM.BYTE);
  97.  
  98.     (* Stores a value at the given CMOS location.       *)
  99.  
  100. (************************************************************************)
  101. (*                         BIOS/MS-DOS CALLS                            *)
  102. (************************************************************************)
  103.  
  104. PROCEDURE BIOS (InterruptNumber: CARDINAL;
  105.                         VAR (*INOUT*) Registers: RegisterPacket);
  106.  
  107.     (* Performs a software interrupt, with the given interrupt number,  *)
  108.     (* after loading the components of variable "Registers" into the    *)
  109.     (* machine registers.  After the handler returns, the updated       *)
  110.     (* register values are put back into variable "Registers".          *)
  111.  
  112. PROCEDURE ProcessorStatus(): CARDINAL;
  113.  
  114.     (* Returns the current value of the processor flags word.   *)
  115.  
  116. PROCEDURE ShortDelay (amount: CARDINAL);
  117.  
  118.     (* Provides a time delay for those cases where the required delay   *)
  119.     (* is not long enough to justify a Sleep() operation.               *)
  120.     (* The present version is not entirely satisfactory - needs to be   *)
  121.     (* re-tuned for different compiler options, different processor     *)
  122.     (* models, etc.  This should be seen as an interim solution only.   *)
  123. *)
  124.  
  125. END MiscPMOS.
  126.