Changeset 60291 in vbox for trunk/src/VBox/ValidationKit/bootsectors
- Timestamp:
- Apr 1, 2016 8:51:29 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 1 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/Config.kmk
r60270 r60291 515 515 segment BS3SYSTEM16 \ 516 516 clname FAR_DATA \ 517 segment BS3DATA16 segaddr=0x2 700 \517 segment BS3DATA16 segaddr=0x2900 \ 518 518 segment BS3DATA16CONST \ 519 519 segment BS3DATA16CONST2 \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-c.c
r60232 r60291 38 38 BS3TESTMODE_PROTOTYPES_MODE(bs3CpuBasic2_RaiseXcpt1); 39 39 //BS3TESTMODE_PROTOTYPES_CMN(bs3CpuBasic2_iret); 40 //BS3TESTMODE_PROTOTYPES_MODE(bs3CpuBasic2_iret);40 BS3TESTMODE_PROTOTYPES_MODE(bs3CpuBasic2_iret); 41 41 42 42 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60233 r60291 207 207 unsigned uLine; 208 208 # if TMPL_BITS != 16 209 int rc; 209 210 uint8_t *pbIdtCopyAlloc; 210 211 PX86DESC pIdtCopy; 211 212 const unsigned cbIdte = 1 << (3 + cIdteShift); 213 RTCCUINTXREG uCr0Saved = ASMGetCR0(); 214 RTGDTR GdtrSaved; 212 215 # endif 213 216 RTIDTR IdtrSaved; … … 215 218 216 219 ASMGetIDTR(&IdtrSaved); 220 # if TMPL_BITS != 16 221 ASMGetGDTR(&GdtrSaved); 222 # endif 217 223 218 224 /* make sure they're allocated */ … … 481 487 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx80, 0x80 /*bXcpt*/, pszMode, uLine++); 482 488 483 i= Bs3PagingProtect(uCr2Expected, _4K, 0 /*fSet*/, X86_PTE_P /*fClear*/);484 if (RT_SUCCESS( i))489 rc = Bs3PagingProtect(uCr2Expected, _4K, 0 /*fSet*/, X86_PTE_P /*fClear*/); 490 if (RT_SUCCESS(rc)) 485 491 { 486 492 ASMSetIDTR(&Idtr); … … 496 502 /* Check if that the entry type is checked after the whole IDTE has been cleared for #PF. */ 497 503 pIdtCopy[0x80 << cIdteShift].Gate.u4Type = 0; 498 i= Bs3PagingProtect(uCr2Expected, _4K, 0 /*fSet*/, X86_PTE_P /*fClear*/);499 if (RT_SUCCESS( i))504 rc = Bs3PagingProtect(uCr2Expected, _4K, 0 /*fSet*/, X86_PTE_P /*fClear*/); 505 if (RT_SUCCESS(rc)) 500 506 { 501 507 ASMSetIDTR(&Idtr); … … 527 533 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx81, 0x81 /*bXcpt*/, pszMode, uLine++); 528 534 529 i= Bs3PagingProtect(Idtr.pIdt, _4K, 0 /*fSet*/, X86_PTE_RW | X86_PTE_US /*fClear*/);530 if (RT_SUCCESS( i))535 rc = Bs3PagingProtect(Idtr.pIdt, _4K, 0 /*fSet*/, X86_PTE_RW | X86_PTE_US /*fClear*/); 536 if (RT_SUCCESS(rc)) 531 537 { 532 538 ASMSetIDTR(&Idtr); … … 537 543 } 538 544 ASMSetIDTR(&IdtrSaved); 545 } 546 547 /* 548 * Check that CS.u1Accessed is set to 1. Use the test page selector #0 and #3 together 549 * with interrupt gates 80h and 83h, respectively. 550 */ 551 uLine = 5400; 552 if (BS3_MODE_IS_PAGED(bMode) && pbIdtCopyAlloc) 553 { 554 BS3_DATA_NM(Bs3GdteTestPage00) = BS3_DATA_NM(Bs3Gdt)[uSysR0Cs >> X86_SEL_SHIFT]; 555 BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; 556 paIdt[0x80 << cIdteShift].Gate.u16Sel = BS3_SEL_TEST_PAGE_00; 557 558 BS3_DATA_NM(Bs3GdteTestPage03) = BS3_DATA_NM(Bs3Gdt)[(uSysR0Cs + (3 << BS3_SEL_RING_SHIFT)) >> X86_SEL_SHIFT]; 559 BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; 560 paIdt[0x83 << cIdteShift].Gate.u16Sel = BS3_SEL_TEST_PAGE_03; /* rpl is ignored, so leave it as zero. */ 561 562 /* Check that the CS.A bit is being set on a general basis and that 563 the special CS values work with out generic handler code. */ 564 Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx); 565 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx80, 0x80 /*bXcpt*/, pszMode, uLine); 566 if (!(BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 567 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 568 uLine++; 569 570 Bs3MemCpy(&CtxTmp, &Ctx83, sizeof(CtxTmp)); 571 Bs3RegCtxConvertToRingX(&CtxTmp, 3); 572 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 573 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &CtxTmp, 0x83 /*bXcpt*/, pszMode, uLine); 574 if (!(BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 575 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed!\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 576 uLine++; 577 578 /* 579 * Now check that setting CS.u1Access to 1 does __NOT__ trigger a page 580 * fault due to the RW bit being zero. 581 * (We check both with with and without the WP bit if 80486.) 582 */ 583 if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80486) 584 ASMSetCR0(uCr0Saved | X86_CR0_WP); 585 586 BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; 587 BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; 588 rc = Bs3PagingProtect(GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_00, 8, 0 /*fSet*/, X86_PTE_RW /*fClear*/); 589 if (RT_SUCCESS(rc)) 590 { 591 /* ring-0 handler */ 592 Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx); 593 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx80, 0x80 /*bXcpt*/, pszMode, uLine); 594 if (!(BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 595 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed!\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 596 uLine++; 597 598 /* ring-3 handler */ 599 Bs3MemCpy(&CtxTmp, &Ctx83, sizeof(CtxTmp)); 600 Bs3RegCtxConvertToRingX(&CtxTmp, 3); 601 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 602 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &CtxTmp, 0x83 /*bXcpt*/, pszMode, uLine); 603 if (!(BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 604 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed!\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 605 uLine++; 606 607 /* clear WP and repeat the above. */ 608 if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80486) 609 ASMSetCR0(uCr0Saved & ~X86_CR0_WP); 610 BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; /* (No need to RW the page - ring-0, WP=0.) */ 611 BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; /* (No need to RW the page - ring-0, WP=0.) */ 612 613 Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx); 614 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx80, 0x80 /*bXcpt*/, pszMode, uLine); 615 if (!(BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 616 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed!\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 617 uLine++; 618 619 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 620 bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &CtxTmp, 0x83 /*bXcpt*/, pszMode, uLine); 621 if (!(BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED)) 622 Bs3TestFailedF("%u - %s: u4Type=%#x, not accessed!\n", uLine, pszMode, BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type); 623 uLine++; 624 625 Bs3PagingProtect(GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_00, 8, X86_PTE_RW /*fSet*/, 0 /*fClear*/); 626 } 627 628 ASMSetCR0(uCr0Saved); 629 630 /* 631 * While we're here, check that if the CS GDT entry is a non-present 632 * page we do get a #PF with the rigth error code and CR2. 633 */ 634 BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; /* Just for fun, really a pointless gesture. */ 635 BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED; 636 rc = Bs3PagingProtect(GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_00, 8, 0 /*fSet*/, X86_PTE_P /*fClear*/); 637 if (RT_SUCCESS(rc)) 638 { 639 Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx); 640 bs3CpuBasic2_ComparePfCtx(&TrapCtx, &Ctx80, 0 /*uErrCd*/, GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_00, 641 f16BitSys, pszMode, uLine); 642 uLine++; 643 644 /* Do it from ring-3 to check ErrCd, which doesn't set X86_TRAP_PF_US it turns out. */ 645 Bs3MemCpy(&CtxTmp, &Ctx83, sizeof(CtxTmp)); 646 Bs3RegCtxConvertToRingX(&CtxTmp, 3); 647 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 648 649 bs3CpuBasic2_ComparePfCtx(&TrapCtx, &CtxTmp, 0 /*uErrCd*/, GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_03, 650 f16BitSys, pszMode, uLine); 651 uLine++; 652 653 Bs3PagingProtect(GdtrSaved.pGdt + BS3_SEL_TEST_PAGE_00, 8, X86_PTE_P /*fSet*/, 0 /*fClear*/); 654 if (BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED) 655 Bs3TestFailedF("%u - %s: u4Type=%#x, accessed!\n", uLine - 2, pszMode, BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type); 656 if (BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED) 657 Bs3TestFailedF("%u - %s: u4Type=%#x, accessed!\n", uLine - 1, pszMode, BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type); 658 } 659 660 /* restore */ 661 paIdt[0x80 << cIdteShift].Gate.u16Sel = uSysR0Cs; 662 paIdt[0x83 << cIdteShift].Gate.u16Sel = uSysR0Cs + (3 << BS3_SEL_RING_SHIFT) + 3; 539 663 } 540 664 … … 614 738 * - Run \#PF and \#GP (and others?) at CPLs other than zero. 615 739 * - Quickly generate all faults. 616 * - Check that CS.u1Accessed is set to 1.617 * - Check that setting CS.u1Access to 1 triggers page fault.618 740 * - Check CS.u1Access = 1 \#PF against \#NP(CS), CS.u2DPL, \#NP(SS), 619 741 * SS.u2DPL, and SS.u1Access=1 \#PF. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r60234 r60291 64 64 bs3-cmn-PrintX32.asm \ 65 65 bs3-cmn-PrintStr.c \ 66 bs3-cmn-PrintStrN.asm \ 66 67 bs3-cmn-PrintStrColonSpaces.asm \ 67 68 bs3-cmn-PrintStrSpacesColonSpace.c \ … … 197 198 ../../../Runtime/common/asm/ASMGetIDTR.asm \ 198 199 ../../../Runtime/common/asm/ASMSetIDTR.asm \ 200 ../../../Runtime/common/asm/ASMGetGDTR.asm \ 201 ../../../Runtime/common/asm/ASMSetGDTR.asm \ 199 202 200 203 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStr.c
r58675 r60291 5 5 6 6 /* 7 * Copyright (C) 2007-201 5Oracle Corporation7 * Copyright (C) 2007-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 27 27 #include "bs3kit-template-header.h" 28 28 29 #undef Bs3PrintStr 30 BS3_DECL(void) BS3_CMN_NM(Bs3PrintStr)(const char BS3_FAR *pszString) 29 BS3_DECL(void) Bs3PrintStr(const char BS3_FAR *pszString) 31 30 { 32 char ch; 33 while ((ch = *pszString++) != '\0') 34 Bs3PrintChr(ch); 31 Bs3PrintStrN(pszString, Bs3StrLen(pszString)); 35 32 } 36 33 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Printf.c
r58812 r60291 5 5 6 6 /* 7 * Copyright (C) 2007-201 5Oracle Corporation7 * Copyright (C) 2007-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 */ 26 26 27 28 /********************************************************************************************************************************* 29 * Header Files * 30 *********************************************************************************************************************************/ 27 31 #include "bs3kit-template-header.h" 28 32 #include <iprt/ctype.h> 29 33 30 34 35 /********************************************************************************************************************************* 36 * Structures and Typedefs * 37 *********************************************************************************************************************************/ 38 /** Output buffering for Bs3TestPrintfV. */ 39 typedef struct BS3PRINTBUF 40 { 41 uint8_t cchBuf; 42 char achBuf[79]; 43 } BS3PRINTBUF; 44 45 31 46 static BS3_DECL_CALLBACK(size_t) bs3PrintFmtOutput(char ch, void BS3_FAR *pvUser) 32 47 { 48 BS3PRINTBUF BS3_FAR *pBuf = (BS3PRINTBUF BS3_FAR *)pvUser; 33 49 if (ch != '\0') 34 50 { 35 if (ch == '\n') 36 Bs3PrintChr('\r'); 37 Bs3PrintChr(ch); 38 return 1; 51 BS3_ASSERT(pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf)); 52 pBuf->achBuf[pBuf->cchBuf++] = ch; 53 54 /* Whether to flush the buffer. We do line flushing here to avoid 55 dropping too much info when the formatter crashes on bad input. */ 56 if ( pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf) 57 && ch != '\n') 58 return 1; 39 59 } 40 NOREF(pvUser); 41 return 0; 60 Bs3PrintStrN(&pBuf->achBuf[0], pBuf->cchBuf); 61 pBuf->cchBuf = 0; 62 return ch != '\0'; 42 63 } 43 64 … … 45 66 BS3_DECL(size_t) Bs3PrintfV(const char BS3_FAR *pszFormat, va_list va) 46 67 { 47 return Bs3StrFormatV(pszFormat, va, bs3PrintFmtOutput, NULL); 68 BS3PRINTBUF Buf; 69 Buf.cchBuf = 0; 70 return Bs3StrFormatV(pszFormat, va, bs3PrintFmtOutput, &Buf); 48 71 } 49 72 … … 54 77 va_list va; 55 78 va_start(va, pszFormat); 56 cchRet = Bs3 StrFormatV(pszFormat, va, bs3PrintFmtOutput, NULL);79 cchRet = Bs3PrintfV(pszFormat, va); 57 80 va_end(va); 58 81 return cchRet; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxConvertToRingX.c
r60119 r60291 73 73 * @param uSeg The current selector value. 74 74 * @param bRing The target ring. 75 * @param iReg Register index. 75 76 */ 76 static uint16_t bs3RegCtxConvertProtSelToRingX(uint16_t uSel, uint8_t bRing )77 static uint16_t bs3RegCtxConvertProtSelToRingX(uint16_t uSel, uint8_t bRing, uint8_t iReg) 77 78 { 78 79 if ( uSel > X86_SEL_RPL 79 80 && !(uSel & X86_SEL_LDT) ) 80 81 { 81 if (uSel >= BS3_SEL_R0_FIRST )82 if (uSel >= BS3_SEL_R0_FIRST && uSel < BS3_SEL_R0_FIRST + (5 << BS3_SEL_RING_SHIFT)) 82 83 { 83 84 /* Convert BS3_SEL_R*_XXX to the target ring. */ … … 95 96 else if (uSelRaw == BS3_SEL_DATA16) 96 97 uSel = (BS3_SEL_R0_DS16 | bRing) + ((uint16_t)bRing << BS3_SEL_RING_SHIFT); 98 /* CS and SS must have CPL == DPL. So, convert to standard selectors as we're 99 usually here because Bs3SwitchToRing0 was called to get out of a test situation. */ 100 else if (iReg == X86_SREG_CS || iReg == X86_SREG_SS) 101 { 102 if ( BS3_DATA_NM(Bs3Gdt)[uSel >> X86_SEL_SHIFT].Gen.u1Long 103 && BS3_MODE_IS_64BIT_SYS(BS3_DATA_NM(g_bBs3CurrentMode)) ) 104 uSel = iReg == X86_SREG_CS ? BS3_SEL_R0_CS64 : BS3_SEL_R0_DS64; 105 else 106 { 107 uint32_t uFlat = Bs3SelFar32ToFlat32(0, uSel); 108 bool fDefBig = BS3_DATA_NM(Bs3Gdt)[uSel >> X86_SEL_SHIFT].Gen.u1DefBig; 109 if (!fDefBig && uFlat == BS3_ADDR_BS3TEXT16 && iReg == X86_SREG_CS) 110 uSel = BS3_SEL_R0_CS16; 111 else if (!fDefBig && uFlat == 0 && iReg == X86_SREG_SS) 112 uSel = BS3_SEL_R0_SS16; 113 else if (fDefBig && uFlat == 0) 114 uSel = iReg == X86_SREG_CS ? BS3_SEL_R0_CS32 : BS3_SEL_R0_SS32; 115 else 116 { 117 Bs3Printf("uSel=%#x iReg=%d\n", uSel, iReg); 118 BS3_ASSERT(0); 119 return uSel; 120 } 121 uSel |= bRing; 122 uSel += (uint16_t)bRing << BS3_SEL_RING_SHIFT; 123 } 124 } 97 125 /* Adjust the RPL on tiled and MMIO selectors. */ 98 126 else if ( uSelRaw == BS3_SEL_VMMDEV_MMIO16 … … 128 156 else 129 157 { 130 pRegCtx->cs = bs3RegCtxConvertProtSelToRingX(pRegCtx->cs, bRing );131 pRegCtx->ss = bs3RegCtxConvertProtSelToRingX(pRegCtx->ss, bRing );132 pRegCtx->ds = bs3RegCtxConvertProtSelToRingX(pRegCtx->ds, bRing );133 pRegCtx->es = bs3RegCtxConvertProtSelToRingX(pRegCtx->es, bRing );134 pRegCtx->fs = bs3RegCtxConvertProtSelToRingX(pRegCtx->fs, bRing );135 pRegCtx->gs = bs3RegCtxConvertProtSelToRingX(pRegCtx->gs, bRing );158 pRegCtx->cs = bs3RegCtxConvertProtSelToRingX(pRegCtx->cs, bRing, X86_SREG_CS); 159 pRegCtx->ss = bs3RegCtxConvertProtSelToRingX(pRegCtx->ss, bRing, X86_SREG_SS); 160 pRegCtx->ds = bs3RegCtxConvertProtSelToRingX(pRegCtx->ds, bRing, X86_SREG_DS); 161 pRegCtx->es = bs3RegCtxConvertProtSelToRingX(pRegCtx->es, bRing, X86_SREG_ES); 162 pRegCtx->fs = bs3RegCtxConvertProtSelToRingX(pRegCtx->fs, bRing, X86_SREG_FS); 163 pRegCtx->gs = bs3RegCtxConvertProtSelToRingX(pRegCtx->gs, bRing, X86_SREG_GS); 136 164 } 137 165 pRegCtx->bCpl = bRing; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
r60199 r60291 34 34 %endif 35 35 TMPL_BEGIN_TEXT 36 BS3_EXTERN_CMN Bs3S witchToRing036 BS3_EXTERN_CMN Bs3Syscall 37 37 TMPL_BEGIN_TEXT 38 38 … … 58 58 BS3_PROC_BEGIN_CMN Bs3RegCtxRestore 59 59 BS3_CALL_CONV_PROLOG 2 60 61 ; 62 ; Make sure we're in ring-0 when we do this job. 60 push xBP 61 mov xBP, xSP 62 63 ; 64 ; If we're not in ring-0, ask the kernel to restore it for us (quicker 65 ; and less problematic if we're in a funny context right now with weird 66 ; CS or SS values). 63 67 ; 64 68 mov ax, ss 65 69 test al, 3 66 70 jz .in_ring0 67 call Bs3SwitchToRing0 71 %if TMPL_BITS == 16 72 mov si, [bp + 4] 73 mov cx, [bp + 4+2] 74 mov dx, [bp + 8] 75 mov ax, BS3_SYSCALL_RESTORE_CTX 76 %else 77 mov cx, ds 78 mov xSI, [xBP + xCB*2] 79 movzx edx, word [xBP + xCB*3] 80 mov eax, BS3_SYSCALL_RESTORE_CTX 81 %endif 82 call Bs3Syscall 68 83 .in_ring0: 69 84 … … 72 87 ; g_uBs3CpuDetected), DS:xBX with pRegCtx and fFlags into xCX. 73 88 ; 74 push xBP75 mov xBP, xSP76 89 %if TMPL_BITS == 16 77 90 mov ax, BS3DATA16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestPrintf.c
r60097 r60291 35 35 36 36 37 /********************************************************************************************************************************* 38 * Structures and Typedefs * 39 *********************************************************************************************************************************/ 40 /** Output buffering for Bs3TestPrintfV. */ 41 typedef struct BS3TESTPRINTBUF 42 { 43 bool fNewCmd; 44 uint8_t cchBuf; 45 char achBuf[78]; 46 } BS3TESTPRINTBUF; 47 48 37 49 /** 38 50 * @impl_callback_method{FNBS3STRFORMATOUTPUT, Prints to screen and VMMDev} … … 40 52 static BS3_DECL_CALLBACK(size_t) bs3TestPrintfStrOutput(char ch, void BS3_FAR *pvUser) 41 53 { 54 BS3TESTPRINTBUF BS3_FAR *pBuf = (BS3TESTPRINTBUF BS3_FAR *)pvUser; 55 42 56 /* 43 57 * VMMDev first. We do line by line processing to avoid running out of … … 46 60 if (BS3_DATA_NM(g_fbBs3VMMDevTesting)) 47 61 { 48 bool *pfNewCmd = (bool *)pvUser; 49 if (ch != '\n' && !*pfNewCmd) 62 if (ch != '\n' && !pBuf->fNewCmd) 50 63 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch); 51 64 else if (ch != '\0') 52 65 { 53 if ( *pfNewCmd)66 if (pBuf->fNewCmd) 54 67 { 55 68 ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_PRINT); 56 *pfNewCmd = false;69 pBuf->fNewCmd = false; 57 70 } 58 71 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch); … … 60 73 { 61 74 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\0'); 62 *pfNewCmd = true;75 pBuf->fNewCmd = true; 63 76 } 64 77 } … … 69 82 */ 70 83 if (ch != '\0') 71 Bs3PrintChr(ch); 72 return 1; 84 { 85 BS3_ASSERT(pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf)); 86 pBuf->achBuf[pBuf->cchBuf++] = ch; 87 88 /* Whether to flush the buffer. We do line flushing here to avoid 89 dropping too much info when the formatter crashes on bad input. */ 90 if ( pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf) 91 && ch != '\n') 92 return 1; 93 } 94 BS3_ASSERT(pBuf->cchBuf <= RT_ELEMENTS(pBuf->achBuf)); 95 Bs3PrintStrN(&pBuf->achBuf[0], pBuf->cchBuf); 96 pBuf->cchBuf = 0; 97 return ch != '\0'; 73 98 } 74 99 … … 77 102 BS3_DECL(void) Bs3TestPrintfV(const char BS3_FAR *pszFormat, va_list va) 78 103 { 79 bool fNewCmd = true; 80 Bs3StrFormatV(pszFormat, va, bs3TestPrintfStrOutput, &fNewCmd); 104 BS3TESTPRINTBUF Buf; 105 Buf.fNewCmd = true; 106 Buf.cchBuf = 0; 107 Bs3StrFormatV(pszFormat, va, bs3TestPrintfStrOutput, &Buf); 81 108 } 82 109 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c
r60088 r60291 47 47 if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_PRINT_CHR) 48 48 Bs3PrintChr(pTrapFrame->Ctx.rcx.u8); 49 else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_PRINT_STR) 50 Bs3PrintStrN(Bs3XptrFlatToCurrent((pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16); 51 else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_RESTORE_CTX) 52 Bs3RegCtxRestore(Bs3XptrFlatToCurrent((pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16); 49 53 else if ( pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING0 50 54 || pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING1 … … 180 184 //Bs3Printf("Calling longjmp: pSetJmpFrame=%p (%#lx)\n", pSetJmpFrame, g_pBs3TrapSetJmpFrame); 181 185 g_pBs3TrapSetJmpFrame = 0; 182 183 186 Bs3MemCpy(pSetJmpFrame, pTrapFrame, sizeof(*pSetJmpFrame)); 184 187 //Bs3RegCtxPrint(&g_Bs3TrapSetJmpCtx); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmpAndRestore.c
r60119 r60291 34 34 { 35 35 if (Bs3TrapSetJmp(pTrapFrame)) 36 { 37 #if TMPL_BITS == 32 38 BS3_DATA_NM(g_uBs3TrapEipHint) = pCtxRestore->rip.u32; 39 #endif 36 40 Bs3RegCtxRestore(pCtxRestore, 0); 41 } 37 42 } 38 43 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForLM64.asm
r60019 r60291 55 55 cmp eax, 0ffffffffh 56 56 je .init_root 57 %ifdef BS3_STRICT 58 .return: 59 cmp eax, 1000h 60 jnb .cr3_ok_low 61 hlt 62 .cr3_ok_low: 63 cmp eax, 16*_1M 64 jb .cr3_ok_high 65 hlt 66 .cr3_ok_high: 67 %endif 57 68 ret 58 69 … … 112 123 BS3_ONLY_16BIT_STMT pop es 113 124 leave 125 %ifdef BS3_STRICT 126 jmp .return 127 %else 114 128 ret 129 %endif 115 130 BS3_PROC_END_MODE Bs3PagingGetRootForLM64 116 131 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForPP32.asm
r60019 r60291 55 55 cmp eax, 0ffffffffh 56 56 je .init_root 57 %ifdef BS3_STRICT 58 .return: 59 cmp eax, 1000h 60 jnb .cr3_ok_low 61 hlt 62 .cr3_ok_low: 63 cmp eax, 16*_1M 64 jb .cr3_ok_high 65 hlt 66 .cr3_ok_high: 67 %endif 57 68 ret 58 69 … … 113 124 BS3_ONLY_16BIT_STMT pop es 114 125 leave 126 %ifdef BS3_STRICT 127 jmp .return 128 %else 115 129 ret 130 %endif 116 131 BS3_PROC_END_MODE Bs3PagingGetRootForPP32 117 132 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM16.asm
r59946 r60291 43 43 BS3_PROC_BEGIN_MODE Bs3SwitchToLM16 44 44 %ifdef TMPL_LM16 45 extern BS3_CMN_NM(Bs3SwitchToRing0) 46 call BS3_CMN_NM(Bs3SwitchToRing0) 47 push ax 48 mov ax, BS3_SEL_R0_DS16 49 mov ds, ax 50 mov es, ax 51 pop ax 45 52 ret 46 53 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16.asm
r59950 r60291 49 49 BS3_PROC_BEGIN_MODE Bs3SwitchToPAE16 50 50 %ifdef TMPL_PAE16 51 extern BS3_CMN_NM(Bs3SwitchToRing0) 52 call BS3_CMN_NM(Bs3SwitchToRing0) 53 push ax 54 mov ax, BS3_SEL_R0_DS16 55 mov ds, ax 56 mov es, ax 57 pop ax 51 58 ret 52 59 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16.asm
r59950 r60291 42 42 BS3_PROC_BEGIN_MODE Bs3SwitchToPE16 43 43 %ifdef TMPL_PE16 44 extern BS3_CMN_NM(Bs3SwitchToRing0) 45 call BS3_CMN_NM(Bs3SwitchToRing0) 46 push ax 47 mov ax, BS3_SEL_R0_DS16 48 mov ds, ax 49 mov es, ax 50 pop ax 44 51 ret 45 52 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16.asm
r59950 r60291 49 49 BS3_PROC_BEGIN_MODE Bs3SwitchToPP16 50 50 %ifdef TMPL_PP16 51 extern BS3_CMN_NM(Bs3SwitchToRing0) 52 call BS3_CMN_NM(Bs3SwitchToRing0) 53 push ax 54 mov ax, BS3_SEL_R0_DS16 55 mov ds, ax 56 mov es, ax 57 pop ax 51 58 ret 52 59 … … 97 104 push ecx 98 105 pushfd 106 %ifdef BS3_STRICT 107 mov ax, ds 108 cmp ax, BS3_ADDR_BS3DATA16 >> 4 109 je .real_mode_ds_ok 110 hlt 111 .real_mode_ds_ok: 112 %endif 99 113 100 114 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm
r60019 r60291 53 53 BS3_PROC_BEGIN_MODE Bs3SwitchToRM 54 54 %ifdef TMPL_RM 55 push ax 56 mov ax, BS3_SEL_DATA16 57 mov ds, ax 58 mov es, ax 59 pop ax 55 60 ret 56 61 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r60218 r60291 41 41 TMPL_BEGIN_TEXT 42 42 43 %if TMPL_BITS == 3244 43 BS3_EXTERN_CMN Bs3SelProtFar32ToFlat32 45 %endif46 44 BS3_EXTERN_CMN Bs3RegCtxConvertToRingX 47 45 BS3_EXTERN_CMN Bs3RegCtxRestore 48 46 BS3_EXTERN_CMN Bs3Panic 47 48 BS3_BEGIN_TEXT16 49 extern Bs3PrintStrN_c16_CX_Bytes_At_DS_SI 49 50 TMPL_BEGIN_TEXT 50 51 … … 73 74 %define VAR_CALLER_DS [xBP - xCB] 74 75 %endif 75 %define VAR_CALLER_BX [xBP - sCB*1 - xCB] 76 %define VAR_CALLER_BX [xBP - sCB*1 - xCB] ; Note! the upper word is not clean on pre-386 (16-bit mode). 76 77 %define VAR_CALLER_AX [xBP - sCB*2 - xCB] 77 78 %define VAR_CALLER_CX [xBP - sCB*3 - xCB] 78 79 %define VAR_CALLER_DX [xBP - sCB*4 - xCB] 79 80 %define VAR_CALLER_SI [xBP - sCB*5 - xCB] 81 %define VAR_CALLER_SI_HI [xBP - sCB*5 - xCB + 2] 80 82 %define VAR_CALLER_DI [xBP - sCB*6 - xCB] 83 %define VAR_CALLER_DI_HI [xBP - sCB*6 - xCB + 2] 81 84 %if TMPL_BITS == 16 82 85 %define VAR_CALLER_EBP [xBP - sCB*7 - xCB] … … 84 87 %define VAR_CALLER_EFLAGS [xBP - sCB*9 - xCB] 85 88 %define VAR_CALLER_MODE [xBP - sCB*9 - xCB*2] 89 %define BP_TOP_STACK_EXPR xBP - sCB*9 - xCB*2 86 90 %else 87 91 %define VAR_CALLER_MODE [xBP - sCB*6 - xCB*2] 92 %define BP_TOP_STACK_EXPR xBP - sCB*6 - xCB*2 88 93 %endif 89 94 push xBP … … 122 127 push bx ; dummy 123 128 push bx 124 push ax ; dummy 129 xor bx, bx 130 push bx ; dummy 125 131 push ax 126 push cx ; dummy132 push bx ; dummy 127 133 push cx 128 push dx ; dummy134 push bx ; dummy 129 135 push dx 130 push si; dummy136 push bx ; dummy 131 137 push si 132 push di; dummy138 push bx ; dummy 133 139 push di 134 140 sub sp, 0ch ; dummy … … 167 173 dw .to_ringX wrt BS3TEXT16 168 174 dw .to_ringX wrt BS3TEXT16 175 dw .restore_ctx wrt BS3TEXT16 169 176 %else 170 177 dd .invalid_syscall wrt FLAT … … 175 182 dd .to_ringX wrt FLAT 176 183 dd .to_ringX wrt FLAT 184 dd .restore_ctx wrt FLAT 177 185 %endif 178 186 … … 238 246 239 247 ; 240 ; Print CX chars from string pointed to by DX:SI in 16-bit and v8086 mode, 241 ; and ESI/RSI in 64-bit and 32-bit mode (flat). 248 ; Prints DX chars from the string pointed to by CX:xSI to the screen. 242 249 ; 243 250 ; We use the vga bios teletype interrupt to do the writing, so we must 244 ; be in some kind of real mode for this to work. 16-bit code segment245 ; requried for the mode switching code.251 ; be in some kind of real mode for this to work. The string must be 252 ; accessible from real mode too. 246 253 ; 247 254 .print_str: 248 ;;%if TMPL_BITS != 64 249 ;; mov bl, byte VAR_CALLER_MODE 250 ;; and bl, BS3_MODE_CODE_MASK 251 ;; cmp bl, BS3_MODE_CODE_V86 252 ;; jne .print_str_not_v8086 253 ;; ;; @todo this gets complicated _fast_. Later. 254 ;;.print_str_not_v8086: 255 ;;%endif 256 int3 255 %if TMPL_BITS != 64 256 push es 257 %endif 258 ; Convert the incoming pointer to real mode (assuming caller checked 259 ; that real mode can access it). 260 call .convert_ptr_arg_to_real_mode_ax_si 261 mov cx, VAR_CALLER_DX 262 263 ; Switch to real mode (no 20h scratch required) 264 %ifndef TMPL_CMN_R86 265 %if TMPL_BITS != 16 266 jmp .print_str_to_16bit 267 BS3_BEGIN_TEXT16 268 .print_str_to_16bit: 269 BS3_SET_BITS TMPL_BITS 270 %endif 271 extern TMPL_NM(Bs3SwitchToRM) 272 call TMPL_NM(Bs3SwitchToRM) 273 BS3_SET_BITS 16 274 %endif 275 ; Call code in Bs3PrintStrN to do the work. 276 mov ds, ax 277 call Bs3PrintStrN_c16_CX_Bytes_At_DS_SI 278 279 ; Switch back (20h param scratch area not required). 280 %ifndef TMPL_CMN_R86 281 extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm) 282 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm) 283 %if TMPL_BITS != 16 284 BS3_SET_BITS TMPL_BITS 285 jmp .print_str_end 286 TMPL_BEGIN_TEXT 287 %endif 288 .print_str_end: 289 %endif 290 %if TMPL_BITS != 64 291 pop es 292 %endif 257 293 jmp .return 258 294 … … 298 334 jmp Bs3Panic 299 335 336 337 ; 338 ; Restore context pointed to by cx:xSI. 339 ; 340 .restore_ctx: 341 call .convert_ptr_arg_to_cx_xSI 342 BS3_ONLY_64BIT_STMT sub rsp, 10h 343 mov xDX, VAR_CALLER_DX 344 push xDX 345 BS3_ONLY_16BIT_STMT push cx 346 push xSI 347 BS3_CALL Bs3RegCtxRestore, 2 348 jmp Bs3Panic 300 349 301 350 ; … … 696 745 697 746 747 ; 748 ; Internal function for converting a syscall pointer parameter (cx:xSI) 749 ; to a pointer we can use here in this context. 750 ; 751 ; Returns the result in cx:xSI. 752 ; @uses xAX, xCX, xDX 753 ; 754 .convert_ptr_arg_to_cx_xSI: 755 call .convert_ptr_arg_to_flat 756 %if TMPL_BITS == 16 757 ; Convert to tiled address. 758 mov si, ax ; offset. 759 shl dx, X86_SEL_SHIFT 760 add dx, BS3_SEL_TILED 761 mov cx, dx 762 %else 763 ; Just supply a flat selector. 764 mov xSI, xAX 765 mov cx, ds 766 %endif 767 ret 768 769 ; 770 ; Internal function for converting a syscall pointer parameter (caller CX:xSI) 771 ; to a real mode pointer. 772 ; 773 ; Returns the result in AX:SI. 774 ; @uses xAX, xCX, xDX 775 ; 776 .convert_ptr_arg_to_real_mode_ax_si: 777 call .convert_ptr_arg_to_flat 778 mov si, ax 779 %if TMPL_BITS == 16 780 mov ax, dx 781 %else 782 shr eax, 16 783 %endif 784 shl ax, 12 785 ret 786 787 ; 788 ; Internal function for the above that wraps the Bs3SelProtFar32ToFlat32 call. 789 ; 790 ; @returns eax (32-bit, 64-bit), dx+ax (16-bit). 791 ; @uses eax, ecx, edx 792 ; 793 .convert_ptr_arg_to_flat: 794 %if TMPL_BITS == 16 795 ; Convert to (32-bit) flat address first. 796 test byte VAR_CALLER_MODE, BS3_MODE_CODE_V86 797 jz .convert_ptr_arg_to_flat_prot_16 798 799 mov ax, VAR_CALLER_CX 800 mov dx, ax 801 shl ax, 4 802 shr dx, 12 803 add ax, VAR_CALLER_SI 804 adc dx, 0 805 ret 806 807 .convert_ptr_arg_to_flat_prot_16: 808 push es 809 push bx 810 push word VAR_CALLER_CX ; selector 811 xor ax, ax 812 test byte VAR_CALLER_MODE, BS3_MODE_CODE_16 813 jnz .caller_is_16_bit 814 mov ax, VAR_CALLER_SI_HI 815 .caller_is_16_bit: 816 push ax ; offset high 817 push word VAR_CALLER_SI ; offset low 818 call Bs3SelProtFar32ToFlat32 819 add sp, 2*3 820 pop bx 821 pop es 822 ret 823 824 %else ; 32 or 64 bit 825 test byte VAR_CALLER_MODE, BS3_MODE_CODE_V86 826 jz .convert_ptr_arg_to_cx_xSI_prot 827 828 ; Convert real mode address to flat address and return it. 829 movzx eax, word VAR_CALLER_CX 830 shl eax, 4 831 movzx edx, word VAR_CALLER_SI 832 add eax, edx 833 ret 834 835 ; Convert to (32-bit) flat address. 836 .convert_ptr_arg_to_cx_xSI_prot: 837 %if TMPL_BITS == 64 838 push r11 839 push r10 840 push r9 841 push r8 842 sub rsp, 10h 843 %endif 844 movzx ecx, word VAR_CALLER_CX 845 push xCX 846 mov eax, VAR_CALLER_SI 847 test byte VAR_CALLER_MODE, BS3_MODE_CODE_16 848 jz .no_masking_offset 849 and eax, 0ffffh 850 .no_masking_offset: 851 push xAX 852 BS3_CALL Bs3SelProtFar32ToFlat32,2 853 add xSP, xCB*2 BS3_ONLY_64BIT(+ 10h) 854 %if TMPL_BITS == 64 855 pop r8 856 pop r9 857 pop r10 858 pop r11 859 %endif 860 %endif 861 ret 862 698 863 BS3_PROC_END_MODE Bs3TrapSystemCallHandler 699 864 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c
r59941 r60291 170 170 * - 0x10000 to 0x1yyyy - BS3TEXT16 171 171 * - 0x20000 to 0x26fff - BS3SYSTEM16 172 * - 0x2 7000 to 0xzzzzz - BS3DATA16, BS3TEXT32, BS3TEXT64, BS3DATA32, BS3DATA64 (in that order).172 * - 0x29000 to 0xzzzzz - BS3DATA16, BS3TEXT32, BS3TEXT64, BS3DATA32, BS3DATA64 (in that order). 173 173 * - 0xzzzzZ to 0x9fdff - Free conventional memory. 174 174 * - 0x9fc00 to 0x9ffff - Extended BIOS data area (exact start may vary). -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-system-data.asm
r60210 r60291 5 5 6 6 ; 7 ; Copyright (C) 2007-201 5Oracle Corporation7 ; Copyright (C) 2007-2016 Oracle Corporation 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 ; 26 26 27 28 27 %include "bs3kit.mac" 29 28 … … 37 36 StartSystem16: 38 37 db 10, 13, 'eye-catcher: SYSTEM16.......', 10, 13 ; 32 bytes long 39 BS3_GLOBAL_DATA Bs3Gdt, 300038 BS3_GLOBAL_DATA Bs3Gdt, 4000h - 20h 40 39 41 40 ;; Macro for checking GDT offsets as we go along. … … 198 197 199 198 BS3_GLOBAL_DATA Bs3Gdte_R %+ %1 %+ _DS16, 8 ; Entry 108h 200 dw 0ffffh, (0xffff & BS3_ADDR_BS3DATA16) ; 16-bit data segment with base 02 7000h.199 dw 0ffffh, (0xffff & BS3_ADDR_BS3DATA16) ; 16-bit data segment with base 029000h. 201 200 dw 09300h | (%1 << 0dh) | (0xff & (BS3_ADDR_BS3DATA16 >> 16)), 00000h | (0xff00 & (BS3_ADDR_BS3DATA16 >> 16)) 202 201 … … 417 416 418 417 ; 419 ; 2008..2 6f8h - Free GDTEs.420 ; 421 BS3_GLOBAL_DATA Bs3GdteFreePart3, 0 6f8h422 times 0 6f8h db 0423 424 ; 425 ; 2 700h - the real mode segment number for BS3DATA16. DPL=3. BASE=0x23000h426 ; 427 BS3GdtAssertOffset 02 700h418 ; 2008..28f8h - Free GDTEs. 419 ; 420 BS3_GLOBAL_DATA Bs3GdteFreePart3, 08f8h 421 times 08f8h db 0 422 423 ; 424 ; 2900h - the real mode segment number for BS3DATA16. DPL=3. BASE=0x29000h 425 ; 426 BS3GdtAssertOffset 02900h 428 427 BS3_GLOBAL_DATA Bs3Gdte_DATA16, 8h 429 dw 0ffffh, 07000h, 0f302h, 00000h 428 dw 0ffffh, 09000h, 0f302h, 00000h 429 430 ; 431 ; 2908..2f98h - Free GDTEs. 432 ; 433 BS3GdtAssertOffset 02908h 434 BS3_GLOBAL_DATA Bs3GdteFreePart4, 698h 435 times 698h db 0 436 437 ; 438 ; 2be0..2fe0h - 8 spare entries preceeding the test page which we're free 439 ; to mess with page table protection. 440 ; 441 BS3GdtAssertOffset 02fa0h 442 BS3_GLOBAL_DATA Bs3GdtePreTestPage08, 8 443 dq 0 444 BS3_GLOBAL_DATA Bs3GdtePreTestPage07, 8 445 dq 0 446 BS3_GLOBAL_DATA Bs3GdtePreTestPage06, 8 447 dq 0 448 BS3_GLOBAL_DATA Bs3GdtePreTestPage05, 8 449 dq 0 450 BS3_GLOBAL_DATA Bs3GdtePreTestPage04, 8 451 dq 0 452 BS3_GLOBAL_DATA Bs3GdtePreTestPage03, 8 453 dq 0 454 BS3_GLOBAL_DATA Bs3GdtePreTestPage02, 8 455 dq 0 456 BS3_GLOBAL_DATA Bs3GdtePreTestPage01, 8 457 dq 0 458 459 ; 460 ; 2fe0..3fd8h - 16 Test entries at the start of the page where we're free 461 ; to mess with page table protection. 462 ; 463 BS3GdtAssertOffset 02fe0h 464 AssertCompile(($ - $$) == 0x3000) 465 BS3_GLOBAL_DATA Bs3GdteTestPage, 0 466 BS3_GLOBAL_DATA Bs3GdteTestPage00, 8 467 dq 0 468 BS3_GLOBAL_DATA Bs3GdteTestPage01, 8 469 dq 0 470 BS3_GLOBAL_DATA Bs3GdteTestPage02, 8 471 dq 0 472 BS3_GLOBAL_DATA Bs3GdteTestPage03, 8 473 dq 0 474 BS3_GLOBAL_DATA Bs3GdteTestPage04, 8 475 dq 0 476 BS3_GLOBAL_DATA Bs3GdteTestPage05, 8 477 dq 0 478 BS3_GLOBAL_DATA Bs3GdteTestPage06, 8 479 dq 0 480 BS3_GLOBAL_DATA Bs3GdteTestPage07, 8 481 dq 0 482 BS3GdtAssertOffset 3020h 483 times 0fb8h db 0 484 BS3GdtAssertOffset 3fd8h 430 485 BS3_GLOBAL_DATA Bs3GdtEnd, 0 431 486 db 10, 13, 'GDTE', 10, 13 ; alignment padding (next address on 16 byte boundrary). 487 BS3GdtAssertOffset 4000h - 20h ; We're at a page boundrary here! Only GDT and eyecatchers on page starting at 3000h! 488 AssertCompile(($ - $$) == 0x4000) 489 432 490 433 491 … … 954 1012 ; LDT filling up the rest of the segment. 955 1013 ; 956 ; Currently this starts at 0x 6c50, which leaves us with 0x3b0 bytes. We'll use1014 ; Currently this starts at 0x84d0, which leaves us with 0xb30 bytes. We'll use 957 1015 ; the last 32 of those for an eye catcher. 958 1016 ; 959 BS3_GLOBAL_DATA Bs3Ldt, 0 3b0h960 times (0 3b0h - 32) db 01017 BS3_GLOBAL_DATA Bs3Ldt, 0b30h - 32 1018 times (0b30h - 32) db 0 961 1019 BS3_GLOBAL_DATA Bs3LdtEnd, 0 962 1020 db 10, 13, 'eye-catcher: SYSTEM16 END', 10, 13, 0, 0, 0 ; 32 bytes long … … 966 1024 ; 967 1025 %ifndef KBUILD_GENERATING_MAKEFILE_DEPENDENCIES 968 %if ($ - $$) != 0 7000h1026 %if ($ - $$) != 09000h 969 1027 %assign offActual ($ - $$) 970 %error "Bad BS3SYSTEM16 segment size: " %+ offActual %+ ", expected 0x 7000 (28672)"1028 %error "Bad BS3SYSTEM16 segment size: " %+ offActual %+ ", expected 0x9000 (36864)" 971 1029 %endif 972 1030 %endif -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r60231 r60291 184 184 /** The base address of the BS3DATA16 segment. 185 185 * @sa BS3_SEL_DATA16 */ 186 #define BS3_ADDR_BS3DATA16 0x2 7000186 #define BS3_ADDR_BS3DATA16 0x29000 187 187 /** @} */ 188 188 … … 198 198 * | BS3TEXT16 | 0x00010000 | 1000h | 199 199 * | BS3SYSTEM16 | 0x00020000 | 2000h | 200 * | BS3DATA16 | 0x0002 7000 | 2700h |200 * | BS3DATA16 | 0x00029000 | 2900h | 201 201 * 202 202 * This means that we've got a lot of GDT space to play around with. … … 352 352 353 353 #define BS3_SEL_FREE_PART3 0x2008 /**< Free selector space - part \#3. */ 354 #define BS3_SEL_FREE_PART3_LAST 0x26f8 /**< Free selector space - part \#3, last entry. */ 355 356 #define BS3_SEL_DATA16 0x2700 /**< The BS3DATA16 selector. */ 357 358 #define BS3_SEL_GDT_LIMIT 0x2707 /**< The GDT limit. */ 354 #define BS3_SEL_FREE_PART3_LAST 0x28f8 /**< Free selector space - part \#3, last entry. */ 355 356 #define BS3_SEL_DATA16 0x2900 /**< The BS3DATA16 selector. */ 357 358 #define BS3_SEL_FREE_PART4 0x2908 /**< Free selector space - part \#4. */ 359 #define BS3_SEL_FREE_PART4_LAST 0x2f98 /**< Free selector space - part \#4, last entry. */ 360 361 #define BS3_SEL_PRE_TEST_PAGE_08 0x2fa0 /**< Selector located 8 selectors before the test page. */ 362 #define BS3_SEL_PRE_TEST_PAGE_07 0x2fa8 /**< Selector located 7 selectors before the test page. */ 363 #define BS3_SEL_PRE_TEST_PAGE_06 0x2fb0 /**< Selector located 6 selectors before the test page. */ 364 #define BS3_SEL_PRE_TEST_PAGE_05 0x2fb8 /**< Selector located 5 selectors before the test page. */ 365 #define BS3_SEL_PRE_TEST_PAGE_04 0x2fc0 /**< Selector located 4 selectors before the test page. */ 366 #define BS3_SEL_PRE_TEST_PAGE_03 0x2fc8 /**< Selector located 3 selectors before the test page. */ 367 #define BS3_SEL_PRE_TEST_PAGE_02 0x2fd0 /**< Selector located 2 selectors before the test page. */ 368 #define BS3_SEL_PRE_TEST_PAGE_01 0x2fd8 /**< Selector located 1 selector before the test page. */ 369 #define BS3_SEL_TEST_PAGE 0x2fe0 /**< Start of the test page intended for playing around with paging and GDT. */ 370 #define BS3_SEL_TEST_PAGE_00 0x2fe0 /**< Test page selector number 00h (convenience). */ 371 #define BS3_SEL_TEST_PAGE_01 0x2fe8 /**< Test page selector number 01h (convenience). */ 372 #define BS3_SEL_TEST_PAGE_02 0x2ff0 /**< Test page selector number 02h (convenience). */ 373 #define BS3_SEL_TEST_PAGE_03 0x2ff8 /**< Test page selector number 03h (convenience). */ 374 #define BS3_SEL_TEST_PAGE_04 0x3000 /**< Test page selector number 04h (convenience). */ 375 #define BS3_SEL_TEST_PAGE_05 0x3008 /**< Test page selector number 05h (convenience). */ 376 #define BS3_SEL_TEST_PAGE_06 0x3010 /**< Test page selector number 06h (convenience). */ 377 #define BS3_SEL_TEST_PAGE_07 0x3018 /**< Test page selector number 07h (convenience). */ 378 #define BS3_SEL_TEST_PAGE_LAST 0x3fd0 /**< The last selector in the spare page. */ 379 380 #define BS3_SEL_GDT_LIMIT 0x3fd8 /**< The GDT limit. */ 359 381 /** @} */ 360 382 … … 570 592 571 593 /** @name System call numbers (ax). 572 * Paramenters are generally passed in registers specific to each system call. 594 * Paramenters are generally passed in registers specific to each system call, 595 * however cx:xSI is used for passing a pointer parameter. 573 596 * @{ */ 574 597 /** Print char (cl). */ 575 598 #define BS3_SYSCALL_PRINT_CHR UINT16_C(0x0001) 576 /** Print string (pointer in ds:[e]si, length in cx). */599 /** Print string (pointer in cx:xSI, length in dx). */ 577 600 #define BS3_SYSCALL_PRINT_STR UINT16_C(0x0002) 578 601 /** Switch to ring-0. */ … … 584 607 /** Switch to ring-3. */ 585 608 #define BS3_SYSCALL_TO_RING3 UINT16_C(0x0006) 609 /** Restore context (pointer in cx:xSI, flags in dx). */ 610 #define BS3_SYSCALL_RESTORE_CTX UINT16_C(0x0007) 586 611 /** @} */ 587 612 … … 734 759 /** The BS3DATA16/BS3_FAR_DATA GDT entry. */ 735 760 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_DATA16); 736 /** The end of the GDT (exclusive). */ 761 /** Free GDTes, part \#4. */ 762 763 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart4)[211]; 764 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage08); /**< GDT entry 8 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_08 */ 765 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage07); /**< GDT entry 7 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_07 */ 766 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage06); /**< GDT entry 6 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_06 */ 767 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage05); /**< GDT entry 5 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_05 */ 768 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage04); /**< GDT entry 4 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_04 */ 769 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage03); /**< GDT entry 3 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_03 */ 770 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage02); /**< GDT entry 2 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_02 */ 771 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtePreTestPage01); /**< GDT entry 1 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_01 */ 772 /** Array of GDT entries starting on a page boundrary and filling (almost) the 773 * whole page. This is for playing with paging and GDT usage. 774 * @see BS3_SEL_TEST_PAGE */ 775 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage)[2043]; 776 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage00); /**< GDT entry 0 on the test page (convenience). @see BS3_SEL_TEST_PAGE_00 */ 777 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage01); /**< GDT entry 1 on the test page (convenience). @see BS3_SEL_TEST_PAGE_01 */ 778 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage02); /**< GDT entry 2 on the test page (convenience). @see BS3_SEL_TEST_PAGE_02 */ 779 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage03); /**< GDT entry 3 on the test page (convenience). @see BS3_SEL_TEST_PAGE_03 */ 780 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage04); /**< GDT entry 4 on the test page (convenience). @see BS3_SEL_TEST_PAGE_04 */ 781 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage05); /**< GDT entry 5 on the test page (convenience). @see BS3_SEL_TEST_PAGE_05 */ 782 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage06); /**< GDT entry 6 on the test page (convenience). @see BS3_SEL_TEST_PAGE_06 */ 783 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTestPage07); /**< GDT entry 7 on the test page (convenience). @see BS3_SEL_TEST_PAGE_07 */ 784 785 /** The end of the GDT (exclusive - contains eye-catcher string). */ 737 786 extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtEnd); 738 787 … … 1191 1240 1192 1241 /** 1242 * Prints a string to the screen. 1243 * 1244 * @param pchString The string to print. Any terminator charss will be printed. 1245 * @param cchString The exact number of characters to print. 1246 */ 1247 BS3_DECL(void) Bs3PrintStrN_c16(const char BS3_FAR *pszString, size_t cchString); 1248 BS3_DECL(void) Bs3PrintStrN_c32(const char BS3_FAR *pszString, size_t cchString); /**< @copydoc Bs3PrintStrN_c16 */ 1249 BS3_DECL(void) Bs3PrintStrN_c64(const char BS3_FAR *pszString, size_t cchString); /**< @copydoc Bs3PrintStrN_c16 */ 1250 #define Bs3PrintStrN BS3_CMN_NM(Bs3PrintStrN) /**< Selects #Bs3PrintStrN_c16, #Bs3PrintStrN_c32 or #Bs3PrintStrN_c64. */ 1251 1252 /** 1193 1253 * Prints a char to the screen. 1194 1254 * -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r60217 r60291 1121 1121 ;; The base address of the BS3DATA16 segment. 1122 1122 ;; @sa BS3_SEL_DATA16 1123 %define BS3_ADDR_BS3DATA16 02 7000h1123 %define BS3_ADDR_BS3DATA16 029000h 1124 1124 ;; @} 1125 1125 … … 1219 1219 1220 1220 ;; @name System call numbers (ax) 1221 ;; @note Pointers are always passed in cx:xDI. 1221 1222 ;; @{ 1222 1223 ;; Print char (cl). 1223 1224 %define BS3_SYSCALL_PRINT_CHR 0001h 1224 ;; Print string (pointer in ds:[e]si, length in cx).1225 ;; Print string (pointer in cx:xDI, length in xDX). 1225 1226 %define BS3_SYSCALL_PRINT_STR 0002h 1226 1227 ;; Switch to ring-0. … … 1232 1233 ;; Switch to ring-3. 1233 1234 %define BS3_SYSCALL_TO_RING3 0006h 1235 ;; Restore context (pointer in cx:xDI, flags in dx). 1236 %define BS3_SYSCALL_RESTORE_CTX 0007h 1234 1237 ;; The last system call value. 1235 %define BS3_SYSCALL_LAST BS3_SYSCALL_ TO_RING31238 %define BS3_SYSCALL_LAST BS3_SYSCALL_RESTORE_CTX 1236 1239 ;; @} 1237 1240 … … 1389 1392 1390 1393 %define BS3_SEL_FREE_PART3 2008h ;;< Free selector space - part \%3. 1391 %define BS3_SEL_FREE_PART3_LAST 26f8h ;;< Free selector space - part \%3, last entry. 1392 1393 %define BS3_SEL_DATA16 2700h ;;< The BS3DATA16 selector. 1394 1395 %define BS3_SEL_GDT_LIMIT 2707h ;;< The GDT limit. 1394 %define BS3_SEL_FREE_PART3_LAST 28f8h ;;< Free selector space - part \%3, last entry. 1395 1396 %define BS3_SEL_DATA16 2900h ;;< The BS3DATA16 selector. 1397 1398 %define BS3_SEL_FREE_PART4 2908h ;;< Free selector space - part \#4. 1399 %define BS3_SEL_FREE_PART4_LAST 2f98h ;;< Free selector space - part \#4, last entry. 1400 1401 %define BS3_SEL_PRE_TEST_PAGE_08 2fa0h ;;< Selector located 8 selectors before the test page. 1402 %define BS3_SEL_PRE_TEST_PAGE_07 2fa8h ;;< Selector located 7 selectors before the test page. 1403 %define BS3_SEL_PRE_TEST_PAGE_06 2fb0h ;;< Selector located 6 selectors before the test page. 1404 %define BS3_SEL_PRE_TEST_PAGE_05 2fb8h ;;< Selector located 5 selectors before the test page. 1405 %define BS3_SEL_PRE_TEST_PAGE_04 2fc0h ;;< Selector located 4 selectors before the test page. 1406 %define BS3_SEL_PRE_TEST_PAGE_03 2fc8h ;;< Selector located 3 selectors before the test page. 1407 %define BS3_SEL_PRE_TEST_PAGE_02 2fd0h ;;< Selector located 2 selectors before the test page. 1408 %define BS3_SEL_PRE_TEST_PAGE_01 2fd8h ;;< Selector located 1 selector before the test page. 1409 %define BS3_SEL_TEST_PAGE 2fe0h ;;< Start of the test page intended for playing around with paging and GDT. 1410 %define BS3_SEL_TEST_PAGE_00 2fe0h ;;< Test page selector number 00h (convenience). 1411 %define BS3_SEL_TEST_PAGE_01 2fe8h ;;< Test page selector number 01h (convenience). 1412 %define BS3_SEL_TEST_PAGE_02 2ff0h ;;< Test page selector number 02h (convenience). 1413 %define BS3_SEL_TEST_PAGE_03 2ff8h ;;< Test page selector number 03h (convenience). 1414 %define BS3_SEL_TEST_PAGE_04 3000h ;;< Test page selector number 04h (convenience). 1415 %define BS3_SEL_TEST_PAGE_05 3008h ;;< Test page selector number 05h (convenience). 1416 %define BS3_SEL_TEST_PAGE_06 3010h ;;< Test page selector number 06h (convenience). 1417 %define BS3_SEL_TEST_PAGE_07 3018h ;;< Test page selector number 07h (convenience). 1418 %define BS3_SEL_TEST_PAGE_LAST 3fd0h ;;< The last selector in the spare page. 1419 1420 %define BS3_SEL_GDT_LIMIT 3fd8h ;;< The GDT limit. 1396 1421 1397 1422 ;; @}
Note:
See TracChangeset
for help on using the changeset viewer.