VirtualBox

Changeset 60668 in vbox


Ignore:
Timestamp:
Apr 23, 2016 12:06:18 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106836
Message:

bs3kit: updates.

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  
    11; $Id$
    22;; @file
    3 ; BS3Kit - First Object, calling real-mode main().
     3; BS3Kit - First Object, calling 16-bit protected-mode main().
    44;
    55
    66;
    7 ; Copyright (C) 2007-2015 Oracle Corporation
     7; Copyright (C) 2007-2016 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040;*  External Symbols                                                                                                             *
    4141;*********************************************************************************************************************************
    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
     42BS3_BEGIN_DATA16
    5143
    5244BS3_BEGIN_RMTEXT16
    53 EXTERN Bs3InitMemory_rm_far
     45extern _Bs3CpuDetect_rm_far
     46extern _Bs3InitMemory_rm_far
    5447
    5548BS3_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 
     49BS3_EXTERN_CMN Bs3PicMaskAll
     50BS3_EXTERN_CMN Bs3Trap16Init
     51extern _Bs3SwitchToPE16_rm
     52extern _Main_pe16
    8153BS3_EXTERN_CMN Bs3Shutdown
    82 BS3_EXTERN_CMN Bs3Trap32Init
    8354
    8455
    8556BS3_BEGIN_TEXT16
    8657    ;
    87     ; We need to enter 16-bit protected mode before we can call Main_pe16.
     58    ; Zero return address and zero caller BP.
    8859    ;
    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
    16964
    17065    ;
    171     ; Call main, if it returns shutdown the system.
     66    ; Load DS and ES with data selectors.
    17267    ;
    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.
    17794    call    Bs3Shutdown
    17895
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-CpuDetect.asm

    r60556 r60668  
    127127        ; assume 386+ if ET=1.
    128128        ;
    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.
    134136        smsw    ax
    135137        test    ax, ~(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS | X86_CR0_ET | X86_CR0_NE)
    136         jnz     .is_286
     138        jz      .486plus
    137139
    138140        ;
     
    177179CPU 386
    178180.386plus:
     181.486plus:
    179182        ;
    180183        ; 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 */
    15
     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*********************************************************************************************************************************/
    231#include "bs3kit.h"
    332#include <iprt/assert.h>
     33#include <iprt/asm-amd64-x86.h>
    434
    535AssertCompileSize(uint16_t, 2);
     
    737AssertCompileSize(uint64_t, 8);
    838
     39extern uint16_t ASMGetMsw();
     40#pragma aux ASMGetMsw = \
     41    ".286" \
     42    "smsw ax" \
     43    value [ax] \
     44    modify exact;
     45
     46extern void ASMSetMsw(uint16_t uMsw);
     47#pragma aux ASMSetMsw = \
     48    ".286p" \
     49    "lmsw ax" \
     50    parm [ax] \
     51    modify exact;
    952
    1053/* Just a sample. */
    1154BS3_DECL(void) Main_pe16(void)
    1255{
    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());
    1767
    1868    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
    6173    Bs3Shutdown();
     74#endif
    6275    return;
    6376}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette