Changeset 60668 in vbox
- Timestamp:
- Apr 23, 2016 12:06:18 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106836
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-pe16.asm
r60556 r60668 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - First Object, calling real-mode main().3 ; BS3Kit - First Object, calling 16-bit protected-mode main(). 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 … … 40 40 ;* External Symbols * 41 41 ;********************************************************************************************************************************* 42 BS3_EXTERN_SYSTEM16 Bs3Lgdt_Gdt 43 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt16 44 45 extern Bs3SelProtFar32ToFlat32_c64 46 extern Bs3PrintChr_c64 47 extern Bs3Printf_c64 48 extern Bs3TestTerm_c64 49 extern Bs3TestSub_c64 50 extern Bs3TestInit_c64 42 BS3_BEGIN_DATA16 51 43 52 44 BS3_BEGIN_RMTEXT16 53 EXTERN Bs3InitMemory_rm_far 45 extern _Bs3CpuDetect_rm_far 46 extern _Bs3InitMemory_rm_far 54 47 55 48 BS3_BEGIN_TEXT16 56 %if 0 57 EXTERN Main_pe16 58 EXTERN Bs3SwitchToPE16_rm 59 EXTERN Bs3SwitchToRM_pe16 60 EXTERN Bs3SwitchToPE32_rm 61 EXTERN Bs3SwitchTo32Bit_c16 62 EXTERN Bs3SwitchTo32Bit_c32 63 EXTERN Bs3SwitchTo16Bit_c16 64 EXTERN Bs3SwitchTo16Bit_c32 65 EXTERN Bs3SwitchToPP16_rm 66 EXTERN Bs3SwitchToPP32_rm 67 EXTERN Bs3SwitchToPAE16_rm 68 EXTERN Bs3SwitchToPAE32_rm 69 EXTERN Bs3SwitchToLM64_rm 70 EXTERN Bs3SwitchToRM_pe32 71 EXTERN Bs3SwitchToRM_pp16 72 EXTERN Bs3SwitchToRM_pp32 73 EXTERN Bs3SwitchToRM_pae16 74 EXTERN Bs3SwitchToRM_pae32 75 extern Bs3SwitchToRM_lm64 76 extern _Bs3PrintChr_c16 77 extern _Bs3PrintChr_c32 78 extern Bs3PrintChr_c64 79 %endif 80 49 BS3_EXTERN_CMN Bs3PicMaskAll 50 BS3_EXTERN_CMN Bs3Trap16Init 51 extern _Bs3SwitchToPE16_rm 52 extern _Main_pe16 81 53 BS3_EXTERN_CMN Bs3Shutdown 82 BS3_EXTERN_CMN Bs3Trap32Init83 54 84 55 85 56 BS3_BEGIN_TEXT16 86 57 ; 87 ; We need to enter 16-bit protected mode before we can call Main_pe16.58 ; Zero return address and zero caller BP. 88 59 ; 89 call far NAME(Bs3InitMemory_rm_far) ; Initialize the memory (must be done from real mode). 90 call Bs3Trap32Init 91 sub xSP, 20h ; for 64-bit calls. 92 %if 0 93 call NAME(Bs3SwitchToPE16_rm) 94 push '1' 95 call NAME(Bs3PrintChr_c16) 96 97 call NAME(Bs3SwitchTo32Bit_c16) 98 BS3_SET_BITS 32 99 call NAME(Bs3SwitchTo16Bit_c32) 100 BS3_SET_BITS 16 101 push '2' 102 call NAME(Bs3PrintChr_c16) 103 104 call NAME(Bs3SwitchToRM_pe16) 105 106 call NAME(Bs3SwitchToPE32_rm) 107 BS3_SET_BITS 32 108 push '3' 109 call NAME(Bs3PrintChr_c32) 110 call NAME(Bs3SwitchToRM_pe32) 111 BS3_SET_BITS 16 112 push '4' 113 call NAME(Bs3PrintChr_c16) 114 115 call NAME(Bs3SwitchToPE16_rm) 116 push '5' 117 call NAME(Bs3PrintChr_c16) 118 119 call NAME(Bs3SwitchToRM_pe16) 120 push '6' 121 call NAME(Bs3PrintChr_c16) 122 123 call NAME(Bs3SwitchToPP16_rm) 124 push '7' 125 call NAME(Bs3PrintChr_c16) 126 127 call NAME(Bs3SwitchToRM_pp16) 128 push '8' 129 call NAME(Bs3PrintChr_c16) 130 131 call NAME(Bs3SwitchToPP32_rm) 132 BS3_SET_BITS 32 133 push '9' 134 call NAME(Bs3PrintChr_c32) 135 136 call NAME(Bs3SwitchToRM_pp32) 137 BS3_SET_BITS 16 138 push 'a' 139 call NAME(Bs3PrintChr_c16) 140 141 call NAME(Bs3SwitchToPAE32_rm) 142 BS3_SET_BITS 32 143 push 'b' 144 call NAME(Bs3PrintChr_c32) 145 146 call NAME(Bs3SwitchToRM_pae32) 147 BS3_SET_BITS 16 148 push 'c' 149 call NAME(Bs3PrintChr_c16) 150 151 call NAME(Bs3SwitchToPAE16_rm) 152 push 'd' 153 call NAME(Bs3PrintChr_c16) 154 155 call NAME(Bs3SwitchToRM_pae16) 156 push 'e' 157 call NAME(Bs3PrintChr_c16) 158 159 call NAME(Bs3SwitchToLM64_rm) 160 BS3_SET_BITS 64 161 push 'f' 162 BS3_CALL Bs3PrintChr_c64,1 163 164 call Bs3SwitchToRM_lm64 165 BS3_SET_BITS 16 166 push 'g' 167 call NAME(Bs3PrintChr_c16) 168 %endif 60 xor ax, ax 61 push ax 62 push ax 63 mov bp, sp 169 64 170 65 ; 171 ; Call main, if it returns shutdown the system.66 ; Load DS and ES with data selectors. 172 67 ; 173 .halt: 174 hlt 175 jmp .halt 176 ; call NAME(Main_pe16) 68 mov ax, BS3KIT_GRPNM_DATA16 69 mov ds, ax 70 mov es, ax 71 72 73 ; 74 ; Make sure interrupts are disabled as we cannot (don't want to) service 75 ; BIOS interrupts once we switch mode. 76 ; 77 cli 78 call Bs3PicMaskAll 79 80 ; 81 ; Initialize 16-bit protected mode. 82 ; 83 call far _Bs3CpuDetect_rm_far 84 call far _Bs3InitMemory_rm_far 85 call Bs3Trap16Init 86 87 ; 88 ; Switch to PE16 and call main. 89 ; 90 call _Bs3SwitchToPE16_rm 91 call _Main_pe16 92 93 ; Try shutdown if it returns. 177 94 call Bs3Shutdown 178 95 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-CpuDetect.asm
r60556 r60668 127 127 ; assume 386+ if ET=1. 128 128 ; 129 ; However, it turns out the 286 I've got here has bits 4 thru 15 all 130 ; set. This is very nice though, because only bits 4 and 5 are defined 131 ; on later CPUs and the remainder MBZ. So, check whether any of the MBZ 132 ; bits are set, if so, then it's 286. 133 ; 129 ; The second idea was to check whether any reserved bits are set, 130 ; because the 286 here has bits 4 thru 15 all set. Unfortunately, it 131 ; turned out the 386SX and AMD 486DX-40 also sets bits 4 thru 15 when 132 ; using SMSW. So, nothing conclusive to distinguish 386 from 286, but 133 ; we've probably got a save 486+ detection here. 134 ; 135 ;; @todo check if LOADALL can set any of the reserved bits on a 286 or 386. 134 136 smsw ax 135 137 test ax, ~(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS | X86_CR0_ET | X86_CR0_NE) 136 j nz .is_286138 jz .486plus 137 139 138 140 ; … … 177 179 CPU 386 178 180 .386plus: 181 .486plus: 179 182 ; 180 183 ; Check for CPUID and AC. The former flag indicates CPUID support, the -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c
r60019 r60668 1 /* $Id$ */ 2 /** @file 3 * BS3Kit - Shutdown VM from PE16 - proof of concept (BS3Kit). 4 */ 1 5 6 /* 7 * Copyright (C) 2007-2016 Oracle Corporation 8 * 9 * This file is part of VirtualBox Open Source Edition (OSE), as 10 * available from http://www.virtualbox.org. This file is free software; 11 * you can redistribute it and/or modify it under the terms of the GNU 12 * General Public License (GPL) as published by the Free Software 13 * Foundation, in version 2 as it comes in the "COPYING" file of the 14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 * 17 * The contents of this file may alternatively be used under the terms 18 * of the Common Development and Distribution License Version 1.0 19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the 20 * VirtualBox OSE distribution, in which case the provisions of the 21 * CDDL are applicable instead of those of the GPL. 22 * 23 * You may elect to license modified versions of this file under the 24 * terms and conditions of either the GPL or the CDDL or both. 25 */ 26 27 28 /********************************************************************************************************************************* 29 * Header Files * 30 *********************************************************************************************************************************/ 2 31 #include "bs3kit.h" 3 32 #include <iprt/assert.h> 33 #include <iprt/asm-amd64-x86.h> 4 34 5 35 AssertCompileSize(uint16_t, 2); … … 7 37 AssertCompileSize(uint64_t, 8); 8 38 39 extern uint16_t ASMGetMsw(); 40 #pragma aux ASMGetMsw = \ 41 ".286" \ 42 "smsw ax" \ 43 value [ax] \ 44 modify exact; 45 46 extern void ASMSetMsw(uint16_t uMsw); 47 #pragma aux ASMSetMsw = \ 48 ".286p" \ 49 "lmsw ax" \ 50 parm [ax] \ 51 modify exact; 9 52 10 53 /* Just a sample. */ 11 54 BS3_DECL(void) Main_pe16(void) 12 55 { 13 void BS3_FAR *pvTmp1; 14 void BS3_FAR *pvTmp2; 15 void BS3_FAR *pvTmp3; 16 void BS3_FAR *pvTmp4; 56 uint16_t uMsw = ASMGetMsw(); 57 Bs3Printf("msw=%#x cr0=%RX32 g_uBs3CpuDetected=%#x\n", uMsw, ASMGetCR0(), g_uBs3CpuDetected); 58 Bs3Printf("cr2=%RX32 cr3=%RX32\n", ASMGetCR2(), ASMGetCR3()); 59 ASMSetMsw(X86_CR0_PE); 60 Bs3Printf("lmsw(PE) => msw=%#x cr0=%RX32\n", ASMGetMsw(), ASMGetCR0()); 61 ASMSetMsw(UINT16_MAX); 62 Bs3Printf("lmsw(0xffff) => msw=%#x cr0=%RX32\n", ASMGetMsw(), ASMGetCR0()); 63 ASMSetCR0(X86_CR0_PE); 64 Bs3Printf("ASMSetCR0(X86_CR0_PE) => msw=%#x cr0=%RX32\n", ASMGetMsw(), ASMGetCR0()); 65 ASMSetCR0(UINT32_C(0x7fffffff)); 66 Bs3Printf("ASMSetCR0(0x7fffffff) => msw=%#x cr0=%RX32\n", ASMGetMsw(), ASMGetCR0()); 17 67 18 68 Bs3TestInit("bs3-shutdown"); 19 20 Bs3PrintStr("Bs3PrintX32:"); 21 Bs3PrintX32(UINT32_C(0xfdb97531)); 22 Bs3PrintStr("\n"); 23 24 Bs3Printf("Bs3Printf: RX32=%#'RX32 string='%s' d=%d p=%p\n", UINT32_C(0xfdb97531), "my string", 42, Main_pe16); 25 26 pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 27 Bs3PrintStr("pvTmp2="); 28 Bs3PrintX32((uintptr_t)pvTmp2); 29 Bs3PrintStr("\n"); 30 31 pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 32 Bs3PrintStr("pvTmp3="); 33 Bs3PrintX32((uintptr_t)pvTmp3); 34 Bs3PrintStr("\n"); 35 Bs3MemFree(pvTmp2, _4K); 36 37 pvTmp4 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 38 Bs3PrintStr("pvTmp4="); 39 Bs3PrintX32((uintptr_t)pvTmp4); 40 Bs3PrintStr("\n"); 41 Bs3PrintStr("\n"); 42 43 pvTmp1 = Bs3MemAlloc(BS3MEMKIND_REAL, 31); 44 Bs3PrintStr("pvTmp1="); 45 Bs3PrintX32((uintptr_t)pvTmp1); 46 Bs3PrintStr("\n"); 47 48 pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, 17); 49 Bs3PrintStr("pvTmp2="); 50 Bs3PrintX32((uintptr_t)pvTmp2); 51 Bs3PrintStr("\n"); 52 53 Bs3MemFree(pvTmp1, 31); 54 pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, 17); 55 Bs3PrintStr("pvTmp3="); 56 Bs3PrintX32((uintptr_t)pvTmp3); 57 Bs3PrintStr("\n"); 58 59 60 Bs3Panic(); 69 Bs3TestPrintf("detected cpu: %#x\n", g_uBs3CpuDetected); 70 #if 1 71 ASMHalt(); 72 #else 61 73 Bs3Shutdown(); 74 #endif 62 75 return; 63 76 }
Note:
See TracChangeset
for help on using the changeset viewer.