- Timestamp:
- Mar 18, 2016 12:07:33 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/Config.kmk
r60008 r60088 401 401 # Note! Optimization options should come after debug stuff as -d2 for instance 402 402 # 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 # 403 407 # 404 408 # Compiler options explained: … … 452 456 TEMPLATE_VBoxBS3KitImg_CXXTOOL = Bs3Ow16 453 457 TEMPLATE_VBoxBS3KitImg_CFLAGS = \ 454 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3C ODE16-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+ 455 459 TEMPLATE_VBoxBS3KitImg_CXXFLAGS = \ 456 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3C ODE16-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+ 457 461 TEMPLATE_VBoxBS3KitImg_CDEFS = ARCH_BITS=16 RT_ARCH_X86 458 462 … … 499 503 clname BS3FLAT segaddr=0x0000 \ 500 504 segment BS3FLAT segaddr=0x0000 \ 501 clname BS3C ODE16segaddr=0x1000 \505 clname BS3CLASS16CODE segaddr=0x1000 \ 502 506 segment BS3TEXT16 \ 503 507 segment BS3TEXT16_END \ … … 520 524 segment .data \ 521 525 segment DATA64_END \ 522 clname BS3C ODE32\526 clname BS3CLASS32CODE \ 523 527 segment BS3TEXT32 \ 524 528 segment TEXT32 \ 525 clname BS3C ODE64\529 clname BS3CLASS64CODE \ 526 530 segment BS3TEXT64 \ 527 531 segment TEXT64 \ … … 582 586 TEMPLATE_VBoxBS3KitImg32_CXXTOOL = Bs3Ow32 583 587 TEMPLATE_VBoxBS3KitImg32_CFLAGS = \ 584 -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3C ODE32-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+ 585 589 TEMPLATE_VBoxBS3KitImg32_CXXFLAGS = \ 586 -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3C ODE32-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+ 587 591 TEMPLATE_VBoxBS3KitImg32_INCS = $(VBOX_PATH_BS3KIT_SRC) . 588 592 TEMPLATE_VBoxBS3KitImg32_LDTOOL = VBoxBsUnusedLd -
trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk
r60024 r60088 45 45 if defined(VBOX_WITH_OPEN_WATCOM) 46 46 if1of ($(KBUILD_TARGET), win) 47 # temp disabled #VBOX_WITH_BS3KIT = 147 VBOX_WITH_BS3KIT = 1 48 48 else if $(VBOX_GCC_VERSION_CC) >= 40400 # ms_abi was added in 4.4 49 49 # Awaiting elf -> omf converter # if1of ($(KBUILD_TARGET), linux) -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60024 r60088 30 30 extern BS3_DECL(void) TMPL_NM(bs3CpuBasic2_TssGateEsp_IntXx)(void); 31 31 32 # if TMPL_MODE == BS3_MODE_PE16 \ 33 || TMPL_MODE == BS3_MODE_PE16_32 34 35 static 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 84 AssertCompileMemberOffset(BS3REGCTX, ss, 0x9a); 85 32 86 BS3_DECL(uint8_t) TMPL_NM(bs3CpuBasic2_TssGateEsp)(uint8_t bMode) 33 87 { 34 88 uint8_t bRet = 0; 35 # if TMPL_MODE == BS3_MODE_PE16 \36 || TMPL_MODE == BS3_MODE_PE16_3237 89 BS3TRAPFRAME TrapCtx; 38 90 BS3REGCTX Ctx; 39 91 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 40 99 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); 42 106 43 107 /* 44 108 * Check that the stuff works first. 45 109 */ 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); 48 117 49 Bs3TrapUnsetJmp(); 50 } 51 else 52 { 53 /* trapped. */ 54 } 118 Bs3Printf("trapped\n"); 55 119 56 120 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac
r60024 r60088 72 72 73 73 74 BS3_PROC_BEGIN_MODE bs3CpuBasic2_TssGateEsp_IntXx 75 int 80h 76 nop 77 BS3_PROC_END_MODE bs3CpuBasic2_TssGateEsp_IntXx 78 79 74 80 75 81 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r60024 r60088 85 85 bs3-cmn-RegCtxConvertToRingX.c \ 86 86 bs3-cmn-RegCtxPrint.c \ 87 bs3-cmn-RegCtxSave.asm \ 87 88 bs3-cmn-SelFar32ToFlat32.c \ 88 89 bs3-cmn-SelProtFar32ToFlat32.c \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp
r60044 r60088 994 994 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FLAT"), &idxGrpFlat) 995 995 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3DATA64_GROUP"), &idxGrpData) 996 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3C ODE64"), &idxClassCode)996 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CLASS64CODE"), &idxClassCode) 997 997 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FAR_DATA"), &idxClassData) 998 998 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("DWARF"), &idxClassDwarf) … … 1570 1570 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FLAT"), &idxGrpFlat) 1571 1571 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3DATA64_GROUP"), &idxGrpData) 1572 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3C ODE64"), &idxClassCode)1572 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("BS3CLASS64CODE"), &idxClassCode) 1573 1573 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("FAR_DATA"), &idxClassData) 1574 1574 || !omfWriter_LNamesAddN(pThis, RT_STR_TUPLE("DEBSYM"), &idxClassDebugSymbols) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm
r60002 r60088 664 664 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], cx 665 665 mov [bp + 2], cx ; For better call stacks. 666 mov cx, [e ax+ X86TSS16.cs]666 mov cx, [es:di + X86TSS16.cs] 667 667 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx 668 mov cx, [e ax+ X86TSS16.ds]668 mov cx, [es:di + X86TSS16.ds] 669 669 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx 670 mov cx, [e ax+ X86TSS16.es]670 mov cx, [es:di + X86TSS16.es] 671 671 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx 672 mov cx, [e ax+ X86TSS16.ss]672 mov cx, [es:di + X86TSS16.ss] 673 673 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 674 mov cx, [e ax+ 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. 675 675 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx 676 676 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCpy.c
r58666 r60088 30 30 BS3_DECL(void BS3_FAR *) BS3_CMN_NM(Bs3MemCpy)(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy) 31 31 { 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 32 57 size_t cLargeRounds; 33 58 BS3CPTRUNION uSrc; … … 44 69 *uDst.pb++ = *uSrc.pb++; 45 70 71 #endif 72 46 73 return pvDst; 47 74 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxPrint.c
r59976 r60088 40 40 pRegCtx->rip.u32, pRegCtx->rsp.u32, pRegCtx->rbp.u32, pRegCtx->rflags.u32, pRegCtx->cr0.u32, pRegCtx->cr2.u32); 41 41 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); 43 43 Bs3Printf("tr=%04RX16 ldtr=%04RX16 cpl=%d mode=%#x\n", 44 44 pRegCtx->tr, pRegCtx->ldtr, pRegCtx->bCpl, pRegCtx->bMode); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
r60002 r60088 46 46 ; @note Only respects the BS3_MODE_CODE_MASK part of pRegCtx->bMode. 47 47 ; 48 %if TMPL_BITS == 16 || TMPL_BITS == 32 49 BS3_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 48 57 BS3_PROC_BEGIN_CMN Bs3RegCtxRestore 49 58 BS3_CALL_CONV_PROLOG 2 … … 103 112 104 113 .restore_16_bit_ancient: 105 int3106 114 ; Some general registers. 107 mov si, [bx + BS3REGCTX.rsi]108 115 mov cx, [bx + BS3REGCTX.rcx] 109 116 mov dx, [bx + BS3REGCTX.rdx] … … 130 137 push ax 131 138 139 mov si, [bx + BS3REGCTX.rsi] 132 140 mov di, [bx + BS3REGCTX.rdi] 133 141 mov es, [bx + BS3REGCTX.es] 134 mov ax, [bx + BS3REGCTX.r bx]142 mov ax, [bx + BS3REGCTX.rax] 135 143 mov bp, [bx + BS3REGCTX.rbp] ; restore late for better stacks. 136 144 mov bx, [bx + BS3REGCTX.rbx] … … 141 149 .restore_16_bit_same_privilege: 142 150 sub di, 2*5 ; iret frame + pop ds 143 mov [bx + BS3REGCTX.rsp], di151 mov si, di 144 152 mov es, [bx + BS3REGCTX.ss] ; ES is target stack segment. 145 153 cld … … 158 166 mov di, [bx + BS3REGCTX.rdi] 159 167 mov es, [bx + BS3REGCTX.es] 160 mov ax, [bx + BS3REGCTX.r bx]168 mov ax, [bx + BS3REGCTX.rax] 161 169 mov ss, [bx + BS3REGCTX.ss] 162 mov sp, [bx + BS3REGCTX.rsp] ; adjusted, see above. 170 mov sp, si 171 mov si, [bx + BS3REGCTX.rsi] 163 172 mov bx, [bx + BS3REGCTX.rbx] 164 173 … … 350 359 .using_16_bit_stack_pointer: 351 360 movzx edi, di 352 mov [xBX + BS3REGCTX.rsp], di 361 mov esi, [xBX + BS3REGCTX.rsp] 362 mov si, di ; save rsp for later. 353 363 jmp .es_edi_is_pointing_to_return_frame_location 354 364 .using_32_bit_stack_pointer: 355 mov [xBX + BS3REGCTX.rsp], edi365 mov esi, edi 356 366 .es_edi_is_pointing_to_return_frame_location: 357 367 cld … … 373 383 mov edx, [xBX + BS3REGCTX.rdx] 374 384 mov ecx, [xBX + BS3REGCTX.rcx] 375 mov esi, [xBX + BS3REGCTX.rsi]376 385 mov edi, [xBX + BS3REGCTX.rdi] 377 386 mov ebp, [xBX + BS3REGCTX.rbp] ; restore late for better stacks. 378 387 379 388 mov ss, [xBX + BS3REGCTX.ss] 380 mov esp, [xBX + BS3REGCTX.rsp] ; adjusted, see above. 389 mov esp, esi 390 mov esi, [xBX + BS3REGCTX.rsi] 381 391 mov ebx, [xBX + BS3REGCTX.rbx] 382 392 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm
r60024 r60088 36 36 37 37 38 %if BS3REGCTX_size %39 40 38 41 39 ;; … … 49 47 push xBP 50 48 mov xBP, xSP 51 xPUSHF ; save the incoming flags exactly.52 push xAX ; save incoming xAX53 push xCX ; save incoming xCX54 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 57 55 58 56 ; … … 70 68 ; Clear the whole structure first, unless 64-bit 71 69 ; 72 push es73 les74 push ds75 pop ds76 70 xor xAX, xAX 77 71 cld 78 72 %if TMPL_BITS == 16 73 les xDI, [xBP + xCB*2] 79 74 mov xCX, BS3REGCTX_size / 2 80 75 rep stosw 81 mov di, [bp + 4]82 76 %else 77 mov xDI, [xBP + xCB*2] 83 78 mov xCX, BS3REGCTX_size / 4 84 79 rep stosd 80 %endif 85 81 mov xDI, [xBP + xCB*2] 86 %endif87 82 %endif 88 83 … … 90 85 ; Save the current mode. 91 86 ; 92 mov cl, BS3_DATA16_WRT(g_bBs3CurrentMode)87 mov cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 93 88 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 100 96 jae .save_full 101 97 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. 104 103 push es 105 104 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 113 106 ; 16-bit GPRs not on the stack. 114 107 mov [xDI + BS3REGCTX.rdx], dx … … 116 109 mov [xDI + BS3REGCTX.rsi], si 117 110 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 123 117 %endif 124 118 … … 149 143 %endif 150 144 %if TMPL_BITS == 16 ; Save high bits. 151 mov [xDI + BS3REGCTX. eax], eax152 mov [xDI + BS3REGCTX. ecx], ecx153 mov [xDI + BS3REGCTX. edi], edi154 mov [xDI + BS3REGCTX. ebp], ebp155 mov [xDI + BS3REGCTX. esp], esp145 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 156 150 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 159 157 160 158 ; Control registers. … … 167 165 mov sAX, cr4 168 166 mov [xDI + BS3REGCTX.cr4], sAX 167 168 ; 80286 control registers. 169 .common_80286: 169 170 str [xDI + BS3REGCTX.tr] 170 171 sldt [xDI + BS3REGCTX.ldtr] 171 172 172 ; Segment registers.173 mov [xDI + BS3REGCTX.fs], fs174 mov [xDI + BS3REGCTX.gs], gs175 176 173 ; 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] 179 176 mov [xDI + BS3REGCTX.rflags], xAX 180 177 mov xAX, [xBP - xCB*2] 181 mov [xDI + BS3REGCTX. eax], xAX178 mov [xDI + BS3REGCTX.rax], xAX 182 179 mov xAX, [xBP - xCB*3] 183 mov [xDI + BS3REGCTX. ecx], xAX180 mov [xDI + BS3REGCTX.rcx], xAX 184 181 mov xAX, [xBP - xCB*4] 185 mov [xDI + BS3REGCTX. edi], xAX182 mov [xDI + BS3REGCTX.rdi], xAX 186 183 mov xAX, [xBP] 187 mov [xDI + BS3REGCTX. ebp], xAX184 mov [xDI + BS3REGCTX.rbp], xAX 188 185 mov xAX, [xBP + xCB] 189 186 mov [xDI + BS3REGCTX.rip], xAX 190 187 lea xAX, [xBP + xCB*2] 191 mov [xDI + BS3REGCTX. esp], xAX188 mov [xDI + BS3REGCTX.rsp], xAX 192 189 193 190 mov [xDI + BS3REGCTX.cs], cs … … 201 198 mov [xDI + BS3REGCTX.es], es 202 199 %endif 200 mov [xDI + BS3REGCTX.ss], ss 203 201 204 202 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c
r60024 r60088 34 34 * Global Variables * 35 35 *********************************************************************************************************************************/ 36 /* We ASSUME that BS3C ODE16is 64KB aligned, so the low 16-bit of the36 /* We ASSUME that BS3CLASS16CODE is 64KB aligned, so the low 16-bit of the 37 37 flat address matches. Also, these symbols are defined both with 38 38 and without underscore prefixes. */ … … 57 57 if (f386Plus) 58 58 { 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; 63 74 } 64 75 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c
r60001 r60088 29 29 *********************************************************************************************************************************/ 30 30 #include "bs3kit-template-header.h" 31 32 33 /********************************************************************************************************************************* 34 * Global Variables * 35 *********************************************************************************************************************************/ 36 #define g_pBs3TrapSetJmpFrame BS3_DATA_NM(g_pBs3TrapSetJmpFrame) 37 extern uint32_t g_pBs3TrapSetJmpFrame; 38 39 #define g_Bs3TrapSetJmpCtx BS3_DATA_NM(g_Bs3TrapSetJmpCtx) 40 extern BS3REGCTX g_Bs3TrapSetJmpCtx; 31 41 32 42 … … 163 173 164 174 /* 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 /* 165 189 * Fatal. 166 190 */ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm
r60024 r60088 85 85 %if TMPL_BITS == 16 86 86 xor ax, ax 87 push word [xBP + xCB*2 + 2] 87 88 push ax 88 push word [xBP + xCB*2 + 2]89 89 push word [xBP + xCB*2] 90 90 call Bs3SelFar32ToFlat32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac
r59932 r60088 53 53 section BS3TEXT16_END align=2 progbits alloc exec nowrite 54 54 %else 55 section BS3TEXT16_END align=2 CLASS=BS3C ODE16PUBLIC USE1655 section BS3TEXT16_END align=2 CLASS=BS3CLASS16CODE PUBLIC USE16 56 56 %endif 57 57 … … 109 109 section BS3TEXT32_END align=1 progbits alloc exec nowrite 110 110 %else 111 section BS3TEXT32_END align=1 CLASS=BS3C ODE32PUBLIC USE32 FLAT111 section BS3TEXT32_END align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT 112 112 %endif 113 113 … … 132 132 section BS3TEXT64_END align=1 progbits alloc exec nowrite 133 133 %else 134 section BS3TEXT64_END align=1 CLASS=BS3C ODE64PUBLIC USE32 FLAT134 section BS3TEXT64_END align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT 135 135 %endif 136 136 BS3_GLOBAL_DATA Bs3Text64_EndOfSegment, 0 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r60024 r60088 35 35 #ifndef DOXYGEN_RUNNING 36 36 # 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 37 48 #endif 38 49 … … 385 396 * Get the segment offset part of a far pointer. 386 397 * 398 * For sake of convenience, this works like a uintptr_t cast in 32-bit and 399 * 64-bit code. 400 * 387 401 * @returns offset. 388 402 * @param a_pv Far pointer. … … 397 411 */ 398 412 # 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)) 400 415 #endif 401 416 … … 705 720 /** Free GDTes, part \#1. */ 706 721 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart1)[64]; 707 /** The BS3 CODE16GDT entry. @see BS3_SEL_TEXT16 */722 /** The BS3TEXT16/BS3CLASS16CODE GDT entry. @see BS3_SEL_TEXT16 */ 708 723 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_CODE16); 709 724 /** Free GDTes, part \#2. */ … … 713 728 /** Free GDTes, part \#3. */ 714 729 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart3)[223]; 715 /** The BS3DATA16 GDT entry. */730 /** The BS3DATA16/BS3_FAR_DATA GDT entry. */ 716 731 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_DATA16); 717 732 /** The end of the GDT (exclusive). */ … … 1057 1072 */ 1058 1073 #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 */ 1081 DECLINLINE(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 1059 1088 /** @} */ 1060 1089 … … 1081 1110 * The current implementation will only halt the CPU. 1082 1111 */ 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 */1112 BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c16(void); 1113 BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16 */ 1114 BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16 */ 1086 1115 #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 1087 1120 1088 1121 /** … … 2087 2120 BS3_DECL(DECL_NO_RETURN(void)) Bs3RegCtxRestore_c64(PCBS3REGCTX pRegCtx, uint16_t fFlags); /**< @copydoc Bs3RegCtxRestore_c16 */ 2088 2121 #define Bs3RegCtxRestore BS3_CMN_NM(Bs3RegCtxRestore) /**< Selects #Bs3RegCtxRestore_c16, #Bs3RegCtxRestore_c32 or #Bs3RegCtxRestore_c64. */ 2089 #if def __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 2092 2125 #endif 2093 2126 … … 2328 2361 BS3_DECL(void) Bs3TrapUnsetJmp_c64(void); /**< @copydoc Bs3TrapUnsetJmp_c16 */ 2329 2362 #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 #endif2334 2363 2335 2364 /** @} */ … … 2422 2451 /** The TMPL_MODE_STR value for each mode. 2423 2452 * These are all in DATA16 so they can be accessed from any code. */ 2424 BS3_MODE_EXPAND_EXTERN_DATA16(const char *, g_szBs3ModeName, []);2453 BS3_MODE_EXPAND_EXTERN_DATA16(const char, g_szBs3ModeName, []); 2425 2454 2426 2455 /** -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r60009 r60088 352 352 section BS3TEXT16 align=2 progbits alloc exec nowrite 353 353 %else 354 section BS3TEXT16 align=2 CLASS=BS3C ODE16PUBLIC USE16354 section BS3TEXT16 align=2 CLASS=BS3CLASS16CODE PUBLIC USE16 355 355 %endif 356 356 %else … … 380 380 section BS3TEXT32 align=1 progbits alloc exec nowrite 381 381 %else 382 section BS3TEXT32 align=1 CLASS=BS3C ODE32PUBLIC USE32 FLAT382 section BS3TEXT32 align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT 383 383 %endif 384 384 %else … … 408 408 section BS3TEXT64 align=1 progbits alloc exec nowrite 409 409 %else 410 section BS3TEXT64 align=1 CLASS=BS3C ODE64PUBLIC USE32 FLAT410 section BS3TEXT64 align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT 411 411 %endif 412 412 %else
Note:
See TracChangeset
for help on using the changeset viewer.