Class TkdDirectMemoryRange
Unit
kdranges
Declaration
type TkdDirectMemoryRange = class(TkdRange
)
Description
Resource class TkdDirectMemoryRange is the ancestor for all components modelling memory ranges which are directly accessible from the user space. Beside other behaviour the class introduces UserDirectAddr
property to provide user programs with direct access to device memory. This class is actual to accelerate access to hardware devices which lend themselves to the Linux mmap abstraction. Most PCI periferals, for example, map their control registers to a memory address, and demanding applications might prefer to have direct access to the registers instead of having to use indirect transfers provided by TkdMemoryRange
class. Depending on the nature of memory required to be accessed there have been established two descendant classes: TkdDirectRPIOMRange
and TkdDirectRRAMRange
whose implementations vary mainly on the GDD level.Hierarchy
TkdRange
> TkdResource
Methods
Overview
Description
TkdDirectMemoryRange redefines Create so that, for directly accessible memory ranges, Create arranges for the memory to be 1. at least readable; this part of the whole access mode can not be withdrawn and 2. mapped privately by a corresponding user process.
GetFileAccMode is overridden to add the writable access mode to the GDD's main device file (/dev/kdmodule0) in case if mpPROT_WRITE value in MemProt
property is specified. Note, in order to produce a successful mapping to the user space with the coincident presence of mtMAP_SHARED value in MapType
property, this method must be obligately overridden to specify the mentioned-above writable access mode.
GetRegisterPriority method is overridden to result independent_registration_priority
constant so that to decree any resource of this class must be registered first of all.
Properties
Overview
Description
MapLength property is an accessor for determining the whole amount of physical memory mapped for the purpose of organizing the direct memory range. This property is pure informative.
MapType property specifies whether the mapped data of the direct memory range belongs to the only process that currently uses this range or may be shared by read between other processes. If mtMAP_SHARED value is specified, the direct memory range is shared between other processes mapping it (or part of it); writing to this memory is equal to physical memory write operation. If mtMAP_PRIVATE value is specified, the direct memory range is *not* shared between other processes mapping it (or part of it); writing to this memory is with copy-on-write principal and do not affect physical memory.
MemProt property specifies the desirable access mode to the direct memory range. The direct memory range can be totally accessible, alternetively, the access mode can be restricted to either read or write.
StartPageAddr property is an accessor for obtaining the physical address of the first page (page where the low bound of the direct memory range is located). This property is pure informative.
UserDirectAddr property is an accessor for obtaining the pointer required for direct access to the direct memory range from the user space.