CN120086163A - PCI serial port device universal driver system and configuration method based on Loongson platform - Google Patents
PCI serial port device universal driver system and configuration method based on Loongson platform Download PDFInfo
- Publication number
- CN120086163A CN120086163A CN202510040554.2A CN202510040554A CN120086163A CN 120086163 A CN120086163 A CN 120086163A CN 202510040554 A CN202510040554 A CN 202510040554A CN 120086163 A CN120086163 A CN 120086163A
- Authority
- CN
- China
- Prior art keywords
- pci
- equipment
- loongson
- bridge piece
- interrupt
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/382—Information transfer, e.g. on bus using universal interface adapter
- G06F13/387—Information transfer, e.g. on bus using universal interface adapter for adaptation of different data processing systems to different peripheral devices, e.g. protocol converters for incompatible systems, open system
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4004—Coupling between buses
- G06F13/4022—Coupling between buses using switching circuits, e.g. switching matrix, connection or expansion network
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44594—Unloading
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0024—Peripheral component interconnect [PCI]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Computer Hardware Design (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention relates to a universal driving system and a configuration method for PCI serial equipment based on a Loongson platform, wherein the universal driving system comprises a Loongson processor 3A3000, a Loongson bridge piece 7A1000 and a PCI-to-PCI bridge piece, wherein the Loongson processor 3A3000 and the Loongson bridge piece 7A1000 are mutually connected, a PCIE interface of the Loongson bridge piece 7A1000 is connected with an input end of the PCI-to-PCI bridge piece, and an output end of the PCI-to-PCI bridge piece is respectively connected with PCI equipment. The invention designs a universal method for driving PCI serial port equipment by fully combining the hardware resource characteristics of the Loongson processor and the matched bridge under the kylin operating system so as to meet different use scenes and realize code multiplexing, thereby reducing the cost of repeated development.
Description
Technical Field
The invention belongs to the field of computer operating systems, in particular to a universal driving system and a configuration method for PCI serial equipment based on a Loongson platform.
Background
The kylin operating system is used as a desktop operating system of the main stream of military, the application is becoming more and more widespread. For compatibility with some devices, serial devices are more required in military control devices, and currently under a kylin operating system, a general driving framework is lacking, so that repeated development cost is high. Therefore, a common serial port driving frame under a kylin operating system is designed to meet the requirements of different scenes of military control equipment.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides a universal driving system and a configuration method for PCI serial equipment based on a Loongson platform, fully combines the hardware resource characteristics of a Loongson processor and a matched bridge piece, meets different use scenes, realizes code multiplexing, and reduces the development and development cost.
The invention solves the technical problems by adopting the following technical scheme:
The universal PCI serial port equipment driving system based on the Loongson platform comprises a Loongson processor 3A3000, a Loongson bridge piece 7A1000 and a PCI-to-PCI bridge piece, wherein the Loongson processor 3A3000 and the Loongson bridge piece 7A1000 are connected with each other, the PCIE interface of the Loongson bridge piece 7A1000 is connected with the input end of the PCI-to-PCI bridge piece, the output ends of the PCI-to-PCI bridge piece are respectively connected with PCI equipment, and all PCI equipment are hung under the switching bridge piece and share the same interrupt.
The configuration method of the universal drive system of the PCI serial port equipment based on the Loongson platform is characterized by comprising the following steps:
Step 1, configuring PC equipment space;
Step 2, initializing PCI equipment by a kernel, and generating a pci_dev structure diagram;
step 3, loading a driver to call the pcb_dev member according to the generated pcb_dev structure diagram;
step 4, providing corresponding information for PCI device drive through corresponding pci_dev of probe () channel;
Step 5, realizing the driving of PCI equipment as character equipment;
And 6, binding the interrupt to the appointed CPU.
The specific implementation method of the step 3 is that the PCI driver is defined by using the PCi_driver, wherein the PCi_driver comprises functions of detection/removal, suspension/restoration and the like of PCI equipment, and four important structural body members of equipment names, equipment lists, equipment searching functions and equipment removing functions are involved.
The specific implementation method of the step 4 is that a member function probe () detects the PCI device according to a device list defined by a structpci _dev_id structure body, and stores configuration information into a parameter pci_dev, and initialization of the PCI device and registration of identity driving of the PCI device are completed in the probe () function.
The specific implementation method of the step 6 is as follows:
Step 6.1, interrupt service programming, namely, interrupt processing driven by PCI serial equipment is mainly responsible for recognizing interrupt, responding to interrupt and waking up sleep process operation, and comprises recognizing interrupt resources, responding to interrupt requests, waking up sleep process corresponding to the interrupt;
step 6.2, designing an API interface with a user layer, wherein PCI serial port equipment adopts a character equipment model, a structural body cdev in Linux represents one character equipment, and the structural body is defined as follows:
Wherein the member functions in the file_operations structure are the subject content of the character device driver design;
The file_operations structure commonly uses several member functions, namely, read () is used for reading data from a device and calling copy_to_user to copy the count kernel data into user space buf, read () system call in an application program is called back the function, function write () is used for sending data to the device and calling copy_from_user () is used for copying the count kernel data from the user space buf and then sending the copy () system call in the device application program to call back the function, ioctl () is used for providing realization of device related control commands, open () device is used for opening functions, release () device release functions, define the functions in a drive and initialize the file_operations structure.
The invention has the advantages and positive effects that:
The invention comprises a Loongson processor 3A3000, a Loongson bridge chip 7A1000 and a PCIE-to-PCI bridge chip, wherein the Loongson processor 3A3000 and the Loongson bridge chip 7A1000 are connected with each other, a PCIE interface of the Loongson bridge chip 7A1000 is connected with an input end of the PCIE-to-PCI bridge chip, and an output end of the PCIE-to-PCI bridge chip is respectively connected with PCI equipment. The invention fully combines the hardware resource characteristics of the Loongson processor and the matched bridge piece to meet different use scenes, realizes code multiplexing and reduces development cost.
Drawings
FIG. 1 is a system block diagram of the present invention;
Fig. 2 is a flow chart of the method of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
The universal PCI serial port equipment driving system based on the Loongson platform comprises a Loongson processor 3A3000, a Loongson bridge piece 7A1000 and a PCI-to-PCI bridge piece, as shown in FIG. 1, wherein the Loongson processor 3A3000 and the Loongson bridge piece 7A1000 are mutually connected, the PCIE interface of the Loongson bridge piece 7A1000 is connected with the input end of the PCI-to-PCI bridge piece, and the output ends of the PCI-to-PCI bridge piece are respectively connected with PCI equipment.
Based on the basic principle of the drive of the Linux equipment, the invention combines the characteristics of PCI bus equipment to construct 1 PCI serial port equipment drive frame, expounds the development process of the drive of the Linux equipment through the development of the drive of the actually used PCI serial port equipment, and verifies the correct drive transmitting and receiving data by using a programming program.
The object for which the driver is directed is a peripheral rather than a CPU. Linux has 3 basic major device types of character devices, block devices and network devices. The character device and the block device are mapped to files and directories of the file system, except for the network device. The operation on the device file is, from the application point of view, an operation on the corresponding hardware device. The call of the functions of the system call interfaces open (), write (), read (), etc. indirectly calls the member functions open (), write (), read (), etc. of the structure in the drive. And the file_operations member functions of the character device are directly provided by the device driver.
A configuration method of a universal drive system of PCI serial port equipment based on a Loongson platform is characterized in that PCI is only a bus, and the PCI equipment can be character equipment, network equipment or block equipment. According to the character device driving method and device, the character device driving module is selected according to the device characteristics and the use scene. The PCI serial device comprises a PCI device and a serial device dual identity, so that a driving framework comprises a PCI device driving part and a device driving part, wherein a main body of the PCI device driving part is still used as a character device driving part in driving, and the PCI serial device is characterized by comprising the following steps of:
and step 1, configuring PC equipment space.
And step 2, initializing PCI equipment by the kernel, and generating a pci_dev structure diagram.
And step 3, loading a driver to call the pcb_dev member according to the generated pcb_dev structure diagram.
When a PCI device is just powered up, only the configuration space of the device can be accessed, which space holds all the information required for the PCI device to operate, such as manufacturer numbers, device numbers, resource requirements, interrupt information, etc. By reading and programming this spatial information, configuration of the PCI device may be accomplished.
In the Linux kernel starting process, the kernel calls the pci_init () to finish initializing the PCI device. After the PCI device is initialized, a kernel data structure for managing the PCI subsystem is generated in the kernel. There are mainly 2 of these data structures, namely, the pci_bus structure and the pci_dev structure. Where the fabric pci_bus represents a PCI bus and the fabric pci_dev represents a PCI device.
The PCI driver is defined by using the pci_driver, the structure diagram comprises functions of detecting/removing, suspending/recovering and the like of PCI equipment, the structure diagram relates to four important structure members of equipment names, equipment lists, equipment searching functions and equipment removing functions, and the four members are mainly realized in a driving framework.
And 4, providing corresponding information for PCI device drivers through the corresponding pci_dev of the probe () channel.
A) PCI serial device data structure realizes:
In PCI device drivers, it is necessary to define 3 important static global variables device_table [ ], uartCard _ driver, uartCard _fops. Wherein device_table [ ] represents the PCI device supported by the current drive, uartCard _driver represents the current PCI driver, and UartCard _fops represents the set of device file operation entry point functions that the drive provides to the application;
b) Drive load and unload functions:
After defining the three data structures in 1), designing a drive loading interface and an unloading interface of the PCI serial device;
c) Detection and removal interface of serial device:
after successfully scanning the PCI device, the PCI subsystem needs to call a detection interface function implemented by the device driver to find a driver that matches the PCI device. The probe function interface firstly allocates a storage space for the equipment instance, and enables the PCI equipment if the application is successful, and the probe interface in the invention is designed as follows:
1) Allocating a storage space for the equipment instance, if the allocation is successful, switching to 2), otherwise, returning;
2) Enabling PCI equipment, if the PCI equipment is enabled successfully, turning to step 3), otherwise, returning;
3) Initializing private variables related to the device instance;
4) Acquiring I/O, MEM resources;
5) And applying for the I/I, MEM space, if the application is successful, initializing successfully, and otherwise, returning.
The complete use of the detection interface is that the interface is removed, and the design is as follows:
1) Releasing the virtual address space;
2) Releasing the I/O, MEM resources;
PCI devices are disabled.
And 5, driving the PCI equipment serving as character equipment.
PCI is essentially just 1 bus, and specific PCI devices may be character devices, network devices, USB host controllers, etc. Therefore, 1 device driver specifically connected with the system through the PCI bus at least comprises 2 parts of contents, namely PCI device driver and device driver. PCI drive is only intended to assist in the driving of the device itself, and is not intended to be a mere means. The PCI device itself contains more than two identities. In the case of a character device driver connected to a system via a PCI bus, the main body is still the driver of the character device itself except for the PCI driver.
A) Interrupt service programming
The PCI serial device driven interrupt processing is mainly responsible for recognizing the interrupt, responding to the interrupt, waking up the sleep process and other operations, and is designed as follows, recognizing the interrupt resource, responding to the interrupt request, waking up the sleep process corresponding to the interrupt.
B) Interface design with user layer API
In the invention, the PCI serial port device adopts a character device model, a structural body cdev in Linux is used for representing a character device, and the structural body is defined as follows:
Wherein the membership functions in the file_operations structure are the subject content of the character device driver design.
The file_operations structure commonly uses several member functions, namely, read () is used for reading data from a device and calling copy_to_user to copy the count kernel data into a user space buf, a read () system call in an application program can call the function, function write () is used for sending data call copy_from_user () to the device and copying the count kernel data from the user space buf to the kernel and then sending the data call to a write () system call in the device application program can call the function, ioctl () provides realization of a device-related control command, an open () device opens the function, and a release () device releases the function. These functions are defined in the driver and the file_operations constructs are initialized.
Opening of the device
The opening of the device is used to call the UartCard _open () function in the entry driver when the application calls the open () function.
The function is mainly responsible for increasing the use count of the device and applying for interrupts according to the interrupt number, and registering the interrupt handling function.
Closure of the device
In contrast to the opening of the device, the closing of the device mainly completes the work of releasing the interrupt and reducing the usage count of the module.
Read operation of a device
The device reading operation is to copy serial data from kernel space to user space for use in user process, and the method is as follows:
1) Waiting for reading data;
2) Copying data in the device to kernel space;
3) Data is copied from kernel space to user space.
Write operation of a device
The writing operation of the device is to copy the data from the user process to the kernel process, and then write the data in the kernel space into the I/O memory of the PCI device, which is specifically realized as follows:
1) Copying data from the user space to the kernel space;
2) And copying the data in the kernel space into the memory of the device.
After these tasks are completed, initialization and registration of the device, including assignment of device numbers and acquisition of interrupt applications, is completed in the probe () function.
And 6, binding the interrupt to the appointed CPU.
The frequent generation of hardware interrupt is a very CPU consuming matter, because all PCI interrupts of the Loongson platform share the same PCIE interrupt number 100, the load of CPU0 is particularly heavy, and the load of CPUs 2-3 is low, so that the system performance is reduced, and in order to solve the problem, the SMP IRQ AFFINITY technology is adopted to bind the interrupt number of PCI serial device to CPU2, so that the utilization rate of system resources is effectively improved. The specific operation is as follows:
1) Stopping the IRQ automatically regulated service process;
2) The IRQ is manually bound to the CPU 2.
It should be emphasized that the examples described herein are illustrative rather than limiting, and therefore the invention includes, but is not limited to, the examples described in the detailed description, as other embodiments derived from the technical solutions of the invention by a person skilled in the art are equally within the scope of the invention.
Claims (5)
1. The universal PCI serial port equipment driving system based on the Loongson platform is characterized by comprising a Loongson processor 3A3000, a Loongson bridge piece 7A1000 and a PCI-to-PCI bridge piece, wherein the Loongson processor 3A3000 and the Loongson bridge piece 7A1000 are connected with each other, a PCIE interface of the Loongson bridge piece 7A1000 is connected with an input end of the PCI-to-PCI bridge piece, an output end of the PCI-to-PCI bridge piece is respectively connected with PCI equipment, and all PCI equipment is hung under the transfer bridge piece and shares the same interrupt.
2. The configuration method of the universal PCI serial port equipment driving system based on the Loongson platform as claimed in claim 1 is characterized by comprising the following steps:
Step 1, configuring PC equipment space;
Step 2, initializing PCI equipment by a kernel, and generating a pci_dev structure diagram;
step 3, loading a driver to call the pcb_dev member according to the generated pcb_dev structure diagram;
Step 4, detecting the corresponding pci_dev through probe () and providing the corresponding information to PCI device drive;
Step 5, realizing the driving of PCI equipment as character equipment;
And 6, binding the interrupt to the appointed CPU.
3. The configuration method of the universal PCI serial port equipment driving system based on the Loongson platform according to claim 2 is characterized in that the specific implementation method of the step 3 is that a PCI driver is defined by using a pci_driver, wherein the pci_driver comprises functions such as detection/removal, suspension/recovery and the like of PCI equipment, and four important structural members including equipment names, equipment lists, equipment searching functions and equipment removing functions are involved.
4. The configuration method of the universal PCI serial port device driving system based on the Loongson platform as set forth in claim 2, wherein the specific implementation method of the step 4 is that a member function probe () detects the PCI device according to a device list defined by a structpci _dev_id structure body and stores configuration information into a parameter pci_dev, and initialization of the PCI device and registration of identity driving of the PCI device are completed in the probe () function.
5. The configuration method of the universal driving system of the PCI serial port equipment based on the Loongson platform according to claim 2 is characterized in that the specific implementation method of the step 6 is as follows:
Step 6.1, interrupt service programming, namely, interrupt processing driven by PCI serial equipment is mainly responsible for recognizing interrupt, responding to interrupt and waking up sleep process operation, and comprises recognizing interrupt resources, responding to interrupt requests, waking up sleep process corresponding to the interrupt;
step 6.2, designing an API interface with a user layer, wherein PCI serial port equipment adopts a character equipment model, a structural body cdev in Linux represents one character equipment, and the structural body is defined as follows:
Wherein the member functions in the file_operations structure are the subject content of the character device driver design;
The file_operations structure commonly uses several member functions, namely, read () is used for reading data from a device and calling copy_to_user to copy the count kernel data into user space buf, read () system call in an application program is called back the function, function write () is used for sending data to the device and calling copy_from_user () is used for copying the count kernel data from the user space buf and then sending the copy () system call in the device application program to call back the function, ioctl () is used for providing realization of device related control commands, open () device is used for opening functions, release () device release functions, define the functions in a drive and initialize the file_operations structure.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202510040554.2A CN120086163A (en) | 2025-01-10 | 2025-01-10 | PCI serial port device universal driver system and configuration method based on Loongson platform |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202510040554.2A CN120086163A (en) | 2025-01-10 | 2025-01-10 | PCI serial port device universal driver system and configuration method based on Loongson platform |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN120086163A true CN120086163A (en) | 2025-06-03 |
Family
ID=95846120
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202510040554.2A Pending CN120086163A (en) | 2025-01-10 | 2025-01-10 | PCI serial port device universal driver system and configuration method based on Loongson platform |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN120086163A (en) |
-
2025
- 2025-01-10 CN CN202510040554.2A patent/CN120086163A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US9389904B2 (en) | Apparatus, system and method for heterogeneous data sharing | |
| CN100555257C (en) | The memory controller of the dma operation between the processing page replicative phase and method | |
| US6275893B1 (en) | Method and apparatus for providing seamless hooking and intercepting of selected kernel and HAL exported entry points in an operating system | |
| US7877526B2 (en) | Data processing system having a channel adapter shared by multiple operating systems | |
| EP0672987A2 (en) | Portable PCMCIA interface for a host computer | |
| US7454547B1 (en) | Data exchange between a runtime environment and a computer firmware in a multi-processor computing system | |
| US6718401B2 (en) | System and method for device support | |
| JPS62281039A (en) | Dynamic provision of virtual memory source to control program | |
| JP2003531434A (en) | Computer method and system for executing a Java computer program | |
| CN101065740A (en) | USB Portable (On-The-Go) Controller | |
| CN111666036B (en) | Method, device and system for migrating data | |
| JP2002530778A (en) | Direct memory access engine to support multiple virtual direct memory access channels | |
| US6216216B1 (en) | Method and apparatus for providing processor partitioning on a multiprocessor machine | |
| KR20010040936A (en) | Accessing a messaging unit from a secondary bus | |
| US9047264B2 (en) | Low pin count controller | |
| CN114116024B (en) | Peripheral drive processing method, device and system for embedded operating system | |
| US8732441B2 (en) | Multiprocessing system | |
| JP4316882B2 (en) | System and method for logical replacement of processor control in an emulated computing environment | |
| CN120086163A (en) | PCI serial port device universal driver system and configuration method based on Loongson platform | |
| KR102000721B1 (en) | Computing device, data transfer method between coprocessor and non-volatile memory, and program including the same | |
| WO1998029807A1 (en) | Real time services in backwardly compatible operating systems | |
| CN101661444A (en) | Method and system for dynamically managing pluggable device | |
| CN101091168B (en) | Method and apparatus for implementing multi-stage software | |
| CN120353742A (en) | Data processing method and related equipment | |
| CN118467414A (en) | A drive control method and device for PCIE device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |