Changeset 39053 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Oct 20, 2011 1:37:40 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevAPIC.cpp
r37636 r39053 324 324 uint8_t delivery_mode, uint8_t vector_num, 325 325 uint8_t polarity, uint8_t trigger_mode); 326 static int apic_get_arb_pri(APICState *s);327 static int apic_get_ppr(APICState *s);328 static uint32_t apic_get_current_count(APICDeviceInfo * pDev, APICState*s);326 static int apic_get_arb_pri(APICState const *s); 327 static int apic_get_ppr(APICState const *s); 328 static uint32_t apic_get_current_count(APICDeviceInfo const *pDev, APICState const *s); 329 329 static void apicTimerSetInitialCount(APICDeviceInfo *pDev, APICState *s, uint32_t initial_count); 330 330 static void apicTimerSetLvt(APICDeviceInfo *pDev, APICState *pApic, uint32_t fNew); … … 694 694 /* else: fall thru */ 695 695 default: 696 AssertMsgFailed(("unknown iReg %x\n", iReg)); 696 Log(("apicWriteRegister/%u: unknown index %#x\n", pApic->phys_id, iReg)); 697 rc = PDMDevHlpDBGFStop(pDev->CTX_SUFF(pDevIns), RT_SRC_POS, 698 "unknown index %#x (id=%u)\n", iReg, pApic->phys_id); 697 699 pApic->esr |= ESR_ILLEGAL_ADDRESS; 698 700 break; … … 803 805 */ 804 806 default: 805 AssertMsgFailed(("apicReadMSR: unknown index %x\n", index));806 807 /** 807 808 * @todo: according to spec when APIC writes to ESR it msut raise error interrupt, 808 809 * i.e. LVT[5] 809 810 */ 811 Log(("apicReadMSR/%u: unknown index %#x\n", apic->phys_id, index)); 812 rc = PDMDevHlpDBGFStop(pDev->CTX_SUFF(pDevIns), RT_SRC_POS, 813 "unknown index %#x (id=%u)\n", index, apic->phys_id); 810 814 apic->esr |= ESR_ILLEGAL_ADDRESS; 811 815 val = 0; … … 923 927 924 928 /* return -1 if no bit is set */ 925 static int get_highest_priority_int(uint32_t *tab)929 static int get_highest_priority_int(uint32_t const *tab) 926 930 { 927 931 int i; … … 934 938 } 935 939 936 static int apic_get_ppr(APICState *s)940 static int apic_get_ppr(APICState const *s) 937 941 { 938 942 int tpr, isrv, ppr; … … 960 964 } 961 965 962 static int apic_get_arb_pri(APICState *s)966 static int apic_get_arb_pri(APICState const *s) 963 967 { 964 968 /* XXX: arbitration */ … … 1232 1236 * May return to ring-3 to acquire the TM and PDM lock. 1233 1237 */ 1234 static uint32_t apic_get_current_count(APICDeviceInfo *pDev, APICState*s)1238 static uint32_t apic_get_current_count(APICDeviceInfo const *pDev, APICState const *s) 1235 1239 { 1236 1240 int64_t d; … … 1476 1480 # endif /* IN_RING3 */ 1477 1481 1478 static uint32_t apic_mem_readl(APICDeviceInfo* pDev, APICState *s, RTGCPHYS addr) 1479 { 1480 uint32_t val; 1481 int index; 1482 1483 index = (addr >> 4) & 0xff; 1484 1485 switch(index) { 1482 static int apic_mem_readl(APICDeviceInfo *pDev, APICState *s, RTGCPHYS addr, uint32_t *pu32) 1483 { 1484 int rc = VINF_SUCCESS; 1485 int index = (addr >> 4) & 0xff; 1486 uint32_t val; 1487 1488 switch (index) { 1486 1489 case 0x02: /* id */ 1487 1490 val = s->id << 24; … … 1543 1546 break; 1544 1547 case 0x2f: 1545 /** 1546 * Correctable machine check exception vector, @todo:implement me!1548 /** @todo 1549 * Correctable machine check exception vector, implement me! 1547 1550 */ 1548 1551 default: 1549 AssertMsgFailed(("apic_mem_readl: unknown index %x\n", index));1550 1552 s->esr |= ESR_ILLEGAL_ADDRESS; 1551 val = 0; 1552 break; 1553 *pu32 = 0; 1554 Log(("APIC/%u: unknown index %#x (%RGp)\n", s->phys_id, index, addr)); 1555 return PDMDevHlpDBGFStop(pDev->CTX_SUFF(pDevIns), RT_SRC_POS, 1556 "unknown index %#x (%RGp) (id=%u)\n", index, addr, s->phys_id); 1553 1557 } 1554 1558 #ifdef DEBUG_APIC 1555 1559 Log(("CPU%d: APIC read: %08x = %08x\n", s->phys_id, (uint32_t)addr, val)); 1556 1560 #endif 1557 return val; 1561 *pu32 = val; 1562 return rc; 1558 1563 } 1559 1564 … … 1645 1650 1646 1651 int rc = TMR3TimerLoad(s->CTX_SUFF(pTimer), f); 1652 AssertRCReturn(rc, rc); 1647 1653 s->uHintedCountShift = s->uHintedInitialCount = 0; 1648 1654 s->fTimerArmed = TMTimerIsActive(s->CTX_SUFF(pTimer)); … … 1663 1669 Log(("CPU%d: apicMMIORead at %llx\n", s->phys_id, (uint64_t)GCPhysAddr)); 1664 1670 1665 /** @todo : add LAPIC range validity checks (different LAPICs can theoretically have1666 1671 /** @todo add LAPIC range validity checks (different LAPICs can 1672 * theoretically have different physical addresses, see #3092) */ 1667 1673 1668 1674 STAM_COUNTER_INC(&CTXSUFF(pDev->StatMMIORead)); … … 1670 1676 { 1671 1677 case 1: 1678 /** @todo this is not how recent APIC behave! We will fix 1679 * this via the IOM. */ 1672 1680 *(uint8_t *)pv = 0; 1673 1681 break; 1674 1682 1675 1683 case 2: 1684 /** @todo this is not how recent APIC behave! */ 1676 1685 *(uint16_t *)pv = 0; 1677 1686 break; … … 1697 1706 #endif /* experimental */ 1698 1707 APIC_LOCK(pDev, VINF_IOM_HC_MMIO_READ); 1699 *(uint32_t *)pv = apic_mem_readl(pDev, s, GCPhysAddr);1708 int rc = apic_mem_readl(pDev, s, GCPhysAddr, (uint32_t *)pv); 1700 1709 APIC_UNLOCK(pDev); 1701 break;1710 return rc; 1702 1711 } 1703 1712 default: … … 1741 1750 1742 1751 /* Print a 8-dword LAPIC bit map (256 bits). */ 1743 static void lapicDumpVec(APICDeviceInfo *pDev, APICState *lapic, PCDBGFINFOHLP pHlp, unsigned start) 1744 { 1745 unsigned i; 1746 uint32_t val; 1747 1748 for (i = 0; i < 8; ++i) 1752 static void lapicDumpVec(APICDeviceInfo *pDev, APICState *lapic, PCDBGFINFOHLP pHlp, unsigned start) 1753 { 1754 for (unsigned i = 0; i < 8; ++i) 1749 1755 { 1750 val = apic_mem_readl(pDev, lapic, start + (i << 4)); 1756 uint32_t val; 1757 apic_mem_readl(pDev, lapic, start + (i << 4), &val); 1751 1758 pHlp->pfnPrintf(pHlp, "%08X", val); 1752 1759 } … … 1761 1768 1762 1769 pHlp->pfnPrintf(pHlp, "Local APIC at %08X:\n", lapic->apicbase); 1763 val = apic_mem_readl(pDev, lapic, 0x20);1770 apic_mem_readl(pDev, lapic, 0x20, &val); 1764 1771 pHlp->pfnPrintf(pHlp, " LAPIC ID : %08X\n", val); 1765 1772 pHlp->pfnPrintf(pHlp, " APIC ID = %02X\n", (val >> 24) & 0xff); 1766 val = apic_mem_readl(pDev, lapic, 0x30);1773 apic_mem_readl(pDev, lapic, 0x30, &val); 1767 1774 max_lvt = (val >> 16) & 0xff; 1768 1775 pHlp->pfnPrintf(pHlp, " APIC VER : %08X\n", val); 1769 1776 pHlp->pfnPrintf(pHlp, " version = %02X\n", val & 0xff); 1770 1777 pHlp->pfnPrintf(pHlp, " lvts = %d\n", ((val >> 16) & 0xff) + 1); 1771 val = apic_mem_readl(pDev, lapic, 0x80);1778 apic_mem_readl(pDev, lapic, 0x80, &val); 1772 1779 pHlp->pfnPrintf(pHlp, " TPR : %08X\n", val); 1773 1780 pHlp->pfnPrintf(pHlp, " task pri = %d/%d\n", (val >> 4) & 0xf, val & 0xf); 1774 val = apic_mem_readl(pDev, lapic, 0xA0);1781 apic_mem_readl(pDev, lapic, 0xA0, &val); 1775 1782 pHlp->pfnPrintf(pHlp, " PPR : %08X\n", val); 1776 1783 pHlp->pfnPrintf(pHlp, " cpu pri = %d/%d\n", (val >> 4) & 0xf, val & 0xf); 1777 val = apic_mem_readl(pDev, lapic, 0xD0);1784 apic_mem_readl(pDev, lapic, 0xD0, &val); 1778 1785 pHlp->pfnPrintf(pHlp, " LDR : %08X\n", val); 1779 1786 pHlp->pfnPrintf(pHlp, " log id = %02X\n", (val >> 24) & 0xff); 1780 val = apic_mem_readl(pDev, lapic, 0xE0);1787 apic_mem_readl(pDev, lapic, 0xE0, &val); 1781 1788 pHlp->pfnPrintf(pHlp, " DFR : %08X\n", val); 1782 val = apic_mem_readl(pDev, lapic, 0xF0);1789 apic_mem_readl(pDev, lapic, 0xF0, &val); 1783 1790 pHlp->pfnPrintf(pHlp, " SVR : %08X\n", val); 1784 1791 pHlp->pfnPrintf(pHlp, " focus = %s\n", val & (1 << 9) ? "check off" : "check on"); … … 1793 1800 val = get_highest_priority_int(lapic->irr); 1794 1801 pHlp->pfnPrintf(pHlp, " highest = %02X\n", val == ~0U ? 0 : val); 1795 val = apic_mem_readl(pDev, lapic, 0x320);1802 apic_mem_readl(pDev, lapic, 0x320, &val); 1796 1803 } 1797 1804 … … 1799 1806 static DECLCALLBACK(void) lapicInfoLVT(APICDeviceInfo *pDev, APICState *lapic, PCDBGFINFOHLP pHlp) 1800 1807 { 1801 uint32_t val; 1802 static const char *dmodes[] = { "Fixed ", "Reserved", "SMI", "Reserved", 1803 "NMI", "INIT", "Reserved", "ExtINT" }; 1804 1805 val = apic_mem_readl(pDev, lapic, 0x320); 1808 static const char *s_apszDeliveryModes[] = 1809 { 1810 "Fixed ", "Reserved", "SMI", "Reserved", "NMI", "INIT", "Reserved", "ExtINT" 1811 }; 1812 uint32_t val; 1813 1814 apic_mem_readl(pDev, lapic, 0x320, &val); 1806 1815 pHlp->pfnPrintf(pHlp, " LVT Timer : %08X\n", val); 1807 1816 pHlp->pfnPrintf(pHlp, " mode = %s\n", val & (1 << 17) ? "periodic" : "one-shot"); … … 1809 1818 pHlp->pfnPrintf(pHlp, " status = %s\n", val & (1 << 12) ? "pending" : "idle"); 1810 1819 pHlp->pfnPrintf(pHlp, " vector = %02X\n", val & 0xff); 1811 val = apic_mem_readl(pDev, lapic, 0x350);1820 apic_mem_readl(pDev, lapic, 0x350, &val); 1812 1821 pHlp->pfnPrintf(pHlp, " LVT LINT0 : %08X\n", val); 1813 1822 pHlp->pfnPrintf(pHlp, " mask = %d\n", (val >> 16) & 1); … … 1816 1825 pHlp->pfnPrintf(pHlp, " polarty = %d\n", (val >> 13) & 1); 1817 1826 pHlp->pfnPrintf(pHlp, " status = %s\n", val & (1 << 12) ? "pending" : "idle"); 1818 pHlp->pfnPrintf(pHlp, " delivry = %s\n", dmodes[(val >> 8) & 7]);1827 pHlp->pfnPrintf(pHlp, " delivry = %s\n", s_apszDeliveryModes[(val >> 8) & 7]); 1819 1828 pHlp->pfnPrintf(pHlp, " vector = %02X\n", val & 0xff); 1820 val = apic_mem_readl(pDev, lapic, 0x360);1829 apic_mem_readl(pDev, lapic, 0x360, &val); 1821 1830 pHlp->pfnPrintf(pHlp, " LVT LINT1 : %08X\n", val); 1822 1831 pHlp->pfnPrintf(pHlp, " mask = %d\n", (val >> 16) & 1); … … 1825 1834 pHlp->pfnPrintf(pHlp, " polarty = %d\n", (val >> 13) & 1); 1826 1835 pHlp->pfnPrintf(pHlp, " status = %s\n", val & (1 << 12) ? "pending" : "idle"); 1827 pHlp->pfnPrintf(pHlp, " delivry = %s\n", dmodes[(val >> 8) & 7]);1836 pHlp->pfnPrintf(pHlp, " delivry = %s\n", s_apszDeliveryModes[(val >> 8) & 7]); 1828 1837 pHlp->pfnPrintf(pHlp, " vector = %02X\n", val & 0xff); 1829 1838 } 1830 1839 1831 1840 /* Print LAPIC timer state. */ 1832 static DECLCALLBACK(void) lapicInfoTimer(APICDeviceInfo 1841 static DECLCALLBACK(void) lapicInfoTimer(APICDeviceInfo *pDev, APICState *lapic, PCDBGFINFOHLP pHlp) 1833 1842 { 1834 1843 uint32_t val; … … 1836 1845 1837 1846 pHlp->pfnPrintf(pHlp, "Local APIC timer:\n"); 1838 val = apic_mem_readl(pDev, lapic, 0x380);1847 apic_mem_readl(pDev, lapic, 0x380, &val); 1839 1848 pHlp->pfnPrintf(pHlp, " Initial count : %08X\n", val); 1840 val = apic_mem_readl(pDev, lapic, 0x390);1849 apic_mem_readl(pDev, lapic, 0x390, &val); 1841 1850 pHlp->pfnPrintf(pHlp, " Current count : %08X\n", val); 1842 val = apic_mem_readl(pDev, lapic, 0x3E0);1851 apic_mem_readl(pDev, lapic, 0x3E0, &val); 1843 1852 pHlp->pfnPrintf(pHlp, " Divide config : %08X\n", val); 1844 1853 divider = ((val >> 1) & 0x04) | (val & 0x03); … … 1861 1870 1862 1871 if (pszArgs == NULL || !strcmp(pszArgs, "basic")) 1863 {1864 1872 lapicInfoBasic(pDev, lapic, pHlp); 1865 }1866 1873 else if (!strcmp(pszArgs, "lvt")) 1867 {1868 1874 lapicInfoLVT(pDev, lapic, pHlp); 1869 }1870 1875 else if (!strcmp(pszArgs, "timer")) 1871 {1872 1876 lapicInfoTimer(pDev, lapic, pHlp); 1873 }1874 1877 else 1875 {1876 1878 pHlp->pfnPrintf(pHlp, "Invalid argument. Recognized arguments are 'basic', 'lvt', 'timer'.\n"); 1877 }1878 1879 } 1879 1880
Note:
See TracChangeset
for help on using the changeset viewer.