
Was : SHAREWARE, now - FREEWARE!

{========================================================================}
{=================       Component TVicHW_95        =====================}
{========================================================================}
{==========  Copyright (c) 1996-1997 Victor I. Ishikeev           =======} 
{========================================================================} 
{==========           victor@ivi.ugatu.ac.ru (home)               =======}
{========================================================================}

1. OVERVIEW
===========

     TVicHW_95 (version 1.0) is FREEWARE-component of handle the PC-equipment 
for use in Delphi 2.x under Windows 95. To 01.02.1997 I plan the release 
a similar component for Delphi 2.x under Windows NT. But it _will be_ 
SHAREWARE!:-E. 

Possibilities of a component:

- writing and reading IO ports;
- access to physical memory; 
- hardware interrupts handling.

2. FILES
========

hwport95.dcr - image for a graphic palette of components;
readme.txt   - this file in English
readme.rus   - this file in Russian 
hwport95.dcu - unit of implementation a component TVicHW_95 
hwport95.vxd - Dynamic loaded virtual driver 
hwport95.dcr - Image for a graphic palette of components 
hw_test.dpr  - Test example (together with main.pas, main.dfm, hw_test.res)

3. INSTALLATION
================

Components will be installed in a graphic palette of components on page "Samples". 
- To copy all files in the selected directory (i.e. C:\HW).;
- To start Delphi and to select Component | Install | Add | browse to C:\HW\hwport95.dcu;
- To press OK for recompilation of the library of components.

4. NOTES
=========

- allocate virtual  driver (hwport95.vxd) in current or /windows/ directory;
- operation only with one hardware interrupt is possible; 
- the handler of an event OnHWInterrupt is fulfilled in separate stream, his priority can 
  be changed. Do not use VCL-calls from OnHwInterrupt!
- I check efficiency of interrupt processing with period in 1 millisecond at 
  the "empty" handler of an event OnHWInterrupt on the computer Pentium-90 with 
  "tpNormal" priority;
- do not try to reassign irq0 (interruption from the system timer), components 
  does not allow it to make.

6. PROPERTYES, METHODS and EVENTS
=================================

6.1. Creation and initialization
--------------------------------

Constructor Create (Owner: TComponent); - to create  of components
Destructor Destroy;                     - to destroy of components
Procedure OpenDriver;                   - to open operation with component   
procedure CloseDriver;                  - to close the driver 
property ActiveHW: Boolean;             - the driver is opened?

The example, components is created and is on the form:

......
var HW_PC : TVicHW_95;
......
with HW_PC do begin
  OpenDriver; {to do in the application an once}
  if ActiveHW then begin
    ...............
    ... Working...
    ...............
    CloseDriver; {to do in the application an once, after completion of all operation} 
  end
  else Application.MessageBox (' Driver not opened! ','Error! ', mbOK); 
end;

6.2. Operation with ports.
--------------------------

property Port  [Index: Word]: Byte; read, write; 
property PortW [Index: Word]: Word; read, write; 
property PortL [Index: Word]: dWord; read, write;

These three properties are similar to the similar predetermined arrays 
from Delphi 1 and quite are suitable, if you want time from time something 
to write in ports or to read from them. Each operation goes through separate 
call to the virtual driver, therefore a minimum cycle makes on my computer 
(P-90) about 25 microseconds.

Example: 

with VicHW_95 do begin
  .....
  Port [$2F8]:=$34;
  .....
  MyByte:=Port [$2f9];
.....
end;


If you need quickly to write / read "pack" of sequentially located ports for one 
call to the driver, use methods:

procedure ReadPortArray (BasePort, NumPorts: Word; pValues: Pointer); 
procedure WritePortArray (BasePort, NumPorts: Word; pValues: Pointer);

Where: BasePort - address of the first port in "pack" 
       NumPorts - amounty of ports in "pack" 
       pValues  - pointer on the byte array of a size [1.. NumPorts] for record 
                  in ports (ReadPortArray) or buffer for reading ports (WritePortArray).

If numbers of ports in "pack" are not located sequentially, you can use methods:

procedure ReadPortRecord (NumPorts: Word; pPorts, pValues: Pointer); 
procedure WritePortRecord (NumPorts: Word; pPorts, pValues: Pointer);

Where: NumPorts - amounty of ports in "pack"; 
       pPorts   - pointer to the array of numbers of ports, which will be be 
                  sequentially read out or are written (array [1.. NumPorts] of Word); 
       pValues  - pointer on the byte array of a size [1.. NumPorts] for record in 
                  ports (ReadPortRecord) or buffer for reading ports (WritePortRecord).

6.2. Operation with phisical memory
-----------------------------------

property PhysMemPtr [PhysAddr, SizeOfByte: dWord]: Pointer; 

This property allows to install the pointer on given memory address.

Example: to install the pointer to BIOS-area [f800:0000] by a size of 256 bytes.

type TMyMemory = array [0 ..255] of Byte; 
pMyMemory = ^TMyMemory;

var MyPointer: PMyMemory;
..........

MyPointer:=PhysMemPtr [$f8000,256];


6.3. Operation with interruption
--------------------------------

Properties and the methods are given in the operating procedure with interruption;

property IRQNumber: Byte; read, write;                         {IRQ number [1..15] } 
property OnHwInterrupt: TNotifyEvent;        {to install in design time or run time} 
                                             {Event for interrupt processing} 

procedure SetIRQ;                            {Set IRQ in the driver} 

property IsIRQSet: Boolean; read;            {to check up, whether is installed IRQ?}

property Priority: THWPriority; read, write; {thread priority for IRQ procession}

procedure UnmaskInterrupt; {no comment :) }

function GetInterruptCounter: dWord; {and how many IRQ is obtained inside the driver?}

property Masked: Boolean;            {the interruption is currently masked?}

procedure MaskInterrupt;  {no comment :) }

procedure DestroyIRQ;                        {to delete IRQ in the driver}

======================================= =====================================

Results of use the component, wish and sentence ask to transmit to me through e-mail. 

victor@ivi.ugatu.ac.ru
Victor I.Ishikeev

Ufa, Russia

