                           TVicHw32 version 2.0

                   Copyright (C) 1997 Victor Ishikeev
                     e-mail: victor@ivi.ugatu.ac.ru
                Portions Copyright (C) 1997 EnTech Taiwan
                     e-mail: tools@entechtaiwan.com

                             AS_COMP.TXT



CONTENTS
========

1. GENERAL TVicHW32 COMPONENT PROPERTIES AND METHODS
2. DIRECT MEMORY ACCESS WITH TVicHW32
3. DIRECT PORT I/O WITH TVicHW32
4. HARDWARE INTERRUPT HANDLING WITH TVicHW32
5. CONTACT INFORMATION



1. GENERAL TVicHW32 COMPONENT PROPERTIES AND METHODS
====================================================

After successfully adding the TVicHW32 component to your VCL, and
after copying the kernel-mode driver(s) to the appropriate Windows
directories, you can test the functionality of the component, and
examine the sample code provided, by opening the included HW_TEST
demonstration program.

TVicHW32 has the following general component properties and methods:

    constructor Create (Owner: TComponent); override;
    -------------------------------------------------
    The Create method allocates memory to create the TVicHW32 
    component and initializes data as needed. Note that Create does 
    *not* automatically open the kernel-mode driver: you must open the
    kernel-mode driver with the OpenDriver method (see below).

    You do not normally need to directly call the Create method; the 
    component is automatically created at run-time.
    
    destructor Destroy; override;
    -----------------------------
    The Destroy method destroys the TVicHW32 component releases the 
    memory allocated to it. If a hardware interrupt was "unmasked" to
    permit direct access, the "mask" is automatically restored, and if 
    the kernel-mode driver was opened, it is automatically closed.

    You do not normally need to directly call the Destroy method; the 
    component is automatically destroyed when the application closes.

    procedure OpenDriver;
    ---------------------
    Loads the vichwXX.vxd (under Windows 95) or vichwXX.sys (under 
    Windows NT) kernel-mode driver, providing direct access to the 
    hardware. If the kernel-mode driver was successfully opened, the
    boolean ActiveHW property (see below) will be set to True; if the 
    procedure fails, the ActiveHW property will be False.

    procedure CloseDriver;
    ----------------------
    Closes the kernel-mode driver and releases memory allocated to it.
    If a hardware interrupt was "unmasked", the "mask" is restored. If the
    driver was successfully closed, the ActiveHW property (see below) will
    be set to False.

    property ActiveHW: Boolean; (published, read);
    ----------------------------------------------
    The read-only and run-time ActiveHW property specifies whether the
    kernel-mode driver is open. ActiveHW returns True if the driver is
    open, or False if it is not.


2. DIRECT MEMORY ACCESS WITH TVicHW32
=====================================

The following function permits direct memory acccess:

    function MapPhysToLinear (PhAddr: dWord; Size: dWord): Pointer;
    ---------------------------------------- ----------------------
    Maps a specific physical address to a pointer in linear memory, 
    where PhAddr is the base address and Size is the actual number of
    bytes to which access is required.

    Note that a subsequent call to MapPhysToLinear invalidates the 
    previous pointer.

    The following example returns a pointer to the system ROM BIOS area:

    type 
      TBiosArray = array [0 ..255] of Byte;
      PBiosArray = ^TBiosArray;

    var 
      pBIOS: PBiosArray;

    begin
      with VicHw32 do
      begin
        OpenDriver;
        if ActiveHW then
        begin
          PBIOS:=MapPhysToLinear ($F8000,256); //255 bytes beginning at $F8000
          {...working with pBIOS...}
          CloseDriver;
        end
        else ShowMessage('ERROR: Kernel-mode driver is not open.'); 
      end;
    end;

3. DIRECT PORT I/O WITH TVicHW32
================================

For access to the 80x86 CPU data ports, TVicHW32 provides an implementation of
the traditional Borland Pascal 7 predefined arrays, Port and PortW, and adds
PortL (which accepts a DWORD) and a "Hard/Soft" boolean switch.

When a value is assigned to an array of type Port, PortW, or PortL, the value 
is output to the selected port. When an array of type Port, PortW or PortL is 
referenced in an expression, its value is input from the selected port. Use of 
the Port, PortW and PortL arrays are restricted to assignment and reference in 
expressions only.

The following properties permit direct I/O port access:

    property Port[Index: Word]: Byte; (public, read, write);
    --------------------------------------------------------
    Value of the Port array is of type Byte.

    property PortW [Index: Word]: Word; (public, read, write);
    --------------------------------------- ------------------
    Value of the PortW array is of type Word.

    property PortL [Index: Word]: dWord; (public, read, write);
    --------------------------------------- -------------------
    Value of the PortL array is of type DWord.

    procedure   PortControl(Ports:pPortRec; NumPorts:Word);
    -------------------------------------------------------

    This method allows write/read array of ports.

    type PortRec = array[1..NumPorts] of record
           PortAddr : Word;    // Address
           PortData : Byte;    // Data (for writing or after reading)
           fWrite   : Boolean; // TRUE if you want to write this port 
                               // and FALSE if to read.
         end;
     pPortRec   =^PortRec;

    procedure ReadPortFIFO(PortAddr:Word; NumPorts:Word; var Buffer);
    ----------------------------------------------------------------
   
    This method allows read array of bytes from single port.

    procedure WritePortFIFO(PortAddr:Word; NumPorts:Word; var Buffer);
    ------------------------------------------------------------------
   
    This method allows write array of bytes to single port.

    property HardAccess: Boolean; (published, read, write);     
    --------------------------------------- ---------------
    The HardAccess property determines whether the kernel-mode driver
    should use "hard" or "soft" access to the I/O ports. If set to True
    "hard" access is employed; if set to False "soft" access is employed.

    "Soft" access provides higher performance access to ports, but may fail
    if the port(s) addressed are already in use by another kernel-mode 
    driver. While slower, "Hard" access provides more reliable access to
    ports which have already been opened by another kernel-mode driver. 

    The following example demonstrates direct port I/O calls, and generally
    complies with traditional Borland Pascal 7 syntax to facilitate porting
    16-bit code to Delphi 2:

    with VicHw32 do
    begin
      {...}
      Port[$2F8]:=$34;     // write a byte to port
      {...}
      MyByte:=Port[$2f9];  // read a byte from a port
      {...}
    end;


4. HARDWARE INTERRUPT HANDLING WITH TVicHW32
============================================

In a Win32 environment, hardware interrupts are normally hidden or "masked" 
by Windows; the TVicHW32 kernel-mode driver allows you to "unmask" the 
interrupt for direct handling by your application. Note that only one 
interrupt can be handled at a time.

The following properties and methods permit access to hardware interrupts.

    property OnHwInterrupt: TNotifyEvent; published;
    ------------------------------------------------
    Notification event that a specific hardware interrupt has occurred. 

    property IRQNumber: Byte; (published, read, write)
    --------------------------------------------------
    Specifies which hardware interrupt (IRQ1..15) is to be unmasked for 
    processing. Note that IRQ0 (the system timer) is *not* supported.

    procedure SetIRQ;
    -----------------
    Assign the interrupt specified by the IRQNumber property to the
    OnHwInterrrupt event, and sets the IsIRQSet property (see below) to True.

    procedure UnmaskInterrupt;
    --------------------------
    Unmasks the hardware interrupt specified by the IRQNumber property, so 
    that an OnHWInterrupt event will be generated when a hardware interrupt 
    occurs, and sets the Masked property (see below) to False. 

    procedure MaskInterrupt;
    ------------------------
    Masks the hardware interrupt specified by the IRQNumber property.

    procedure DestroyIRQ;
    ---------------------
    Frees the memory and code previously assigned for unmasking the hardware
    interrupt specified by the IRQNumber property, setting the IsIRQSet 
    property to False and the Masked property to True.

    property IsIRQSet: Boolean; (read only);
    ----------------------------------------
    Read-only property which specifies whether the hardware interrupt handler
    has been created by the SetIRQ method.
 
    property Masked: Boolean; (read only);
    --------------------------------------
    Read-only property which specifies whether the hardware interrupt handler 
    has been removed (True), or is still active (False).

    property IRQCounter: dWord; (read only);
    ----------------------------------------
    Read-only property which counts the number of hardware interrupts 
    intercepted by the TVicHW32 kernel-mode driver. The IRQCounter property 
    is provided largely for debugging purposes, allowing you to compare the 
    actual number of hardware interrupts generated with the number processed 
    by your application.
    
    procedure SimulateHwInt;
    ------------------------
    This procedure is provided for purposes of debugging, and allows you to
    simulate a hardware interrupt. When this procedure is called, the TVicHW32
    kernel-mode driver will feign a "hardware interrupt", without directly
    affecting the hardware.

5. CONTACT INFORMATION
======================

    Comments, questions and suggestions regarding TVicHW32 can be directed
by e-mail to victor@ivi.ugatu.ac.ru or tools@entechtaiwan.com.

With best wishes,

Victor Ishikeev
June 1997