Changeset 66184 in vbox
- Timestamp:
- Mar 21, 2017 5:22:09 PM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
r66174 r66184 192 192 /** The flat address corresponding to pbCodePg. */ 193 193 uintptr_t uCodePgFlat; 194 /** The 16-bit address corresponding to pbCodePg if relevant for bMode. */ 195 RTFAR16 CodePgFar; 196 /** The IP/EIP/RIP value for pbCodePg[0] relative to CS (bMode). */ 197 uintptr_t CodePgRip; 198 194 199 /** Page for placing data operands in. When paging is enabled, the page before 195 200 * and after are marked not-present. */ … … 1780 1785 if (BS3_MODE_IS_PAGED(pThis->bMode)) 1781 1786 { 1787 #if ARCH_BITS != 16 1782 1788 Bs3MemGuardedTestPageFree(pThis->pbCodePg); 1783 1789 Bs3MemGuardedTestPageFree(pThis->pbDataPg); 1790 #endif 1784 1791 } 1785 1792 else … … 1798 1805 * @param bMode The mode being tested. 1799 1806 */ 1800 static bool Bs3Cg1Init(PBS3CG1STATE pThis, uint8_t bMode, uint8_t cRings, uint8_t iFirstRing)1807 bool BS3_CMN_NM(Bs3Cg1Init)(PBS3CG1STATE pThis, uint8_t bMode, uint8_t cRings, uint8_t iFirstRing) 1801 1808 { 1802 1809 BS3MEMKIND const enmMemKind = BS3_MODE_IS_RM_OR_V86(bMode) ? BS3MEMKIND_REAL … … 1817 1824 if (BS3_MODE_IS_PAGED(bMode)) 1818 1825 { 1826 #if ARCH_BITS != 16 1819 1827 pThis->pbCodePg = Bs3MemGuardedTestPageAlloc(enmMemKind); 1820 1828 if (!pThis->pbCodePg) … … 1834 1842 return 0; 1835 1843 } 1844 #else 1845 return Bs3TestFailed("WTF?! #1"); 1846 #endif 1836 1847 } 1837 1848 else … … 1850 1861 pThis->uDataPgFlat = Bs3SelPtrToFlat(pThis->pbDataPg); 1851 1862 #if ARCH_BITS == 16 1863 pThis->CodePgFar.sel = BS3_FP_SEG(pThis->pbCodePg); 1864 pThis->CodePgFar.off = BS3_FP_OFF(pThis->pbCodePg); 1865 pThis->CodePgRip = BS3_FP_OFF(pThis->pbCodePg); 1866 pThis->DataPgFar.sel = BS3_FP_SEG(pThis->pbDataPg); 1852 1867 pThis->DataPgFar.off = BS3_FP_OFF(pThis->pbDataPg); 1853 pThis->DataPgFar.sel = BS3_FP_SEG(pThis->pbDataPg);1854 1868 #else 1855 1869 if (BS3_MODE_IS_RM_OR_V86(bMode)) 1870 { 1856 1871 *(uint32_t *)&pThis->DataPgFar = Bs3SelFlatDataToRealMode(pThis->uDataPgFlat); 1857 else if (!BS3_MODE_IS_64BIT_CODE(bMode)) 1872 ASMCompilerBarrier(); 1873 pThis->CodePgFar.off = 0; 1874 pThis->CodePgFar.sel = pThis->uDataPgFlat >> 4; 1875 pThis->CodePgRip = pThis->CodePgFar.off; 1876 } 1877 else if (BS3_MODE_IS_16BIT_CODE(bMode)) 1878 { 1858 1879 *(uint32_t *)&pThis->DataPgFar = Bs3SelFlatDataToProtFar16(pThis->uDataPgFlat); 1880 ASMCompilerBarrier(); 1881 pThis->CodePgFar.sel = BS3_SEL_SPARE_00; 1882 pThis->CodePgFar.off = 0; 1883 pThis->CodePgRip = 0; 1884 } 1885 else if (BS3_MODE_IS_32BIT_CODE(bMode)) 1886 { 1887 *(uint32_t *)&pThis->DataPgFar = Bs3SelFlatDataToProtFar16(pThis->uDataPgFlat); 1888 ASMCompilerBarrier(); 1889 pThis->CodePgFar.sel = 0; 1890 pThis->CodePgFar.off = 0; 1891 pThis->CodePgRip = (uintptr_t)pThis->pbCodePg; 1892 } 1859 1893 else 1860 *(uint32_t *)&pThis->DataPgFar = 0; 1894 { 1895 pThis->DataPgFar.off = 0; 1896 pThis->DataPgFar.sel = 0; 1897 pThis->CodePgFar.off = 0; 1898 pThis->CodePgFar.sel = 0; 1899 pThis->CodePgRip = (uintptr_t)pThis->pbCodePg; 1900 } 1861 1901 #endif 1862 1902 … … 1866 1906 if (BS3_MODE_IS_RM_OR_V86(bMode)) 1867 1907 { 1908 pThis->aInitialCtxs[iFirstRing].cs = pThis->CodePgFar.sel; 1909 BS3_ASSERT(iFirstRing + 1 >= cRings); 1910 } 1911 else if (BS3_MODE_IS_16BIT_CODE(bMode)) 1912 { 1868 1913 #if ARCH_BITS == 16 1869 pThis->aInitialCtxs[iFirstRing].cs = BS3_FP_SEG(pThis->pbCodePg);1914 uintptr_t const uFlatCodePgSeg = Bs3SelPtrToFlat(BS3_FP_MAKE(BS3_FP_SEG(pThis->pbCodePg), 0)); 1870 1915 #else 1871 pThis->aInitialCtxs[iFirstRing].cs = Bs3SelFlatCodeToRealMode((uintptr_t)pThis->pbCodePg) >> 16;1916 uintptr_t const uFlatCodePgSeg = (uintptr_t)pThis->pbCodePg; 1872 1917 #endif 1873 BS3_ASSERT(iFirstRing + 1 >= cRings);1874 }1875 else if (BS3_MODE_IS_16BIT_CODE(bMode))1876 {1877 #if ARCH_BITS == 161878 uintptr_t const uFlatCodePg = Bs3SelPtrToFlat(BS3_FP_MAKE(BS3_FP_SEG(pThis->pbCodePg), 0));1879 #else1880 uintptr_t const uFlatCodePg = (uintptr_t)pThis->pbCodePg;1881 #endif1882 BS3_ASSERT(ARCH_BITS == 16);1883 1918 for (iRing = iFirstRing + 1; iRing < cRings; iRing++) 1884 1919 { … … 1889 1924 { 1890 1925 pThis->aInitialCtxs[iRing].cs = BS3_SEL_SPARE_00 + iRing * 8 + iRing; 1891 Bs3SelSetup16BitCode(&Bs3GdteSpare00 + iRing, uFlatCodePg , iRing);1926 Bs3SelSetup16BitCode(&Bs3GdteSpare00 + iRing, uFlatCodePgSeg, iRing); 1892 1927 } 1893 1928 } … … 1902 1937 } 1903 1938 1939 ASMCompilerBarrier(); 1904 1940 return true; 1905 1941 } 1906 1942 1907 1943 1908 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(Bs3Cg1Worker)(uint8_t bMode) 1909 { 1910 BS3CG1STATE ThisIsIt; 1911 PBS3CG1STATE pThis = &ThisIsIt; 1912 unsigned const iFirstRing = BS3_MODE_IS_V86(bMode) ? 3 : 0; 1913 uint8_t const cRings = BS3_MODE_IS_RM_OR_V86(bMode) ? 1 : 4; 1914 uint8_t iRing; 1915 unsigned iInstr; 1944 static uint8_t BS3_CMN_NM(Bs3Cg1WorkerInner)(PBS3CG1STATE pThis, uint8_t bMode, uint8_t const cRings, uint8_t const iFirstRing) 1945 { 1946 uint8_t iRing; 1947 unsigned iInstr; 1916 1948 1917 1949 #if 0 1918 if (bMode != BS3_MODE_ PP16_V86)1950 if (bMode != BS3_MODE_LM16) 1919 1951 return BS3TESTDOMODE_SKIPPED; 1920 1952 #endif 1921 1922 /*1923 * Initalize the state.1924 */1925 if (!Bs3Cg1Init(pThis, bMode, cRings, iFirstRing))1926 return 1;1927 1953 1928 1954 /* … … 2020 2046 { 2021 2047 /* Okay, set up the execution context. */ 2048 unsigned offCode; 2022 2049 uint8_t BS3_FAR *pbCode; 2023 2050 2024 2051 Bs3MemCpy(&pThis->Ctx, &pThis->aInitialCtxs[iRing], sizeof(pThis->Ctx)); 2025 2052 if (BS3_MODE_IS_PAGED(bMode)) 2026 pbCode = &pThis->pbCodePg[X86_PAGE_SIZE - pThis->cbCurInstr]; 2053 { 2054 offCode = X86_PAGE_SIZE - pThis->cbCurInstr; 2055 pbCode = &pThis->pbCodePg[offCode]; 2056 } 2027 2057 else 2028 2058 { … … 2030 2060 pbCode[pThis->cbCurInstr] = 0x0f; /* UD2 */ 2031 2061 pbCode[pThis->cbCurInstr + 1] = 0x0b; 2062 offCode = 0; 2032 2063 } 2064 pThis->Ctx.rip.u = pThis->CodePgRip + offCode; 2033 2065 Bs3MemCpy(pbCode, pThis->abCurInstr, pThis->cbCurInstr); 2034 pThis->Ctx.rip.u = BS3_FP_OFF(pbCode);2035 2066 2036 2067 if (Bs3Cg1RunContextModifier(pThis, &pThis->Ctx, pHdr, pHdr->cbSelector, pHdr->cbInput, NULL, pbCode)) … … 2078 2109 } 2079 2110 2080 /*2081 * Clean up.2082 */2083 Bs3Cg1Destroy(pThis);2084 Bs3TestSubDone();2085 2086 2111 #if 0 2087 2112 if (bMode >= BS3_MODE_PE16_32) … … 2095 2120 } 2096 2121 2122 2123 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(Bs3Cg1Worker)(uint8_t bMode) 2124 { 2125 unsigned const iFirstRing = BS3_MODE_IS_V86(bMode) ? 3 : 0; 2126 uint8_t const cRings = BS3_MODE_IS_RM_OR_V86(bMode) ? 1 : 4; 2127 uint8_t bRet = 1; 2128 #if 1 2129 BS3CG1STATE This = {0}; 2130 if (BS3_CMN_NM(Bs3Cg1Init)(&This, bMode, cRings, iFirstRing)) 2131 { 2132 bRet = BS3_CMN_NM(Bs3Cg1WorkerInner)(&This, bMode, iFirstRing, cRings); 2133 2134 Bs3Cg1Destroy(&This); 2135 Bs3TestSubDone(); 2136 } 2137 #else 2138 PBS3CG1STATE pThis = (PBS3CG1STATE)Bs3MemAlloc(BS3MEMKIND_REAL, sizeof(*pThis)); 2139 if (pThis) 2140 { 2141 2142 if (BS3_CMN_NM(Bs3Cg1Init)(pThis, bMode, cRings, iFirstRing)) 2143 { 2144 bRet = BS3_CMN_NM(Bs3Cg1WorkerInner)(pThis, bMode, iFirstRing, cRings); 2145 2146 Bs3Cg1Destroy(pThis); 2147 Bs3TestSubDone(); 2148 } 2149 Bs3MemFree(pThis, sizeof(*pThis)); 2150 } 2151 #endif 2152 return bRet; 2153 } 2154 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.c
r65959 r66184 36 36 * Internal Functions * 37 37 *********************************************************************************************************************************/ 38 BS3TESTMODE _PROTOTYPES_CMN(Bs3Cg1Worker);38 BS3TESTMODEBYMAX_PROTOTYPES_CMN(Bs3Cg1Worker); 39 39 40 40 … … 42 42 * Global Variables * 43 43 *********************************************************************************************************************************/ 44 static const BS3TESTMODE ENTRY g_aModeTest[] =44 static const BS3TESTMODEBYMAXENTRY g_aModeTest[] = 45 45 { 46 BS3TESTMODE ENTRY_CMN(NULL, Bs3Cg1Worker),46 BS3TESTMODEBYMAXENTRY_CMN(NULL, Bs3Cg1Worker), 47 47 }; 48 48 … … 53 53 Bs3TestInit("bs3-cpu-generated-1"); 54 54 55 Bs3TestDoModes _rm(g_aModeTest, RT_ELEMENTS(g_aModeTest));55 Bs3TestDoModesByMax_rm(g_aModeTest, RT_ELEMENTS(g_aModeTest)); 56 56 57 57 Bs3TestTerm();
Note:
See TracChangeset
for help on using the changeset viewer.