WO2015139431A1 - Stable hot plugging driving method and apparatus and hot plugging-supporting equipment - Google Patents

Stable hot plugging driving method and apparatus and hot plugging-supporting equipment Download PDF

Info

Publication number
WO2015139431A1
WO2015139431A1 PCT/CN2014/086094 CN2014086094W WO2015139431A1 WO 2015139431 A1 WO2015139431 A1 WO 2015139431A1 CN 2014086094 W CN2014086094 W CN 2014086094W WO 2015139431 A1 WO2015139431 A1 WO 2015139431A1
Authority
WO
WIPO (PCT)
Prior art keywords
port
hot
state
delay
swappable
Prior art date
Application number
PCT/CN2014/086094
Other languages
French (fr)
Chinese (zh)
Inventor
刘鹏举
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015139431A1 publication Critical patent/WO2015139431A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4081Live connection to bus, e.g. hot-plugging

Definitions

  • the present invention relates to the field of embedded storage technologies, and in particular, to a stable hot swap drive method, device, and a hot swappable device.
  • CF card has been widely used due to its high storage density, easy programming and reprogramming, fast read/write speed and low cost.
  • the CF card is connected to the host through a connector.
  • the CF card stores data like a disk for users to use.
  • the biggest advantage is that it supports hot swap operation.
  • the CF card hot swap operation mainly solves two problems. The first is how to detect The insertion and removal of the CF card, and the second is how to ensure that the CF card and the system can still work normally after multiple consecutive hot plugging.
  • a stable hot swap drive method includes:
  • the state in which the port supporting the hot plug device is inserted is detected; when the detected state of the port is the insertion, the port is scanned for a certain time delay.
  • the delay time is greater than or equal to 2 seconds.
  • the port when detecting that the state of the port is unplugged, the port is immediately scanned.
  • the scanning processing of the port comprises invoking a device scanning function for port scanning processing.
  • the detecting the state in which the hot-swappable port is located includes detecting the state of the port by using an interrupt or a round robin.
  • the hot-swappable device comprises a mouse or a mobile phone that stores a loose disk, a mobile hard disk, a universal serial bus USB interface.
  • a stable hot plug drive device includes: a detection module, a delay module and a processing module; the detection module is configured to: detect a state in which a port that can support the hot plug device is inserted; and the delay module is configured When: the detecting module detects that the state of the port is an insertion, delaying for a certain time;
  • the processing module is configured to: scan the port after the delay module delays a certain time.
  • the delay module is configured to set a delay of greater than or equal to 2 seconds when the detecting module detects that the state of the port is an insertion.
  • the detecting module further includes a scanning module; the scanning module is configured to: when the detecting module detects that the state of the port is unplugged, immediately scans the port.
  • a device that supports hot plugging including a memory, a processor, and a port;
  • the memory is configured to store the set delay time
  • the processor is configured to: detect a state in which a port that can support the hot plug device is inserted, and delay the delay set in the memory when the detected state of the port is an insertion The port is scanned after the time.
  • the processor is further configured to: when the detecting module detects that the state of the port is unplugged, immediately scan the port.
  • the memory storage setting has a delay time of 2 seconds or more.
  • the embodiment of the present invention delays a certain period of time, so as to ensure that the resources configured by the system are released in time, and further ensure that after the insertion and extraction operations of the hot-swappable device are performed multiple times in succession.
  • the device and system are still working.
  • FIG. 1 is a flow chart of a stable hot swap drive method according to a first embodiment of the present invention
  • FIG. 2 is a flowchart of a process after detecting an interrupt signal according to a second embodiment of the present invention
  • FIG. 3 is a schematic diagram of a module for a stable hot swap drive device according to a third embodiment of the present invention
  • FIG. 4 is a fourth embodiment of the present invention
  • FIG. 5 is a schematic diagram of a connection between a CF card and a system CPU according to a fifth embodiment of the present invention
  • FIG. 6 is a schematic diagram of obtaining SATA port information according to a fifth embodiment of the present invention
  • Post-processing method flow chart Preferred embodiment of the invention
  • the embodiment of the invention detects the state of the port that can support the hot plugging device, and detects that the port that can support the hot plugging device is inserted, and delays for a certain time. After the delay time ends, further The scanning process is performed on the port.
  • the delay time is preferably greater than or equal to 2 s.
  • the application delays a certain time after detecting that the port of the hot-swappable device is inserted, which ensures that the resources allocated by the system are released in time, and the solution is solved. After the hot-swappable device is continuously hot-swapped, the device and system can still work normally. Question.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • Figure 1 shows the hot plug method provided in this embodiment, including:
  • Step 101 The detection inserts a state that supports the port of the plugged device
  • Step 102 When the detected state is the insertion, the scanning process is performed on the port that can be inserted into the hot-swappable device.
  • a system startup link is detected before the state in which the hot-swappable device port is supported is inserted, and the system startup link can detect whether there is a hot-swappable device in the system port by means of port scanning, and if so, After the system is started, the corresponding device information can be seen through the related commands. If no, the system can not see the corresponding device information after the system is started.
  • the port that supports the hot-swappable device is detected. The status is detected by scanning. Of course, it is also possible to detect, at the system port, whether there is a device that can support hot swapping in the system startup process by other possible means.
  • the manner of detecting the state in which the hot-swappable device port is inserted is detected in at least one of the following two ways:
  • the first type by means of interruption;
  • step 102 when it is detected that the state in which the hot-swappable device port is inserted is inserted, the system first powers up the hot-swappable device, and then the system delays for a certain time, when the delay is certain. After the time has elapsed, the system will scan the hot-swappable devices.
  • the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
  • scanning is performed on the port of the device that is inserted to support hot swap.
  • the scanning process is device scanning processing, and the device scanning process includes supporting hot plugging.
  • the extracted device is added to the system device, and the system performs the lighting operation. After the scan process is completed, the user can use the device normally.
  • step 102 when it is detected that the state in which the hot-swappable device port is inserted is unplugged, no delay processing is required, and the port for inserting the hot-swappable device is directly scanned.
  • the device scan processing is performed by calling a device scan function.
  • the scan function performs device scan processing under /sys/class/scsi_host/hostx, and of course, other scan methods may be used for scanning processing.
  • the scanning process for inserting the port capable of supporting the hot plug device is a rescan process.
  • the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, etc., and the storage disc may further include a CF card, a U disk, a TF card, and the like.
  • the hot-swappable device is not limited to the ones described above in the embodiment, and any device that can be hot-swapped through a USB interface or other interfaces is within the scope of the present application.
  • the delay is delayed for a certain period of time, and the main purpose of increasing the delay time is as follows: First, the system is ready to perform scanning processing on the device. The second is to ensure that the resources allocated by the system can be released in a timely manner. Using the method in this embodiment, it is ensured that the device and system can still work normally after multiple consecutive hot swapping of the hot-swappable devices.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • FIG. 2 is a flowchart of the process after the system detects the interrupt signal in the embodiment:
  • Step 201 detecting an interrupt signal, proceeding to step 202;
  • Step 202 Determine whether the interrupt signal is an insertion signal. If yes, go to step 203. If no, Go to step 204;
  • Step 203 delay a certain period of time, and after the delay time ends, scan the port inserted with the hot-swappable device;
  • Step 204 Scan the port with the hot-swappable device.
  • a port scan is required before detecting that an interrupt signal is generated.
  • an interrupt signal is immediately generated to the system.
  • step 202 after the system receives the interrupt signal, further detecting whether the interrupt signal is an insertion signal, if yes, proceeding to step 203; if not, proceeding to step 204;
  • step 203 before the delay is delayed, the supportable hot plug device needs to be powered on, and after the delay time ends, the device port is again scanned, and the scan process includes device scan processing, device scan processing. After the completion, the hot-swappable devices are added to the system device tree, and the system performs lighting operations.
  • step 204 after the re-scanning process is completed, the device can be powered off, and then the device is powered off.
  • the scanning process in this step includes the hot-swappable device from the system device tree. Remove, the system does the light-off operation.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • FIG. 3 is a schematic diagram of a hot plug device module according to the embodiment, including: a detection module 301, a delay module 302, and a processing module 303;
  • the detecting module 301 is configured to detect a state in which the port that can support the hot plugging device is inserted; the delay module 302 is configured to delay when the detecting module 301 detects that the state in which the hot pluggable device port is inserted is inserted. Time
  • the processing module 303 is configured to perform scanning processing on the port that can be supported by the hot-swappable device after the delay of the module 302 to be delayed.
  • the detecting module 301 detects the state in which the port supporting the hot plug device is inserted.
  • the system startup link can detect whether there is a hot-swappable device in the system port through port scanning. If yes, the corresponding device information can be seen through the relevant commands after the system is started; if not, then After the system is started, the corresponding device information cannot be seen through the relevant commands.
  • detecting that the port supporting the hot-swappable device is inserted is Detected by scanning.
  • the detecting module 301 detects that the state in which the hot-swappable device port is inserted is at least one of the following two modes:
  • the first type by means of interruption;
  • the system When it is detected that the state in which the hot-swappable device port is inserted is the inserted state, the system first powers up the device that can support hot plugging, and then delays the delay by the delay module 302 for a certain period of time. After the end, the processing module 303 performs scanning processing on the device port that is inserted to support hot swap.
  • the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
  • the scanning module 3031 in the processing module 303 performs an operation of performing scanning processing on the port that can support the hot-pluggable device.
  • the scanning process is device scanning processing, and the device scans. Processing involves adding hot-swappable devices to the system device, and the system performs lighting operations. After the device scan processing is completed, the user can use the device normally.
  • scanning processing for inserting a port capable of supporting hot plugging is a rescan processing.
  • the scanning module 3031 in the processing module 303 performs scanning processing by calling a device scanning function, and preferably performs scanning processing on the device under the /sys/class/scsi_host/hostx device, and of course, other devices may be used.
  • the scanning method is performed by scanning.
  • the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, and the like, and the storage disc further includes a CF card, a U disk, a TF card, and the like.
  • the hot-swappable device is not limited to the above-mentioned ones in the embodiment, and any device that can implement the hot-swap function through the USB interface or other interfaces belongs to the scope of the present application.
  • the detecting module 301 delays a certain time when detecting that the port of the device capable of supporting hot plugging is in the inserted state, and increases the delay time.
  • the first purpose is to let the system scan the device.
  • the first preparation; the second is to ensure that the resources allocated by the system can be released in a timely manner. Using the apparatus of this embodiment, it is ensured that the system can still operate normally after multiple consecutive hot swapping of the supportable hot swappable apparatus.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • FIG. 4 is a schematic structural diagram of a hot plug device according to the embodiment, including: a memory and a processor;
  • the memory is set to store the previously set delay time
  • the processor is configured to detect a state in which the port supporting the hot-swappable device is inserted, and when the detected state is an insertion, delaying the delay time set in the memory, inserting a supportable hot-swappable device
  • the port performs scanning processing.
  • the processor detects that there is a system startup link before the state in which the hot-swappable device port is supported, and the system startup link can detect whether the system port is in the port through the port scanning manner.
  • detecting that the port supporting the hot-swappable device is inserted is Detected by scanning.
  • the manner in which the processor detects the state in which the hot-swappable device port is inserted includes at least one of the following two modes:
  • the first type by means of interruption;
  • the system When it is detected that the state in which the hot-swappable device port is inserted is inserted, the system first powers up the device that can support hot plugging, and then delays for a certain time. When the delay is over, the processor ends. Scan the device port that is plugged with hot swappable again.
  • the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
  • the processor further performs an operation of performing scanning processing on the port that can support the hot-swappable device.
  • the scanning process is a device scanning process, and the device scanning process includes adding a device that can support hot plugging.
  • the system performs lighting operations. After the device scan processing is completed, the user can use the device normally.
  • the delay processing is not required, and the port that can be supported by the hot-swappable device is directly scanned, in this implementation.
  • the scan processing is performed on the port that can be inserted into the hot-swappable device for rescan processing.
  • the processor performs a device scanning process by calling a device scan function, and preferably performs a scan function for scanning processing under /sys/class/scsi_host/hostx, and of course, can also be used. Other scanning methods are used for scanning processing.
  • the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, and the like, and the storage disc further includes a CF card, a U disk, a TF card, and the like.
  • the hot-swappable device is not limited to the above-mentioned ones in the embodiment, and any device that can implement the hot plug function through the USB interface or other interfaces belongs to the scope of the present application.
  • the processor when the processor detects that the port of the device capable of supporting hot plugging is in the inserted state, the processor delays a certain time, and the main purpose of increasing the delay time is as follows: First, let the system perform the scanning process on the device before performing the scanning process on the device. The second is to ensure that the resources allocated by the system can be released in a timely manner. ⁇ With the hot plugging device in this embodiment, after the device is continuously hot swapped, the device and the system can still work normally.
  • the hot plug device in the present application can be used independently or can be loaded inside other devices to achieve the same hot plug function.
  • Embodiment 5 is a diagrammatic representation of Embodiment 5:
  • the connection between the CF card and the system CPU provided in this embodiment is performed.
  • the CF card end is connected to the SATA interface of the CPU through the IDE interface through a bridge chip.
  • the bridge chip is the connector of the SATA TO IDE.
  • SATA TO IDE bridge chip is used to realize high-speed bidirectional data transmission by serializing data or parallelizing high-speed signals between SATA and IDE.
  • connection between the CF card and the system CPU is not limited to the SATA interface and the IED interface in the embodiment, and may be a SATA interface and a SCSI interface or a SCSI interface and an IDE interface, as long as the data between the CF card and the CPU is implemented.
  • the connector between the two ends of the interface It is not limited to the SATA TO IDE bridge in this application, but may be other chips with a connector function.
  • the CF card since the CF card is connected to the CPU through the bridge, the CF card uses the True IDE mode.
  • the system scans each port of the SATA. If the CF card is already in place, the system can see the information of the CF card by using the fdisk-1 command. When the CF card is not found in the scanning process, the fdisk-1 command in the system does not see the information in the CF card.
  • the SATA driver is preferably used for port scanning.
  • the process after obtaining the SATA port information includes preparation before scanning
  • the SATA port When the CF card is inserted into the card slot, it is detected that the SATA port generates a CF card insertion interrupt signal.
  • the CF card is powered on first, and then the CPU delays for a certain period of time. In this embodiment, the preferred time delay is 2s. After the delay is over, the system re-scans the SATA port through the SATA driver. After the scan is finished, the CF card is added to the system device tree, and then lights up, and then the user can use it normally.
  • the part scanned by the device is implemented based on the mechanism and command of the SCSI hard disk scanning, that is, the SCSI scan is run through the attribute setting under the /sys, that is, the SCSI device can be rescanned by writing the corresponding parameter to the scan.
  • the command is as follows:
  • '—— represents channel, target and lun number. The above command will cause all channels, target and visible lun under hostO to be swept.
  • the delay work queue is used to implement the scheduling of the work command, that is, queue-delay-work(struct workqueue_struct *wq, struct delayed_work *dwork, Unsigned long delay) , dwork until the clock specified by delay It will not be executed until the beat is used up.
  • the system When the CF card is removed from the card slot, it detects that the SATA port generates a CF card pull-out interrupt signal, then the system does not perform delay processing, directly calls the relevant function to re-scan the device, and simultaneously performs the light-off operation.
  • the use of the hot plug method is introduced by using a specific example.
  • the hot plug method in this embodiment can ensure that the CF card and the system can still be used after the CF card is continuously hot swapped. Normal work, that is, to ensure that the CF card and system work status is still undetermined.
  • the embodiment of the present invention delays a certain period of time, so as to ensure that the resources configured by the system are released in time, and further ensure that after the insertion and extraction operations of the hot-swappable device are performed multiple times in succession. The device and system are still working.

