Changeset 61389 in vbox
- Timestamp:
- Jun 2, 2016 12:04:34 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107703
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 8 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.c
r61385 r61389 126 126 X86FXSTATE BS3_FAR *pChecking = pExpected + 1; 127 127 uint32_t iLoop; 128 uint32_t uStartTick; 128 129 bool fMmioReadback; 129 130 bool fReadBackError = false; 130 131 BS3PTRUNION MmioReg; 132 131 133 132 134 # undef CHECK_STATE … … 138 140 Bs3TestFailedF("State differs after " #a_Instr " (write) in loop #%RU32\n", iLoop); \ 139 141 bs3FpuState1_Diff(pExpected, pChecking); \ 142 Bs3PitDisable(); \ 140 143 return 1; \ 141 144 } \ … … 146 149 */ 147 150 148 /* First, figure out which MMIO region we'll be using so we can correctly initialize FPUDS. */ 151 /* Make this code executable in raw-mode. A bit tricky. */ 152 ASMSetCR0(ASMGetCR0() | X86_CR0_WP); 153 Bs3PitSetupAndEnablePeriodTimer(20); 154 ASMIntEnable(); 155 # if ARCH_BITS != 64 156 ASMHalt(); 157 # endif 158 159 /* Figure out which MMIO region we'll be using so we can correctly initialize FPUDS. */ 149 160 # if BS3_MODE_IS_RM_OR_V86(TMPL_MODE) 150 161 MmioReg.pv = BS3_FP_MAKE(0xffff, VMMDEV_TESTING_MMIO_BASE - _1M + 16); … … 166 177 } 167 178 168 /* Second, make 100% sure we don't trap accessing the FPU state and that we can use fxsave/fxrstor. */179 /* Make 100% sure we don't trap accessing the FPU state and that we can use fxsave/fxrstor. */ 169 180 g_usBs3TestStep = 1; 170 181 ASMSetCR0((ASMGetCR0() & ~(X86_CR0_TS | X86_CR0_EM)) | X86_CR0_MP); 171 182 ASMSetCR4(ASMGetCR4() | X86_CR4_OSFXSR /*| X86_CR4_OSXMMEEXCPT*/); 172 183 173 /* Third, come up with a distinct state. We do that from assembly (will do FPU in R0/RC). */184 /* Come up with a distinct state. We do that from assembly (will do FPU in R0/RC). */ 174 185 g_usBs3TestStep = 2; 175 186 Bs3MemSet(abBuf, 0x42, sizeof(abBuf)); 176 187 TMPL_NM(bs3FpuState1_InitState)(pExpected, MmioReg.pb); 188 177 189 178 190 /* … … 180 192 */ 181 193 g_usBs3TestStep = 3; 182 for (iLoop = 0; iLoop < _1M; iLoop++) /** @todo adjust counter. will hardcode for now and do timers later so day... */ 194 uStartTick = g_cBs3PitTicks; 195 for (iLoop = 0; iLoop < _16M; iLoop++) 196 { 183 197 CHECK_STATE(nop); 198 if ( (iLoop & 0xffff) == 0xffff 199 && g_cBs3PitTicks - uStartTick >= 20 * 20) /* 20 seconds*/ 200 break; 201 } 184 202 185 203 /* … … 190 208 */ 191 209 g_usBs3TestStep = 4; 192 for (iLoop = 0; iLoop < _128K; iLoop++) /** @todo adjust counter. will hardcode for now and do timers later so day... */ 210 uStartTick = g_cBs3PitTicks; 211 for (iLoop = 0; iLoop < _1M; iLoop++) 193 212 { 194 213 unsigned off; … … 269 288 # endif 270 289 CHECK_STATE(FMUL); 290 291 /* check for timeout every now an then. */ 292 if ( (iLoop & 0xfff) == 0xfff 293 && g_cBs3PitTicks - uStartTick >= 20 * 20) /* 20 seconds*/ 294 break; 271 295 } 272 296 297 Bs3PitDisable(); 273 298 return 0; 274 299 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r60774 r61389 90 90 bs3-cmn-PagingProtect.c \ 91 91 bs3-cmn-PagingSetupCanonicalTraps.c \ 92 bs3-cmn-pic-data.c \ 92 93 bs3-cmn-PicMaskAll.c \ 94 bs3-cmn-PicUpdateMask.c \ 95 bs3-cmn-PicSetup.c \ 96 bs3-cmn-pit.c \ 97 bs3-cmn-PitIrqHandler.c \ 93 98 bs3-cmn-RegCtxRestore.asm \ 94 99 bs3-cmn-RegCtxConvertToRingX.c \ … … 158 163 bs3-cmn-Trap64SetGate.c \ 159 164 bs3-cmn-TrapDefaultHandler.c \ 165 bs3-cmn-TrapHandlersData.asm \ 160 166 bs3-cmn-TrapPrintFrame.c \ 161 167 bs3-cmn-TrapSetHandler.c \ 168 bs3-cmn-TrapSetHandlerEx.c \ 162 169 bs3-cmn-TrapSetJmp.asm \ 163 170 bs3-cmn-TrapSetJmpAndRestore.c \ … … 210 217 bs3-c16-Trap16Generic.asm \ 211 218 bs3-c16-TrapRmV86Generic.asm \ 212 bs3-c16-Trap16RmV86Data.asm \213 219 bs3-c16-TrapRmV86Data.c \ 214 220 bs3-c16-CreateHybridFarRet.asm -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r60657 r61389 40 40 BS3_EXTERN_DATA16 g_bBs3CurrentMode 41 41 BS3_EXTERN_DATA16 g_uBs3CpuDetected 42 BS3_EXTERN_DATA16 g_apfnBs3TrapHandlers_c32 42 43 BS3_EXTERN_SYSTEM16 Bs3Gdt 43 44 TMPL_BEGIN_TEXT … … 58 59 dd Bs3Trap32DoubleFaultHandler wrt FLAT 59 60 60 BS3_BEGIN_DATA32 61 ;; Pointer C trap handlers. 62 BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024 63 resd 256 64 65 61 62 TMPL_BEGIN_TEXT 66 63 67 64 ;; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c64-Trap64Generic.asm
r60657 r61389 39 39 ;********************************************************************************************************************************* 40 40 BS3_EXTERN_DATA16 g_bBs3CurrentMode 41 BS3_EXTERN_DATA16 g_apfnBs3TrapHandlers_c64 41 42 TMPL_BEGIN_TEXT 42 43 BS3_EXTERN_CMN Bs3TrapDefaultHandler … … 53 54 dd Bs3Trap64GenericEntries wrt FLAT 54 55 55 BS3_BEGIN_DATA64 56 ;; Pointer C trap handlers. 57 BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c64, 2048 58 resq 256 59 60 56 57 TMPL_BEGIN_TEXT 61 58 62 59 ;; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c
r60749 r61389 69 69 } 70 70 ASMIntDisable(); 71 Bs3Pic MaskAll();71 Bs3PicSetup(); 72 72 73 73 /* -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-system-data.asm
r60724 r61389 58 58 59 59 BS3_GLOBAL_DATA Bs3Gdte_Ldt, 16 ; Entry 010h 60 dw BS3_DATA_NM(Bs3LdtEnd) - BS3_DATA_NM(Bs3Ldt) 60 dw BS3_DATA_NM(Bs3LdtEnd) - BS3_DATA_NM(Bs3Ldt) - 1 61 61 dw BS3_SYSTEM16_BASE_LOW(Bs3Ldt) 62 62 db BS3_SYSTEM16_BASE_16_23 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk
r60774 r61389 53 53 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrPrintf) 54 54 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrPrintfV) 55 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PicUpdateMask) 55 56 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabFree) 56 57 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestSubErrorCount) … … 72 73 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageFree) 73 74 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PicMaskAll) 75 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PicSetup) 76 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PitDisable) 77 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PitSetupAndEnablePeriodTimer) 74 78 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PrintStr) 75 79 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3RegCtxConvertToRingX) … … 112 116 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86InitEx) 113 117 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86SetGate) 118 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandlerEx) 114 119 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetJmpAndRestore) 115 120 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapUnsetJmp) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
r60774 r61389 60 60 #define Bs3Panic BS3_CMN_MANGLER(Bs3Panic) 61 61 #define Bs3PicMaskAll BS3_CMN_MANGLER(Bs3PicMaskAll) 62 #define Bs3PicSetup BS3_CMN_MANGLER(Bs3PicSetup) 63 #define Bs3PicUpdateMask BS3_CMN_MANGLER(Bs3PicUpdateMask) 64 #define Bs3PitDisable BS3_CMN_MANGLER(Bs3PitDisable) 65 #define Bs3PitSetupAndEnablePeriodTimer BS3_CMN_MANGLER(Bs3PitSetupAndEnablePeriodTimer) 62 66 #define Bs3PrintChr BS3_CMN_MANGLER(Bs3PrintChr) 63 67 #define Bs3Printf BS3_CMN_MANGLER(Bs3Printf) … … 139 143 #define Bs3TrapRmV86SetGate BS3_CMN_MANGLER(Bs3TrapRmV86SetGate) 140 144 #define Bs3TrapSetHandler BS3_CMN_MANGLER(Bs3TrapSetHandler) 145 #define Bs3TrapSetHandlerEx BS3_CMN_MANGLER(Bs3TrapSetHandlerEx) 141 146 #define Bs3TrapSetJmp BS3_CMN_MANGLER(Bs3TrapSetJmp) 142 147 #define Bs3TrapSetJmpAndRestore BS3_CMN_MANGLER(Bs3TrapSetJmpAndRestore) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
r60774 r61389 60 60 #undef Bs3Panic 61 61 #undef Bs3PicMaskAll 62 #undef Bs3PicSetup 63 #undef Bs3PicUpdateMask 64 #undef Bs3PitDisable 65 #undef Bs3PitSetupAndEnablePeriodTimer 62 66 #undef Bs3PrintChr 63 67 #undef Bs3Printf … … 139 143 #undef Bs3TrapRmV86SetGate 140 144 #undef Bs3TrapSetHandler 145 #undef Bs3TrapSetHandlerEx 141 146 #undef Bs3TrapSetJmp 142 147 #undef Bs3TrapSetJmpAndRestore -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r61385 r61389 628 628 * Declares a BS3Kit callback function (typically static). 629 629 * 630 * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.631 *632 630 * @param a_Type The return type. */ 633 631 #ifdef IN_BS3KIT … … 637 635 #endif 638 636 637 /** @def BS3_DECL_NEAR_CALLBACK 638 * Declares a near BS3Kit callback function (typically static). 639 * 640 * 16-bit users must be in CGROUP16! 641 * 642 * @param a_Type The return type. */ 643 #ifdef IN_BS3KIT 644 # define BS3_DECL_NEAR_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL 645 #else 646 # define BS3_DECL_NEAR_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL 647 #endif 648 639 649 /** 640 650 * Constructs a common name. … … 685 695 * \#define Bs3Gdt BS3_DATA_NM(Bs3Gdt) 686 696 * extern X86DESC BS3_FAR_DATA Bs3Gdt 687 * @endcode697 f * @endcode 688 698 * 689 699 * @param a_Name The name of the global variable. … … 2223 2233 * for a command (call #Bs3KbdWait if unsure). 2224 2234 * 2225 * @returns 2226 * @param 2235 * @returns The value read is returned (in al). 2236 * @param bCmd The read command. 2227 2237 */ 2228 2238 BS3_CMN_PROTO_NOSB(uint8_t, Bs3KbdRead,(uint8_t bCmd)); … … 2234 2244 * for a command (call #Bs3KbdWait if unsure). 2235 2245 * 2236 * @param 2237 * @param 2246 * @param bCmd The write command. 2247 * @param bData The data to write. 2238 2248 */ 2239 2249 BS3_CMN_PROTO_NOSB(void, Bs3KbdWrite,(uint8_t bCmd, uint8_t bData)); … … 2241 2251 2242 2252 /** 2253 * Configures the PIC, once only. 2254 * 2255 * Subsequent calls to this function will not do anything. 2256 * 2257 * The PIC will be programmed to use IDT/IVT vectors 0x70 thru 0x7f, auto 2258 * end-of-interrupt, and all IRQs masked. The individual PIC users will have to 2259 * use #Bs3PicUpdateMask unmask their IRQ once they've got all the handlers 2260 * installed. 2261 */ 2262 BS3_CMN_PROTO_STUB(void, Bs3PicSetup,(void)); 2263 2264 /** 2265 * Updates the PIC masks. 2266 * 2267 * @returns The new mask - master in low, slave in high byte. 2268 * @param fAndMask Things to keep as-is. Master in low, slave in high byte. 2269 * @param fOrMask Things to start masking. Ditto wrt bytes. 2270 */ 2271 BS3_CMN_PROTO_STUB(uint16_t, Bs3PicUpdateMask,(uint16_t fAndMask, uint16_t fOrMask)); 2272 2273 /** 2243 2274 * Disables all IRQs on the PIC. 2244 2275 */ 2245 2276 BS3_CMN_PROTO_STUB(void, Bs3PicMaskAll,(void)); 2277 2278 2279 /** 2280 * Sets up the PIT for periodic callback. 2281 * 2282 * @param cHzDesired The desired Hz. Zero means max interval length 2283 * (18.2Hz). Plase check the various PIT globals for 2284 * the actual interval length. 2285 */ 2286 BS3_CMN_PROTO_STUB(void, Bs3PitSetupAndEnablePeriodTimer,(uint16_t cHzDesired)); 2287 2288 /** 2289 * Disables the PIT if active. 2290 */ 2291 BS3_CMN_PROTO_STUB(void, Bs3PitDisable,(void)); 2292 2293 /** Nano seconds (approx) since last the PIT timer was started. */ 2294 extern uint64_t volatile g_cBs3PitNs; 2295 /** Milliseconds seconds (very approx) since last the PIT timer was started. */ 2296 extern uint64_t volatile g_cBs3PitMs; 2297 /** Number of ticks since last the PIT timer was started. */ 2298 extern uint32_t volatile g_cBs3PitTicks; 2299 /** The current interval in nanon seconds. */ 2300 extern uint32_t g_cBs3PitIntervalNs; 2301 /** The current interval in milliseconds (approximately). 2302 * This is 0 if not yet started (used for checking the state internally). */ 2303 extern uint16_t volatile g_cBs3PitIntervalMs; 2304 /** The current PIT frequency (approximately). 0 if not yet started. */ 2305 extern uint16_t g_cBs3PitIntervalHz; 2246 2306 2247 2307 … … 2645 2705 * C-style trap handler. 2646 2706 * 2647 * Upon return Bs3Trap16ResumeFrame_c16, #Bs3Trap32ResumeFrame_c32, or 2648 * Bs3Trap64ResumeFrame_c64 will be called depending on the current template 2649 * context. 2707 * The caller will resume the context in @a pTrapFrame upon return. 2650 2708 * 2651 2709 * @param pTrapFrame The trap frame. Registers can be modified. 2652 */ 2653 typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame); 2710 * @note The 16-bit versions must be in CGROUP16! 2711 */ 2712 typedef BS3_DECL_NEAR_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame); 2654 2713 /** Pointer to a trap handler (current template context). */ 2655 2714 typedef FNBS3TRAPHANDLER *PFNBS3TRAPHANDLER; 2656 2715 2716 /** @copydoc FNBS3TRAPHANDLER */ 2717 typedef FNBS3TRAPHANDLER FNBS3TRAPHANDLER16; 2718 /** @copydoc PFNBS3TRAPHANDLER */ 2719 typedef FNBS3TRAPHANDLER16 *PFNBS3TRAPHANDLER16; 2720 #if ARCH_BITS == 16 2721 /** @copydoc FNBS3TRAPHANDLER */ 2722 typedef FNBS3FAR FNBS3TRAPHANDLER32; 2723 /** @copydoc FNBS3TRAPHANDLER */ 2724 typedef FNBS3FAR FNBS3TRAPHANDLER64; 2725 #else 2726 /** @copydoc FNBS3TRAPHANDLER */ 2727 typedef FNBS3TRAPHANDLER FNBS3TRAPHANDLER32; 2728 /** @copydoc FNBS3TRAPHANDLER */ 2729 typedef FNBS3TRAPHANDLER FNBS3TRAPHANDLER64; 2730 #endif 2731 /** @copydoc PFNBS3TRAPHANDLER */ 2732 typedef FNBS3TRAPHANDLER32 *PFNBS3TRAPHANDLER32; 2733 /** @copydoc PFNBS3TRAPHANDLER */ 2734 typedef FNBS3TRAPHANDLER64 *PFNBS3TRAPHANDLER64; 2735 2736 2737 /** 2738 * C-style trap handler, near 16-bit (CGROUP16). 2739 * 2740 * The caller will resume the context in @a pTrapFrame upon return. 2741 * 2742 * @param pTrapFrame The trap frame. Registers can be modified. 2743 */ 2744 typedef BS3_DECL_NEAR_CALLBACK(void) FNBS3TRAPHANDLER16(PBS3TRAPFRAME pTrapFrame); 2745 /** Pointer to a trap handler (current template context). */ 2746 typedef FNBS3TRAPHANDLER16 *PFNBS3TRAPHANDLER16; 2747 2748 /** 2749 * C-style trap handler, near 16-bit (CGROUP16). 2750 * 2751 * The caller will resume the context in @a pTrapFrame upon return. 2752 * 2753 * @param pTrapFrame The trap frame. Registers can be modified. 2754 */ 2755 typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER3264(PBS3TRAPFRAME pTrapFrame); 2756 /** Pointer to a trap handler (current template context). */ 2757 typedef FNBS3TRAPHANDLER3264 *FPFNBS3TRAPHANDLER3264; 2758 2759 2657 2760 /** 2658 2761 * Sets a trap handler (C/C++/assembly) for the current bitcount. 2659 *2660 * When using a 32-bit IDT, only #Bs3TrapSetHandler_c32 will have any effect.2661 * Likewise, when using a 16-bit IDT, only Bs3TrapSetHandler_c16 will make any2662 * difference. Ditto 64-bit.2663 *2664 * Rational: It's mainly a C API, can't easily mix function pointers from other2665 * bit counts in C. Use assembly helpers or something if that is necessary.2666 * Besides, most of the real trap handling goes thru the default handler with2667 * help of trap records.2668 2762 * 2669 2763 * @returns Previous handler. 2670 2764 * @param iIdt The index of the IDT entry to set. 2671 2765 * @param pfnHandler Pointer to the handler. 2766 * @sa Bs3TrapSetHandlerEx 2672 2767 */ 2673 2768 BS3_CMN_PROTO_STUB(PFNBS3TRAPHANDLER, Bs3TrapSetHandler,(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler)); 2769 2770 /** 2771 * Sets a trap handler (C/C++/assembly) for all the bitcounts. 2772 * 2773 * @param iIdt The index of the IDT and IVT entry to set. 2774 * @param pfnHandler16 Pointer to the 16-bit handler. (Assumes linker addresses.) 2775 * @param pfnHandler32 Pointer to the 32-bit handler. (Assumes linker addresses.) 2776 * @param pfnHandler64 Pointer to the 64-bit handler. (Assumes linker addresses.) 2777 * @sa Bs3TrapSetHandler 2778 */ 2779 BS3_CMN_PROTO_STUB(void, Bs3TrapSetHandlerEx,(uint8_t iIdt, PFNBS3TRAPHANDLER16 pfnHandler16, 2780 PFNBS3TRAPHANDLER32 pfnHandler32, PFNBS3TRAPHANDLER64 pfnHandler64)); 2674 2781 2675 2782 /**
Note:
See TracChangeset
for help on using the changeset viewer.