/** * Equivalent to rtTestSubCleanup + rtTestSubTestReport. */ BS3_DECL(void) bs3TestSubCleanup(void) { if (g_szBs3SubTest[0] != '\0') { if (!g_fbBs3SubTestReported) { size_t cch; uint16_t cErrors = g_cusBs3TestErrors - g_cusBs3SubTestAtErrors; /* Tell VMMDev. */ bs3TestSendCmdWithU32(VMMDEV_TESTING_CMD_SUB_DONE, cErrors); /* Print result to the console. */ Bs3PrintStr(g_szBs3SubTest); Bs3PrintChr(':'); cch = Bs3StrLen(g_szBs3SubTest); do Bs3PrintChr(' '); while (cch++ < 49); if (!cErrors) Bs3PrintStr(!g_fbBs3SubTestSkipped ? "PASSED\n" : "SKIPPED\n"); else { g_cusBs3SubTestsFailed++; Bs3Printf("FAILED (%u errors)\n", g_szBs3SubTest, cErrors); } } /* Reset the sub-test. */ g_fbBs3SubTestReported = true; g_fbBs3SubTestSkipped = false; g_szBs3SubTest[0] = '\0'; } }
/** * @callback_method_impl{FNBS3STRFORMATOUTPUT, * Used by Bs3TestFailedV and Bs3TestSkippedV.} */ BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser) { PBS3TESTFAILEDBUF pBuf = (PBS3TESTFAILEDBUF)pvUser; /* * VMMDev first. We postpone newline processing here so we can strip one * trailing newline. */ if (g_fbBs3VMMDevTesting) { if (pBuf->fNewLine && ch != '\0') ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\n'); pBuf->fNewLine = ch == '\n'; if (ch != '\n') ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch); } /* * Console next. */ if (ch != '\0') { BS3_ASSERT(pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf)); pBuf->achBuf[pBuf->cchBuf++] = ch; /* Whether to flush the buffer. We do line flushing here to avoid dropping too much info when the formatter crashes on bad input. */ if ( pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf) && ch != '\n') { pBuf->fNewLine = false; return 1; } pBuf->fNewLine = '\n'; } /* Try fit missing newline into the buffer. */ else if (!pBuf->fNewLine && pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf)) { pBuf->fNewLine = true; pBuf->achBuf[pBuf->cchBuf++] = '\n'; } BS3_ASSERT(pBuf->cchBuf <= RT_ELEMENTS(pBuf->achBuf)); Bs3PrintStrN(&pBuf->achBuf[0], pBuf->cchBuf); pBuf->cchBuf = 0; /* In case we failed to add trailing new line, print one separately. */ if (!pBuf->fNewLine) Bs3PrintChr('\n'); return ch != '\0'; }
static void bs3TrapDefaultHandlerV8086Syscall(PBS3TRAPFRAME pTrapFrame) { /* Minimal syscall. */ if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_PRINT_CHR) Bs3PrintChr(pTrapFrame->Ctx.rcx.u8); else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_PRINT_STR) Bs3PrintStrN(Bs3XptrFlatToCurrent(((uint32_t)pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16); else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_RESTORE_CTX) Bs3RegCtxRestore(Bs3XptrFlatToCurrent(((uint32_t)pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16); else if ( pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING0 || pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING1 || pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING2 || pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING3) { Bs3RegCtxConvertToRingX(&pTrapFrame->Ctx, pTrapFrame->Ctx.rax.u16 - BS3_SYSCALL_TO_RING0); } else Bs3Panic(); }