4720 views|0 replies

19

Posts

0

Resources
The OP
 

PCI device RTX driver development method [Copy link]

1. When operating peripherals under RTX, you need to move the device from Windows to RTX. For specific migration methods, please refer to the section Converting a Windows Device to an RTX Device in the middle of the RTX Help document or refer to the attachment <> 2. Characteristics of PCI Drivers Before designing a driver, you must first carefully analyze the hardware device to be controlled, and you need to understand the characteristics of the hardware device in detail. The characteristics of the hardware device will have a significant impact on the driver design. The most important hardware characteristics that need to be understood include: (1) The bus structure of the device. The bus structure used by the device is very important, because different bus types (such as ISA and PCI) are different in many hardware working mechanisms, so the driver design is also different. (2) Registers. You need to understand the setting of control registers, data registers, and status registers, as well as the working characteristics of these registers. (3) Device errors and status. You need to understand how to judge the status and error signals of the device. These signals should be returned to the user through the driver. (4) Interrupt behavior. You need to understand the conditions for the device to generate interrupts and the number of interrupts used. (5) Data transfer mechanism The most common data transfer mechanism is through the I/O port, that is, through the CPU to read and write data. Another important transmission mechanism of the PC is DMA, but the PCI specification does not include the description of slave DMA. (6) Device memory Many devices have their own memory. Most PCI devices are mapped to the physical memory of the PC system. Some devices also need to set the device interface register through the driver. 3. RTX driver overall architecture Use the 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, and you can generate the RTX PCI device driver framework. The program framework is divided into two functions, Driver file and DriverFunc file: Driver file mainly includes main function, interrupt service routine and interrupt service thread; DriverFunc file is mainly the basic operation function of PCI device, including PCI device search, PCI device initialization, enable or disable interrupt, handle PCI device shared interrupt, and PCI driver resource cleanup functions. 4. The complete RTX PCI driver is based on the RTX PCI device driver framework. Users need to add the corresponding code. The following is an analysis based on the RTX driver of the reflective memory card. The basic characteristics of the reflective memory card: (1) PCI, PCIe, PMC, VME appearance, nodes form a ring connection or a star connection through a fiber optic hub (2) Deterministic data transmission delay between nodes, the delay is less than 750us The RTX driver of the PCI reflective memory card is also divided into two files: Driver file and DriverFunc file. The driver file mainly includes the main function, interrupt service program and interrupt service thread. The following is a detailed analysis: (1) Main function: The Main function is not part of the RTX PCI driver. To be precise, it is the process of how to use the RTX PCI driver. What users need to do: a. In the main function generated by the RTX PCI device driver framework, after the device initialization (DeviceInit()) is completed and before the PCI interrupt is enabled, add the device open (open()) function. The function of this function is mainly to create semaphores and initialize the board. b. After enabling the PCI interrupt, the user can call the read and write functions in the PCI driver to write a simple read and write test program. (2) Interrupt service program: After receiving the interrupt, this function will be handed over to the interrupt service thread for processing. Users generally do not need to modify it. (3) Interrupt service thread: The interrupt service thread mainly completes the reading and recording of the interrupt information of the PCI board, releasing 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 analysis of the specific meaning of the interrupt. The DriverFunc file mainly contains basic operation functions for PCI devices, including PCI device search, PCI device initialization, enabling or disabling interrupts, handling PCI device shared interrupts, and PCI driver resource cleanup, data reading and writing, sending and receiving message interrupts, etc. The following is a detailed analysis: (1) DeviceSearch function This function searches for PCI devices based on the PCI device's Vendor ID and Device ID, and returns PCI configuration information and slot Number. Users 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 convert the PCI device address into a physical address that the CPU can directly access, and RtMapMemory() maps the physical address to a virtual address. After mapping to the virtual address space, ring3 users can read and write PCI memory space or I/O space. What users need to pay attention to is the address range of the mapping from physical address to virtual address, which is generally set to 4KBytes. The default maximum address range that can be mapped by the RtMapMemory() function is 64M Bytes. If a larger range is required, please refer to the memory management section. (3) Enable/Disable Interrupts On Chip function enables or disables interrupts on PCI devices. Users can modify it according to the PCI device. (4) IsMyInterrupt function PCI device interrupt numbers can be shared under RTX. If there is a PCI device shared under RTX, it is necessary to distinguish whether it is an interrupt of this device in the middle of this function. (5) DeviceCleanup function This function releases the interrupt handle and releases the mapping between physical address and virtual address. Users basically do not need to modify this function. (6) RFM2gOpen function Reflective memory function function. The function of this function is mainly to create semaphores and initialize the board for hardware function modules such as DMA channels, sending and receiving Events (a message-type interrupt of reflective memory). In order to prevent access conflicts to hardware resources, you need to obtain semaphores before using these hardware resources and release these semaphores after use. (7) RFM2gEnableEvent function reflects memory function. Enables the board to receive message interrupts. (8) RFM2gSendEvent function reflects memory function. Sends message interrupts to other nodes. (9) RFM2gWaitForEvent function reflects memory
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list