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

Class TkdInterrupt

Unit

kdinterrupt

Declaration

type TkdInterrupt = class(TkdResource)

Description

Final resource class TkdInterrupt models hardware interrupts. This basic interrupt managing class includes members for specifying a particular interrupt and all information for that interrupt acknowledgement, binding to that interrupt the common interrupt service routine (ISR) located inside the GDD and running in the privileged mode and a user-defined interrupt event handler established through the inter-spatial interrupt-bearing pipe between kernel and user spaces. There are proper reversing methods for unbinding the ISR from that interrupt and destroying the pipe instance. The class also includes several statistical members such as properties for obtaining system times at whose two recent interrupts are generated and properties for calculating the whole number of interrupts generated and directed to a user-defined interrupt event handler, if established. Each instance of this class contains singular instance of TkdInterruptPipe class, the former is being completely responsible for creation, activation, synchronization and destruction of the pipe encapsulated. Each instance of this class can also hold the whole set of interrupt acknowledgement actions, each of which is modelled by TkdInterruptAcknowledgement class. Although TkdInterrupt class has dozens of methods and properties, including those intended merely for design-time work, relevant members are documented only.

Hierarchy

TkdResource

Methods

Overview

Publicconstructor Create(AOwner: TComponent); override;
Publicfunction AddInterruptAcknowledgement (Item: TkdInterruptAcknowledgement): LongInt;
Protectedfunction CheckResourceDataReadiness: Boolean; override;
Publicprocedure DeleteInterruptAcknowledgement(AHandle: Longint);
Publicfunction DisableInterrupt: Boolean;
Publicfunction EnableInterrupt: Boolean;
Protectedfunction GetFileAccMode: Integer; override;
Protectedfunction GetRegisterPriority: Byte; override;
Publicfunction ItemIndexByHandle(AHandle: Longint): Integer;
Protectedprocedure OnGetRegisteredParamsPointerFail; override;
Protectedprocedure OnRegisterResourceFail; override;
Protectedfunction PostRegisterResource(RegisteredParams: Pointer; IoctlResult: Integer): Boolean; override;
Protectedfunction PreRegisterResource: Boolean; override;
Protectedprocedure PreUnregisterResource; override;
Protectedprocedure StartInterruptPipe;
Protectedprocedure StopInterruptPipe;

Description

Publicconstructor Create(AOwner: TComponent); override;

TkdInterrupt redefines Create so that, for hardware interrupts, Create sets all public and published properties to their default states. Also, specialized object lists are constructed to lend necessary protection and behaviour to some members such as InterruptHandler and InterruptAcknowledgement. These object lists classes are not documented.

Publicfunction AddInterruptAcknowledgement (Item: TkdInterruptAcknowledgement): LongInt;

AddInterruptAcknowledgement method attaches the specified interrupt acknowledgement action to the whole set of interrupt acknowledgement actions hosted at InterruptAcknowledgement property.

Protectedfunction CheckResourceDataReadiness: Boolean; override;

CheckResourceDataReadiness method is overridden to verify whether certain dependencies between properities involved in interrupt management are correctly resolved. Similar verifications are made inside the GDD, but doing those on the client side is a good tone.

Publicprocedure DeleteInterruptAcknowledgement(AHandle: Longint);

DeleteInterruptAcknowledgement method detaches the interrupt acknowledgement action specified by handle from the whole set of interrupt acknowledgement actions hosted at InterruptAcknowledgement property.

Publicfunction DisableInterrupt: Boolean;

DisableInterrupt method unbinds the interrupt specified by InterruptNumber property from the hardware interrupt handler of the GDD and disenables the user-defined interrupt event handler currently established via OnHwInterrupt property. The method preliminarily calls StopInterruptPipe method to deactivate the interrupt-bearing pipe and destroy it (read the description of TkdInterruptPipe class).

Publicfunction EnableInterrupt: Boolean;

EnableInterrupt method binds the interrupt specified by InterruptNumber property to the hardware interrupt handler of the GDD and enables the user-defined interrupt event handler established via OnHwInterrupt property. The method preliminarily calls StartInterruptPipe method to create and put in action the inter-spatial interrupt-bearing pipe (read the description of TkdInterruptPipe class). The hardware interrupt handler is configured in compliance with the properties specially provided, such as HandlerType, InterruptShared and InterruptAcknowledgement The method returns True on success, otherwise False is returned.

Protectedfunction GetFileAccMode: Integer; override;

