Method, device, electronic device and storage medium for closing serial port of computer system
By setting the variable value of the serial port option under the basic input and output system settings interface of the computer system, determining and closing the target serial port under the operating system, the problem of not being able to be properly closed under the OS after closing the serial port under BIOS, and the correct disabling of the serial port is achieved.
Patent Information
- Application Number
- CN202411534203.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In computer systems, although the serial port is manually closed under the Basic Input and Output System (BIOS) setting interface, the serial port cannot be closed correctly under the operating system (OS), resulting in the serial port disabling failure.
By setting the variable value of the serial port option in the setting interface of the basic input and output system, determine the target serial port that needs to be closed under the operating system, and prohibit the transmission of data from the serial port from the substrate management controller to the operating system, thereby correctly closing the serial port under the operating system.
It realizes that after closing the serial port under the basic input and output system settings interface, correctly closing the relevant serial port under the operating system, solving the problem of failed serial port disabling.
Smart Images

Figure CN119046220B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of serial ports, and particularly to a method, device, electronic device and storage medium for closing serial ports of a computer system. Background Art
[0002] With the rapid development of computer system technology, relying on its powerful CPU computing power, strong security and compatibility, especially the reliable operation stability and other advantages, it has taken a leading position in the scientific and technological field. Especially, whether the serial port information is correctly displayed under the operating system (OS) of the computer system is crucial for operation and maintenance personnel, R & D personnel to debug problems, and for customers.
[0003] However, a fatal problem is found during the development of the computer system: even if the serial port is manually closed in the setup interface of the Basic Input Output System (BIOS) and its corresponding register is checked, it is found that the serial port is successfully closed at the BIOS end. However, when viewing the serial port information under the OS, it is found that the corresponding serial port still exists, and the specific devices relying on the serial port can still transmit data communication normally, and the serial port disabling fails. For this situation, after analysis, it is found that in order to be compatible with the computer systems of other manufacturers, third-party code manufacturers re-initialize the serial port in the early stage of BIOS operation, but this processing method will cause the computer system to be unable to close the serial port under the OS after closing the serial port under the BIOS. Summary of the Invention
[0004] The present invention provides a method, device, electronic device and storage medium for closing serial ports of a computer system, so as to achieve the purpose of correctly closing the relevant serial ports under the operating system after closing the serial ports in the setup interface of the Basic Input Output System.
[0005] The present invention provides a method for closing serial ports of a computer system, and the method includes:
[0006] Based on the variable values of each serial port option set in the setup interface of the Basic Input Output System, determine the target serial port that needs to be closed under the operating system;
[0007] For the target serial port, prohibit the serial port data of the target serial port from being transmitted from the Baseboard Management Controller to the operating system, and close the target serial port under the operating system.
[0008] According to the method for closing serial ports of a computer system provided by the present invention, the prohibiting the serial port data of the target serial port from being transmitted from the Baseboard Management Controller to the operating system includes:
[0009] Set the state variable value of the register of the target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state;
[0010] When it is determined that the hardware layer reads the state variable value of the register of the target serial port as the first value, the hardware layer adjusts the level of the control serial port information to prohibit the target protocol signal from passing through, prohibits the serial port data of the target serial port from being transmitted from the basic input / output system to the baseboard management controller, and prohibits the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system; the target protocol is the communication protocol between the basic input / output system and the baseboard management controller.
[0011] According to a method for closing a serial port of a computer system provided by the present invention, setting the state variable value of the register of the target serial port to a first value includes:
[0012] During the preparation startup stage of the computer system operation, the basic input / output system modifies the decoding code of the serial port and adjusts the state variable value of the register of the target serial port to the first value.
[0013] According to a method for closing a serial port of a computer system provided by the present invention, setting the state variable value of the register of the target serial port to a first value includes:
[0014] The hardware layer sets the state variable value of the register of the target serial port to the first value.
[0015] According to a method for closing a serial port of a computer system provided by the present invention, prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system includes:
[0016] Set the state variable value of the register of the target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state;
[0017] The baseboard management controller receives the state variable value of the register of the target serial port;
[0018] When the baseboard management controller reads the state variable value of the register of the target serial port as the first value, the baseboard management controller stops transmitting the serial port data of the target serial port to the operating system; the first value is used to indicate that the target serial port is in a disabled state.
[0019] According to a method for closing a serial port of a computer system provided by the present invention, it further includes:
[0020] After setting the value of the status variable of the register of the target serial port to the first value, store the value of the status variable of the register of the target serial port in a non-volatile memory.
[0021] According to a method for closing a serial port of a computer system provided by the present invention, determining a target serial port that needs to be closed under an operating system based on variable values of each serial port option set in a setup interface of a basic input / output system includes:
[0022] For each of the serial port options, if the variable value of the serial port option set in the setup interface of the basic input / output system is a second value, determine that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system; the second value is used to indicate that the serial port corresponding to the serial port option is closed in the setup interface of the basic input / output system.
[0023] According to a method for closing a serial port of a computer system provided by the present invention, it further includes:
[0024] When the computer system is powered on and running, store the initial variable values of each of the serial port options of the setup interface of the basic input / output system in a non-volatile memory through the basic input / output system;
[0025] If the variable value of a serial port option is set in the setup interface of the basic input / output system, update the newly set variable value of the serial port option to the non-volatile memory;
[0026] For each of the serial port options, if the variable value of the serial port option set in the setup interface of the basic input / output system is a second value, determining that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system includes:
[0027] For each of the serial port options, if the variable value of the serial port option read from the non-volatile memory is the second value, determine that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system.
[0028] According to a method for closing a serial port of a computer system provided by the present invention, it further includes:
[0029] If the variable value of the serial port option read from the non-volatile memory is a third value, determine that the serial port corresponding to the serial port option is the target serial port that needs to be opened; the third value is used to indicate that the serial port corresponding to the serial port option is not closed in the setup interface of the basic input / output system.
[0030] A method for closing a serial port of a computer system provided by the present invention, where prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system includes:
[0031] Synchronize the variable values of each serial port option set in the setting interface of the basic input / output system to the network interface of the baseboard management controller through the basic input / output system;
[0032] If the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller is the second value, stop transmitting the serial port data of the target serial port to the operating system through the baseboard management controller.
[0033] A method for closing a serial port of a computer system provided by the present invention further includes:
[0034] Export the values of all options in the setting interface of the basic input / output system through the basic input / output system option modification tool;
[0035] For each serial port option, if the variable value of the serial port option set in the setting interface of the basic input / output system is the second value, determining that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system includes:
[0036] For each serial port option, if the variable value of the serial port option is found to be the second value from the values of all options exported from the setting interface of the basic input / output system, determine that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system.
[0037] A method for closing a serial port of a computer system provided by the present invention, after setting the state variable value of the register of the target serial port to the first value, further includes:
[0038] Read the state variable value of the register of the target serial port through a read / write tool;
[0039] If the state variable value of the register of the target serial port is the first value, determine that the target serial port has been closed in the setting interface of the basic input / output system.
[0040] The present invention also provides a device for closing a serial port of a computer system, and the device includes:
[0041] A serial port determination module, configured to determine a target serial port to be closed under the operating system based on the variable values of each serial port option set in the setting interface of the basic input / output system;
[0042] A serial port closing module is used to prohibit the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system for the target serial port, and close the target serial port under the operating system.
[0043] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the computer system serial port closing method described in any one of the above is implemented.
[0044] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer system serial port closing method described in any one of the above is implemented.
[0045] The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the computer system serial port closing method described in any one of the above is implemented.
[0046] For the computer system serial port closing method, device, electronic device, and storage medium provided by the present invention, first, based on the variable values of each serial port option set in the setup interface of the basic input / output system, the serial ports that have been closed under the setup interface of the basic input / output system can be determined as the target serial ports that need to be closed under the operating system. Then, for the target serial ports, the serial port data of the target serial ports is prohibited from being transmitted from the baseboard management controller to the operating system. Since the operating system will no longer receive the serial port data of the target serial ports, the target serial ports are closed under the operating system. The present invention can correctly close the relevant serial ports under the operating system after closing the serial ports under the setup interface of the basic input / output system. Description of the Drawings
[0047] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0048] Figure 1 It is a schematic diagram of the hardware architecture of the computer system provided by the embodiment of the present invention.
[0049] Figure 2 It is a schematic diagram of the flow of the computer system serial port closing method provided by the embodiment of the present invention.
[0050] Figure 3 It is one of the schematic diagrams of the target serial port determination process provided by the embodiment of the present invention.
[0051] Figure 4It is the second schematic diagram of the target serial port determination process provided by the embodiment of the present invention.
[0052] Figure 5 It is the first schematic diagram of the serial port data prohibition process of the target serial port provided by the embodiment of the present invention.
[0053] Figure 6 It is the second schematic diagram of the serial port data prohibition process of the target serial port provided by the embodiment of the present invention.
[0054] Figure 7 It is the third schematic diagram of the serial port data prohibition process of the target serial port provided by the embodiment of the present invention.
[0055] Figure 8 It is the fourth schematic diagram of the serial port data prohibition process of the target serial port provided by the embodiment of the present invention.
[0056] Figure 9 It is the schematic diagram of the structure of the serial port closing device of the computer system provided by the embodiment of the present invention.
[0057] Figure 10 It is the schematic diagram of the structure of the electronic device provided by the embodiment of the present invention. Detailed implementation manners
[0058] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without creative efforts shall fall within the protection scope of the present invention.
[0059] First, please refer to Figure 1 , Figure 1 which is the schematic diagram of the hardware architecture of the computer system provided by the embodiment of the present invention. As Figure 1 shown, the computer system includes: a basic input / output system 1, a baseboard management controller 2, an operating system 3, a hardware layer 4, a plurality of serial ports 5, and registers 6 of the plurality of serial ports. Among them, the plurality of serial ports 5 and their registers 6 are respectively connected to the basic input / output system 1 and the hardware layer 4, and the baseboard management controller 2 is respectively connected to the basic input / output system 1 and the operating system 3. Optionally, the computer system may further include a non-volatile memory 7, and the basic input / output system 1 is connected to the non-volatile memory 7. The hardware layer 4 is the serial port device on the motherboard of the computer system.
[0060] Next, the serial port closing method of the computer system of the present invention will be described below in combination with the above computer system.
[0061] Please refer to Figure 2 ,Figure 2 It is a schematic flowchart of a method for closing a serial port of a computer system provided by an embodiment of the present invention. As Figure 2 shown, the method may include step 201 and step 202.
[0062] Step 201: Based on the variable values of each serial port option set in the setup interface of the basic input / output system, determine the target serial port to be closed under the operating system.
[0063] Specifically, after the user sets the variable values of each serial port option in the setup interface of the basic input / output system 1, the basic input / output system 1 can, based on the variable values of each serial port option, determine the serial port that has been closed by the user in the setup interface of the basic input / output system 1 as the target serial port to be closed under the operating system 3.
[0064] In one embodiment, step 101 includes: for each serial port option, if the variable value of the serial port option set in the setup interface of the basic input / output system is a second numerical value, determine that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system; the second numerical value is used to indicate that the serial port corresponding to the serial port option has been closed in the setup interface of the basic input / output system.
[0065] Exemplarily, assuming the second numerical value is 0, for each serial port option, if the variable value of the serial port option set in the setup interface of the basic input / output system 1 is 0, it means that the user has closed the serial port corresponding to the serial port option in the setup interface of the basic input / output system 1, and it can be determined that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system 3.
[0066] Step 202: For the target serial port, prohibit the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and close the target serial port under the operating system.
[0067] Specifically, for the target serial port, prohibit the serial port data of the target serial port from being transmitted from the baseboard management controller 2 to the operating system 3. Since the serial port data of the target serial port is prohibited from being transmitted from the baseboard management controller 2 to the operating system 3, the operating system 3 will no longer receive the serial port data of the target serial port, thereby closing the target serial port under the operating system 3.
[0068] The serial port closing method for a computer system provided by an embodiment of the present invention. First, based on the variable values of each serial port option set in the setup interface of the Basic Input / Output System (BIOS), the serial ports that have been closed under the setup interface of the BIOS can be determined as the target serial ports to be closed under the operating system. Then, for the target serial ports, the serial port data of the target serial ports is prohibited from being transmitted from the Baseboard Management Controller (BMC) to the operating system. Since the operating system will no longer receive the serial port data of the target serial ports, the target serial ports are closed under the operating system. The embodiment of the present invention can correctly close the relevant serial ports under the operating system after closing the serial ports under the setup interface of the BIOS.
[0069] In one embodiment, as Figure 3 shown, the target serial port determination process may include:
[0070] Step 301: When the computer system is powered on and running, store the initial variable values of each serial port option in the setup interface of the BIOS to the non-volatile memory through the BIOS.
[0071] Step 302: If the variable value of the serial port option is set in the setup interface of the BIOS, update the newly set variable value of the serial port option to the non-volatile memory.
[0072] Step 303: For each serial port option, if the variable value of the serial port option read from the non-volatile memory is the second value, determine that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system.
[0073] Specifically, when the computer system is powered on and running, store the initial variable values of each serial port option in the setup interface of the BIOS 1 to the non-volatile memory 7 through the BIOS 1. For example: Non-Volatile Random Access Memory (NVRAM). If the user sets the variable value of the serial port option in the setup interface of the BIOS 1, automatically update the newly set variable value of the serial port option to the non-volatile memory 7, which can avoid data loss due to power failure. Assume that the second value is 0. If the variable value of the serial port option read from the non-volatile memory 7 is 0, it means that the user has closed the serial port corresponding to the serial port option under the setup interface of the BIOS 1, and it can be determined that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system 3.
[0074] In this embodiment, the variable values of each serial port option set in the setup interface of the basic input / output system are stored in a non-volatile memory, and then the variable values of the serial port options are read from the non-volatile memory as a second value, so as to determine that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system, which can avoid data loss due to power failure and improve the stability of the computer system.
[0075] Optionally, the above method further includes: if the variable value of the serial port option read from the non-volatile memory is a third value, it is determined that the serial port corresponding to the serial port option is the target serial port to be opened; the third value is used to indicate that the serial port corresponding to the serial port option is not closed in the setup interface of the basic input / output system.
[0076] Exemplarily, assume that the third value is 1. If the variable value of the serial port option read from the non-volatile memory 7 is 1, it means that the user has not closed the serial port corresponding to the serial port option in the setup interface of the basic input / output system 1, and it can be determined that the serial port corresponding to the serial port option is the target serial port to be opened, and subsequent prohibition processing is not required in this case.
[0077] In this embodiment, if the variable value of the serial port option read from the non-volatile memory is a third value, it means that the user has not closed the serial port corresponding to the serial port option in the setup interface of the basic input / output system, and it can be determined that the serial port corresponding to the serial port option is the target serial port to be opened, and subsequent prohibition processing is not required.
[0078] In one embodiment, as Figure 4 shown, the target serial port determination process may include:
[0079] Step 401, export the values of all options in the setup interface of the basic input / output system through the basic input / output system option modification tool;
[0080] Step 402, for each serial port option, if the variable value of the serial port option is found to be the second value from the values of all options exported from the setup interface of the basic input / output system, it is determined that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system.
[0081] Specifically, the values of all options in the setup interface of the basic input / output system 1 are exported through the basic input / output system option modification tool (i.e., the sce (setup control environment) tool). Assume that the second value is 0. For each serial port option, if the variable value of the serial port option is found to be 0 from the values of all options exported from the setup interface of the basic input / output system 1, it means that the user has closed the serial port corresponding to the serial port option in the setup interface of the basic input / output system 1, and it can be determined that the serial port corresponding to the serial port option is the target serial port to be closed under the operating system 3.
[0082] In this embodiment, by using the Basic Input / Output System (BIOS) option modification tool to export the values of all options in the BIOS setup interface, the variable value of the serial port option can be quickly found to be the second value, thereby determining that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system.
[0083] In one embodiment, as Figure 5 shown, step 202 includes:
[0084] Step 501: Set the status variable value of the register of the target serial port to the first value; the first value is used to indicate that the target serial port is in a disabled state.
[0085] Exemplarily, assume that the first value is 0. After determining that the target serial port needs to be closed under operating system 3, set the status variable value of the register of the target serial port to 0, which means that the target serial port is in a disabled state.
[0086] Step 502: When it is determined that the hardware layer reads the status variable value of the register of the target serial port as the first value, adjust the level of the control serial port information through the hardware layer to prohibit the target protocol signal from passing through, prohibit the serial port data of the target serial port from being transmitted from the Basic Input / Output System to the Baseboard Management Controller, and prohibit the serial port data of the target serial port from being transmitted from the Baseboard Management Controller to the operating system.
[0087] Exemplarily, when it is determined that the hardware layer 4 reads the status variable value of the register of the target serial port as 0, pull down the level of the control serial port information, which can prohibit the target protocol signal from passing through, thereby prohibiting the serial port data of the target serial port from being transmitted from the Basic Input / Output System 1 to the Baseboard Management Controller 2, and further prohibiting the serial port data of the target serial port from being transmitted from the Baseboard Management Controller 2 to the operating system 3. The target protocol is the communication protocol between the Basic Input / Output System 1 and the Baseboard Management Controller 2, for example: Enhanced Serial Peripheral Interface (ESPI).
[0088] In this embodiment, first, set the status variable value of the register of the target serial port to the first value to make the target serial port in a disabled state; then, when it is determined that the hardware layer reads the status variable value of the register of the target serial port as the first value, adjust the level of the control serial port information through the hardware layer, which can prohibit the target protocol signal from passing through. The target protocol is the communication protocol between the Basic Input / Output System and the Baseboard Management Controller, thereby prohibiting the serial port data of the target serial port from being transmitted from the Basic Input / Output System to the Baseboard Management Controller, and further prohibiting the serial port data of the target serial port from being transmitted from the Baseboard Management Controller to the operating system, so as to close the target serial port under the operating system.
[0089] In one embodiment, step 501 specifically includes: in the preparation startup stage of the computer system operation, modify the decoding code of the serial port through the basic input / output system, and adjust the state variable value of the register of the target serial port to the first value.
[0090] Specifically, the preparation startup (Ready to Boot) stage of the computer system operation is the later stage of BDS (Boot Device Selection), which is the stage before entering the system. BDS is a relatively later stage in the startup process of the Unified Extensible Firmware Interface (UEFI), and is responsible for selecting and loading the startup device.
[0091] In the preparation startup stage of the computer system operation, modify the decoding code of the serial port through the basic input / output system 1. Assuming the first value is 0, adjust the state variable value of the register of the target serial port to 0. This operation method of modifying the decoding code in the later stage of BDS can avoid the problem of incomplete printing of serial port information after enabling the debug mode, thereby operating the underlying code logic from the decoding level, cutting off the target protocol signal (for example: ESPI signal), prohibiting the operating system 3 from obtaining serial port data from the basic input / output system 1 in an interrupt manner, avoiding the transmission of serial port error information under the operating system 3, and bringing unnecessary trouble to customers and testers, providing a strong guarantee for the normal operation of the computer system.
[0092] In this embodiment, in the preparation startup stage of the computer system operation, modify the decoding code of the serial port through the basic input / output system, and adjust the state variable value of the register of the target serial port to the first value. Since the optimization scheme is adjusted to the preparation startup stage of the computer system operation, the problems of serial port information loss and incomplete printing of serial port information after enabling the debug mode can be avoided.
[0093] In one embodiment, step 501 specifically includes: set the state variable value of the register of the target serial port to the first value through the hardware layer.
[0094] Specifically, assuming the first value is 0, directly set the state variable value of the register of the target serial port to 0 through the hardware layer 4, and adjust the level of the serial port information controlled by the hardware layer 4, which can prohibit the passage of the target protocol signal (for example: enhanced serial communication protocol signal), thereby prohibiting the serial port data of the target serial port from being transmitted from the basic input / output system 1 to the baseboard management controller 2, and further prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller 2 to the operating system 3, realizing the shutdown of the target serial port under the operating system 3.
[0095] In this embodiment, the state variable value of the register of the target serial port can be directly set to a first value at the hardware level, ensuring that the state variable value of the register of the target serial port read by the hardware layer is the first value. The level of the serial port information can be adjusted and controlled through the hardware layer to prohibit the passage of the target protocol signal (e.g., enhanced serial communication protocol signal), thereby prohibiting the serial port data of the target serial port from being transmitted from the basic input / output system to the baseboard management controller, and further prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, so as to close the target serial port under the operating system.
[0096] In one embodiment, as Figure 6 shown, step 202 includes:
[0097] Step 601: Set the state variable value of the register of the target serial port to a first value; the first value is used to represent that the target serial port is in a disabled state;
[0098] Step 602: Receive the state variable value of the register of the target serial port through the baseboard management controller;
[0099] Step 603: When the baseboard management controller reads that the state variable value of the register of the target serial port is the first value, stop transmitting the serial port data of the target serial port to the operating system through the baseboard management controller.
[0100] Optionally, during the preparation startup stage of the computer system operation, modify the decoding code of the serial port through the basic input / output system 1 and adjust the state variable value of the register of the target serial port to the first value. Assuming the first value is 0, the baseboard management controller 2 can receive the state variable value of the register of the target serial port transmitted by the basic input / output system 1. If the baseboard management controller 2 reads that the state variable value of the register of the target serial port is 0, it means that the target serial port is in a disabled state, and the baseboard management controller 2 actively stops transmitting the serial port data of the target serial port to the operating system 3, thereby closing the target serial port under the operating system 3.
[0101] Optionally, set the state variable value of the register of the target serial port to the first value through the hardware layer 4. Assuming the first value is 0, the baseboard management controller 2 can receive the state variable value of the register of the target serial port transmitted by the hardware layer 4. If the baseboard management controller 2 reads that the state variable value of the register of the target serial port is 0, it means that the target serial port is in a disabled state, and the baseboard management controller 2 actively stops transmitting the serial port data of the target serial port to the operating system 3, thereby closing the target serial port under the operating system 3.
[0102] In this embodiment, the status variable value of the register of the target serial port is set to a first value; the first value is used to indicate that the target serial port is in a disabled state; when the baseboard management controller receives the status variable value of the register of the target serial port, it can actively stop transmitting the serial port data of the target serial port to the operating system when the status variable value of the register of the target serial port is the first value, thereby cutting off the transmission of the serial port data of the target serial port from the baseboard management controller side and achieving the closure of the target serial port under the operating system.
[0103] In one embodiment, the above method further includes: after setting the status variable value of the register of the target serial port to the first value, storing the status variable value of the register of the target serial port in the non-volatile memory 7, which can avoid data loss due to power-off and improve the stability of the computer system.
[0104] In one embodiment, as Figure 7 shown, step 202 includes:
[0105] Step 701, synchronize the variable values of each serial port option set in the setup interface of the basic input / output system to the network interface of the baseboard management controller through the basic input / output system;
[0106] Step 702, if the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller is a second value, stop transmitting the serial port data of the target serial port to the operating system through the baseboard management controller.
[0107] Specifically, synchronize the variable values of each serial port option set in the setup interface of the basic input / output system 1 to the network interface of the baseboard management controller 2. In this way, assuming that the second value is 0 and the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller 2 is 0, it means that the target serial port has been closed under the network interface of the baseboard management controller 2. The baseboard management controller 2 actively stops transmitting the serial port data of the target serial port to the operating system 3, thereby achieving the closure of the target serial port under the operating system 3.
[0108] In this embodiment, synchronizing the variable values of each serial port option set in the setup interface of the basic input / output system to the network interface of the baseboard management controller can make the variable values of each serial port option on the network interface of the baseboard management controller consistent with those on the setup interface of the basic input / output system. In this way, when the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller is the second value, actively stop transmitting the serial port data of the target serial port to the operating system, thereby cutting off the transmission of the serial port data of the target serial port from the baseboard management controller side and achieving the closure of the target serial port under the operating system.
[0109] Optionally, as Figure 8 shown, step 202 includes:
[0110] Step 801: When the variable value of each serial port option is set in the setup interface of the basic input / output system, synchronize the variable value of the serial port option set in the setup interface of the basic input / output system to the network interface of the baseboard management controller.
[0111] Step 802: If the variable value of the serial port option read from the network interface of the baseboard management controller is the second value, stop transmitting the serial port data of the target serial port corresponding to the serial port option to the operating system through the baseboard management controller.
[0112] Specifically, every time the user sets the variable value of a serial port option in the setup interface of the basic input / output system 1, a data synchronization is triggered, that is, the variable value of the serial port option is synchronized to the network interface of the baseboard management controller 2 through the basic input / output system 1. Assume the second value is 0. If the variable value of the serial port option read from the network interface of the baseboard management controller 2 is 0, it means that the target serial port corresponding to the serial port option has been closed under the network interface of the baseboard management controller 2, and actively stops transmitting the serial port data of the target serial port corresponding to the serial port option to the operating system 3, so as to cut off the transmission of the serial port data of the target serial port from the baseboard management controller 2 side, and achieve closing the target serial port under the operating system 3.
[0113] In this embodiment, it is not necessary to wait for all the variable values of the serial port options in the setup interface of the basic input / output system to be set before synchronizing to the network interface of the baseboard management controller, and the target serial port corresponding to the serial port option can be quickly closed under the operating system.
[0114] In one embodiment, after setting the status variable value of the register of the target serial port to the first value, the above method further includes: reading the status variable value of the register of the target serial port through a read / write tool; if the status variable value of the register of the target serial port is the first value, it is determined that the target serial port has been closed in the setup interface of the basic input / output system.
[0115] Specifically, after setting the status variable value of the register of the target serial port to the first value, read the status variable value of the register of the target serial port through a read / write (RW) tool. Assume the first value is 0. If the status variable value of the register of the target serial port is 0, it can be determined that the target serial port has been closed in the setup interface of the basic input / output system 1.
[0116] In this embodiment, the RW tool can be used to detect whether the target serial port is closed in the setup interface of the basic input / output system.
[0117] The computer system serial port closing device provided by the present invention will be described below. The computer system serial port closing device described below can be correspondingly referred to the computer system serial port closing method described above.
[0118] Please refer to Figure 9 , Figure 9 which is a schematic structural diagram of the computer system serial port closing device provided by an embodiment of the present invention. As Figure 9 shown, the device may include:
[0119] A serial port determination module 10, configured to determine a target serial port that needs to be closed under an operating system based on variable values of each serial port option set in a setup interface of a basic input / output system;
[0120] A serial port closing module 20, configured to prohibit serial port data of the target serial port from being transmitted from a baseboard management controller to the operating system, and close the target serial port under the operating system.
[0121] In one embodiment, the serial port closing module 20 includes:
[0122] A register setting unit, configured to set a status variable value of a register of the target serial port to a first value; the first value is used to represent that the target serial port is in a disabled state;
[0123] A serial port level adjustment unit, configured to, when it is determined that a status variable value of a register of the target serial port read at a hardware layer is the first value, adjust a level of serial port information through the hardware layer to prohibit a target protocol signal from passing through, prohibit serial port data of the target serial port from being transmitted from the basic input / output system to the baseboard management controller, and prohibit serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system; the target protocol is a communication protocol between the basic input / output system and the baseboard management controller.
[0124] In one embodiment, the register setting unit is specifically configured to: in a preparation startup stage when the computer system is running, modify a decoding code of the serial port through the basic input / output system, and adjust a status variable value of a register of the target serial port to the first value.
[0125] In one embodiment, the register setting unit is specifically configured to: set a status variable value of a register of the target serial port to the first value through the hardware layer.
[0126] In one embodiment, the serial port closing module 20 is specifically configured to:
[0127] Set a status variable value of a register of the target serial port to a first value; the first value is used to represent that the target serial port is in a disabled state;
[0128] Receive a status variable value of a register of the target serial port through the baseboard management controller;
[0129] When the substrate management controller reads that the status variable value of the register of the target serial port is the first value, the substrate management controller stops transmitting the serial port data of the target serial port to the operating system; the first value is used to indicate that the target serial port is in a disabled state.
[0130] In one embodiment, the device further includes:
[0131] A register variable storage module, configured to store the status variable value of the register of the target serial port to a non-volatile memory after setting the status variable value of the register of the target serial port to the first value.
[0132] In one embodiment, the serial port determination module 10 includes:
[0133] A serial port determination unit, configured to, for each serial port option, if the variable value of the serial port option set in the setup interface of the basic input / output system is the second value, determine the serial port corresponding to the serial port option as the target serial port to be closed under the operating system; the second value is used to indicate that the serial port corresponding to the serial port option is closed in the setup interface of the basic input / output system.
[0134] In one embodiment, the device further includes:
[0135] A serial port option variable storage module, configured to store the initial variable values of the serial port options in the setup interface of the basic input / output system to a non-volatile memory through the basic input / output system when the computer system is powered on and running; if the variable value of the serial port option is set in the setup interface of the basic input / output system, update the newly set variable value of the serial port option to the non-volatile memory;
[0136] The serial port determination unit is specifically configured to: for each serial port option, if the variable value of the serial port option read from the non-volatile memory is the second value, determine the serial port corresponding to the serial port option as the target serial port to be closed under the operating system.
[0137] In one embodiment, the serial port determination unit is further configured to: if the variable value of the serial port option read from the non-volatile memory is the third value, determine the serial port corresponding to the serial port option as the target serial port to be opened; the third value is used to indicate that the serial port corresponding to the serial port option is not closed in the setup interface of the basic input / output system.
[0138] In one embodiment, the serial port closing module 20 is specifically configured to:
[0139] Synchronize the variable values of the serial port options set in the setup interface of the basic input / output system to the network interface of the substrate management controller through the basic input / output system;
[0140] If the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller is the second value, the baseboard management controller stops transmitting the serial port data of the target serial port to the operating system.
[0141] In one embodiment, the serial port determination module 10 is further configured to:
[0142] After setting the status variable value of the register of the target serial port to the first value, read the status variable value of the register of the target serial port through a read / write tool;
[0143] If the status variable value of the register of the target serial port is the first value, it is determined that the target serial port is closed in the setup interface of the basic input / output system.
[0144] In one embodiment, the device further includes:
[0145] An option export module, configured to export the values of all options in the setup interface of the basic input / output system through a basic input / output system option modification tool;
[0146] The serial port determination unit is specifically configured to:
[0147] For each serial port option, if the variable value of the serial port option is found to be the second value from the values of all options in the exported setup interface of the basic input / output system, it is determined that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system.
[0148] Figure 10 An example of the physical structure diagram of an electronic device is shown as Figure 10 As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030, and a communication bus 1040. Among them, the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other through the communication bus 1040. The processor 1010 can call the logical instructions in the memory 1030 to execute the computer system serial port closing method, which includes: determining the target serial port that needs to be closed under the operating system based on the variable values of each serial port option set in the setup interface of the basic input / output system; for the target serial port, prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and closing the target serial port under the operating system.
[0149] In addition, when the logical instructions in the above-mentioned memory 1030 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0150] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the computer system serial port closing method provided by the above-mentioned various methods. The method includes: determining a target serial port that needs to be closed under the operating system based on the variable values of each serial port option set in the setup interface of the basic input / output system; for the target serial port, prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and closing the target serial port under the operating system.
[0151] On another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the computer system serial port closing method provided by the above-mentioned various methods. The method includes: determining a target serial port that needs to be closed under the operating system based on the variable values of each serial port option set in the setup interface of the basic input / output system; for the target serial port, prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and closing the target serial port under the operating system.
[0152] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative labor.
[0153] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for closing a serial port of a computer system, characterized in that: The method comprises: Based on the variable values of each serial port option set in the basic input and output system setting interface, determine the target serial port that needs to be closed in the operating system; For the target serial port, prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and closing the target serial port under the operating system; The prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system includes: Setting the state variable value of the register of the target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state; When it is determined that the state variable value of the register of the target serial port read by the hardware layer is the first value, the level of the control serial port information is adjusted by the hardware layer to prohibit the target protocol signal from passing, prohibit the serial port data of the target serial port from being transmitted from the basic input and output system to the baseboard management controller, and prohibit the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system; the target protocol is the communication protocol between the basic input and output system and the baseboard management controller; Alternatively, the prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system includes: Setting the state variable value of the register of the target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state; Receiving, by the baseboard management controller, a state variable value of a register of the target serial port; When the baseboard management controller reads that the state variable value of the register of the target serial port is a first value, the baseboard management controller controls to stop transmitting the serial port data of the target serial port to the operating system.
2. The method for closing a computer system serial port according to claim 1, characterized in that: The step of setting the state variable value of the register of the target serial port to a first value includes: In the preparation and startup phase of the computer system, the decoding code of the serial port is modified through the basic input and output system, and the state variable value of the register of the target serial port is adjusted to the first value.
3. The method for closing a computer system serial port according to claim 1, characterized in that: The step of setting the state variable value of the register of the target serial port to a first value includes: The state variable value of the register of the target serial port is set to the first value through the hardware layer.
4. The method for closing a serial port of a computer system according to any one of claims 1 to 3, characterized in that: Also includes: After setting the state variable value of the register of the target serial port to the first value, the state variable value of the register of the target serial port is stored in a non-volatile memory.
5. The method for closing a serial port of a computer system according to claim 1, characterized in that: The step of determining the target serial port to be closed in the operating system based on the variable value of each serial port option set in the setting interface of the basic input and output system includes: For each of the serial port options, if the variable value of the serial port option set in the setting interface of the basic input and output system is a second numerical value, it is determined that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system; the second numerical value is used to characterize that the serial port corresponding to the serial port option has been closed in the setting interface of the basic input and output system.
6. The method for closing a computer system serial port according to claim 5, characterized in that: Also includes: When the computer system is turned on and running, the initial variable value of each serial port option of the setting interface of the basic input and output system is stored in the non-volatile memory through the basic input and output system; If the variable value of the serial port option is set in the setting interface of the basic input and output system, the newly set variable value of the serial port option is updated to the non-volatile memory; For each of the serial port options, if the variable value of the serial port option set in the setting interface of the basic input and output system is a second value, determining that the serial port corresponding to the serial port option is the target serial port that needs to be closed in the operating system includes: For each of the serial port options, if the variable value of the serial port option read from the non-volatile memory is the second value, it is determined that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system.
7. The method for closing a serial port of a computer system according to claim 6, characterized in that: Also includes: If the variable value of the serial port option read from the non-volatile memory is a third value, determining that the serial port corresponding to the serial port option is the target serial port to be opened; The third value is used to indicate that the serial port corresponding to the serial port option is not closed in the basic input and output system setting interface.
8. The method for closing a computer system serial port according to claim 5, characterized in that: The prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system includes: Synchronizing the variable values of each serial port option set in the setting interface of the basic input and output system to the network interface of the baseboard management controller through the basic input and output system; If the variable value of the serial port option of the target serial port read from the network interface of the baseboard management controller is the second value, the baseboard management controller stops transmitting the serial port data of the target serial port to the operating system.
9. The method for closing a serial port of a computer system according to claim 5, characterized in that: Also includes: Exporting the values of all options in the basic input and output system setting interface through a basic input and output system option modification tool; For each of the serial port options, if the variable value of the serial port option set in the setting interface of the basic input and output system is a second value, determining that the serial port corresponding to the serial port option is the target serial port that needs to be closed in the operating system includes: For each of the serial port options, if the variable value of the serial port option is found to be the second value from the values of all options in the exported basic input / output system setting interface, it is determined that the serial port corresponding to the serial port option is the target serial port that needs to be closed under the operating system.
10. The method for closing a serial port of a computer system according to any one of claims 1 to 3, characterized in that: After setting the state variable value of the register of the target serial port to the first value, the method further includes: Read the state variable value of the register of the target serial port through a reading and writing tool; If the state variable value of the register of the target serial port is the first value, it is determined that the target serial port has been closed in the setting interface of the basic input and output system.
11. A computer system serial port closing device, characterized in that: The device comprises: A serial port determination module, used to determine a target serial port that needs to be closed in the operating system based on the variable value of each serial port option set in the basic input and output system setting interface; A serial port closing module, used for prohibiting the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system, and closing the target serial port under the operating system; The serial port closing module includes: A register setting unit, used to set a state variable value of a register of a target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state; The serial port level adjustment unit is used to adjust the level of the control serial port information through the hardware layer when it is determined that the state variable value of the register of the target serial port read by the hardware layer is a first value, so as to prohibit the target protocol signal from passing, prohibit the serial port data of the target serial port from being transmitted from the basic input and output system to the baseboard management controller, and prohibit the serial port data of the target serial port from being transmitted from the baseboard management controller to the operating system; the target protocol is a communication protocol between the basic input and output system and the baseboard management controller; Alternatively, the serial port closing module is specifically used for: Setting the state variable value of the register of the target serial port to a first value; the first value is used to indicate that the target serial port is in a disabled state; Receiving, by the baseboard management controller, a state variable value of a register of the target serial port; When the baseboard management controller reads that the state variable value of the register of the target serial port is a first value, the baseboard management controller controls to stop transmitting the serial port data of the target serial port to the operating system.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for closing the serial port of a computer system as described in any one of claims 1 to 10 is implemented.
13. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for closing a serial port of a computer system as claimed in any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Serial port automatic debugging system and method
CN107341079A