home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / communic / biosfix.pas next >
Encoding:
Pascal/Delphi Source File  |  1991-06-09  |  3.6 KB  |  130 lines

  1. {
  2.   BIOSFIX - a program to update the BIOS data area and equipment flag to
  3.   reflect the number and base addresses of standard serial ports Com1 through
  4.   Com4
  5.  
  6.   Usage: BIOSFIX [option]
  7.     Q       quiet mode - suppress messages
  8.     ?       show help
  9.  
  10.   Normally, the BIOS data area that contains the addresses of all known
  11.   standard UARTs, [$0040:0000], is filled in at bootstrap time. Unfortunately,
  12.   not all BIOSs check for UARTs at the Com3 and Com4 addresses. Some
  13.   communications programs check the BIOS data area for UART addresses and will
  14.   refuse to use a serial port unless its address is listed in the BIOS data
  15.   area. In fact, you may choose to use such a check in your programs before
  16.   opening a requested serial port (as a very safe method of operation to
  17.   guarantee that no other hardware is operating at a standard UART address).
  18.  
  19.   BIOSFIX helps out in this area by checking for UARTs at all standard
  20.   addresses and updating the BIOS data area and the equipment flags. You would
  21.   typically run BIOSFIX as part of your AUTOEXEC.BAT -- preferably before
  22.   installing any network drivers or any other hardware drivers (in case the
  23.   addresses of the related hardware conflicts with standard UART addresses).
  24.  
  25.   Requires Async Professional to compile.
  26.   Released to the public domain.
  27.  
  28.   Written by Terry Hughes, TurboPower Software
  29.  
  30.   Version 1.0 - 5/21/91
  31.     initial release
  32. }
  33.  
  34. {$R-,S-}
  35. program BiosFix;
  36.   {-Adds standard serial ports, Com1..Com4, to the BIOS data area}
  37. uses
  38.   ApMisc,
  39.   ApPort,
  40.   ApUart;
  41.  
  42. const
  43.   {Search range}
  44.   FirstCom = Com1;
  45.   LastCom = Com4;
  46.  
  47.   {To show update messages}
  48.   ShowMsg : Boolean = True;
  49.  
  50. var
  51.   Com : ComNameType;
  52.   BaseAddr : Word;
  53.   BiosIndex : Byte;
  54.   BiosData : array[1..4] of Word absolute $40:$0;
  55.   EquipFlag : Word absolute $40:$10;
  56.  
  57.   function HexW(W : Word) : string;
  58.     {-Return hex string for word}
  59.   const
  60.     Digits : array[0..$F] of Char = '0123456789ABCDEF';
  61.   begin
  62.     HexW[0] := #4;
  63.     HexW[1] := Digits[hi(W) shr 4];
  64.     HexW[2] := Digits[hi(W) and $F];
  65.     HexW[3] := Digits[lo(W) shr 4];
  66.     HexW[4] := Digits[lo(W) and $F];
  67.   end;
  68.  
  69. procedure ShowHelp;
  70.   {-Show usage}
  71. begin
  72.   WriteLn('Usage: BIOSFIX [option]');
  73.   WriteLn('  Q     quiet mode - suppress messages');
  74.   WriteLn('  ?     show help');
  75.   Halt;
  76. end;
  77.  
  78. procedure ParseCommandLine;
  79.   {-Get args}
  80. var
  81.   S : String;
  82. begin
  83.   if ParamCount <> 0 then begin
  84.     S := ParamStr(1);
  85.     case upcase(S[1]) of
  86.       'Q' : ShowMsg := False;
  87.       else  ShowHelp;
  88.     end;
  89.   end;
  90. end;
  91.  
  92. procedure UpdateEquip;
  93.   {-Update the equipment flag to reflect the number of serial ports found}
  94. begin
  95.   Dec(BiosIndex);
  96.   EquipFlag := (EquipFlag and $F1FF) or (BiosIndex shl 9);
  97.   if ShowMsg then
  98.     WriteLn('Updated equipment flag to show ', BiosIndex, ' serial ports');
  99. end;
  100.  
  101. begin
  102.   ParseCommandLine;
  103.  
  104.   BiosIndex := 1;
  105.   for Com := FirstCom to LastCom do begin
  106.     {Get the base address for this serial port}
  107.     if ((Com = Com3) or (Com = Com4)) and IsPS2 then
  108.       BaseAddr := DefPS2Addr[Com]
  109.     else
  110.       BaseAddr := DefBaseAddr[Com];
  111.  
  112.     {If a UART is found, update the BIOS data area}
  113.     if UartTest1(BaseAddr) and UartTest2(BaseAddr) then begin
  114.       if ShowMsg then
  115.         WriteLn('BIOS updated for ', ComNameString(Com), ' at ', HexW(BaseAddr));
  116.       BiosData[BiosIndex] := BaseAddr;
  117.       Inc(BiosIndex);
  118.  
  119.       {Prevent overflowing the BIOS data area}
  120.       if BiosIndex > 4 then begin
  121.         UpdateEquip;
  122.         Halt;
  123.       end;
  124.     end;
  125.   end;
  126.  
  127.   {Update the equipment flags}
  128.   UpdateEquip;
  129. end.
  130.