VirtualBox

Changeset 66174 in vbox


Ignore:
Timestamp:
Mar 21, 2017 10:20:57 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114086
Message:

bs3-cpu-generated-1: split main function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66172 r66174  
    17711771
    17721772
    1773 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(Bs3Cg1Worker)(uint8_t bMode)
    1774 {
    1775     BS3CG1STATE                 ThisIsIt;
    1776     PBS3CG1STATE                pThis = &ThisIsIt;
    1777     unsigned const              iFirstRing = BS3_MODE_IS_V86(bMode)       ? 3 : 0;
    1778     uint8_t const               cRings     = BS3_MODE_IS_RM_OR_V86(bMode) ? 1 : 4;
    1779     uint8_t                     iRing;
    1780     unsigned                    iInstr;
    1781     BS3MEMKIND const            enmMemKind = BS3_MODE_IS_RM_OR_V86(bMode) ? BS3MEMKIND_REAL
    1782                                            : !BS3_MODE_IS_64BIT_CODE(bMode) ? BS3MEMKIND_TILED : BS3MEMKIND_FLAT32;
    1783 
    1784 #if 0
    1785     if (bMode != BS3_MODE_PP16_V86)
    1786         return BS3TESTDOMODE_SKIPPED;
    1787 #endif
    1788 
    1789     /*
    1790      * Initalize the state.
    1791      */
     1773/**
     1774 * Destroys the state, freeing all allocations and such.
     1775 *
     1776 * @param   pThis               The state.
     1777 */
     1778static void Bs3Cg1Destroy(PBS3CG1STATE pThis)
     1779{
     1780    if (BS3_MODE_IS_PAGED(pThis->bMode))
     1781    {
     1782        Bs3MemGuardedTestPageFree(pThis->pbCodePg);
     1783        Bs3MemGuardedTestPageFree(pThis->pbDataPg);
     1784    }
     1785    else
     1786    {
     1787        Bs3MemFree(pThis->pbCodePg, X86_PAGE_SIZE);
     1788        Bs3MemFree(pThis->pbDataPg, X86_PAGE_SIZE);
     1789    }
     1790}
     1791
     1792
     1793/**
     1794 * Initializes the state.
     1795 *
     1796 * @returns Success indicator (true/false)
     1797 * @param   pThis               The state.
     1798 * @param   bMode               The mode being tested.
     1799 */
     1800static bool Bs3Cg1Init(PBS3CG1STATE pThis, uint8_t bMode, uint8_t cRings, uint8_t iFirstRing)
     1801{
     1802    BS3MEMKIND const    enmMemKind = BS3_MODE_IS_RM_OR_V86(bMode) ? BS3MEMKIND_REAL
     1803                                   : !BS3_MODE_IS_64BIT_CODE(bMode) ? BS3MEMKIND_TILED : BS3MEMKIND_FLAT32;
     1804    unsigned            iRing;
     1805
    17921806    Bs3MemSet(pThis, 0, sizeof(*pThis));
    17931807
     
    18871901        }
    18881902    }
     1903
     1904    return true;
     1905}
     1906
     1907
     1908BS3_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;
     1916
     1917#if 0
     1918    if (bMode != BS3_MODE_PP16_V86)
     1919        return BS3TESTDOMODE_SKIPPED;
     1920#endif
     1921
     1922    /*
     1923     * Initalize the state.
     1924     */
     1925    if (!Bs3Cg1Init(pThis, bMode, cRings, iFirstRing))
     1926        return 1;
    18891927
    18901928    /*
     
    20432081     * Clean up.
    20442082     */
    2045     if (BS3_MODE_IS_PAGED(bMode))
    2046     {
    2047         Bs3MemGuardedTestPageFree(pThis->pbCodePg);
    2048         Bs3MemGuardedTestPageFree(pThis->pbDataPg);
    2049     }
    2050     else
    2051     {
    2052         Bs3MemFree(pThis->pbCodePg, X86_PAGE_SIZE);
    2053         Bs3MemFree(pThis->pbDataPg, X86_PAGE_SIZE);
    2054     }
    2055 
     2083    Bs3Cg1Destroy(pThis);
    20562084    Bs3TestSubDone();
     2085
    20572086#if 0
    20582087    if (bMode >= BS3_MODE_PE16_32)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette