VirtualBox

Changeset 60676 in vbox


Ignore:
Timestamp:
Apr 24, 2016 11:04:57 AM (8 years ago)
Author:
vboxsync
Message:

bs3kit: updates

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
5 added
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-asm.asm

    r60609 r60676  
    3737BS3_BEGIN_DATA16
    3838BS3_GLOBAL_DATA g_bs3CpuBasic2_ud2_FlatAddr, 4
    39         dd  bs3CpuBasic2_ud2 wrt FLAT
     39        dd  _bs3CpuBasic2_ud2 wrt FLAT
    4040
    4141
     
    4646BS3_BEGIN_TEXT16
    4747
    48 BS3_PROC_BEGIN  bs3CpuBasic2_ud2, BS3_PB_WITH_US_ALIAS
     48BS3_PROC_BEGIN _bs3CpuBasic2_ud2
    4949.again:
    5050        ud2
    5151        jmp     .again
    52 BS3_PROC_END    bs3CpuBasic2_ud2
     52BS3_PROC_END   _bs3CpuBasic2_ud2
    5353
    5454
    55 BS3_PROC_BEGIN bs3CpuBasic2_Int80, BS3_PB_WITH_US_ALIAS
     55BS3_PROC_BEGIN _bs3CpuBasic2_Int80
    5656        int     80h
    5757.again: ud2
    5858        jmp     .again
    59 BS3_PROC_END   bs3CpuBasic2_Int80
     59BS3_PROC_END   _bs3CpuBasic2_Int80
    6060
    6161
    62 BS3_PROC_BEGIN bs3CpuBasic2_Int81, BS3_PB_WITH_US_ALIAS
     62BS3_PROC_BEGIN _bs3CpuBasic2_Int81
    6363        int     81h
    6464.again: ud2
    6565        jmp     .again
    66 BS3_PROC_END   bs3CpuBasic2_Int81
     66BS3_PROC_END   _bs3CpuBasic2_Int81
    6767
    6868
    69 BS3_PROC_BEGIN bs3CpuBasic2_Int82, BS3_PB_WITH_US_ALIAS
     69BS3_PROC_BEGIN _bs3CpuBasic2_Int82
    7070        int     82h
    7171.again: ud2
    7272        jmp     .again
    73 BS3_PROC_END   bs3CpuBasic2_Int82
     73BS3_PROC_END   _bs3CpuBasic2_Int82
    7474
    7575
    76 BS3_PROC_BEGIN bs3CpuBasic2_Int83, BS3_PB_WITH_US_ALIAS
     76BS3_PROC_BEGIN _bs3CpuBasic2_Int83
    7777        int     83h
    7878.again: ud2
    7979        jmp     .again
    80 BS3_PROC_END   bs3CpuBasic2_Int83
     80BS3_PROC_END   _bs3CpuBasic2_Int83
    8181
    8282
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c

    r60669 r60676  
    8282    uint8_t u1DescType;
    8383} BS3CB2INVLDESCTYPE;
     84
     85typedef struct BS3CB2SIDTSGDT
     86{
     87    FPFNBS3FAR  fpfnWorker;
     88    uint8_t     cbInstr;
     89    bool        fSs;
     90    uint8_t     bMode;
     91} BS3CB2SIDTSGDT;
    8492#endif
    8593
     
    8997*********************************************************************************************************************************/
    9098#ifdef BS3_INSTANTIATING_CMN
    91 extern BS3_DECL(void)   bs3CpuBasic2_Int80(void);
    92 extern BS3_DECL(void)   bs3CpuBasic2_Int81(void);
    93 extern BS3_DECL(void)   bs3CpuBasic2_Int82(void);
    94 extern BS3_DECL(void)   bs3CpuBasic2_Int83(void);
    95 extern BS3_DECL(void)   bs3CpuBasic2_ud2(void);
    96 #define                 bs3CpuBasic2_sidt_bx_ud2 BS3_CMN_NM(bs3CpuBasic2_sidt_bx_ud2)
    97 extern BS3_DECL(void)   bs3CpuBasic2_sidt_bx_ud2(void);
    98 #define                 bs3CpuBasic2_lidt_bx_ud2 BS3_CMN_NM(bs3CpuBasic2_lidt_bx_ud2)
    99 extern BS3_DECL(void)   bs3CpuBasic2_lidt_bx_ud2(void);
    100 #define                 g_bs3CpuBasic2_ud2_FlatAddr BS3_DATA_NM(g_bs3CpuBasic2_ud2_FlatAddr)
    101 extern uint32_t         g_bs3CpuBasic2_ud2_FlatAddr;
     99extern FNBS3FAR     bs3CpuBasic2_Int80;
     100extern FNBS3FAR     bs3CpuBasic2_Int81;
     101extern FNBS3FAR     bs3CpuBasic2_Int82;
     102extern FNBS3FAR     bs3CpuBasic2_Int83;
     103extern FNBS3FAR     bs3CpuBasic2_ud2;
     104# define            g_bs3CpuBasic2_ud2_FlatAddr BS3_DATA_NM(g_bs3CpuBasic2_ud2_FlatAddr)
     105extern uint32_t     g_bs3CpuBasic2_ud2_FlatAddr;
     106
     107extern FNBS3FAR     bs3CpuBasic2_sidt_bx_ud2_c16;
     108extern FNBS3FAR     bs3CpuBasic2_sidt_bx_ud2_c32;
     109extern FNBS3FAR     bs3CpuBasic2_sidt_bx_ud2_c64;
     110extern FNBS3FAR     bs3CpuBasic2_sidt_ss_bx_ud2_c16;
     111extern FNBS3FAR     bs3CpuBasic2_sidt_ss_bx_ud2_c32;
     112extern FNBS3FAR     bs3CpuBasic2_sidt_rexw_bx_ud2_c64;
     113extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_bx_ud2_c16;
     114extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_bx_ud2_c32;
     115extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_bx_ud2_c64;
     116extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c16;
     117extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c32;
     118extern FNBS3FAR     bs3CpuBasic2_sidt_opsize_rexw_bx_ud2_c64;
     119
     120extern FNBS3FAR     bs3CpuBasic2_sgdt_bx_ud2_c16;
     121extern FNBS3FAR     bs3CpuBasic2_sgdt_bx_ud2_c32;
     122extern FNBS3FAR     bs3CpuBasic2_sgdt_bx_ud2_c64;
     123extern FNBS3FAR     bs3CpuBasic2_sgdt_opsize_bx_ud2_c16;
     124extern FNBS3FAR     bs3CpuBasic2_sgdt_opsize_bx_ud2_c32;
     125extern FNBS3FAR     bs3CpuBasic2_sgdt_opsize_bx_ud2_c64;
     126extern FNBS3FAR     bs3CpuBasic2_lidt_bx_ud2_c16;
     127extern FNBS3FAR     bs3CpuBasic2_lidt_bx_ud2_c32;
     128extern FNBS3FAR     bs3CpuBasic2_lidt_bx_ud2_c64;
    102129#endif
    103130
     
    113140# define                    g_f16BitSys     BS3_CMN_NM(g_f16BitSys)
    114141static bool                 g_f16BitSys = 1;
     142
     143
     144static BS3CB2SIDTSGDT const g_aSidtWorkers[] =
     145{
     146    { bs3CpuBasic2_sidt_bx_ud2_c16,             3, false,   BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     147//    { bs3CpuBasic2_sidt_ss_bx_ud2_c16,          4, true,    BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     148    { bs3CpuBasic2_sidt_opsize_bx_ud2_c16,      4, false,   BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     149//    { bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c16,   5, true,    BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     150    { bs3CpuBasic2_sidt_bx_ud2_c32,             3, false,   BS3_MODE_CODE_32 },
     151//    { bs3CpuBasic2_sidt_ss_bx_ud2_c32,          4, true,    BS3_MODE_CODE_32 },
     152    { bs3CpuBasic2_sidt_opsize_bx_ud2_c32,      4, false,   BS3_MODE_CODE_32 },
     153//    { bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c32,   5, true,    BS3_MODE_CODE_32 },
     154    { bs3CpuBasic2_sidt_bx_ud2_c64,             3, false,   BS3_MODE_CODE_64 },
     155    { bs3CpuBasic2_sidt_rexw_bx_ud2_c64,        4, false,   BS3_MODE_CODE_64 },
     156    { bs3CpuBasic2_sidt_opsize_bx_ud2_c64,      4, false,   BS3_MODE_CODE_64 },
     157    { bs3CpuBasic2_sidt_opsize_rexw_bx_ud2_c64, 5, false,   BS3_MODE_CODE_64 },
     158};
     159
     160#if 0
     161static BS3CB2SIDTSGDT const g_aSgdtNormal[3] =
     162{
     163    { bs3CpuBasic2_sgdt_bx_ud2_c16, bs3CpuBasic2_sgdt_ss_bx_ud2_c16, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     164    { bs3CpuBasic2_sgdt_bx_ud2_c32, bs3CpuBasic2_sgdt_ss_bx_ud2_c32, BS3_MODE_CODE_32 },
     165    { bs3CpuBasic2_sgdt_bx_ud2_c64, bs3CpuBasic2_sgdt_rexw_bx_ud2_c64, BS3_MODE_CODE_64 },
     166};
     167
     168static BS3CB2SIDTSGDT const g_aSgdtOpSize[3] =
     169{
     170    { bs3CpuBasic2_sgdt_opsize_bx_ud2_c16, bs3CpuBasic2_sgdt_ss_bx_ud2_c16, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },
     171    { bs3CpuBasic2_sgdt_opsize_bx_ud2_c32, bs3CpuBasic2_sgdt_ss_bx_ud2_c32, BS3_MODE_CODE_32 },
     172    { bs3CpuBasic2_sgdt_opsize_bx_ud2_c64, bs3CpuBasic2_sgdt_rexw_bx_ud2_c64, BS3_MODE_CODE_64 },
     173};
     174#endif
     175
    115176
    116177/** Table containing invalid CS selector types. */
     
    13051366
    13061367
    1307 # define bs3CpuBasic2_sidt_Common BS3_CMN_NM(bs3CpuBasic2_sidt_Common)
    1308 BS3_DECL_NEAR(void) bs3CpuBasic2_sidt_Common(void)
     1368/**
     1369 * Executes one round of SIDT and SGDT tests using one assembly worker.
     1370 *
     1371 * This is written with driving everything from the 16-bit or 32-bit worker in
     1372 * mind, i.e. not assuming the test bitcount is the same as the current.
     1373 */
     1374# define bs3CpuBasic2_sidt_sgdt_One BS3_CMN_NM(bs3CpuBasic2_sidt_sgdt_One)
     1375BS3_DECL_NEAR(void) bs3CpuBasic2_sidt_sgdt_One(BS3CB2SIDTSGDT const BS3_FAR *pWorker, uint8_t bTestMode,
     1376                                               uint8_t const *pabExpected)
    13091377{
    13101378    BS3TRAPFRAME        TrapCtx;
     
    13151383    uint8_t             abBuf[8*2 + 8 + 8];  /* test buffer w/ misalignment test space and some extra guard. */
    13161384    uint8_t BS3_FAR    *pbBuf  = abBuf;
    1317     uint8_t const       cbIdtr = BS3_MODE_IS_64BIT_CODE(g_bTestMode) ? 2+8 : 2+4;
     1385    uint8_t const       cbIdtr = BS3_MODE_IS_64BIT_CODE(bTestMode) ? 2+8 : 2+4;
    13181386    bool const          f286   = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) == BS3CPU_80286;
    13191387    uint8_t             bFiller;
    1320     unsigned            off;
    1321 
    1322     g_usBs3TestStep = 0;
     1388    int                 off;
     1389    uint8_t BS3_FAR    *pbTest;
     1390Bs3TestPrintf("bs3CpuBasic2_sidt_sgdt_One: %p bTestMode=%#x\n",  pWorker,  bTestMode);
    13231391
    13241392    /* make sure they're allocated  */
     
    13311399    /* Create a context, give this routine some more stack space, point the context
    13321400       at our SIDT [xBX] + UD2 combo, and point DS:xBX at abBuf. */
    1333     Bs3RegCtxSaveEx(&Ctx, g_bTestMode, 256 /*cbExtraStack*/);
    1334     Ctx.rip.u  = (uintptr_t)BS3_FP_OFF(&bs3CpuBasic2_sidt_bx_ud2);
    1335 # if TMPL_BITS == 32
    1336     g_uBs3TrapEipHint = Ctx.rip.u32;
    1337 # endif
    1338     Ctx.rbx.u = BS3_FP_OFF(pbBuf);
    1339 # if TMPL_BITS == 16
    1340     Ctx.ds    = BS3_FP_SEG(pbBuf);
    1341 # endif
     1401    Bs3RegCtxSaveEx(&Ctx, bTestMode, 256 /*cbExtraStack*/);
     1402    Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, abBuf);
     1403    Bs3RegCtxSetRipCsFromLnkPtr(&Ctx, pWorker->fpfnWorker);
     1404    if (BS3_MODE_IS_16BIT_SYS(bTestMode))
     1405        g_uBs3TrapEipHint = Ctx.rip.u32;
    13421406
    13431407    /* For successful SIDT attempts, we'll stop at the UD2. */
    13441408    Bs3MemCpy(&CtxUdExpected, &Ctx, sizeof(Ctx));
    1345     CtxUdExpected.rip.u += 3;
     1409    CtxUdExpected.rip.u += pWorker->cbInstr;
    13461410
    13471411    /*
     
    13601424    if (!ASMMemIsZero(&abBuf[cbIdtr], cbBuf - cbIdtr))
    13611425        Bs3TestFailedF("Unexpected buffer bytes set (#1): cbIdtr=%u abBuf=%.*Rhxs\n", cbIdtr, cbBuf, pbBuf);
     1426    if (Bs3MemCmp(abBuf, pabExpected, cbIdtr) != 0)
     1427        Bs3TestFailedF("Mismatch (#1): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, abBuf);
    13621428    g_usBs3TestStep++;
    13631429
     
    13781444    if (Bs3MemChr(abBuf, bFiller, cbIdtr) != NULL)
    13791445        Bs3TestFailedF("Not all bytes touched: cbIdtr=%u bFiller=%#x abBuf=%.*Rhxs\n", cbIdtr, bFiller, cbBuf, pbBuf);
     1446    if (Bs3MemCmp(abBuf, pabExpected, cbIdtr) != 0)
     1447        Bs3TestFailedF("Mismatch (#2): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, abBuf);
    13801448    g_usBs3TestStep++;
    13811449
     
    13861454    {
    13871455        pbBuf = &abBuf[off];
    1388         CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf);
     1456        Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, &abBuf[off]);
     1457        CtxUdExpected.rbx.u = Ctx.rbx.u;
    13891458
    13901459        /* First with zero buffer. */
     
    14001469        if (f286 && abBuf[off + cbIdtr - 1] != 0xff)
    14011470            Bs3TestFailedF("286: Top base byte isn't 0xff (#3): %#x\n", abBuf[off + cbIdtr - 1]);
     1471        if (Bs3MemCmp(&abBuf[off], pabExpected, cbIdtr) != 0)
     1472            Bs3TestFailedF("Mismatch (#3): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &abBuf[off]);
    14021473        g_usBs3TestStep++;
    14031474
     
    14171488        if (f286 && abBuf[off + cbIdtr - 1] != 0xff)
    14181489            Bs3TestFailedF("286: Top base byte isn't 0xff (#4): %#x\n", abBuf[off + cbIdtr - 1]);
     1490        if (Bs3MemCmp(&abBuf[off], pabExpected, cbIdtr) != 0)
     1491            Bs3TestFailedF("Mismatch (#4): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &abBuf[off]);
    14191492        g_usBs3TestStep++;
    1420 
    14211493    }
    14221494    pbBuf = abBuf;
    1423     CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf);
     1495    Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, abBuf);
     1496    CtxUdExpected.rbx.u = Ctx.rbx.u;
    14241497
    14251498    /*
     
    14271500     * We use BS3_SEL_TEST_PAGE_00 for this
    14281501     */
    1429     if (   !BS3_MODE_IS_RM_OR_V86(g_bTestMode)
    1430         && !BS3_MODE_IS_64BIT_CODE(g_bTestMode))
     1502    if (   !BS3_MODE_IS_RM_OR_V86(bTestMode)
     1503        && !BS3_MODE_IS_64BIT_CODE(bTestMode))
    14311504    {
    14321505        uint16_t cbLimit;
    1433         uint16_t const uSavedDs = Ctx.ds;
    1434         uint32_t uFlatBuf = Bs3SelPtrToFlat(pbBuf);
     1506        uint32_t uFlatBuf = Bs3SelPtrToFlat(abBuf);
    14351507        Bs3GdteTestPage00 = Bs3Gdte_DATA16;
    14361508        Bs3GdteTestPage00.Gen.u16BaseLow  = (uint16_t)uFlatBuf;
     
    14551527                        Bs3TestFailedF("Not all bytes touched (#5): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
    14561528                                       cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf);
     1529                    if (Bs3MemCmp(&abBuf[off], pabExpected, cbIdtr) != 0)
     1530                        Bs3TestFailedF("Mismatch (#5): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &abBuf[off]);
    14571531                    if (f286 && abBuf[off + cbIdtr - 1] != 0xff)
    14581532                        Bs3TestFailedF("286: Top base byte isn't 0xff (#5): %#x\n", abBuf[off + cbIdtr - 1]);
     
    14661540                            Bs3TestFailedF("Limit bytes not touched (#6): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
    14671541                                           cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf);
     1542                        if (Bs3MemCmp(&abBuf[off], pabExpected, 2) != 0)
     1543                            Bs3TestFailedF("Mismatch (#6): expected %.2Rhxs, got %.2Rhxs\n", pabExpected, &abBuf[off]);
    14681544                        if (!ASMMemIsAllU8(&abBuf[off + 2], cbIdtr - 2, bFiller))
    14691545                            Bs3TestFailedF("Base bytes touched on #GP (#6): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
     
    15061582                    bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected);
    15071583                    if (Bs3MemChr(&abBuf[off], bFiller, cbIdtr) != NULL)
    1508                         Bs3TestFailedF("Not all bytes touched (#5): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
     1584                        Bs3TestFailedF("Not all bytes touched (#8): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
    15091585                                       cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf);
     1586                    if (Bs3MemCmp(&abBuf[off], pabExpected, cbIdtr) != 0)
     1587                        Bs3TestFailedF("Mismatch (#8): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &abBuf[off]);
    15101588                    if (f286 && abBuf[off + cbIdtr - 1] != 0xff)
    1511                         Bs3TestFailedF("286: Top base byte isn't 0xff (#5): %#x\n", abBuf[off + cbIdtr - 1]);
     1589                        Bs3TestFailedF("286: Top base byte isn't 0xff (#8): %#x\n", abBuf[off + cbIdtr - 1]);
    15121590                }
    15131591                else
     
    15201598
    15211599                if (off > 0 && !ASMMemIsAllU8(abBuf, off, bFiller))
    1522                     Bs3TestFailedF("Leading bytes touched (#7): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
     1600                    Bs3TestFailedF("Leading bytes touched (#9): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
    15231601                                   cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf);
    15241602                if (!ASMMemIsAllU8(&abBuf[off + cbIdtr], sizeof(abBuf) - off - cbIdtr, bFiller))
    1525                     Bs3TestFailedF("Trailing bytes touched (#7): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
     1603                    Bs3TestFailedF("Trailing bytes touched (#9): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n",
    15261604                                   cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf);
    15271605
     
    15301608        }
    15311609
    1532         CtxUdExpected.ds = Ctx.ds = uSavedDs;
    1533         CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf);
     1610        Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, pbBuf);
    15341611    }
    15351612
     
    15371614     * Play with the paging.
    15381615     */
    1539     if (BS3_MODE_IS_PAGED(g_bTestMode))
    1540     {
    1541 
    1542 
     1616    if (   BS3_MODE_IS_PAGED(bTestMode)
     1617
     1618        && (pbTest = (uint8_t BS3_FAR *)Bs3MemGuardedTestPageAlloc(BS3MEMKIND_TILED)) != NULL)
     1619    {
     1620        RTCCUINTXREG uFlatTest = Bs3SelPtrToFlat(pbTest);
     1621
     1622        /*
     1623         * Slide the buffer towards the trailing guard page.  We'll observe the
     1624         * first word being written entirely separately from the 2nd dword/qword.
     1625         */
     1626        for (off = X86_PAGE_4K_SIZE - cbIdtr - 4; off < X86_PAGE_4K_SIZE + 4; off++)
     1627        {
     1628            Bs3MemSet(&pbTest[X86_PAGE_4K_SIZE - cbIdtr * 2], bFiller, cbIdtr * 2);
     1629            Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, &pbTest[off]);
     1630            Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx);
     1631            if (off + cbIdtr <= X86_PAGE_4K_SIZE)
     1632            {
     1633                CtxUdExpected.rbx = Ctx.rbx;
     1634                CtxUdExpected.ds  = Ctx.ds;
     1635                bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected);
     1636                if (Bs3MemCmp(&pbTest[off], pabExpected, cbIdtr) != 0)
     1637                    Bs3TestFailedF("Mismatch (#9): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &pbTest[off]);
     1638            }
     1639            else
     1640            {
     1641                bs3CpuBasic2_ComparePfCtx(&TrapCtx, &Ctx, X86_TRAP_PF_RW | (Ctx.bCpl ? X86_TRAP_PF_US : 0),
     1642                                          uFlatTest + RT_MAX(off, X86_PAGE_4K_SIZE));
     1643                if (   off <= X86_PAGE_4K_SIZE - 2
     1644                    && Bs3MemCmp(&pbTest[off], pabExpected, 2) != 0)
     1645                    Bs3TestPrintf("Mismatch (#10): Expected limit %.2Rhxs, got %.2Rhxs; off=%#x\n",
     1646                                  pabExpected, &pbTest[off], off);
     1647                if (   off < X86_PAGE_4K_SIZE - 2
     1648                    && !ASMMemIsAllU8(&pbTest[off + 2], X86_PAGE_4K_SIZE - off - 2, bFiller))
     1649                    Bs3TestPrintf("Wrote partial base on #PF (#10): Expected %.*Rhxs, got %.*Rhxs; off=%#x\n",
     1650                                  X86_PAGE_4K_SIZE - off - 2, pabExpected, X86_PAGE_4K_SIZE - off - 2, &pbTest[off + 2], off);
     1651                if (off == X86_PAGE_4K_SIZE - 1 && pbTest[off] != bFiller)
     1652                    Bs3TestPrintf("Wrote partial limit on #PF (#10): Expected %02x, got %02x\n", bFiller, pbTest[off]);
     1653            }
     1654        }
     1655
     1656        /*
     1657         * Now, do it the other way around. It should look normal now since writing
     1658         * the limit will #PF first and nothing should be written.
     1659         */
     1660        for (off = cbIdtr + 4; off >= -cbIdtr - 4; off--)
     1661        {
     1662            Bs3MemSet(pbTest, bFiller, 32);
     1663            Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, &pbTest[off]);
     1664            Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx);
     1665            if (off >= 0)
     1666            {
     1667                CtxUdExpected.rbx = Ctx.rbx;
     1668                CtxUdExpected.ds  = Ctx.ds;
     1669                bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected);
     1670                if (Bs3MemCmp(&pbTest[off], pabExpected, cbIdtr) != 0)
     1671                    Bs3TestFailedF("Mismatch (#10): expected %.*Rhxs, got %.*Rhxs\n", cbIdtr, pabExpected, cbIdtr, &pbTest[off]);
     1672            }
     1673            else
     1674            {
     1675                bs3CpuBasic2_ComparePfCtx(&TrapCtx, &Ctx, X86_TRAP_PF_RW | (Ctx.bCpl ? X86_TRAP_PF_US : 0),
     1676                                          uFlatTest + RT_MAX(off, X86_PAGE_4K_SIZE));
     1677                if (   -off < cbIdtr
     1678                    && !ASMMemIsAllU8(pbTest, cbIdtr + off, bFiller))
     1679                    Bs3TestPrintf("Wrote partial content on #PF (#11): bFiller=%#x, found %.*Rhxs; off=%d\n",
     1680                                  bFiller, cbIdtr + off, pbTest, off);
     1681            }
     1682            if (!ASMMemIsAllU8(&pbTest[RT_MAX(cbIdtr + off, 0)], 16, bFiller))
     1683                Bs3TestPrintf("Wrote beyond expected area (#12): bFiller=%#x, found %.16Rhxs; off=%d\n",
     1684                              bFiller, &pbTest[RT_MAX(cbIdtr + off, 0)], off);
     1685        }
     1686
     1687        Bs3MemGuardedTestPageFree(pbTest);
    15431688    }
    15441689
    15451690}
     1691
     1692# define bs3CpuBasic2_sidt_sgdt_Common BS3_CMN_NM(bs3CpuBasic2_sidt_sgdt_Common)
     1693BS3_DECL_NEAR(void) bs3CpuBasic2_sidt_sgdt_Common(uint8_t bTestMode, BS3CB2SIDTSGDT const BS3_FAR *paWorkers, unsigned cWorkers,
     1694                                                  uint8_t const *pabExpected)
     1695{
     1696    unsigned idx;
     1697    unsigned iStep = 0;
     1698
     1699    for (idx = 0; idx < cWorkers; idx++)
     1700        if (paWorkers[idx].bMode & (bTestMode & BS3_MODE_CODE_MASK))
     1701        {
     1702            g_usBs3TestStep = iStep;
     1703            bs3CpuBasic2_sidt_sgdt_One(&paWorkers[idx], bTestMode, pabExpected);
     1704            iStep += 1000;
     1705        }
     1706}
     1707
    15461708
    15471709# if ARCH_BITS != 64
     
    17941956{
    17951957//if (bMode == BS3_MODE_PE16_V86)
    1796 {
     1958if (bMode & BS3_MODE_CODE_V86)
     1959{
     1960    union
     1961    {
     1962        RTIDTR  Idtr;
     1963        uint8_t ab[16];
     1964    } Expected;
     1965
    17971966    g_pszTestMode = TMPL_NM(g_szBs3ModeName);
    17981967    g_bTestMode   = bMode;
     
    18041973     * Pass to common worker which is only compiled once per mode.
    18051974     */
    1806     bs3CpuBasic2_sidt_Common();
     1975    Bs3MemZero(&Expected, sizeof(Expected));
     1976    ASMGetIDTR(&Expected.Idtr);
     1977    bs3CpuBasic2_sidt_sgdt_Common(bMode, g_aSidtWorkers, RT_ELEMENTS(g_aSidtWorkers), Expected.ab);
    18071978
    18081979    /*
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac

    r60657 r60676  
    9292%ifdef BS3_INSTANTIATING_CMN
    9393
     94;
     95; SIDT
     96;
    9497BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_bx_ud2, BS3_PBC_NEAR
    9598        sidt    [xBX]
     
    99102BS3_PROC_END_CMN   bs3CpuBasic2_sidt_bx_ud2
    100103
     104BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_bx_ud2, BS3_PBC_NEAR
     105        db      X86_OP_PRF_SIZE_OP
     106        sidt    [xBX]
     107.again: ud2
     108        jmp     .again
     109AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_bx_ud2) == 4)
     110BS3_PROC_END_CMN   bs3CpuBasic2_sidt_opsize_bx_ud2
    101111
     112%if TMPL_BITS == 64
     113BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_rexw_bx_ud2, BS3_PBC_NEAR
     114        db      X86_OP_REX_W
     115        sidt    [xBX]
     116.again: ud2
     117        jmp     .again
     118AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_rexw_bx_ud2) == 4)
     119BS3_PROC_END_CMN   bs3CpuBasic2_sidt_rexw_bx_ud2
     120
     121BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2, BS3_PBC_NEAR
     122        db      X86_OP_PRF_SIZE_OP
     123        db      X86_OP_REX_W
     124        sidt    [xBX]
     125.again: ud2
     126        jmp     .again
     127AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_rexw_bx_ud2) == 5)
     128BS3_PROC_END_CMN   bs3CpuBasic2_sidt_opsize_rexw_bx_ud2
     129%endif
     130
     131%if TMPL_BITS != 64
     132BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_ss_bx_ud2, BS3_PBC_NEAR
     133        sidt    [ss:xBX]
     134.again: ud2
     135        jmp     .again
     136AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_ss_bx_ud2) == 4)
     137BS3_PROC_END_CMN   bs3CpuBasic2_sidt_ss_bx_ud2
     138
     139BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2, BS3_PBC_NEAR
     140        db      X86_OP_PRF_SIZE_OP
     141        sidt    [ss:xBX]
     142.again: ud2
     143        jmp     .again
     144AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_ss_bx_ud2) == 5)
     145BS3_PROC_END_CMN   bs3CpuBasic2_sidt_opsize_ss_bx_ud2
     146%endif
     147
     148;
     149; SGDT
     150;
     151BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_bx_ud2, BS3_PBC_NEAR
     152        sgdt    [xBX]
     153.again: ud2
     154        jmp     .again
     155AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_bx_ud2) == 3)
     156BS3_PROC_END_CMN   bs3CpuBasic2_sgdt_bx_ud2
     157
     158BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2, BS3_PBC_NEAR
     159        db      X86_OP_PRF_SIZE_OP
     160        sgdt    [xBX]
     161.again: ud2
     162        jmp     .again
     163AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_bx_ud2) == 4)
     164BS3_PROC_END_CMN   bs3CpuBasic2_sgdt_opsize_bx_ud2
     165
     166%if TMPL_BITS == 64
     167BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2, BS3_PBC_NEAR
     168        db      X86_OP_REX_W
     169        sgdt    [xBX]
     170.again: ud2
     171        jmp     .again
     172AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_rexw_bx_ud2) == 4)
     173BS3_PROC_END_CMN   bs3CpuBasic2_sgdt_rexw_bx_ud2
     174%endif
     175
     176%if TMPL_BITS != 64
     177BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_ss_bx_ud2, BS3_PBC_NEAR
     178        sgdt    [ss:xBX]
     179.again: ud2
     180        jmp     .again
     181AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_ss_bx_ud2) == 4)
     182BS3_PROC_END_CMN   bs3CpuBasic2_sgdt_ss_bx_ud2
     183%endif
     184
     185
     186;
     187;
     188;
    102189BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_bx_ud2, BS3_PBC_NEAR
    103190        lidt    [xBX]
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r60657 r60676  
    7272       bs3-cmn-StrCpy.c \
    7373       bs3-cmn-MemChr.asm \
     74       bs3-cmn-MemCmp.asm \
    7475       bs3-cmn-MemCpy.c \
    7576       bs3-cmn-MemPCpy.c \
     
    8081       bs3-cmn-MemAllocZ.c \
    8182       bs3-cmn-MemFree.c \
     83       bs3-cmn-MemGuardedTestPage.c \
    8284       bs3-cmn-PagingData.c \
    8385       bs3-cmn-PagingInitRootForPP.c \
     
    9193       bs3-cmn-RegCtxSave.asm \
    9294       bs3-cmn-RegCtxSaveEx.asm \
     95       bs3-cmn-RegCtxSetGrpSegFromCurPtr.c \
     96       bs3-cmn-RegCtxSetGrpSegFromFlat.c \
     97       bs3-cmn-RegCtxSetRipCsFromLnkPtr.c \
    9398       bs3-cmn-SelFar32ToFlat32.c \
    9499       bs3-cmn-SelFar32ToFlat32NoClobber.asm \
     
    193198        bs3-wc16-U4D.asm \
    194199        bs3-wc16-I4D.asm \
     200       bs3-c16-SwitchFromV86To16BitAndCallC.asm \
    195201       bs3-c16-Trap16Generic.asm \
    196202       bs3-c16-TrapRmV86Generic.asm \
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp

    r60539 r60676  
    257257typedef OMFSYMBOL *POMFSYMBOL;
    258258
     259/** OMF Writer LNAME lookup record. */
     260typedef struct OMFWRLNAME
     261{
     262    /** Pointer to the next entry with the name hash. */
     263    struct OMFWRLNAME      *pNext;
     264    /** The LNAMES index number.   */
     265    uint16_t                idxName;
     266    /** The name length.   */
     267    uint8_t                 cchName;
     268    /** The name (variable size).   */
     269    char                    szName[1];
     270} OMFWRLNAME;
     271/** Pointer to the a OMF writer LNAME lookup record. */
     272typedef OMFWRLNAME *POMFWRLNAME;
     273
    259274/**
    260275 * OMF converter & writer instance.
     
    312327    /** The EXTDEF index of the __ImageBase symbol. */
    313328    uint16_t        idxExtImageBase;
     329
     330    /** LNAME lookup hash table. To avoid too many duplicates. */
     331    POMFWRLNAME     apNameLookup[63];
    314332} OMFWRITE;
    315333/** Pointer to an OMF writer. */
     
    353371{
    354372    free(pThis->paSymbols);
     373
    355374    for (uint32_t i = 0; i < pThis->cSegments; i++)
    356375        if (pThis->paSegments[i].pszName)
    357376            free(pThis->paSegments[i].pszName);
     377
    358378    free(pThis->paSegments);
     379
     380    uint32_t i = RT_ELEMENTS(pThis->apNameLookup);
     381    while (i-- > 0)
     382    {
     383        POMFWRLNAME pNext = pThis->apNameLookup[i];
     384        pThis->apNameLookup[i] = NULL;
     385        while (pNext)
     386        {
     387            POMFWRLNAME pFree = pNext;
     388            pNext = pNext->pNext;
     389            free(pFree);
     390        }
     391    }
     392
    359393    free(pThis);
    360394}
     
    424458}
    425459
    426 static bool omfWriter_RecAddStringN(POMFWRITER pThis, const char *pchString, size_t cchString)
     460static bool omfWriter_RecAddStringNEx(POMFWRITER pThis, const char *pchString, size_t cchString, bool fPrependUnderscore)
    427461{
    428462    if (cchString < 256)
    429463    {
    430         return omfWriter_RecAddU8(pThis, (uint8_t)cchString)
     464        return omfWriter_RecAddU8(pThis, (uint8_t)cchString + fPrependUnderscore)
     465            && (!fPrependUnderscore || omfWriter_RecAddU8(pThis, '_'))
    431466            && omfWriter_RecAddBytes(pThis, pchString, cchString);
    432467    }
     
    435470}
    436471
     472static bool omfWriter_RecAddStringN(POMFWRITER pThis, const char *pchString, size_t cchString)
     473{
     474    return omfWriter_RecAddStringNEx(pThis, pchString, cchString, false /*fPrependUnderscore*/);
     475}
     476
    437477static bool omfWriter_RecAddString(POMFWRITER pThis, const char *pszString)
    438478{
    439     return omfWriter_RecAddStringN(pThis, pszString, strlen(pszString));
     479    return omfWriter_RecAddStringNEx(pThis, pszString, strlen(pszString), false /*fPrependUnderscore*/);
    440480}
    441481
     
    471511}
    472512
     513
     514/**
     515 * Simple stupid string hashing function (for LNAMES)
     516 * @returns 8-bit hash.
     517 * @param   pchName             The string.
     518 * @param   cchName             The string length.
     519 */
     520DECLINLINE(uint8_t) omfWriter_HashStrU8(const char *pchName, size_t cchName)
     521{
     522    if (cchName)
     523        return (uint8_t)(cchName + pchName[cchName >> 1]);
     524    return 0;
     525}
     526
     527/**
     528 * Looks up a LNAME.
     529 *
     530 * @returns Index (0..32K) if found, UINT16_MAX if not found.
     531 * @param   pThis               The OMF writer.
     532 * @param   pchName             The name to look up.
     533 * @param   cchName             The length of the name.
     534 */
     535static uint16_t omfWriter_LNamesLookupN(POMFWRITER pThis, const char *pchName, size_t cchName)
     536{
     537    uint8_t uHash = omfWriter_HashStrU8(pchName, cchName);
     538    uHash %= RT_ELEMENTS(pThis->apNameLookup);
     539
     540    POMFWRLNAME pCur = pThis->apNameLookup[uHash];
     541    while (pCur)
     542    {
     543        if (   pCur->cchName == cchName
     544            && memcmp(pCur->szName, pchName, cchName) == 0)
     545            return pCur->idxName;
     546        pCur = pCur->pNext;
     547    }
     548
     549    return UINT16_MAX;
     550}
     551
     552/**
     553 * Add a LNAME lookup record.
     554 *
     555 * @returns success indicator.
     556 * @param   pThis               The OMF writer.
     557 * @param   pchName             The name to look up.
     558 * @param   cchName             The length of the name.
     559 * @param   idxName             The name index.
     560 */
     561static bool omfWriter_LNamesAddLookup(POMFWRITER pThis, const char *pchName, size_t cchName, uint16_t idxName)
     562{
     563    POMFWRLNAME pCur = (POMFWRLNAME)malloc(sizeof(*pCur) + cchName);
     564    if (!pCur)
     565        return error("???", "Out of memory!\n");
     566
     567    pCur->idxName = idxName;
     568    pCur->cchName = (uint8_t)cchName;
     569    memcpy(pCur->szName, pchName, cchName);
     570    pCur->szName[cchName] = '\0';
     571
     572    uint8_t uHash = omfWriter_HashStrU8(pchName, cchName);
     573    uHash %= RT_ELEMENTS(pThis->apNameLookup);
     574    pCur->pNext = pThis->apNameLookup[uHash];
     575    pThis->apNameLookup[uHash] = pCur;
     576
     577    return true;
     578}
     579
     580
    473581static bool omfWriter_LNamesAddN(POMFWRITER pThis, const char *pchName, size_t cchName, uint16_t *pidxName)
    474582{
     583    /* See if we've already got that name in the list. */
     584    uint16_t idxName;
     585    if (pidxName) /* If pidxName is NULL, we assume the caller migth just be passing stuff thru. */
     586    {
     587        idxName = omfWriter_LNamesLookupN(pThis, pchName, cchName);
     588        if (idxName != UINT16_MAX)
     589        {
     590            *pidxName = idxName;
     591            return true;
     592        }
     593    }
     594
    475595    /* split? */
    476596    if (pThis->cbRec + 1 /*len*/ + cchName + 1 /*crc*/ > OMF_MAX_RECORD_PAYLOAD)
     
    483603    }
    484604
     605    idxName = pThis->idxNextName++;
    485606    if (pidxName)
    486         *pidxName = pThis->idxNextName;
    487     pThis->idxNextName++;
    488     return omfWriter_RecAddStringN(pThis, pchName, cchName);
     607        *pidxName = idxName;
     608    return omfWriter_RecAddStringN(pThis, pchName, cchName)
     609        && omfWriter_LNamesAddLookup(pThis, pchName, cchName, idxName);
    489610}
    490611
     
    548669}
    549670
    550 static bool omfWriter_PubDefAddN(POMFWRITER pThis, uint32_t uValue, const char *pchString, size_t cchString)
     671static bool omfWriter_PubDefAddN(POMFWRITER pThis, uint32_t uValue, const char *pchString, size_t cchString,
     672                                 bool fPrependUnderscore)
    551673{
    552674    /* Split? */
    553     if (pThis->cbRec + 1 + cchString + 4 + 1 + 1 > OMF_MAX_RECORD_PAYLOAD)
     675    if (pThis->cbRec + 1 + cchString + 4 + 1 + 1 + fPrependUnderscore > OMF_MAX_RECORD_PAYLOAD)
    554676    {
    555677        if (cchString >= 256)
     
    568690    }
    569691
    570     return omfWriter_RecAddStringN(pThis, pchString, cchString)
     692    return omfWriter_RecAddStringNEx(pThis, pchString, cchString, fPrependUnderscore)
    571693        && omfWriter_RecAddU32(pThis, uValue)
    572694        && omfWriter_RecAddIdx(pThis, 0); /* type */
    573695}
    574696
    575 static bool omfWriter_PubDefAdd(POMFWRITER pThis, uint32_t uValue, const char *pszString)
    576 {
    577     return omfWriter_PubDefAddN(pThis, uValue, pszString, strlen(pszString));
     697static bool omfWriter_PubDefAdd(POMFWRITER pThis, uint32_t uValue, const char *pszString, bool fPrependUnderscore)
     698{
     699    return omfWriter_PubDefAddN(pThis, uValue, pszString, strlen(pszString), fPrependUnderscore);
    578700}
    579701
     
    595717 * EXTDEF - Add an entry, split record if necessary.
    596718 */
    597 static bool omfWriter_ExtDefAddN(POMFWRITER pThis, const char *pchString, size_t cchString, uint16_t idxType)
     719static bool omfWriter_ExtDefAddN(POMFWRITER pThis, const char *pchString, size_t cchString, uint16_t idxType,
     720                                 bool fPrependUnderscore)
    598721{
    599722    /* Split? */
    600     if (pThis->cbRec + 1 + cchString + 1 + 1 > OMF_MAX_RECORD_PAYLOAD)
     723    if (pThis->cbRec + 1 + cchString + 1 + 1 + fPrependUnderscore > OMF_MAX_RECORD_PAYLOAD)
    601724    {
    602725        if (cchString >= 256)
     
    608731    }
    609732
    610     return omfWriter_RecAddStringN(pThis, pchString, cchString)
     733    return omfWriter_RecAddStringNEx(pThis, pchString, cchString, fPrependUnderscore)
    611734        && omfWriter_RecAddIdx(pThis, idxType); /* type */
    612735}
     
    615738 * EXTDEF - Add an entry, split record if necessary.
    616739 */
    617 static bool omfWriter_ExtDefAdd(POMFWRITER pThis, const char *pszString)
    618 {
    619     return omfWriter_ExtDefAddN(pThis, pszString, strlen(pszString), 0);
     740static bool omfWriter_ExtDefAdd(POMFWRITER pThis, const char *pszString, bool fPrependUnderscore)
     741{
     742    return omfWriter_ExtDefAddN(pThis, pszString, strlen(pszString), 0, fPrependUnderscore);
    620743}
    621744
     
    15061629                        && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    15071630                    {
     1631                        /* Underscore prefix all names not already underscored/mangled. */
    15081632                        const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    1509                         if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName))
     1633                        if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName, pszName[0] != '_'))
    15101634                            return false;
    1511 
    1512                         /* If the symbol doesn't start with an underscore and is a _c64 or _lm64 symbol,
    1513                            add an underscore prefixed alias to ease access from 16-bit and 32-bit code. */
    1514                         size_t cchName = strlen(pszName);
    1515                         if (   *pszName != '_'
    1516                             && (   (cchName > 4 && strcmp(&pszName[cchName - 4], "_c64")  == 0)
    1517                                 || (cchName > 5 && strcmp(&pszName[cchName - 5], "_lm64") == 0) ) )
    1518                         {
    1519                             char   szCdeclName[512];
    1520                             if (cchName > sizeof(szCdeclName) - 2)
    1521                                 cchName = sizeof(szCdeclName) - 2;
    1522                             szCdeclName[0] = '_';
    1523                             memcpy(&szCdeclName[1], pszName, cchName);
    1524                             szCdeclName[cchName + 1] = '\0';
    1525                             if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, szCdeclName))
    1526                                 return false;
    1527                         }
    1528 
    15291635                        pThis->paSymbols[iSym].idx = idxPubDef++;
    15301636                    }
     
    15421648                && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    15431649            {
     1650                /* Underscore prefix all names not already underscored/mangled. */
    15441651                const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    1545                 if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName))
     1652                if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName, pszName[0] != '_'))
    15461653                    return false;
    15471654                pThis->paSymbols[iSym].idx = idxPubDef++;
     
    15601667        if (pThis->paSymbols[iSym].enmType == OMFSYMTYPE_EXTDEF)
    15611668        {
     1669            /* Underscore prefix all names not already underscored/mangled. */
    15621670            const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    1563             if (!omfWriter_ExtDefAdd(pThis, pszName))
     1671            if (!omfWriter_ExtDefAdd(pThis, pszName, *pszName != '_'))
    15641672                return false;
    15651673            pThis->paSymbols[iSym].idx = idxExtDef++;
     
    23372445                        && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    23382446                    {
     2447                        /* Underscore prefix all symbols not already underscored or mangled. */
    23392448                        const char *pszName = coffGetSymbolName(&paSymbols[iSym], pchStrTab, cbStrTab, szShort);
    2340                         if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].Value, pszName))
     2449                        if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].Value, pszName, pszName[0] != '_' && pszName[0] != '?'))
    23412450                            return false;
    2342 
    2343                         /* If the symbol doesn't start with an underscore and is a _c64 or _lm64 symbol,
    2344                            add an underscore prefixed alias to ease access from 16-bit and 32-bit code. */
    2345                         size_t cchName = strlen(pszName);
    2346                         if (   *pszName != '_'
    2347                             && (   (cchName > 4 && strcmp(&pszName[cchName - 4], "_c64")  == 0)
    2348                                 || (cchName > 5 && strcmp(&pszName[cchName - 5], "_lm64") == 0) ) )
    2349                         {
    2350                             char   szCdeclName[512];
    2351                             if (cchName > sizeof(szCdeclName) - 2)
    2352                                 cchName = sizeof(szCdeclName) - 2;
    2353                             szCdeclName[0] = '_';
    2354                             memcpy(&szCdeclName[1], pszName, cchName);
    2355                             szCdeclName[cchName + 1] = '\0';
    2356                             if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].Value, szCdeclName))
    2357                                 return false;
    2358                         }
    2359 
    23602451                        pThis->paSymbols[iSym].idx = idxPubDef++;
    23612452                    }
     
    23732464                && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    23742465            {
    2375                 if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].Value,
    2376                                          coffGetSymbolName(&paSymbols[iSym], pchStrTab, cbStrTab, szShort)) )
     2466                /* Underscore prefix all symbols not already underscored or mangled. */
     2467                const char *pszName = coffGetSymbolName(&paSymbols[iSym], pchStrTab, cbStrTab, szShort);
     2468                if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].Value, pszName, pszName[0] != '_' && pszName[0] != '?') )
    23772469                    return false;
    23782470                pThis->paSymbols[iSym].idx = idxPubDef++;
     
    23912483        if (pThis->paSymbols[iSym].enmType == OMFSYMTYPE_EXTDEF)
    23922484        {
    2393             if (!omfWriter_ExtDefAdd(pThis, coffGetSymbolName(&paSymbols[iSym], pchStrTab, cbStrTab, szShort)))
     2485            /* Underscore prefix all symbols not already underscored or mangled. */
     2486            const char *pszName = coffGetSymbolName(&paSymbols[iSym], pchStrTab, cbStrTab, szShort);
     2487            if (!omfWriter_ExtDefAdd(pThis, pszName, pszName[0] != '_' && pszName[0] != '?'))
    23942488                return false;
    23952489            pThis->paSymbols[iSym].idx = idxExtDef++;
     
    24002494    if (iSymImageBase != UINT32_MAX)
    24012495        pThis->idxExtImageBase = pThis->paSymbols[iSymImageBase].idx;
    2402     else if (omfWriter_ExtDefAdd(pThis, "__ImageBase"))
     2496    else if (omfWriter_ExtDefAdd(pThis, "__ImageBase", false /*fPrependUnderscore*/))
    24032497        pThis->idxExtImageBase = idxExtDef;
    24042498    else
     
    27242818};
    27252819
    2726 /** Macro for getting the size of a AMD64 ELF relocation. */
    2727 #define ELF_AMD64_RELOC_SIZE(a_Type) ( (a_Type) < RT_ELEMENTS(g_acbElfAmd64RelTypes) ? g_acbElfAmd64RelTypes[(a_Type)] : 1)
    2728 
    2729 
    2730 typedef struct ELFDETAILS
     2820/** Macro for getting the size of a AMD64 Mach-O relocation. */
     2821#define MACHO_AMD64_RELOC_SIZE(a_Type) ( (a_Type) < RT_ELEMENTS(g_acbMachOAmd64RelTypes) ? g_acbMachOAmd64RelTypes[(a_Type)] : 1)
     2822
     2823
     2824typedef struct MACHODETAILS
    27312825{
    27322826    /** The ELF header. */
     
    27522846    size_t              cbStrTab;
    27532847
    2754 } ELFDETAILS;
    2755 typedef ELFDETAILS *PELFDETAILS;
    2756 typedef ELFDETAILS const *PCELFDETAILS;
    2757 
    2758 
    2759 static bool validateElf(const char *pszFile, uint8_t const *pbFile, size_t cbFile, PELFDETAILS pElfStuff)
    2760 {
    2761     /*
    2762      * Initialize the ELF details structure.
    2763      */
    2764     memset(pElfStuff, 0,  sizeof(*pElfStuff));
    2765     pElfStuff->iSymSh = UINT16_MAX;
    2766     pElfStuff->iStrSh = UINT16_MAX;
     2848} MACHODETAILS;
     2849typedef MACHODETAILS *PMACHODETAILS;
     2850typedef MACHODETAILS const *PCMACHODETAILS;
     2851
     2852
     2853static bool validateMacho(const char *pszFile, uint8_t const *pbFile, size_t cbFile, PMACHODETAILS pMachOStuff)
     2854{
     2855    /*
     2856     * Initialize the Mach-O details structure.
     2857     */
     2858    memset(pMachOStuff, 0,  sizeof(*pMachOStuff));
     2859    pMachOStuff->iSymSh = UINT16_MAX;
     2860    pMachOStuff->iStrSh = UINT16_MAX;
    27672861
    27682862    /*
     
    27702864     */
    27712865    Elf64_Ehdr const *pEhdr = (Elf64_Ehdr const *)pbFile;
    2772     pElfStuff->pEhdr = pEhdr;
     2866    pMachOStuff->pEhdr = pEhdr;
    27732867    if (   pEhdr->e_ident[EI_CLASS] != ELFCLASS64
    27742868        || pEhdr->e_ident[EI_DATA]  != ELFDATA2LSB
     
    27972891     */
    27982892    Elf64_Shdr const *paShdrs = (Elf64_Shdr const *)&pbFile[pEhdr->e_shoff];
    2799     pElfStuff->paShdrs = paShdrs;
     2893    pMachOStuff->paShdrs = paShdrs;
    28002894
    28012895    Elf64_Xword const cbShStrTab = paShdrs[pEhdr->e_shstrndx].sh_size;
     
    28072901                     paShdrs[pEhdr->e_shstrndx].sh_offset, paShdrs[pEhdr->e_shstrndx].sh_size, (Elf64_Xword)cbFile);
    28082902    const char *pchShStrTab = (const char *)&pbFile[paShdrs[pEhdr->e_shstrndx].sh_offset];
    2809     pElfStuff->pchShStrTab = pchShStrTab;
     2903    pMachOStuff->pchShStrTab = pchShStrTab;
    28102904
    28112905    /*
     
    29113005                             i, pszShNm, paShdrs[i].sh_size, cSymbols);
    29123006
    2913             if (pElfStuff->iSymSh == UINT16_MAX)
    2914             {
    2915                 pElfStuff->iSymSh    = (uint16_t)i;
    2916                 pElfStuff->paSymbols = (Elf64_Sym const *)&pbFile[paShdrs[i].sh_offset];
    2917                 pElfStuff->cSymbols  = cSymbols;
     3007            if (pMachOStuff->iSymSh == UINT16_MAX)
     3008            {
     3009                pMachOStuff->iSymSh    = (uint16_t)i;
     3010                pMachOStuff->paSymbols = (Elf64_Sym const *)&pbFile[paShdrs[i].sh_offset];
     3011                pMachOStuff->cSymbols  = cSymbols;
    29183012
    29193013                if (paShdrs[i].sh_link != 0)
     
    29213015                    /* Note! The symbol string table section header may not have been validated yet! */
    29223016                    Elf64_Shdr const *pStrTabShdr = &paShdrs[paShdrs[i].sh_link];
    2923                     pElfStuff->iStrSh    = paShdrs[i].sh_link;
    2924                     pElfStuff->pchStrTab = (const char *)&pbFile[pStrTabShdr->sh_offset];
    2925                     pElfStuff->cbStrTab  = (size_t)pStrTabShdr->sh_size;
     3017                    pMachOStuff->iStrSh    = paShdrs[i].sh_link;
     3018                    pMachOStuff->pchStrTab = (const char *)&pbFile[pStrTabShdr->sh_offset];
     3019                    pMachOStuff->cbStrTab  = (size_t)pStrTabShdr->sh_size;
    29263020                }
    29273021                else
     
    29313025            else
    29323026                fRet = error(pszFile, "Section #%u '%s': Found additonal symbol table, previous in #%u\n",
    2933                              i, pszShNm, pElfStuff->iSymSh);
     3027                             i, pszShNm, pMachOStuff->iSymSh);
    29343028        }
    29353029    }
     
    29373031}
    29383032
    2939 static bool convertElfSectionsToSegDefsAndGrpDefs(POMFWRITER pThis, PCELFDETAILS pElfStuff)
     3033static bool convertMachoSectionsToSegDefsAndGrpDefs(POMFWRITER pThis, PCMACHODETAILS pMachOStuff)
    29403034{
    29413035    /*
     
    29543048
    29553049    bool              fHaveData = false;
    2956     Elf64_Shdr const *pShdr     = &pElfStuff->paShdrs[1];
    2957     Elf64_Half const  cSections = pElfStuff->pEhdr->e_shnum;
     3050    Elf64_Shdr const *pShdr     = &pMachOStuff->paShdrs[1];
     3051    Elf64_Half const  cSections = pMachOStuff->pEhdr->e_shnum;
    29583052    for (Elf64_Half i = 1; i < cSections; i++, pShdr++)
    29593053    {
    2960         const char *pszName = &pElfStuff->pchShStrTab[pShdr->sh_name];
     3054        const char *pszName = &pMachOStuff->pchShStrTab[pShdr->sh_name];
    29613055        if (*pszName == '\0')
    29623056            return error(pThis->pszSrc, "Section #%u has an empty name!\n", i);
     
    30483142     */
    30493143    uint16_t iSegDef = 1; /* Start counting at 1. */
    3050     pShdr = &pElfStuff->paShdrs[1];
     3144    pShdr = &pMachOStuff->paShdrs[1];
    30513145    for (Elf64_Half i = 1; i < cSections; i++, pShdr++)
    30523146    {
     
    31403234}
    31413235
    3142 static bool convertElfSymbolsToPubDefsAndExtDefs(POMFWRITER pThis, PCELFDETAILS pElfStuff)
    3143 {
    3144     if (!pElfStuff->cSymbols)
     3236static bool convertMachOSymbolsToPubDefsAndExtDefs(POMFWRITER pThis, PCMACHODETAILS pMachOStuff)
     3237{
     3238    if (!pMachOStuff->cSymbols)
    31453239        return true;
    31463240
     
    31543248        pThis->paSegments[iSeg].cPubDefs = 0;
    31553249
    3156     uint32_t const          cSections = pElfStuff->pEhdr->e_shnum;
    3157     uint32_t const          cSymbols  = pElfStuff->cSymbols;
    3158     Elf64_Sym const * const paSymbols = pElfStuff->paSymbols;
     3250    uint32_t const          cSections = pMachOStuff->pEhdr->e_shnum;
     3251    uint32_t const          cSymbols  = pMachOStuff->cSymbols;
     3252    Elf64_Sym const * const paSymbols = pMachOStuff->paSymbols;
    31593253    for (uint32_t iSym = 0; iSym < cSymbols; iSym++)
    31603254    {
    31613255        const uint8_t bBind      = ELF64_ST_BIND(paSymbols[iSym].st_info);
    31623256        const uint8_t bType      = ELF64_ST_TYPE(paSymbols[iSym].st_info);
    3163         const char   *pszSymName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
     3257        const char   *pszSymName = &pMachOStuff->pchStrTab[paSymbols[iSym].st_name];
    31643258        if (   *pszSymName == '\0'
    31653259            && bType == STT_SECTION
    31663260            && paSymbols[iSym].st_shndx < cSections)
    3167             pszSymName = &pElfStuff->pchShStrTab[pElfStuff->paShdrs[paSymbols[iSym].st_shndx].sh_name];
     3261            pszSymName = &pMachOStuff->pchShStrTab[pMachOStuff->paShdrs[paSymbols[iSym].st_shndx].sh_name];
    31683262
    31693263        pThis->paSymbols[iSym].enmType   = OMFSYMTYPE_IGNORED;
     
    32303324    /*
    32313325     * Emit the PUBDEFs the first time around (see order of records in TIS spec).
     3326     * Note! We expect the os x compiler to always underscore symbols, so unlike the
     3327     *       other 64-bit converters we don't need to check for underscores and add them.
    32323328     */
    32333329    uint16_t idxPubDef = 1;
     
    32443340                        && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    32453341                    {
    3246                         const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    3247                         if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName))
     3342                        const char *pszName = &pMachOStuff->pchStrTab[paSymbols[iSym].st_name];
     3343                        if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName, false /*fPrependUnderscore*/))
    32483344                            return false;
    3249 
    3250                         /* If the symbol doesn't start with an underscore and is a _c64 or _lm64 symbol,
    3251                            add an underscore prefixed alias to ease access from 16-bit and 32-bit code. */
    3252                         size_t cchName = strlen(pszName);
    3253                         if (   *pszName != '_'
    3254                             && (   (cchName > 4 && strcmp(&pszName[cchName - 4], "_c64")  == 0)
    3255                                 || (cchName > 5 && strcmp(&pszName[cchName - 5], "_lm64") == 0) ) )
    3256                         {
    3257                             char   szCdeclName[512];
    3258                             if (cchName > sizeof(szCdeclName) - 2)
    3259                                 cchName = sizeof(szCdeclName) - 2;
    3260                             szCdeclName[0] = '_';
    3261                             memcpy(&szCdeclName[1], pszName, cchName);
    3262                             szCdeclName[cchName + 1] = '\0';
    3263                             if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, szCdeclName))
    3264                                 return false;
    3265                         }
    3266 
    32673345                        pThis->paSymbols[iSym].idx = idxPubDef++;
    32683346                    }
     
    32803358                && pThis->paSymbols[iSym].enmType   == OMFSYMTYPE_PUBDEF)
    32813359            {
    3282                 const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    3283                 if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName))
     3360                const char *pszName = &pMachOStuff->pchStrTab[paSymbols[iSym].st_name];
     3361                if (!omfWriter_PubDefAdd(pThis, paSymbols[iSym].st_value, pszName, false /*fPrependUnderscore*/))
    32843362                    return false;
    32853363                pThis->paSymbols[iSym].idx = idxPubDef++;
     
    32983376        if (pThis->paSymbols[iSym].enmType == OMFSYMTYPE_EXTDEF)
    32993377        {
    3300             const char *pszName = &pElfStuff->pchStrTab[paSymbols[iSym].st_name];
    3301             if (!omfWriter_ExtDefAdd(pThis, pszName))
     3378            const char *pszName = &pMachOStuff->pchStrTab[paSymbols[iSym].st_name];
     3379            if (!omfWriter_ExtDefAdd(pThis, pszName, false /*fPrependUnderscore*/))
    33023380                return false;
    33033381            pThis->paSymbols[iSym].idx = idxExtDef++;
     
    33103388}
    33113389
    3312 static bool convertElfSectionsToLeDataAndFixupps(POMFWRITER pThis, PCELFDETAILS pElfStuff, uint8_t const *pbFile, size_t cbFile)
    3313 {
    3314     Elf64_Sym const    *paSymbols = pElfStuff->paSymbols;
    3315     Elf64_Shdr const   *paShdrs   = pElfStuff->paShdrs;
     3390static bool convertMachOSectionsToLeDataAndFixupps(POMFWRITER pThis, PCMACHODETAILS pMachOStuff,
     3391                                                   uint8_t const *pbFile, size_t cbFile)
     3392{
     3393    Elf64_Sym const    *paSymbols = pMachOStuff->paSymbols;
     3394    Elf64_Shdr const   *paShdrs   = pMachOStuff->paShdrs;
    33163395    bool                fRet      = true;
    33173396    for (uint32_t i = 1; i < pThis->cSegments; i++)
     
    33203399            continue;
    33213400
    3322         const char         *pszSegNm   = &pElfStuff->pchShStrTab[paShdrs[i].sh_name];
     3401        const char         *pszSegNm   = &pMachOStuff->pchShStrTab[paShdrs[i].sh_name];
    33233402        bool const          fRelocs    = i + 1 < pThis->cSegments && paShdrs[i + 1].sh_type == SHT_RELA;
    33243403        uint32_t            cRelocs    = fRelocs ? paShdrs[i + 1].sh_size / sizeof(Elf64_Rela) : 0;
     
    33843463                Elf64_Sym const * const pElfSym    =        &paSymbols[iSymbol];
    33853464                POMFSYMBOL const        pOmfSym    = &pThis->paSymbols[iSymbol];
    3386                 const char * const      pszSymName = &pElfStuff->pchStrTab[pElfSym->st_name];
     3465                const char * const      pszSymName = &pMachOStuff->pchStrTab[pElfSym->st_name];
    33873466
    33883467                /* Calc fixup location in the pending chunk and setup a flexible pointer to it. */
     
    35243603     * Validate the source file a little.
    35253604     */
    3526     ELFDETAILS ElfStuff;
    3527     if (!validateElf(pszFile, pbFile, cbFile, &ElfStuff))
     3605    MACHODETAILS MachOStuff;
     3606    if (!validateMachO(pszFile, pbFile, cbFile, &MachOStuff))
    35283607        return false;
    35293608
     
    35313610     * Instantiate the OMF writer.
    35323611     */
    3533     POMFWRITER pThis = omfWriter_Create(pszFile, ElfStuff.pEhdr->e_shnum, ElfStuff.cSymbols, pDst);
     3612    POMFWRITER pThis = omfWriter_Create(pszFile, MachOStuff.pEhdr->e_shnum, MachOStuff.cSymbols, pDst);
    35343613    if (!pThis)
    35353614        return false;
     
    35443623        const char       *pszStrTab = (const char *)&pbFile[paShdrs[pEhdr->e_shstrndx].sh_offset];
    35453624
    3546         if (   convertElfSectionsToSegDefsAndGrpDefs(pThis, &ElfStuff)
    3547             && convertElfSymbolsToPubDefsAndExtDefs(pThis, &ElfStuff)
     3625        if (   convertMachOSectionsToSegDefsAndGrpDefs(pThis, &MachOStuff)
     3626            && convertMachOSymbolsToPubDefsAndExtDefs(pThis, &MachOStuff)
    35483627            && omfWriter_LinkPassSeparator(pThis)
    3549             && convertElfSectionsToLeDataAndFixupps(pThis, &ElfStuff, pbFile, cbFile)
     3628            && convertMachOSectionsToLeDataAndFixupps(pThis, &MachOStuff, pbFile, cbFile)
    35503629            && omfWriter_EndModule(pThis) )
    35513630        {
     
    46824761                                }
    46834762
    4684                             if (!omfWriter_ExtDefAddN(pThis, szName, cchName, idxType))
     4763                            if (!omfWriter_ExtDefAddN(pThis, szName, cchName, idxType, false /*fPrependUnderscore*/))
    46854764                                return false;
    46864765                        }
    4687                         else if (!omfWriter_ExtDefAddN(pThis, pchName, cchName, idxType))
     4766                        else if (!omfWriter_ExtDefAddN(pThis, pchName, cchName, idxType, false /*fPrependUnderscore*/))
    46884767                            return false;
    46894768                    }
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm

    r60365 r60676  
    225225.do_load
    226226        mov     [g_bBootDrv], dl
    227         call    bs3InitLoadImage
     227        call    NAME(bs3InitLoadImage)
    228228%if 0
    229229        mov     al, '='
    230         call bs3PrintChrInAl
     230        call    NAME(bs3PrintChrInAl)
    231231%endif
    232232
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c

    r60527 r60676  
    3737{
    3838    void BS3_FAR   *pvRet;
    39     uint8_t         idxSlabList = bs3MemSizeToSlabListIndex(cb);
     39    uint8_t         idxSlabList;
     40
     41#if ARCH_BITS == 16
     42    /* Don't try allocate memory which address we cannot return. */
     43    if (   enmKind != BS3MEMKIND_REAL
     44        && BS3_MODE_IS_RM_OR_V86(g_bBs3CurrentMode))
     45        enmKind = BS3MEMKIND_REAL;
     46#endif
     47
     48    idxSlabList = bs3MemSizeToSlabListIndex(cb);
    4049    if (idxSlabList < BS3_MEM_SLAB_LIST_COUNT)
    4150    {
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCmp.asm

    r60657 r60676  
    11; $Id$
    22;; @file
    3 ; BS3Kit - Bs3MemSet.
     3; BS3Kit - Bs3MemCmp.
    44;
    55
    66;
    7 ; Copyright (C) 2007-2015 Oracle Corporation
     7; Copyright (C) 2007-2016 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828
    2929;;
    30 ; @cproto   BS3_CMN_PROTO_NOSB(void, Bs3MemSet,(void BS3_FAR *pvDst, uint8_t bFiller, size_t cbDst));
     30; @cproto   BS3_CMN_PROTO_NOSB(int, Bs3MemCmp,(void const BS3_FAR *pv1, void const BS3_FAR *pv2, size_t cb));
    3131;
    32 BS3_PROC_BEGIN_CMN Bs3MemSet, BS3_PBC_HYBRID
     32BS3_PROC_BEGIN_CMN Bs3MemCmp, BS3_PBC_HYBRID
     33TONLY16 CPU 8086
    3334        push    xBP
    3435        mov     xBP, xSP
    3536        push    xDI
    36 %ifdef RT_ARCH_AMD64
     37        push    xSI
     38TNOT64  push    es
     39TONLY16 push    ds
     40        cld
    3741
    38         mov     rdi, rcx                ; rdi = pvDst
    39         mov     rcx, r8                 ; rcx = cbDst
    40         movzx   edx, dl                 ; bFiller
    41         mov     rax, 0101010101010101h
    42         mul     rdx
    43         mov     rcx, r8
    44         shr     rcx, 3                  ; calc qword count.
    45         cld
    46         rep stosq
     42        ;
     43        ; To save complexity and space, do straight forward byte compares.
     44        ;
     45%if TMPL_BITS == 16
     46        mov     di, [bp + 2 + cbCurRetAddr]         ; pv1.off
     47        mov     es, [bp + 2 + cbCurRetAddr + 2]     ; pv1.sel
     48        mov     si, [bp + 2 + cbCurRetAddr + 4]     ; pv2.off
     49        mov     ds, [bp + 2 + cbCurRetAddr + 6]     ; pv2.sel
     50        mov     cx, [bp + 2 + cbCurRetAddr + 8]     ; cbDst
     51        xor     ax, ax
     52        repe cmpsb
     53        je      .return
    4754
    48         mov     rcx, r8                 ; cbDst
    49         and     rcx, 7                  ; calc trailing byte count.
    50         rep stosb
    51 
    52 %elif ARCH_BITS == 16
    53         push    es
    54 
    55         mov     di, [bp + 2 + cbCurRetAddr]     ; pvDst.off
    56         mov     es, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel
    57         mov     al, [bp + 2 + cbCurRetAddr + 4] ; bFiller
    58         mov     ah, al
    59         mov     cx, [bp + 2 + cbCurRetAddr + 6] ; cbDst
    60         shr     cx, 1                           ; calc dword count.
    61         rep stosw
    62 
    63         mov     cx, [bp + 2 + cbCurRetAddr + 6] ; cbDst
    64         and     cx, 1                           ; calc tailing byte count.
    65         rep stosb
    66 
    67         pop     es
    68 
    69 %elif ARCH_BITS == 32
    70         mov     edi, [ebp + 8]                          ; pvDst
    71         mov     al, byte [ebp + 4 + cbCurRetAddr + 4]   ; bFiller
    72         mov     ah, al
    73         mov     dx, ax
    74         shl     eax, 16
    75         mov     ax, dx                                  ; eax = RT_MAKE_U32_FROM_U8(bFiller, bFiller, bFiller, bFiller)
    76         mov     ecx, [ebp + 4 + cbCurRetAddr + 8]       ; cbDst
    77         shr     cx, 2                                   ; calc dword count.
    78         rep stosd
    79 
    80         mov     ecx, [ebp + 4 + cbCurRetAddr + 8]       ; cbDst
    81         and     ecx, 3                                  ; calc tailing byte count.
    82         rep stosb
     55        mov     al, [es:di - 1]
     56        xor     dx, dx
     57        mov     dl, [esi - 1]
     58        sub     ax, dx
    8359
    8460%else
    85  %error "Unknown bitness."
     61 %if TMPL_BITS == 64
     62        mov     rdi, rcx                            ; rdi = pv1
     63        mov     rsi, rdx                            ; rdi = pv2
     64        mov     rcx, r8                             ; rcx = cbDst
     65 %else
     66        mov     ax, ds
     67        mov     es, ax                              ; paranoia
     68        mov     edi, [ebp + 4 + cbCurRetAddr]       ; pv1
     69        mov     esi, [ebp + 4 + cbCurRetAddr + 4]   ; pv2
     70        mov     ecx, [ebp + 4 + cbCurRetAddr + 8]   ; cbDst
     71 %endif
     72        xor     eax, eax
     73        repe cmpsb
     74        je      .return
     75
     76        mov     al, [xDI - 1]
     77        movzx   edx, byte [xSI - 1]
     78        sub     eax, edx
    8679%endif
    8780
     81.return:
     82TONLY16 pop     ds
     83TNOT64  pop     es
     84        pop     xSI
    8885        pop     xDI
    8986        pop     xBP
    9087        BS3_HYBRID_RET
    91 BS3_PROC_END_CMN   Bs3MemSet
     88BS3_PROC_END_CMN   Bs3MemCmp
    9289
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingProtect.c

    r60527 r60676  
    3737*   Defined Constants And Macros                                                                                                 *
    3838*********************************************************************************************************************************/
     39#if 1
     40# define BS3PAGING_DPRINTF1(a) Bs3TestPrintf a
     41#else
     42# define BS3PAGING_DPRINTF1(a) do { } while (0)
     43#endif
    3944#if 0
    40 # define BS3PAGING_DPRINTF(a) Bs3TestPrintf a
    41 #else
    42 # define BS3PAGING_DPRINTF(a) do { } while (0)
     45# define BS3PAGING_DPRINTF2(a) Bs3TestPrintf a
     46#else
     47# define BS3PAGING_DPRINTF2(a) do { } while (0)
    4348#endif
    4449
     
    6873    uint32_t const  uMaxAddr = UINT32_MAX;
    6974#endif
    70     BS3PAGING_DPRINTF(("bs3PagingGetLegacyPte: cr3=%RX32 uFlat=%RX32 uMaxAddr=%RX32\n", (uint32_t)cr3, uFlat, uMaxAddr));
     75    BS3PAGING_DPRINTF2(("bs3PagingGetLegacyPte: cr3=%RX32 uFlat=%RX32 uMaxAddr=%RX32\n", (uint32_t)cr3, uFlat, uMaxAddr));
    7176
    7277    *prc = VERR_OUT_OF_RANGE;
     
    8287
    8388            BS3_ASSERT(pPD->a[iPde].b.u1Present);
    84             BS3PAGING_DPRINTF(("bs3PagingGetLegacyPte: pPD=%p iPde=%#x: %#RX32\n", pPD, iPde, pPD->a[iPde]));
     89            BS3PAGING_DPRINTF2(("bs3PagingGetLegacyPte: pPD=%p iPde=%#x: %#RX32\n", pPD, iPde, pPD->a[iPde]));
    8590            if (pPD->a[iPde].b.u1Present)
    8691            {
     
    8893                {
    8994                    if (pPD->a[iPde].u <= uMaxAddr)
     95                    {
    9096                        pPTE = &((X86PT BS3_FAR *)Bs3XptrFlatToCurrent(pPD->a[iPde].u & ~(uint32_t)PAGE_OFFSET_MASK))->a[iPte];
     97                        *prc = VINF_SUCCESS;
     98                    }
     99                    else
     100                        BS3PAGING_DPRINTF1(("bs3PagingGetLegacyPte: out of range! iPde=%#x: %#x\n", iPde, pPD->a[iPde].u));
    91101                }
    92102                else
     
    99109                        uPte |= X86_PTE_PAT;
    100110
    101                     pPT = (X86PT BS3_FAR *)bs3PagingBuildPaeTable(RT_MAKE_U64(uPte, uPte + PAGE_SIZE),
     111                    pPT = (X86PT BS3_FAR *)bs3PagingBuildPaeTable(RT_MAKE_U64(uPte, uPte | PAGE_SIZE),
    102112                                                                  RT_MAKE_U64(PAGE_SIZE*2, PAGE_SIZE*2),
    103113                                                                  uMaxAddr > _1M ? BS3MEMKIND_TILED : BS3MEMKIND_REAL, prc);
    104114
    105                     BS3PAGING_DPRINTF(("bs3PagingGetLegacyPte: Built pPT=%p uPte=%RX32\n", pPT, uPte));
     115                    BS3PAGING_DPRINTF2(("bs3PagingGetLegacyPte: Built pPT=%p uPte=%RX32\n", pPT, uPte));
    106116                    if (pPT)
    107117                    {
    108118                        pPD->a[iPde].u = Bs3SelPtrToFlat(pPT)
    109119                                       | (pPD->a[iPde].u & ~(uint32_t)(X86_PTE_PG_MASK | X86_PDE4M_PS | X86_PDE4M_G | X86_PDE4M_D));
    110                         BS3PAGING_DPRINTF(("bs3PagingGetLegacyPte: iPde=%#x: %#RX32\n", iPde, pPD->a[iPde].u));
     120                        BS3PAGING_DPRINTF2(("bs3PagingGetLegacyPte: iPde=%#x: %#RX32\n", iPde, pPD->a[iPde].u));
    111121                        if (fUseInvlPg)
    112122                            ASMInvalidatePage(uFlat);
    113123                        pPTE = &pPT->a[iPte];
     124                        *prc = VINF_SUCCESS;
    114125                    }
    115126                }
     
    117128        }
    118129    }
     130    else
     131        BS3PAGING_DPRINTF1(("bs3PagingGetLegacyPte: out of range! cr3=%#x\n", cr3));
    119132    return pPTE;
    120133}
     
    149162                    if ((pPdpt->a[iPdpte].u & X86_PDPE_PG_MASK) <= uMaxAddr)
    150163                        pPD = (X86PDPAE BS3_FAR *)Bs3XptrFlatToCurrent(pPdpt->a[iPdpte].u & ~(uint64_t)PAGE_OFFSET_MASK);
     164                    else
     165                        BS3PAGING_DPRINTF1(("bs3PagingGetPte: out of range! iPdpte=%#x: %RX64 max=%RX32\n",
     166                                            iPdpte, pPdpt->a[iPdpte].u, (uint32_t)uMaxAddr));
    151167                }
    152168                else
     
    174190            if ((pPdpt->a[iPdpte].u & X86_PDPE_PG_MASK) <= uMaxAddr)
    175191                pPD = (X86PDPAE BS3_FAR *)Bs3XptrFlatToCurrent(pPdpt->a[iPdpte].u & X86_PDPE_PG_MASK);
     192            else
     193                BS3PAGING_DPRINTF1(("bs3PagingGetPte: out of range! iPdpte=%#x: %RX64 max=%RX32\n",
     194                                    iPdpte, pPdpt->a[iPdpte].u, (uint32_t)uMaxAddr));
    176195        }
    177196        else
     197        {
    178198            pPD = NULL;
     199            BS3PAGING_DPRINTF1(("bs3PagingGetPte: out of range! uFlat=%#RX64 max=%RX32\n", uFlat, (uint32_t)uMaxAddr));
     200        }
    179201        if (pPD)
    180202        {
     
    184206            {
    185207                if ((pPD->a[iPde].u & X86_PDE_PAE_PG_MASK) <= uMaxAddr)
     208                {
    186209                    pPTE = &((X86PTPAE BS3_FAR *)Bs3XptrFlatToCurrent(pPD->a[iPde].u & ~(uint64_t)PAGE_OFFSET_MASK))->a[iPte];
     210                    *prc = VINF_SUCCESS;
     211                }
     212                else
     213                    BS3PAGING_DPRINTF1(("bs3PagingGetPte: out of range! iPde=%#x: %RX64 max=%RX32\n",
     214                                        iPde, pPD->a[iPde].u, (uint32_t)uMaxAddr));
    187215            }
    188216            else
     
    205233                        ASMInvalidatePage(uFlat);
    206234                    pPTE = &pPT->a[iPte];
     235                    *prc = VINF_SUCCESS;
    207236                }
    208237            }
    209238        }
    210239    }
    211 
     240    else
     241        BS3PAGING_DPRINTF1(("bs3PagingGetPte: out of range! cr3=%#RX32 uMaxAddr=%#RX32\n", (uint32_t)cr3, (uint32_t)uMaxAddr));
    212242    return pPTE;
    213243}
     
    217247BS3_CMN_DEF(int, Bs3PagingProtect,(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear))
    218248{
    219     RTCCUINTXREG const  cr3        = ASMGetCR3();
    220     RTCCUINTXREG const  cr4        = g_uBs3CpuDetected & BS3CPU_F_CPUID ? ASMGetCR4() : 0;
    221     bool const          fLegacyPTs = !(cr4 & X86_CR4_PAE);
    222     bool const          fUseInvlPg = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80486
    223                                   && (   cb < UINT64_C(16)*PAGE_SIZE
    224                                       || (cr4 & X86_CR4_PGE));
    225     unsigned            cEntries;
    226     int                 rc;
    227 
     249#if ARCH_BITS == 16
     250    if (!BS3_MODE_IS_V86(g_bBs3CurrentMode))
     251#endif
     252    {
     253        RTCCUINTXREG const  cr3        = ASMGetCR3();
     254        RTCCUINTXREG const  cr4        = g_uBs3CpuDetected & BS3CPU_F_CPUID ? ASMGetCR4() : 0;
     255        bool const          fLegacyPTs = !(cr4 & X86_CR4_PAE);
     256        bool const          fUseInvlPg = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80486
     257                                      && (   cb < UINT64_C(16)*PAGE_SIZE
     258                                          || (cr4 & X86_CR4_PGE));
     259        unsigned            cEntries;
     260        int                 rc;
     261
     262        /*
     263         * Adjust the range parameters.
     264         */
     265        cb += uFlat & PAGE_OFFSET_MASK;
     266        cb = RT_ALIGN_64(cb, PAGE_SIZE);
     267        uFlat &= ~(uint64_t)PAGE_OFFSET_MASK;
     268
     269        fSet   &= ~X86_PTE_PAE_PG_MASK;
     270        fClear &= ~X86_PTE_PAE_PG_MASK;
     271
     272        BS3PAGING_DPRINTF1(("Bs3PagingProtect: uFlat=%RX64 cb=%RX64 fSet=%RX64 fClear=%RX64 %s %s\n", uFlat, cb, fSet, fClear,
     273                            fLegacyPTs ? "legacy" : "pae/amd64", fUseInvlPg ? "invlpg" : "reload-cr3"));
     274        if (fLegacyPTs)
     275        {
     276            /*
     277             * Legacy page tables.
     278             */
     279            while ((uint32_t)cb > 0)
     280            {
     281                PX86PTE pPte = BS3_CMN_FAR_NM(bs3PagingGetLegacyPte)(cr3, (uint32_t)uFlat, fUseInvlPg, &rc);
     282                if (!pPte)
     283                    return rc;
     284
     285                cEntries = X86_PG_ENTRIES - ((uFlat >> X86_PT_SHIFT) & X86_PT_MASK);
     286                while (cEntries-- > 0 && cb > 0)
     287                {
     288                    pPte->u &= ~(uint32_t)fClear;
     289                    pPte->u |= (uint32_t)fSet;
     290                    if (fUseInvlPg)
     291                        ASMInvalidatePage(uFlat);
     292
     293                    pPte++;
     294                    uFlat += PAGE_SIZE;
     295                    cb    -= PAGE_SIZE;
     296                }
     297            }
     298        }
     299        else
     300        {
     301            /*
     302             * Long mode or PAE page tables (at this level they are the same).
     303             */
     304            while (cb > 0)
     305            {
     306                PX86PTEPAE pPte = BS3_CMN_FAR_NM(bs3PagingGetPte)(cr3, uFlat, fUseInvlPg, &rc);
     307                if (!pPte)
     308                    return rc;
     309
     310                cEntries = X86_PG_ENTRIES - ((uFlat >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK);
     311                while (cEntries-- > 0 && cb > 0)
     312                {
     313                    pPte->u &= ~fClear;
     314                    pPte->u |= fSet;
     315                    if (fUseInvlPg)
     316                        ASMInvalidatePage(uFlat);
     317
     318                    pPte++;
     319                    uFlat += PAGE_SIZE;
     320                    cb    -= PAGE_SIZE;
     321                }
     322            }
     323        }
     324
     325        /*
     326         * Flush the TLB if we didn't use INVLPG above.
     327         */
     328        BS3PAGING_DPRINTF2(("Bs3PagingProtect: reloading cr3=%RX32\n", (uint32_t)cr3));
     329        //if (!fUseInvlPg)
     330            ASMSetCR3(cr3);
     331        BS3PAGING_DPRINTF2(("Bs3PagingProtect: reloaded cr3=%RX32\n", (uint32_t)cr3));
     332    }
     333#if ARCH_BITS == 16
    228334    /*
    229      * Adjust the range parameters.
     335     * We can do this stuff in v8086 mode.
    230336     */
    231     cb += uFlat & PAGE_OFFSET_MASK;
    232     cb = RT_ALIGN_64(cb, PAGE_SIZE);
    233     uFlat &= ~(uint64_t)PAGE_OFFSET_MASK;
    234 
    235     fSet   &= ~X86_PTE_PAE_PG_MASK;
    236     fClear &= ~X86_PTE_PAE_PG_MASK;
    237 
    238     BS3PAGING_DPRINTF(("Bs3PagingProtect: uFlat=%RX64 cb=%RX64 fSet=%RX64 fClear=%RX64 %s %s\n", uFlat, cb, fSet, fClear,
    239                        fLegacyPTs ? "legacy" : "pae/amd64", fUseInvlPg ? "invlpg" : "reload-cr3"));
    240     if (fLegacyPTs)
    241     {
    242         /*
    243          * Legacy page tables.
    244          */
    245         while ((uint32_t)cb > 0)
    246         {
    247             PX86PTE pPte = BS3_CMN_NM(bs3PagingGetLegacyPte)(cr3, (uint32_t)uFlat, fUseInvlPg, &rc);
    248             if (!pPte)
    249                 return rc;
    250 
    251             cEntries = X86_PG_ENTRIES - ((uFlat >> X86_PT_SHIFT) & X86_PT_MASK);
    252             while (cEntries-- > 0 && cb > 0)
    253             {
    254                 pPte->u &= ~(uint32_t)fClear;
    255                 pPte->u |= (uint32_t)fSet;
    256                 if (fUseInvlPg)
    257                     ASMInvalidatePage(uFlat);
    258 
    259                 pPte++;
    260                 uFlat += PAGE_SIZE;
    261                 cb    -= PAGE_SIZE;
    262             }
    263         }
    264     }
    265337    else
    266     {
    267         /*
    268          * Long mode or PAE page tables (at this level they are the same).
    269          */
    270         while (cb > 0)
    271         {
    272             PX86PTEPAE pPte = BS3_CMN_NM(bs3PagingGetPte)(cr3, uFlat, fUseInvlPg, &rc);
    273             if (!pPte)
    274                 return rc;
    275 
    276             cEntries = X86_PG_ENTRIES - ((uFlat >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK);
    277             while (cEntries-- > 0 && cb > 0)
    278             {
    279                 pPte->u &= ~fClear;
    280                 pPte->u |= fSet;
    281                 if (fUseInvlPg)
    282                     ASMInvalidatePage(uFlat);
    283 
    284                 pPte++;
    285                 uFlat += PAGE_SIZE;
    286                 cb    -= PAGE_SIZE;
    287             }
    288         }
    289     }
    290 
    291     /*
    292      * Flush the TLB if we didn't use INVLPG above.
    293      */
    294     BS3PAGING_DPRINTF(("Bs3PagingProtect: reloading cr3=%RX32\n", (uint32_t)cr3));
    295     //if (!fUseInvlPg)
    296         ASMSetCR3(cr3);
    297     BS3PAGING_DPRINTF(("Bs3PagingProtect: reloaded cr3=%RX32\n", (uint32_t)cr3));
    298 
     338        return Bs3SwitchFromV86To16BitAndCallC((FPFNBS3FAR)Bs3PagingProtect_f16, sizeof(uint64_t)*4, uFlat, cb, fSet, fClear);
     339#endif
    299340    return VINF_SUCCESS;
    300341}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelRealModeDataToFlat.asm

    r60657 r60676  
    4343;;
    4444; @cproto   BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelRealModeDataToFlat,(uint32_t uFar1616));
     45; @cproto   BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelRealModeCodeToFlat,(uint32_t uFar1616));
    4546;
    4647; @uses     Only return registers (ax:dx, eax, eax);
    4748; @remarks  No 20h scratch area requirements.
    4849;
     50BS3_PROC_BEGIN_CMN Bs3SelRealModeCodeToFlat, BS3_PBC_NEAR      ; Far stub generated by the makefile/bs3kit.h.
    4951BS3_PROC_BEGIN_CMN Bs3SelRealModeDataToFlat, BS3_PBC_NEAR      ; Far stub generated by the makefile/bs3kit.h.
    5052        push    xBP
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm

    r60557 r60676  
    221221%elif BS3_MODE_IS_64BIT_SYS(TMPL_MODE)
    222222        BS3_EXTERN_CMN Bs3Trap64SetGate
    223         extern         Bs3TrapSystemCallHandler_lm64
     223        extern         _Bs3TrapSystemCallHandler_lm64
    224224        TMPL_BEGIN_TEXT
    225225        push    0                       ; bIst
    226226 %if BS3_MODE_IS_64BIT_CODE(TMPL_MODE)
    227         push    Bs3TrapSystemCallHandler_lm64 wrt FLAT
     227        push    _Bs3TrapSystemCallHandler_lm64 wrt FLAT
    228228 %else
    229229        push    dword 0                 ; upper offset
    230         push    dword Bs3TrapSystemCallHandler_lm64 wrt FLAT
     230        push    dword _Bs3TrapSystemCallHandler_lm64 wrt FLAT
    231231 %endif
    232232        push    BS3_SEL_R0_CS64
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm

    r60557 r60676  
    134134extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32):wrt BS3FLAT
    135135extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm32):wrt BS3FLAT
    136 extern RT_CONCAT3(Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64):wrt BS3FLAT
     136extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64):wrt BS3FLAT
    137137
    138138
     
    11051105
    11061106        STRICT_SAVE_REGS
    1107         call    RT_CONCAT3(Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64)
     1107        call    RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64)
    11081108        BS3_SET_BITS TMPL_BITS
    11091109        STRICT_CHECK_REGS
     
    11331133
    11341134%endif
     1135
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-I8DQ.asm

    r60595 r60676  
    3333; 64-bit unsigned integer division, SS variant.
    3434;
    35 ; @returns  ax:bx:cx:dx quotient.
     35; @returns  ax:bx:cx:dx quotient. (AX is the most significant, DX the least)
    3636; @param    ax:bx:cx:dx     Dividend.
    3737; @param    [ss:si]         Divisor
     
    5858; 64-bit unsigned integer division, ES variant.
    5959;
    60 ; @returns  ax:bx:cx:dx quotient.
     60; @returns  ax:bx:cx:dx quotient. (AX is the most significant, DX the least)
    6161; @param    ax:bx:cx:dx     Dividend.
    6262; @param    [es:si]         Divisor
     
    8888
    8989        ; The dividend.
     90        push    ax
     91        push    bx
     92        push    cx
    9093        push    dx
    91         push    cx
    92         push    bx
    93         push    ax
    9494
    9595        call    Bs3Int64Div
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-I8DR.asm

    r60595 r60676  
    3333; 64-bit unsigned integer modulo, SS variant.
    3434;
    35 ; @returns  ax:bx:cx:dx reminder.
     35; @returns  ax:bx:cx:dx reminder. (AX is the most significant, DX the least)
    3636; @param    ax:bx:cx:dx     Dividend.
    3737; @param    [ss:si]         Divisor
     
    8888
    8989        ; The dividend.
     90        push    ax
     91        push    bx
     92        push    cx
    9093        push    dx
    91         push    cx
    92         push    bx
    93         push    ax
    9494
    9595        call    Bs3Int64Div
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-I8RS.asm

    r60595 r60676  
    3131; 64-bit signed integer left shift.
    3232;
    33 ; @returns  AX:BX:CX:DX
     33; @returns  AX:BX:CX:DX (AX is the most significant, DX the least)
    3434; @param    AX:BX:CX:DX Value to shift.
    3535; @param    SI          Shift count.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-U8DQ.asm

    r60595 r60676  
    3333; 64-bit unsigned integer division, SS variant.
    3434;
    35 ; @returns  ax:bx:cx:dx quotient.
     35; @returns  ax:bx:cx:dx quotient.  (AX is the most significant, DX the least)
    3636; @param    ax:bx:cx:dx     Dividend.
    3737; @param    [ss:si]         Divisor
     
    5858; 64-bit unsigned integer division, ES variant.
    5959;
    60 ; @returns  ax:bx:cx:dx quotient.
     60; @returns  ax:bx:cx:dx quotient. (AX is the most significant, DX the least)
    6161; @param    ax:bx:cx:dx     Dividend.
    6262; @param    [es:si]         Divisor
     
    9090
    9191        ; The dividend.
     92        push    ax
     93        push    bx
     94        push    cx
    9295        push    dx
    93         push    cx
    94         push    bx
    95         push    ax
    9696
    9797        call    Bs3UInt64Div
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-U8DR.asm

    r60595 r60676  
    3333; 64-bit unsigned integer modulo, SS variant.
    3434;
    35 ; @returns  ax:bx:cx:dx reminder.
     35; @returns  ax:bx:cx:dx reminder. (AX is the most significant, DX the least)
    3636; @param    ax:bx:cx:dx     Dividend.
    3737; @param    [ss:si]         Divisor
     
    5858; 64-bit unsigned integer modulo, ES variant.
    5959;
    60 ; @returns  ax:bx:cx:dx reminder.
     60; @returns  ax:bx:cx:dx reminder. (AX is the most significant, DX the least)
    6161; @param    ax:bx:cx:dx     Dividend.
    6262; @param    [es:si]         Divisor
     
    9090
    9191        ; The dividend.
     92        push    ax
     93        push    bx
     94        push    cx
    9295        push    dx
    93         push    cx
    94         push    bx
    95         push    ax
    9696
    9797        call    Bs3UInt64Div
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-U8LS.asm

    r60595 r60676  
    3131; 64-bit integer left shift.
    3232;
    33 ; @returns  AX:BX:CX:DX
     33; @returns  AX:BX:CX:DX (AX is the most significant, DX the least)
    3434; @param    AX:BX:CX:DX Value to shift.
    3535; @param    SI          Shift count.
     
    4747        ; time in the below loop.
    4848        ;
    49         ; Using 8086 comatible approach here as it's less hazzle to write
     49        ; Using 8086 compatible approach here as it's less hazzle to write
    5050        ; and smaller.
    5151        ;
    5252        and     si, 3fh
     53
    5354        jz      .return
    54 
    5555.next_shift:
    56         shl     ax, 1
     56        shl     dx, 1
     57        rcl     cx, 1
    5758        rcl     bx, 1
    58         rcl     cx, 1
    59         rcl     dx, 1
     59        rcl     ax, 1
    6060        dec     si
    6161        jnz     .next_shift
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-wc16-U8RS.asm

    r60595 r60676  
    3131; 64-bit unsigned integer left shift.
    3232;
    33 ; @returns  AX:BX:CX:DX
     33; @returns  AX:BX:CX:DX (AX is the most significant, DX the least)
    3434; @param    AX:BX:CX:DX Value to shift.
    3535; @param    SI          Shift count.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk

    r60657 r60676  
    2929$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelProtFar16DataToFlat,4)
    3030$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelProtFar16DataToRealMode,4)
     31$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeCodeToFlat,4)
    3132$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToFlat,4)
    3233$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToProtFar16,4)
     
    4041$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingProtect)
    4142$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingProtectPtr)
     43$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SwitchFromV86To16BitAndCallC)
    4244$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandler)
    4345$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Printf)
     
    5557$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemAllocZ)
    5658$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemCpy)
     59$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageAlloc)
     60$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageAllocEx)
    5761$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemMove)
    5862$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemPCpy)
     
    6266$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAllocEx)
    6367$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemFree)
     68$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageFree)
    6469$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PicMaskAll)
    6570$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PrintStr)
    6671$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxConvertToRingX)
    6772$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxPrint)
     73$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxSetGrpDsFromCurPtr)
     74$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxSetGrpSegFromCurPtr)
     75$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxSetGrpSegFromFlat)
     76$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxSetRipCsFromLnkPtr)
    6877$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabInit)
    6978$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAdd)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h

    r60657 r60676  
    3737#define Bs3MemAllocZ BS3_CMN_MANGLER(Bs3MemAllocZ)
    3838#define Bs3MemChr BS3_CMN_MANGLER(Bs3MemChr)
     39#define Bs3MemCmp BS3_CMN_MANGLER(Bs3MemCmp)
    3940#define Bs3MemCpy BS3_CMN_MANGLER(Bs3MemCpy)
    4041#define Bs3MemFree BS3_CMN_MANGLER(Bs3MemFree)
     42#define Bs3MemGuardedTestPageAlloc BS3_CMN_MANGLER(Bs3MemGuardedTestPageAlloc)
     43#define Bs3MemGuardedTestPageAllocEx BS3_CMN_MANGLER(Bs3MemGuardedTestPageAllocEx)
     44#define Bs3MemGuardedTestPageFree BS3_CMN_MANGLER(Bs3MemGuardedTestPageFree)
    4145#define Bs3MemMove BS3_CMN_MANGLER(Bs3MemMove)
    4246#define Bs3MemPCpy BS3_CMN_MANGLER(Bs3MemPCpy)
     
    6266#define Bs3RegCtxSave BS3_CMN_MANGLER(Bs3RegCtxSave)
    6367#define Bs3RegCtxSaveEx BS3_CMN_MANGLER(Bs3RegCtxSaveEx)
     68#define Bs3RegCtxSetGrpDsFromCurPtr BS3_CMN_MANGLER(Bs3RegCtxSetGrpDsFromCurPtr)
     69#define Bs3RegCtxSetGrpSegFromCurPtr BS3_CMN_MANGLER(Bs3RegCtxSetGrpSegFromCurPtr)
     70#define Bs3RegCtxSetGrpSegFromFlat BS3_CMN_MANGLER(Bs3RegCtxSetGrpSegFromFlat)
     71#define Bs3RegCtxSetRipCsFromLnkPtr BS3_CMN_MANGLER(Bs3RegCtxSetRipCsFromLnkPtr)
    6472#define Bs3SelFar32ToFlat32 BS3_CMN_MANGLER(Bs3SelFar32ToFlat32)
    6573#define Bs3SelFar32ToFlat32NoClobber BS3_CMN_MANGLER(Bs3SelFar32ToFlat32NoClobber)
     
    7280#define Bs3SelProtFar32ToFlat32 BS3_CMN_MANGLER(Bs3SelProtFar32ToFlat32)
    7381#define Bs3SelProtModeCodeToRealMode BS3_CMN_MANGLER(Bs3SelProtModeCodeToRealMode)
     82#define Bs3SelRealModeCodeToFlat BS3_CMN_MANGLER(Bs3SelRealModeCodeToFlat)
    7483#define Bs3SelRealModeCodeToProtMode BS3_CMN_MANGLER(Bs3SelRealModeCodeToProtMode)
    7584#define Bs3SelRealModeDataToFlat BS3_CMN_MANGLER(Bs3SelRealModeDataToFlat)
     
    91100#define Bs3StrPrintf BS3_CMN_MANGLER(Bs3StrPrintf)
    92101#define Bs3StrPrintfV BS3_CMN_MANGLER(Bs3StrPrintfV)
     102#define Bs3SwitchFromV86To16BitAndCallC BS3_CMN_MANGLER(Bs3SwitchFromV86To16BitAndCallC)
    93103#define Bs3TestCheckRegCtxEx BS3_CMN_MANGLER(Bs3TestCheckRegCtxEx)
    94104#define Bs3TestFailed BS3_CMN_MANGLER(Bs3TestFailed)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h

    r60657 r60676  
    3737#undef Bs3MemAllocZ
    3838#undef Bs3MemChr
     39#undef Bs3MemCmp
    3940#undef Bs3MemCpy
    4041#undef Bs3MemFree
     42#undef Bs3MemGuardedTestPageAlloc
     43#undef Bs3MemGuardedTestPageAllocEx
     44#undef Bs3MemGuardedTestPageFree
    4145#undef Bs3MemMove
    4246#undef Bs3MemPCpy
     
    6266#undef Bs3RegCtxSave
    6367#undef Bs3RegCtxSaveEx
     68#undef Bs3RegCtxSetGrpDsFromCurPtr
     69#undef Bs3RegCtxSetGrpSegFromCurPtr
     70#undef Bs3RegCtxSetGrpSegFromFlat
     71#undef Bs3RegCtxSetRipCsFromLnkPtr
    6472#undef Bs3SelFar32ToFlat32
    6573#undef Bs3SelFar32ToFlat32NoClobber
     
    7280#undef Bs3SelProtFar32ToFlat32
    7381#undef Bs3SelProtModeCodeToRealMode
     82#undef Bs3SelRealModeCodeToFlat
    7483#undef Bs3SelRealModeCodeToProtMode
    7584#undef Bs3SelRealModeDataToFlat
     
    91100#undef Bs3StrPrintf
    92101#undef Bs3StrPrintfV
     102#undef Bs3SwitchFromV86To16BitAndCallC
    93103#undef Bs3TestCheckRegCtxEx
    94104#undef Bs3TestFailed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-data.h

    r60557 r60676  
    3232#define ___bs3kit_mangling_data_h
    3333
     34#if 0 /* the object converter deals with this now  */
    3435#if ARCH_BITS == 64
    3536
     
    275276
    276277#endif /* ARCH_BITS == 64 */
     278#endif /* not needed */
     279
    277280#endif /* !___bs3kit_mangling_data_h */
    278281
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac

    r60657 r60676  
    127127%unmacro TONLY32 1+
    128128%unmacro TONLY64 1+
     129%unmacro TNOT64  1+
    129130
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac

    r60657 r60676  
    137137 %define TMPL_BITS              64
    138138 %define TMPL_PTR_DEF           dq
    139  %define TMPL_UNDERSCORE
    140  %define BS3_CMN_NM(Name)       Name %+ _c64
     139 %define TMPL_UNDERSCORE        _
     140 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c64
    141141
    142142%else
     
    361361 %define TMPL_LM64
    362362 %define TMPL_MODE_STR          "long, 64-bit"
    363  %define TMPL_NM(Name)          Name %+ _lm64
     363 %define TMPL_NM(Name)          _ %+ Name %+ _lm64
    364364 %define TMPL_MODE_LNAME        lm64
    365365 %define TMPL_MODE_UNAME        LM64
     
    382382
    383383; TMPL_NM version with uppercased suffix and no underscore separating them.
    384 %ifnidn TMPL_UNDERSCORE,_
    385  %define TMPL_NM_U(Name)        Name %+ TMPL_MODE_UNAME
    386 %else
    387  %define TMPL_NM_U(Name)        TMPL_UNDERSCORE %+ Name %+ TMPL_MODE_UNAME
    388 %endif
     384%define TMPL_NM_U(Name)         TMPL_UNDERSCORE %+ Name %+ TMPL_MODE_UNAME
    389385
    390386; TMPL_FAR_NM
     
    474470%endif
    475471
     472;; @def TNOT64
     473; Version of BNOT64 that follows the code template.
     474; Like BNOT64 this normally goes in column 1.
     475%if TMPL_BITS == 64
     476 %macro TNOT64 1+
     477 %endmacro
     478%else
     479 %macro TNOT64 1+
     480        %1
     481 %endmacro
     482%endif
     483
    476484;
    477485; Default code segment (changes BITS too).
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r60657 r60676  
    309309#define BS3_SEL_VMMDEV_MMIO16       0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
    310310
     311/** Checks if @a uSel is in the BS3_SEL_RX_XXX range. */
     312#define BS3_SEL_IS_IN_RING_RANGE(uSel) ( (unsigned)(uSel -  BS3_SEL_R0_FIRST) < (unsigned)(4 << BS3_SEL_RING_SHIFT) )
    311313#define BS3_SEL_RING_SHIFT          8      /**< For the formula: BS3_SEL_R0_XXX + ((cs & 3) << BS3_SEL_RING_SHIFT) */
    312314#define BS3_SEL_RING_SUB_MASK       0x00f8 /**< Mask for getting the sub-selector. For use with BS3_SEL_R*_FIRST. */
    313315
     316/** Checks if @a uSel is in the BS3_SEL_R0_XXX range. */
     317#define BS3_SEL_IS_IN_R0_RANGE(uSel) ( (unsigned)(uSel -  BS3_SEL_R0_FIRST) < (unsigned)(1 << BS3_SEL_RING_SHIFT) )
    314318#define BS3_SEL_R0_FIRST            0x0100 /**< The first selector in the ring-0 block. */
    315319#define BS3_SEL_R0_CS16             0x0100 /**< ring-0: 16-bit code selector,  base 0x10000. */
     
    387391#define BS3_SEL_R3_CS64_CNF         0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
    388392#define BS3_SEL_R3_CS64_CNF_EO      0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
     393
     394#define BS3_SEL_R3_LAST             0x04f8 /**< ring-3: Last of the BS3_SEL_RX_XXX range. */
    389395
    390396#define BS3_SEL_SPARE_FIRST         0x0500 /**< The first selector in the spare block */
     
    680686 * @remarks Mainly used in bs3kit-mangling.h, internal headers and templates.
    681687 */
    682 #if ARCH_BITS == 64
    683 # define BS3_DATA_NM(a_Name)  RT_CONCAT(_,a_Name)
    684 #else
     688//converter does this now//#if ARCH_BITS == 64
     689//converter does this now//# define BS3_DATA_NM(a_Name)  RT_CONCAT(_,a_Name)
     690//converter does this now//#else
    685691# define BS3_DATA_NM(a_Name)  a_Name
    686 #endif
     692//converter does this now//#endif
    687693
    688694/**
     
    736742BS3_PTR_UNION_TEMPLATE(BS3CVPTRUNION, const volatile);
    737743
     744/** Generic far function type. */
     745typedef BS3_DECL_FAR(void)  FNBS3FAR(void);
     746/** Generic far function pointer type. */
     747typedef FNBS3FAR           *FPFNBS3FAR;
     748
     749/** Generic near function type. */
     750typedef BS3_DECL_NEAR(void) FNBS3NEAR(void);
     751/** Generic near function pointer type. */
     752typedef FNBS3NEAR          *PFNBS3NEAR;
     753
     754/** Generic far 16:16 function pointer type for address conversion functions. */
     755#if ARCH_BITS == 16
     756typedef FPFNBS3FAR          PFNBS3FARADDRCONV;
     757#else
     758typedef uint32_t            PFNBS3FARADDRCONV;
     759#endif
    738760
    739761/** The system call vector. */
     
    10891111
    10901112
    1091 /** @def BS3_IS_PROTECTED_MODE
    1092  * @returns true if protected mode, false if not. */
    1093 #if ARCH_BITS != 16
    1094 # define BS3_IS_PROTECTED_MODE() (true)
    1095 #else
    1096 # if 1
    1097 #  define BS3_IS_PROTECTED_MODE() (!BS3_MODE_IS_RM_SYS(g_bBs3CurrentMode))
    1098 # else
    1099 #  define BS3_IS_PROTECTED_MODE() (Bs3AsmSmsw() & 1 /*PE*/)
    1100 # endif
    1101 #endif
    1102 
    1103 
    1104 
    11051113/** @defgroup bs3kit_cross_ptr  Cross Context Pointer Type
    11061114 *
     
    12401248DECLINLINE(__segment) Bs3Sel16HighFlatPtrToSelector(uint16_t uHigh)
    12411249{
    1242     if (BS3_IS_PROTECTED_MODE())
     1250    if (!BS3_MODE_IS_RM_OR_V86(g_bBs3CurrentMode))
    12431251        return (__segment)(((uHigh << 3) + BS3_SEL_TILED) | Bs3Sel16GetCurRing());
    12441252    return (__segment)(uHigh << 12);
    12451253}
    12461254
    1247 #endif /* ARCH_BITS == 16*/
     1255#endif /* ARCH_BITS == 16 */
    12481256
    12491257/** @def BS3_XPTR_GET
     
    12771285    do { \
    12781286        a_Type BS3_FAR *pTypeCheck = (a_pValue); \
    1279         if (BS3_IS_PROTECTED_MODE()) \
     1287        if (BS3_MODE_IS_RM_OR_V86(g_bBs3CurrentMode)) \
     1288            (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
     1289        else \
    12801290        { \
    12811291            (a_Name).XPtr.u.uLow  = BS3_FP_OFF(pTypeCheck); \
    12821292            (a_Name).XPtr.u.uHigh = ((BS3_FP_SEG(pTypeCheck) & UINT16_C(0xfff8)) - BS3_SEL_TILED) >> 3; \
    12831293        } \
    1284         else \
    1285             (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
    12861294    } while (0)
    12871295#elif ARCH_BITS == 32
     
    16421650BS3_CMN_PROTO_NOSB(void BS3_FAR *, Bs3MemChr,(void const BS3_FAR *pvHaystack, uint8_t bNeedle, size_t cbHaystack));
    16431651
     1652/**
     1653 * CRT style memcmp.
     1654 *
     1655 * @returns 0 if equal. Negative if the left side is 'smaller' than the right
     1656 *          side, and positive in the other case.
     1657 * @param   pv1             The left hand memory.
     1658 * @param   pv2             The right hand memory.
     1659 * @param   bNeedle         The number of bytes to compare.
     1660 */
     1661BS3_CMN_PROTO_NOSB(int, Bs3MemCmp,(void const BS3_FAR *pv1, void const BS3_FAR *pv2, size_t cb));
    16441662
    16451663BS3_CMN_PROTO_STUB(void, Bs3UInt64Div,(RTUINT64U uDividend, RTUINT64U uDivisor, RTUINT64U BS3_FAR *paQuotientReminder));
     
    17131731 */
    17141732BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatCodeToProtFar16,(uint32_t uFlatAddr));
     1733
     1734/**
     1735 * Converts a far 16:16 real mode (code) address to a flat address.
     1736 *
     1737 * @returns 32-bit flat address.
     1738 * @param   uFar1616        Far real mode address (high 16-bit is segment, low
     1739 *                          is offset).
     1740 * @remarks All register are preserved, except return.
     1741 * @remarks No 20h scratch space required in 64-bit mode.
     1742 * @remarks Exactly the same as Bs3SelRealModeDataToFlat, except for param.
     1743 */
     1744BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeCodeToFlat,(PFNBS3FARADDRCONV uFar1616));
    17151745
    17161746/**
     
    19832013BS3_CMN_PROTO_STUB(void, Bs3MemFree,(void BS3_FAR *pv, size_t cb));
    19842014
     2015/**
     2016 * Allocates a page with non-present pages on each side.
     2017 *
     2018 * @returns Pointer to the usable page.  NULL on failure.  Use
     2019 *          Bs3MemGuardedTestPageFree to free the allocation.
     2020 * @param   enmKind     The kind of addressing constraints imposed on the
     2021 *                      allocation.
     2022 */
     2023BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemGuardedTestPageAlloc,(BS3MEMKIND enmKind));
     2024
     2025/**
     2026 * Allocates a page with pages on each side to the @a fPte specification.
     2027 *
     2028 * @returns Pointer to the usable page.  NULL on failure.  Use
     2029 *          Bs3MemGuardedTestPageFree to free the allocation.
     2030 * @param   enmKind     The kind of addressing constraints imposed on the
     2031 *                      allocation.
     2032 * @param   fPte        The page table entry specification for the guard pages.
     2033 */
     2034BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemGuardedTestPageAllocEx,(BS3MEMKIND enmKind, uint64_t fPte));
     2035
     2036/**
     2037 * Frees guarded page allocated by Bs3MemGuardedTestPageAlloc or
     2038 * Bs3MemGuardedTestPageAllocEx.
     2039 *
     2040 * @param   pvGuardedPage   Pointer returned by Bs3MemGuardedTestPageAlloc or
     2041 *                          Bs3MemGuardedTestPageAllocEx.  NULL is ignored.
     2042 */
     2043BS3_CMN_PROTO_STUB(void, Bs3MemGuardedTestPageFree,(void BS3_FAR *pvGuardedPage));
     2044
    19852045
    19862046/**
     
    21102170BS3_CMN_PROTO_STUB(void, Bs3PicMaskAll,(void));
    21112171
     2172
     2173/**
     2174 * Call 16-bit prot mode function from v8086 mode.
     2175 *
     2176 * This switches from v8086 mode to 16-bit protected mode (code) and executed
     2177 * @a fpfnCall with @a cbParams bytes of parameters pushed on the stack.
     2178 * Afterwards it switches back to v8086 mode and returns a 16-bit status code.
     2179 *
     2180 * @returns     16-bit status code if the function returned anything.
     2181 * @param       fpfnCall        Far real mode pointer to the function to call.
     2182 * @param       cbParams        The size of the parameter list, in bytes.
     2183 * @param       ...             The parameters.
     2184 */
     2185BS3_CMN_PROTO_STUB(int, Bs3SwitchFromV86To16BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
    21122186
    21132187
     
    22642338BS3_CMN_PROTO_STUB(void, Bs3RegCtxPrint,(PCBS3REGCTX pRegCtx));
    22652339
     2340/**
     2341 * Sets a GPR and segment register to point at the same location as @a uFlat.
     2342 *
     2343 * @param   pRegCtx     The register context.
     2344 * @param   pGpr        The general purpose register to set (points within
     2345 *                      @a pRegCtx).
     2346 * @param   pSel        The selector register (points within @a pRegCtx).
     2347 * @param   uFlat       Flat location address.
     2348 */
     2349BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpSegFromFlat,(PBS3REGCTX pRegCtx, PBS3REG pGpr, PRTSEL pSel, RTCCUINTXREG uFlat));
     2350
     2351/**
     2352 * Sets a GPR and segment register to point at the same location as @a ovPtr.
     2353 *
     2354 * @param   pRegCtx     The register context.
     2355 * @param   pGpr        The general purpose register to set (points within
     2356 *                      @a pRegCtx).
     2357 * @param   pSel        The selector register (points within @a pRegCtx).
     2358 * @param   pvPtr       Current context pointer.
     2359 */
     2360BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpSegFromCurPtr,(PBS3REGCTX pRegCtx, PBS3REG pGpr, PRTSEL pSel, void  BS3_FAR *pvPtr));
     2361
     2362/**
     2363 * Sets a GPR and DS to point at the same location as @a ovPtr.
     2364 *
     2365 * @param   pRegCtx     The register context.
     2366 * @param   pGpr        The general purpose register to set (points within
     2367 *                      @a pRegCtx).
     2368 * @param   pvPtr       Current context pointer.
     2369 */
     2370BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpDsFromCurPtr,(PBS3REGCTX pRegCtx, PBS3REG pGpr, void  BS3_FAR *pvPtr));
     2371
     2372/**
     2373 * Sets CS:RIP to point at the same piece of code as @a pfnCode.
     2374 *
     2375 * The 16-bit edition of this function expects a far 16:16 address as written by
     2376 * the linker (i.e. real mode).
     2377 *
     2378 * @param   pRegCtx     The register context.
     2379 * @param   pfnCode     Pointer to the code. In 32-bit and 64-bit mode this is a
     2380 *                      flat address, while in 16-bit it's a far 16:16 address
     2381 *                      as fixed up by the linker (real mode selector).  This
     2382 *                      address is converted to match the mode of the context.
     2383 */
     2384BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetRipCsFromLnkPtr,(PBS3REGCTX pRegCtx, FPFNBS3FAR pfnCode));
     2385
    22662386
    22672387/**
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r60657 r60676  
    149149 ;; Mostly internal macro. Follows BS3_SET_BITS.
    150150 %undef  BS3_NAME_UNDERSCORE
    151  %if %1 == 64
    152   %define BS3_NAME_UNDERSCORE
    153  %else
    154   %define BS3_NAME_UNDERSCORE _
    155  %endif
     151 %define BS3_NAME_UNDERSCORE _
    156152
    157153 ;; For segment overrides and stuff. Follows BS3_SET_BITS.
     
    302298;; @{
    303299
    304 %ifdef ASM_FORMAT_OMF
     300%ifndef ASM_FORMAT_BIN
    305301; !!HACK ALERT!!
    306302;
     
    517513;; When using watcom + OMF, we're using __cdecl by default, which
    518514; get an underscore added in front.
    519 %ifdef ASM_FORMAT_OMF
    520  %define NAME(name) _ %+ NAME_OVERLOAD(name)
    521 %endif
     515%define NAME(name) _ %+ NAME_OVERLOAD(name)
    522516
    523517
     
    627621;
    628622%macro BS3_GLOBAL_NAME_EX 3
    629 %ifdef ASM_FORMAT_ELF
    630  %ifdef __NASM__
    631 global %1:%2 %3
    632  %else
    633 global %1:%2
    634  %endif
    635 %else
    636623global %1
    637 %endif
    638624%1:
    639625%endmacro
     
    656642;
    657643; @param    %1      The mangled name.
    658 ; @param    %2      Create an underscore prefixed alias if present and
    659 ;                   BS3_PB_WITH_US_ALIAS (automatic in 64-bit code).
    660 ;
    661 %macro BS3_PROC_BEGIN 1-2 0
    662 %if __BITS__ == 64 || ((%2) & BS3_PB_WITH_US_ALIAS)
    663 BS3_GLOBAL_NAME_EX _ %+ %1, function, (%1 %+ _EndProc - %1)
    664 %endif
     644;
     645%macro BS3_PROC_BEGIN 1
    665646BS3_GLOBAL_NAME_EX %1, function, (%1 %+ _EndProc - %1)
    666647%endmacro
    667 
    668 ;; For use with BS3_PROC_BEGIN for making it produce an underscore prefixed alias.
    669 %define BS3_PB_WITH_US_ALIAS 1
    670648
    671649;;
     
    678656%macro BS3_PROC_END  1
    679657BS3_GLOBAL_NAME_EX %1 %+ _EndProc, function hidden, (%1 %+ _EndProc - %1)
    680  %ifdef ASM_FORMAT_ELF
    681   %ifdef __YASM__
    682 size %1                 %1 %+ _EndProc - %1
    683 size %1 %+ _EndProc     0
    684   %endif
    685  %endif
    686658 int3                                   ; handy and avoids overlapping labels.
    687659%endmacro
     
    10731045%define BS3_MODE_NM_071h(a_Name)        _ %+ a_Name %+ _lm16
    10741046%define BS3_MODE_NM_072h(a_Name)        _ %+ a_Name %+ _lm32
    1075 %define BS3_MODE_NM_074h(a_Name)            a_Name %+ _lm64
     1047%define BS3_MODE_NM_074h(a_Name)        _ %+ a_Name %+ _lm64
    10761048
    10771049%define BS3_MODE_LNAME_001h             rm
     
    11421114%define BS3_MODE_UNDERSCORE_071h        _
    11431115%define BS3_MODE_UNDERSCORE_072h        _
    1144 %define BS3_MODE_UNDERSCORE_074h
     1116%define BS3_MODE_UNDERSCORE_074h        _
    11451117
    11461118%define BS3_MODE_CNAME_001h             c16
     
    11911163%define BS3_MODE_R0_NM_071h(a_Name)     _ %+ a_Name %+ _lm16
    11921164%define BS3_MODE_R0_NM_072h(a_Name)     _ %+ a_Name %+ _lm32
    1193 %define BS3_MODE_R0_NM_074h(a_Name)         a_Name %+ _lm64
     1165%define BS3_MODE_R0_NM_074h(a_Name)     _ %+ a_Name %+ _lm64
    11941166;; @}
    11951167
Note: See TracChangeset for help on using the changeset viewer.

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