The core qdev code uses the reset handler list from vl.c, and
currently *-user has some hacks to make CPU reset work.

This moves qemu_register_reset(), qemu_unregister_reset() and
qemu_devices_reset() to a new file, hw/reset.c, that can be used by qdev
and by *-user.

Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 hw/Makefile.objs     |  1 +
 hw/ac97.c            |  1 +
 hw/acpi_ich9.c       |  1 +
 hw/acpi_piix4.c      |  1 +
 hw/adb.c             |  1 +
 hw/arm_boot.c        |  1 +
 hw/armv7m.c          |  1 +
 hw/bonito.c          |  1 +
 hw/cirrus_vga.c      |  1 +
 hw/cris-boot.c       |  1 +
 hw/cs4231a.c         |  1 +
 hw/cuda.c            |  1 +
 hw/dma.c             |  1 +
 hw/dp8393x.c         |  1 +
 hw/eepro100.c        |  1 +
 hw/es1370.c          |  1 +
 hw/etraxfs_timer.c   |  1 +
 hw/gt64xxx.c         |  1 +
 hw/heathrow_pic.c    |  1 +
 hw/hw.h              |  5 -----
 hw/ide/cmd646.c      |  1 +
 hw/ide/macio.c       |  1 +
 hw/ide/mmio.c        |  1 +
 hw/ide/piix.c        |  1 +
 hw/ide/via.c         |  1 +
 hw/leon3.c           |  1 +
 hw/lm32_boards.c     |  1 +
 hw/lm832x.c          |  1 +
 hw/loader.c          |  1 +
 hw/mac_dbdma.c       |  1 +
 hw/mac_nvram.c       |  1 +
 hw/mc146818rtc.c     |  1 +
 hw/microblaze_boot.c |  1 +
 hw/milkymist.c       |  1 +
 hw/mips_fulong2e.c   |  1 +
 hw/mips_jazz.c       |  1 +
 hw/mips_malta.c      |  1 +
 hw/mips_mipssim.c    |  1 +
 hw/mips_r4k.c        |  1 +
 hw/nseries.c         |  1 +
 hw/omap1.c           |  1 +
 hw/omap2.c           |  1 +
 hw/openpic.c         |  1 +
 hw/openrisc_sim.c    |  1 +
 hw/parallel.c        |  1 +
 hw/pc.c              |  1 +
 hw/pckbd.c           |  1 +
 hw/piix4.c           |  1 +
 hw/piix_pci.c        |  1 +
 hw/ppc/e500.c        |  1 +
 hw/ppc405_boards.c   |  1 +
 hw/ppc405_uc.c       |  1 +
 hw/ppc440_bamboo.c   |  1 +
 hw/ppc4xx_devs.c     |  1 +
 hw/ppc4xx_pci.c      |  1 +
 hw/ppc_newworld.c    |  1 +
 hw/ppc_oldworld.c    |  1 +
 hw/ppc_prep.c        |  1 +
 hw/ppce500_spin.c    |  1 +
 hw/ps2.c             |  1 +
 hw/qdev.c            |  1 +
 hw/r2d.c             |  1 +
 hw/rc4030.c          |  1 +
 hw/reset.c           | 43 +++++++++++++++++++++++++++++++++++++++++++
 hw/reset.h           | 11 +++++++++++
 hw/s390-virtio-bus.c |  1 +
 hw/serial.c          |  1 +
 hw/spapr.c           |  1 +
 hw/sun4m.c           |  1 +
 hw/sun4u.c           |  1 +
 hw/tsc2005.c         |  1 +
 hw/tsc210x.c         |  1 +
 hw/usb/hcd-ehci.c    |  1 +
 hw/usb/hcd-ohci.c    |  1 +
 hw/usb/hcd-uhci.c    |  1 +
 hw/vga.c             |  1 +
 hw/virtex_ml507.c    |  1 +
 hw/vt82c686.c        |  1 +
 hw/xics.c            |  1 +
 hw/xtensa_lx60.c     |  1 +
 hw/xtensa_sim.c      |  1 +
 kvm-all.c            |  1 +
 sysemu.h             |  1 -
 target-i386/cpu.c    |  1 +
 target-i386/kvm.c    |  1 +
 vl.c                 | 41 +----------------------------------------
 xen-all.c            |  1 +
 87 files changed, 137 insertions(+), 46 deletions(-)
 create mode 100644 hw/reset.c
 create mode 100644 hw/reset.h

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..1dfed06 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -1,5 +1,6 @@
 common-obj-y = usb/ ide/
 common-obj-y += loader.o
+common-obj-y += reset.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
 common-obj-$(CONFIG_VIRTIO) += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
diff --git a/hw/ac97.c b/hw/ac97.c
index ce6a1dc..c37aaae 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -17,6 +17,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "audiodev.h"
 #include "audio/audio.h"
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 61034d3..fc2ff2c 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -22,6 +22,7 @@
  *
  *  This is based on acpi.c.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "pci.h"
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 519269a..a022180 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -18,6 +18,7 @@
  * Contributions after 2012-01-13 are licensed under the terms of the
  * GNU GPL, version 2 or (at your option) any later version.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "apm.h"
diff --git a/hw/adb.c b/hw/adb.c
index 3b547f0..5f3d6dc 100644
--- a/hw/adb.c
+++ b/hw/adb.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "adb.h"
 #include "console.h"
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 92e2cab..c608d1d 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -8,6 +8,7 @@
  */
 
 #include "config.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "arm-misc.h"
 #include "sysemu.h"
diff --git a/hw/armv7m.c b/hw/armv7m.c
index ce2ec9b..fca329c 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -7,6 +7,7 @@
  * This code is licensed under the GPL.
  */
 
+#include "hw/reset.h"
 #include "sysbus.h"
 #include "arm-misc.h"
 #include "loader.h"
diff --git a/hw/bonito.c b/hw/bonito.c
index 0bf6d4a..4080def 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -39,6 +39,7 @@
 
 #include <assert.h>
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pci.h"
 #include "pc.h"
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9bef96e..7e51cc4 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -26,6 +26,7 @@
  * Reference: Finn Thogersons' VGADOC4b
  *   available at http://home.worldonline.dk/~finth/
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pci.h"
 #include "console.h"
diff --git a/hw/cris-boot.c b/hw/cris-boot.c
index b21326f..fc0c64b 100644
--- a/hw/cris-boot.c
+++ b/hw/cris-boot.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "loader.h"
 #include "elf.h"
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 0257fd8..b54dfc1 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "audiodev.h"
 #include "audio/audio.h"
diff --git a/hw/cuda.c b/hw/cuda.c
index f1f408b..0e74501 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc_mac.h"
 #include "adb.h"
diff --git a/hw/dma.c b/hw/dma.c
index d6aeac2..0232ceb 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "isa.h"
 
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index 3f6386e..23fd09f 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -17,6 +17,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "qemu-timer.h"
 #include "net.h"
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a189474..0c3e0dd 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -41,6 +41,7 @@
  */
 
 #include <stddef.h>             /* offsetof */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pci.h"
 #include "net.h"
diff --git a/hw/es1370.c b/hw/es1370.c
index e0c9729..6c5466f 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -26,6 +26,7 @@
 /* #define VERBOSE_ES1370 */
 #define SILENT_ES1370
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "audiodev.h"
 #include "audio/audio.h"
diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c
index f5601dc..cea5e00 100644
--- a/hw/etraxfs_timer.c
+++ b/hw/etraxfs_timer.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "sysbus.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "qemu-timer.h"
 #include "ptimer.h"
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index 95d491d..ecda9f9 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "mips.h"
 #include "pci.h"
diff --git a/hw/heathrow_pic.c b/hw/heathrow_pic.c
index b9ec8e7..b0e1a9d 100644
--- a/hw/heathrow_pic.c
+++ b/hw/heathrow_pic.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc_mac.h"
 
diff --git a/hw/hw.h b/hw/hw.h
index f530f6f..fe057f0 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -37,11 +37,6 @@
 #endif
 #endif
 
