Changeset 60657 in vbox
- Timestamp:
- Apr 22, 2016 3:57:22 PM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 8 added
- 40 edited
- 2 copied
-
Makefile.kmk (modified) (1 diff)
-
bs3-cpu-basic-2-template.c (modified) (5 diffs)
-
bs3-cpu-basic-2-template.mac (modified) (2 diffs)
-
bs3-cpu-basic-2.c (modified) (1 diff)
-
bs3kit/Makefile.kmk (modified) (9 diffs)
-
bs3kit/bs3-c16-Trap16Generic.asm (modified) (1 diff)
-
bs3kit/bs3-c16-TrapRmV86Generic.asm (modified) (11 diffs)
-
bs3kit/bs3-c32-Trap32Generic.asm (modified) (1 diff)
-
bs3kit/bs3-c64-Trap64Generic.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-A20Disable.asm (modified) (3 diffs)
-
bs3kit/bs3-cmn-A20Enable.asm (modified) (3 diffs)
-
bs3kit/bs3-cmn-KbdWrite.asm (modified) (2 diffs)
-
bs3kit/bs3-cmn-MemChr.asm (copied) (copied from trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemZero.asm ) (2 diffs)
-
bs3kit/bs3-cmn-MemSet.asm (copied) (copied from trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemZero.asm ) (2 diffs)
-
bs3kit/bs3-cmn-PrintU32.asm (modified) (3 diffs)
-
bs3kit/bs3-cmn-PrintX32.asm (modified) (3 diffs)
-
bs3kit/bs3-cmn-RegCtxRestore.asm (modified) (8 diffs)
-
bs3kit/bs3-cmn-RegCtxSave.asm (modified) (5 diffs)
-
bs3kit/bs3-cmn-RegCtxSaveEx.asm (added)
-
bs3kit/bs3-cmn-SelFar32ToFlat32NoClobber.asm (added)
-
bs3kit/bs3-cmn-SelFlatDataToProtFar16.asm (added)
-
bs3kit/bs3-cmn-SelFlatDataToRealMode.asm (added)
-
bs3kit/bs3-cmn-SelProtFar16DataToFlat.asm (added)
-
bs3kit/bs3-cmn-SelProtFar16DataToRealMode.asm (added)
-
bs3kit/bs3-cmn-SelRealModeDataToFlat.asm (added)
-
bs3kit/bs3-cmn-SelRealModeDataToProtFar16.asm (added)
-
bs3kit/bs3-cmn-StrFormatV.c (modified) (3 diffs)
-
bs3kit/bs3-cmn-SwitchTo16Bit.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-SwitchTo16BitV86.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-SwitchToRing0.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-SwitchToRing1.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-SwitchToRing2.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-SwitchToRing3.asm (modified) (1 diff)
-
bs3kit/bs3-cmn-TestCheckRegCtxEx.c (modified) (3 diffs)
-
bs3kit/bs3-cmn-TestSendCmdWithStr.asm (modified) (2 diffs)
-
bs3kit/bs3-cmn-TrapDefaultHandler.c (modified) (2 diffs)
-
bs3kit/bs3-cmn-TrapPrintFrame.c (modified) (1 diff)
-
bs3kit/bs3-cmn-TrapSetJmp.asm (modified) (2 diffs)
-
bs3kit/bs3-mode-PagingGetRootForLM64.asm (modified) (3 diffs)
-
bs3kit/bs3-mode-PagingGetRootForPAE32.asm (modified) (3 diffs)
-
bs3kit/bs3-mode-PagingGetRootForPP32.asm (modified) (3 diffs)
-
bs3kit/bs3-mode-SwitchToRM.asm (modified) (2 diffs)
-
bs3kit/bs3-mode-TrapSystemCallHandler.asm (modified) (3 diffs)
-
bs3kit/bs3kit-autostubs.kmk (modified) (1 diff)
-
bs3kit/bs3kit-mangling-code-define.h (modified) (2 diffs)
-
bs3kit/bs3kit-mangling-code-undef.h (modified) (2 diffs)
-
bs3kit/bs3kit-template-footer.mac (modified) (1 diff)
-
bs3kit/bs3kit-template-header.mac (modified) (1 diff)
-
bs3kit/bs3kit.h (modified) (9 diffs)
-
bs3kit/bs3kit.mac (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk
r60609 r60657 247 247 $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate-x0.o16 \ 248 248 $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o32 \ 249 $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o64 249 $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o64 \ 250 $$(bs3-cpu-basic-2_0_OUTDIR)/bs3-cpu-basic-2-asm.o16 250 251 endif 251 252 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60609 r60657 1310 1310 BS3TRAPFRAME TrapCtx; 1311 1311 BS3REGCTX Ctx; 1312 BS3REGCTX CtxUdExpected; 1312 1313 BS3REGCTX TmpCtx; 1313 uint8_t abBuf[16]; 1314 uint8_t const cbBuf = 8*2; /* test buffer area */ 1315 uint8_t abBuf[8*2 + 8 + 8]; /* test buffer w/ misalignment test space and some extra guard. */ 1314 1316 uint8_t BS3_FAR *pbBuf = abBuf; 1317 uint8_t const cbIdtr = BS3_MODE_IS_64BIT_CODE(g_bTestMode) ? 2+8 : BS3_MODE_IS_32BIT_CODE(g_bTestMode) ? 2+4 1318 : (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) == BS3CPU_80286 ? 2+3 : 2+4; 1319 uint8_t bFiller; 1320 unsigned off; 1321 //unsigned i, j; 1322 1323 g_usBs3TestStep = 0; 1315 1324 1316 1325 /* make sure they're allocated */ 1317 1326 Bs3MemZero(&Ctx, sizeof(Ctx)); 1327 Bs3MemZero(&CtxUdExpected, sizeof(CtxUdExpected)); 1318 1328 Bs3MemZero(&TmpCtx, sizeof(TmpCtx)); 1319 1329 Bs3MemZero(&TrapCtx, sizeof(TrapCtx)); … … 1322 1332 /* Create a context, give this routine some more stack space, point the context 1323 1333 at our SIDT [xBX] + UD2 combo, and point DS:xBX at abBuf. */ 1324 Bs3RegCtxSave(&Ctx); 1325 Ctx.rsp.u -= 0x80; 1334 Bs3RegCtxSaveEx(&Ctx, g_bTestMode, 256 /*cbExtraStack*/); 1326 1335 Ctx.rip.u = (uintptr_t)BS3_FP_OFF(&bs3CpuBasic2_sidt_bx_ud2); 1327 1336 # if TMPL_BITS == 32 … … 1333 1342 # endif 1334 1343 1335 /* 1336 * Check that it works at all. 1337 */ 1338 Bs3MemZero(&abBuf, sizeof(abBuf)); 1344 /* For successful SIDT attempts, we'll stop at the UD2. */ 1345 Bs3MemCpy(&CtxUdExpected, &Ctx, sizeof(Ctx)); 1346 CtxUdExpected.rip.u += 3; 1347 1348 /* 1349 * Check that it works at all and that only bytes we expect gets written to. 1350 */ 1351 /* First with zero buffer. */ 1352 Bs3MemZero(abBuf, sizeof(abBuf)); 1353 if (!ASMMemIsAllU8(abBuf, sizeof(abBuf), 0)) 1354 Bs3TestFailedF("ASMMemIsAllU8 or Bs3MemZero is busted: abBuf=%.*Rhxs\n", sizeof(abBuf), pbBuf); 1355 if (!ASMMemIsZero(abBuf, sizeof(abBuf))) 1356 Bs3TestFailedF("ASMMemIsZero or Bs3MemZero is busted: abBuf=%.*Rhxs\n", sizeof(abBuf), pbBuf); 1339 1357 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1340 g_usBs3TestStep = 0; 1341 //bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &Ctx, 0x80 /*bXcpt*/); 1358 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); 1359 if (!ASMMemIsZero(&abBuf[cbIdtr], cbBuf - cbIdtr)) 1360 Bs3TestFailedF("Unexpected buffer bytes set (#1): cbIdtr=%u abBuf=%.*Rhxs\n", cbIdtr, cbBuf, pbBuf); 1361 g_usBs3TestStep++; 1362 1363 /* Again with buffer filled a byte not occuring in the previous result. */ 1364 bFiller = 0x55; 1365 while (Bs3MemChr(abBuf, bFiller, cbBuf) != NULL) 1366 bFiller++; 1367 Bs3MemSet(abBuf, bFiller, sizeof(abBuf)); 1368 if (!ASMMemIsAllU8(abBuf, sizeof(abBuf), bFiller)) 1369 Bs3TestFailedF("ASMMemIsAllU8 or Bs3MemSet is busted: bFiller=%#x abBuf=%.*Rhxs\n", bFiller, sizeof(abBuf), pbBuf); 1370 1371 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1372 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); 1373 if (!ASMMemIsAllU8(&abBuf[cbIdtr], cbBuf - cbIdtr, bFiller)) 1374 Bs3TestFailedF("Unexpected buffer bytes set (#2): cbIdtr=%u bFiller=%#x abBuf=%.*Rhxs\n", cbIdtr, bFiller, cbBuf, pbBuf); 1375 if (Bs3MemChr(abBuf, bFiller, cbIdtr) != NULL) 1376 Bs3TestFailedF("Not all bytes touched: cbIdtr=%u bFiller=%#x abBuf=%.*Rhxs\n", cbIdtr, bFiller, cbBuf, pbBuf); 1377 g_usBs3TestStep++; 1378 1379 /* 1380 * Slide the buffer along 8 bytes to cover misalignment. 1381 */ 1382 for (off = 0; off < 8; off++) 1383 { 1384 pbBuf = &abBuf[off]; 1385 CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf); 1386 1387 /* First with zero buffer. */ 1388 Bs3MemZero(abBuf, sizeof(abBuf)); 1389 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1390 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); 1391 if (off > 0 && !ASMMemIsZero(abBuf, off)) 1392 Bs3TestFailedF("Unexpected buffer bytes set before (#3): cbIdtr=%u off=%u abBuf=%.*Rhxs\n", 1393 cbIdtr, off, off + cbBuf, abBuf); 1394 if (!ASMMemIsZero(&abBuf[off + cbIdtr], sizeof(abBuf) - cbIdtr - off)) 1395 Bs3TestFailedF("Unexpected buffer bytes set after (#3): cbIdtr=%u off=%u abBuf=%.*Rhxs\n", 1396 cbIdtr, off, off + cbBuf, abBuf); 1397 g_usBs3TestStep++; 1398 1399 /* Again with buffer filled a byte not occuring in the previous result. */ 1400 Bs3MemSet(abBuf, bFiller, sizeof(abBuf)); 1401 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1402 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); 1403 if (off > 0 && !ASMMemIsAllU8(abBuf, off, bFiller)) 1404 Bs3TestFailedF("Unexpected buffer bytes set before (#4): cbIdtr=%u off=%u bFiller=%#x abBuf=%.*Rhxs\n", 1405 cbIdtr, off, bFiller, off + cbBuf, abBuf); 1406 if (!ASMMemIsAllU8(&abBuf[off + cbIdtr], sizeof(abBuf) - cbIdtr - off, bFiller)) 1407 Bs3TestFailedF("Unexpected buffer bytes set after (#4): cbIdtr=%u off=%u bFiller=%#x abBuf=%.*Rhxs\n", 1408 cbIdtr, off, bFiller, off + cbBuf, abBuf); 1409 if (Bs3MemChr(&abBuf[off], bFiller, cbIdtr) != NULL) 1410 Bs3TestFailedF("Not all bytes touched (#4): cbIdtr=%u off=%u bFiller=%#x abBuf=%.*Rhxs\n", 1411 cbIdtr, off, bFiller, off + cbBuf, abBuf); 1412 g_usBs3TestStep++; 1413 1414 } 1415 pbBuf = abBuf; 1416 CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf); 1417 1418 /* 1419 * Play with the selector limit if the target mode supports limit checking 1420 * We use BS3_SEL_TEST_PAGE_00 for this 1421 */ 1422 if ( !BS3_MODE_IS_RM_OR_V86(g_bTestMode) 1423 && !BS3_MODE_IS_64BIT_CODE(g_bTestMode)) 1424 { 1425 uint16_t cbLimit; 1426 uint16_t const uSavedDs = Ctx.ds; 1427 uint32_t uFlatBuf = Bs3SelPtrToFlat(pbBuf); 1428 Bs3GdteTestPage00 = Bs3Gdte_DATA16; 1429 Bs3GdteTestPage00.Gen.u16BaseLow = (uint16_t)uFlatBuf; 1430 Bs3GdteTestPage00.Gen.u8BaseHigh1 = (uint8_t)(uFlatBuf >> 16); 1431 Bs3GdteTestPage00.Gen.u8BaseHigh2 = (uint8_t)(uFlatBuf >> 24); 1432 1433 CtxUdExpected.ds = Ctx.ds = BS3_SEL_TEST_PAGE_00; 1434 for (off = 0; off < 8; off++) 1435 { 1436 CtxUdExpected.rbx.u = Ctx.rbx.u = off; 1437 for (cbLimit = 0; cbLimit < cbIdtr*2; cbLimit++) 1438 { 1439 Bs3GdteTestPage00.Gen.u16LimitLow = cbLimit; 1440 Bs3MemSet(abBuf, bFiller, sizeof(abBuf)); 1441 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1442 if (off + cbIdtr <= cbLimit + 1) 1443 { 1444 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); 1445 if (Bs3MemChr(&abBuf[off], bFiller, cbIdtr) != NULL) 1446 Bs3TestFailedF("Not all bytes touched (#5): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1447 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1448 } 1449 else 1450 { 1451 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1452 if (off + 2 <= cbLimit + 1) 1453 { 1454 if (Bs3MemChr(&abBuf[off], bFiller, 2) != NULL) 1455 Bs3TestFailedF("Limit bytes not touched (#6): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1456 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1457 if (!ASMMemIsAllU8(&abBuf[off + 2], cbIdtr - 2, bFiller)) 1458 Bs3TestFailedF("Base bytes touched on #GP (#6): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1459 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1460 } 1461 else if (!ASMMemIsAllU8(abBuf, sizeof(abBuf), bFiller)) 1462 Bs3TestFailedF("Bytes touched on #GP: cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1463 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1464 } 1465 1466 if (off > 0 && !ASMMemIsAllU8(abBuf, off, bFiller)) 1467 Bs3TestFailedF("Leading bytes touched (#7): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1468 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1469 if (!ASMMemIsAllU8(&abBuf[off + cbIdtr], sizeof(abBuf) - off - cbIdtr, bFiller)) 1470 Bs3TestFailedF("Trailing bytes touched (#7): cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", 1471 cbIdtr, off, cbLimit, bFiller, off + cbBuf, abBuf); 1472 1473 g_usBs3TestStep++; 1474 } 1475 } 1476 1477 CtxUdExpected.ds = Ctx.ds = uSavedDs; 1478 CtxUdExpected.rbx.u = Ctx.rbx.u = BS3_FP_OFF(pbBuf); 1479 } 1480 1481 /* 1482 * Play with the paging. 1483 */ 1484 if (BS3_MODE_IS_PAGED(g_bTestMode)) 1485 { 1486 1487 1488 } 1342 1489 1343 1490 } … … 1591 1738 BS3_DECL_FAR(uint8_t) TMPL_NM(bs3CpuBasic2_sidt)(uint8_t bMode) 1592 1739 { 1740 //if (bMode == BS3_MODE_PE16_V86) 1741 { 1593 1742 g_pszTestMode = TMPL_NM(g_szBs3ModeName); 1594 1743 g_bTestMode = bMode; … … 1606 1755 */ 1607 1756 Bs3TrapInit(); 1757 } 1758 1608 1759 return 0; 1609 1760 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac
r60609 r60657 96 96 .again: ud2 97 97 jmp .again 98 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_bx_ud2) == 3) 98 99 BS3_PROC_END_CMN bs3CpuBasic2_sidt_bx_ud2 99 100 … … 103 104 .again: ud2 104 105 jmp .again 106 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_bx_ud2) == 3) 105 107 BS3_PROC_END_CMN bs3CpuBasic2_lidt_bx_ud2 106 108 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2.c
r60609 r60657 49 49 { 50 50 //BS3TESTMODEENTRY_MODE("tss / gate / esp", bs3CpuBasic2_TssGateEsp), 51 BS3TESTMODEENTRY_MODE("raise xcpt #1", bs3CpuBasic2_RaiseXcpt1),51 // BS3TESTMODEENTRY_MODE("raise xcpt #1", bs3CpuBasic2_RaiseXcpt1), 52 52 //BS3TESTMODEENTRY_CMN("iret", bs3CpuBasic2_iret), 53 BS3TESTMODEENTRY_MODE("iret", bs3CpuBasic2_iret),54 //BS3TESTMODEENTRY_MODE("sidt", bs3CpuBasic2_sidt),53 // BS3TESTMODEENTRY_MODE("iret", bs3CpuBasic2_iret), 54 BS3TESTMODEENTRY_MODE("sidt", bs3CpuBasic2_sidt), 55 55 }; 56 56 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r60585 r60657 71 71 bs3-cmn-StrNLen.c \ 72 72 bs3-cmn-StrCpy.c \ 73 bs3-cmn-MemChr.asm \ 73 74 bs3-cmn-MemCpy.c \ 74 75 bs3-cmn-MemPCpy.c \ 75 76 bs3-cmn-MemMove.c \ 77 bs3-cmn-MemSet.asm \ 76 78 bs3-cmn-MemZero.asm \ 77 79 bs3-cmn-MemAlloc.c \ … … 88 90 bs3-cmn-RegCtxPrint.c \ 89 91 bs3-cmn-RegCtxSave.asm \ 92 bs3-cmn-RegCtxSaveEx.asm \ 90 93 bs3-cmn-SelFar32ToFlat32.c \ 94 bs3-cmn-SelFar32ToFlat32NoClobber.asm \ 91 95 bs3-cmn-SelProtFar32ToFlat32.c \ 92 96 bs3-cmn-SelProtModeCodeToRealMode.asm \ … … 94 98 bs3-cmn-SelFlatCodeToRealMode.asm \ 95 99 bs3-cmn-SelFlatCodeToProtFar16.asm \ 100 bs3-cmn-SelRealModeDataToProtFar16.asm \ 101 bs3-cmn-SelProtFar16DataToRealMode.asm \ 102 bs3-cmn-SelRealModeDataToFlat.asm \ 103 bs3-cmn-SelProtFar16DataToFlat.asm \ 104 bs3-cmn-SelFlatDataToProtFar16.asm \ 105 bs3-cmn-SelFlatDataToRealMode.asm \ 96 106 bs3-cmn-SlabInit.c \ 97 107 bs3-cmn-SlabAlloc.c \ … … 451 461 # Rule for regenerating bs3kit-mangling-functions-undef.h. 452 462 # 453 bs3kit-mangling-code-undef.h: $(PATH_SUB_CURRENT)/bs3kit-mangling-code-define.h 463 bs3kit-mangling-code-undef.h: $(PATH_SUB_CURRENT)/bs3kit-mangling-code-define.h $(MAKEFILE) 454 464 $(SED) \ 455 465 -e 's/#\( *\)define \([a-zA-Z_][a-zA-Z0-9_]*\) .*$(DOLLAR)/#\1undef \2/' \ … … 464 474 $(PATH_SUB_CURRENT)/bs3kit.h \ 465 475 $(PATH_SUB_CURRENT)/bs3-cmn-paging.h \ 466 $(PATH_SUB_CURRENT)/bs3-cmn-test.h 476 $(PATH_SUB_CURRENT)/bs3-cmn-test.h \ 477 $(MAKEFILE) 467 478 $(APPEND) -tn "$(dir $<)$@" \ 468 479 '/* $(DOLLAR)Id: $(DOLLAR) */' \ … … 496 507 -e 's/^ *BS3_CMN_PROTO_NOSB([^,]*, *\([a-zA-Z_][a-zA-Z0-9_]*\) *,.*$(DOLLAR)/#define \1 BS3_CMN_MANGLER(\1)/p' \ 497 508 -e 's/^ *BS3_CMN_PROTO_FARSTUB([^,]*,[^,]*, *\([a-zA-Z_][a-zA-Z0-9_]*\) *,.*$(DOLLAR)/#define \1 BS3_CMN_MANGLER(\1)/p' \ 498 $ <| sort >> "$(dir $<)bs3kit-mangling-code-define.h"509 $(filter %.h,$^) | sort >> "$(dir $<)bs3kit-mangling-code-define.h" 499 510 $(APPEND) -n "$(dir $<)$@" '#ifndef BS3_CMN_ONLY' 500 511 $(SED) -n \ … … 502 513 -e 's/^ *BS3_MODE_PROTO_NOSB([^,]*, *\([a-zA-Z_][a-zA-Z0-9_]*\) *,.*$(DOLLAR)/# define \1 BS3_MODE_MANGLER(\1)/p' \ 503 514 -e 's/^ *BS3_MODE_PROTO_FARSTUB([^,]*,[^,]*, *\([a-zA-Z_][a-zA-Z0-9_]*\) *,.*$(DOLLAR)/# define \1 BS3_MODE_MANGLER(\1)/p' \ 504 $ <| sort >> "$(dir $<)bs3kit-mangling-code-define.h"515 $(filter %.h,$^) | sort >> "$(dir $<)bs3kit-mangling-code-define.h" 505 516 $(APPEND) -n "$(dir $<)$@" '#endif /* !BS3_CMN_ONLY */' 506 517 … … 512 523 $(PATH_SUB_CURRENT)/bs3-cmn-memory.h \ 513 524 $(PATH_SUB_CURRENT)/bs3-cmn-paging.h \ 514 $(PATH_SUB_CURRENT)/bs3-cmn-test.h 525 $(PATH_SUB_CURRENT)/bs3-cmn-test.h \ 526 $(MAKEFILE) 515 527 $(APPEND) -tn "$(dir $<)$@" \ 516 528 '# $(DOLLAR)Id: $(DOLLAR)' \ … … 542 554 $(SED) -n \ 543 555 -e '/^ *BS3_CMN_PROTO_STUB/p' \ 544 -e '/^ *BS3_CM D_PROTO_FARSTUB/p' \556 -e '/^ *BS3_CMN_PROTO_FARSTUB/p' \ 545 557 -e '/^ *BS3_MODE_PROTO_STUB/p' \ 546 558 -e '/^ *BS3_MODE_PROTO_FARSTUB/p' \ 547 $ <\559 $(filter %.h,$^) \ 548 560 | sort \ 549 561 | $(SED) -n \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm
r60585 r60657 432 432 433 433 .skip_crX_because_cpl_not_0: 434 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR435 jmp .set_flags434 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], \ 435 BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4 | BS3REG_CTX_F_NO_CR0_IS_MSW 436 436 437 437 CPU 286 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-TrapRmV86Generic.asm
r60585 r60657 54 54 BS3_PROC_BEGIN Bs3TrapRmV86GenericEntries 55 55 %macro Bs3TrapRmV86GenericEntryNoErr 1 56 push byte 0 ; 2 byte: fake error code 57 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 58 jmp %1 ; 3 byte 56 push ax ; 1 byte: Reserve space for fake error cd. (BP(+2) + 4) 57 push ax ; 1 byte: Save AX (BP(+2) + 2) 58 mov ax, i | 00000h ; 2 bytes: AL = trap/interrupt number; AH=indicate no error code 59 jmp %1 ; 3 bytes: Jump to handler code 59 60 ALIGNCODE(8) 60 61 %assign i i+1 … … 62 63 63 64 %macro Bs3TrapRmV86GenericEntryErrCd 1 64 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 65 jmp %1 ; 3 byte 65 push ax ; 1 byte: Save AX (BP(+2) + 2) 66 mov ax, i | 0ff00h ; 2 bytes: AL = trap/interrupt number; AH=indicate have error code. 67 jmp %1 ; 3 bytes: Jump to handler code 66 68 ALIGNCODE(8) 67 69 %assign i i+1 … … 111 113 ; Trap or interrupt with error code, faked if necessary. 112 114 ; 113 ; Note! This code is going to "misbehave" if the high word of ESP is not cleared.114 ;115 115 BS3_PROC_BEGIN _bs3TrapRmV86GenericTrapOrInt 116 116 BS3_PROC_BEGIN bs3TrapRmV86GenericTrapOrInt … … 137 137 movzx ebx, sp 138 138 139 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 140 mov edx, [bp - 12h] ; This isn't quite right for wrap arounds, but close enough for now139 140 mov edx, [bp - 12h] 141 141 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], edx ; high bits 142 142 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], edx ; high bits 143 143 mov dx, [bp - 0eh] 144 ;mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], dx - share this here145 144 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], dx 146 145 mov edx, [bp - 0ch] … … 153 152 mov edx, [bp] 154 153 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], edx 155 156 mov dl, [bp + 4] 157 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 158 154 mov edx, eax ; high bits 155 mov dx, [bp + 4] 156 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], edx 157 158 mov [ss:bx + BS3TRAPFRAME.bXcpt], al 159 160 test ah, 0ffh 161 jz .no_error_code 162 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts. 159 163 mov dx, [bp + 6] 160 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts.161 164 mov [ss:bx + BS3TRAPFRAME.uErrCd], dx 165 .no_error_code: 162 166 163 167 add bp, 6 ; adjust so it points to the word before the iret frame. … … 173 177 push bp 174 178 mov bp, sp 175 push bx 176 pushf 177 push ax 179 push bx ; BP - 2 180 pushf ; BP - 4 178 181 cld 179 182 180 183 ; Reserve space for the the register and trap frame. 181 184 mov bx, (BS3TRAPFRAME_size + 7) / 8 185 push ax 182 186 xor ax, ax 183 187 .more_zeroed_space: … … 189 193 jnz .more_zeroed_space 190 194 mov bx, sp 191 192 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ax 193 ;mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], ss - share this here 195 pop ax 196 194 197 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], ss 195 198 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], dx … … 201 204 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], dx 202 205 203 mov dl, [bp + 2] 204 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 205 206 mov dx, [bp + 2] 207 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], dx 208 209 mov [ss:bx + BS3TRAPFRAME.bXcpt], al 210 211 test ah, 0ffh 212 jz .no_error_code 213 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts. 206 214 mov dx, [bp + 4] 207 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts.208 215 mov [ss:bx + BS3TRAPFRAME.uErrCd], dx 216 .no_error_code: 209 217 210 218 add bp, 4 ; adjust so it points to the word before the iret frame. … … 217 225 ; Common context saving code and dispatching. 218 226 ; 219 ; @param bxPointer to the trap frame, zero filled. The following members227 ; @param ss:bx Pointer to the trap frame, zero filled. The following members 220 228 ; have been filled in by the previous code: 221 229 ; - bXcpt … … 295 303 mov byte [ss:bx + BS3TRAPFRAME.cbIretFrame], 3*2 296 304 305 ; The VM flag and CPL. 306 test al, BS3_MODE_CODE_V86 307 jz .dont_set_vm 308 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags + 2], X86_EFL_VM >> 16 309 mov byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3 310 .dont_set_vm: 311 312 297 313 ; 298 314 ; Control registers. 299 315 ; 316 ; Since we're in real or v8086 here, we cannot save TR and LDTR. 317 ; But get MSW (CR0) first since that's always accessible and we 318 ; need it even on a 386 to check whether we're in v8086 mode or not. 319 ; 300 320 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286 301 jb .skip_control_regsiters_because_80186_or_older 302 303 ; The 286 ones. 321 jb .skip_control_registers_because_80186_or_older 304 322 CPU 286 305 str [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.tr]306 sldt [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr]307 323 smsw ax 308 324 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], ax … … 333 349 334 350 CPU 8086 335 .skip_control_reg siters_because_80186_or_older:351 .skip_control_registers_because_80186_or_older: 336 352 .skip_crX_because_v8086: 337 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 353 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], \ 354 BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4 338 355 .set_flags: ; The double fault code joins us here. 339 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64 356 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64 | BS3REG_CTX_F_NO_TR_LDTR 340 357 341 358 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r60319 r60657 370 370 371 371 .skip_crX_because_cpl_not_0: 372 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 373 372 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], \ 373 BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4 374 smsw [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0] 374 375 .set_flags: 375 376 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c64-Trap64Generic.asm
r60203 r60657 296 296 297 297 .skip_crX_because_cpl_not_0: 298 or byte [rdi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 298 or byte [rdi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], \ 299 BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4 300 smsw [rdi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0] 299 301 300 302 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Disable.asm
r60527 r60657 40 40 BS3_PROC_BEGIN_CMN Bs3A20Disable, BS3_PBC_HYBRID_0_ARGS 41 41 ; Must call both because they may be ORed together on real HW. 42 BS3_ONLY_64BIT_STMTsub rsp, 20h42 BONLY64 sub rsp, 20h 43 43 call BS3_CMN_NM(Bs3A20DisableViaKbd) 44 44 call BS3_CMN_NM(Bs3A20DisableViaPortA) 45 BS3_ONLY_64BIT_STMTadd rsp, 20h45 BONLY64 add rsp, 20h 46 46 BS3_HYBRID_RET 47 47 BS3_PROC_END_CMN Bs3A20Disable … … 80 80 pushf 81 81 cli 82 BS3_ONLY_64BIT_STMTsub rsp, 20h82 BONLY64 sub rsp, 20h 83 83 84 84 call Bs3KbdWait … … 97 97 call Bs3KbdWait 98 98 99 BS3_ONLY_64BIT_STMTadd rsp, 20h99 BONLY64 add rsp, 20h 100 100 popf 101 101 pop xAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Enable.asm
r60554 r60657 41 41 push xBP 42 42 mov xBP, xSP 43 BS3_ONLY_64BIT_STMTsub rsp, 20h43 BONLY64 sub rsp, 20h 44 44 45 45 call BS3_CMN_NM(Bs3A20EnableViaPortA) … … 63 63 pushf 64 64 cli 65 BS3_ONLY_64BIT_STMTsub rsp, 20h65 BONLY64 sub rsp, 20h 66 66 67 67 call Bs3KbdWait … … 80 80 call Bs3KbdWait 81 81 82 BS3_ONLY_64BIT_STMTadd rsp, 20h82 BONLY64 add rsp, 20h 83 83 popf 84 84 pop xAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWrite.asm
r60527 r60657 49 49 mov xBP, xSP 50 50 push xAX 51 BS3_ONLY_64BIT_STMTsub rsp, 20h51 BONLY64 sub rsp, 20h 52 52 53 53 mov al, [xBP + xCB*2] … … 59 59 call Bs3KbdWait 60 60 61 BS3_ONLY_64BIT_STMTadd rsp, 20h61 BONLY64 add rsp, 20h 62 62 pop xAX 63 63 pop xBP -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemChr.asm
r60585 r60657 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - Bs3Mem Zero.3 ; BS3Kit - Bs3MemChr. 4 4 ; 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 … … 28 28 29 29 ;; 30 ; @cproto BS3_ DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);30 ; @cproto BS3_CMN_PROTO_NOSB(void BS3_FAR *, Bs3MemChr,(void BS3_FAR const *pvHaystack, uint8_t bNeedle, size_t cbHaystack)); 31 31 ; 32 BS3_PROC_BEGIN_CMN Bs3MemZero, BS3_PBC_HYBRID 33 %ifdef RT_ARCH_AMD64 34 push rdi 32 BS3_PROC_BEGIN_CMN Bs3MemChr, BS3_PBC_HYBRID 33 push xBP 34 mov xBP, xSP 35 push xDI 36 TONLY16 push es 35 37 36 mov rdi, rcx ; rdi = pvDst 37 mov rcx, rdx ; rcx = cbDst 38 shr rcx, 3 ; calc qword count. 39 xor eax, eax ; rax = 0 (filler qword) 38 %if TMPL_BITS == 64 39 40 mov rdi, rcx ; rdi = pvHaystack 41 mov rcx, r8 ; rcx = cbHaystack 42 mov al, dl ; bNeedle 43 mov rcx, r8 44 45 %elif TMPL_BITS == 16 46 mov di, [bp + 2 + cbCurRetAddr] ; pvHaystack.off 47 mov es, [bp + 2 + cbCurRetAddr + 2] ; pvHaystack.sel 48 mov al, [bp + 2 + cbCurRetAddr + 4] ; bNeedle 49 mov cx, [bp + 2 + cbCurRetAddr + 6] ; cbHaystack 50 51 %elif TMPL_BITS == 32 52 mov edi, [ebp + 8] ; pvHaystack 53 mov al, byte [ebp + 4 + cbCurRetAddr + 4] ; bNeedle 54 mov ecx, [ebp + 4 + cbCurRetAddr + 8] ; cbHaystack 55 %else 56 %error "TMPL_BITS!" 57 %endif 58 40 59 cld 41 rep stosq 60 repne scasb 61 je .found 42 62 43 mov rcx, rdx ; cbDst 44 and rcx, 7 ; calc trailing byte count. 45 rep stosb 63 xor xAX, xAX 64 TONLY16 xor dx, dx 46 65 47 pop rdi 66 .return: 67 TONLY16 pop es 68 pop xDI 69 pop xBP 48 70 BS3_HYBRID_RET 49 71 50 %elif ARCH_BITS == 16 51 push bp 52 mov bp, sp 53 push di 54 push es 72 .found: 73 lea xAX, [xDI - 1] 74 TONLY16 mov dx, es 75 jmp .return 55 76 56 mov di, [bp + 2 + cbCurRetAddr] ; pvDst.off 57 mov dx, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel 58 mov es, dx 59 mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst 60 shr cx, 1 ; calc dword count. 61 xor ax, ax 62 rep stosw 77 BS3_PROC_END_CMN Bs3MemChr 63 78 64 mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst65 and cx, 1 ; calc tailing byte count.66 rep stosb67 68 pop es69 pop di70 pop bp71 BS3_HYBRID_RET72 73 %elif ARCH_BITS == 3274 push edi75 76 mov edi, [esp + 8] ; pvDst77 mov ecx, [esp + 8 + 4] ; cbDst78 shr cx, 2 ; calc dword count.79 xor eax, eax80 rep stosd81 82 mov ecx, [esp + 8 + 4] ; cbDst83 and ecx, 3 ; calc tailing byte count.84 rep stosb85 86 pop edi87 BS3_HYBRID_RET88 89 %else90 %error "Unknown bitness."91 %endif92 BS3_PROC_END_CMN Bs3MemZero93 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemSet.asm
r60585 r60657 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - Bs3Mem Zero.3 ; BS3Kit - Bs3MemSet. 4 4 ; 5 5 … … 28 28 29 29 ;; 30 ; @cproto BS3_ DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);30 ; @cproto BS3_CMN_PROTO_NOSB(void, Bs3MemSet,(void BS3_FAR *pvDst, uint8_t bFiller, size_t cbDst)); 31 31 ; 32 BS3_PROC_BEGIN_CMN Bs3MemZero, BS3_PBC_HYBRID 32 BS3_PROC_BEGIN_CMN Bs3MemSet, BS3_PBC_HYBRID 33 push xBP 34 mov xBP, xSP 35 push xDI 33 36 %ifdef RT_ARCH_AMD64 34 push rdi35 37 36 38 mov rdi, rcx ; rdi = pvDst 37 mov rcx, rdx ; rcx = cbDst 39 mov rcx, r8 ; rcx = cbDst 40 movzx edx, dl ; bFiller 41 mov rax, 0101010101010101h 42 mul rdx 43 mov rcx, r8 38 44 shr rcx, 3 ; calc qword count. 39 xor eax, eax ; rax = 0 (filler qword)40 45 cld 41 46 rep stosq 42 47 43 mov rcx, r dx; cbDst48 mov rcx, r8 ; cbDst 44 49 and rcx, 7 ; calc trailing byte count. 45 50 rep stosb 46 51 47 pop rdi48 BS3_HYBRID_RET49 50 52 %elif ARCH_BITS == 16 51 push bp52 mov bp, sp53 push di54 53 push es 55 54 56 55 mov di, [bp + 2 + cbCurRetAddr] ; pvDst.off 57 mov dx, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel 58 mov es, dx 59 mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst 56 mov es, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel 57 mov al, [bp + 2 + cbCurRetAddr + 4] ; bFiller 58 mov ah, al 59 mov cx, [bp + 2 + cbCurRetAddr + 6] ; cbDst 60 60 shr cx, 1 ; calc dword count. 61 xor ax, ax62 61 rep stosw 63 62 64 mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst63 mov cx, [bp + 2 + cbCurRetAddr + 6] ; cbDst 65 64 and cx, 1 ; calc tailing byte count. 66 65 rep stosb 67 66 68 67 pop es 69 pop di70 pop bp71 BS3_HYBRID_RET72 68 73 69 %elif ARCH_BITS == 32 74 push edi 75 76 mov edi, [esp + 8] ; pvDst 77 mov ecx, [esp + 8 + 4] ; cbDst 78 shr cx, 2 ; calc dword count. 79 xor eax, eax 70 mov edi, [ebp + 8] ; pvDst 71 mov al, byte [ebp + 4 + cbCurRetAddr + 4] ; bFiller 72 mov ah, al 73 mov dx, ax 74 shl eax, 16 75 mov ax, dx ; eax = RT_MAKE_U32_FROM_U8(bFiller, bFiller, bFiller, bFiller) 76 mov ecx, [ebp + 4 + cbCurRetAddr + 8] ; cbDst 77 shr cx, 2 ; calc dword count. 80 78 rep stosd 81 79 82 mov ecx, [e sp + 8 + 4]; cbDst83 and ecx, 3 ; calc tailing byte count.80 mov ecx, [ebp + 4 + cbCurRetAddr + 8] ; cbDst 81 and ecx, 3 ; calc tailing byte count. 84 82 rep stosb 85 86 pop edi87 BS3_HYBRID_RET88 83 89 84 %else 90 85 %error "Unknown bitness." 91 86 %endif 92 BS3_PROC_END_CMN Bs3MemZero93 87 88 pop xDI 89 pop xBP 90 BS3_HYBRID_RET 91 BS3_PROC_END_CMN Bs3MemSet 92 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm
r60527 r60657 43 43 push sCX 44 44 push sBX 45 BS3_ONLY_16BIT_STMT pushds45 BONLY16 push ds 46 46 47 47 mov eax, [xBP + xCB + cbCurRetAddr] … … 49 49 ; Allocate a stack buffer and terminate it. ds:bx points ot the end. 50 50 sub xSP, 30h 51 BS3_ONLY_16BIT_STMT movbx, ss52 BS3_ONLY_16BIT_STMT movds, bx51 BONLY16 mov bx, ss 52 BONLY16 mov ds, bx 53 53 mov xBX, xSP 54 54 add xBX, 2fh … … 66 66 67 67 ; Print the string. 68 BS3_ONLY_64BIT_STMTadd rsp, 18h69 BS3_ONLY_16BIT_STMTpush ss68 BONLY64 add rsp, 18h 69 BONLY16 push ss 70 70 push xBX 71 71 BS3_CALL Bs3PrintStr, 1 72 72 73 73 add xSP, 30h + BS3_IF_16_32_64BIT(2, 0, 18h) + xCB 74 BS3_ONLY_16BIT_STMT popds74 BONLY16 pop ds 75 75 pop sBX 76 76 pop sCX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm
r60527 r60657 43 43 push sCX 44 44 push sBX 45 BS3_ONLY_16BIT_STMT pushds45 BONLY16 push ds 46 46 47 47 mov eax, [xBP + xCB + cbCurRetAddr] … … 49 49 ; Allocate a stack buffer and terminate it. ds:bx points ot the end. 50 50 sub xSP, 30h 51 BS3_ONLY_16BIT_STMT movbx, ss52 BS3_ONLY_16BIT_STMT movds, bx51 BONLY16 mov bx, ss 52 BONLY16 mov ds, bx 53 53 mov xBX, xSP 54 54 add xBX, 2fh … … 70 70 71 71 ; Print the string. 72 BS3_ONLY_64BIT_STMTadd rsp, 18h73 BS3_ONLY_16BIT_STMTpush ss72 BONLY64 add rsp, 18h 73 BONLY16 push ss 74 74 push xBX 75 75 BS3_CALL Bs3PrintStr, 1 76 76 77 77 add xSP, 30h + BS3_IF_16_32_64BIT(2, 0, 18h) + xCB 78 BS3_ONLY_16BIT_STMT popds78 BONLY16 pop ds 79 79 pop sBX 80 80 pop sCX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
r60527 r60657 69 69 ; CS or SS values). 70 70 ; 71 %if TMPL_BITS == 16 72 cmp byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM 73 je .in_ring0 74 test byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_V86 75 jnz .do_syscall_restore_ctx 76 %endif 71 77 mov ax, ss 72 78 test al, 3 73 79 jz .in_ring0 80 81 .do_syscall_restore_ctx: 74 82 %if TMPL_BITS == 16 75 83 mov si, [bp + xCB + cbCurRetAddr] … … 84 92 %endif 85 93 call Bs3Syscall 86 .in_ring0:87 94 88 95 ; … … 90 97 ; and g_uBs3CpuDetected), DS:xBX with pRegCtx and fFlags into xCX. 91 98 ; 99 .in_ring0: 92 100 %if TMPL_BITS == 16 93 101 mov ax, BS3_SEL_DATA16 … … 236 244 test cl, BS3TRAPRESUME_F_SKIP_CRX 237 245 jnz .skip_control_regs 238 test byte [xBX + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 246 test byte [xBX + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 239 247 jnz .skip_control_regs 240 248 … … 355 363 ; 32-bit/16-bit is more complicated as we have three different iret frames. 356 364 ; 357 cmp byte [BS3_ONLY_16BIT(es:) BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM 365 mov al, [BS3_ONLY_16BIT(es:) BS3_DATA16_WRT(g_bBs3CurrentMode)] 366 cmp al, BS3_MODE_RM 358 367 je .iretd_same_cpl_rm 359 368 … … 387 396 mov ecx, [xBX + BS3REGCTX.rcx] 388 397 mov esi, [xBX + BS3REGCTX.rsi] 389 %if TMPL_BITS == 16 ; if SS is 16-bit, we will not be able to restore the high word.398 %if TMPL_BITS == 16 ; if SS is 16-bit, we will not be able to restore the high word. 390 399 mov edi, [xBX + BS3REGCTX.rsp] 391 400 mov di, sp 392 401 mov esp, edi 393 %endif402 %endif 394 403 mov edi, [xBX + BS3REGCTX.rdi] 395 404 mov ebx, [xBX + BS3REGCTX.rbx] … … 405 414 ; Use STOSD/ES:EDI to create the frame. 406 415 mov es, [xBX + BS3REGCTX.ss] 407 movzx esp, word [xBX + BS3REGCTX.rsp] 408 jmp .using_16_bit_stack_pointer 416 mov esi, [xBX + BS3REGCTX.rsp] 417 sub esi, 5*4 418 movzx edi, si 419 jmp .es_edi_is_pointing_to_return_frame_location 409 420 410 421 .iretd_same_cpl: … … 420 431 jnz .using_32_bit_stack_pointer 421 432 .using_16_bit_stack_pointer: 433 mov esi, edi ; save rsp for later. 422 434 movzx edi, di 423 mov esi, [xBX + BS3REGCTX.rsp]424 mov si, di ; save rsp for later.425 435 jmp .es_edi_is_pointing_to_return_frame_location 426 436 .using_32_bit_stack_pointer: -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm
r60527 r60657 44 44 ; 45 45 BS3_PROC_BEGIN_CMN Bs3RegCtxSave, BS3_PBC_HYBRID_SAFE 46 TMPL_ONLY_16BIT_STMTCPU 808646 TONLY16 CPU 8086 47 47 BS3_CALL_CONV_PROLOG 1 48 48 push xBP … … 52 52 push xCX ; xBP - xCB*3: save incoming xCX 53 53 push xDI ; xBP - xCB*4: save incoming xDI 54 BS3_ONLY_16BIT_STMT push es; xBP - xCB*555 BS3_ONLY_16BIT_STMT push ds; xBP - xCB*654 BONLY16 push es ; xBP - xCB*5 55 BONLY16 push ds ; xBP - xCB*6 56 56 57 57 ; … … 153 153 pop dword [xDI + BS3REGCTX.rflags] 154 154 %endif 155 %if TMPL_BITS != 64 156 ; The VM flag is never on the stack, so derive it from the bMode we saved above. 157 test byte [xDI + BS3REGCTX.bMode], BS3_MODE_CODE_V86 158 jz .not_v8086 159 or byte [xDI + BS3REGCTX.rflags + 2], X86_EFL_VM >> 16 160 mov byte [xDI + BS3REGCTX.bCpl], 3 161 .not_v8086: 162 %endif 155 163 156 164 ; 386 segment registers. … … 186 194 187 195 .common_full_no_control_regs: 188 or byte [xDI + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 196 or byte [xDI + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4 197 smsw [xDI + BS3REGCTX.cr0] 189 198 190 199 ; 80286 control registers. 191 200 .common_80286: 192 TMPL_ONLY_16BIT_STMT CPU 286 201 TONLY16 CPU 286 202 %if TMPL_BITS != 64 193 203 cmp cl, BS3_MODE_RM 194 je .common_ancient 204 je .no_str_sldt 205 test cl, BS3_MODE_CODE_V86 206 jnz .no_str_sldt 207 %endif 195 208 str [xDI + BS3REGCTX.tr] 196 209 sldt [xDI + BS3REGCTX.ldtr] 197 210 211 .no_str_sldt: 212 or byte [xDI + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR 213 198 214 ; Common stuff - stuff on the stack, 286 segment registers. 199 215 .common_ancient: 200 TMPL_ONLY_16BIT_STMTCPU 8086216 TONLY16 CPU 8086 201 217 mov xAX, [xBP - xCB*1] 202 218 mov [xDI + BS3REGCTX.rflags], xAX … … 232 248 ; 233 249 .return: 234 BS3_ONLY_16BIT_STMTpop ds235 BS3_ONLY_16BIT_STMTpop es250 BONLY16 pop ds 251 BONLY16 pop es 236 252 pop xDI 237 253 pop xCX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrFormatV.c
r60527 r60657 436 436 } 437 437 State.fFlags |= STR_F_WIDTH; 438 ch = *pszFormat++; 438 439 } 439 440 … … 442 443 */ 443 444 State.cchPrecision = 0; 444 if (RT_C_IS_DIGIT(ch)) 445 { 446 do 447 { 448 State.cchPrecision *= 10; 449 State.cchPrecision = ch - '0'; 445 if (ch == '.') 446 { 447 ch = *pszFormat++; 448 if (RT_C_IS_DIGIT(ch)) 449 { 450 do 451 { 452 State.cchPrecision *= 10; 453 State.cchPrecision = ch - '0'; 454 ch = *pszFormat++; 455 } while (RT_C_IS_DIGIT(ch)); 456 State.fFlags |= STR_F_PRECISION; 457 } 458 else if (ch == '*') 459 { 460 State.cchPrecision = va_arg(va, int); 461 if (State.cchPrecision < 0) 462 State.cchPrecision = 0; 463 State.fFlags |= STR_F_PRECISION; 450 464 ch = *pszFormat++; 451 } while (RT_C_IS_DIGIT(ch)); 452 State.fFlags |= STR_F_PRECISION; 453 } 454 else if (ch == '*') 455 { 456 State.cchPrecision = va_arg(va, int); 457 if (State.cchPrecision < 0) 458 State.cchPrecision = 0; 459 State.fFlags |= STR_F_PRECISION; 465 } 460 466 } 461 467 … … 651 657 State.fFlags &= ~(STR_F_PLUS | STR_F_BLANK); 652 658 State.uBase = 16; 659 break; 660 case 'h': 661 ch = *pszFormat++; 662 if (ch == 'x') 663 { 664 /* Hex dumping. */ 665 uint8_t const BS3_FAR *pbHex = va_arg(va, uint8_t const BS3_FAR *); 666 if (State.cchPrecision < 0) 667 State.cchPrecision = 16; 668 ch = *pszFormat++; 669 if (ch == 's' || ch == 'd') 670 { 671 /* %Rhxd is currently implemented as %Rhxs. */ 672 while (State.cchPrecision-- > 0) 673 { 674 uint8_t b = *pbHex++; 675 State.pfnOutput(g_achBs3HexDigits[b >> 4], State.pvUser); 676 State.pfnOutput(g_achBs3HexDigits[b & 0x0f], State.pvUser); 677 if (State.cchPrecision) 678 State.pfnOutput(' ', State.pvUser); 679 } 680 } 681 } 682 State.uBase = 0; 653 683 break; 654 684 default: -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm
r60527 r60657 103 103 104 104 popfd 105 TMPL_ONLY_64BIT_STMTpop ebx105 TONLY64 pop ebx 106 106 pop ebx 107 TMPL_ONLY_64BIT_STMTpop eax107 TONLY64 pop eax 108 108 pop eax 109 TMPL_ONLY_64BIT_STMTadd sp, 4109 TONLY64 add sp, 4 110 110 ret (TMPL_BITS - 16) / 8 ; Return and pop 2 or 6 bytes of "parameters" (unused return value) 111 111 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16BitV86.asm
r60527 r60657 42 42 BS3_PROC_BEGIN_CMN Bs3SwitchTo16BitV86, BS3_PBC_NEAR 43 43 ; Construct basic v8086 return frame. 44 BS3_ONLY_16BIT_STMTmovzx esp, sp44 BONLY16 movzx esp, sp 45 45 push dword 0 ; +0x20: GS 46 46 push dword 0 ; +0x1c: FS -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm
r60527 r60657 55 55 %else 56 56 push 0 57 TMPL_ONLY_16BIT_STMT pushcs57 TONLY16 push cs 58 58 call Bs3SwitchToRingX 59 59 add xSP, xCB -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm
r60527 r60657 55 55 %else 56 56 push 1 57 TMPL_ONLY_16BIT_STMT pushcs57 TONLY16 push cs 58 58 call Bs3SwitchToRingX 59 59 add xSP, xCB -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm
r60527 r60657 55 55 %else 56 56 push 2 57 TMPL_ONLY_16BIT_STMT pushcs57 TONLY16 push cs 58 58 call Bs3SwitchToRingX 59 59 add xSP, xCB -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm
r60527 r60657 55 55 %else 56 56 push 3 57 TMPL_ONLY_16BIT_STMT pushcs57 TONLY16 push cs 58 58 call Bs3SwitchToRingX 59 59 add xSP, xCB -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestCheckRegCtxEx.c
r60527 r60657 36 36 uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep)) 37 37 { 38 uint16_t cErrorsBefore = Bs3TestSubErrorCount(); 38 uint16_t const cErrorsBefore = Bs3TestSubErrorCount(); 39 uint8_t const fbFlags = pActualCtx->fbFlags | pExpectedCtx->fbFlags; 39 40 40 41 #define CHECK_MEMBER(a_szName, a_szFmt, a_Actual, a_Expected) \ … … 52 53 CHECK_MEMBER("rsi", "%08RX64", pActualCtx->rsi.u, pExpectedCtx->rsi.u); 53 54 CHECK_MEMBER("rdi", "%08RX64", pActualCtx->rdi.u, pExpectedCtx->rdi.u); 54 if ( !(pActualCtx->fbFlags & BS3REG_CTX_F_NO_AMD64) 55 && !(pExpectedCtx->fbFlags & BS3REG_CTX_F_NO_AMD64) ) 55 if (!(fbFlags & BS3REG_CTX_F_NO_AMD64)) 56 56 { 57 57 CHECK_MEMBER("r8", "%08RX64", pActualCtx->r8.u, pExpectedCtx->r8.u); … … 71 71 CHECK_MEMBER("fs", "%04RX16", pActualCtx->fs, pExpectedCtx->fs); 72 72 CHECK_MEMBER("gs", "%04RX16", pActualCtx->gs, pExpectedCtx->gs); 73 CHECK_MEMBER("tr", "%04RX16", pActualCtx->tr, pExpectedCtx->tr); 74 CHECK_MEMBER("ldtr", "%04RX16", pActualCtx->ldtr, pExpectedCtx->ldtr); 73 74 if (!(fbFlags & BS3REG_CTX_F_NO_TR_LDTR)) 75 { 76 CHECK_MEMBER("tr", "%04RX16", pActualCtx->tr, pExpectedCtx->tr); 77 CHECK_MEMBER("ldtr", "%04RX16", pActualCtx->ldtr, pExpectedCtx->ldtr); 78 } 75 79 CHECK_MEMBER("bMode", "%#04x", pActualCtx->bMode, pExpectedCtx->bMode); 76 80 CHECK_MEMBER("bCpl", "%u", pActualCtx->bCpl, pExpectedCtx->bCpl); 77 if (!(pActualCtx->fbFlags & BS3REG_CTX_F_NO_CR)) 81 82 if (!(fbFlags & BS3REG_CTX_F_NO_CR0_IS_MSW)) 83 CHECK_MEMBER("cr0", "%08RX64", pActualCtx->cr0.u, pExpectedCtx->cr0.u); 84 else 85 CHECK_MEMBER("msw", "%08RX16", pActualCtx->cr0.u16, pExpectedCtx->cr0.u16); 86 if (!(fbFlags & BS3REG_CTX_F_NO_CR2_CR3)) 78 87 { 79 CHECK_MEMBER("cr0", "%08RX64", pActualCtx->cr0.u, pExpectedCtx->cr0.u);80 88 CHECK_MEMBER("cr2", "%08RX64", pActualCtx->cr2.u, pExpectedCtx->cr2.u); 81 89 CHECK_MEMBER("cr3", "%08RX64", pActualCtx->cr3.u, pExpectedCtx->cr3.u); 90 } 91 if (!(fbFlags & BS3REG_CTX_F_NO_CR4)) 82 92 CHECK_MEMBER("cr4", "%08RX64", pActualCtx->cr4.u, pExpectedCtx->cr4.u); 83 }84 93 #undef CHECK_MEMBER 85 94 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithStr.asm
r60527 r60657 41 41 push xDX 42 42 push xSI 43 BS3_ONLY_16BIT_STMT pushds43 BONLY16 push ds 44 44 45 45 cmp byte [BS3_DATA16_WRT(g_fbBs3VMMDevTesting)], 0 … … 70 70 71 71 .no_vmmdev: 72 BS3_ONLY_16BIT_STMT popds72 BONLY16 pop ds 73 73 pop xSI 74 74 pop xDX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c
r60527 r60657 29 29 *********************************************************************************************************************************/ 30 30 #include "bs3kit-template-header.h" 31 #if TMPL_BITS != 64 32 # include <VBox/VMMDevTesting.h> 33 # include <iprt/asm-amd64-x86.h> 34 #endif 31 35 32 36 … … 148 152 else if (bOpCode == 0xfb) 149 153 pTrapFrame->Ctx.rflags.u16 |= X86_EFL_IF; 154 /* OUT: byte I/O to VMMDev. */ 155 else if ( bOpCode == 0xee 156 && ((unsigned)(pTrapFrame->Ctx.rdx.u16 - VMMDEV_TESTING_IOPORT_BASE) < (unsigned)VMMDEV_TESTING_IOPORT_COUNT)) 157 ASMOutU8(pTrapFrame->Ctx.rdx.u16, pTrapFrame->Ctx.rax.u8); 158 /* OUT: [d]word I/O to VMMDev. */ 159 else if ( bOpCode == 0xef 160 && ((unsigned)(pTrapFrame->Ctx.rdx.u16 - VMMDEV_TESTING_IOPORT_BASE) < (unsigned)VMMDEV_TESTING_IOPORT_COUNT)) 161 { 162 if (cBitsOpcode != 32) 163 ASMOutU16(pTrapFrame->Ctx.rdx.u16, pTrapFrame->Ctx.rax.u16); 164 else 165 ASMOutU32(pTrapFrame->Ctx.rdx.u16, pTrapFrame->Ctx.rax.u32); 166 } 167 /* IN: byte I/O to VMMDev. */ 168 else if ( bOpCode == 0xec 169 && ((unsigned)(pTrapFrame->Ctx.rdx.u16 - VMMDEV_TESTING_IOPORT_BASE) < (unsigned)VMMDEV_TESTING_IOPORT_COUNT)) 170 pTrapFrame->Ctx.rax.u8 = ASMInU8(pTrapFrame->Ctx.rdx.u16); 171 /* IN: [d]word I/O to VMMDev. */ 172 else if ( bOpCode == 0xed 173 && ((unsigned)(pTrapFrame->Ctx.rdx.u16 - VMMDEV_TESTING_IOPORT_BASE) < (unsigned)VMMDEV_TESTING_IOPORT_COUNT)) 174 { 175 if (cBitsOpcode != 32) 176 pTrapFrame->Ctx.rax.u16 = ASMInU16(pTrapFrame->Ctx.rdx.u16); 177 else 178 pTrapFrame->Ctx.rax.u32 = ASMInU32(pTrapFrame->Ctx.rdx.u32); 179 } 150 180 /* Unexpected. */ 151 181 else -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapPrintFrame.c
r60527 r60657 35 35 { 36 36 #if 1 37 Bs3TestPrintf("Trap %#04x errcd=%#06RX64 at %04x:%016RX64 - test step %d (%#x)\n",37 Bs3TestPrintf("Trap %#04x errcd=%#06RX64 at %04x:%016RX64 (by %04x/%04x) - test step %d (%#x)\n", 38 38 pTrapFrame->bXcpt, 39 39 pTrapFrame->uErrCd, 40 40 pTrapFrame->Ctx.cs, 41 41 pTrapFrame->Ctx.rip.u64, 42 pTrapFrame->uHandlerCs, 43 pTrapFrame->uHandlerSs, 42 44 g_usBs3TestStep, g_usBs3TestStep); 43 45 Bs3RegCtxPrint(&pTrapFrame->Ctx); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm
r60527 r60657 54 54 mov xBP, xSP 55 55 push xBX 56 BS3_ONLY_64BIT_STMTsub xSP, 20h56 BONLY64 sub xSP, 20h 57 57 58 58 ; 59 59 ; Save the current register context. 60 60 ; 61 BS3_ONLY_16BIT_STMTpush ds61 BONLY16 push ds 62 62 BS3_LEA_MOV_WRT_RIP(xAX, BS3_DATA16_WRT(g_Bs3TrapSetJmpCtx)) 63 63 push xAX … … 125 125 ; 126 126 mov xAX, 1 127 BS3_ONLY_64BIT_STMTadd xSP, 20h127 BONLY64 add xSP, 20h 128 128 pop xBX 129 129 pop xBP -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForLM64.asm
r60554 r60657 71 71 push xBP 72 72 mov xBP, xSP 73 BS3_ONLY_16BIT_STMTpush es73 BONLY16 push es 74 74 push sDX 75 75 push sCX … … 102 102 ; Not a problematic addressing mode. 103 103 ; 104 BS3_ONLY_64BIT_STMTsub rsp, 20h104 BONLY64 sub rsp, 20h 105 105 BS3_CALL Bs3PagingInitRootForLM, 0 106 BS3_ONLY_64BIT_STMTadd rsp, 20h106 BONLY64 add rsp, 20h 107 107 %endif 108 108 … … 121 121 pop sCX 122 122 pop sDX 123 BS3_ONLY_16BIT_STMTpop es123 BONLY16 pop es 124 124 leave 125 125 %ifdef BS3_STRICT -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForPAE32.asm
r60554 r60657 60 60 push xBP 61 61 mov xBP, xSP 62 BS3_ONLY_16BIT_STMTpush es62 BONLY16 push es 63 63 push sDX 64 64 push sCX … … 92 92 ; Not a problematic addressing mode. 93 93 ; 94 BS3_ONLY_64BIT_STMTsub rsp, 20h94 BONLY64 sub rsp, 20h 95 95 BS3_CALL Bs3PagingInitRootForPAE, 0 96 BS3_ONLY_64BIT_STMTadd rsp, 20h96 BONLY64 add rsp, 20h 97 97 %endif 98 98 … … 111 111 pop sCX 112 112 pop sDX 113 BS3_ONLY_16BIT_STMTpop es113 BONLY16 pop es 114 114 leave 115 115 ret -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForPP32.asm
r60554 r60657 71 71 push xBP 72 72 mov xBP, xSP 73 BS3_ONLY_16BIT_STMTpush es73 BONLY16 push es 74 74 push sDX 75 75 push sCX … … 103 103 ; Not a problematic addressing mode. 104 104 ; 105 BS3_ONLY_64BIT_STMTsub rsp, 20h105 BONLY64 sub rsp, 20h 106 106 BS3_CALL Bs3PagingInitRootForPP, 0 107 BS3_ONLY_64BIT_STMTadd rsp, 20h107 BONLY64 add rsp, 20h 108 108 %endif 109 109 … … 122 122 pop sCX 123 123 pop sDX 124 BS3_ONLY_16BIT_STMTpop es124 BONLY16 pop es 125 125 leave 126 126 %ifdef BS3_STRICT -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm
r60557 r60657 181 181 and ax, ~X86_CR0_PE 182 182 mov cr0, eax 183 hlt184 183 jmp BS3_SEL_TEXT16:.resume 185 184 %endif … … 323 322 %if BS3_MODE_IS_64BIT_SYS(TMPL_MODE) 324 323 pop ecx 325 TMPL_ONLY_64BIT_STMT popeax324 TONLY64 pop eax 326 325 pop edx 327 TMPL_ONLY_64BIT_STMT popeax326 TONLY64 pop eax 328 327 %endif 329 328 popfd 330 TMPL_ONLY_64BIT_STMT popeax329 TONLY64 pop eax 331 330 pop ebx 332 TMPL_ONLY_64BIT_STMT popeax331 TONLY64 pop eax 333 332 pop eax 334 TMPL_ONLY_64BIT_STMT addsp, 4333 TONLY64 add sp, 4 335 334 retn (TMPL_BITS - 16) / 8 336 335 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r60557 r60657 319 319 320 320 ; Convert the register context from whatever it is to ring-0. 321 BS3_ONLY_64BIT_STMTsub rsp, 10h321 BONLY64 sub rsp, 10h 322 322 mov ax, VAR_CALLER_AX 323 323 sub ax, BS3_SYSCALL_TO_RING0 324 324 push xAX 325 BS3_ONLY_16BIT_STMTpush ss325 BONLY16 push ss 326 326 push xBX 327 327 BS3_CALL Bs3RegCtxConvertToRingX, 2 … … 330 330 ; Restore the register context (does not return). 331 331 pop xBX ; restore saved pointer. 332 BS3_ONLY_64BIT_STMTsub rsp, 18h333 BS3_ONLY_16BIT_STMTpush ss332 BONLY64 sub rsp, 18h 333 BONLY16 push ss 334 334 push xBX 335 335 BS3_CALL Bs3RegCtxRestore, 1 … … 342 342 .restore_ctx: 343 343 call .convert_ptr_arg_to_cx_xSI 344 BS3_ONLY_64BIT_STMTsub rsp, 10h344 BONLY64 sub rsp, 10h 345 345 mov xDX, VAR_CALLER_DX 346 346 push xDX 347 BS3_ONLY_16BIT_STMTpush cx347 BONLY16 push cx 348 348 push xSI 349 349 BS3_CALL Bs3RegCtxRestore, 2 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk
r60585 r60657 25 25 # 26 26 27 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelFlatDataToProtFar16,4) 28 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelFlatDataToRealMode,4) 29 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelProtFar16DataToFlat,4) 30 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelProtFar16DataToRealMode,4) 31 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToFlat,4) 32 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToProtFar16,4) 33 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelFar32ToFlat32NoClobber,6) 34 $(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3RegCtxSaveEx,8) 27 35 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestCheckRegCtxEx) 28 36 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrCpy) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
r60585 r60657 36 36 #define Bs3MemAlloc BS3_CMN_MANGLER(Bs3MemAlloc) 37 37 #define Bs3MemAllocZ BS3_CMN_MANGLER(Bs3MemAllocZ) 38 #define Bs3MemChr BS3_CMN_MANGLER(Bs3MemChr) 38 39 #define Bs3MemCpy BS3_CMN_MANGLER(Bs3MemCpy) 39 40 #define Bs3MemFree BS3_CMN_MANGLER(Bs3MemFree) 40 41 #define Bs3MemMove BS3_CMN_MANGLER(Bs3MemMove) 41 42 #define Bs3MemPCpy BS3_CMN_MANGLER(Bs3MemPCpy) 43 #define Bs3MemSet BS3_CMN_MANGLER(Bs3MemSet) 42 44 #define Bs3MemZero BS3_CMN_MANGLER(Bs3MemZero) 43 45 #define Bs3PagingInitRootForLM BS3_CMN_MANGLER(Bs3PagingInitRootForLM) … … 59 61 #define Bs3RegCtxRestore BS3_CMN_MANGLER(Bs3RegCtxRestore) 60 62 #define Bs3RegCtxSave BS3_CMN_MANGLER(Bs3RegCtxSave) 63 #define Bs3RegCtxSaveEx BS3_CMN_MANGLER(Bs3RegCtxSaveEx) 61 64 #define Bs3SelFar32ToFlat32 BS3_CMN_MANGLER(Bs3SelFar32ToFlat32) 65 #define Bs3SelFar32ToFlat32NoClobber BS3_CMN_MANGLER(Bs3SelFar32ToFlat32NoClobber) 62 66 #define Bs3SelFlatCodeToProtFar16 BS3_CMN_MANGLER(Bs3SelFlatCodeToProtFar16) 63 67 #define Bs3SelFlatCodeToRealMode BS3_CMN_MANGLER(Bs3SelFlatCodeToRealMode) 68 #define Bs3SelFlatDataToProtFar16 BS3_CMN_MANGLER(Bs3SelFlatDataToProtFar16) 69 #define Bs3SelFlatDataToRealMode BS3_CMN_MANGLER(Bs3SelFlatDataToRealMode) 70 #define Bs3SelProtFar16DataToFlat BS3_CMN_MANGLER(Bs3SelProtFar16DataToFlat) 71 #define Bs3SelProtFar16DataToRealMode BS3_CMN_MANGLER(Bs3SelProtFar16DataToRealMode) 64 72 #define Bs3SelProtFar32ToFlat32 BS3_CMN_MANGLER(Bs3SelProtFar32ToFlat32) 65 73 #define Bs3SelProtModeCodeToRealMode BS3_CMN_MANGLER(Bs3SelProtModeCodeToRealMode) 66 74 #define Bs3SelRealModeCodeToProtMode BS3_CMN_MANGLER(Bs3SelRealModeCodeToProtMode) 75 #define Bs3SelRealModeDataToFlat BS3_CMN_MANGLER(Bs3SelRealModeDataToFlat) 76 #define Bs3SelRealModeDataToProtFar16 BS3_CMN_MANGLER(Bs3SelRealModeDataToProtFar16) 67 77 #define Bs3Shutdown BS3_CMN_MANGLER(Bs3Shutdown) 68 78 #define Bs3SlabAlloc BS3_CMN_MANGLER(Bs3SlabAlloc) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
r60585 r60657 36 36 #undef Bs3MemAlloc 37 37 #undef Bs3MemAllocZ 38 #undef Bs3MemChr 38 39 #undef Bs3MemCpy 39 40 #undef Bs3MemFree 40 41 #undef Bs3MemMove 41 42 #undef Bs3MemPCpy 43 #undef Bs3MemSet 42 44 #undef Bs3MemZero 43 45 #undef Bs3PagingInitRootForLM … … 59 61 #undef Bs3RegCtxRestore 60 62 #undef Bs3RegCtxSave 63 #undef Bs3RegCtxSaveEx 61 64 #undef Bs3SelFar32ToFlat32 65 #undef Bs3SelFar32ToFlat32NoClobber 62 66 #undef Bs3SelFlatCodeToProtFar16 63 67 #undef Bs3SelFlatCodeToRealMode 68 #undef Bs3SelFlatDataToProtFar16 69 #undef Bs3SelFlatDataToRealMode 70 #undef Bs3SelProtFar16DataToFlat 71 #undef Bs3SelProtFar16DataToRealMode 64 72 #undef Bs3SelProtFar32ToFlat32 65 73 #undef Bs3SelProtModeCodeToRealMode 66 74 #undef Bs3SelRealModeCodeToProtMode 75 #undef Bs3SelRealModeDataToFlat 76 #undef Bs3SelRealModeDataToProtFar16 67 77 #undef Bs3Shutdown 68 78 #undef Bs3SlabAlloc -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac
r60554 r60657 124 124 %undef sSI 125 125 126 %unmacro T MPL_ONLY_16BIT_STMT1+127 %unmacro T MPL_ONLY_32BIT_STMT1+128 %unmacro T MPL_ONLY_64BIT_STMT1+126 %unmacro TONLY16 1+ 127 %unmacro TONLY32 1+ 128 %unmacro TONLY64 1+ 129 129 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
r60554 r60657 438 438 %endif 439 439 440 ;; @def TMPL_ONLY_16BIT_STMT 441 ; Version of BS3_ONLY_16BIT_STMT that follows the code template. 440 ;; @def TONLY16 441 ; Version of BONLY16 that follows the code template. 442 ; Like BONLY16 this normally goes in column 1. 442 443 %if TMPL_BITS == 16 443 %macro T MPL_ONLY_16BIT_STMT1+444 %macro TONLY16 1+ 444 445 %1 445 446 %endmacro 446 447 %else 447 %macro TMPL_ONLY_16BIT_STMT 1+ 448 %endmacro 449 %endif 450 451 ;; @def TMPL_ONLY_32BIT_STMT 452 ; Version of BS3_ONLY_32BIT_STMT that follows the code template. 448 %macro TONLY16 1+ 449 %endmacro 450 %endif 451 452 ;; @def TONLY32 453 ; Version of BONLY32 that follows the code template. 454 ; Like BONLY32 this normally goes in column 1. 453 455 %if TMPL_BITS == 32 454 %macro T MPL_ONLY_32BIT_STMT1+456 %macro TONLY32 1+ 455 457 %1 456 458 %endmacro 457 459 %else 458 %macro TMPL_ONLY_32BIT_STMT 1+ 459 %endmacro 460 %endif 461 462 ;; @def TMPL_ONLY_64BIT_STMT 463 ; Version of BS3_ONLY_64BIT_STMT that follows the code template. 460 %macro TONLY32 1+ 461 %endmacro 462 %endif 463 464 ;; @def TONLY64 465 ; Version of BONLY64 that follows the code template. 466 ; Like BONLY64 this normally goes in column 1. 464 467 %if TMPL_BITS == 64 465 %macro T MPL_ONLY_64BIT_STMT1+468 %macro TONLY64 1+ 466 469 %1 467 470 %endmacro 468 471 %else 469 %macro T MPL_ONLY_64BIT_STMT1+472 %macro TONLY64 1+ 470 473 %endmacro 471 474 %endif -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r60609 r60657 911 911 /** The BS3DATA16/BS3KIT_GRPNM_DATA16 GDT entry. */ 912 912 extern X86DESC BS3_FAR_DATA Bs3Gdte_DATA16; 913 913 914 /** Free GDTes, part \#4. */ 914 915 915 extern X86DESC BS3_FAR_DATA Bs3GdteFreePart4[211]; 916 916 917 extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage08; /**< GDT entry 8 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_08 */ 917 918 extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage07; /**< GDT entry 7 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_07 */ … … 1623 1624 BS3_CMN_PROTO_NOSB(void, Bs3MemZero,(void BS3_FAR *pvDst, size_t cbDst)); 1624 1625 1626 /** 1627 * CRT style memset. 1628 * 1629 * @param pvDst The buffer to be fill. 1630 * @param bFiller The filler byte. 1631 * @param cbDst The number of bytes to fill. 1632 */ 1633 BS3_CMN_PROTO_NOSB(void, Bs3MemSet,(void BS3_FAR *pvDst, uint8_t bFiller, size_t cbDst)); 1634 1635 /** 1636 * CRT style memchr. 1637 * 1638 * @param pvHaystack The memory to scan for @a bNeedle. 1639 * @param bNeedle The byte to search for. 1640 * @param cbHaystack The amount of memory to search. 1641 */ 1642 BS3_CMN_PROTO_NOSB(void BS3_FAR *, Bs3MemChr,(void const BS3_FAR *pvHaystack, uint8_t bNeedle, size_t cbHaystack)); 1643 1625 1644 1626 1645 BS3_CMN_PROTO_STUB(void, Bs3UInt64Div,(RTUINT64U uDividend, RTUINT64U uDivisor, RTUINT64U BS3_FAR *paQuotientReminder)); … … 1647 1666 1648 1667 /** 1668 * Wrapper around Bs3SelFar32ToFlat32 that makes it easier to use in tight 1669 * assembly spots. 1670 * 1671 * @returns 32-bit flat address. 1672 * @param off The segment offset. 1673 * @param uSel The current mode segment selector. 1674 * @remarks All register are preserved, except return. 1675 * @remarks No 20h scratch space required in 64-bit mode. 1676 */ 1677 BS3_CMN_PROTO_FARSTUB(6, uint32_t, Bs3SelFar32ToFlat32NoClobber,(uint32_t off, uint16_t uSel)); 1678 1679 /** 1649 1680 * Converts a real mode code segment to a protected mode code segment selector. 1650 1681 * 1651 1682 * @returns protected mode segment selector. 1652 1683 * @param uRealSeg Real mode code segment. 1684 * @remarks All register are preserved, except return and parameter. 1653 1685 */ 1654 1686 BS3_CMN_PROTO_NOSB(uint16_t, Bs3SelRealModeCodeToProtMode,(uint16_t uRealSeg)); … … 1659 1691 * @returns protected mode segment selector. 1660 1692 * @param uProtSel Real mode code segment. 1693 * @remarks All register are preserved, except return and parameter. 1661 1694 */ 1662 1695 BS3_CMN_PROTO_NOSB(uint16_t, Bs3SelProtModeCodeToRealMode,(uint16_t uProtSel)); … … 1665 1698 * Converts a flat code address to a real mode segment and offset. 1666 1699 * 1667 * @returns Far real mode address (high 16-bit is segment, low is offset) 1700 * @returns Far real mode address (high 16-bit is segment, low is offset). 1668 1701 * @param uFlatAddr Flat code address. 1702 * @remarks All register are preserved, except return and parameter. 1669 1703 */ 1670 1704 BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatCodeToRealMode,(uint32_t uFlatAddr)); … … 1676 1710 * low is segment offset). 1677 1711 * @param uFlatAddr Flat code address. 1712 * @remarks All register are preserved, except return and parameter. 1678 1713 */ 1679 1714 BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatCodeToProtFar16,(uint32_t uFlatAddr)); 1715 1716 /** 1717 * Converts a flat data address to a real mode segment and offset. 1718 * 1719 * @returns Far real mode address (high 16-bit is segment, low is offset) 1720 * @param uFlatAddr Flat code address. 1721 * @remarks All register are preserved, except return. 1722 * @remarks No 20h scratch space required in 64-bit mode. 1723 */ 1724 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelFlatDataToRealMode,(uint32_t uFlatAddr)); 1725 1726 /** 1727 * Converts a flat data address to a real mode segment and offset. 1728 * 1729 * @returns Far 16-bit protected mode address (high 16-bit is segment selector, 1730 * low is segment offset). 1731 * @param uFlatAddr Flat code address. 1732 * @remarks All register are preserved, except return. 1733 * @remarks No 20h scratch space required in 64-bit mode. 1734 */ 1735 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelFlatDataToProtFar16,(uint32_t uFlatAddr)); 1736 1737 /** 1738 * Converts a far 16:16 data address to a real mode segment and offset. 1739 * 1740 * @returns Far real mode address (high 16-bit is segment, low is offset) 1741 * @param uFar1616 Far 16-bit protected mode address (high 16-bit is 1742 * segment selector, low is segment offset). 1743 * @remarks All register are preserved, except return. 1744 * @remarks No 20h scratch space required in 64-bit mode. 1745 */ 1746 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelProtFar16DataToRealMode,(uint32_t uFar1616)); 1747 1748 /** 1749 * Converts a far 16:16 real mode address to a 16-bit protected mode address. 1750 * 1751 * @returns Far real mode address (high 16-bit is segment, low is offset) 1752 * @param uFar1616 Far real mode address (high 16-bit is segment, low 1753 * is offset). 1754 * @remarks All register are preserved, except return. 1755 * @remarks No 20h scratch space required in 64-bit mode. 1756 */ 1757 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeDataToProtFar16,(uint32_t uFar1616)); 1758 1759 /** 1760 * Converts a far 16:16 data address to a flat 32-bit address. 1761 * 1762 * @returns 32-bit flat address. 1763 * @param uFar1616 Far 16-bit protected mode address (high 16-bit is 1764 * segment selector, low is segment offset). 1765 * @remarks All register are preserved, except return. 1766 * @remarks No 20h scratch space required in 64-bit mode. 1767 */ 1768 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelProtFar16DataToFlat,(uint32_t uFar1616)); 1769 1770 /** 1771 * Converts a far 16:16 real mode address to a flat address. 1772 * 1773 * @returns 32-bit flat address. 1774 * @param uFar1616 Far real mode address (high 16-bit is segment, low 1775 * is offset). 1776 * @remarks All register are preserved, except return. 1777 * @remarks No 20h scratch space required in 64-bit mode. 1778 */ 1779 BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeDataToFlat,(uint32_t uFar1616)); 1680 1780 1681 1781 /** … … 2094 2194 /** @name BS3REG_CTX_F_XXX - BS3REGCTX::fbFlags masks. 2095 2195 * @{ */ 2096 /** The context doesn't have valid values for the CRx fields. 2097 * This is usually because it wasn't created with CPL=0. */ 2098 #define BS3REG_CTX_F_NO_CR UINT8_C(0x01) 2099 /** The CPU is too old for CR4, so no CR4 in this context. */ 2100 #define BS3REG_CTX_F_NO_CR4 UINT8_C(0x02) 2196 /** The CR0 is MSW (only low 16-bit). */ 2197 #define BS3REG_CTX_F_NO_CR0_IS_MSW UINT8_C(0x01) 2198 /** No CR2 and CR3 values. Not in CPL 0 or CPU too old for CR2 & CR3. */ 2199 #define BS3REG_CTX_F_NO_CR2_CR3 UINT8_C(0x02) 2200 /** No CR4 value. The CPU is too old for CR4. */ 2201 #define BS3REG_CTX_F_NO_CR4 UINT8_C(0x04) 2202 /** No TR and LDTR values. Context gathered in real mode or v8086 mode. */ 2203 #define BS3REG_CTX_F_NO_TR_LDTR UINT8_C(0x08) 2101 2204 /** The context doesn't have valid values for AMD64 GPR extensions. */ 2102 #define BS3REG_CTX_F_NO_AMD64 UINT8_C(0x 04)2205 #define BS3REG_CTX_F_NO_AMD64 UINT8_C(0x10) 2103 2206 /** @} */ 2104 2207 … … 2109 2212 */ 2110 2213 BS3_CMN_PROTO_NOSB(void, Bs3RegCtxSave,(PCBS3REGCTX pRegCtx)); 2214 2215 /** 2216 * Switch to the specified CPU bitcount, reserve additional stack and save the 2217 * CPU context. 2218 * 2219 * This is for writing more flexible test drivers that can test more than the 2220 * CPU bitcount (16-bit, 32-bit, 64-bit, and virtual 8086) of the driver itself. 2221 * For instance a 32-bit driver can do V86 and 16-bit testing, thus saving more 2222 * precious and problematic 16-bit code. 2223 * 2224 * @param pRegCtx Where to store the register context. 2225 * @param bBitMode Bit mode to switch to, BS3_MODE_CODE_XXX. Only 2226 * BS3_MODE_CODE_MASK is used, other bits are ignored 2227 * to make it possible to pass a full mode value. 2228 * @param cbExtraStack Number of bytes of additional stack to allocate. 2229 */ 2230 BS3_CMN_PROTO_FARSTUB(8, void, Bs3RegCtxSaveEx,(PCBS3REGCTX pRegCtx, uint8_t bBitMode, uint16_t cbExtraStack)); 2111 2231 2112 2232 /** … … 2313 2433 2314 2434 /** 2315 * Sets a trap handler (C/C++/assembly) for the current bit ness.2435 * Sets a trap handler (C/C++/assembly) for the current bitcount. 2316 2436 * 2317 2437 * When using a 32-bit IDT, only #Bs3TrapSetHandler_c32 will have any effect. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r60609 r60657 272 272 ;; 273 273 ; For instruction that should only be emitted in 16-bit mode. Follows BS3_SET_BITS. 274 %macro BS3_ONLY_16BIT_STMT 1+ 274 ; BONLY16 normally goes in column 1. 275 %macro BONLY16 1+ 275 276 %if __BITS__ == 16 276 277 %1 … … 280 281 ;; 281 282 ; For instruction that should only be emitted in 32-bit mode. Follows BS3_SET_BITS. 282 %macro BS3_ONLY_32BIT_STMT 1+ 283 ; BONLY32 normally goes in column 1. 284 %macro BONLY32 1+ 283 285 %if __BITS__ == 32 284 286 %1 … … 288 290 ;; 289 291 ; For instruction that should only be emitted in 64-bit mode. Follows BS3_SET_BITS. 290 %macro BS3_ONLY_64BIT_STMT 1+ 292 ; BONLY64 normally goes in column 1. 293 %macro BONLY64 1+ 291 294 %if __BITS__ == 64 292 295 %1 … … 1405 1408 ;; @name BS3REG_CTX_F_XXX - BS3REGCTX::fbFlags masks. 1406 1409 ; @{ 1407 ;; The context doesn't have valid values for the CRx fields. 1408 ; This is usually because it wasn't created with CPL=0. 1409 %define BS3REG_CTX_F_NO_CR 0x01 1410 ;; The CPU is too old for CR4, so no CR4 in this context. 1411 %define BS3REG_CTX_F_NO_CR4 0x02 1410 ;; The CR0 is MSW (only low 16-bit). */ 1411 %define BS3REG_CTX_F_NO_CR0_IS_MSW 0x01 1412 ;; No CR2 and CR3 values. Not in CPL 0 or CPU too old for CR2 & CR3. 1413 %define BS3REG_CTX_F_NO_CR2_CR3 0x02 1414 ;; No CR4 value. The CPU is too old for CR4. 1415 %define BS3REG_CTX_F_NO_CR4 0x04 1416 ;; No TR and LDTR values. Context gathered in real mode or v8086 mode. 1417 %define BS3REG_CTX_F_NO_TR_LDTR 0x08 1412 1418 ;; The context doesn't have valid values for AMD64 GPR extensions. 1413 %define BS3REG_CTX_F_NO_AMD64 0x 041419 %define BS3REG_CTX_F_NO_AMD64 0x10 1414 1420 ;; @} 1415 1421
Note:
See TracChangeset
for help on using the changeset viewer.

