Disclosure of Invention
The embodiment of the invention provides a modification method, a modification device and a storage medium of a field replaceable unit, which are used for monopolizing an I2C bus resource in the FRU modification process and ensuring the information of the FRU to be successfully modified.
To achieve the objects of the embodiments of the present invention, embodiments of the present invention provide a method of modifying a field replaceable unit, the method including:
determining a bus to which a target Field Replaceable Unit (FRU) belongs;
determining one or more devices mounted on the bus;
stopping a bus channel switching function of one or more devices mounted on the bus when an instruction to modify the target FRU is received.
Preferably, the modifying method further includes: restoring the function of switching bus channels of the one or more devices mounted on the bus when it is determined that the target FRU modification is complete.
Preferably, the method previously comprises: setting an FRU flag bit, wherein the FRU flag bit is a flag bit for distinguishing whether the FRU is in a modification state;
and setting a modification flag bit, wherein the modification flag bit is a flag bit for distinguishing whether the equipment is allowed to switch the bus channel.
Preferably, the function of stopping the bus channel switching of the one or more devices mounted on the bus comprises:
when the FRU flag bit is detected to be a first numerical value, setting modification flag bits corresponding to one or more devices mounted on the bus to be a second numerical value, wherein the first numerical value indicates that the FRU is in a modification state, and the second numerical value indicates that the bus channel is not allowed to be modified and switched.
Preferably, when it is determined that the target FRU modification is complete, the function of resuming switching bus channels for the one or more devices mounted on the bus comprises:
modifying the FRU flag to a third value when it is determined that the modification of the target FRU is completed; when the FRU flag bit is detected to be a third value, setting modification flag bits corresponding to one or more devices mounted on the bus to be a fourth value, wherein the third value indicates that the FRU is not in a modification state, and the fourth value indicates that the bus channel is allowed to be modified and switched.
Preferably, determining the bus to which the target field replaceable unit FRU belongs includes:
inquiring the attribution table corresponding to the FRU, and determining the bus of the FRU
Determining one or more devices mounted on the bus comprises:
and inquiring a mounted device table corresponding to the bus, and determining the devices included in the table.
In a second aspect, an embodiment of the present invention further provides a modifying apparatus for a field replaceable unit, including:
an acquisition module configured to determine a bus to which a target Field Replaceable Unit (FRU) belongs; further configured to determine one or more devices mounted on the bus;
and the processing module is set to stop the function of switching the bus channel of one or more devices mounted on the bus when receiving the instruction of modifying the target FRU.
In a third aspect, embodiments of the present invention further provide a computer-readable storage medium storing computer-executable instructions for performing the method for modifying a field replaceable unit described above.
In a fourth aspect, the present invention also provides an apparatus for effecting modification of a field replaceable unit, comprising a memory holding a modification program for the field replaceable unit and a processor for executing the above-described method of modifying a field replaceable unit when the field replaceable unit-based modification program is read.
The beneficial effects of the embodiment of the invention can include:
when the target FRU is modified, the embodiment of the invention stops the function of switching the bus channel of one or more devices mounted on the bus, so that the I2C bus resource is monopolized in the process of modifying the FRU, and the information of the FRU is successfully modified.
In an exemplary embodiment, the FRU information is modified successfully by defining a new flag and setting the flag of whether each device can switch the bus channel to a first value before modifying the FRU and setting the flag of whether each device can switch the bus channel to a second value after modifying the FRU, so as to ensure that the bus channel is not cut away by other devices on the same I2C bus during the modification.
Additional features and advantages of embodiments of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The objectives and other advantages of the embodiments of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Example one
An embodiment of the present invention provides a method for modifying a field replaceable unit, as shown in fig. 1, where the method includes S101 to S103:
s101, determining a bus to which a target Field Replaceable Unit (FRU) belongs;
s102, determining one or more devices mounted on the bus;
s103, stopping the function of switching the bus channel of one or more devices mounted on the bus when receiving the command of modifying the target FRU.
In this embodiment of the present invention, the modification method further includes: restoring the function of switching bus channels of the one or more devices mounted on the bus when it is determined that the target FRU modification is complete.
In the embodiment of the invention, the method comprises the following steps: setting an FRU flag bit, wherein the FRU flag bit is a flag bit for distinguishing whether the FRU is in a modification state;
and setting a modification flag bit, wherein the modification flag bit is a flag bit for distinguishing whether the bus channel is allowed to be switched or not.
In this embodiment of the present invention, in step S103, the function of stopping switching of bus channels of one or more devices mounted on the bus includes:
when the FRU flag bit is detected to be a first numerical value, setting modification flag bits corresponding to one or more devices mounted on the bus to be a second numerical value, wherein the first numerical value indicates that the FRU is in a modification state, and the second numerical value indicates that the bus channel is not allowed to be modified and switched.
In this embodiment of the present invention, when it is determined that the modification of the target FRU is completed, the function of restoring the bus channel switching function of the one or more devices mounted on the bus includes:
modifying the FRU flag to a third value when it is determined that the modification of the target FRU is completed; when the FRU flag bit is detected to be a third value, setting modification flag bits corresponding to one or more devices mounted on the bus to be a fourth value, wherein the third value indicates that the FRU is not in a modification state, and the fourth value indicates that the bus channel is allowed to be modified and switched.
In the embodiment of the invention, firstly, the devices hung on the same I2C bus are judged, then a flag bit is set for each device whether the channel of the PCA9548 can be switched, when the flag bit is 1, the channel of the PCA9548 is allowed to be switched, and when the flag bit is 0, the channel of the PCA9548 is not allowed to be switched. Before the FRU is modified, the flag positions of all devices on the same I2C bus are set to 0, so that the channel of the PCA9548 is prevented from being cut off when FRU information is written, and after the FRU information is written, all the flag positions 1 are set to allow other devices on the same bus to cut off the channel.
In an embodiment of the present invention, determining a bus to which a target field replaceable unit FRU belongs includes:
inquiring the attribution table corresponding to the FRU, and determining the bus of the FRU
Determining one or more devices mounted on the bus comprises:
and inquiring a mounted device table corresponding to the bus, and determining the devices included in the table.
In the embodiment of the invention, which bus the FRU belongs to is determined in the code and can be obtained by table lookup. The method includes the steps that a mounted device table corresponding to a bus identifies the bus on which each device is mounted, when an FRU is modified, the bus where the FRU is located is obtained first, and then other devices on the bus can be obtained through table lookup.
Example two
An embodiment of the present invention provides a modification apparatus for a field replaceable unit, as shown in fig. 2, including:
an acquisition module configured to determine a bus to which a target Field Replaceable Unit (FRU) belongs; further configured to determine one or more devices mounted on the bus;
and the processing module is set to stop the function of switching the bus channel of one or more devices mounted on the bus when receiving the instruction of modifying the target FRU.
Embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions for performing the above method for modifying a field replaceable unit.
An embodiment of the present invention further provides an apparatus for implementing modification of a field replaceable unit, including a memory storing a modification program of the field replaceable unit and a processor for executing the above-described method of modifying a field replaceable unit when the field replaceable unit-based modification program is read.
EXAMPLE III
The present embodiment describes a modification process of the field replaceable unit by taking an example of setting a flag to control whether the device can switch the bus channel:
1. defining a flag bit whether to allow the channel of the PCA9548 to be switched or not for each device on the same bus as the FRU, wherein when the flag bit is 0, the channel of the PCA9548 is not allowed to be switched, and when the flag bit is 1, the channel of the PCA9548 is allowed to be switched;
2. before each time of changing FRU information, the mark positions 0 of all devices on the same bus are set, so that the phenomenon that the channel of PCA9548 is cut off when the FRU information is written to cause failure in modifying the FRU information is prevented;
3. when the equipment on the same bus seizes the resource, the zone bit of the equipment is detected before the channel is switched, when the zone bit is 1, the channel switching action is normally executed, and when the zone bit is 0, the channel switching is stopped;
4. and after the FRU information is modified, setting the flag positions of all the devices to be 1.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.