-typedef void QEMUResetHandler(void *opaque);
-
-void qemu_register_reset(QEMUResetHandler *func, void *opaque);
-void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
-
 /* handler to set the boot_device order for a specific type of QEMUMachine */
 /* return 0 if success */
 typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 804db60..0666102 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -27,6 +27,7 @@
 #include <hw/pci.h>
 #include <hw/isa.h>
 #include "block.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "dma.h"
 
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index d2edcc0..9fe3a9f 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include <hw/hw.h>
 #include <hw/ppc_mac.h>
 #include <hw/mac_dbdma.h>
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index bcb26c8..4da8c6e 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include <hw/hw.h>
 #include "block.h"
 #include "dma.h"
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 9431bad..b6c910a 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -28,6 +28,7 @@
 #include <hw/pci.h>
 #include <hw/isa.h>
 #include "blockdev.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "dma.h"
 
diff --git a/hw/ide/via.c b/hw/ide/via.c
index efda173..9a5a991 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -28,6 +28,7 @@
 #include <hw/pci.h>
 #include <hw/isa.h>
 #include "block.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "dma.h"
 
diff --git a/hw/leon3.c b/hw/leon3.c
index 7742738..d944641 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "qemu-timer.h"
 #include "ptimer.h"
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 772cb8b..30ea613 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -18,6 +18,7 @@
  */
 
 #include "sysbus.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "net.h"
 #include "flash.h"
diff --git a/hw/lm832x.c b/hw/lm832x.c
index 8e09f9b..7f3fc0c 100644
--- a/hw/lm832x.c
+++ b/hw/lm832x.c
@@ -18,6 +18,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "i2c.h"
 #include "qemu-timer.h"
diff --git a/hw/loader.c b/hw/loader.c
index ba01ca6..dafbda4 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -42,6 +42,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "disas.h"
 #include "monitor.h"
diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c
index e551156..e1f876f 100644
--- a/hw/mac_dbdma.c
+++ b/hw/mac_dbdma.c
@@ -36,6 +36,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "isa.h"
 #include "mac_dbdma.h"
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index a0d14dd..90c848d 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "firmware_abi.h"
 #include "sysemu.h"
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index c79fca7..5899be1 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "qemu-timer.h"
 #include "sysemu.h"
diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c
index 02c349c..933a677 100644
--- a/hw/microblaze_boot.c
+++ b/hw/microblaze_boot.c
@@ -28,6 +28,7 @@
 #include "qemu-config.h"
 #include "qemu-common.h"
 #include "device_tree.h"
+#include "hw/reset.h"
 #include "loader.h"
 #include "elf.h"
 
diff --git a/hw/milkymist.c b/hw/milkymist.c
index 4c8111a..25eb0b8 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -18,6 +18,7 @@
  */
 
 #include "sysbus.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "net.h"
 #include "flash.h"
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 5fcf900..f14318f 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -18,6 +18,7 @@
  * http://www.loongsondeveloper.com/doc/Loongson2EUserGuide.pdf
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "serial.h"
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 0847427..8e31187 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "mips.h"
 #include "mips_cpudevs.h"
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 4d2464a..8f96918 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "serial.h"
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index a95a3c1..1a7d3f6 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -24,6 +24,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "mips.h"
 #include "mips_cpudevs.h"
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 325098a..a9c7a0f 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -7,6 +7,7 @@
  * All peripherial devices are attached to this "bus" with
  * the standard PC ISA addresses.
 */
+#include "hw/reset.h"
 #include "hw.h"
 #include "mips.h"
 #include "mips_cpudevs.h"
diff --git a/hw/nseries.c b/hw/nseries.c
index 2de8d21..5604e7c 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -28,6 +28,7 @@
 #include "i2c.h"
 #include "devices.h"
 #include "flash.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "bt.h"
 #include "loader.h"
diff --git a/hw/omap1.c b/hw/omap1.c
index 4d5815e..a5bac74 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -16,6 +16,7 @@
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "arm-misc.h"
 #include "omap.h"
diff --git a/hw/omap2.c b/hw/omap2.c
index 96aba71..10b0a1a 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -19,6 +19,7 @@
  */
 
 #include "blockdev.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "arm-misc.h"
 #include "omap.h"
diff --git a/hw/openpic.c b/hw/openpic.c
index 8b3784a..633a47a 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -33,6 +33,7 @@
  * Serial interrupts, as implemented in Raven chipset are not supported yet.
  *
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc_mac.h"
 #include "pci.h"
diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c
index 23c66df..74b0594 100644
--- a/hw/openrisc_sim.c
+++ b/hw/openrisc_sim.c
@@ -18,6 +18,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "boards.h"
 #include "elf.h"
diff --git a/hw/parallel.c b/hw/parallel.c
index c4705bc..ba17a4e 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -22,6 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "qemu-char.h"
 #include "isa.h"
diff --git a/hw/pc.c b/hw/pc.c
index 2b5bbbf..5f08c5e 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "serial.h"
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 5bb3e0a..6116b58 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "isa.h"
 #include "pc.h"
diff --git a/hw/piix4.c b/hw/piix4.c
index ce4eb0d..eb4d918 100644
--- a/hw/piix4.c
+++ b/hw/piix4.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "pci.h"
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index ba1b3de..e9c3b3b 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "pci.h"
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 6749fff..53f980a 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -18,6 +18,7 @@
 #include "qemu-common.h"
 #include "e500.h"
 #include "net.h"
+#include "hw/reset.h"
 #include "hw/hw.h"
 #include "hw/serial.h"
 #include "hw/pci.h"
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index 8dc693f..421cdc3 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc405.h"
diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c
index 0f458ef..3cd0e5b 100644
--- a/hw/ppc405_uc.c
+++ b/hw/ppc405_uc.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc405.h"
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index cc85607..29d000b 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -14,6 +14,7 @@
 #include "config.h"
 #include "qemu-common.h"
 #include "net.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "pci.h"
 #include "boards.h"
diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c
index bac8d87..4fbf2f7 100644
--- a/hw/ppc4xx_devs.c
+++ b/hw/ppc4xx_devs.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc4xx.h"
diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
index d3ad6a0..a8f4b54 100644
--- a/hw/ppc4xx_pci.c
+++ b/hw/ppc4xx_pci.c
@@ -19,6 +19,7 @@
 /* This file implements emulation of the 32-bit PCI controller found in some
  * 4xx SoCs, such as the 440EP. */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc4xx.h"
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 664747e..dbe705e 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -46,6 +46,7 @@
  * 0001:05:0c.0 IDE interface [0101]: Broadcom K2 SATA [1166:0240]
  *
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc_mac.h"
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index e8138c0..dcb45a6 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -23,6 +23,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ppc.h"
 #include "ppc_mac.h"
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index bf15730..02ab5e3 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "nvram.h"
 #include "pc.h"
diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
index c1a155b..d6435d1 100644
--- a/hw/ppce500_spin.c
+++ b/hw/ppce500_spin.c
@@ -27,6 +27,7 @@
  *
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "sysemu.h"
 #include "sysbus.h"
diff --git a/hw/ps2.c b/hw/ps2.c
index f93cd24..c1b441d 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "ps2.h"
 #include "console.h"
diff --git a/hw/qdev.c b/hw/qdev.c
index 599382c..15b967d 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -27,6 +27,7 @@
 
 #include "net.h"
 #include "qdev.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "error.h"
 #include "qapi/qapi-visit-core.h"
diff --git a/hw/r2d.c b/hw/r2d.c
index 66212e9..9ce2a8c 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -24,6 +24,7 @@
  */
 
 #include "sysbus.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "sh.h"
 #include "devices.h"
diff --git a/hw/rc4030.c b/hw/rc4030.c
index e0024c8..d175cf2 100644
--- a/hw/rc4030.c
+++ b/hw/rc4030.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "mips.h"
 #include "qemu-timer.h"
diff --git a/hw/reset.c b/hw/reset.c
new file mode 100644
index 0000000..5e34b80
--- /dev/null
+++ b/hw/reset.c
@@ -0,0 +1,43 @@
+#include "hw/reset.h"
+#include "qlist.h"
+
+typedef struct QEMUResetEntry {
+    QTAILQ_ENTRY(QEMUResetEntry) entry;
+    QEMUResetHandler *func;
+    void *opaque;
+} QEMUResetEntry;
+
+static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
+    QTAILQ_HEAD_INITIALIZER(reset_handlers);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque)
+{
+    QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
+
+    re->func = func;
+    re->opaque = opaque;
+    QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
+}
+
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
+{
+    QEMUResetEntry *re;
+
+    QTAILQ_FOREACH(re, &reset_handlers, entry) {
+        if (re->func == func && re->opaque == opaque) {
+            QTAILQ_REMOVE(&reset_handlers, re, entry);
+            g_free(re);
+            return;
+        }
+    }
+}
+
+void qemu_devices_reset(void)
+{
+    QEMUResetEntry *re, *nre;
+
+    /* reset all devices */
+    QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
+        re->func(re->opaque);
+    }
+}
diff --git a/hw/reset.h b/hw/reset.h
new file mode 100644
index 0000000..fce4066
--- /dev/null
+++ b/hw/reset.h
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev and other code */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index e0ac2d1..699e07f 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "block.h"
 #include "sysemu.h"
diff --git a/hw/serial.c b/hw/serial.c
index 60283ea..0254e1b 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -27,6 +27,7 @@
 #include "qemu-char.h"
 #include "qemu-timer.h"
 #include "exec-memory.h"
+#include "hw/reset.h"
 
 //#define DEBUG_SERIAL
 
diff --git a/hw/spapr.c b/hw/spapr.c
index ad3f0ea..97ca1e6 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -25,6 +25,7 @@
  *
  */
 #include "sysemu.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "elf.h"
 #include "net.h"
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 1a78676..e3e5958 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -27,6 +27,7 @@
 #include "nvram.h"
 #include "sparc32_dma.h"
 #include "fdc.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "net.h"
 #include "boards.h"
diff --git a/hw/sun4u.c b/hw/sun4u.c
index b2b51e3..e263e8e 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "pci.h"
 #include "apb_pci.h"
diff --git a/hw/tsc2005.c b/hw/tsc2005.c
index 9a500eb..f7a892d 100644
--- a/hw/tsc2005.c
+++ b/hw/tsc2005.c
@@ -18,6 +18,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "qemu-timer.h"
 #include "console.h"
diff --git a/hw/tsc210x.c b/hw/tsc210x.c
index 3c448a6..4e3ea2d 100644
--- a/hw/tsc210x.c
+++ b/hw/tsc210x.c
@@ -19,6 +19,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "audio/audio.h"
 #include "qemu-timer.h"
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 7df8e21..71e243f 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -28,6 +28,7 @@
  */
 
 #include "hw/usb/hcd-ehci.h"
+#include "hw/reset.h"
 
 /* Capability Registers Base Address - section 2.2 */
 #define CAPLENGTH        0x0000  /* 1-byte, 0x0001 reserved */
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 64de906..ac75bbf 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -26,6 +26,7 @@
  *  o BIOS work to boot from USB storage
 */
 
+#include "hw/reset.h"
 #include "hw/hw.h"
 #include "qemu-timer.h"
 #include "hw/usb.h"
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 8e47803..b5437c8 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -25,6 +25,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw/hw.h"
 #include "hw/usb.h"
 #include "hw/pci.h"
diff --git a/hw/vga.c b/hw/vga.c
index 2b0200a..23f0aea 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -21,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "hw/reset.h"
 #include "hw.h"
 #include "vga.h"
 #include "console.h"
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index 6ab8fee..ba07f25 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -23,6 +23,7 @@
  */
 
 #include "sysbus.h"
+#include "hw/reset.h"
 #include "hw.h"
 #include "serial.h"
 #include "net.h"
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 5d7c00c..671322d 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -10,6 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "pc.h"
 #include "vt82c686.h"
diff --git a/hw/xics.c b/hw/xics.c
index 1da3106..673c8aa 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include "hw/reset.h"
 #include "hw.h"
 #include "hw/spapr.h"
 #include "hw/xics.h"
diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c
index 4c42edc..39b0d67 100644
--- a/hw/xtensa_lx60.c
+++ b/hw/xtensa_lx60.c
@@ -25,6 +25,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "boards.h"
 #include "loader.h"
diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c
index 0d633e4..c30efc8 100644
--- a/hw/xtensa_sim.c
+++ b/hw/xtensa_sim.c
@@ -25,6 +25,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "boards.h"
 #include "loader.h"
diff --git a/kvm-all.c b/kvm-all.c
index 8e9a8d8..9a3010c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -25,6 +25,7 @@
 #include "qemu-option.h"
 #include "qemu-config.h"
 #include "sysemu.h"
+#include "hw/reset.h"
 #include "hw/hw.h"
 #include "hw/msi.h"
 #include "gdbstub.h"
diff --git a/sysemu.h b/sysemu.h
index ab1ef8b..51f19cc 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -57,7 +57,6 @@ void qemu_system_vmstop_request(RunState reason);
 int qemu_shutdown_requested_get(void);
 int qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
-void qemu_devices_reset(void);
 void qemu_system_reset(bool report);
 
 void qemu_add_exit_notifier(Notifier *notify);
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c6c2ca0..483a6fc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -32,6 +32,7 @@
 
 #include "hyperv.h"
 
+#include "hw/reset.h"
 #include "hw/hw.h"
 #if defined(CONFIG_KVM)
 #include <linux/kvm_para.h>
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f669281..5f43232 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -21,6 +21,7 @@
 #include <linux/kvm_para.h>
 
 #include "qemu-common.h"
+#include "hw/reset.h"
 #include "sysemu.h"
 #include "kvm.h"
 #include "kvm_i386.h"
diff --git a/vl.c b/vl.c
index a3ab384..e053e6a 100644
--- a/vl.c
+++ b/vl.c
@@ -113,6 +113,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "hw/reset.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/usb.h"
@@ -1457,14 +1458,6 @@ void vm_start(void)
 
 /* reset/shutdown handler */
 
-typedef struct QEMUResetEntry {
-    QTAILQ_ENTRY(QEMUResetEntry) entry;
-    QEMUResetHandler *func;
-    void *opaque;
-} QEMUResetEntry;
-
-static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
-    QTAILQ_HEAD_INITIALIZER(reset_handlers);
 static int reset_requested;
 static int shutdown_requested, shutdown_signal = -1;
 static pid_t shutdown_pid;
@@ -1561,38 +1554,6 @@ static bool qemu_vmstop_requested(RunState *r)
     return false;
 }
 
-void qemu_register_reset(QEMUResetHandler *func, void *opaque)
-{
-    QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
-
-    re->func = func;
-    re->opaque = opaque;
-    QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
-}
-
-void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
-{
-    QEMUResetEntry *re;
-
-    QTAILQ_FOREACH(re, &reset_handlers, entry) {
-        if (re->func == func && re->opaque == opaque) {
-            QTAILQ_REMOVE(&reset_handlers, re, entry);
-            g_free(re);
-            return;
-        }
-    }
-}
-
-void qemu_devices_reset(void)
-{
-    QEMUResetEntry *re, *nre;
-
-    /* reset all devices */
-    QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
-        re->func(re->opaque);
-    }
-}
-
 void qemu_system_reset(bool report)
 {
     if (current_machine && current_machine->reset) {
diff --git a/xen-all.c b/xen-all.c
index 046cc2a..7d2a79f 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -14,6 +14,7 @@
 #include "hw/pc.h"
 #include "hw/xen_common.h"
 #include "hw/xen_backend.h"
+#include "hw/reset.h"
 #include "qmp-commands.h"
 
 #include "range.h"
-- 
1.7.11.7


Reply via email to