]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
pre-exit callback
authorToni Wilen <twilen@winuae.net>
Sun, 17 Sep 2023 08:09:17 +0000 (11:09 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 17 Sep 2023 08:09:17 +0000 (11:09 +0300)
18 files changed:
a2065.cpp
a2091.cpp
akiko.cpp
cd32_fmv.cpp
cdtv.cpp
cdtvcr.cpp
devices.cpp
gayle.cpp
idecontrollers.cpp
include/devices.h
ncr9x_scsi.cpp
ncr_scsi.cpp
od-win32/picasso96_win.cpp
pci.cpp
qemuvga/ne2000.cpp
scsi.cpp
sndboard.cpp
x86.cpp

index a27cb9b5697c22d1fbe9645c30417ec36c0d8677..eb0d16cad844b01641cbef060d37039650fc6815 100644 (file)
--- a/a2065.cpp
+++ b/a2065.cpp
@@ -1153,7 +1153,7 @@ static bool a2065_config (struct autoconfig_info *aci)
 
        device_add_hsync(a2065_hsync_handler);
        device_add_rethink(rethink_a2065);
-       device_add_exit(a2065_free);
+       device_add_exit(a2065_free, NULL);
 
        return true;
 }
index 999197558e88c66750035b2594b052c329994772..fb76d981911fb085a33ad1e6656bbd0f101ed893 100644 (file)
--- a/a2091.cpp
+++ b/a2091.cpp
@@ -4567,9 +4567,9 @@ static void wd_init(void)
 {
        device_add_hsync(scsi_hsync);
        device_add_rethink(rethink_a2091);
-       device_add_exit(a2091_free);
-       device_add_exit(gvp_free);
-       device_add_exit(a3000scsi_free);
+       device_add_exit(a2091_free, NULL);
+       device_add_exit(gvp_free, NULL);
+       device_add_exit(a3000scsi_free, NULL);
 }
 
 #if 0
index 06b34c1e77f1cc91fbcd8f4516795f53494ae0c0..c988bef99a5da89f7adb33777fc8242fad2836b7 100644 (file)
--- a/akiko.cpp
+++ b/akiko.cpp
@@ -2154,7 +2154,7 @@ int akiko_init(void)
                device_add_rethink(rethink_akiko);
        }
 
-       device_add_exit(akiko_free);
+       device_add_exit(akiko_free, NULL);
 
        return 1;
 }
index 0c69f00f0e779a6e0440593df9bc79e90f6cf6c1..4f693f0b12ac4d3518d8f82da60ad47ee7cdb99e 100644 (file)
@@ -1585,7 +1585,7 @@ addrbank *cd32_fmv_init (struct autoconfig_info *aci)
 
        device_add_hsync(cd32_fmv_hsync_handler);
        device_add_vsync_pre(cd32_fmv_vsync_handler);
-       device_add_exit(cd32_fmv_free);
+       device_add_exit(cd32_fmv_free, NULL);
        device_add_rethink(rethink_cd32fmv);
 
        return &fmv_rom_bank;
index 86e44ae08dc22c67df0779409815ddf2abee91da..af7ab11a05c71326392fa61cb10a488782d76047 100644 (file)
--- a/cdtv.cpp
+++ b/cdtv.cpp
@@ -1760,7 +1760,7 @@ bool cdtv_init(struct autoconfig_info *aci)
 
        device_add_hsync(CDTV_hsync_handler);
        device_add_rethink(rethink_cdtv);
-       device_add_exit(cdtv_free);
+       device_add_exit(cdtv_free, NULL);
 
        return true;
 }
index 43ff29655b2604bef5fcc7d40c24db7825d6b11b..738c4426ccb142cbf64eb05ea2a679bfd26e672b 100644 (file)
@@ -1043,7 +1043,7 @@ bool cdtvcr_init(struct autoconfig_info *aci)
 
        device_add_hsync(CDTVCR_hsync_handler);
        device_add_rethink(rethink_cdtvcr);
-       device_add_exit(cdtvcr_free);
+       device_add_exit(cdtvcr_free, NULL);
 
        return true;
 }
index f527fa68b8352cd5881cae2f8d3ce0b48e81b54d..1473677eddcd01ac44b104ab7f1ae790a96bda8a 100644 (file)
@@ -96,6 +96,8 @@ static int device_rethink_cnt;
 static DEVICE_VOID device_rethinks[MAX_DEVICE_ITEMS];
 static int device_leave_cnt;
 static DEVICE_VOID device_leaves[MAX_DEVICE_ITEMS];
+static int device_leave_early_cnt;
+static DEVICE_VOID device_leaves_early[MAX_DEVICE_ITEMS];
 static int device_resets_cnt;
 static DEVICE_INT device_resets[MAX_DEVICE_ITEMS];
 static bool device_reset_done[MAX_DEVICE_ITEMS];
@@ -109,6 +111,7 @@ static void reset_device_items(void)
        device_rethink_cnt = 0;
        device_resets_cnt = 0;
        device_leave_cnt = 0;
+       device_leave_early_cnt = 0;
        memset(device_reset_done, 0, sizeof(device_reset_done));
 }
 
@@ -132,9 +135,14 @@ void device_add_check_config(DEVICE_VOID p)
 {
        add_device_item(device_configs, &device_configs_cnt, p);
 }
-void device_add_exit(DEVICE_VOID p)
+void device_add_exit(DEVICE_VOID p, DEVICE_VOID p2)
 {
-       add_device_item(device_leaves, &device_leave_cnt, p);
+       if (p != NULL) {
+               add_device_item(device_leaves, &device_leave_cnt, p);
+       }
+       if (p2 != NULL) {
+               add_device_item(device_leaves_early, &device_leave_early_cnt, p2);
+       }
 }
 void device_add_reset(DEVICE_INT p)
 {
@@ -308,6 +316,9 @@ void virtualdevice_free(void)
        // must be first
        uae_ppc_free();
 #endif
+
+       execute_device_items(device_leaves_early, device_leave_early_cnt);
+
 #ifdef FILESYS
        filesys_cleanup();
 #endif
index 4db68d1a945a492c15cdfa375dc626000c36aa3d..312d221040d7c4e546b14056f6634897c0097f2c 100644 (file)
--- a/gayle.cpp
+++ b/gayle.cpp
@@ -2207,7 +2207,7 @@ static void gayle_init(void)
        device_add_check_config(check_prefs_changed_gayle);
        device_add_rethink(rethink_gayle);
        device_add_hsync(gayle_hsync);
-       device_add_exit(gayle_free);
+       device_add_exit(gayle_free, NULL);
 }
 
 uae_u8 *save_gayle(size_t *len, uae_u8 *dstptr)
index 4d4b4d275628cefe717d49e8d780326b94fcf18c..c65e4a0714ba3cde9dfac965f020123d4d6d5630 100644 (file)
@@ -1974,7 +1974,7 @@ static struct ide_board *getide(struct autoconfig_info *aci)
 {
        device_add_rethink(idecontroller_rethink);
        device_add_hsync(idecontroller_hsync);
-       device_add_exit(idecontroller_free);
+       device_add_exit(idecontroller_free, NULL);
 
        for (int i = 0; i < MAX_IDE_UNITS; i++) {
                if (ide_boards[i]) {
index 0df38e310825aad8e9a12146968a26b5d31bb5f8..75c7690447ec13a3f2b746e464bfd4574704c736 100644 (file)
@@ -30,7 +30,7 @@ void device_add_rethink(DEVICE_VOID p);
 void device_add_check_config(DEVICE_VOID p);
 void device_add_reset(DEVICE_INT p);
 void device_add_reset_imm(DEVICE_INT p);
-void device_add_exit(DEVICE_VOID p);
+void device_add_exit(DEVICE_VOID p, DEVICE_VOID p2);
 
 #define IRQ_SOURCE_PCI 0
 #define IRQ_SOURCE_SOUND 1
index bd9a0768f1d5bad84d529e40c2c497e078aec2c6..a90bce2d64dfca568d287d8a729732920b881d67 100644 (file)
@@ -1931,7 +1931,7 @@ static void ncr9x_reset_board(struct ncr9x_state *ncr)
 
        device_add_rethink(ncr9x_rethink);
        device_add_reset(ncr9x_reset);
-       device_add_exit(ncr9x_free);
+       device_add_exit(ncr9x_free, NULL);
 }
 
 void ncr_squirrel_init(struct romconfig *rc, uaecptr baseaddress)
index de5332bdb258a96eacb8ec00fa8bec0227567ae2..d84c1ceb6b47a5ab50da0828eaa1fb97b94a52e4 100644 (file)
@@ -872,7 +872,7 @@ static void ncr_reset_board (struct ncr_state *ncr)
        ncr->irq = false;
 
        device_add_rethink(ncr_rethink);
-       device_add_exit(ncr_free);
+       device_add_exit(ncr_free, NULL);
        device_add_vsync_pre(ncr_vsync);
        device_add_reset(ncr_reset);
 }
index a2e7a5807a7a04f144d78983ae9b90037c6bc2c1..ad7759dac2105bf660232ab0259d89fe85b4c4ed 100644 (file)
@@ -6659,7 +6659,7 @@ void uaegfx_install_code (uaecptr start)
 
        device_add_reset(picasso_reset);
        device_add_hsync(picasso_handle_hsync);
-       device_add_exit(picasso_free);
+       device_add_exit(picasso_free, NULL);
 }
 
 #define UAEGFX_VERSION 3
diff --git a/pci.cpp b/pci.cpp
index 2835fdeadeb292442ef8495f8a34a3d875e860ea..60d643e9c34df4b7b94e9f41292f1f9acb14ae67 100644 (file)
--- a/pci.cpp
+++ b/pci.cpp
@@ -1768,7 +1768,7 @@ static void pci_init(void)
 {
        device_add_reset(pci_reset);
        device_add_rethink(pci_rethink);
-       device_add_exit(pci_free);
+       device_add_exit(pci_free, NULL);
        device_add_hsync(pci_hsync);
 }
 
index a2a60ac0f642b806d09ebb0c43136afeaacfbcbb..dbfe3598db0d2a3957436756e01854ed6ffcffaa 100644 (file)
@@ -1947,7 +1947,7 @@ static void ne2000_free(void)
 
 static void init(void)
 {
-       device_add_exit(ne2000_free);
+       device_add_exit(ne2000_free, NULL);
        device_add_reset(ne2000_reset);
        device_add_hsync(ne2000_hsync);
        device_add_rethink(rethink_ne2000);
index 176eebb8d87746285c2e017e6935e405bb2d34f6..c431fe28fc732e327d90eb5fb340a01a23215d94 100644 (file)
--- a/scsi.cpp
+++ b/scsi.cpp
@@ -4327,7 +4327,7 @@ static struct soft_scsi *getscsi(struct romconfig *rc)
 {
        device_add_rethink(ncr80_rethink);
        device_add_reset(soft_scsi_reset);
-       device_add_exit(soft_scsi_free);
+       device_add_exit(soft_scsi_free, NULL);
        if (rc->unitdata)
                return (struct soft_scsi *)rc->unitdata;
        return NULL;
index 2fdb8a46a792302b68d8b1a480e12ad692322f99..7a6cdbdba135d1876376bbf248335c018afc3047 100644 (file)
@@ -3002,8 +3002,8 @@ static void snd_init(void)
        device_add_hsync(sndboard_hsync);
        device_add_vsync_post(sndboard_vsync);
        device_add_rethink(sndboard_rethink);
-       device_add_exit(sndboard_free);
-       device_add_exit(uaesndboard_free);
+       device_add_exit(sndboard_free, NULL);
+       device_add_exit(uaesndboard_free, NULL);
 }
 
 
diff --git a/x86.cpp b/x86.cpp
index 1505a35f7d7d804cb2ce0c1f086a3fb30029805c..6093e10730d3705fd96dc943c4ddc39ab36f7c42 100644 (file)
--- a/x86.cpp
+++ b/x86.cpp
@@ -3854,7 +3854,7 @@ bool x86_bridge_init(struct autoconfig_info *aci, uae_u32 romtype, int type)
 
        device_add_hsync(x86_bridge_hsync);
        device_add_vsync_pre(x86_bridge_vsync);
-       device_add_exit(x86_bridge_free);
+       device_add_exit(x86_bridge_free, NULL);
        device_add_rethink(x86_bridge_rethink);
 
        return true;