PCI device RTX driver development method

1. When operating a peripheral device under RTX, you need to move the device from Windows to RTX.
The specific porting method can refer to the section Converting a Windows Device to an RTX Device in the RTX Help document or refer to the attached <<Serial Device Migration Guide.doc>>

2. Characteristics of PCI Drivers
Before designing the driver, it is necessary to carefully analyze the hardware devices to be controlled, and it is necessary to understand the characteristics of the hardware devices in detail. The characteristics of hardware devices can have a major impact on driver design. The most important hardware features to understand include:
(1) The bus structure of the device
The bus architecture used by the device is critical because different bus types (such as ISA and PCI) are different in many hardware operating mechanisms, so the driver design is also different.
(2) Registers
To understand the settings of the control registers, data registers, and status registers, as well as the operating characteristics of these registers.
(3) Device Errors and Status
To understand how to determine the status of the device and error signals, these signals are returned to the user through the driver.
(4) Interruption
To understand the conditions under which the device generates an interrupt and the number of interrupts used.
(5) Data transmission mechanism
The most common data transfer mechanism is through I/O ports, that is, reading and writing data through the CPU. Another important transport mechanism for PCs is DMA, but the PCI specification does not include instructions for subordinate DMAs.
(6) Device memory
Many devices have their own memory, PCI devices are mostly mapped to the physical memory of the PC system. Some devices also set the device's interface registers through the driver

3. RTX drives the overall architecture
Using RTX Device Driver Development Wizard, Select Support
(1) Interrupt Service Routine (ISR)
(2) Support for Sharing an Interrupt
(3) Basic Port I/O Support
(4) Basic Mapped Memory Support,
The RTX PCI device driver framework can be generated.
The program framework is divided into two functions, the Driver file and the DriverFunc file:
Driver file mainly includes main function, interrupt service routine and interrupt service thread;
The DriverFunc file is primarily a function of the PCI device's basic operations, including functions such as PCI device discovery, PCI device initialization, enabling or disabling of interrupts, handling of PCI device sharing interrupts, and cleanup of PCI driver resources.
4. Complete RTX PCI Driver
Based on the RTX PCI device driver framework, the user needs to add the corresponding code. The following analysis is based on the RTX driver of the reflective memory card.
The basic features of the reflective memory card:
(1) PCI, PCIe, PMC, VME form, form a ring connection between nodes or form a star connection through a fiber Hub
(2) Data deterministic transmission delay between nodes, delay is less than 750us
The RTX driver for the PCI reflective memory card is also divided into two files, the Driver file and the DriverFunc file. Driver file mainly includes main function, interrupt service routine and interrupt service thread. The following is a detailed analysis:
(1) Main function:
The Main function is not part of the RTX PCI driver. It is precisely how it uses the RTX PCI driver process. What the user needs to do:
a. The main function generated in the RTX PCI device driver framework needs to add the device open (open()) function after device initialization (DeviceInit()) and before enabling the PCI interrupt. The function of this function is mainly to create semaphores and Initialize the board.
b. After the PCI interrupt is enabled, the user can invoke a simple read/write test program by calling the read/write function in the PCI driver.
(2) Interrupt service procedures:
This function is passed to the interrupt service thread after it receives the interrupt. The user does not need to change it.
(3) Interrupt service thread:
The interrupt service thread mainly completes the reading and recording of the interrupt information of the PCI board card, releases the related semaphores, etc., and generally does not complete the specific interrupt processing work. The PCI driver generally also provides a function to capture these released semaphores and complete the parsing of the specific meaning of the interrupt.
The DriverFunc file is mainly a basic operation function for PCI devices, including PCI device search, PCI device initialization, enabling or disabling of interrupts, handling of PCI device sharing interrupts, and clearing of PCI driver resources, reading and writing of data, and sending and receiving of message interrupts. Equivalent functions. The following is a detailed analysis:
(1) DeviceSearch function
This function searches for the PCI device based on the Vendor ID and Device ID of the PCI device and returns the PCI configuration information and slot number. The user can modify the Vendor ID and Device ID.
(2) DeviceInit function
PCI device initialization function. This function calls two RTX system functions RtTranslateBusAddress() and RtMapMemory(). RtTranslateBusAddress() is used to translate the PCI device address into a physical address that the CPU can directly access. The RtMapMemory() function maps the physical address. To the virtual address. The ring3 user can read or write the PCI memory space or I/O space after mapping to the virtual address space. Users should pay attention to the physical address to virtual address mapping address range, generally set to 4K Bytes. RtMapMemory () function default maximum address mapping can be 64M Bytes, if you need a larger range, you can refer to the memory management section.
(3) Enable/Disable Interrupts On Chip Function
Enables or disables interrupts on the PCI device. The user makes modifications based on the PCI device.
(4) IsMyInterrupt function
PCI device interrupt numbers can be shared under RTX. If there is a PCI device sharing under RTX, it is necessary to distinguish whether the device is an interrupt in the middle of the function.
(5) DeviceCleanup function
This function releases the interrupt handler and releases the mapping between the physical address and the virtual address. The user basically does not need to modify this function.
(6) RFM2gOpen function
Reflect memory function function. The function of this function is mainly to create semaphores and initialize the board for hardware functions such as DMA channels, sending and receiving events (a message type interrupt of reflective memory). In order to prevent access conflicts on hardware resources, it is necessary to obtain semaphores before using these hardware resources and release these semaphores after use.
(7) RFM2gEnableEvent function
Reflect memory function function. Enables the card to receive message class interrupts.
(8) RFM2gSendEvent function
Reflect memory function function. Send message class interrupts to other nodes.
(9) RFM2gWaitForEvent function
Reflective memory

MCCB TRM Series

Mccb Breaker,Mccb Circuit Breaker,Overload Protection Mccb,Moulded Case Circuit Breaker

ZHEJIANG QIANNA ELECTRIC CO.,LTD , https://www.traner-elec.com

Posted on