home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / at / setup21.arc / CMOS.PAS next >
Encoding:
Pascal/Delphi Source File  |  1988-06-03  |  2.8 KB  |  84 lines

  1. unit CMOS;
  2.  
  3. Interface
  4.  
  5. const
  6.      ClockSec  = $00;    { RTclock seconds }
  7.      ClockMin  = $02;    { RTclock minutes }
  8.      ClockHour = $04;    { RTclock hours }
  9.      ClockDOW  = $06;    { RTclock day of week }
  10.      ClockDay  = $07;    { RTclock day in month }
  11.      ClockMon  = $08;    { RTclock month }
  12.      ClockYear = $09;    { RTclock year (mod 100)}
  13.      AlarmSec  = $01;    { Alarm seconds }
  14.      AlarmMin  = $03;    { Alarm minutes }
  15.      AlarmHour = $05;    { Alarm hours }
  16.      Diskettes = $10;    { Floppy disk type byte }
  17.      HardDisk  = $12;    { Regular hard disk type }
  18.      HDExt1    = $19;    { Extended hard disk type, unit 1 }
  19.      HDExt2    = $1A;    { Extended hard disk type, unit 2 }
  20.      Equipment = $14;    { Equipment list }
  21.      CheckLo   = $2F;    { Checksum low }
  22.      CheckHi   = $2E;    { Checksum high }
  23.      BaseLo    = $15;    { Base mem low }
  24.      BaseHi    = $16;    { Base mem high }
  25.      ExpdLo    = $17;    { Expansion mem size low }
  26.      ExpdHi    = $18;    { Expansion mem size high }
  27.      StatRegA  = $0A;    { Status Register A }
  28.      StatRegB  = $0B;    { Status register B }
  29.      StatRegC  = $0C;    { Status register C }
  30.      StatRegD  = $0D;    { Status register D }
  31.      DiagStat  = $0E;    { Diagnostic status byte }
  32.      ShutDown  = $0F;    { Shutdown status byte }
  33.      Century   = $32;    { BCD Century number }
  34.      AltExpdLo = $30;    { Expansion mem size low (alternate) }
  35.      AltExpdHi = $31;    { Expansion mem size high (alternate) }
  36.      InfoFlags = $33;    { Bit 7 set = top 128k installed, bit
  37.                            6 set = first user message (?) }
  38.  
  39. function ReadCmos(Address: byte): byte;
  40.           { Returns the byte at the given CMOS ADDRESS }
  41.  
  42. procedure WriteCmos(Address, Data: byte);
  43.           { Writes DATA to ADDRESS in CMOS ram }
  44.  
  45. procedure SetCMOSCheckSum;
  46.           { Sets the CMOS checksum after you've messed with it :-}
  47.  
  48. { The following bytes are RESERVED: $11, $13, $1B-$2D, and 
  49.   $34-$3F ($3F marks the end of the CMOS area).  You'll note that
  50.   some of these are included in the checksum calculation. }
  51.  
  52. implementation
  53.  
  54. const
  55.      CmosAddr  = $70;    { CMOS control port }
  56.      CmosData  = $71;    { CMOS data port }
  57.  
  58. function ReadCmos(Address: byte): byte;
  59. begin
  60.      port[CmosAddr] := Address;
  61.      ReadCmos := port[CmosData]
  62. end; {ReadCmos}
  63.  
  64. procedure WriteCmos(Address, Data: byte);
  65. begin
  66.      port[CmosAddr] := Address;
  67.      port[CmosData] := Data
  68. end; {WriteCmos}
  69.  
  70. procedure SetCMOSCheckSum;
  71. { The checksum is simply the sum of $10 to $2D 
  72.   (some of these bytes are reserved) }
  73.  
  74. var
  75.      I, Sum: word;
  76. begin
  77.      Sum := 0;
  78.      for I:= $10 to $2D do Sum := Sum + ReadCmos(I);
  79.      WriteCmos(CheckHi, Hi(sum));
  80.      WriteCmos(CheckLo, Lo(sum));
  81. end; {SetCMOSCheckSum}
  82.  
  83. end.
  84.