Abstract

Disclosed are a stable hot plugging driving method and apparatus and hot plugging-supporting equipment, which solve the problem that equipment and system can still operate normally even after repeated, continuous and rapid hot plugging of the equipment capable of supporting hot plugging. The method comprises: detecting the state of a port in which the equipment capable of supporting hot plugging is plugged; and when the detected state of the port is plugged in, scanning the port after a delay of a certain period of time.

Description

一种稳定热插拔驱动方法、 装置及一种支持热插拔设备 技术领域  Stable hot-swap driving method, device and hot-swapping device
本发明涉及嵌入式存储技术领域, 尤其涉及一种稳定热插拔驱动方法、 装置及一种支持热插拔设备。  The present invention relates to the field of embedded storage technologies, and in particular, to a stable hot swap drive method, device, and a hot swappable device.
背景技术 Background technique
数据的转储和备份无论在哪个技术领域都必不可少 ,便携式的数据存储 设备能够为其提供方便的存储接口。 CF卡作为一种方便的存储设备, 因其具 有存储密度高、 易于编程和再编程、 读写速度快、 成本低等特征, 受到了广 泛的应用。 CF卡与主机通过连接器相连接, CF卡像磁盘一样存储数据供用 户使用, 其最大的优点在于支持热插拔操作, CF卡的热插拔操作主要解决两 个问题,第一是如何检测到 CF卡的插入与拔出,第二是如何保证多次连续快 速热插拔后, CF卡和系统仍然能够正常工作。 对于第二个问题, 相关技术中 还没有相关方案可以证明是否连续快速多次插拔后系统和 CF卡使用仍然正 常, 系统仍然保持稳定。 因此, 如何保证多次连续快速热插拔后, CF卡和系 统仍然能够正常工作是本申请亟待解决的技术问题。  Data dumps and backups are essential in any technology area, and portable data storage devices provide a convenient storage interface. As a convenient storage device, CF card has been widely used due to its high storage density, easy programming and reprogramming, fast read/write speed and low cost. The CF card is connected to the host through a connector. The CF card stores data like a disk for users to use. The biggest advantage is that it supports hot swap operation. The CF card hot swap operation mainly solves two problems. The first is how to detect The insertion and removal of the CF card, and the second is how to ensure that the CF card and the system can still work normally after multiple consecutive hot plugging. For the second problem, there is no related solution in the related technology to prove whether the system and the CF card are still in use after continuous rapid multiple insertion and removal, and the system remains stable. Therefore, how to ensure that the CF card and the system still work normally after multiple consecutive hot plugging are technical problems to be solved in this application.
发明内容 Summary of the invention
本发明要解决的技术问题在于, 提供一种稳定热插拔驱动方法、 装置及 一种支持热插拔设备, 能够解决可支持热插拔设备多次连续快速热插拔后, 设备和系统仍然能够正常工作的问题。 一种稳定热插拔驱动方法, 包括:  The technical problem to be solved by the present invention is to provide a stable hot-swap driving method, device and a hot-swappable device, which can solve the problem that the device and system can still be supported after multiple consecutive rapid hot-plugging of the hot-swappable device The problem of being able to work properly. A stable hot swap drive method includes:
检测插有可支持热插拔设备的端口所处的状态; 当检测到的所述端口所处的状态为插入, 则延迟一定时间对所述端口 进行扫描处理。 较佳地, 所述延迟一定时间对所述端口进行扫描处理的步骤中, 延迟 时间大于等于 2秒。 The state in which the port supporting the hot plug device is inserted is detected; when the detected state of the port is the insertion, the port is scanned for a certain time delay. Preferably, in the step of performing scanning processing on the port for a certain period of time, the delay time is greater than or equal to 2 seconds.
较佳地, 当检测所述端口所处的状态为拔出时, 则立即对所述端口进 行扫描处理。  Preferably, when detecting that the state of the port is unplugged, the port is immediately scanned.
较佳地, 所述对所述端口进行扫描处理包括调用设备扫描函数进行端 口扫描处理。  Preferably, the scanning processing of the port comprises invoking a device scanning function for port scanning processing.
较佳地, 所述检测支持热插拔的端口所处的状态包括釆用中断或轮循 的方式检测所述端口所处的状态。  Preferably, the detecting the state in which the hot-swappable port is located includes detecting the state of the port by using an interrupt or a round robin.
较佳地, 所述支持热插拔设备包括存储散盘, 移动硬盘, 通用串行总 线 USB接口的鼠标或手机。  Preferably, the hot-swappable device comprises a mouse or a mobile phone that stores a loose disk, a mobile hard disk, a universal serial bus USB interface.
一种稳定热插拔驱动装置, 包括: 检测模块, 延时模块和处理模块; 所述检测模块设置为:检测插有可支持热插拔设备的端口所处的状态; 所述延时模块设置为: 当检测模块检测到所述端口所处的状态为插入, 则延迟一定时间;  A stable hot plug drive device includes: a detection module, a delay module and a processing module; the detection module is configured to: detect a state in which a port that can support the hot plug device is inserted; and the delay module is configured When: the detecting module detects that the state of the port is an insertion, delaying for a certain time;
所述处理模块设置为: 待延时模块延迟一定时间结束后对所述端口进 行扫描处理。  The processing module is configured to: scan the port after the delay module delays a certain time.
较佳地, 所述延时模块是设置为当检测模块检测到所述端口所处的状 态为插入, 则延迟大于等于 2秒的时间。  Preferably, the delay module is configured to set a delay of greater than or equal to 2 seconds when the detecting module detects that the state of the port is an insertion.
较佳地, 所述检测模块还包括扫描模块; 所述扫描模块设置为: 当检 测模块检测到所述端口所处的状态为拔出时, 则立即对所述端口进行扫描 处理。  Preferably, the detecting module further includes a scanning module; the scanning module is configured to: when the detecting module detects that the state of the port is unplugged, immediately scans the port.
一种支持热插拔的设备, 包括存储器, 处理器, 以及端口;  A device that supports hot plugging, including a memory, a processor, and a port;
所述存储器设置为存储设置的延迟时间;  The memory is configured to store the set delay time;
所述处理器设置为: 检测插有可支持热插拔设备的端口所处的状态, 当检测到的所述端口所处的状态为插入, 则延迟存储器中设置的所述延迟 时间后对所述端口进行扫描处理。 The processor is configured to: detect a state in which a port that can support the hot plug device is inserted, and delay the delay set in the memory when the detected state of the port is an insertion The port is scanned after the time.
较佳地, 所述处理器还设置为: 当检测模块检测到所述端口所处的状 态为拔出时, 则立即对所述端口进行扫描处理。  Preferably, the processor is further configured to: when the detecting module detects that the state of the port is unplugged, immediately scan the port.
较佳地, 所述存储器存储设置的延迟时间大于等于 2秒。  Preferably, the memory storage setting has a delay time of 2 seconds or more.
本发明实施例在检测到端口的插入状态以后, 延迟一定时间, 这样可以 保证系统配置的资源得到及时的释放, 进一步确保了在连续多次对可支持热 插拔设备进行插入和拔出操作后, 设备与系统仍然能够正常工作。 附图概述  After detecting the insertion state of the port, the embodiment of the present invention delays a certain period of time, so as to ensure that the resources configured by the system are released in time, and further ensure that after the insertion and extraction operations of the hot-swappable device are performed multiple times in succession. The device and system are still working. BRIEF abstract
图 1是本发明第一实施例提供的稳定热插拔驱动法流程图;  1 is a flow chart of a stable hot swap drive method according to a first embodiment of the present invention;
图 2是本发明第二实施例提供的检测到中断信号后的处理流程图; 图 3为本发明第三实施例提供的稳定热插拔驱动装置模块示意图; 图 4为本发明第四实施例提供的一种支持热插拔设备结构示意图; 图 5为本发明第五实施例中提供的 CF卡与系统 CPU的连接方式示意图; 图 6为本发明第五实施例中提供的获取 SATA端口信息后的处理方法流 程图。 本发明的较佳实施方式  2 is a flowchart of a process after detecting an interrupt signal according to a second embodiment of the present invention; FIG. 3 is a schematic diagram of a module for a stable hot swap drive device according to a third embodiment of the present invention; FIG. 4 is a fourth embodiment of the present invention; FIG. 5 is a schematic diagram of a connection between a CF card and a system CPU according to a fifth embodiment of the present invention; FIG. 6 is a schematic diagram of obtaining SATA port information according to a fifth embodiment of the present invention; Post-processing method flow chart. Preferred embodiment of the invention
下面结合附图对本发明的实施方式作详细说明, 在不冲突的情况下, 本 发明实施例及实施例中的特征可以相互任意组合。 本发明实施例通过检测插 有可支持热插拔设备端口所处状态, 当检测到插有可支持热插拔设备端口为 插入状态时, 延时一定时间, 在延时时间结束后, 再进一步对端口进行扫描 处理, 在本发明一实施例中, 所述延时一定时间优选大于等于 2s。 与现有技 术相比, 本申请在检测到插有可支持热插拔设备端口处于插入状态后, 会进 行一定时间的延时, 这样确保了系统分配的资源得到及时的释放, 解决了对 可支持热插拔设备进行连续多次热插拔后, 设备和系统仍然能够正常工作的 问题。 The embodiments of the present invention are described in detail below with reference to the accompanying drawings, and the features of the embodiments and the embodiments of the present invention can be arbitrarily combined with each other without conflict. The embodiment of the invention detects the state of the port that can support the hot plugging device, and detects that the port that can support the hot plugging device is inserted, and delays for a certain time. After the delay time ends, further The scanning process is performed on the port. In an embodiment of the invention, the delay time is preferably greater than or equal to 2 s. Compared with the prior art, the application delays a certain time after detecting that the port of the hot-swappable device is inserted, which ensures that the resources allocated by the system are released in time, and the solution is solved. After the hot-swappable device is continuously hot-swapped, the device and system can still work normally. Question.
实施例一:  Embodiment 1:
图 1本实施例提供的热插拔方法, 包括:  Figure 1 shows the hot plug method provided in this embodiment, including:
步骤 101 : 检测插有可支持让插拔设备端口所处状态;  Step 101: The detection inserts a state that supports the port of the plugged device;
步骤 102: 当检测到的所述所处状态为插入, 则延迟一定时间对插有可 支持热插拔设备端口进行扫描处理。  Step 102: When the detected state is the insertion, the scanning process is performed on the port that can be inserted into the hot-swappable device.
在步骤 101 中, 检测插有可支持热插拔设备端口所处状态之前有系统启 动环节, 系统启动环节可通过端口扫描的方式检测系统端口中是否有可支持 热插拔设备存在, 如是, 则系统启动后通过相关的命令可以看到对应设备信 息; 如否, 则系统启动后通过相关命令是看不到对应设备信息, 在本实施例 中,检测插有可支持热插拔设备端口所处状态为通过扫描的方式检测。 当然, 还可以是通过其他可能的方式在系统启动环节在系统端口处检测是否有可支 持热插拔的设备存在。  In step 101, a system startup link is detected before the state in which the hot-swappable device port is supported is inserted, and the system startup link can detect whether there is a hot-swappable device in the system port by means of port scanning, and if so, After the system is started, the corresponding device information can be seen through the related commands. If no, the system can not see the corresponding device information after the system is started. In this embodiment, the port that supports the hot-swappable device is detected. The status is detected by scanning. Of course, it is also possible to detect, at the system port, whether there is a device that can support hot swapping in the system startup process by other possible means.
在本实施例中, 检测插有可支持热插拔设备端口所处状态的方式至少包 括以下两种方式中的一种:  In this embodiment, the manner of detecting the state in which the hot-swappable device port is inserted is detected in at least one of the following two ways:
第一种: 通过中断的方式;  The first type: by means of interruption;
第二种: 通过轮循的方式。  Second: through the way of round robin.
在步骤 102中, 当检测到插有可支持热插拔设备端口所处状态为插入状 态的时, 系统会先给可支持热插拔设备上电, 然后系统会延迟一定时间, 当 延迟的一定时间结束以后, 系统会对可支持热插拔设备进行扫描处理。  In step 102, when it is detected that the state in which the hot-swappable device port is inserted is inserted, the system first powers up the hot-swappable device, and then the system delays for a certain time, when the delay is certain. After the time has elapsed, the system will scan the hot-swappable devices.
在本实施例中,优选延迟的一定时间具体为延迟时间大于等于 2s, 当然, 具体设定的延迟时间根据系统运行情况而定, 不限于本实施例中所述的时间 范围。  In the present embodiment, the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
延迟时间结束以后, 对插有可支持热插拔的设备端口进行扫描处理, 优 选地, 所述的扫描处理为设备扫描处理, 该设备扫描处理包括将可支持热插 拔的设备添加到系统设备中, 系统做点灯操作。 完成扫描处理后, 用户可以 正常对该设备进行使用。 After the delay time is over, scanning is performed on the port of the device that is inserted to support hot swap. Preferably, the scanning process is device scanning processing, and the device scanning process includes supporting hot plugging. The extracted device is added to the system device, and the system performs the lighting operation. After the scan process is completed, the user can use the device normally.
在步骤 102中, 当检测到插有可支持热插拔设备端口此时的状态为拔出 时, 则不需要做延迟处理, 而是直接对插有可支持热插拔设备端口进行扫描 处理。  In step 102, when it is detected that the state in which the hot-swappable device port is inserted is unplugged, no delay processing is required, and the port for inserting the hot-swappable device is directly scanned.
在本实施例中通过调用设备扫描函数进行设备扫描处理, 优选该扫描函 数在 /sys/class/scsi— host/hostx下执行设备扫描处理, 当然还可以釆用其他的扫 描方式进行扫描处理, 在本实施例中, 对插有可支持热插拔设备端口进行扫 描处理为重新扫描处理。  In this embodiment, the device scan processing is performed by calling a device scan function. Preferably, the scan function performs device scan processing under /sys/class/scsi_host/hostx, and of course, other scan methods may be used for scanning processing. In this embodiment, the scanning process for inserting the port capable of supporting the hot plug device is a rescan process.
在本实施例中, 所述可支持热插拔设备优选包括存储散盘, 移动硬盘, 连接 USB接口的鼠标, 手机等, 所述存储散盘又可包括 CF卡, U盘, TF卡 等直接通过 USB接口进行数据交换或者通过读卡器等设备与 USB接口连接 进而进行数据交换的设备。 该可支持热插拔设备不限于本实施例上述所述的 几种,只要是通过 USB接口或者其他接口可实现热插拔功能的设备都属于本 申请请求保护的范围。  In this embodiment, the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, etc., and the storage disc may further include a CF card, a U disk, a TF card, and the like. A device that exchanges data via a USB interface or connects to a USB interface through a device such as a card reader to exchange data. The hot-swappable device is not limited to the ones described above in the embodiment, and any device that can be hot-swapped through a USB interface or other interfaces is within the scope of the present application.
在本实施例中,在检测到插有可支持热插拔的设备端口处于插入状态时, 延迟一定时间, 增加延时时间的主要目的: 一是让系统做好对设备进行扫描 处理前的准备; 二是确保系统分配的资源能够得到及时的释放。 釆用本实施 例中的方法, 可以确保对可支持热插拔设备进行多次连续的热插拔后, 该设 备与系统仍然能够正常工作。  In this embodiment, when it is detected that the port of the device capable of supporting hot plugging is in the inserted state, the delay is delayed for a certain period of time, and the main purpose of increasing the delay time is as follows: First, the system is ready to perform scanning processing on the device. The second is to ensure that the resources allocated by the system can be released in a timely manner. Using the method in this embodiment, it is ensured that the device and system can still work normally after multiple consecutive hot swapping of the hot-swappable devices.
实施例二:  Embodiment 2:
在本实施例中, 优选通过中断方式检测可支持热插拔设备的所处状态, 图 2是本实施例提供的系统检测到中断信号后的处理流程图:  In this embodiment, it is preferable to detect the state in which the hot-swappable device can be supported by the interrupt mode. FIG. 2 is a flowchart of the process after the system detects the interrupt signal in the embodiment:
步骤 201 : 检测到有中断信号, 进入步骤 202;  Step 201: detecting an interrupt signal, proceeding to step 202;
步骤 202: 判断该中断信号是否为插入信号,如是,进入步骤 203 ,如否, 进入步骤 204; Step 202: Determine whether the interrupt signal is an insertion signal. If yes, go to step 203. If no, Go to step 204;
步骤 203 : 延迟一定时间, 延迟时间结束后对插有可支持热插拔设备的 端口进行扫描处理;  Step 203: delay a certain period of time, and after the delay time ends, scan the port inserted with the hot-swappable device;
步骤 204: 对插有可支持热插拔设备的端口进行扫描处理。  Step 204: Scan the port with the hot-swappable device.
在步骤 201 中, 检测到有中断信号产生之前需要进行端口扫描, 当端口 扫描的过程中检测到有可支持热插拔设备存在于端口上, 则立马产生中断信 号给系统。  In step 201, a port scan is required before detecting that an interrupt signal is generated. When a port scan process detects that a hot-swappable device exists on the port, an interrupt signal is immediately generated to the system.
在步骤 202中, 当系统接收到该中断信号以后, 进一步检测该中断信号 是否为插入信号, 如是, 则进入步骤 203; 如否, 则进入步骤 204;  In step 202, after the system receives the interrupt signal, further detecting whether the interrupt signal is an insertion signal, if yes, proceeding to step 203; if not, proceeding to step 204;
在步骤 203中, 在延迟一定时间之前, 还需要给该可支持热插拔设备通 电, 在延迟时间结束后对插有该设备端口再次进行扫描处理, 该扫描处理包 括设备扫描处理, 设备扫描处理完成后将可支持热插拔的设备添加到系统设 备树中, 系统做点灯操作。  In step 203, before the delay is delayed, the supportable hot plug device needs to be powered on, and after the delay time ends, the device port is again scanned, and the scan process includes device scan processing, device scan processing. After the completion, the hot-swappable devices are added to the system device tree, and the system performs lighting operations.
在步骤 204中, 对插有可支持热插拔设备端口完成重新扫描处理后, 进 而使得设备与系统之间断电, 该步骤中的扫描处理包括将可支持热插拔的设 备从系统设备树中去掉, 系统做灭灯操作。  In step 204, after the re-scanning process is completed, the device can be powered off, and then the device is powered off. The scanning process in this step includes the hot-swappable device from the system device tree. Remove, the system does the light-off operation.
实施例三:  Embodiment 3:
图 3为本实施例提供的热插拔装置模块示意图, 包括: 检测模块 301 , 延时模块 302和处理模块 303;  3 is a schematic diagram of a hot plug device module according to the embodiment, including: a detection module 301, a delay module 302, and a processing module 303;
检测模块 301设置为检测插有可支持热插拔设备端口所处状态; 延时模块 302设置为当检测模块 301检测到插有可支持热插拔设备端口 所处状态为插入时, 则延迟一定时间;  The detecting module 301 is configured to detect a state in which the port that can support the hot plugging device is inserted; the delay module 302 is configured to delay when the detecting module 301 detects that the state in which the hot pluggable device port is inserted is inserted. Time
处理模块 303设置为待延时模块 302延迟一定时间结束后对插有可支持 热插拔设备端口进行扫描处理。  The processing module 303 is configured to perform scanning processing on the port that can be supported by the hot-swappable device after the delay of the module 302 to be delayed.
在本实施例中, 检测模块 301检测插有可支持热插拔设备端口所处状态 之前还有系统启动环节 , 系统启动环节可通过端口扫描的方式检测系统端口 中是否有可支持热插拔设备存在, 如是, 则系统启动后通过相关命令可以看 到对应设备信息; 如否, 则系统启动后通过相关命令是看不到对应设备信息。 当然, 还可以是通过其他可能的方式在系统启动环节在系统端口处检测是否 有可支持热插拔的设备存在, 在本实施例中, 检测插有可支持热插拔设备端 口所处状态为通过扫描的方式检测。 当然, 还可以是通过其他可能的方式在 系统启动环节在系统端口处检测是否有可支持热插拔的设备存在。 In this embodiment, the detecting module 301 detects the state in which the port supporting the hot plug device is inserted. There is also a system startup link. The system startup link can detect whether there is a hot-swappable device in the system port through port scanning. If yes, the corresponding device information can be seen through the relevant commands after the system is started; if not, then After the system is started, the corresponding device information cannot be seen through the relevant commands. Of course, it is also possible to detect whether there is a hot-swappable device at the system port in the system startup link. In this embodiment, detecting that the port supporting the hot-swappable device is inserted is Detected by scanning. Of course, it is also possible to detect, at the system port, whether there is a device capable of supporting hot plugging in the system startup link by other possible means.
在本实施例中, 检测模块 301检测插有可支持热插拔设备端口所处状态 的方式至少包括以下两种方式中的其中一种:  In this embodiment, the detecting module 301 detects that the state in which the hot-swappable device port is inserted is at least one of the following two modes:
第一种: 通过中断的方式;  The first type: by means of interruption;
第二种: 通过轮循的方式。  Second: through the way of round robin.
当检测到插有可支持热插拔设备端口所处状态为插入状态的时候, 系统 会先给可支持热插拔的设备上电, 然后通过延时模块 302延迟一定时间, 当 延迟的一定时间结束以后, 处理模块 303会对插有可支持热插拔的设备端口 进行扫描处理。  When it is detected that the state in which the hot-swappable device port is inserted is the inserted state, the system first powers up the device that can support hot plugging, and then delays the delay by the delay module 302 for a certain period of time. After the end, the processing module 303 performs scanning processing on the device port that is inserted to support hot swap.
在本实施例中,优选延迟的一定时间具体为延迟时间大于等于 2s, 当然, 具体设定的延迟时间根据系统运行情况而定, 不限于本实施例中所述的时间 范围。  In the present embodiment, the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
当延时模块 302控制的延迟时间结束以后, 处理模块 303中的扫描模块 3031执行对插有可支持热插拔设备端口进行扫描处理的操作, 优选地, 扫描 处理为设备扫描处理, 该设备扫描处理包括将可支持热插拔的设备添加到系 统设备中, 系统做点灯操作。 完成设备扫描处理后, 用户可以正常对该设备 进行使用。  After the delay time controlled by the delay module 302 ends, the scanning module 3031 in the processing module 303 performs an operation of performing scanning processing on the port that can support the hot-pluggable device. Preferably, the scanning process is device scanning processing, and the device scans. Processing involves adding hot-swappable devices to the system device, and the system performs lighting operations. After the device scan processing is completed, the user can use the device normally.
当检测模块 301 检测到插有可支持热插拔设备端口此时的状态为拔出 时, 则不需要做延迟处理, 而是直接对插有可支持热插拔设备端口进行设备 扫描处理 , 在本实施例中 , 对插有可支持热插拔设备端口进行扫描处理为重 新扫描处理。 When the detecting module 301 detects that the state in which the hot-swappable device port is inserted is unplugged, the delay processing is not required, and the device that directly supports the hot-swappable device port is directly connected. Scan processing, in this embodiment, scanning processing for inserting a port capable of supporting hot plugging is a rescan processing.
在本实施例中,处理模块 303中的扫描模块 3031通过调用设备扫描函数 进行扫描处理,优选在 /sys/class/scsi— host/hostx下执行扫描函数进行设备扫描 处理, 当然还可以釆用其他的扫描方式进行扫描处理。  In this embodiment, the scanning module 3031 in the processing module 303 performs scanning processing by calling a device scanning function, and preferably performs scanning processing on the device under the /sys/class/scsi_host/hostx device, and of course, other devices may be used. The scanning method is performed by scanning.
在本实施例中, 所述的可支持热插拔设备优选包括存储散盘, 移动硬盘, 连接 USB接口的鼠标, 手机等, 所述存储散盘又进一步包括 CF卡, U盘, TF卡等直接通过 USB接口进行数据交换或者通过读卡器等设备与 USB接口 连接进而进行数据交换的设备。 该可支持热插拔设备不限于本实施例上述所 述的几种,只要是通过 USB接口或者其他接口可实现热插拔功能的设备都属 于本申请请求保护的范围。  In this embodiment, the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, and the like, and the storage disc further includes a CF card, a U disk, a TF card, and the like. A device that exchanges data directly through a USB interface or connects to a USB interface through a device such as a card reader to exchange data. The hot-swappable device is not limited to the above-mentioned ones in the embodiment, and any device that can implement the hot-swap function through the USB interface or other interfaces belongs to the scope of the present application.
在本实施例中, 检测模块 301在检测到插有可支持热插拔的设备端口处 于插入状态时, 延迟一定时间, 增加延时时间的主要目的: 一是让系统做好 对设备进行扫描处理前的准备; 二是确保系统分配的资源能够得到及时的释 放。 釆用本实施例中的装置, 可以确保对可支持热插拔装置进行多次连续的 热插拔后, 系统仍然能够正常工作。  In this embodiment, the detecting module 301 delays a certain time when detecting that the port of the device capable of supporting hot plugging is in the inserted state, and increases the delay time. The first purpose is to let the system scan the device. The first preparation; the second is to ensure that the resources allocated by the system can be released in a timely manner. Using the apparatus of this embodiment, it is ensured that the system can still operate normally after multiple consecutive hot swapping of the supportable hot swappable apparatus.
实施例四:  Embodiment 4:
图 4为本实施例中提供的一种热插拔设备结构示意图, 包括: 存储器和 处理器;  FIG. 4 is a schematic structural diagram of a hot plug device according to the embodiment, including: a memory and a processor;
存储器设置为存储之前设置好的延迟时间;  The memory is set to store the previously set delay time;
处理器设置为检测插有可支持热插拔设备端口所处状态, 当检测到的所 述所处状态为插入, 则延迟存储器中设置的所述延迟时间后对插有可支持热 插拔设备端口进行扫描处理。  The processor is configured to detect a state in which the port supporting the hot-swappable device is inserted, and when the detected state is an insertion, delaying the delay time set in the memory, inserting a supportable hot-swappable device The port performs scanning processing.
在本实施例中, 处理器检测插有可支持热插拔设备端口所处状态之前还 有系统启动环节, 系统启动环节可通过端口扫描的方式检测系统端口中是否 有可支持热插拔设备存在, 如是, 则系统启动后通过相关命令可以看到对应 设备信息; 如否, 则系统启动后通过相关命令是看不到对应设备信息。 当然, 还可以是通过其他可能的方式在系统启动环节在系统端口处检测是否有可支 持热插拔的设备存在, 在本实施例中, 检测插有可支持热插拔设备端口所处 状态为通过扫描的方式检测。 当然, 还可以是通过其他可能的方式在系统启 动环节在系统端口处检测是否有可支持热插拔的设备存在。 。 In this embodiment, the processor detects that there is a system startup link before the state in which the hot-swappable device port is supported, and the system startup link can detect whether the system port is in the port through the port scanning manner. There is a device that can support hot swap. If yes, the corresponding device information can be seen through the related commands after the system is started. If no, the corresponding device information cannot be seen after the system is started. Of course, it is also possible to detect whether there is a hot-swappable device at the system port in the system startup link. In this embodiment, detecting that the port supporting the hot-swappable device is inserted is Detected by scanning. Of course, it is also possible to detect, at the system port, whether there is a device capable of supporting hot plugging in the system startup link by other possible means. .
在本实施例中, 处理器检测插有可支持热插拔设备端口所处状态的方式 至少包括以下两种方式中的其中一种:  In this embodiment, the manner in which the processor detects the state in which the hot-swappable device port is inserted includes at least one of the following two modes:
第一种: 通过中断的方式;  The first type: by means of interruption;
第二种: 通过轮循的方式。  Second: through the way of round robin.
当检测到插有可支持热插拔设备端口所处状态为插入状态的时候, 系统 会先给可支持热插拔的设备上电, 然后延迟一定时间, 当延迟的一定时间结 束以后, 处理器会对插有可支持热插拔的设备端口再次进行扫描处理。  When it is detected that the state in which the hot-swappable device port is inserted is inserted, the system first powers up the device that can support hot plugging, and then delays for a certain time. When the delay is over, the processor ends. Scan the device port that is plugged with hot swappable again.
在本实施例中,优选延迟的一定时间具体为延迟时间大于等于 2s, 当然, 具体设定的延迟时间根据系统运行情况而定, 不限于本实施例中所述的时间 范围。  In the present embodiment, the delay time is preferably 2s or more, and the delay time is not limited to the time range described in this embodiment.
当延迟时间结束以后, 处理器进一步执行对插有可支持热插拔设备端口 进行扫描处理的操作, 优选地, 扫描处理为设备扫描处理, 该设备扫描处理 包括将可支持热插拔的设备添加到系统设备中, 系统做点灯操作。 完成设备 扫描处理后, 用户可以正常对该设备进行使用。  After the delay time ends, the processor further performs an operation of performing scanning processing on the port that can support the hot-swappable device. Preferably, the scanning process is a device scanning process, and the device scanning process includes adding a device that can support hot plugging. In the system equipment, the system performs lighting operations. After the device scan processing is completed, the user can use the device normally.
当处理器检测到插有可支持热插拔设备端口此时的状态为拔出时, 则不 需要做延迟处理, 而是直接对插有可支持热插拔设备端口进行扫描处理, 在 本实施例中, 对插有可支持热插拔设备端口进行扫描处理为重新扫描处理。  When the processor detects that the state of the hot-swappable device port is plugged in, the delay processing is not required, and the port that can be supported by the hot-swappable device is directly scanned, in this implementation. In the example, the scan processing is performed on the port that can be inserted into the hot-swappable device for rescan processing.
在本实施例中, 处理器通过调用设备扫描函数进行设备扫描处理, 优选 地在 /sys/class/scsi— host/hostx下执行扫描函数进行扫描处理, 当然还可以釆用 其他的扫描方式进行扫描处理。 In this embodiment, the processor performs a device scanning process by calling a device scan function, and preferably performs a scan function for scanning processing under /sys/class/scsi_host/hostx, and of course, can also be used. Other scanning methods are used for scanning processing.
在本实施例中, 所述的可支持热插拔设备优选包括存储散盘, 移动硬盘, 连接 USB接口的鼠标, 手机等, 所述存储散盘又进一步包括 CF卡, U盘, TF卡等直接通过 USB接口进行数据交换或者通过读卡器等设备与 USB接口 连接进而进行数据交换的设备。 。 该可支持热插拔设备不限于本实施例上述 所述的几种,只要是通过 USB接口或者其他接口可实现热插拔功能的设备都 属于本申请请求保护的范围。  In this embodiment, the supportable hot plug device preferably includes a storage disc, a mobile hard disk, a mouse connected to the USB interface, a mobile phone, and the like, and the storage disc further includes a CF card, a U disk, a TF card, and the like. A device that exchanges data directly through a USB interface or connects to a USB interface through a device such as a card reader to exchange data. . The hot-swappable device is not limited to the above-mentioned ones in the embodiment, and any device that can implement the hot plug function through the USB interface or other interfaces belongs to the scope of the present application.
在本实施例中 , 处理器在检测到插有可支持热插拔的设备端口处于插入 状态时, 延迟一定时间, 增加延时时间的主要目的: 一是让系统做好对设备 进行扫描处理前的准备; 二是确保系统分配的资源能够得到及时的释放。 釆 用本实施例中的热插拔设备, 将该设备进行多次连续的热插拔后, 该设备与 系统仍然能够正常工作。  In this embodiment, when the processor detects that the port of the device capable of supporting hot plugging is in the inserted state, the processor delays a certain time, and the main purpose of increasing the delay time is as follows: First, let the system perform the scanning process on the device before performing the scanning process on the device. The second is to ensure that the resources allocated by the system can be released in a timely manner.釆 With the hot plugging device in this embodiment, after the device is continuously hot swapped, the device and the system can still work normally.
优选地, 本申请中的热插拔设备可以独立使用, 也可以装载在其他设备 内部, 实现相同的热插拔功能。  Preferably, the hot plug device in the present application can be used independently or can be loaded inside other devices to achieve the same hot plug function.
实施例五:  Embodiment 5:
为了对本申请做进一步说明, 在本实施例中, 釆用可支持热插拔操作的 CF卡做详细说明。  In order to further explain the present application, in the present embodiment, a CF card capable of supporting hot plugging operation will be described in detail.
在本申请中, 参见图 5, 为本实施例中提供的 CF卡与系统 CPU的连接 方式, 在本实施例中, CF卡端通过 IDE接口与 CPU端的 SATA接口通过一 个桥片芯片连接, 该桥片芯片为 SATA TO IDE的连接器。 在本实施例中, 釆 用 SATA TO IDE的桥接芯片, 通过将 SATA及 IDE两者间数据串行化或者 并列化的高速信号转接, 实现高速的双向数据传输。  In this application, referring to FIG. 5, the connection between the CF card and the system CPU provided in this embodiment is performed. In this embodiment, the CF card end is connected to the SATA interface of the CPU through the IDE interface through a bridge chip. The bridge chip is the connector of the SATA TO IDE. In this embodiment, SATA TO IDE bridge chip is used to realize high-speed bidirectional data transmission by serializing data or parallelizing high-speed signals between SATA and IDE.
当然, CF卡与系统 CPU之间的连接也不限于本实施例中的 SATA接口 与 IED接口,也可以是 SATA接口与 SCSI接口或者是 SCSI接口与 IDE接口, 只要实现 CF卡与 CUP之间数据更好的传输即可, 两端接口之间的连接器也 不限于本申请中的 SATA TO IDE桥片, 还可以是其他具有连接器作用的芯 片。 Of course, the connection between the CF card and the system CPU is not limited to the SATA interface and the IED interface in the embodiment, and may be a SATA interface and a SCSI interface or a SCSI interface and an IDE interface, as long as the data between the CF card and the CPU is implemented. Better transmission, the connector between the two ends of the interface It is not limited to the SATA TO IDE bridge in this application, but may be other chips with a connector function.
在本实施例中, 因为 CF卡是通过桥片与 CPU相互连接, 因此, CF卡釆 用 True IDE模式。  In this embodiment, since the CF card is connected to the CPU through the bridge, the CF card uses the True IDE mode.
在本实施例中, 优选地, 在系统启动中, 系统会对 SATA的每个端口进 行扫描, 如果扫描到 CF卡已经在位, 系统会通过 fdisk-1命令是可以看到 CF 卡的信息; 当扫描过程中没有发现 CF卡在位, 系统中的 fdisk-1命令不会看 到 CF卡中的信息。 在本实施例中, 优选地 SATA驱动进行端口扫描。  In this embodiment, preferably, during system startup, the system scans each port of the SATA. If the CF card is already in place, the system can see the information of the CF card by using the fdisk-1 command. When the CF card is not found in the scanning process, the fdisk-1 command in the system does not see the information in the CF card. In this embodiment, the SATA driver is preferably used for port scanning.
在本实施例中, 参见图 6, 获取 SATA端口信息后的处理过程, 包括扫 描前的准备;  In this embodiment, referring to FIG. 6, the process after obtaining the SATA port information includes preparation before scanning;
当 CF卡插入卡槽, 即检测到 SATA端口产生 CF卡插入中断信号, 则先 对 CF卡进行上电, 然后 CPU会延时一定时间, 在本实施例中, 优选延时的 一定时间为 2s, 延时结束后, 系统通过 SATA驱动对 SATA端口重新做一次 扫描, 扫描结束后, CF卡被加到系统设备树当中, 然后点灯, 随后供用户正 常使用。  When the CF card is inserted into the card slot, it is detected that the SATA port generates a CF card insertion interrupt signal. The CF card is powered on first, and then the CPU delays for a certain period of time. In this embodiment, the preferred time delay is 2s. After the delay is over, the system re-scans the SATA port through the SATA driver. After the scan is finished, the CF card is added to the system device tree, and then lights up, and then the user can use it normally.
在本实施例中, 设备扫描的部分是基于 SCSI硬盘扫描的机制和命令实 施, 即通过 /sys下的属性设置运行 SCSI扫描, 即通过向 scan中写入对应参数 便可以实现 SCSI设备的重新扫描。 命令如下:  In this embodiment, the part scanned by the device is implemented based on the mechanism and command of the SCSI hard disk scanning, that is, the SCSI scan is run through the attribute setting under the /sys, that is, the SCSI device can be rescanned by writing the corresponding parameter to the scan. . The command is as follows:
# cd /sys/class/scsi_host/hostx/(x表示 host编号);  # cd /sys/class/scsi_host/hostx/(x means host number);
# echo '— ' > scan;  # echo '- ' > scan;
'——,代表 channel, target和 lun编号。 以上命令会导致 hostO 下所有 channel , target以及可见 lun被扫 4 。  '——, represents channel, target and lun number. The above command will cause all channels, target and visible lun under hostO to be swept.
在本实施例中, 为了让 work命令有合理的执行, 釆取延时工作队列的方 式实现 work命令的调度, 即 queue— delayed— work(struct workqueue— struct *wq, struct delayed— work * dwork, unsigned long delay) , dwork直到 delay指定的时钟 节拍用完后才会执行。 In this embodiment, in order to make the work command have a reasonable execution, the delay work queue is used to implement the scheduling of the work command, that is, queue-delay-work(struct workqueue_struct *wq, struct delayed_work *dwork, Unsigned long delay) , dwork until the clock specified by delay It will not be executed until the beat is used up.
当 CF卡拔出卡槽时, 即检测到 SATA端口产生 CF卡拔出中断信号, 则 系统不做延时处理, 直接调用相关函数进行设备重新扫描, 同时做灭灯操作。  When the CF card is removed from the card slot, it detects that the SATA port generates a CF card pull-out interrupt signal, then the system does not perform delay processing, directly calls the relevant function to re-scan the device, and simultaneously performs the light-off operation.
本实施例中, 通过具体的例子, 介绍了热插拔方法的使用, 釆用本实施 例中的热插拔方法, 能够保证 CF卡在多次连续热插拔以后, CF卡以及系统 仍然能够正常工作, 即确保 CF卡与系统工作状态仍然未定。  In this embodiment, the use of the hot plug method is introduced by using a specific example. The hot plug method in this embodiment can ensure that the CF card and the system can still be used after the CF card is continuously hot swapped. Normal work, that is, to ensure that the CF card and system work status is still undetermined.
以上内容是结合具体的实施方式对本发明所作的进一步详细说明, 不能 认定本发明的具体实施只局限于这些说明。 对于本发明所属技术领域的普通 技术人员来说, 在不脱离本发明构思的前提下, 还可以做出若干简单推演或 替换, 都应当视为属于本发明的保护范围。 The above is a further detailed description of the present invention in connection with the specific embodiments, and it is not intended that the specific embodiments of the invention are limited to the description. It will be apparent to those skilled in the art that the present invention may be practiced without departing from the spirit and scope of the invention.
工业实用性 Industrial applicability
本发明实施例在检测到端口的插入状态以后, 延迟一定时间, 这样可以 保证系统配置的资源得到及时的释放, 进一步确保了在连续多次对可支持热 插拔设备进行插入和拔出操作后, 设备与系统仍然能够正常工作。  After detecting the insertion state of the port, the embodiment of the present invention delays a certain period of time, so as to ensure that the resources configured by the system are released in time, and further ensure that after the insertion and extraction operations of the hot-swappable device are performed multiple times in succession. The device and system are still working.

