Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Class TkdCustomCard

Unit

kdclxcore

Declaration

type TkdCustomCard = class(TComponent)

Description

Class TkdCustomCard models hardware device. Whereas descendants of TkdResource class model different hardware resources separately (such as: memory and port ranges, registers, interrupts and other), TkdCustomCard models hardware device (or card) on the whole. This class includes members for making up the device abstraction (henceforth, model) by attaching and detaching essential resources mentioned above, loading and unloading the GDD, registering and unregistering the device model (the prototype of user-mode device driver) in the system. An original and very powerful feature is that this component and its CardItems property are equipped with a specific editor - tool whose name is CardBuilder. Right at design time CardBuilder, like a wizard, helps you to produce the definition of device model and the diagnostics of corresponding hardware. TkdCustomCard is the ultimate class for hardware devices, it does not support inheritance. Although TkdCustomCard class has dozens of methods and properties, relevant members are documented only. Refer to the outside documentation about how to use CardBuilder.

Methods

Overview

Publicconstructor Create (AOwner: TComponent); override;
Publicdestructor Destroy; override;
Publicfunction AddResource(Item: TkdResource): Longint;
Publicfunction CallUserCodeFromKernel(pCode: Pointer): LongWord;
Publicprocedure Clear;
Publicprocedure DeleteResource(AHandle: Longint);
Publicfunction ExecNativeKernelRoutine(var RoutineName: String): LongWord;
Publicfunction GetCountByClass (ClassName: ShortString): Integer;
Publicfunction ItemIndexByHandle(AHandle: Longint; ClassName: ShortString): Integer;
Protectedfunction LoadModule: Boolean;
Publicfunction RegisterCard: Boolean;
Protectedprocedure RemoveItem(Item: TkdResource);
Publicfunction Sleep: Boolean;
Protectedprocedure UnloadModule;
Publicprocedure UnregisterCard;

Description

Publicconstructor Create (AOwner: TComponent); override;

TkdCustomCard redefines Create so that, for hardware device, Create also: 1. checks that the hardware device component is being placed onto a TDataModule instance; 2. checks that the hardware device component is the only one per application; 3. registers all classes modelling hardware resources.

Publicdestructor Destroy; override;

TkdCustomCard redefines Destroy so that, for hardware device, Destroy also 1. unregisters the device model if the corresponding hardware is currently serviced, 2. frees all hardware resources maintained.

Publicfunction AddResource(Item: TkdResource): Longint;

AddResource method attaches the new resource to the resources list of the hardware device. The method returns -1 on fail, otherwise a positive number is returned.

Publicfunction CallUserCodeFromKernel(pCode: Pointer): LongWord;

CallUserCodeFromKernel method calls a user application routine, specified by pointer, and performs the whole execution in the kernel space. In the body of the routine use build-in assembler code only. Usage of any variables (either local or global) is not currently supported. Consider usage of EAX processor register to return a value from the kernel space, if need be. See demos as well as ExecNativeKernelRoutine method description.

Publicprocedure Clear;

Clear method detaches and frees all resources maintained in the resources list of the hardware device.

Publicprocedure DeleteResource(AHandle: Longint);

DeleteResource method detaches the resource specified by handle from the resources list of the hardware device and deletes it.

Publicfunction ExecNativeKernelRoutine(var RoutineName: String): LongWord;

ExecNativeKernelRoutine method calls a native kernel routine, specified by name. See demos as well as CallUserCodeFromKernel method description.

Publicfunction GetCountByClass (ClassName: ShortString): Integer;

GetCountByClass method returns the number of resources of the specified class name. This method is principally called by CardBuilder to categorize all resources maintained.

Publicfunction ItemIndexByHandle(AHandle: Longint; ClassName: ShortString): Integer;

ItemIndexByHandle method returns the categorized index of the resource specified by handle and class name. This method is principally called by CardBuilder to categorize all resources maintained.

Protectedfunction LoadModule: Boolean;

LoadModule method is a part of the write method for ModuleLoaded property. It executes a Linux shell script that installs the GDD. Installing the GDD is a compound process that consists of: loading the corresponding kernel module (kdmodule.o/kdmodule.ko), linking it to the kernel and creating requisite device files. The method returns True if the GDD has been successfully loaded and is ready to function, otherwise False is returned.

Publicfunction RegisterCard: Boolean;

RegisterCard method registers the hardware device (all resources) in the system and establishes the instant working session with the GDD. The method internally calls RegisterResource method for each resource maintained in the resources list of the hardware device according to each priority and returns True if all calls are successfully completed. Otherwise False is returned. As soon as the hardware device is registered, your Kylix user-mode device driver team up with the GDD are put into action to serve the particular physical device.

Protectedprocedure RemoveItem(Item: TkdResource);

RemoveItem method is internally called by DeleteResource method to remove the specified resource from the resources list of the hardware device.

Publicfunction Sleep: Boolean;

Sleep method delays execution for a specific duration of time. The method can be used to access slow response hardware and for other goals. The result is True if the method has worked out, otherwise False is returned.

Protectedprocedure UnloadModule;

UnloadModule method is a part of the write method for ModuleLoaded property. It executes a Linux shell script that uninstalls the GDD. Uninstalling the GDD is a compound process that consists of: unloading the corresponding kernel module (kdmodule), unlinking it from the kernel and deleting requisite device files.

Publicprocedure UnregisterCard;

UnregisterCard method unregisters the hardware device (all resources) in the system and closes the current working session with the GDD. The method internally calls UnregisterResource method for each resource maintained in the resources list of the hardware device according to each priority. As soon as the hardware device is unregistered, your Kylix user-mode device driver team up with the GDD are disenabled to serve the particular physical device.

Properties

Overview

Publishedproperty CardItems: TList;
Publicproperty CardRegistered: Boolean;
Publishedproperty CardType: TkdCustomCardCardType;
Publicproperty Count: Integer;
Publishedproperty Description: TStrings;
Publishedproperty DevicePath: ShortString;
Publicproperty FailedResource: TkdResource;
Publishedproperty ModuleLoaded: Boolean;
Publishedproperty ScriptPath: ShortString;
Publishedproperty SleepMicrosecs: LongWord;
Publishedproperty SleepOptions: TkdCustomCardSleepOptions;

Description

Publishedproperty CardItems: TList;

CardItems property hosts the whole set of resources of the hardware device It implements the resources list. The property as well as the TkdCustomCard component itself is equipped with a specific editor called CardBuilder, that helps you to produce the definition of a device model and the diagnostics of corresponding hardware at design time.

Publicproperty CardRegistered: Boolean;

CardRegistered property is an accessor for determining whether the hardware device is currently registered in the system or not. The result is True if the hardware device is registered.

Publishedproperty CardType: TkdCustomCardCardType;

TO BE DOCUMENTED.

Publicproperty Count: Integer;

Count property is an accessor for obtaining the number of resources maintained in the resources list of the hardware device.

Publishedproperty Description: TStrings;

Description property hosts remarks you specify for the hardware device. This property may be useful for keeping any design-time information that is actual for all the life-time of a Kylix project.

Publishedproperty DevicePath: ShortString;

DevicePath property specifies the directory (Linux system /dev directory) where requisite device files are located. The device files are needed to function with the GDD from the side of a user application. Do not affect this property.

Publicproperty FailedResource: TkdResource;

FailedResource property is an accessor for obtaining the resource failed during unsuccessful registration of the hardware device.

Publishedproperty ModuleLoaded: Boolean;

ModuleLoaded property installs and uninstalls the GDD. If the hardware device is currently registered, the GDD can not be uninstalled. The property is initially set to False. If the GDD has not been installed for some reason, the property is still False. Refer to LoadModule and UnloadModule methods for additional information. This property is actual for root only.

Publishedproperty ScriptPath: ShortString;

ScriptPath property specifies the directory where the GDD module (kdmodule.o/kdmodule.ko file) is located.

Publishedproperty SleepMicrosecs: LongWord;

SleepMicrosecs property specifies sleep time in microseconds for Sleep method.

Publishedproperty SleepOptions: TkdCustomCardSleepOptions;

SleepOptions property specifies necessary rule for Sleep method to function. If soNON_BUSY_SLEEP value is specified, Sleep method delays execution with no consuming CPU resources. This value is not relevant for under 17000 microseconds specified at SleepMicrosecs property. Non-busy sleep is less accurate than busy sleep and is not specified by default.