GetFileAccMode is overridden to add the writable access mode to the GDD's main device file (/dev/kdmodule0). This is to specify that the shared memory page (in case of its existance) accessible via SharedMemory property can be guaranteedly mapped to the user space with common map_shared approach.

Protectedfunction GetRegisterPriority: Byte; override;

GetRegisterPriority method is overridden to result dependent3l_registration_priority constant, the lowest of all possible priorities, so that to allow all of other resources to be registered ahead. This is because most of resources can be referenced in the hardware interrupt handler script hosted at InterruptHandler property.

Publicfunction ItemIndexByHandle(AHandle: Longint): Integer;

ItemIndexByHandle method returns the index of an interrupt acknowledgement action specified by handle in the whole set of interrupt acknowledgement actions hosted at InterruptAcknowledgement property.

Protectedprocedure OnGetRegisteredParamsPointerFail; override;

OnGetRegisteredParamsPointerFail method is overridden to stop the inter-spatial interrupt-bearing pipe by calling StopInterruptPipe method.

Protectedprocedure OnRegisterResourceFail; override;

OnRegisterResourceFail method is overridden to call StopInterruptPipe method as the cleanup code.

Protectedfunction PostRegisterResource(RegisteredParams: Pointer; IoctlResult: Integer): Boolean; override;

PostRegisterResource method is overridden to call StopInterruptPipe method as the cleanup code on the unsuccessful registration of the interrupt.

Protectedfunction PreRegisterResource: Boolean; override;

PreRegisterResource method is overridden to call StartInterruptPipe method as the preparatory action before the registration of the interrupt if AutoRequest property is set to arInstall. This is because, in this case, the inter-spatial interrupt-bearing pipe must be established coincidently with the registration of the interrupt.

Protectedprocedure PreUnregisterResource; override;

PreUnregisterResource method is overridden to call DisableInterrupt method as the preparatory action before the unregistration of the interrupt. But this is not completely all the method does. There are times at those the interrupt is about to be unregistered but its inter-spatial interrupt-bearing pipe is in the middle of functioning or even fallen asleep. In this case it is necessary to wait for a while till the inter-spatial interrupt-bearing pipe is destroyed.

Protectedprocedure StartInterruptPipe;

StartInterruptPipe method creates the inter-spatial interrupt-bearing pipe and starts it. Read the description of TkdInterruptPipe class for more info.

Protectedprocedure StopInterruptPipe;

StopInterruptPipe method stops the inter-spatial interrupt-bearing pipe when it is unnecessary anymore by running out of its Execute method and destroys the thread object. Read the description of TkdInterruptPipe class for more info.

Properties

Overview

Publishedproperty AutoRequest: TkdInterruptAutoRequest;
Publicproperty Enabled: Boolean;
Publishedproperty HandlerType: TkdInterruptHandlerType;
Publicproperty IACount: Integer;
Publishedproperty InterruptAcknowledgement: TInterruptAcknowledgementList;
Publishedproperty InterruptHandler: TInterruptHandlerStringList;
Publicproperty InterruptLastTime: Extended;
Publishedproperty InterruptNumber: Integer;
Publicproperty InterruptPreviousTime: Extended;
Publishedproperty InterruptRTSynchronized: Boolean;
Publicproperty InterruptsDirected: Cardinal;
Publicproperty InterruptsGenerated: Cardinal;
Publishedproperty InterruptShared: Boolean;
Publishedproperty InterruptType: TkdInterruptInterruptType;
Publishedproperty OnHwInterrupt: TkdInterruptHandler;
Publishedproperty SharedMemory: LongWord;
Publishedproperty UseInterruptAcknowledgement: Boolean;
Publishedproperty UseInterruptHandler: Boolean;

Description

Publishedproperty AutoRequest: TkdInterruptAutoRequest;

AutoRequest property specifies if the hardware interrupt handler of the GDD must be automatically installed on the registration of the interrupt by RegisterResource method regardless of EnableInterrupt method call. If the property is set to arNone the handler will not be installed till EnableInterrupt method is called, but the registration of the interrupt is permitted. If the property is set to arInstall the handler will be automatically installed on the registration of the interrupt, supposing if the handler installation fails then the registration of the interrupt fails as well. And if arCheckOnly is the value, the GDD will check if the interrupt can be enabled afterwards and protects from the registration of the interrupt if it is not the case.

Publicproperty Enabled: Boolean;

Enabled property is an accessor for determining whether the interrupt is currently enabled.

Publishedproperty HandlerType: TkdInterruptHandlerType;

HandlerType property specifies whether the hardware interrupt handler of the GDD must be slow or fast. A fast handler runs with interrupt reporting disabled in the microprocessor, and the interrupt being serviced is disabled in the interrupt controller. A slow handler runs with interrupt reporting enabled in the processor, and the interrupt being serviced is disabled in the interrupt controller. Unless you have a strong reason to run your interrupt handler with other interrupts disabled, you should not use this property set to htFast.

Publicproperty IACount: Integer;

IACount property is an accessor for obtaining the number of interrupt acknowledgement actions currently hosted at InterruptAcknowledgement property. This is a duplicate of what InterruptAcknowledgement.Count property returns.

Publishedproperty InterruptAcknowledgement: TInterruptAcknowledgementList;

InterruptAcknowledgement property hosts the whole set of interrupt acknowledgement actions. Interrupt acknowledgement is an absolutely necessary operation for level-sensitive interrupts (PCI interrupts). Refer to the outside documentation for additional info.

Publishedproperty InterruptHandler: TInterruptHandlerStringList;

InterruptHandler property hosts the whole set of actions which make up the kernel-mode interrupt handler. Refer to the outside documentation for additional info.

Publicproperty InterruptLastTime: Extended;

InterruptLastTime property is an accessor for obtaining the system time at that the most recent interrupt was generated. The property is supposed to be accessed inside the user-defined interrupt event handler established via OnHwInterrupt property, but not obligatory.

Publishedproperty InterruptNumber: Integer;

InterruptNumber property specifies the system interrupt number (IRQ) to bind to. It's interesting to note that the number of interrupts defined on the x86 is currently 224, not 16 as you may expect; this, as explained in include/asm-i386/irq.h,depends on Linux using the architectural limit instead of an implementation - specific limit (like the 16 interrupt sources of the old-fashioned PC interrupt controller).

Publicproperty InterruptPreviousTime: Extended;

InterruptPreviousTime property is an accessor for obtaining the system time at that the preceding interrupt (to the most recent interrupt) was generated. The property is supposed to be accessed inside the user-defined interrupt event handler established via OnHwInterrupt property, but not obligatory.

Publishedproperty InterruptRTSynchronized: Boolean;

InterruptRTSynchronized property determines whether the user-defined interrupt event handler established via OnHwInterrupt property can safely contain any CLX-based code. The default value is True.

Publicproperty InterruptsDirected: Cardinal;

InterruptsDirected property is an accessor for obtaining the number of interrupts which have been directed to the user-defined interrupt event handler since the latest call to EnableInterrupt method. If the handler is being established for all the time, the number of interrupts directed is naturally equal to what InterruptsGenerated property returns. The property is supposed to be accessed inside the user-defined interrupt event handler established via OnHwInterrupt property.

Publicproperty InterruptsGenerated: Cardinal;

InterruptsGenerated property is an accessor for obtaining the number interrupts which have been generated since the latest call to EnableInterrupt method. The property is supposed to be accessed inside the user-defined interrupt event handler established via OnHwInterrupt property.

Publishedproperty InterruptShared: Boolean;

InterruptShared property specifies whether or not the vector associated with the interrupt is shared (or sharable) between multiple devices.

Publishedproperty InterruptType: TkdInterruptInterruptType;

InterruptType property specifies the type of the interrupt.

Publishedproperty OnHwInterrupt: TkdInterruptHandler;

OnHwInterrupt event occurs when a new hardware interrupt is generated. Write an event handler for this property to take specific actions in an and-user application. Access InterruptsGenerated property to determine how many interrupts are generated. Access InterruptLastTime and InterruptPreviousTime properties to determine the system times at those two most recent interrupts were generated.

Publishedproperty SharedMemory: LongWord;

SharedMemory property is an accessor for obtaining the pointer required for direct access from the user space to the memory page shared between the user space and the kernel space. Shared memory page can be efficiently used to exchange certain data between the kernel-mode interrupt handler and an end-user application. Shared memory page size is 4096 bytes. Refer to the outside documentation for additional info.

Publishedproperty UseInterruptAcknowledgement: Boolean;

UseInterruptAcknowledgement property specifies whether InterruptAcknowledgement property is involved in the process of handling the interrupt.

Publishedproperty UseInterruptHandler: Boolean;

UseInterruptHandler property specifies whether InterruptHandler property is involved in the process of handling the interrupt.