Claims

权 利 要 求 书 claims
1、 一种稳定热插拔驱动方法, 包括: 1. A stable hot-swap driver method, including:
检测插有可支持热插拔设备的端口所处的状态; Detect the status of ports with hot-swappable devices plugged into them;
当检测到的所述端口所处的状态为插入, 则延迟一定时间对所述端口 进行扫描处理。 When the detected state of the port is insertion, the scanning process of the port is delayed for a certain period of time.
2、 如权利要求 1所述的稳定热插拔驱动方法, 其中, 所述延迟一定时 间对所述端口进行扫描处理的步骤中, 延迟时间大于等于 2秒。 2. The stable hot-swap driving method as claimed in claim 1, wherein in the step of delaying scanning the port for a certain period of time, the delay time is greater than or equal to 2 seconds.
3、 如权利要求 1所述的稳定热插拔驱动方法, 其中, 当检测所述端口 所处的状态为拔出时, 则立即对所述端口进行扫描处理。 3. The stable hot-plug driving method according to claim 1, wherein when it is detected that the state of the port is unplugged, the port is scanned immediately.
4、 如权利要求 1-3任一项所述的稳定热插拔驱动方法, 其中, 所述对 所述端口进行扫描处理包括调用设备扫描函数进行端口扫描处理。 4. The stable hot-plug driving method according to any one of claims 1 to 3, wherein the scanning of the port includes calling a device scan function to perform port scanning.
5、 如权利要求 1-3任一项所述的稳定热插拔驱动方法, 其中, 所述检 所处的状态。 5. The stable hot-swappable driving method according to any one of claims 1-3, wherein the state of the detected device is detected.
6、 如权利要求 5所述的稳定热插拔驱动方法, 其中, 所述支持热插拔 设备包括存储散盘, 移动硬盘, 通用串行总线 USB接口的鼠标或手机。 6. The stable hot-swappable driving method according to claim 5, wherein the hot-swappable device includes a storage disk, a mobile hard disk, a mouse or a mobile phone with a Universal Serial Bus USB interface.
7、一种稳定热插拔驱动装置, 包括: 检测模块,延时模块和处理模块; 所述检测模块设置为:检测插有可支持热插拔设备的端口所处的状态; 所述延时模块设置为: 当检测模块检测到所述端口所处的状态为插入, 则延迟一定时间; 7. A stable hot-swap driving device, including: a detection module, a delay module and a processing module; the detection module is configured to: detect the state of a port that is inserted with a device that can support hot-swapping; the delay The module is set as follows: when the detection module detects that the state of the port is plugged in, it delays for a certain period of time;
所述处理模块设置为: 待延时模块延迟一定时间结束后对所述端口进 行扫描处理。 The processing module is configured to scan the port after the delay module delays for a certain period of time.
8、 如权利要求 7所述的稳定热插拔驱动装置, 其中, 所述延时模块是 设置为当检测模块检测到所述端口所处的状态为插入, 则延迟大于等于 2 秒的时间。 8. The stable hot-swappable drive device according to claim 7, wherein the delay module is configured to delay for a time greater than or equal to 2 seconds when the detection module detects that the state of the port is plugged in.
9、 如权利要求 7所述的稳定热插拔驱动装置, 其中, 所述检测模块还 包括扫描模块; 所述扫描模块设置为: 当检测模块检测到所述端口所处的 状态为拔出时, 则立即对所述端口进行扫描处理。 9. The stable hot-swappable drive device according to claim 7, wherein the detection module further includes a scanning module; the scanning module is configured to: when the detection module detects that the state of the port is unplugged , then the port will be scanned immediately.
10、 一种支持热插拔的设备, 包括存储器, 处理器, 以及端口; 所述存储器设置为存储设置的延迟时间; 10. A device that supports hot plugging, including a memory, a processor, and a port; the memory is set to store a set delay time;
所述处理器设置为: 检测插有可支持热插拔设备的端口所处的状态, 当检测到的所述端口所处的状态为插入, 则延迟存储器中设置的所述延迟 时间后对所述端口进行扫描处理。 The processor is configured to: detect the state of a port that is plugged into a device that supports hot-swappable devices; when the detected state of the port is plugged in, delay the delay time set in the memory and then The port mentioned above is scanned.
11、 如权利要求 10所述的设备, 其中, 11. The device of claim 10, wherein,
所述处理器还设置为: 当检测模块检测到所述端口所处的状态为拔出 时, 则立即对所述端口进行扫描处理。 The processor is further configured to: when the detection module detects that the state of the port is unplugged, immediately scan the port.
12、 如权利要求 10所述的设备, 其中, 12. The device of claim 10, wherein,
所述存储器存储设置的延迟时间大于等于 2秒。 The delay time of the memory storage setting is greater than or equal to 2 seconds.
PCT/CN2014/086094 2014-03-21 2014-09-09 Stable hot plugging driving method and apparatus and hot plugging-supporting equipment WO2015139431A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410108441.3A CN104932993A (en) 2014-03-21 2014-03-21 Stable hot plug driving method and apparatus as well as hot plugging supporting device
CN201410108441.3 2014-03-21

