CN110083394B - Serial port driving method, device and storage medium - Google Patents
Serial port driving method, device and storage medium Download PDFInfo
- Publication number
- CN110083394B CN110083394B CN201910272326.2A CN201910272326A CN110083394B CN 110083394 B CN110083394 B CN 110083394B CN 201910272326 A CN201910272326 A CN 201910272326A CN 110083394 B CN110083394 B CN 110083394B
- Authority
- CN
- China
- Prior art keywords
- serial port
- interrupt
- function
- target
- interrupt controller
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 230000006870 function Effects 0.000 claims description 101
- 230000002093 peripheral effect Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 10
- 238000004891 communication Methods 0.000 description 7
- 230000000694 effects Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 230000002159 abnormal effect Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000011982 device technology Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000011022 operating instruction Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Microcomputers (AREA)
Abstract
The invention provides a serial port driving method, a device and a storage medium, wherein the method is applied to a target processor, the target processor is any one of at least two processors of electronic equipment, an interrupt controller and at least one serial port are integrated on the target processor, and the method comprises the following steps: determining a target serial port to be subjected to first operation, wherein the first operation is opening operation or closing operation, and the target serial port is any one of at least one serial port; when the serial port driver is used for executing a first operation on the target serial port, calling a first function in the serial port driver so as to not execute the first operation on the serial port interrupt control bit of the interrupt controller. The serial port driving method, the serial port driving device and the storage medium provided by the invention can avoid the problem that the interrupt of the serial ports on other CPUs is abnormally opened or closed due to opening or closing of a certain CPU integrated serial port by an APP.
Description
Technical Field
The present invention relates to electronic device technologies, and in particular, to a serial port driving method, device, and storage medium.
Background
Currently, a Central Processing Unit (CPU) may integrate an interrupt controller and at least one serial port. In this scenario, for a serial port integrated on the CPU, an interrupt controller integrated on the CPU needs to manage an interrupt of the serial port. Taking a computer running with a Linux operating system as an example, when an application program needs to open a serial port integrated on a CPU, the CPU needs to call a serial port driver to open the serial port, and open the serial port interrupt (i.e., open a serial port interrupt control bit in an interrupt controller integrated on the CPU for controlling the serial port interrupt), so that the application program communicates with an external device through the serial port integrated on the CPU (i.e., receives and transmits serial port data through the serial port). Accordingly, when the application program needs to close the serial port integrated on the CPU, the CPU needs to call the serial port driver to execute the shutdown of the serial port, and to close the serial port interrupt (i.e., to close the serial port interrupt control bit for controlling the serial port interrupt in the interrupt controller integrated on the CPU).
For a computer employing multiple CPUs, the same Application (APP) may be run by different CPUs at different times. The CPU executes opening or closing of the serial port through the serial port driver, and cannot distinguish the opened or closed serial port and the serial port interruption as the objects required by the APP to operate when the serial port interruption is opened or closed. Therefore, with a multi-CPU computer, when an application program needs to open or close a serial port integrated on a certain CPU, if the CPU running the application program and the CPU where the serial port that the application program needs to open or close are not the same CPU, the CPU running the application program calls the serial port to open or close and the serial port that the application program needs to open or close is not the serial port that the application program needs to open or close, and further the CPU running the application program calls the serial port to open or close an erroneous serial port interrupt (that is, an erroneous serial port interrupt control bit in an interrupt controller integrated on the CPU is opened or closed).
Disclosure of Invention
The invention provides a serial port driving method, a serial port driving device and a storage medium, which are used for solving the problem that in the prior art, serial port interruption on other CPUs is abnormally opened or closed due to opening or closing of a certain CPU integrated serial port by an APP.
The first aspect of the present invention provides a serial port driving method, applied to a target processor, where the target processor is any one of at least two processors of an electronic device, and an interrupt controller and at least one serial port are integrated on the target processor, and the method includes:
determining a target serial port to be subjected to first operation, wherein the first operation is an opening operation or a closing operation, and the target serial port is any one of the at least one serial port;
and calling a first function in the serial port driver when the serial port driver is used for executing a first operation on the target serial port so as not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
In one possible embodiment, before the calling a first function in the serial driver to perform a first operation on the target serial port by using the serial driver to perform the first operation on the serial port interrupt control bit of the interrupt controller, the method further includes:
and opening a serial port interrupt control bit of the interrupt controller when the interrupt controller is initialized.
In a possible implementation, the first function is an element in an interrupt structure corresponding to the interrupt controller.
In one possible embodiment, before the calling a first function in the serial driver to perform a first operation on the target serial port by using the serial driver to perform the first operation on the serial port interrupt control bit of the interrupt controller, the method further includes:
when the interrupt structure is initialized, the first function is initialized, so that the first function has a function of controlling the target processor not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
In one possible implementation, the electronic device is an electronic device running a Linux operating system.
A second aspect of the present invention provides a serial port driving apparatus, which is applied to a target processor, where the target processor is any one of at least two processors of an electronic device, and an interrupt controller and at least one serial port are integrated on the target processor, and the apparatus includes:
the device comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target serial port to be subjected to first operation, the first operation is opening operation or closing operation, and the target serial port is any one of the at least one serial port;
and the calling module is used for calling a first function in the serial port driver when the serial port driver is used for executing a first operation on the target serial port so as not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
In a possible embodiment, the apparatus further comprises:
the first initialization module is used for calling a first function in the serial port driver when the calling module executes a first operation on the target serial port by using the serial port driver so as to open the serial port interrupt control bit of the interrupt controller when initializing the interrupt controller before the calling module does not execute the first operation on the serial port interrupt control bit of the interrupt controller.
In a possible implementation, the first function is an element in an interrupt structure corresponding to the interrupt controller.
In a possible embodiment, the apparatus further comprises:
the second initialization module is used for calling a first function in the serial port driver when the calling module executes a first operation on the target serial port by using the serial port driver so as to initialize the first function before the first operation is not executed on the serial port interrupt control bit of the interrupt controller when the interrupt structure is initialized, so that the first function has a function of controlling the device not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
In one possible implementation, the electronic device is an electronic device running a Linux operating system.
A third aspect of the present invention provides a serial port driving apparatus, including: at least one processor and memory;
the memory stores computer-executable instructions; the at least one processor executes computer-executable instructions stored by the memory to perform the method of any of the first aspects.
A fourth aspect of the invention provides a computer readable storage medium having stored thereon program instructions which, when executed by a processor, implement the method of any of the first aspects.
The invention provides a serial port driving method, a device and a storage medium, for an electronic device which comprises a plurality of CPUs and integrates an interrupt controller and at least one serial port on the CPUs, a first function which does not execute opening or closing of a serial port interrupt control bit of the interrupt controller is additionally arranged in the serial port driver, so that when a processor of the electronic device calls the serial port driver to open or close a target serial port integrated on the processor, the first function can not execute the first operation on the serial port interrupt control bit of the interrupt controller, namely, the operation of opening or closing the target serial port interrupt is not executed any more, thereby avoiding the problem that the serial port interrupt on other CPUs is abnormally opened or closed due to opening or closing of a certain CPU integrated serial port by an APP.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram of a serial driver provided in the prior art;
fig. 2 is a schematic diagram of abnormal prohibition of serial port interrupt provided in the prior art;
fig. 3 is a schematic flow chart of a serial port driving method according to the present invention;
FIG. 4 is a schematic diagram of a serial driver according to the present invention;
FIG. 5 is a schematic flow chart of another serial port driving method according to the present invention;
fig. 6 is a schematic structural diagram of a serial port driving device provided in the present invention;
fig. 7 is a schematic structural diagram of another serial port driving device provided by the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The serial port is used for connecting a Central Processing Unit (CPU) and an external device (peripheral for short), so that the CPU and the peripheral can communicate through the serial port. The peripheral devices referred to herein may be, for example: display, mouse, keyboard, etc.
An interrupt controller is hardware in a computer that manages device interrupts. In the embodiment of the invention, the CPU can manage the interrupt of the serial port through the interrupt controller. When the interruption of the serial port is opened, the CPU can transmit the serial port data through the serial port, and when the interruption of the serial port is closed, the CPU cannot transmit the serial port data through the serial port. In specific implementation, the CPU may open or close a serial port interrupt control bit in the interrupt controller for controlling the serial port interrupt, so as to open or close the serial port interrupt.
Currently, an interrupt controller and at least one serial port may be integrated on a CPU. In this scenario, for a serial port integrated on the CPU, an interrupt controller integrated on the CPU needs to manage an interrupt of the serial port.
Fig. 1 is a schematic diagram of a serial driver provided in the prior art, and as shown in fig. 1, for example, when an application running in a user space needs to open a serial port integrated on a CPU (for example, when the application needs to communicate with a peripheral device through the serial port integrated on the CPU), the CPU needs to invoke a driver (for short, a serial driver) specially responsible for opening and closing the serial port in an kernel space to open the serial port and open a serial port interrupt (that is, open a serial port interrupt control bit in an interrupt controller integrated on the CPU for controlling the serial port interrupt), so that the application communicates with the peripheral device through the serial port integrated on the CPU (that is, receives and sends serial port data through the serial port). Accordingly, when the application program needs to close the serial port integrated on the CPU, the CPU needs to call a serial port driver to close the serial port, and close the serial port interrupt (i.e., close a serial port interrupt control bit for controlling the serial port interrupt in an interrupt controller integrated on the CPU).
In specific implementation, the serial port driver includes an interrupt structure irq _ chip corresponding to the interrupt controller, and the irq _ chip includes two elements, which are an irq _ mask function and an irq _ unmask function respectively. The irq _ unmask function is used for opening a serial port interrupt control bit for controlling serial port interrupt in an interrupt controller integrated on the CPU, that is, opening the serial port interrupt. The irq _ mask function is used for closing a serial port interrupt control bit used for controlling serial port interrupt in an interrupt controller integrated on the CPU, namely, closing the serial port interrupt. Therefore, the CPU can realize the opening or closing of the serial port interrupt through the two elements.
For a computer employing multiple CPUs, the same Application (APP) may be run by different CPUs at different times. The CPU executes opening or closing of the serial port through the serial port driver, and cannot distinguish the opened or closed serial port and the serial port interruption as the objects required by the APP to operate when the serial port interruption is opened or closed. Therefore, with a multi-CPU computer, when an application program needs to open or close a serial port integrated on a certain CPU, if the CPU running the application program and the CPU where the serial port that the application program needs to open or close are not the same CPU, the CPU running the application program calls the serial port to open or close and the serial port that the application program needs to open or close is not the serial port that the application program needs to open or close, and further the CPU running the application program calls the serial port to open or close an erroneous serial port interrupt (that is, an erroneous serial port interrupt control bit in an interrupt controller integrated on the CPU is opened or closed).
For example, fig. 2 is a schematic diagram of a serial port interrupt exception prohibition provided in the prior art, and as shown in fig. 2, taking a computer including a CPU0 and a CPU1 as an example, it is assumed that a serial port is integrated on each CPU, and the connected peripherals are as shown in table 1 below:
TABLE 1
CPU | Serial port integrated on CPU | Peripheral connected by serial port |
CPU0 | Serial port 1 | Peripheral 1 |
CPU1 | Serial port 2 | Peripheral 2 |
Taking the example of opening a serial port interrupt, assume that the APP runs on CPU0 at time T0, on CPU1 at time T1, and on CPU0 at time T2.
At time T0, assuming that the APP needs to close serial port 1, CPU0 running the APP calls a serial port driver to close serial port 1 integrated on CPU0, and close the serial port 1 interrupt (i.e., close a serial port interrupt control bit in an interrupt controller integrated on CPU0 for controlling the interrupt of serial port 1).
At time T1, assuming that the APP needs to open serial port 1, CPU1 running the APP calls a serial port driver to open serial port 2 integrated on CPU1, and serial port 2 interrupts (i.e., opens a serial port interrupt control bit in an interrupt controller integrated on CPU1 for controlling the interrupt of serial port 2), instead of the interrupt of serial port 1 and serial port 1 that the APP needs to open (i.e., opens a serial port interrupt control bit in an interrupt controller integrated on CPU0 for controlling the interrupt of serial port 1). That is to say, when a certain serial port needs to be opened to APP, which CPU is running this APP, which CPU will carry out the operation of opening the serial port and opening the serial port interrupt through general serial port drive, but can't distinguish the serial port that oneself opened and whether the serial port interrupt is that APP needs to open through this serial port drive.
At the moment of T2, when the APP needs to carry out the transceiving of serial data through serial 1, because serial 1's interrupt is not opened (i.e. the serial interrupt control bit that is used for controlling this serial 1 interrupt in the integrated interrupt controller on CPU0 is not opened), make the APP unable to carry out the transceiving of serial data through serial 1 and peripheral 1, lead to APP and peripheral 1's communication to make mistakes.
In view of the above problems, the present invention provides a serial port driving method for an electronic device including a plurality of CPUs integrated with an interrupt controller and at least one serial port, so as to avoid the problem that the interrupt of the serial port on another CPU is abnormally opened or closed due to opening or closing a certain CPU integrated serial port by an APP. It can be understood by those skilled in the art that the serial port driving method provided by the present invention includes, but is not limited to, an electronic device running a Linux operating system, and may also be applied to any electronic device running other operating systems but having the above problems, which will not be described again.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 3 is a schematic flow chart of a serial port driving method provided by the present invention. The serial port driving method provided by the invention can be applied to a target processor, wherein the target processor is any one of at least two processors of electronic equipment, and an interrupt controller and at least one serial port are integrated on the target processor. As shown in fig. 3, the method includes:
s101, the target processor determines a target serial port to execute a first operation, wherein the first operation is an opening operation or a closing operation, and the target serial port is any one of the at least one serial port;
for how to determine the target serial port to be subjected to the first operation, reference may be made to the prior art, which is not described herein again.
S102, when the target processor executes a first operation on the target serial port by using a serial port driver, calling a first function in the serial port driver so as not to execute the first operation on a serial port interrupt control bit of the interrupt controller.
Specifically, in this embodiment, a first function that does not perform opening or closing of the serial port interrupt control bit of the interrupt controller is added in the serial port driver, so that when the target processor calls the serial port driver to open or close the target serial port integrated on the target processor, the first operation is not performed on the serial port interrupt control bit of the interrupt controller through the first function, that is, the operation of opening or closing the target serial port interrupt is not performed any more, and thus the problem that the serial port interrupt on other CPUs is abnormally opened or closed due to opening or closing of a certain CPU integrated serial port by the APP can be avoided.
It should be understood that in this implementation, the serial port interrupt control bit of the interrupt controller is in an always-on state, that is, the target serial port interrupt is in an always-on state. As a possible implementation manner, the target processor may open a serial port interrupt control bit of the interrupt controller when initializing the interrupt controller. That is, the serial interrupt control bit of the interrupt controller integrated on the target processor is always on after initialization. Therefore, when a certain serial port integrated on the target processor is opened or closed, the subsequent target processor can not execute the operation of opening or closing the serial port interruption by calling the first function any more, so that the problem that the serial port interruption on other CPUs is opened or closed abnormally due to opening or closing of the serial port integrated by the CPU by the APP can be avoided.
The first function may be any function capable of preventing the target processor from executing the first operation on the serial port interrupt control bit of the interrupt controller. That is, the target processor can be made not to execute the function of the irq _ mask function or the irq _ unmask function. The embodiment of the present invention does not limit the position of the first function in the serial port driver, and as a possible implementation manner, the first function may be an element in an interrupt structure irq _ chip corresponding to an interrupt controller in the serial port driver.
Fig. 4 is a schematic diagram of a serial port driver provided in the present invention, and as shown in fig. 4, when the first function is an element in an interrupt structure irq _ chip corresponding to an interrupt controller in the serial port driver, as an example, if the first function is used to prevent a target processor from performing an open operation on a serial port interrupt control bit of the interrupt controller, the first function may be, for example, an irq _ startup function. Therefore, when the target processor uses the serial port driver to open the target serial port, the irq _ startup function can be called to avoid calling the irq _ unmask function to execute the operation of opening the target serial port interrupt. In a specific implementation, the irq _ startup function may be defined as a function for not performing any operation, for example, a null function.
Correspondingly, if the first function is used to prevent the target processor from performing a shutdown operation on the serial port interrupt control bit of the interrupt controller, the first function may be, for example, an irq _ shutdown function. Therefore, when the target processor uses the serial port drive to close the target serial port, the irq _ shutdown function can be called to avoid calling the irq _ mask function to execute the operation of closing the target serial port interrupt. In a specific implementation, an irq _ shutdown function may be defined as a function for not performing any operation, for example, a null function.
By multiplexing the irq _ shutdown function and the irq _ startup function, the problem that the serial ports on other CPUs are abnormally opened or closed due to opening or closing of a serial port integrated by the APP can be avoided under the condition that the source code of the serial port driver is not changed. Therefore, the source code of the serial port driver can still be used as a public code to be applied to the scene of the CPU integrated serial port and the scene of the non-CPU integrated serial port, and the application scene of the serial port driver is expanded.
Optionally, when the first function is an element in an interrupt structure irq _ chip corresponding to an interrupt controller in a serial port driver, the target processor may initialize the first function when initializing the interrupt structure, so that the first function has a function of controlling the target processor not to perform the first operation on a serial port interrupt control bit of the interrupt controller. It should be understood that initializing the first function as described herein may be understood as assigning values to the first function as described above.
The method provided by the embodiment of the invention is exemplified by taking the electronic device running the Linux operating system as an example. The method comprises the following steps that an element irq _ startup function and an element irq _ shutdown function are added in an interrupt structure body irq _ chip corresponding to an interrupt controller in a serial port drive.
Fig. 5 is a schematic flow chart of another serial port driving method provided by the present invention, and as shown in fig. 5, the method may include:
s201, when the target processor initializes the interrupt controller integrated on the target processor, the serial port interrupt control bit of the interrupt controller is opened.
S202, when initializing the interrupt structure body corresponding to the interrupt controller in the serial port drive, the target processor initializes an irq _ startup function and an irq _ shutdown function.
The irq _ startup function and the irq _ shutdown function are assigned with values so that the irq _ startup function has a function of controlling the target processor not to execute the irq _ unmask function (i.e., a function of controlling the target processor not to perform an open operation on the serial port interrupt control bit of the interrupt controller), and the irq _ shutdown function has a function of controlling the target processor not to execute the irq _ mask function (i.e., a function of controlling the target processor not to perform a close operation on the serial port interrupt control bit of the interrupt controller).
It should be understood that the steps S201 and S202 may be executed in no order, S201 may be executed first and then S202 may be executed, S202 may be executed first and then S201 may be executed, or S201 and S202 may be executed simultaneously.
Therefore, when the APP is operated and the serial port opening operation needs to be executed, the subsequent target processor can call the irq _ startup function in the serial port driver when the serial port driver is used for executing the opening operation on the target serial port after the target serial port to be executed is determined, so that the serial port interruption control bit of the interruption controller is not executed with the opening operation, and the interruption of opening the target serial port is avoided.
Correspondingly, when the subsequent target processor runs the APP and needs to execute the operation of closing the serial port, after the target serial port to be executed and closed is determined, the irq _ shutdown function in the serial port driver can be called when the serial port driver is used for executing the closing operation on the target serial port, so that the serial port interrupt control bit of the interrupt controller is not executed with the closing operation, and the interrupt of the target serial port is avoided.
Taking the example shown in fig. 2 as an example, when the method embodiment of the present invention is adopted, at time T0, when the CPU0 running the APP calls the serial port driver to close the serial port 1 integrated on the CPU0, the operation of closing the serial port 1 interrupt by calling the irq _ shutdown function is no longer performed, that is, the serial port interrupt control bit for controlling the interrupt of the serial port 1 in the interrupt controller integrated on the CPU0 is no longer performed.
At the time T1 when the APP needs to open the serial port 1, when the CPU1 running the APP calls the serial port driver to open the serial port 2 integrated on the CPU1, the "serial port interrupt control bit for controlling the interrupt of the serial port 2 in the interrupt controller integrated on the CPU 1" may not be executed any more by calling the irq _ startup function, that is, the operation of opening the interrupt of the serial port 2 is not executed any more.
Thus, even if the APP needs to open the serial port 1 at time T1, causing the CPU1 running the APP to call a serial port driver to open the serial port 2 integrated on the CPU1, the interrupt of the serial port 2 is not opened. Correspondingly, because serial ports 1's interrupt also has not been closed at T0 moment, consequently, when APP need carry out serial ports data's the receiving and dispatching through serial ports 1 at T2 moment, APP through this serial ports 1, can carry out serial ports data's receiving and dispatching with peripheral hardware 1, guaranteed that APP carries out receiving and dispatching data through serial ports 1.
By the method, the effect of avoiding abnormal prohibition of the interruption of the CPU integrated serial port under the scene of multiple physical CPUs is achieved by modifying the interrupt structure irq _ chip corresponding to the interrupt controller in the serial port drive (namely modifying the specific code of the CPU architecture) without changing the source code of the serial port drive of the Linux kernel.
The serial port driving method provided by the invention is characterized in that for an electronic device which comprises a plurality of CPUs and is integrated with an interrupt controller and at least one serial port, a first function which does not execute opening or closing of a serial port interrupt control bit of the interrupt controller is additionally arranged in a serial port driver, so that when a processor of the electronic device calls the serial port driver to open or close a target serial port integrated on the processor, the first function can not execute the first operation on the serial port interrupt control bit of the interrupt controller, namely, the operation of opening or closing the target serial port interrupt is not executed any more, thereby avoiding the problem that the serial port interrupts on other CPUs are opened or closed abnormally due to opening or closing of a certain CPU integrated serial port by APP.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Fig. 6 is a schematic structural diagram of a serial port driving device provided in the present invention. The serial port driving device is applied to a target processor, the target processor is any one of at least two processors of electronic equipment, and an interrupt controller and at least one serial port are integrated on the target processor. The electronic device may be an electronic device running a Linux operating system, for example. That is, the serial port driver may implement part or all of the target processor through a combination of software and/or hardware, for example, the serial port driver may be a chip on the target processor, or the serial port driver may be the target processor.
As shown in fig. 6, the serial port driving apparatus may include: a determination module 11 and a calling module 12. Wherein,
the device comprises a determining module 11, a determining module, a judging module and a judging module, wherein the determining module is used for determining a target serial port to be subjected to first operation, the first operation is an opening operation or a closing operation, and the target serial port is any one of the at least one serial port;
the calling module 12 is configured to call a first function in the serial driver when a serial driver executes a first operation on the target serial port, so as not to execute the first operation on a serial port interrupt control bit of the interrupt controller.
Optionally, the apparatus may further include:
a first initializing module 13, configured to, when the calling module 12 uses a serial driver to perform a first operation on the target serial port, call a first function in the serial driver, so as to open a serial interrupt control bit of the interrupt controller when initializing the interrupt controller before the calling module 12 does not perform the first operation on the serial interrupt control bit of the interrupt controller.
Optionally, the first function is an element in an interrupt structure corresponding to the interrupt controller.
Then in this implementation, the apparatus further comprises:
the second initializing module 14 is configured to, when the calling module 12 performs a first operation on the target serial port by using a serial port driver, call a first function in the serial port driver, so as to initialize the first function when initializing the interrupt structure before the first operation is not performed on the serial port interrupt control bit of the interrupt controller, so that the first function has a function of controlling the device not to perform the first operation on the serial port interrupt control bit of the interrupt controller.
The serial port driving device provided by the invention can execute the method embodiment, the realization principle and the technical effect are similar, and the details are not repeated.
Fig. 7 is a schematic structural diagram of another serial port driving device provided by the present invention. As shown in fig. 7, the serial port driving apparatus may include: at least one processor 21 and a memory 22. Fig. 7 shows a serial drive apparatus as an example of a processor, in which,
and a memory 22 for storing a program. In particular, the program may include program code comprising computer operating instructions. The memory 22 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The processor 21 is configured to execute the computer execution instruction stored in the memory 22 to implement the serial port driving method in the foregoing embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
The processor 21 may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present invention.
Alternatively, in a specific implementation, if the communication interface, the memory 22 and the processor 21 are implemented independently, the communication interface, the memory 22 and the processor 21 may be connected to each other through a bus and perform communication with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The buses may be divided into address buses, data buses, control buses, etc., but do not represent only one bus or one type of bus.
Alternatively, in a specific implementation, if the communication interface, the memory 22 and the processor 21 are integrated on a chip, the communication interface, the memory 22 and the processor 21 may complete the same communication through an internal interface.
The present invention also provides a computer-readable storage medium, which may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. Specifically, the computer-readable storage medium stores therein program instructions for the method in the above-described embodiment.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (12)
1. A serial port driving method is applied to a target processor, wherein the target processor is any one of at least two processors of an electronic device, and an interrupt controller and at least one serial port are integrated on the target processor, and the method comprises the following steps:
determining a target serial port to be subjected to first operation, wherein the first operation is an opening operation or a closing operation, and the target serial port is any one of the at least one serial port;
when a serial port driver is used for executing a first operation on the target serial port, calling a first function in the serial port driver so as not to execute the first operation on a serial port interrupt control bit of the interrupt controller;
the first function is a function capable of preventing the target processor from executing a first operation on the serial port interrupt control bit of the interrupt controller.
2. The method of claim 1, wherein before calling a first function in the serial driver to perform a first operation on the target serial port using the serial driver to perform the first operation on the serial port interrupt control bit of the interrupt controller, the method further comprises:
and opening a serial port interrupt control bit of the interrupt controller when the interrupt controller is initialized.
3. The method of claim 1, wherein the first function is an element in an interrupt structure to which the interrupt controller corresponds.
4. The method of claim 3, wherein before the calling the first function in the serial driver to perform the first operation on the target serial port using the serial driver to perform the first operation on the serial port interrupt control bit of the interrupt controller, the method further comprises:
when the interrupt structure is initialized, the first function is initialized, so that the first function has a function of controlling the target processor not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
5. The method according to any one of claims 1-4, wherein the electronic device is an electronic device running a Linux operating system.
6. A serial port driving device is applied to a target processor, wherein the target processor is any one of at least two processors of an electronic device, and an interrupt controller and at least one serial port are integrated on the target processor, and the device comprises:
the device comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target serial port to be subjected to first operation, the first operation is opening operation or closing operation, and the target serial port is any one of the at least one serial port;
the calling module is used for calling a first function in the serial port driver when a serial port driver is used for executing a first operation on the target serial port so as not to execute the first operation on a serial port interrupt control bit of the interrupt controller;
the first function is a function capable of preventing the target processor from executing a first operation on the serial port interrupt control bit of the interrupt controller.
7. The apparatus of claim 6, further comprising:
the first initialization module is used for calling a first function in the serial port driver when the calling module executes a first operation on the target serial port by using the serial port driver so as to open the serial port interrupt control bit of the interrupt controller when initializing the interrupt controller before the calling module does not execute the first operation on the serial port interrupt control bit of the interrupt controller.
8. The apparatus of claim 6, wherein the first function is an element in an interrupt structure to which the interrupt controller corresponds.
9. The apparatus of claim 8, further comprising:
the second initialization module is used for calling a first function in the serial port driver when the calling module executes a first operation on the target serial port by using the serial port driver so as to initialize the first function before the first operation is not executed on the serial port interrupt control bit of the interrupt controller when the interrupt structure is initialized, so that the first function has a function of controlling the device not to execute the first operation on the serial port interrupt control bit of the interrupt controller.
10. The apparatus according to any one of claims 6-9, wherein the electronic device is an electronic device running a Linux operating system.
11. A serial port driving device, comprising: at least one processor and memory;
the memory stores computer-executable instructions; the at least one processor executes computer-executable instructions stored by the memory to perform the method of any of claims 1-5.
12. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein program instructions, which when executed by a processor, implement the method of any one of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910272326.2A CN110083394B (en) | 2019-04-04 | 2019-04-04 | Serial port driving method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910272326.2A CN110083394B (en) | 2019-04-04 | 2019-04-04 | Serial port driving method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110083394A CN110083394A (en) | 2019-08-02 |
CN110083394B true CN110083394B (en) | 2022-04-22 |
Family
ID=67414246
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910272326.2A Active CN110083394B (en) | 2019-04-04 | 2019-04-04 | Serial port driving method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110083394B (en) |
Citations (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101067794A (en) * | 2007-06-14 | 2007-11-07 | 中兴通讯股份有限公司 | Multi-nuclear processor and serial port multiplexing method |
CN101241460A (en) * | 2008-02-25 | 2008-08-13 | 中兴通讯股份有限公司 | Method for checking CPU dead halt |
CN101452437A (en) * | 2007-12-03 | 2009-06-10 | 英业达股份有限公司 | Multiprocessor system and CPU switching method |
CN102184122A (en) * | 2011-05-16 | 2011-09-14 | 曙光信息产业股份有限公司 | Basic input/output system (bios) and interrupt realizing method for Loongson central processing unit (CPU) mainboard |
CN103744342A (en) * | 2014-01-22 | 2014-04-23 | 大连理工计算机控制工程有限公司 | PAC (programmable automatic controller) real-time control system based on dual-core processor |
CN106649186A (en) * | 2016-12-12 | 2017-05-10 | 青岛海信电器股份有限公司 | Communication method and device for application program and serial port peripheral |
CN206585338U (en) * | 2017-03-10 | 2017-10-24 | 江门云天电力设计咨询有限公司 | A kind of grid-connected control system with temperature protection |
CN107346296A (en) * | 2016-05-05 | 2017-11-14 | 研祥智能科技股份有限公司 | A kind of driving method and device |
CN206684533U (en) * | 2017-04-13 | 2017-11-28 | 佛山市拓拓网络科技有限公司 | Wechat remote control chip |
CN107451076A (en) * | 2016-05-30 | 2017-12-08 | 龙芯中科技术有限公司 | Serial ports interruption processing method and device based on VxWorks system |
CN108227572A (en) * | 2017-12-21 | 2018-06-29 | 中国船舶重工集团公司第七0七研究所 | A kind of serial data recording device based on FATFS32 file system |
CN108470008A (en) * | 2018-01-23 | 2018-08-31 | 广州市中海达测绘仪器有限公司 | Serial data reading/writing method, device, computer equipment and storage medium |
CN108509255A (en) * | 2017-02-24 | 2018-09-07 | 龙芯中科技术有限公司 | The treating method and apparatus of hardware interrupts |
CN109358827A (en) * | 2018-12-05 | 2019-02-19 | 深圳市创维软件有限公司 | Method, system, equipment and the storage medium of serially printing are applied in control |
CN109558369A (en) * | 2018-11-29 | 2019-04-02 | 杭州迪普科技股份有限公司 | Control method, device, equipment and the system of multi -CPU list serial ports |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8078773B2 (en) * | 2006-03-29 | 2011-12-13 | Broadcom Corporation | Optimized transmission of signals between a disk drive controller and a motor controller using a serial port |
-
2019
- 2019-04-04 CN CN201910272326.2A patent/CN110083394B/en active Active
Patent Citations (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101067794A (en) * | 2007-06-14 | 2007-11-07 | 中兴通讯股份有限公司 | Multi-nuclear processor and serial port multiplexing method |
CN101452437A (en) * | 2007-12-03 | 2009-06-10 | 英业达股份有限公司 | Multiprocessor system and CPU switching method |
CN101241460A (en) * | 2008-02-25 | 2008-08-13 | 中兴通讯股份有限公司 | Method for checking CPU dead halt |
CN102184122A (en) * | 2011-05-16 | 2011-09-14 | 曙光信息产业股份有限公司 | Basic input/output system (bios) and interrupt realizing method for Loongson central processing unit (CPU) mainboard |
CN103744342A (en) * | 2014-01-22 | 2014-04-23 | 大连理工计算机控制工程有限公司 | PAC (programmable automatic controller) real-time control system based on dual-core processor |
CN107346296A (en) * | 2016-05-05 | 2017-11-14 | 研祥智能科技股份有限公司 | A kind of driving method and device |
CN107451076A (en) * | 2016-05-30 | 2017-12-08 | 龙芯中科技术有限公司 | Serial ports interruption processing method and device based on VxWorks system |
CN106649186A (en) * | 2016-12-12 | 2017-05-10 | 青岛海信电器股份有限公司 | Communication method and device for application program and serial port peripheral |
CN108509255A (en) * | 2017-02-24 | 2018-09-07 | 龙芯中科技术有限公司 | The treating method and apparatus of hardware interrupts |
CN206585338U (en) * | 2017-03-10 | 2017-10-24 | 江门云天电力设计咨询有限公司 | A kind of grid-connected control system with temperature protection |
CN206684533U (en) * | 2017-04-13 | 2017-11-28 | 佛山市拓拓网络科技有限公司 | Wechat remote control chip |
CN108227572A (en) * | 2017-12-21 | 2018-06-29 | 中国船舶重工集团公司第七0七研究所 | A kind of serial data recording device based on FATFS32 file system |
CN108470008A (en) * | 2018-01-23 | 2018-08-31 | 广州市中海达测绘仪器有限公司 | Serial data reading/writing method, device, computer equipment and storage medium |
CN109558369A (en) * | 2018-11-29 | 2019-04-02 | 杭州迪普科技股份有限公司 | Control method, device, equipment and the system of multi -CPU list serial ports |
CN109358827A (en) * | 2018-12-05 | 2019-02-19 | 深圳市创维软件有限公司 | Method, system, equipment and the storage medium of serially printing are applied in control |
Non-Patent Citations (3)
Title |
---|
DPZ1型综合集成硬件控制器在气象传输应用中常见故障分析;廖丹;《信息通信》;20180215(第02期);第146-147页 * |
一种基于高速串口通信的高效数据处理方法;王斌等;《自动化技术与应用》;20160625(第06期);第61-64页 * |
基于BF561平台的多串口通信设计与实现;张晶晶等;《江西科技师范大学学报》;20151215(第06期);第58-61页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110083394A (en) | 2019-08-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4001873B2 (en) | Apparatus and method for virtualizing interrupts in a logically partitioned computer system | |
US8145893B2 (en) | Hot-plugging a memory device | |
US9372702B2 (en) | Non-disruptive code update of a single processor in a multi-processor computing system | |
EP3070605A1 (en) | System and method for facilitating joint operation of multiple hypervisors in a computer system | |
EP3436947B1 (en) | Secure driver platform | |
KR20080013914A (en) | Method for delivering interrupts to user mode drivers | |
WO2016128443A1 (en) | Method to isolate real-time or safety-critical software and operating system from non-critical software and operating system | |
CN113467850A (en) | Hypervisor removal | |
US20080126747A1 (en) | Methods and apparatus to implement high-performance computing | |
US10853284B1 (en) | Supporting PCI-e message-signaled interrupts in computer system with shared peripheral interrupts | |
CN105335227B (en) | Data processing method, device and system in a kind of node | |
US11099897B2 (en) | Virtual machine memory overcommit by reverse ballooning | |
US9342477B2 (en) | Multi-core processor, controlling method thereof and computer system with such processor | |
US20100241840A1 (en) | System and method for resource assignment | |
CN110083394B (en) | Serial port driving method, device and storage medium | |
US7802081B2 (en) | Exposed sequestered partition apparatus, systems, and methods | |
US20160292108A1 (en) | Information processing device, control program for information processing device, and control method for information processing device | |
US9977730B2 (en) | System and method for optimizing system memory and input/output operations memory | |
US11604744B2 (en) | Dual-modal memory interface controller | |
US20220092015A1 (en) | Peripheral component interconnect express (pcie) device add-on card detection | |
KR20180011866A (en) | Method and apparatus for exclusion of memory encryption | |
US11593123B2 (en) | Methods and apparatus for boot time reduction in a processor and programmable logic device environment | |
US10824471B2 (en) | Bus allocation system | |
JP2023542935A (en) | Register compression with early release | |
CN110941452B (en) | Configuration method, BIOS chip and electronic equipment |
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 | ||
CB02 | Change of applicant information |
Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant after: Loongson Zhongke Technology Co.,Ltd. Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |