Changeset 24019 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 23, 2009 10:14:27 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r24010 r24019 42 42 } 43 43 44 #define SB16_SSM_VERSION 145 46 44 #ifndef VBOX 47 45 … … 60 58 61 59 #else /* VBOX */ 60 61 /** Current saved state version. */ 62 #define SB16_SAVE_STATE_VERSION 2 63 /** The version used in VirtualBox version 3.0 and earlier. This didn't include 64 * the config dump. */ 65 #define SB16_SAVE_STATE_VERSION_VBOX_30 1 62 66 63 67 DECLINLINE(void) dolog (const char *fmt, ...) … … 122 126 #ifndef VBOX 123 127 qemu_irq *pic; 128 #endif 129 #ifdef VBOX /* lazy bird */ 130 int irqCfg; 131 int dmaCfg; 132 int hdmaCfg; 133 int portCfg; 134 int verCfg; 124 135 #endif 125 136 int irq; … … 1477 1488 } 1478 1489 1479 #ifndef VBOX1480 1490 static void SB_save (QEMUFile *f, void *opaque) 1481 1491 { 1492 #ifndef VBOX 1482 1493 SB16State *s = opaque; 1483 1494 #else 1484 static DECLCALLBACK(int) sb16SaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 1485 { 1486 SB16State *s = PDMINS_2_DATA (pDevIns, SB16State *); 1487 QEMUFile *f = pSSMHandle; 1495 SB16State *s = (SB16State *)opaque; 1488 1496 #endif 1489 1497 … … 1535 1543 qemu_put_be32 (f, s->mixer_nreg); 1536 1544 qemu_put_buffer (f, s->mixer_regs, 256); 1537 1538 #ifdef VBOX 1539 return VINF_SUCCESS; 1540 #endif 1541 } 1542 1543 #ifndef VBOX 1545 } 1546 1544 1547 static int SB_load (QEMUFile *f, void *opaque, int version_id) 1545 1548 { 1549 #ifndef VBOX 1546 1550 SB16State *s = opaque; 1547 1551 … … 1549 1553 return -EINVAL; 1550 1554 } 1551 #else /* VBOX */ 1552 static DECLCALLBACK(int) sb16LoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, 1553 uint32_t uVersion, uint32_t uPass) 1554 { 1555 SB16State *s = PDMINS_2_DATA (pDevIns, SB16State *); 1556 QEMUFile *f = pSSMHandle; 1557 1558 AssertMsgReturn(uVersion == SB16_SSM_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 1559 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 1560 #endif /* VBOX */ 1555 #else 1556 SB16State *s = (SB16State *)opaque; 1557 #endif 1561 1558 1562 1559 s->irq=qemu_get_be32 (f); … … 1565 1562 s->port=qemu_get_be32 (f); 1566 1563 s->ver=qemu_get_be32 (f); 1567 1568 1564 s->in_index=qemu_get_be32 (f); 1569 1565 s->out_data_len=qemu_get_be32 (f); … … 1709 1705 #else /* VBOX */ 1710 1706 1707 1708 static DECLCALLBACK(int) sb16LiveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 1709 { 1710 SB16State *pThis = PDMINS_2_DATA (pDevIns, SB16State *); 1711 1712 SSMR3PutS32(pSSM, pThis->irqCfg); 1713 SSMR3PutS32(pSSM, pThis->dmaCfg); 1714 SSMR3PutS32(pSSM, pThis->hdmaCfg); 1715 SSMR3PutS32(pSSM, pThis->portCfg); 1716 SSMR3PutS32(pSSM, pThis->verCfg); 1717 return VINF_SSM_DONT_CALL_AGAIN; 1718 } 1719 1720 static DECLCALLBACK(int) sb16SaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1721 { 1722 SB16State *pThis = PDMINS_2_DATA (pDevIns, SB16State *); 1723 1724 sb16LiveExec (pDevIns, pSSM, 0); 1725 SB_save (pSSM, pThis); 1726 return VINF_SUCCESS; 1727 } 1728 1729 static DECLCALLBACK(int) sb16LoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, 1730 uint32_t uVersion, uint32_t uPass) 1731 { 1732 SB16State *pThis = PDMINS_2_DATA (pDevIns, SB16State *); 1733 1734 AssertMsgReturn( uVersion == SB16_SAVE_STATE_VERSION 1735 || uVersion == SB16_SAVE_STATE_VERSION_VBOX_30, 1736 ("%u\n", uVersion), 1737 VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 1738 if (uVersion > SB16_SAVE_STATE_VERSION_VBOX_30) 1739 { 1740 int32_t irq; 1741 SSMR3GetS32 (pSSM, &irq); 1742 int32_t dma; 1743 SSMR3GetS32 (pSSM, &dma); 1744 int32_t hdma; 1745 SSMR3GetS32 (pSSM, &hdma); 1746 int32_t port; 1747 SSMR3GetS32 (pSSM, &port); 1748 int32_t ver; 1749 int rc = SSMR3GetS32 (pSSM, &ver); 1750 AssertRCReturn (rc, rc); 1751 1752 if ( irq != pThis->irqCfg 1753 || dma != pThis->dmaCfg 1754 || hdma != pThis->hdmaCfg 1755 || port != pThis->portCfg 1756 || ver != pThis->verCfg ) 1757 { 1758 LogRel(("SB16: config changed: irq=%x/%x dma=%x/%x hdma=%x/%x port=%x/%x ver=%x/%x (saved/config)\n", 1759 irq, pThis->irqCfg, 1760 dma, pThis->dmaCfg, 1761 hdma, pThis->hdmaCfg, 1762 port, pThis->portCfg, 1763 ver, pThis->verCfg)); 1764 return VERR_SSM_LOAD_CONFIG_MISMATCH; 1765 } 1766 } 1767 if (uPass != SSM_PASS_FINAL) 1768 return VINF_SUCCESS; 1769 1770 SB_load(pSSM, pThis, uVersion); 1771 return VINF_SUCCESS; 1772 } 1773 1711 1774 static DECLCALLBACK(void *) sb16QueryInterface (struct PDMIBASE *pInterface, 1712 1775 PDMINTERFACE enmInterface) … … 1749 1812 return PDMDEV_SET_ERROR(pDevIns, rc, 1750 1813 N_("Configuration error: Failed to get the \"IRQ\" value")); 1814 s->irqCfg = s->irq; 1751 1815 1752 1816 rc = CFGMR3QuerySIntDef(pCfgHandle, "DMA", &s->dma, 1); … … 1754 1818 return PDMDEV_SET_ERROR(pDevIns, rc, 1755 1819 N_("Configuration error: Failed to get the \"DMA\" value")); 1820 s->dmaCfg = s->dma; 1756 1821 1757 1822 rc = CFGMR3QuerySIntDef(pCfgHandle, "DMA16", &s->hdma, 5); … … 1759 1824 return PDMDEV_SET_ERROR(pDevIns, rc, 1760 1825 N_("Configuration error: Failed to get the \"DMA16\" value")); 1826 s->hdmaCfg = s->hdma; 1761 1827 1762 1828 RTIOPORT Port; … … 1765 1831 return PDMDEV_SET_ERROR(pDevIns, rc, 1766 1832 N_("Configuration error: Failed to get the \"Port\" value")); 1767 s->port = Port; 1833 s->port = Port; 1834 s->portCfg = Port; 1768 1835 1769 1836 uint16_t u16Version; … … 1772 1839 return PDMDEV_SET_ERROR(pDevIns, rc, 1773 1840 N_("Configuration error: Failed to get the \"Version\" value")); 1774 s->ver = u16Version; 1841 s->ver = u16Version; 1842 s->verCfg = u16Version; 1775 1843 1776 1844 /* … … 1816 1884 s->can_write = 1; 1817 1885 1818 rc = PDMDevHlpSSMRegister (pDevIns, SB16_SSM_VERSION, sizeof(*s), sb16SaveExec, sb16LoadExec);1886 rc = PDMDevHlpSSMRegister3(pDevIns, SB16_SAVE_STATE_VERSION, sizeof(*s), sb16LiveExec, sb16SaveExec, sb16LoadExec); 1819 1887 if (RT_FAILURE(rc)) 1820 1888 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.