Publications (1)

Publication Number Publication Date
WO2015139431A1 true WO2015139431A1 (en) 2015-09-24

Family

ID=54120164

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/086094 WO2015139431A1 (en) 2014-03-21 2014-09-09 Stable hot plugging driving method and apparatus and hot plugging-supporting equipment

Country Status (2)

Country Link
CN (1) CN104932993A (en)
WO (1) WO2015139431A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106844119A (en) * 2017-01-25 2017-06-13 郑州云海信息技术有限公司 A kind of detection method of equipment, device and system
CN109284245A (en) * 2017-07-21 2019-01-29 中兴通讯股份有限公司 A kind of hot-plug method based on SRIO, device, equipment and storage medium
CN107704209A (en) * 2017-10-26 2018-02-16 郑州云海信息技术有限公司 A kind of disk scanning method, system, equipment and computer-readable storage medium
CN111581144B (en) * 2020-03-24 2022-02-08 惠州市德赛西威智能交通技术研究院有限公司 Vehicle-mounted camera hot-plug self-recovery method and device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1459691A (en) * 2002-05-24 2003-12-03 英业达股份有限公司 Hot connect disconnect protecting device of hard disk
CN1873632A (en) * 2005-06-03 2006-12-06 英业达股份有限公司 Identification system and method for hot plug peripheral unit
CN101799715A (en) * 2010-03-18 2010-08-11 中兴通讯股份有限公司 Device for power protection against hot-plug function of hard disk interface and implementation method thereof

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7673090B2 (en) * 2001-12-19 2010-03-02 Intel Corporation Hot plug interface control method and apparatus
CN103019619B (en) * 2012-11-28 2016-06-08 浙江宇视科技有限公司 A kind of disk plug control method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1459691A (en) * 2002-05-24 2003-12-03 英业达股份有限公司 Hot connect disconnect protecting device of hard disk
CN1873632A (en) * 2005-06-03 2006-12-06 英业达股份有限公司 Identification system and method for hot plug peripheral unit
CN101799715A (en) * 2010-03-18 2010-08-11 中兴通讯股份有限公司 Device for power protection against hot-plug function of hard disk interface and implementation method thereof

Also Published As

Publication number Publication date
CN104932993A (en) 2015-09-23

Similar Documents

Publication Publication Date Title
US7613862B2 (en) Embedded driver for bus-connected device
US8266371B2 (en) Non-volatile storage device, host device, non-volatile storage system, data recording method, and program
WO2015139431A1 (en) Stable hot plugging driving method and apparatus and hot plugging-supporting equipment
CN107844165A (en) Hard disk hot-plug realization device
US8069282B2 (en) SD switch box in a cellular handset
US20050033917A1 (en) Computer system including a card medium controller and control method
US8527667B2 (en) Apparatuses and methods for transferring data
EP2990956B1 (en) Usb device and method thereof for automatically recognizing microsoft windowing operating system version
US8161214B2 (en) System and method for data transfer using ATA interface
TW201112131A (en) Controllers, apparatuses, and methods for transferring data
US11226757B2 (en) Hot plug memory device data protection method
US20100287616A1 (en) Controller capable of preventing spread of computer viruses and storage system and method thereof
CN103324445B (en) Method and system, USB storage device that USB storage device is run
TWI587147B (en) Method and device capable of automatically identifying host operating system
JP6693417B2 (en) Reader / writer device, information processing device, data transfer control method, and program
TW201734800A (en) Method for setting redundant array of independent disks
CN202268977U (en) Multimedia processor capable of automatically upgrading and vehicle-mounted entertainment system
US10684792B2 (en) Method and system for managing storage device of electronic device by alternative electronic device
US20040030821A1 (en) Portable and interface exchangeable storage system and method for executing the same
CN201654764U (en) Embedded download-free USB game client
CN100371916C (en) SCSI magnetic disc recording device and mehtod
JP5212289B2 (en) Information processing system, application program, and storage medium
EP1914628A1 (en) Method for changing booting sources of computer system and related backup/restore method thereof
KR20070033525A (en) Portable apparatus having function that send/receive data between portable apparatuses and data send/receive method thereof
TWI275998B (en) IDE apparatus hot-plug system and implementation method under Linux operating system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14885931

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14885931

Country of ref document: EP

Kind code of ref document: A1