?? as_comp.txt
字號:
TVicHW32 version 3.0
====================
Copyright (C) 1997,1998 Victor Ishikeev
e-mail: ivi@ufanet.ru, tools@entechtaiwan.com
http://www.entechatiwan.com/tools.htm
AS_COMP.TXT
===========
CONTENTS
========
1. GENERAL TVicHW32 COMPONENT PROPERTIES AND METHODS
2. DIRECT MEMORY ACCESS WITH TVicHW32 (NEW features!)
3. DIRECT PORT I/O WITH TVicHW32
4. HARDWARE INTERRUPT HANDLING WITH TVicHW32 (NEW features!)
5. SPECIFIC WORK WITH THE LPT PORT (NEW!)
6. 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 (includes NEW features!)
==============================================================
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.
NEW! Now you can get up 16 of valid pointers to various physical
=== addresses.
The pointer returned by MapPhysToLinear() can be used in Mem[],
MemW[] and in MemL[] properties (NEW! see below)
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;
NEW!
====
For access to the predefined memory area, TVicHW32 3.0 provides an
implementation of the traditional Borland Pascal 7 predefined arrays,
Mem, MemW and MemL
property Mem[Base:Pointer; Index:DWORD] : Byte; read, write;
-----------------------------------------------------------------
Value of the Mem array is of type Byte.
This property allows read/write one byte from the array type Byte
based at given linear address: Result := Mem[Base, index].
"Index" value should begin from the "0" value.
In general, "Base" can be any valid linear pointer to the memory. But
if this pointer was received from the MapPhysToLinear() function then
you can access physical memory also.
property MemW[Base:Pointer; Index:DWORD] : Word; read, write;
-----------------------------------------------------------------
Value of the MemW array is of type Word.
This property allows read/write two bytes (one word) from the array
type word based at given linear address: Result := MemW[Base, index].
"Index" value should begin from the "0" value.
property MemL[Base:Pointer; Index:DWORD] : DWORD; read, write;
-----------------------------------------------------------------
Value of the MemL array is of type DWORD.
This property allows read/write four bytes (two words) from the array
type DWORD based at given linear address: Result := MemL[Base, index].
"Index" value should begin from the "0" value.
The following example demonstrates direct access to the physical memory
address 0040:0008:
type TLPTAddress : array[1..3] of Word;
PLPTAddress :^PLPTAddress;
var PLPT : PLPTAddress;
index : DWORD;
with VicHw32 do
begin
{...}
PLPT := MapPhysToLinear($408,6); // Map 6 bytes to the linear address space
for index:= 0 to 2 do
ShowMessage("Address of LPT"+IntToStr(index+1)+" is: "+IntToHex(MemW[PLPT,index]);
{...}
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); default TRUE;
--------------------------------------- -----------------------------
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.
I reccomend you use HardAccess := TRUE.
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 (NEW features!)
============================================================
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 (Sender : TObject;
HwCounter : Longint;
LPT_DataReg : Byte;
LPT_StatusReg : Byte;
Keyb_ScanCode : Byte) of object; published;
-------------------------------------------------------------------
Notification event that a specific hardware interrupt has occurred.
HwCounter : shows how many interruption was processed in the driver.
LPT_DataReg : if used IRQ7 then driver reads base LPT port (data)
LPT_StatusReg : if used IRQ7 then driver reads status LPT register(base+2)
Keyb_ScanKode : if used IRQ1 then driver allows you see all keystrokes
(scan codes) from the keyboard.
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.
property IRQMasked : Boolean; (public, read, write);
---------------------------------------------------
Unmasks (IRQMasked := TRUE) or masks the hardware interrupt specified
by the IRQNumber property, so that an OnHWInterrupt event will be generated
when a hardware interrupt occurs.
You can read this property when you want check if current IRQ masked or not.
5. SPECIFIC WORK WITH THE LPT PORT (NEW!)
=========================================
Now TVicHW32 provides extended properties and methods for work with the
printer (LPT) port.
==== BASE ====
property LPTNumPorts : Byte; (public, read only)
-------------------------------------------
Shows how many LPT ports are installed on your PC.
property LPTNumber : Byte; (public, read, write, default 1);
-----------------------------------------------------------
Allows select a current LPT port.
property LPTBasePort : Word; (public, read);
--------------------------------------------
Returns a base address of the current LPT port.
==== PINS ====
property Pin[Index:1..25] : Boolean; (public, read, write)
---------------------------------------------------------
Allows : 1) Read an electrical level from the select pin of
current LPT port. Returns TRUE if current level is HIGH
2) Write an electrical level to the selected pin.
TRUE - HIGH level.
Note: Not all pins are accessible for this operation. Run test example
for more info.
==== STATUS ====
property LPTAckwl : Boolean (public, read)
------------------------------------------
Returns ACKWL state from the printer
property LPTBusy : Boolean (public, read)
------------------------------------------
Returns BUSY state from the printer
property LPTPaperEnd : Boolean (public, read)
--------------------------------------------
Returns PAPER END state from the printer
property LPTSlct : Boolean (public, read)
------------------------------------------
Returns SLCT state from the printer
property LPTError : Boolean (public, read)
------------------------------------------
Returns ERROR state from the printer
=== COMMANDS ===
procedure LPTStrobe; public;
----------------------------
Sends STROBE signal to the printer
procedure LPTAutofd(Flag:Boolean); public;
------------------------------------------
Sets current AUTOFD state on printer
procedure LPTInit; public;
-------------------------------------
Resets printer by sending INIT signal
procedure LPTSlctIn; public;
----------------------------------
Sends SLCTIN signal to the printer
function LPTPrintChar(ch:Char):Boolean; public;
-----------------------------------------------
Sends one symbol to the printer. Returns TRUE if
successed. Otherwise you need repeat this operation.
6. CONTACT INFORMATION
======================
Comments, questions and suggestions regarding TVicHW32 can be directed
by e-mail to ivi@ufanet.ru or tools@entechtaiwan.com. For the latest version
of TVicHW32 visit http://www.entechatiwan.com/tools.htm
With best wishes,
Victor Ishikeev
Oct 1998
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -