VirtualBox

Changeset 60088 in vbox for trunk


Ignore:
Timestamp:
Mar 18, 2016 12:07:33 AM (9 years ago)
Author:
vboxsync
Message:

bs3kit: updates.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/Config.kmk

    r60008 r60088  
    401401# Note! Optimization options should come after debug stuff as -d2 for instance
    402402#       disables all optimziations.
     403# Note! We use BS3CLASS16CODE because of wdis code detection heuristics requires the class
     404#       of a code segment to be exactly 'CODE', or ending with 'CODE' or 'TEXT' (more
     405#       recent wdis have a -c=<clsnm> option, but not the one we currently use ).
     406#
    403407#
    404408# Compiler options explained:
     
    452456TEMPLATE_VBoxBS3KitImg_CXXTOOL      = Bs3Ow16
    453457TEMPLATE_VBoxBS3KitImg_CFLAGS       = \
    454         -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
     458        -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
    455459TEMPLATE_VBoxBS3KitImg_CXXFLAGS     = \
    456         -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
     460        -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
    457461TEMPLATE_VBoxBS3KitImg_CDEFS        = ARCH_BITS=16 RT_ARCH_X86
    458462
     
    499503         clname BS3FLAT segaddr=0x0000 \
    500504           segment BS3FLAT segaddr=0x0000 \
    501          clname BS3CODE16 segaddr=0x1000 \
     505         clname BS3CLASS16CODE segaddr=0x1000 \
    502506          segment BS3TEXT16 \
    503507          segment BS3TEXT16_END \
     
    520524          segment .data \
    521525          segment DATA64_END \
    522         clname BS3CODE32 \
     526        clname BS3CLASS32CODE \
    523527          segment BS3TEXT32 \
    524528          segment TEXT32 \
    525         clname BS3CODE64 \
     529        clname BS3CLASS64CODE \
    526530          segment BS3TEXT64 \
    527531          segment TEXT64 \
     
    582586TEMPLATE_VBoxBS3KitImg32_CXXTOOL      = Bs3Ow32
    583587TEMPLATE_VBoxBS3KitImg32_CFLAGS       = \
    584         -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zl -mf $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
     588        -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CLASS32CODE -ecc -q -wx -zl -mf $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
    585589TEMPLATE_VBoxBS3KitImg32_CXXFLAGS     = \
    586         -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zl -mf $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
     590        -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CLASS32CODE -ecc -q -wx -zl -mf $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+
    587591TEMPLATE_VBoxBS3KitImg32_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
    588592TEMPLATE_VBoxBS3KitImg32_LDTOOL       = VBoxBsUnusedLd
  • trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk

    r60024 r60088  
    4545if defined(VBOX_WITH_OPEN_WATCOM)
    4646 if1of ($(KBUILD_TARGET), win)
    47 # temp disabled #  VBOX_WITH_BS3KIT = 1
     47  VBOX_WITH_BS3KIT = 1
    4848 else if $(VBOX_GCC_VERSION_CC) >= 40400 # ms_abi was added in 4.4
    4949# Awaiting elf -> omf converter #  if1of ($(KBUILD_TARGET), linux)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c

    r60024 r60088  
    3030extern BS3_DECL(void) TMPL_NM(bs3CpuBasic2_TssGateEsp_IntXx)(void);
    3131
     32# if TMPL_MODE == BS3_MODE_PE16 \
     33  || TMPL_MODE == BS3_MODE_PE16_32
     34
     35static void bs3CpuBasic2_CompareTrapCtx1(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t cbIpAdjust, uint8_t bXcpt,
     36                                         unsigned uStep)
     37{
     38    const char *pszMode = BS3_DATA_NM(TMPL_NM(g_szBs3ModeName));
     39    uint16_t    cErrorsBefore = Bs3TestSubErrorCount();
     40
     41#define CHECK_MEMBER(a_szName, a_szFmt, a_Actual, a_Expected) \
     42    do { \
     43        if ((a_Actual) == (a_Expected)) { /* likely */ } \
     44        else Bs3TestFailedF("%u - %s: " a_szName "=" a_szFmt " expected " a_szFmt, uStep, pszMode, (a_Actual), (a_Expected)); \
     45    } while (0)
     46
     47    CHECK_MEMBER("bXcpt",   "%#04x",    pTrapCtx->bXcpt,        bXcpt);
     48    CHECK_MEMBER("rax",     "%08RX64",  pTrapCtx->Ctx.rax.u,    pStartCtx->rax.u);
     49    CHECK_MEMBER("rcx",     "%08RX64",  pTrapCtx->Ctx.rcx.u,    pStartCtx->rcx.u);
     50    CHECK_MEMBER("rdx",     "%08RX64",  pTrapCtx->Ctx.rdx.u,    pStartCtx->rdx.u);
     51    CHECK_MEMBER("rbx",     "%08RX64",  pTrapCtx->Ctx.rbx.u,    pStartCtx->rbx.u);
     52    CHECK_MEMBER("rsp",     "%08RX64",  pTrapCtx->Ctx.rsp.u,    pStartCtx->rsp.u);
     53    CHECK_MEMBER("rbp",     "%08RX64",  pTrapCtx->Ctx.rbp.u,    pStartCtx->rbp.u);
     54    CHECK_MEMBER("rsi",     "%08RX64",  pTrapCtx->Ctx.rsi.u,    pStartCtx->rsi.u);
     55    CHECK_MEMBER("rdi",     "%08RX64",  pTrapCtx->Ctx.rdi.u,    pStartCtx->rdi.u);
     56    CHECK_MEMBER("r8",      "%08RX64",  pTrapCtx->Ctx.r8.u,     pStartCtx->r8.u);
     57    CHECK_MEMBER("r9",      "%08RX64",  pTrapCtx->Ctx.r9.u,     pStartCtx->r9.u);
     58    CHECK_MEMBER("r10",     "%08RX64",  pTrapCtx->Ctx.r10.u,    pStartCtx->r10.u);
     59    CHECK_MEMBER("r11",     "%08RX64",  pTrapCtx->Ctx.r11.u,    pStartCtx->r11.u);
     60    CHECK_MEMBER("r12",     "%08RX64",  pTrapCtx->Ctx.r12.u,    pStartCtx->r12.u);
     61    CHECK_MEMBER("r13",     "%08RX64",  pTrapCtx->Ctx.r13.u,    pStartCtx->r13.u);
     62    CHECK_MEMBER("r14",     "%08RX64",  pTrapCtx->Ctx.r14.u,    pStartCtx->r14.u);
     63    CHECK_MEMBER("r15",     "%08RX64",  pTrapCtx->Ctx.r15.u,    pStartCtx->r15.u);
     64    CHECK_MEMBER("rflags",  "%08RX64",  pTrapCtx->Ctx.rflags.u, pStartCtx->rflags.u);
     65    CHECK_MEMBER("rip",     "%08RX64",  pTrapCtx->Ctx.rip.u,    pStartCtx->rip.u + cbIpAdjust);
     66    CHECK_MEMBER("cs",      "%04RX16",  pTrapCtx->Ctx.cs,       pStartCtx->cs);
     67    CHECK_MEMBER("ds",      "%04RX16",  pTrapCtx->Ctx.ds,       pStartCtx->ds);
     68    CHECK_MEMBER("es",      "%04RX16",  pTrapCtx->Ctx.es,       pStartCtx->es);
     69    CHECK_MEMBER("fs",      "%04RX16",  pTrapCtx->Ctx.fs,       pStartCtx->fs);
     70    CHECK_MEMBER("gs",      "%04RX16",  pTrapCtx->Ctx.gs,       pStartCtx->gs);
     71    CHECK_MEMBER("tr",      "%04RX16",  pTrapCtx->Ctx.tr,       pStartCtx->tr);
     72    CHECK_MEMBER("ldtr",    "%04RX16",  pTrapCtx->Ctx.ldtr,     pStartCtx->ldtr);
     73    CHECK_MEMBER("bMode",   "%#04x",    pTrapCtx->Ctx.bMode,    pStartCtx->bMode);
     74    CHECK_MEMBER("bCpl",    "%u",       pTrapCtx->Ctx.bCpl,     pStartCtx->bCpl);
     75    CHECK_MEMBER("cr0",     "%08RX32",  pTrapCtx->Ctx.cr0.u,    pStartCtx->cr0.u);
     76    CHECK_MEMBER("cr2",     "%08RX32",  pTrapCtx->Ctx.cr2.u,    pStartCtx->cr2.u);
     77    CHECK_MEMBER("cr3",     "%08RX32",  pTrapCtx->Ctx.cr3.u,    pStartCtx->cr3.u);
     78    CHECK_MEMBER("cr4",     "%08RX32",  pTrapCtx->Ctx.cr4.u,    pStartCtx->cr4.u);
     79    if (Bs3TestSubErrorCount() != cErrorsBefore)
     80        Bs3TrapPrintFrame(pTrapCtx);
     81}
     82#endif
     83
     84AssertCompileMemberOffset(BS3REGCTX, ss, 0x9a);
     85
    3286BS3_DECL(uint8_t) TMPL_NM(bs3CpuBasic2_TssGateEsp)(uint8_t bMode)
    3387{
    3488    uint8_t         bRet = 0;
    35 # if TMPL_MODE == BS3_MODE_PE16 \
    36  || TMPL_MODE == BS3_MODE_PE16_32
    3789    BS3TRAPFRAME    TrapCtx;
    3890    BS3REGCTX       Ctx;
    3991
     92    /* make sure they're allocated  */
     93    Bs3MemZero(&Ctx, sizeof(Ctx));
     94    Bs3MemZero(&TrapCtx, sizeof(TrapCtx));
     95
     96# if TMPL_MODE == BS3_MODE_PE16 \
     97  || TMPL_MODE == BS3_MODE_PE16_32
     98
    4099    Bs3RegCtxSave(&Ctx);
    41     Ctx.rip.u = (uintptr_t)&TMPL_NM(bs3CpuBasic2_TssGateEsp_IntXx);
     100    Ctx.rsp.u -= 0x80;
     101    Ctx.rip.u  = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_TssGateEsp_IntXx));
     102# if TMPL_BITS == 32
     103    BS3_DATA_NM(g_uBs3TrapEipHint) = Ctx.rip.u32;
     104# endif
     105    Bs3Printf("esp=%#llx\n", Ctx.rsp.u);
    42106
    43107    /*
    44108     * Check that the stuff works first.
    45109     */
    46      if (Bs3TrapSetJmp(&TrapCtx))
    47      {
     110    if (Bs3TrapSetJmp(&TrapCtx))
     111    {
     112        Bs3RegCtxRestore(&Ctx, 0); /* (does not return) */
     113    }
     114    /* trapped. */
     115    bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &Ctx, 2 /*int 80h*/, 0x80 /*bXcpt*/, 1/*bStep*/);
     116    Bs3Printf("esp=%#llx\n", Ctx.rsp.u);
    48117
    49          Bs3TrapUnsetJmp();
    50      }
    51      else
    52      {
    53          /* trapped. */
    54      }
     118Bs3Printf("trapped\n");
    55119
    56120
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac

    r60024 r60088  
    7272
    7373
     74BS3_PROC_BEGIN_MODE bs3CpuBasic2_TssGateEsp_IntXx
     75        int     80h
     76        nop
     77BS3_PROC_END_MODE   bs3CpuBasic2_TssGateEsp_IntXx
     78
     79
    7480
    7581
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r60024 r60088  
    8585       bs3-cmn-RegCtxConvertToRingX.c \
    8686       bs3-cmn-RegCtxPrint.c \
     87       bs3-cmn-RegCtxSave.asm \
    8788       bs3-cmn-SelFar32ToFlat32.c \
    8889       bs3-cmn-SelProtFar32ToFlat32.c \
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp

    r60044 r60088  
    994994        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FLAT"), &idxGrpFlat)
    995995        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3DATA64_GROUP"), &idxGrpData)
    996         || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CODE64"), &idxClassCode)
     996        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CLASS64CODE"), &idxClassCode)
    997997        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FAR_DATA"), &idxClassData)
    998998        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("DWARF"), &idxClassDwarf)
     
    15701570        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FLAT"), &idxGrpFlat)
    15711571        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3DATA64_GROUP"), &idxGrpData)
    1572         || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CODE64"), &idxClassCode)
     1572        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CLASS64CODE"), &idxClassCode)
    15731573        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FAR_DATA"), &idxClassData)
    15741574        || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("DEBSYM"), &idxClassDebugSymbols)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm

    r60002 r60088  
    664664        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], cx
    665665        mov     [bp + 2], cx            ; For better call stacks.
    666         mov     cx, [eax + X86TSS16.cs]
     666        mov     cx, [es:di + X86TSS16.cs]
    667667        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
    668         mov     cx, [eax + X86TSS16.ds]
     668        mov     cx, [es:di + X86TSS16.ds]
    669669        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
    670         mov     cx, [eax + X86TSS16.es]
     670        mov     cx, [es:di + X86TSS16.es]
    671671        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
    672         mov     cx, [eax + X86TSS16.ss]
     672        mov     cx, [es:di + X86TSS16.ss]
    673673        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
    674         mov     cx, [eax + X86TSS16.selLdt]             ; Note! This isn't necessarily the ldtr at the time of the fault.
     674        mov     cx, [es:di + X86TSS16.selLdt]             ; Note! This isn't necessarily the ldtr at the time of the fault.
    675675        mov     [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx
    676676
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCpy.c

    r58666 r60088  
    3030BS3_DECL(void BS3_FAR *) BS3_CMN_NM(Bs3MemCpy)(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy)
    3131{
     32#if 1
     33    const size_t BS3_FAR   *pBigSrc = (const size_t BS3_FAR *)pvSrc;
     34    size_t BS3_FAR         *pBigDst = (size_t *)pvDst;
     35    size_t                  cBig = cbToCopy / sizeof(size_t);
     36    while (cBig-- > 0)
     37        *pBigDst++ = *pBigSrc++;
     38
     39    switch (cbToCopy % sizeof(size_t))
     40    {
     41#if TMPL_BITS >= 64
     42        case 7: ((uint8_t BS3_FAR *)pBigDst)[6] = ((const uint8_t BS3_FAR *)pBigSrc)[6];
     43        case 6: ((uint8_t BS3_FAR *)pBigDst)[5] = ((const uint8_t BS3_FAR *)pBigSrc)[5];
     44        case 5: ((uint8_t BS3_FAR *)pBigDst)[4] = ((const uint8_t BS3_FAR *)pBigSrc)[4];
     45        case 4: ((uint8_t BS3_FAR *)pBigDst)[3] = ((const uint8_t BS3_FAR *)pBigSrc)[3];
     46#endif
     47#if TMPL_BITS >= 32
     48        case 3: ((uint8_t BS3_FAR *)pBigDst)[2] = ((const uint8_t BS3_FAR *)pBigSrc)[2];
     49        case 2: ((uint8_t BS3_FAR *)pBigDst)[1] = ((const uint8_t BS3_FAR *)pBigSrc)[1];
     50#endif
     51        case 1: ((uint8_t BS3_FAR *)pBigDst)[0] = ((const uint8_t BS3_FAR *)pBigSrc)[0];
     52        case 0:
     53            break;
     54    }
     55
     56#else
    3257    size_t          cLargeRounds;
    3358    BS3CPTRUNION    uSrc;
     
    4469        *uDst.pb++ = *uSrc.pb++;
    4570
     71#endif
     72
    4673    return pvDst;
    4774}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxPrint.c

    r59976 r60088  
    4040                  pRegCtx->rip.u32, pRegCtx->rsp.u32, pRegCtx->rbp.u32, pRegCtx->rflags.u32, pRegCtx->cr0.u32, pRegCtx->cr2.u32);
    4141        Bs3Printf("cs=%04RX16   ds=%04RX16 es=%04RX16 fs=%04RX16 gs=%04RX16   ss=%04RX16 cr3=%08RX32 cr4=%08RX32\n",
    42                   pRegCtx->cs, pRegCtx->ds, pRegCtx->es, pRegCtx->fs, pRegCtx->gs, pRegCtx->fs, pRegCtx->cr3.u32, pRegCtx->cr4.u32);
     42                  pRegCtx->cs, pRegCtx->ds, pRegCtx->es, pRegCtx->fs, pRegCtx->gs, pRegCtx->ss, pRegCtx->cr3.u32, pRegCtx->cr4.u32);
    4343        Bs3Printf("tr=%04RX16 ldtr=%04RX16 cpl=%d   mode=%#x\n",
    4444                  pRegCtx->tr, pRegCtx->ldtr, pRegCtx->bCpl, pRegCtx->bMode);
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm

    r60002 r60088  
    4646; @note         Only respects the BS3_MODE_CODE_MASK part of pRegCtx->bMode.
    4747;
     48%if TMPL_BITS == 16 || TMPL_BITS == 32
     49BS3_PROC_BEGIN_CMN Bs3RegCtxRestore_aborts ; special entry point for when watcom applies __aborts
     50 %if TMPL_BITS == 16
     51        xor     xAX, xAX
     52        push    xAX                     ; fake return address.
     53 %else
     54        push    0feedfaceh              ; fake return address.
     55 %endif
     56%endif
    4857BS3_PROC_BEGIN_CMN Bs3RegCtxRestore
    4958        BS3_CALL_CONV_PROLOG 2
     
    103112
    104113.restore_16_bit_ancient:
    105 int3
    106114        ; Some general registers.
    107         mov     si, [bx + BS3REGCTX.rsi]
    108115        mov     cx, [bx + BS3REGCTX.rcx]
    109116        mov     dx, [bx + BS3REGCTX.rdx]
     
    130137        push    ax
    131138
     139        mov     si, [bx + BS3REGCTX.rsi]
    132140        mov     di, [bx + BS3REGCTX.rdi]
    133141        mov     es, [bx + BS3REGCTX.es]
    134         mov     ax, [bx + BS3REGCTX.rbx]
     142        mov     ax, [bx + BS3REGCTX.rax]
    135143        mov     bp, [bx + BS3REGCTX.rbp]    ; restore late for better stacks.
    136144        mov     bx, [bx + BS3REGCTX.rbx]
     
    141149.restore_16_bit_same_privilege:
    142150        sub     di, 2*5                     ; iret frame + pop ds
    143         mov     [bx + BS3REGCTX.rsp], di
     151        mov     si, di
    144152        mov     es, [bx + BS3REGCTX.ss]     ; ES is target stack segment.
    145153        cld
     
    158166        mov     di, [bx + BS3REGCTX.rdi]
    159167        mov     es, [bx + BS3REGCTX.es]
    160         mov     ax, [bx + BS3REGCTX.rbx]
     168        mov     ax, [bx + BS3REGCTX.rax]
    161169        mov     ss, [bx + BS3REGCTX.ss]
    162         mov     sp, [bx + BS3REGCTX.rsp]    ; adjusted, see above.
     170        mov     sp, si
     171        mov     si, [bx + BS3REGCTX.rsi]
    163172        mov     bx, [bx + BS3REGCTX.rbx]
    164173
     
    350359.using_16_bit_stack_pointer:
    351360        movzx   edi, di
    352         mov     [xBX + BS3REGCTX.rsp], di
     361        mov     esi, [xBX + BS3REGCTX.rsp]
     362        mov     si, di                  ; save rsp for later.
    353363        jmp     .es_edi_is_pointing_to_return_frame_location
    354364.using_32_bit_stack_pointer:
    355         mov     [xBX + BS3REGCTX.rsp], edi
     365        mov     esi, edi
    356366.es_edi_is_pointing_to_return_frame_location:
    357367        cld
     
    373383        mov     edx, [xBX + BS3REGCTX.rdx]
    374384        mov     ecx, [xBX + BS3REGCTX.rcx]
    375         mov     esi, [xBX + BS3REGCTX.rsi]
    376385        mov     edi, [xBX + BS3REGCTX.rdi]
    377386        mov     ebp, [xBX + BS3REGCTX.rbp] ; restore late for better stacks.
    378387
    379388        mov     ss,  [xBX + BS3REGCTX.ss]
    380         mov     esp, [xBX + BS3REGCTX.rsp] ; adjusted, see above.
     389        mov     esp, esi
     390        mov     esi, [xBX + BS3REGCTX.rsi]
    381391        mov     ebx, [xBX + BS3REGCTX.rbx]
    382392
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm

    r60024 r60088  
    3636
    3737
    38 %if BS3REGCTX_size %
    39 
    4038
    4139;;
     
    4947        push    xBP
    5048        mov     xBP, xSP
    51         xPUSHF                          ; save the incoming flags exactly.
    52         push    xAX                     ; save incoming xAX
    53         push    xCX                     ; save incoming xCX
    54         push    xDI
    55         BS3_ONLY_16BIT_STMT push    es
    56         BS3_ONLY_16BIT_STMT push    ds
     49        xPUSHF                          ; xBP - xCB*1: save the incoming flags exactly.
     50        push    xAX                     ; xBP - xCB*2: save incoming xAX
     51        push    xCX                     ; xBP - xCB*3: save incoming xCX
     52        push    xDI                     ; xBP - xCB*4: save incoming xDI
     53        BS3_ONLY_16BIT_STMT push    es  ; xBP - xCB*5
     54        BS3_ONLY_16BIT_STMT push    ds  ; xBP - xCB*6
    5755
    5856        ;
     
    7068        ; Clear the whole structure first, unless 64-bit
    7169        ;
    72         push    es
    73         les
    74         push    ds
    75         pop     ds
    7670        xor     xAX, xAX
    7771        cld
    7872 %if TMPL_BITS == 16
     73        les     xDI, [xBP + xCB*2]
    7974        mov     xCX, BS3REGCTX_size / 2
    8075        rep stosw
    81         mov     di, [bp + 4]
    8276 %else
     77        mov     xDI, [xBP + xCB*2]
    8378        mov     xCX, BS3REGCTX_size / 4
    8479        rep stosd
     80 %endif
    8581        mov     xDI, [xBP + xCB*2]
    86  %endif
    8782%endif
    8883
     
    9085        ; Save the current mode.
    9186        ;
    92         mov     cl, BS3_DATA16_WRT(g_bBs3CurrentMode)
     87        mov     cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
    9388        mov     [BS3_ONLY_16BIT(es:) xDI + BS3REGCTX.bMode], cl
    94 
    95 %if TMPL_BITS == 16
    96         ;
    97         ; Check what the CPU can do.
    98         ;
    99         cmp     byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80386
     89%if TMPL_BITS == 16
     90
     91        ;
     92        ; In 16-bit mode we could be running on really ancient CPUs, so check
     93        ; mode and detected CPU and proceed with care.
     94        ;
     95        cmp     cl, BS3_MODE_PP16
    10096        jae     .save_full
    10197
    102         ; Do the 80286 specifics first and load ES into DS so we can save some segment prefix bytes.
    103         cmp     byte [es:BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286
     98        mov     cl, [BS3_DATA16_WRT(g_uBs3CpuDetected)]
     99        cmp     cl, BS3CPU_80386
     100        jae     .save_full
     101
     102        ; load ES into DS so we can save some segment prefix bytes.
    104103        push    es
    105104        pop     ds
    106         jb      .save_16_bit_ancient
    107 
    108         smsw    [xDI + BS3REGCTX.cr0]
    109         sldt    [xDI + BS3REGCTX.ldtr]
    110         str     [xDI + BS3REGCTX.tr]
    111 
    112 .save_16_bit_ancient:
     105
    113106        ; 16-bit GPRs not on the stack.
    114107        mov     [xDI + BS3REGCTX.rdx], dx
     
    116109        mov     [xDI + BS3REGCTX.rsi], si
    117110
    118         ; flags
    119         mov     xAX, [xBP + xCB - xCB]
    120         mov     [xDI + BS3REGCTX.rflags], xAX
    121 
    122         jmp     .common
     111        ; Join the common code.
     112        cmp     cl, BS3CPU_80286
     113        jb      .common_ancient
     114
     115        smsw    [xDI + BS3REGCTX.cr0]
     116        jmp     .common_80286
    123117%endif
    124118
     
    149143%endif
    150144%if TMPL_BITS == 16 ; Save high bits.
    151         mov     [xDI + BS3REGCTX.eax], eax
    152         mov     [xDI + BS3REGCTX.ecx], ecx
    153         mov     [xDI + BS3REGCTX.edi], edi
    154         mov     [xDI + BS3REGCTX.ebp], ebp
    155         mov     [xDI + BS3REGCTX.esp], esp
     145        mov     [xDI + BS3REGCTX.rax], eax
     146        mov     [xDI + BS3REGCTX.rcx], ecx
     147        mov     [xDI + BS3REGCTX.rdi], edi
     148        mov     [xDI + BS3REGCTX.rbp], ebp
     149        mov     [xDI + BS3REGCTX.rsp], esp
    156150        pushfd
    157         pop     [xDI + BS3REGCTX.rflags]
    158 %endif
     151        pop     dword [xDI + BS3REGCTX.rflags]
     152%endif
     153
     154        ; 386 segment registers.
     155        mov     [xDI + BS3REGCTX.fs], fs
     156        mov     [xDI + BS3REGCTX.gs], gs
    159157
    160158        ; Control registers.
     
    167165        mov     sAX, cr4
    168166        mov     [xDI + BS3REGCTX.cr4], sAX
     167
     168        ; 80286 control registers.
     169.common_80286:
    169170        str     [xDI + BS3REGCTX.tr]
    170171        sldt    [xDI + BS3REGCTX.ldtr]
    171172
    172         ; Segment registers.
    173         mov     [xDI + BS3REGCTX.fs], fs
    174         mov     [xDI + BS3REGCTX.gs], gs
    175 
    176173        ; Common stuff - stuff on the stack, 286 segment registers.
    177 .common:
    178         mov     xAX, [xBP - xCB]
     174.common_ancient:
     175        mov     xAX, [xBP - xCB*1]
    179176        mov     [xDI + BS3REGCTX.rflags], xAX
    180177        mov     xAX, [xBP - xCB*2]
    181         mov     [xDI + BS3REGCTX.eax], xAX
     178        mov     [xDI + BS3REGCTX.rax], xAX
    182179        mov     xAX, [xBP - xCB*3]
    183         mov     [xDI + BS3REGCTX.ecx], xAX
     180        mov     [xDI + BS3REGCTX.rcx], xAX
    184181        mov     xAX, [xBP - xCB*4]
    185         mov     [xDI + BS3REGCTX.edi], xAX
     182        mov     [xDI + BS3REGCTX.rdi], xAX
    186183        mov     xAX, [xBP]
    187         mov     [xDI + BS3REGCTX.ebp], xAX
     184        mov     [xDI + BS3REGCTX.rbp], xAX
    188185        mov     xAX, [xBP + xCB]
    189186        mov     [xDI + BS3REGCTX.rip], xAX
    190187        lea     xAX, [xBP + xCB*2]
    191         mov     [xDI + BS3REGCTX.esp], xAX
     188        mov     [xDI + BS3REGCTX.rsp], xAX
    192189
    193190        mov     [xDI + BS3REGCTX.cs], cs
     
    201198        mov     [xDI + BS3REGCTX.es], es
    202199%endif
     200        mov     [xDI + BS3REGCTX.ss], ss
    203201
    204202        ;
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c

    r60024 r60088  
    3434*   Global Variables                                                                                                             *
    3535*********************************************************************************************************************************/
    36 /* We ASSUME that BS3CODE16 is 64KB aligned, so the low 16-bit of the
     36/* We ASSUME that BS3CLASS16CODE is 64KB aligned, so the low 16-bit of the
    3737   flat address matches.   Also, these symbols are defined both with
    3838   and without underscore prefixes. */
     
    5757    if (f386Plus)
    5858    {
    59         bs3Trap16GenericTrapErrCode[1] = 0;
    60         bs3Trap16GenericTrapErrCode[2] = 0;
    61         bs3Trap16GenericTrapOrInt[1]   = 0;
    62         bs3Trap16GenericTrapOrInt[2]   = 0;
     59        uint8_t BS3_FAR_DATA *pbFunction = &bs3Trap16GenericTrapErrCode[0];
     60#if ARCH_BITS == 16
     61        if (g_bBs3CurrentMode != BS3_MODE_RM)
     62            pbFunction = (uint8_t BS3_FAR_DATA *)BS3_FP_MAKE(BS3_SEL_TILED + 1, BS3_FP_OFF(pbFunction));
     63#endif
     64        pbFunction[1] = 0;
     65        pbFunction[2] = 0;
     66
     67        pbFunction = &bs3Trap16GenericTrapOrInt[0];
     68#if ARCH_BITS == 16
     69        if (g_bBs3CurrentMode != BS3_MODE_RM)
     70            pbFunction = (uint8_t BS3_FAR_DATA *)BS3_FP_MAKE(BS3_SEL_TILED + 1, BS3_FP_OFF(pbFunction));
     71#endif
     72        pbFunction[1] = 0;
     73        pbFunction[2] = 0;
    6374    }
    6475
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c

    r60001 r60088  
    2929*********************************************************************************************************************************/
    3030#include "bs3kit-template-header.h"
     31
     32
     33/*********************************************************************************************************************************
     34*   Global Variables                                                                                                             *
     35*********************************************************************************************************************************/
     36#define g_pBs3TrapSetJmpFrame BS3_DATA_NM(g_pBs3TrapSetJmpFrame)
     37extern uint32_t  g_pBs3TrapSetJmpFrame;
     38
     39#define g_Bs3TrapSetJmpCtx    BS3_DATA_NM(g_Bs3TrapSetJmpCtx)
     40extern BS3REGCTX g_Bs3TrapSetJmpCtx;
    3141
    3242
     
    163173
    164174    /*
     175     * Any pending setjmp?
     176     */
     177    if (g_pBs3TrapSetJmpFrame != 0)
     178    {
     179        PBS3TRAPFRAME pSetJmpFrame = (PBS3TRAPFRAME)Bs3XptrFlatToCurrent(g_pBs3TrapSetJmpFrame);
     180        //Bs3Printf("Calling longjmp: pSetJmpFrame=%p (%#lx)\n", pSetJmpFrame, g_pBs3TrapSetJmpFrame);
     181        g_pBs3TrapSetJmpFrame = 0;
     182
     183        Bs3MemCpy(pSetJmpFrame, pTrapFrame, sizeof(*pSetJmpFrame));
     184        //Bs3RegCtxPrint(&g_Bs3TrapSetJmpCtx);
     185        Bs3RegCtxRestore(&g_Bs3TrapSetJmpCtx, 0 /*fFlags*/);
     186    }
     187
     188    /*
    165189     * Fatal.
    166190     */
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm

    r60024 r60088  
    8585%if TMPL_BITS == 16
    8686        xor     ax, ax
     87        push    word [xBP + xCB*2 + 2]
    8788        push    ax
    88         push    word [xBP + xCB*2 + 2]
    8989        push    word [xBP + xCB*2]
    9090        call    Bs3SelFar32ToFlat32
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac

    r59932 r60088  
    5353section BS3TEXT16_END   align=2 progbits alloc exec nowrite
    5454%else
    55 section BS3TEXT16_END   align=2 CLASS=BS3CODE16 PUBLIC USE16
     55section BS3TEXT16_END   align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
    5656%endif
    5757
     
    109109section BS3TEXT32_END   align=1 progbits alloc exec nowrite
    110110%else
    111 section BS3TEXT32_END   align=1 CLASS=BS3CODE32 PUBLIC USE32 FLAT
     111section BS3TEXT32_END   align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
    112112%endif
    113113
     
    132132section BS3TEXT64_END   align=1 progbits alloc exec nowrite
    133133%else
    134 section BS3TEXT64_END   align=1 CLASS=BS3CODE64 PUBLIC USE32 FLAT
     134section BS3TEXT64_END   align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
    135135%endif
    136136BS3_GLOBAL_DATA Bs3Text64_EndOfSegment, 0
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r60024 r60088  
    3535#ifndef DOXYGEN_RUNNING
    3636# undef  IN_RING0
     37#endif
     38
     39/*
     40 * We normally don't want the noreturn / aborts attributes as they mess up stack traces.
     41 *
     42 * Note! pragma aux <fnname> aborts can only be used with functions
     43 *       implemented in C and functions that does not have parameters.
     44 */
     45#ifndef BS3_KIT_WITH_NO_RETURN
     46# undef  DECL_NO_RETURN
     47# define DECL_NO_RETURN(type) type
    3748#endif
    3849
     
    385396 * Get the segment offset part of a far pointer.
    386397 *
     398 * For sake of convenience, this works like a uintptr_t cast in 32-bit and
     399 * 64-bit code.
     400 *
    387401 * @returns offset.
    388402 * @param   a_pv        Far pointer.
     
    397411 */
    398412# define BS3_FP_MAKE(a_uSeg, a_off)  (((__segment)(a_uSeg)) :> ((void __near *)(a_off)))
    399 
     413#else
     414# define BS3_FP_OFF(a_pv)            ((uintptr_t)(a_pv))
    400415#endif
    401416
     
    705720/** Free GDTes, part \#1. */
    706721extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart1)[64];
    707 /** The BS3CODE16 GDT entry. @see BS3_SEL_TEXT16   */
     722/** The BS3TEXT16/BS3CLASS16CODE GDT entry. @see BS3_SEL_TEXT16   */
    708723extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_CODE16);
    709724/** Free GDTes, part \#2. */
     
    713728/** Free GDTes, part \#3. */
    714729extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart3)[223];
    715 /** The BS3DATA16 GDT entry. */
     730/** The BS3DATA16/BS3_FAR_DATA GDT entry. */
    716731extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_DATA16);
    717732/** The end of the GDT (exclusive). */
     
    10571072 */
    10581073#define BS3_XPTR_IS_NULL(a_Type, a_Name)    ((a_Name).XPtr.uFlat == 0)
     1074
     1075/**
     1076 * Gets a working pointer from a 32-bit flat address.
     1077 *
     1078 * @returns Current context pointer.
     1079 * @param   uFlatPtr    The flat address to convert.
     1080 */
     1081DECLINLINE(void BS3_FAR *) Bs3XptrFlatToCurrent(uint32_t uFlatPtr)
     1082{
     1083    BS3_XPTR_AUTO(void, pTmp);
     1084    BS3_XPTR_SET_FLAT(void, pTmp, uFlatPtr);
     1085    return BS3_XPTR_GET(void, pTmp);
     1086}
     1087
    10591088/** @} */
    10601089
     
    10811110 * The current implementation will only halt the CPU.
    10821111 */
    1083 BS3_DECL(void) Bs3Panic_c16(void);
    1084 BS3_DECL(void) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16  */
    1085 BS3_DECL(void) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16  */
     1112BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c16(void);
     1113BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16  */
     1114BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16  */
    10861115#define Bs3Panic BS3_CMN_NM(Bs3Panic) /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
     1116#if !defined(BS3_KIT_WITH_NO_RETURN) && defined(__WATCOMC__)
     1117# pragma aux Bs3Panic_c16 __aborts
     1118# pragma aux Bs3Panic_c32 __aborts
     1119#endif
    10871120
    10881121/**
     
    20872120BS3_DECL(DECL_NO_RETURN(void)) Bs3RegCtxRestore_c64(PCBS3REGCTX pRegCtx, uint16_t fFlags); /**< @copydoc Bs3RegCtxRestore_c16 */
    20882121#define Bs3RegCtxRestore BS3_CMN_NM(Bs3RegCtxRestore) /**< Selects #Bs3RegCtxRestore_c16, #Bs3RegCtxRestore_c32 or #Bs3RegCtxRestore_c64. */
    2089 #ifdef __WATCOMC__
    2090 # pragma aux Bs3RegCtxRestore_c16 __aborts;
    2091 # pragma aux Bs3RegCtxRestore_c32 __aborts;
     2122#if /*!defined(BS3_KIT_WITH_NO_RETURN) &&*/ defined(__WATCOMC__)
     2123# pragma aux Bs3RegCtxRestore_c16 "_Bs3RegCtxRestore_aborts_c16" __aborts
     2124# pragma aux Bs3RegCtxRestore_c32 "_Bs3RegCtxRestore_aborts_c32" __aborts
    20922125#endif
    20932126
     
    23282361BS3_DECL(void) Bs3TrapUnsetJmp_c64(void); /**< @copydoc Bs3TrapUnsetJmp_c16 */
    23292362#define Bs3TrapUnsetJmp BS3_CMN_NM(Bs3TrapUnsetJmp) /**< Selects #Bs3TrapUnsetJmp_c16, #Bs3TrapUnsetJmp_c32 or #Bs3TrapUnsetJmp_c64. */
    2330 #ifdef __WATCOMC__
    2331 # pragma aux Bs3TrapUnsetJmp_c16 aborts;
    2332 # pragma aux Bs3TrapUnsetJmp_c32 aborts;
    2333 #endif
    23342363
    23352364/** @} */
     
    24222451/** The TMPL_MODE_STR value for each mode.
    24232452 * These are all in DATA16 so they can be accessed from any code.  */
    2424 BS3_MODE_EXPAND_EXTERN_DATA16(const char *, g_szBs3ModeName, []);
     2453BS3_MODE_EXPAND_EXTERN_DATA16(const char, g_szBs3ModeName, []);
    24252454
    24262455/**
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r60009 r60088  
    352352        section BS3TEXT16 align=2 progbits alloc exec nowrite
    353353  %else
    354         section BS3TEXT16 align=2 CLASS=BS3CODE16 PUBLIC USE16
     354        section BS3TEXT16 align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
    355355  %endif
    356356 %else
     
    380380        section BS3TEXT32 align=1 progbits alloc exec nowrite
    381381  %else
    382         section BS3TEXT32 align=1 CLASS=BS3CODE32 PUBLIC USE32 FLAT
     382        section BS3TEXT32 align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
    383383  %endif
    384384 %else
     
    408408        section BS3TEXT64 align=1 progbits alloc exec nowrite
    409409  %else
    410         section BS3TEXT64 align=1 CLASS=BS3CODE64 PUBLIC USE32 FLAT
     410        section BS3TEXT64 align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
    411411  %endif
    412412 %else
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