VirtualBox

Ignore:
Timestamp:
Nov 10, 2015 1:25:13 AM (9 years ago)
Author:
vboxsync
Message:

bs3kit: Managed to link 16, 32 and 64-bit C code into the same binary, where the 64-bit C code was produced by the microsoft compiler. That doesn't mean it actually works, but chances are high. Bad new though, no debug info. OTOH, a lot of the assembly code can be converted to C, which is faster and safer than adjusting it to the new calling convensions.

Location:
trunk/src/VBox/ValidationKit/bootsectors/bs3kit
Files:
4 added
6 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r58609 r58628  
    6262# BS3Kit template for assembly and 16-bit code.
    6363TEMPLATE_VBoxBS3KitImg = Template for building BS3Kit test images.
    64 TEMPLATE_VBoxBS3KitImg_INST     = $(INST_VALIDATIONKIT)bootsectors/
    65 TEMPLATE_VBoxBS3KitImg_BINSUFF  = .img
    66 TEMPLATE_VBoxBS3KitImg_MODE     = 0644
    67 TEMPLATE_VBoxBS3KitImg_ASTOOL   = NASM
    68 TEMPLATE_VBoxBS3KitImg_ASFLAGS := -f obj -g -w+orphan-labels
    69 TEMPLATE_VBoxBS3KitImg_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=16 __NASM__
    70 TEMPLATE_VBoxBS3KitImg_ARTOOL   = OPENWATCOM-16
    71 TEMPLATE_VBoxBS3KitImg_CTOOL    = OPENWATCOM-16
    72 TEMPLATE_VBoxBS3KitImg_CXXTOOL  = OPENWATCOM-16
    73 TEMPLATE_VBoxBS3KitImg_CFLAGS   = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
    74 TEMPLATE_VBoxBS3KitImg_CXXFLAGS = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
    75 TEMPLATE_VBoxBS3KitImg_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
    76 TEMPLATE_VBoxBS3KitImg_LDTOOL   = OPENWATCOM-WL
     64TEMPLATE_VBoxBS3KitImg_BLD_TRG      = os-agnostic
     65TEMPLATE_VBoxBS3KitImg_BLD_TRG_ARCH = x86
     66TEMPLATE_VBoxBS3KitImg_INST         = $(INST_VALIDATIONKIT)bootsectors/
     67TEMPLATE_VBoxBS3KitImg_BINSUFF      = .img
     68TEMPLATE_VBoxBS3KitImg_MODE         = 0644
     69TEMPLATE_VBoxBS3KitImg_ASTOOL       = NASM
     70TEMPLATE_VBoxBS3KitImg_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
     71TEMPLATE_VBoxBS3KitImg_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
     72TEMPLATE_VBoxBS3KitImg_DEFS         = ARCH_BITS=16 IN_BS3KIT
     73TEMPLATE_VBoxBS3KitImg_ARTOOL       = OPENWATCOM-16
     74TEMPLATE_VBoxBS3KitImg_CTOOL        = OPENWATCOM-16
     75TEMPLATE_VBoxBS3KitImg_CXXTOOL      = OPENWATCOM-16
     76TEMPLATE_VBoxBS3KitImg_CFLAGS       = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
     77TEMPLATE_VBoxBS3KitImg_CXXFLAGS     = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
     78TEMPLATE_VBoxBS3KitImg_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
     79TEMPLATE_VBoxBS3KitImg_LDTOOL       = OPENWATCOM-WL
    7780#       option quiet, nofarcalls\
    7881#       disable 1014, 1023, 2120, 1080
     
    8184        debug codeview all \
    8285        option quiet, map, statics, verbose, symfile, start=_start \
    83        disable 1014, 1080 \
     86       disable 1014, 1080, 1150 \
    8487        \
    8588        output raw offset=0x10000 \
    8689        order \
    87          clname CODE16  segaddr=0x1000 \
     90         clname BS3CODE16  segaddr=0x1000 \
    8891          segment BS3TEXT16 \
    8992          segment text \
    9093         clname FAR_DATA \
    9194          segment BS3DATA16 \
    92         clname CODE32 \
     95          segment BS3DATA16CONST \
     96          segment BS3DATA16CONST2 \
     97          segment BS3DATA16_DATA \
     98          segment BS3DATA32 \
     99          segment BS3DATA32_CONST \
     100          segment BS3DATA32_CONST2 \
     101          segment BS3DATA32_DATA \
     102          segment DATA32 \
     103        clname BS3CODE32 \
    93104          segment BS3TEXT32 \
    94105          segment TEXT32 \
    95         clname DATA32 \
    96           segment BS3DATA32 \
    97           segment DATA32
     106        clname CODE \
     107          segment BS3TEXT64 \
     108          segment TEXT64 \
     109          segment .text \
     110          segment .rdata \
     111        clname DATA \
     112          segment BS3DATA64 \
     113          segment DATA64 \
     114          segment .data
    98115TEMPLATE_VBoxBS3KitImg_DEPS = \
    99116        $(bs3-bootsector_1_TARGET) \
     
    111128# BS3Kit template for 32-bit code.
    112129TEMPLATE_VBoxBS3KitImg32 = Template for building BS3Kit test images.
    113 TEMPLATE_VBoxBS3KitImg32_INSTTYPE = none
    114 TEMPLATE_VBoxBS3KitImg32_ASTOOL   = NASM
    115 TEMPLATE_VBoxBS3KitImg32_ASFLAGS := -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
    116 TEMPLATE_VBoxBS3KitImg32_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=32 __NASM__
    117 TEMPLATE_VBoxBS3KitImg32_ARTOOL   = OPENWATCOM
    118 TEMPLATE_VBoxBS3KitImg32_CTOOL    = OPENWATCOM
    119 TEMPLATE_VBoxBS3KitImg32_CXXTOOL  = OPENWATCOM
    120 TEMPLATE_VBoxBS3KitImg32_CFLAGS   = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -s -oas -ms -hc -d1
    121 TEMPLATE_VBoxBS3KitImg32_CXXFLAGS = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -s -oas -ms -hc -d1
    122 TEMPLATE_VBoxBS3KitImg32_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
    123 TEMPLATE_VBoxBS3KitImg32_LDTOOL   = VBoxBsUnusedLd
     130TEMPLATE_VBoxBS3KitImg32_BLD_TRG      = os-agnostic
     131TEMPLATE_VBoxBS3KitImg32_BLD_TRG_ARCH = x86
     132TEMPLATE_VBoxBS3KitImg32_INSTTYPE     = none
     133TEMPLATE_VBoxBS3KitImg32_ASTOOL       = NASM
     134TEMPLATE_VBoxBS3KitImg32_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
     135TEMPLATE_VBoxBS3KitImg32_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
     136TEMPLATE_VBoxBS3KitImg32_DEFS         = ARCH_BITS=32 IN_BS3KIT
     137TEMPLATE_VBoxBS3KitImg32_ARTOOL       = OPENWATCOM
     138TEMPLATE_VBoxBS3KitImg32_CTOOL        = OPENWATCOM
     139TEMPLATE_VBoxBS3KitImg32_CXXTOOL      = OPENWATCOM
     140TEMPLATE_VBoxBS3KitImg32_CFLAGS       = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf -hc -d1
     141TEMPLATE_VBoxBS3KitImg32_CXXFLAGS     = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf -hc -d1
     142TEMPLATE_VBoxBS3KitImg32_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
     143TEMPLATE_VBoxBS3KitImg32_LDTOOL       = VBoxBsUnusedLd
    124144
    125145# BS3Kit template for 64-bit code.
    126146TEMPLATE_VBoxBS3KitImg64 = Template for building BS3Kit test images.
    127 TEMPLATE_VBoxBS3KitImg64_INSTTYPE = none
    128 TEMPLATE_VBoxBS3KitImg64_ASTOOL   = NASM
    129 TEMPLATE_VBoxBS3KitImg64_ASFLAGS := -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
    130 TEMPLATE_VBoxBS3KitImg64_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=64 __NASM__
    131 TEMPLATE_VBoxBS3KitImg64_ARTOOL   = OPENWATCOM
    132 TEMPLATE_VBoxBS3KitImg64_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
    133 TEMPLATE_VBoxBS3KitImg64_CTOOL    = VBoxBsUnusedLd
    134 TEMPLATE_VBoxBS3KitImg64_CXXTOOL  = VBoxBsUnusedLd
    135 TEMPLATE_VBoxBS3KitImg64_LDTOOL   = VBoxBsUnusedLd
     147TEMPLATE_VBoxBS3KitImg64_BLD_TRG      = os-agnostic
     148TEMPLATE_VBoxBS3KitImg64_BLD_TRG_ARCH = amd64
     149TEMPLATE_VBoxBS3KitImg64_INSTTYPE     = none
     150TEMPLATE_VBoxBS3KitImg64_ASTOOL       = NASM
     151TEMPLATE_VBoxBS3KitImg64_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
     152TEMPLATE_VBoxBS3KitImg64_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
     153TEMPLATE_VBoxBS3KitImg64_DEFS         = IN_BS3KIT ARCH_BITS=64
     154TEMPLATE_VBoxBS3KitImg64_ARTOOL       = OPENWATCOM
     155TEMPLATE_VBoxBS3KitImg64_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
     156if1of ($(KBUILD_HOST), win)
     157 TEMPLATE_VBoxBS3KitImg64_BLD_TYPE   := release# Must avoid debug info as it contains fixups not supported by the linker.
     158 TEMPLATE_VBoxBS3KitImg64_CTOOL      := $(VBOX_VCC_TOOL_STEM)AMD64
     159 TEMPLATE_VBoxBS3KitImg64_CXXTOOL    := $(VBOX_VCC_TOOL_STEM)AMD64
     160 TEMPLATE_VBoxBS3KitImg64_CFLAGS      = -O1 -Oi -GF -GS- -Gy -Gs65536
     161 TEMPLATE_VBoxBS3KitImg64_CXXFLAGS    = -O1 -Oi -GF -GS- -Gy -Gs65536
     162else
     163 TEMPLATE_VBoxBS3KitImg64_CTOOL      := $(VBOX_GCC_TOOL)
     164 TEMPLATE_VBoxBS3KitImg64_CXXTOOL    := $(VBOX_GCC_TOOL)
     165 TEMPLATE_VBoxBS3KitImg64_CFLAGS      = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_C)
     166 TEMPLATE_VBoxBS3KitImg64_CXXFLAGS    = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_CXX)
     167endif
     168TEMPLATE_VBoxBS3KitImg64_LDTOOL       = VBoxBsUnusedLd
    136169
    137170# BS3Kit template for the bootsector.
    138171TEMPLATE_VBoxBS3KitBS = Template for building BS3Kit test images.
    139 TEMPLATE_VBoxBS3KitBS_INST     = $(INST_VALIDATIONKIT)bootsectors/
    140 TEMPLATE_VBoxBS3KitBS_INSTTYPE = none
    141 TEMPLATE_VBoxBS3KitBS_BINSUFF  = .img
    142 TEMPLATE_VBoxBS3KitBS_MODE     = 0644
    143 TEMPLATE_VBoxBS3KitBS_ASTOOL   = YASM
    144 TEMPLATE_VBoxBS3KitBS_ASFLAGS := -f bin --mapfile
    145 TEMPLATE_VBoxBS3KitBS_ASDEFS   = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__
    146 TEMPLATE_VBoxBS3KitBS_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
    147 TEMPLATE_VBoxBS3KitBS_LDTOOL   = VBoxBsCpLd
     172TEMPLATE_VBoxBS3KitBS_BLD_TRG         = os-agnostic
     173TEMPLATE_VBoxBS3KitBS_BLD_TRG_ARCH    = x86
     174TEMPLATE_VBoxBS3KitBS_INST            = $(INST_VALIDATIONKIT)bootsectors/
     175TEMPLATE_VBoxBS3KitBS_INSTTYPE        = none
     176TEMPLATE_VBoxBS3KitBS_BINSUFF         = .img
     177TEMPLATE_VBoxBS3KitBS_MODE            = 0644
     178TEMPLATE_VBoxBS3KitBS_ASTOOL          = YASM
     179TEMPLATE_VBoxBS3KitBS_ASFLAGS         = -f bin --mapfile
     180TEMPLATE_VBoxBS3KitBS_ASDEFS          = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__
     181TEMPLATE_VBoxBS3KitBS_INCS            = $(VBOX_PATH_BS3KIT_SRC) .
     182TEMPLATE_VBoxBS3KitBS_LDTOOL          = VBoxBsCpLd
    148183
    149184#
     
    159194# Common sources to be compiled into _p16, _p32 and _p64 versions.
    160195VBOX_BS3KIT_COMMON_SOURCES = \
    161         bs3-cmn-shutdown.asm \
    162         bs3-cmn-panic.asm
     196        bs3-cmn-Shutdown.asm \
     197        bs3-cmn-Panic.asm \
     198        bs3-cmn-PrintU32.asm \
     199       bs3-cmn-PrintStrColonSpaces.asm \
     200       bs3-cmn-PrintStrSpacesColonSpace.c \
    163201
    164202# The BS3Kit library.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm

    r58612 r58628  
    2828
    2929
    30 BEGINPROC TMPL_CMN_NM(Bs3Panic)
     30BS3_PROC_BEGIN_CMN Bs3Panic
    3131        cli
    3232.panic_again:
    3333        hlt
    3434        jmp     .panic_again
    35 ENDPROC TMPL_CMN_NM(Bs3Panic)
     35BS3_PROC_END_CMN   Bs3Panic
    3636
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm

    r58612 r58628  
    2727%include "bs3kit-template-header.mac"
    2828
    29 EXTERN_CMN_NM Bs3Panic
     29BS3_EXTERN_CMN Bs3Panic
    3030
    31 BEGINPROC TMPL_CMN_NM(Bs3Shutdown)
     31BS3_PROC_BEGIN_CMN Bs3Shutdown
    3232        cli
    3333        mov     bl, 64
     
    4747.s_szShutdown:
    4848        db      'Shutdown', 0
    49 ENDPROC TMPL_CMN_NM(Bs3Shutdown)
     49BS3_PROC_END_CMN Bs3Shutdown
    5050
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm

    r58609 r58628  
    4747;*********************************************************************************************************************************
    4848BS3_BEGIN_TEXT16
    49 extern NAME(Bs3Shutdown_p16)
     49extern BS3_CMN_NM(Bs3Shutdown)
    5050extern NAME(Main_rm)
     51extern _Bs3PrintStrSpacesColonSpace_c16
     52extern _Bs3PrintStrSpacesColonSpace_c32
     53extern Bs3PrintStrSpacesColonSpace_c64
    5154
    5255
     
    5558;
    5659BS3_BEGIN_TEXT16
    57 BITS 16
    5860GLOBALNAME start
    5961    mov     ax, BS3DATA16
     
    6163    mov     ds, ax
    6264    call    NAME(Main_rm)
    63     call    NAME(Bs3Shutdown_p16)
     65    call    BS3_CMN_NM(Bs3Shutdown)
    6466
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c

    r58609 r58628  
     1
     2#include "bs3kit.h"
     3#include <iprt/assert.h>
     4
     5AssertCompileSize(uint16_t, 2);
     6AssertCompileSize(uint32_t, 4);
     7AssertCompileSize(uint64_t, 8);
     8
    19
    210/* Just a sample. */
    311void Main_rm(void)
    412{
    5 //    for (;;)
    6 //        { }
     13    Bs3Shutdown();
    714    return;
    815}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.h

    r58612 r58628  
    1 ; $Id$
    2 ;; @file
    3 ; BS3Kit footer for multi-mode code templates.
    4 ;
     1/* $Id$ */
     2/** @file
     3 * BS3Kit footer for multi-mode code templates.
     4 */
    55
    6 ;
    7 ; Copyright (C) 2007-2015 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 ;
     6/*
     7 * Copyright (C) 2007-2015 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 */
    2626
    2727
    28 ;
    29 ; Undefine macros defined by the header.
    30 ;
    31 ; Note! The following is useful for verifying that all macros are included here:
    32 ;
    33 ;       for i in `grep "%define" bootsector2-template-header.mac \
    34 ;                 | sed -e 's/^ *%define *//' -e 's/^\([^() ]*\).*$/\1/' \
    35 ;                 | sort -u`
    36 ;       do
    37 ;               if ! grep -wF "%undef $i" bootsector2-template-footer.mac; then
    38 ;                       echo $i
    39 ;               fi
    40 ;       done
    41 ;
    42 %undef TMPL_RM
    43 %undef TMPL_PE16
    44 %undef TMPL_PE32
    45 %undef TMPL_PEV86
    46 %undef TMPL_PP16
    47 %undef TMPL_PP32
    48 %undef TMPL_PPV86
    49 %undef TMPL_PAE16
    50 %undef TMPL_PAE32
    51 %undef TMPL_PAEV86
    52 %undef TMPL_LM16
    53 %undef TMPL_LM32
    54 %undef TMPL_LM64
     28/*
     29 * Undefine macros defined by the header.
     30 * This is a subset of what bs3kit-template-footer.mac does.
     31 */
     32#undef TMPL_RM
     33#undef TMPL_PE16
     34#undef TMPL_PE32
     35#undef TMPL_PEV86
     36#undef TMPL_PP16
     37#undef TMPL_PP32
     38#undef TMPL_PPV86
     39#undef TMPL_PAE16
     40#undef TMPL_PAE32
     41#undef TMPL_PAEV86
     42#undef TMPL_LM16
     43#undef TMPL_LM32
     44#undef TMPL_LM64
    5545
    56 %undef TMPL_CMN_PE
    57 %undef TMPL_CMN_PP
    58 %undef TMPL_CMN_PAE
    59 %undef TMPL_CMN_LM
    60 %undef TMPL_CMN_V86
     46#undef TMPL_CMN_PE
     47#undef TMPL_CMN_PP
     48#undef TMPL_CMN_PAE
     49#undef TMPL_CMN_LM
     50#undef TMPL_CMN_V86
    6151
    62 %undef TMPL_CMN_P16
    63 %undef TMPL_CMN_P32
    64 %undef TMPL_CMN_P64
    65 %undef TMPL_CMN_R16
    66 %undef TMPL_CMN_R86
     52#undef TMPL_CMN_P16
     53#undef TMPL_CMN_P32
     54#undef TMPL_CMN_P64
     55#undef TMPL_CMN_R16
     56#undef TMPL_CMN_R86
    6757
    68 %undef TMPL_NM
    69 %undef TMPL_NM_CMN
    70 %undef TMPL_MODE
    71 %undef TMPL_MODE_STR
    72 %undef TMPL_16BIT
    73 %undef TMPL_32BIT
    74 %undef TMPL_64BIT
    75 %undef TMPL_BITS
    76 %undef TMPL_PTR_DEF
    77 %undef TMPL_HAVE_BIOS
    78 %undef TMPL_BEGINCODE
     58#undef TMPL_NM
     59#undef TMPL_NM_CMN
     60#undef TMPL_MODE
     61#undef TMPL_MODE_STR
     62#undef TMPL_16BIT
     63#undef TMPL_32BIT
     64#undef TMPL_64BIT
     65#undef TMPL_BITS
    7966
    80 %undef xCB
    81 %undef xDEF
    82 %undef xRES
    83 %undef xPRE
    84 %undef xSP
    85 %undef xBP
    86 %undef xAX
    87 %undef xBX
    88 %undef xCX
    89 %undef xDX
    90 %undef xDI
    91 %undef xSI
    92 %undef xWrtRIP
    93 
    94 %undef sCB
    95 %undef sDEF
    96 %undef sRES
    97 %undef sPRE
    98 %undef sSP
    99 %undef sBP
    100 %undef sAX
    101 %undef sBX
    102 %undef sCX
    103 %undef sDX
    104 %undef sDI
    105 %undef sSI
    106 
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac

    r58588 r58628  
    6767
    6868%undef TMPL_NM
    69 %undef TMPL_NM_CMN
     69%undef BS3_CMN_NM
    7070%undef TMPL_MODE
    7171%undef TMPL_MODE_STR
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h

    r58612 r58628  
    1 ; $Id$
    2 ;; @file
    3 ; BS3Kit header for multi-mode code templates.
    4 ;
    5 
    6 ;
    7 ; Copyright (C) 2007-2015 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 %include "bs3kit.mac"
    28 
    29 ;
    30 ; Check and expand the mode defines.
    31 ; One of the following must be defined:
    32 ;       - TMPL_RM    - real mode.
    33 ;       - TMPL_PE16  - 16-bit protected mode, unpaged.
    34 ;       - TMPL_PE32  - 32-bit protected mode, unpaged.
    35 ;       - TMPL_PEV86 - virtual 8086 mode under protected mode, unpaged.
    36 ;       - TMPL_PP16  - 16-bit protected mode, paged.
    37 ;       - TMPL_PP32  - 32-bit protected mode, paged.
    38 ;       - TMPL_PPV86 - virtual 8086 mode under protected mode, paged.
    39 ;       - TMPL_PAE16 - 16-bit protected mode with PAE (paged).
    40 ;       - TMPL_PAE32 - 16-bit protected mode with PAE (paged).
    41 ;       - TMPL_PAEV86- virtual 8086 mode under protected mode with PAE (paged).
    42 ;       - TMPL_LM16  - 16-bit long mode (paged).
    43 ;       - TMPL_LM32  - 32-bit long mode (paged).
    44 ;       - TMPL_LM64  - 64-bit long mode (paged).
    45 ;
    46 ; Derived indicators:
    47 ;       - TMPL_CMN_PE  = TMPL_PE16  | TMPL_PE32  | TMPL_PEV86
    48 ;       - TMPL_CMN_PP  = TMPL_PP16  | TMPL_PP32  | TMPL_PPV86
    49 ;       - TMPL_CMN_PAE = TMPL_PAE16 | TMPL_PAE32 | TMPL_PAEV86
    50 ;       - TMPL_CMN_LM  = TMPL_LM16  | TMPL_LM32  | TMPL_LM64
    51 ;       - TMPL_CMN_V86 = TMPL_PEV86 | TMPL_PPV86 | TMPL_PAEV86
    52 ;       - TMPL_CMN_R86 = TMPL_CMN_V86 | TMPL_RM
    53 ;
    54 %ifdef TMPL_RM
    55  %ifdef TMPL_PE16
    56   %error "Both 'TMPL_RM' and 'TMPL_PE16' are defined."
    57  %endif
    58  %ifdef TMPL_PE32
    59   %error "Both 'TMPL_RM' and 'TMPL_PE32' are defined."
    60  %endif
    61  %ifdef TMPL_PEV86
    62   %error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    63  %endif
    64  %ifdef TMPL_PP16
    65   %error "Both 'TMPL_RM' and 'TMPL_PP16' are defined."
    66  %endif
    67  %ifdef TMPL_PP32
    68   %error "Both 'TMPL_RM' and 'TMPL_PP32' are defined."
    69  %endif
    70  %ifdef TMPL_PPV86
    71   %error "Both 'TMPL_RM' and 'TMPL_PPV86' are defined."
    72  %endif
    73  %ifdef TMPL_PAE16
    74   %error "Both 'TMPL_RM' and 'TMPL_PAE16' are defined."
    75  %endif
    76  %ifdef TMPL_PAE32
    77   %error "Both 'TMPL_RM' and 'TMPL_PAE32' are defined."
    78  %endif
    79  %ifdef TMPL_PAEV86
    80   %error "Both 'TMPL_RM' and 'TMPL_PAEV86' are defined."
    81  %endif
    82  %ifdef TMPL_LM16
    83   %error "Both 'TMPL_RM' and 'TMPL_LM16' are defined."
    84  %endif
    85  %ifdef TMPL_LM32
    86   %error "Both 'TMPL_RM' and 'TMPL_LM32' are defined."
    87  %endif
    88  %ifdef TMPL_LM64
    89   %error "Both 'TMPL_RM' and 'TMPL_LM64' are defined."
    90  %endif
    91  %define TMPL_16BIT
    92  %define TMPL_BITS              16
    93  %define TMPL_PTR_DEF           dw
    94  %define TMPL_NM(Name)          Name %+ _rm
    95  %define TMPL_NM_CMN(Name)      Name %+ _r86
    96  %define TMPL_MODE_STR          'real mode'
    97  %define TMPL_HAVE_BIOS
    98  %define TMPL_CMN_R86
    99 %endif
    100 
    101 %ifdef TMPL_PE16
    102  %ifdef TMPL_RM
    103   %error "Both 'TMPL_PE16' and 'TMPL_RM' are defined."
    104  %endif
    105  %ifdef TMPL_PE32
    106   %error "Both 'TMPL_PE16' and 'TMPL_PE32' are defined."
    107  %endif
    108  %ifdef TMPL_PEV86
    109   %error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    110  %endif
    111  %ifdef TMPL_PP16
    112   %error "Both 'TMPL_PE16' and 'TMPL_PP16' are defined."
    113  %endif
    114  %ifdef TMPL_PP32
    115   %error "Both 'TMPL_PE16' and 'TMPL_PP32' are defined."
    116  %endif
    117  %ifdef TMPL_PPV86
    118   %error "Both 'TMPL_PE16' and 'TMPL_PPV86' are defined."
    119  %endif
    120  %ifdef TMPL_PAE16
    121   %error "Both 'TMPL_PE16' and 'TMPL_PAE16' are defined."
    122  %endif
    123  %ifdef TMPL_PAE32
    124   %error "Both 'TMPL_PE16' and 'TMPL_PAE32' are defined."
    125  %endif
    126  %ifdef TMPL_PAEV86
    127   %error "Both 'TMPL_PE32' and 'TMPL_PAEV86' are defined."
    128  %endif
    129  %ifdef TMPL_LM16
    130   %error "Both 'TMPL_PE16' and 'TMPL_LM16' are defined."
    131  %endif
    132  %ifdef TMPL_LM32
    133   %error "Both 'TMPL_PE16' and 'TMPL_LM32' are defined."
    134  %endif
    135  %ifdef TMPL_LM64
    136   %error "Both 'TMPL_PE16' and 'TMPL_LM64' are defined."
    137  %endif
    138  %define TMPL_CMN_PE
    139  %define TMPL_CMN_P16
    140  %define TMPL_16BIT
    141  %define TMPL_BITS              16
    142  %define TMPL_PTR_DEF           dw
    143  %define TMPL_NM(Name)          Name %+ _pe16
    144  %define TMPL_NM_CMN(Name)      Name %+ _p16
    145  %define TMPL_MODE_STR          '16-bit unpaged protected mode'
    146 %endif
    147 
    148 %ifdef TMPL_PE32
    149  %ifdef TMPL_RM
    150   %error "Both 'TMPL_PE32' and 'TMPL_RM' are defined."
    151  %endif
    152  %ifdef TMPL_PE16
    153   %error "Both 'TMPL_PE32' and 'TMPL_PE16' are defined."
    154  %endif
    155  %ifdef TMPL_PEV86
    156   %error "Both 'TMPL_PE32' and 'TMPL_PEV86' are defined."
    157  %endif
    158  %ifdef TMPL_PP16
    159   %error "Both 'TMPL_PE32' and 'TMPL_PP16' are defined."
    160  %endif
    161  %ifdef TMPL_PP32
    162   %error "Both 'TMPL_PE32' and 'TMPL_PP32' are defined."
    163  %endif
    164  %ifdef TMPL_PPV86
    165   %error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    166  %endif
    167  %ifdef TMPL_PAE16
    168   %error "Both 'TMPL_PE32' and 'TMPL_PAE16' are defined."
    169  %endif
    170  %ifdef TMPL_PAE32
    171   %error "Both 'TMPL_PE32' and 'TMPL_PAE32' are defined."
    172  %endif
    173  %ifdef TMPL_PAE86
    174   %error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    175  %endif
    176  %ifdef TMPL_LM16
    177   %error "Both 'TMPL_PE32' and 'TMPL_LM16' are defined."
    178  %endif
    179  %ifdef TMPL_LM32
    180   %error "Both 'TMPL_PE32' and 'TMPL_LM32' are defined."
    181  %endif
    182  %ifdef TMPL_LM64
    183   %error "Both 'TMPL_PE32' and 'TMPL_LM64' are defined."
    184  %endif
    185  %define TMPL_CMN_PE
    186  %define TMPL_CMN_P32
    187  %define TMPL_32BIT
    188  %define TMPL_BITS              32
    189  %define TMPL_PTR_DEF           dd
    190  %define TMPL_NM(Name)          Name %+ _pe32
    191  %define TMPL_NM_CMN(Name)      Name %+ _p32
    192  %define TMPL_MODE_STR          '32-bit unpaged protected mode'
    193 %endif
    194 
    195 %ifdef TMPL_PEV86
    196  %ifdef TMPL_RM
    197   %error "Both 'TMPL_PEV86' and 'TMPL_RM' are defined."
    198  %endif
    199  %ifdef TMPL_PE16
    200   %error "Both 'TMPL_PEV86' and 'TMPL_PE16' are defined."
    201  %endif
    202  %ifdef TMPL_PP32
    203   %error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    204  %endif
    205  %ifdef TMPL_PP16
    206   %error "Both 'TMPL_PEV86' and 'TMPL_PP16' are defined."
    207  %endif
    208  %ifdef TMPL_PP32
    209   %error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    210  %endif
    211  %ifdef TMPL_PPV86
    212   %error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    213  %endif
    214  %ifdef TMPL_PAE16
    215   %error "Both 'TMPL_PEV86' and 'TMPL_PAE16' are defined."
    216  %endif
    217  %ifdef TMPL_PAE32
    218   %error "Both 'TMPL_PEV86' and 'TMPL_PAE32' are defined."
    219  %endif
    220  %ifdef TMPL_PAE86
    221   %error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    222  %endif
    223  %ifdef TMPL_LM16
    224   %error "Both 'TMPL_PEV86' and 'TMPL_LM16' are defined."
    225  %endif
    226  %ifdef TMPL_LM32
    227   %error "Both 'TMPL_PEV86' and 'TMPL_LM32' are defined."
    228  %endif
    229  %ifdef TMPL_LM64
    230   %error "Both 'TMPL_PEV86' and 'TMPL_LM64' are defined."
    231  %endif
    232  %define TMPL_CMN_PE
    233  %define TMPL_CMN_V86
    234  %define TMPL_CMN_R86
    235  %define TMPL_16BIT
    236  %define TMPL_BITS              16
    237  %define TMPL_PTR_DEF           dw
    238  %define TMPL_NM(Name)          Name %+ _pev86
    239  %define TMPL_NM_CMN(Name)      Name %+ _r86
    240  %define TMPL_MODE_STR          'v8086 unpaged protected mode'
    241 %endif
    242 
    243 %ifdef TMPL_PP16
    244  %ifdef TMPL_RM
    245   %error "Both 'TMPL_PP16' and 'TMPL_RM' are defined."
    246  %endif
    247  %ifdef TMPL_PE16
    248   %error "Both 'TMPL_PP16' and 'TMPL_PE16' are defined."
    249  %endif
    250  %ifdef TMPL_PE32
    251   %error "Both 'TMPL_PP16' and 'TMPL_PE32' are defined."
    252  %endif
    253  %ifdef TMPL_PEV86
    254   %error "Both 'TMPL_PP16' and 'TMPL_PEV86' are defined."
    255  %endif
    256  %ifdef TMPL_PP32
    257   %error "Both 'TMPL_PP16' and 'TMPL_PP32' are defined."
    258  %endif
    259  %ifdef TMPL_PPV86
    260   %error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    261  %endif
    262  %ifdef TMPL_PAE16
    263   %error "Both 'TMPL_PP16' and 'TMPL_PAE16' are defined."
    264  %endif
    265  %ifdef TMPL_PAE32
    266   %error "Both 'TMPL_PP16' and 'TMPL_PAE32' are defined."
    267  %endif
    268  %ifdef TMPL_PAEV86
    269   %error "Both 'TMPL_PP16' and 'TMPL_PAEV86' are defined."
    270  %endif
    271  %ifdef TMPL_LM16
    272   %error "Both 'TMPL_PP16' and 'TMPL_LM16' are defined."
    273  %endif
    274  %ifdef TMPL_LM32
    275   %error "Both 'TMPL_PP16' and 'TMPL_LM32' are defined."
    276  %endif
    277  %ifdef TMPL_LM64
    278   %error "Both 'TMPL_PP16' and 'TMPL_LM64' are defined."
    279  %endif
    280  %define TMPL_CMN_PP
    281  %define TMPL_CMN_P16
    282  %define TMPL_16BIT
    283  %define TMPL_BITS              16
    284  %define TMPL_PTR_DEF           dw
    285  %define TMPL_NM(Name)          Name %+ _pp16
    286  %define TMPL_NM_CMN(Name)      Name %+ _p16
    287  %define TMPL_MODE_STR          '16-bit paged protected mode'
    288 %endif
    289 
    290 %ifdef TMPL_PP32
    291  %ifdef TMPL_RM
    292   %error "Both 'TMPL_PP32' and 'TMPL_RM' are defined."
    293  %endif
    294  %ifdef TMPL_PE16
    295   %error "Both 'TMPL_PP32' and 'TMPL_PE16' are defined."
    296  %endif
    297  %ifdef TMPL_PE32
    298   %error "Both 'TMPL_PP32' and 'TMPL_PE32' are defined."
    299  %endif
    300  %ifdef TMPL_PEV86
    301   %error "Both 'TMPL_PP32' and 'TMPL_PEV86' are defined."
    302  %endif
    303  %ifdef TMPL_PP16
    304   %error "Both 'TMPL_PP32' and 'TMPL_PP16' are defined."
    305  %endif
    306  %ifdef TMPL_PPV86
    307   %error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    308  %endif
    309  %ifdef TMPL_PAE16
    310   %error "Both 'TMPL_PP32' and 'TMPL_PAE16' are defined."
    311  %endif
    312  %ifdef TMPL_PAE32
    313   %error "Both 'TMPL_PP32' and 'TMPL_PAE32' are defined."
    314  %endif
    315  %ifdef TMPL_PAEV86
    316   %error "Both 'TMPL_PP32' and 'TMPL_PAEV86' are defined."
    317  %endif
    318  %ifdef TMPL_LM16
    319   %error "Both 'TMPL_PP32' and 'TMPL_LM16' are defined."
    320  %endif
    321  %ifdef TMPL_LM32
    322   %error "Both 'TMPL_PP32' and 'TMPL_LM32' are defined."
    323  %endif
    324  %ifdef TMPL_LM64
    325   %error "Both 'TMPL_PP32' and 'TMPL_LM64' are defined."
    326  %endif
    327  %define TMPL_CMN_PP
    328  %define TMPL_CMN_P32
    329  %define TMPL_32BIT
    330  %define TMPL_BITS              32
    331  %define TMPL_PTR_DEF           dd
    332  %define TMPL_NM(Name)          Name %+ _pp32
    333  %define TMPL_NM_CMN(Name)      Name %+ _p32
    334  %define TMPL_MODE_STR          '32-bit paged protected mode'
    335 %endif
    336 
    337 %ifdef TMPL_PPV86
    338  %ifdef TMPL_RM
    339   %error "Both 'TMPL_PPV86' and 'TMPL_RM' are defined."
    340  %endif
    341  %ifdef TMPL_PE16
    342   %error "Both 'TMPL_PPV86' and 'TMPL_PE16' are defined."
    343  %endif
    344  %ifdef TMPL_PE32
    345   %error "Both 'TMPL_PPV86' and 'TMPL_PE32' are defined."
    346  %endif
    347  %ifdef TMPL_PEV86
    348   %error "Both 'TMPL_PPV86' and 'TMPL_PEV86' are defined."
    349  %endif
    350  %ifdef TMPL_PP16
    351   %error "Both 'TMPL_PPV86' and 'TMPL_PP16' are defined."
    352  %endif
    353  %ifdef TMPL_PP32
    354   %error "Both 'TMPL_PPV86' and 'TMPL_PP32' are defined."
    355  %endif
    356  %ifdef TMPL_PAE16
    357   %error "Both 'TMPL_PPV86' and 'TMPL_PAE16' are defined."
    358  %endif
    359  %ifdef TMPL_PAE32
    360   %error "Both 'TMPL_PPV86' and 'TMPL_PAE32' are defined."
    361  %endif
    362  %ifdef TMPL_PAEV86
    363   %error "Both 'TMPL_PPV86' and 'TMPL_PAEV86' are defined."
    364  %endif
    365  %ifdef TMPL_LM16
    366   %error "Both 'TMPL_PPV86' and 'TMPL_LM16' are defined."
    367  %endif
    368  %ifdef TMPL_LM32
    369   %error "Both 'TMPL_PPV86' and 'TMPL_LM32' are defined."
    370  %endif
    371  %ifdef TMPL_LM64
    372   %error "Both 'TMPL_PPV86' and 'TMPL_LM64' are defined."
    373  %endif
    374  %define TMPL_CMN_PP
    375  %define TMPL_CMN_V86
    376  %define TMPL_CMN_R86
    377  %define TMPL_16BIT
    378  %define TMPL_BITS              16
    379  %define TMPL_PTR_DEF           dw
    380  %define TMPL_NM(Name)          Name %+ _ppv86
    381  %define TMPL_NM_CMN(Name)      Name %+ _r86
    382  %define TMPL_MODE_STR          'v8086 paged protected mode'
    383 %endif
    384 
    385 %ifdef TMPL_PAE16
    386  %ifdef TMPL_RM
    387   %error "Both 'TMPL_PAE16' and 'TMPL_RM' are defined."
    388  %endif
    389  %ifdef TMPL_PE16
    390   %error "Both 'TMPL_PAE16' and 'TMPL_PE16' are defined."
    391  %endif
    392  %ifdef TMPL_PE32
    393   %error "Both 'TMPL_PAE16' and 'TMPL_PE32' are defined."
    394  %endif
    395  %ifdef TMPL_PEV86
    396   %error "Both 'TMPL_PAE16' and 'TMPL_PEV86' are defined."
    397  %endif
    398  %ifdef TMPL_PP16
    399   %error "Both 'TMPL_PAE16' and 'TMPL_PP16' are defined."
    400  %endif
    401  %ifdef TMPL_PP32
    402   %error "Both 'TMPL_PAE16' and 'TMPL_PP32' are defined."
    403  %endif
    404  %ifdef TMPL_PPV86
    405   %error "Both 'TMPL_PAE16' and 'TMPL_PPV86' are defined."
    406  %endif
    407  %ifdef TMPL_PAE32
    408   %error "Both 'TMPL_PAE16' and 'TMPL_PAE32' are defined."
    409  %endif
    410  %ifdef TMPL_LM16
    411   %error "Both 'TMPL_PAE16' and 'TMPL_LM16' are defined."
    412  %endif
    413  %ifdef TMPL_PAEV86
    414   %error "Both 'TMPL_PAE16' and 'TMPL_PAEV86' are defined."
    415  %endif
    416  %ifdef TMPL_LM32
    417   %error "Both 'TMPL_PAE16' and 'TMPL_LM32' are defined."
    418  %endif
    419  %ifdef TMPL_LM64
    420   %error "Both 'TMPL_PAE16' and 'TMPL_LM64' are defined."
    421  %endif
    422  %define TMPL_CMN_PAE
    423  %define TMPL_16BIT
    424  %define TMPL_CMN_P16
    425  %define TMPL_BITS              16
    426  %define TMPL_PTR_DEF           dw
    427  %define TMPL_NM(Name)          Name %+ _pae16
    428  %define TMPL_NM_CMN(Name)      Name %+ _p16
    429  %define TMPL_MODE_STR          '16-bit pae protected mode'
    430 %endif
    431 
    432 %ifdef TMPL_PAE32
    433  %ifdef TMPL_RM
    434   %error "Both 'TMPL_PAE32' and 'TMPL_RM' are defined."
    435  %endif
    436  %ifdef TMPL_PE16
    437   %error "Both 'TMPL_PAE32' and 'TMPL_PE16' are defined."
    438  %endif
    439  %ifdef TMPL_PE32
    440   %error "Both 'TMPL_PAE32' and 'TMPL_PE32' are defined."
    441  %endif
    442  %ifdef TMPL_PEV86
    443   %error "Both 'TMPL_PAE32' and 'TMPL_PEV86' are defined."
    444  %endif
    445  %ifdef TMPL_PP16
    446   %error "Both 'TMPL_PAE32' and 'TMPL_PP16' are defined."
    447  %endif
    448  %ifdef TMPL_PP32
    449   %error "Both 'TMPL_PAE32' and 'TMPL_PP32' are defined."
    450  %endif
    451  %ifdef TMPL_PPV86
    452   %error "Both 'TMPL_PAE32' and 'TMPL_PPV86' are defined."
    453  %endif
    454  %ifdef TMPL_PAE16
    455   %error "Both 'TMPL_PAE32' and 'TMPL_PAE16' are defined."
    456  %endif
    457  %ifdef TMPL_PAEV86
    458   %error "Both 'TMPL_PAE32' and 'TMPL_PAEV86' are defined."
    459  %endif
    460  %ifdef TMPL_LM16
    461   %error "Both 'TMPL_PAE32' and 'TMPL_LM16' are defined."
    462  %endif
    463  %ifdef TMPL_LM32
    464   %error "Both 'TMPL_PAE32' and 'TMPL_LM32' are defined."
    465  %endif
    466  %ifdef TMPL_LM64
    467   %error "Both 'TMPL_PAE32' and 'TMPL_LM64' are defined."
    468  %endif
    469  %define TMPL_CMN_PAE
    470  %define TMPL_CMN_P32
    471  %define TMPL_32BIT
    472  %define TMPL_BITS              32
    473  %define TMPL_PTR_DEF           dd
    474  %define TMPL_NM(Name)          Name %+ _pae32
    475  %define TMPL_NM_CMN(Name)      Name %+ _p32
    476  %define TMPL_MODE_STR          '32-bit pae protected mode'
    477 %endif
    478 
    479 %ifdef TMPL_PAEV86
    480  %ifdef TMPL_RM
    481   %error "Both 'TMPL_PAEV86' and 'TMPL_RM' are defined."
    482  %endif
    483  %ifdef TMPL_PE16
    484   %error "Both 'TMPL_PAEV86' and 'TMPL_PE16' are defined."
    485  %endif
    486  %ifdef TMPL_PE32
    487   %error "Both 'TMPL_PAEV86' and 'TMPL_PE32' are defined."
    488  %endif
    489  %ifdef TMPL_PEV86
    490   %error "Both 'TMPL_PAEV86' and 'TMPL_PEV86' are defined."
    491  %endif
    492  %ifdef TMPL_PP16
    493   %error "Both 'TMPL_PAEV86' and 'TMPL_PP16' are defined."
    494  %endif
    495  %ifdef TMPL_PP32
    496   %error "Both 'TMPL_PAEV86' and 'TMPL_PP32' are defined."
    497  %endif
    498  %ifdef TMPL_PPV86
    499   %error "Both 'TMPL_PAEV86' and 'TMPL_PPV86' are defined."
    500  %endif
    501  %ifdef TMPL_PAE16
    502   %error "Both 'TMPL_PAEV86' and 'TMPL_PAE16' are defined."
    503  %endif
    504  %ifdef TMPL_PAEV86
    505   %error "Both 'TMPL_PAEV86' and 'TMPL_PAEV86' are defined."
    506  %endif
    507  %ifdef TMPL_LM16
    508   %error "Both 'TMPL_PAEV86' and 'TMPL_LM16' are defined."
    509  %endif
    510  %ifdef TMPL_LM32
    511   %error "Both 'TMPL_PAEV86' and 'TMPL_LM32' are defined."
    512  %endif
    513  %ifdef TMPL_LM64
    514   %error "Both 'TMPL_PAEV86' and 'TMPL_LM64' are defined."
    515  %endif
    516  %define TMPL_CMN_PAE
    517  %define TMPL_CMN_V86
    518  %define TMPL_CMN_R86
    519  %define TMPL_16BIT
    520  %define TMPL_BITS              16
    521  %define TMPL_PTR_DEF           dw
    522  %define TMPL_NM(Name)          Name %+ _paev86
    523  %define TMPL_NM_CMN(Name)      Name %+ _r86
    524  %define TMPL_MODE_STR          'v8086 pae protected mode'
    525 %endif
    526 
    527 %ifdef TMPL_LM16
    528  %ifdef TMPL_RM
    529   %error "Both 'TMPL_LM16' and 'TMPL_RM' are defined."
    530  %endif
    531  %ifdef TMPL_PE16
    532   %error "Both 'TMPL_LM16' and 'TMPL_PE16' are defined."
    533  %endif
    534  %ifdef TMPL_PE32
    535   %error "Both 'TMPL_LM16' and 'TMPL_PE32' are defined."
    536  %endif
    537  %ifdef TMPL_PEV86
    538   %error "Both 'TMPL_LM16' and 'TMPL_PEV86' are defined."
    539  %endif
    540  %ifdef TMPL_PP16
    541   %error "Both 'TMPL_LM16' and 'TMPL_PP16' are defined."
    542  %endif
    543  %ifdef TMPL_PP32
    544   %error "Both 'TMPL_LM16' and 'TMPL_PP32' are defined."
    545  %endif
    546  %ifdef TMPL_PPV86
    547   %error "Both 'TMPL_LM16' and 'TMPL_PPV86' are defined."
    548  %endif
    549  %ifdef TMPL_PAE16
    550   %error "Both 'TMPL_LM16' and 'TMPL_PAE16' are defined."
    551  %endif
    552  %ifdef TMPL_PAE32
    553   %error "Both 'TMPL_LM16' and 'TMPL_PAE32' are defined."
    554  %endif
    555  %ifdef TMPL_PAEV86
    556   %error "Both 'TMPL_LM16' and 'TMPL_PAEV86' are defined."
    557  %endif
    558  %ifdef TMPL_LM32
    559   %error "Both 'TMPL_LM16' and 'TMPL_LM32' are defined."
    560  %endif
    561  %ifdef TMPL_LM64
    562   %error "Both 'TMPL_LM16' and 'TMPL_LM64' are defined."
    563  %endif
    564  %define TMPL_CMN_LM
    565  %define TMPL_CMN_P16
    566  %define TMPL_16BIT
    567  %define TMPL_BITS              16
    568  %define TMPL_PTR_DEF           dw
    569  %define TMPL_NM(Name)          Name %+ _lm16
    570  %define TMPL_NM_CMN(Name)      Name %+ _p16
    571  %define TMPL_MODE_STR          '16-bit long mode'
    572 %endif
    573 
    574 %ifdef TMPL_LM32
    575  %ifdef TMPL_RM
    576   %error "Both 'TMPL_LM32' and 'TMPL_RM' are defined."
    577  %endif
    578  %ifdef TMPL_PE16
    579   %error "Both 'TMPL_LM32' and 'TMPL_PE16' are defined."
    580  %endif
    581  %ifdef TMPL_PE32
    582   %error "Both 'TMPL_LM32' and 'TMPL_PE32' are defined."
    583  %endif
    584  %ifdef TMPL_PEV86
    585   %error "Both 'TMPL_LM32' and 'TMPL_PEV86' are defined."
    586  %endif
    587  %ifdef TMPL_PP16
    588   %error "Both 'TMPL_LM32' and 'TMPL_PP16' are defined."
    589  %endif
    590  %ifdef TMPL_PP32
    591   %error "Both 'TMPL_LM32' and 'TMPL_PP32' are defined."
    592  %endif
    593  %ifdef TMPL_PPV86
    594   %error "Both 'TMPL_LM32' and 'TMPL_PPV86' are defined."
    595  %endif
    596  %ifdef TMPL_PAE16
    597   %error "Both 'TMPL_LM32' and 'TMPL_PAE16' are defined."
    598  %endif
    599  %ifdef TMPL_PAE32
    600   %error "Both 'TMPL_LM32' and 'TMPL_PAE32' are defined."
    601  %endif
    602  %ifdef TMPL_PAEV86
    603   %error "Both 'TMPL_LM32' and 'TMPL_PAEV86' are defined."
    604  %endif
    605  %ifdef TMPL_LM16
    606   %error "Both 'TMPL_LM32' and 'TMPL_LM16' are defined."
    607  %endif
    608  %ifdef TMPL_LM64
    609   %error "Both 'TMPL_LM32' and 'TMPL_LM64' are defined."
    610  %endif
    611  %define TMPL_CMN_LM
    612  %define TMPL_CMN_P32
    613  %define TMPL_32BIT
    614  %define TMPL_BITS              32
    615  %define TMPL_PTR_DEF           dd
    616  %define TMPL_NM(Name)          Name %+ _lm32
    617  %define TMPL_NM_CMN(Name)      Name %+ _p32
    618  %define TMPL_MODE_STR          '32-bit long mode'
    619 %endif
    620 
    621 %ifdef TMPL_LM64
    622  %ifdef TMPL_RM
    623   %error ""Both 'TMPL_LM64' and 'TMPL_RM' are defined.""
    624  %endif
    625  %ifdef TMPL_PE16
    626   %error "Both 'TMPL_LM64' and 'TMPL_PE16' are defined."
    627  %endif
    628  %ifdef TMPL_PE32
    629   %error "Both 'TMPL_LM64' and 'TMPL_PE32' are defined."
    630  %endif
    631  %ifdef TMPL_PEV86
    632   %error "Both 'TMPL_LM64' and 'TMPL_PEV86' are defined."
    633  %endif
    634  %ifdef TMPL_PP16
    635   %error "Both 'TMPL_LM64' and 'TMPL_PP16' are defined."
    636  %endif
    637  %ifdef TMPL_PP32
    638   %error "Both 'TMPL_LM64' and 'TMPL_PP32' are defined."
    639  %endif
    640  %ifdef TMPL_PPV86
    641   %error "Both 'TMPL_LM64' and 'TMPL_PPV86' are defined."
    642  %endif
    643  %ifdef TMPL_PAE16
    644   %error "Both 'TMPL_LM64' and 'TMPL_PAE16' are defined."
    645  %endif
    646  %ifdef TMPL_PAE32
    647   %error "Both 'TMPL_LM64' and 'TMPL_PAE32' are defined."
    648  %endif
    649  %ifdef TMPL_PAEV86
    650   %error "Both 'TMPL_LM64' and 'TMPL_PAEV86' are defined."
    651  %endif
    652  %ifdef TMPL_LM16
    653   %error "Both 'TMPL_LM64' and 'TMPL_LM16' are defined."
    654  %endif
    655  %ifdef TMPL_LM32
    656   %error "Both 'TMPL_LM64' and 'TMPL_LM32' are defined."
    657  %endif
    658  %define TMPL_CMN_LM
    659  %define TMPL_CMN_P64
    660  %define TMPL_64BIT
    661  %define TMPL_BITS              64
    662  %define TMPL_PTR_DEF           dq
    663  %define TMPL_NM(Name)          Name %+ _lm64
    664  %define TMPL_NM_CMN(Name)      Name %+ _p64
    665  %define TMPL_MODE_STR          '64-bit long mode'
    666 %endif
    667 
    668 %ifndef TMPL_MODE_STR
    669  %error "internal error"
    670 %endif
    671 
    672 
    673 ;
    674 ; Preferred spelling of TMPL_NM_CMN in BS3.
    675 ;
    676 %define TMPL_CMN_NM(Name)      TMPL_NM_CMN(Name)
    677 
    678 
    679 ;
    680 ; Register aliases.
    681 ;
    682 %ifdef TMPL_64BIT
    683  %define xCB  8
    684  %define xDEF dq
    685  %define xRES resq
    686  %define xPRE qword
    687  %define xSP  rsp
    688  %define xBP  rbp
    689  %define xAX  rax
    690  %define xBX  rbx
    691  %define xCX  rcx
    692  %define xDX  rdx
    693  %define xDI  rdi
    694  %define xSI  rsi
    695  %define xWrtRIP wrt rip
    696  %define xPUSHF pushq
    697  %define xPOPF  popfq
    698 %else
    699  %ifdef TMPL_32BIT
    700   %define xCB  4
    701   %define xDEF dd
    702   %define xRES resd
    703   %define xPRE dword
    704   %define xSP  esp
    705   %define xBP  ebp
    706   %define xAX  eax
    707   %define xBX  ebx
    708   %define xCX  ecx
    709   %define xDX  edx
    710   %define xDI  edi
    711   %define xSI  esi
    712   %define xWrtRIP
    713   %define xPUSHF pushfd
    714   %define xPOPF  popfd
    715  %else
    716   %ifndef TMPL_16BIT
    717    %error "TMPL_XXBIT is not defined."
    718   %endif
    719   %define xCB  2
    720   %define xDEF dw
    721   %define xRES resw
    722   %define xPRE word
    723   %define xSP  sp
    724   %define xBP  bp
    725   %define xAX  ax
    726   %define xBX  bx
    727   %define xCX  cx
    728   %define xDX  dx
    729   %define xDI  di
    730   %define xSI  si
    731   %define xWrtRIP
    732   %define xPUSHF pushf
    733   %define xPOPF  popf
    734  %endif
    735 %endif
    736 
    737 ;
    738 ; Register names corresponding to the max size for pop/push <reg>.
    739 ;
    740 ; 16-bit can push both 32-bit and 16-bit registers.  This 's' prefixed variant
    741 ; is used when 16-bit should use the 32-bit register.
    742 ;
    743 %ifdef TMPL_64BIT
    744  %define sCB  8
    745  %define sDEF dq
    746  %define sRES resq
    747  %define sPRE qword
    748  %define sSP  rsp
    749  %define sBP  rbp
    750  %define sAX  rax
    751  %define sBX  rbx
    752  %define sCX  rcx
    753  %define sDX  rdx
    754  %define sDI  rdi
    755  %define sSI  rsi
    756  %define sPUSHF pushfq
    757  %define sPOPF  popfq
    758 %else
    759  %define sCB  4
    760  %define sDEF dd
    761  %define sRES resd
    762  %define sPRE dword
    763  %define sSP  esp
    764  %define sBP  ebp
    765  %define sAX  eax
    766  %define sBX  ebx
    767  %define sCX  ecx
    768  %define sDX  edx
    769  %define sDI  edi
    770  %define sSI  esi
    771  %define sPUSHF pushfd
    772  %define sPOPF  popfd
    773 %endif
    774 
    775 ;
    776 ; Default code segment.
    777 ;
    778 %ifdef TMPL_64BIT
    779  %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT64
    780 %elifdef TMPL_32BIT
    781  %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT32
    782 %elifdef TMPL_16BIT
    783  %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT16
    784 %else
    785  %error "Missing TMPL_xxBIT!"
    786 %endif
    787 TMPL_BEGIN_TEXT
    788 
    789 ;
    790 ; Change the bitness.
    791 ;
    792 %ifdef TMPL_64BIT
    793 BITS 64
    794 %else
    795  %ifdef TMPL_32BIT
    796 BITS 32
    797  %else
    798 BITS 16
    799  %endif
    800 %endif
    801 
     1/* $Id$ */
     2/** @file
     3 * BS3Kit header for multi-mode code templates.
     4 */
     5
     6/*
     7 * Copyright (C) 2007-2015 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#include "bs3kit.mac"
     28
     29/** @defgroup grp_bs3kit_tmpl       BS3Kit Multi-Mode Code Templates
     30 * @ingroup grp_bs3kit
     31 *
     32 * Multi-mode code templates avoid duplicating code for each of the CPU modes.
     33 * Instead the code is compiled multiple times, either via multiple inclusions
     34 * into a source files with different mode selectors defined or by multiple
     35 * compiler invocations.
     36 *
     37 * In C/C++ code we're restricted to the compiler target bit count, whereas in
     38 * assembly we can do everything in assembler run (with some 64-bit
     39 * restrictions, that is).
     40 *
     41 * Before \#defining the next mode selector and including
     42 * bs3kit-template-header.h again, include bs3kit-template-footer.h to undefine
     43 * all the previous mode selectors and the macros defined by the header.
     44 *
     45 * @{
     46 */
     47
     48#ifdef DOXYGEN_RUNNING
     49/** @name Template mode selectors.
     50 *
     51 * Exactly one of these are defined by the file including the
     52 * bs3kit-template-header.h header file.  When building the code libraries, the
     53 * kBuild target defines this.
     54 *
     55 * @{ */
     56# define TMPL_RM     /**< real mode. */
     57# define TMPL_PE16   /**< 16-bit protected mode, unpaged. */
     58# define TMPL_PE32   /**< 32-bit protected mode, unpaged. */
     59# define TMPL_PEV86  /**< virtual 8086 mode under protected mode, unpaged. */
     60# define TMPL_PP16   /**< 16-bit protected mode, paged. */
     61# define TMPL_PP32   /**< 32-bit protected mode, paged. */
     62# define TMPL_PPV86  /**< virtual 8086 mode under protected mode, paged. */
     63# define TMPL_PAE16  /**< 16-bit protected mode with PAE (paged). */
     64# define TMPL_PAE32  /**< 16-bit protected mode with PAE (paged). */
     65# define TMPL_PAEV86 /**< virtual 8086 mode under protected mode with PAE (paged). */
     66# define TMPL_LM16   /**< 16-bit long mode (paged). */
     67# define TMPL_LM32   /**< 32-bit long mode (paged). */
     68# define TMPL_LM64   /**< 64-bit long mode (paged). */
     69/** @} */
     70
     71/** @name Derived Indicators
     72 * @{ */
     73# define TMPL_CMN_PE    /**< TMPL_PE16  | TMPL_PE32  | TMPL_PEV86  */
     74# define TMPL_CMN_PP    /**< TMPL_PP16  | TMPL_PP32  | TMPL_PPV86  */
     75# define TMPL_CMN_PAE   /**< TMPL_PAE16 | TMPL_PAE32 | TMPL_PAEV86 */
     76# define TMPL_CMN_LM    /**< TMPL_LM16  | TMPL_LM32  | TMPL_LM64   */
     77# define TMPL_CMN_V86   /**< TMPL_PEV86 | TMPL_PPV86 | TMPL_PAEV86 */
     78# define TMPL_CMN_R86   /**< TMPL_CMN_V86 | TMPL_RM                */
     79/** @} */
     80
     81/** @def TMPL_NM
     82 * Name mangling macro for the current mode.
     83 *
     84 * Example: TMPL_NM(PrintChr)
     85 *
     86 * @param   Name        The function or variable name to mangle.
     87 */
     88# define TMPL_NM(Name)  RT_CONCAT(Name,_mode)
     89
     90/** @def TMPL_MODE_STR
     91 * Short mode description. */
     92# define TMPL_MODE_STR
     93
     94/** @def TMPL_HAVE_BIOS
     95 * Indicates that we have direct access to the BIOS (only in real mode). */
     96# define TMPL_HAVE_BIOS
     97
     98
     99/** @name For ASM compatability
     100 * @{ */
     101/** @def TMPL_16BIT
     102 * For ASM compatibility - please use ARCH_BITS == 16. */
     103# define TMPL_16BIT
     104/** @def TMPL_32BIT
     105 * For ASM compatibility - please use ARCH_BITS == 32. */
     106# define TMPL_32BIT
     107/** @def TMPL_64BIT
     108 * For ASM compatibility - please use ARCH_BITS == 64. */
     109# define TMPL_64BIT
     110
     111/** @def TMPL_BITS
     112 * For ASM compatibility - please use ARCH_BITS instead. */
     113# define TMPL_BITS  ARCH_BITS
     114/** @} */
     115
     116#else /* !DOXYGEN_RUNNING */
     117
     118#ifdef TMPL_RM
     119# ifdef TMPL_PE16
     120#  error "Both 'TMPL_RM' and 'TMPL_PE16' are defined."
     121# endif
     122# ifdef TMPL_PE32
     123#  error "Both 'TMPL_RM' and 'TMPL_PE32' are defined."
     124# endif
     125# ifdef TMPL_PEV86
     126#  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
     127# endif
     128# ifdef TMPL_PP16
     129#  error "Both 'TMPL_RM' and 'TMPL_PP16' are defined."
     130# endif
     131# ifdef TMPL_PP32
     132#  error "Both 'TMPL_RM' and 'TMPL_PP32' are defined."
     133# endif
     134# ifdef TMPL_PPV86
     135#  error "Both 'TMPL_RM' and 'TMPL_PPV86' are defined."
     136# endif
     137# ifdef TMPL_PAE16
     138#  error "Both 'TMPL_RM' and 'TMPL_PAE16' are defined."
     139# endif
     140# ifdef TMPL_PAE32
     141#  error "Both 'TMPL_RM' and 'TMPL_PAE32' are defined."
     142# endif
     143# ifdef TMPL_PAEV86
     144#  error "Both 'TMPL_RM' and 'TMPL_PAEV86' are defined."
     145# endif
     146# ifdef TMPL_LM16
     147#  error "Both 'TMPL_RM' and 'TMPL_LM16' are defined."
     148# endif
     149# ifdef TMPL_LM32
     150#  error "Both 'TMPL_RM' and 'TMPL_LM32' are defined."
     151# endif
     152# ifdef TMPL_LM64
     153#  error "Both 'TMPL_RM' and 'TMPL_LM64' are defined."
     154# endif
     155# if ARCH_BITS != 16
     156#  error "TMPL_RM requires ARCH_BITS to be 16."
     157# endif
     158# define TMPL_16BIT
     159# define TMPL_BITS              16
     160# define TMPL_NM(Name)          RT_CONCAT(Name,_rm)
     161# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     162# define TMPL_MODE_STR          "real mode"
     163# define TMPL_HAVE_BIOS
     164# define TMPL_CMN_R86
     165#endif
     166
     167#ifdef TMPL_PE16
     168# ifdef TMPL_RM
     169#  error "Both 'TMPL_PE16' and 'TMPL_RM' are defined."
     170# endif
     171# ifdef TMPL_PE32
     172#  error "Both 'TMPL_PE16' and 'TMPL_PE32' are defined."
     173# endif
     174# ifdef TMPL_PEV86
     175#  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
     176# endif
     177# ifdef TMPL_PP16
     178#  error "Both 'TMPL_PE16' and 'TMPL_PP16' are defined."
     179# endif
     180# ifdef TMPL_PP32
     181#  error "Both 'TMPL_PE16' and 'TMPL_PP32' are defined."
     182# endif
     183# ifdef TMPL_PPV86
     184#  error "Both 'TMPL_PE16' and 'TMPL_PPV86' are defined."
     185# endif
     186# ifdef TMPL_PAE16
     187#  error "Both 'TMPL_PE16' and 'TMPL_PAE16' are defined."
     188# endif
     189# ifdef TMPL_PAE32
     190#  error "Both 'TMPL_PE16' and 'TMPL_PAE32' are defined."
     191# endif
     192# ifdef TMPL_PAEV86
     193#  error "Both 'TMPL_PE32' and 'TMPL_PAEV86' are defined."
     194# endif
     195# ifdef TMPL_LM16
     196#  error "Both 'TMPL_PE16' and 'TMPL_LM16' are defined."
     197# endif
     198# ifdef TMPL_LM32
     199#  error "Both 'TMPL_PE16' and 'TMPL_LM32' are defined."
     200# endif
     201# ifdef TMPL_LM64
     202#  error "Both 'TMPL_PE16' and 'TMPL_LM64' are defined."
     203# endif
     204# if ARCH_BITS != 16
     205#  error "TMPL_PE16 requires ARCH_BITS to be 16."
     206# endif
     207# define TMPL_CMN_PE
     208# define TMPL_CMN_P16
     209# define TMPL_16BIT
     210# define TMPL_BITS              16
     211# define TMPL_NM(Name)          RT_CONCAT(Name,_pe16)
     212# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     213# define TMPL_MODE_STR          "16-bit unpaged protected mode"
     214#endif
     215
     216#ifdef TMPL_PE32
     217# ifdef TMPL_RM
     218#  error "Both 'TMPL_PE32' and 'TMPL_RM' are defined."
     219# endif
     220# ifdef TMPL_PE16
     221#  error "Both 'TMPL_PE32' and 'TMPL_PE16' are defined."
     222# endif
     223# ifdef TMPL_PEV86
     224#  error "Both 'TMPL_PE32' and 'TMPL_PEV86' are defined."
     225# endif
     226# ifdef TMPL_PP16
     227#  error "Both 'TMPL_PE32' and 'TMPL_PP16' are defined."
     228# endif
     229# ifdef TMPL_PP32
     230#  error "Both 'TMPL_PE32' and 'TMPL_PP32' are defined."
     231# endif
     232# ifdef TMPL_PPV86
     233#  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
     234# endif
     235# ifdef TMPL_PAE16
     236#  error "Both 'TMPL_PE32' and 'TMPL_PAE16' are defined."
     237# endif
     238# ifdef TMPL_PAE32
     239#  error "Both 'TMPL_PE32' and 'TMPL_PAE32' are defined."
     240# endif
     241# ifdef TMPL_PAE86
     242#  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
     243# endif
     244# ifdef TMPL_LM16
     245#  error "Both 'TMPL_PE32' and 'TMPL_LM16' are defined."
     246# endif
     247# ifdef TMPL_LM32
     248#  error "Both 'TMPL_PE32' and 'TMPL_LM32' are defined."
     249# endif
     250# ifdef TMPL_LM64
     251#  error "Both 'TMPL_PE32' and 'TMPL_LM64' are defined."
     252# endif
     253# if ARCH_BITS != 32
     254#  error "TMPL_PE32 requires ARCH_BITS to be 32."
     255# endif
     256# define TMPL_CMN_PE
     257# define TMPL_CMN_P32
     258# define TMPL_32BIT
     259# define TMPL_BITS              32
     260# define TMPL_NM(Name)          RT_CONCAT(Name,_pe32)
     261# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
     262# define TMPL_MODE_STR          "32-bit unpaged protected mode"
     263#endif
     264
     265#ifdef TMPL_PEV86
     266# ifdef TMPL_RM
     267#  error "Both 'TMPL_PEV86' and 'TMPL_RM' are defined."
     268# endif
     269# ifdef TMPL_PE16
     270#  error "Both 'TMPL_PEV86' and 'TMPL_PE16' are defined."
     271# endif
     272# ifdef TMPL_PP32
     273#  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
     274# endif
     275# ifdef TMPL_PP16
     276#  error "Both 'TMPL_PEV86' and 'TMPL_PP16' are defined."
     277# endif
     278# ifdef TMPL_PP32
     279#  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
     280# endif
     281# ifdef TMPL_PPV86
     282#  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
     283# endif
     284# ifdef TMPL_PAE16
     285#  error "Both 'TMPL_PEV86' and 'TMPL_PAE16' are defined."
     286# endif
     287# ifdef TMPL_PAE32
     288#  error "Both 'TMPL_PEV86' and 'TMPL_PAE32' are defined."
     289# endif
     290# ifdef TMPL_PAE86
     291#  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
     292# endif
     293# ifdef TMPL_LM16
     294#  error "Both 'TMPL_PEV86' and 'TMPL_LM16' are defined."
     295# endif
     296# ifdef TMPL_LM32
     297#  error "Both 'TMPL_PEV86' and 'TMPL_LM32' are defined."
     298# endif
     299# ifdef TMPL_LM64
     300#  error "Both 'TMPL_PEV86' and 'TMPL_LM64' are defined."
     301# endif
     302# if ARCH_BITS != 16
     303#  error "TMPL_PEV86 requires ARCH_BITS to be 16."
     304# endif
     305# define TMPL_CMN_PE
     306# define TMPL_CMN_V86
     307# define TMPL_CMN_R86
     308# define TMPL_16BIT
     309# define TMPL_BITS              16
     310# define TMPL_NM(Name)          RT_CONCAT(Name,_pev86)
     311# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     312# define TMPL_MODE_STR          "v8086 unpaged protected mode"
     313#endif
     314
     315#ifdef TMPL_PP16
     316# ifdef TMPL_RM
     317#  error "Both 'TMPL_PP16' and 'TMPL_RM' are defined."
     318# endif
     319# ifdef TMPL_PE16
     320#  error "Both 'TMPL_PP16' and 'TMPL_PE16' are defined."
     321# endif
     322# ifdef TMPL_PE32
     323#  error "Both 'TMPL_PP16' and 'TMPL_PE32' are defined."
     324# endif
     325# ifdef TMPL_PEV86
     326#  error "Both 'TMPL_PP16' and 'TMPL_PEV86' are defined."
     327# endif
     328# ifdef TMPL_PP32
     329#  error "Both 'TMPL_PP16' and 'TMPL_PP32' are defined."
     330# endif
     331# ifdef TMPL_PPV86
     332#  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
     333# endif
     334# ifdef TMPL_PAE16
     335#  error "Both 'TMPL_PP16' and 'TMPL_PAE16' are defined."
     336# endif
     337# ifdef TMPL_PAE32
     338#  error "Both 'TMPL_PP16' and 'TMPL_PAE32' are defined."
     339# endif
     340# ifdef TMPL_PAEV86
     341#  error "Both 'TMPL_PP16' and 'TMPL_PAEV86' are defined."
     342# endif
     343# ifdef TMPL_LM16
     344#  error "Both 'TMPL_PP16' and 'TMPL_LM16' are defined."
     345# endif
     346# ifdef TMPL_LM32
     347#  error "Both 'TMPL_PP16' and 'TMPL_LM32' are defined."
     348# endif
     349# ifdef TMPL_LM64
     350#  error "Both 'TMPL_PP16' and 'TMPL_LM64' are defined."
     351# endif
     352# if ARCH_BITS != 16
     353#  error "TMPL_PP16 requires ARCH_BITS to be 16."
     354# endif
     355# define TMPL_CMN_PP
     356# define TMPL_CMN_P16
     357# define TMPL_16BIT
     358# define TMPL_BITS              16
     359# define TMPL_NM(Name)          RT_CONCAT(Name,_pp16)
     360# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     361# define TMPL_MODE_STR          "16-bit paged protected mode"
     362#endif
     363
     364#ifdef TMPL_PP32
     365# ifdef TMPL_RM
     366#  error "Both 'TMPL_PP32' and 'TMPL_RM' are defined."
     367# endif
     368# ifdef TMPL_PE16
     369#  error "Both 'TMPL_PP32' and 'TMPL_PE16' are defined."
     370# endif
     371# ifdef TMPL_PE32
     372#  error "Both 'TMPL_PP32' and 'TMPL_PE32' are defined."
     373# endif
     374# ifdef TMPL_PEV86
     375#  error "Both 'TMPL_PP32' and 'TMPL_PEV86' are defined."
     376# endif
     377# ifdef TMPL_PP16
     378#  error "Both 'TMPL_PP32' and 'TMPL_PP16' are defined."
     379# endif
     380# ifdef TMPL_PPV86
     381#  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
     382# endif
     383# ifdef TMPL_PAE16
     384#  error "Both 'TMPL_PP32' and 'TMPL_PAE16' are defined."
     385# endif
     386# ifdef TMPL_PAE32
     387#  error "Both 'TMPL_PP32' and 'TMPL_PAE32' are defined."
     388# endif
     389# ifdef TMPL_PAEV86
     390#  error "Both 'TMPL_PP32' and 'TMPL_PAEV86' are defined."
     391# endif
     392# ifdef TMPL_LM16
     393#  error "Both 'TMPL_PP32' and 'TMPL_LM16' are defined."
     394# endif
     395# ifdef TMPL_LM32
     396#  error "Both 'TMPL_PP32' and 'TMPL_LM32' are defined."
     397# endif
     398# ifdef TMPL_LM64
     399#  error "Both 'TMPL_PP32' and 'TMPL_LM64' are defined."
     400# endif
     401# if ARCH_BITS != 32
     402#  error "TMPL_PP32 requires ARCH_BITS to be 32."
     403# endif
     404# define TMPL_CMN_PP
     405# define TMPL_CMN_P32
     406# define TMPL_32BIT
     407# define TMPL_BITS              32
     408# define TMPL_NM(Name)          RT_CONCAT(Name,_pp32)
     409# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
     410# define TMPL_MODE_STR          "32-bit paged protected mode"
     411#endif
     412
     413#ifdef TMPL_PPV86
     414# ifdef TMPL_RM
     415#  error "Both 'TMPL_PPV86' and 'TMPL_RM' are defined."
     416# endif
     417# ifdef TMPL_PE16
     418#  error "Both 'TMPL_PPV86' and 'TMPL_PE16' are defined."
     419# endif
     420# ifdef TMPL_PE32
     421#  error "Both 'TMPL_PPV86' and 'TMPL_PE32' are defined."
     422# endif
     423# ifdef TMPL_PEV86
     424#  error "Both 'TMPL_PPV86' and 'TMPL_PEV86' are defined."
     425# endif
     426# ifdef TMPL_PP16
     427#  error "Both 'TMPL_PPV86' and 'TMPL_PP16' are defined."
     428# endif
     429# ifdef TMPL_PP32
     430#  error "Both 'TMPL_PPV86' and 'TMPL_PP32' are defined."
     431# endif
     432# ifdef TMPL_PAE16
     433#  error "Both 'TMPL_PPV86' and 'TMPL_PAE16' are defined."
     434# endif
     435# ifdef TMPL_PAE32
     436#  error "Both 'TMPL_PPV86' and 'TMPL_PAE32' are defined."
     437# endif
     438# ifdef TMPL_PAEV86
     439#  error "Both 'TMPL_PPV86' and 'TMPL_PAEV86' are defined."
     440# endif
     441# ifdef TMPL_LM16
     442#  error "Both 'TMPL_PPV86' and 'TMPL_LM16' are defined."
     443# endif
     444# ifdef TMPL_LM32
     445#  error "Both 'TMPL_PPV86' and 'TMPL_LM32' are defined."
     446# endif
     447# ifdef TMPL_LM64
     448#  error "Both 'TMPL_PPV86' and 'TMPL_LM64' are defined."
     449# endif
     450# if ARCH_BITS != 16
     451#  error "TMPL_PPV86 requires ARCH_BITS to be 16."
     452# endif
     453# define TMPL_CMN_PP
     454# define TMPL_CMN_V86
     455# define TMPL_CMN_R86
     456# define TMPL_16BIT
     457# define TMPL_BITS              16
     458# define TMPL_NM(Name)          RT_CONCAT(Name,_ppv86)
     459# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
     460# define TMPL_MODE_STR          "v8086 paged protected mode"
     461#endif
     462
     463#ifdef TMPL_PAE16
     464# ifdef TMPL_RM
     465#  error "Both 'TMPL_PAE16' and 'TMPL_RM' are defined."
     466# endif
     467# ifdef TMPL_PE16
     468#  error "Both 'TMPL_PAE16' and 'TMPL_PE16' are defined."
     469# endif
     470# ifdef TMPL_PE32
     471#  error "Both 'TMPL_PAE16' and 'TMPL_PE32' are defined."
     472# endif
     473# ifdef TMPL_PEV86
     474#  error "Both 'TMPL_PAE16' and 'TMPL_PEV86' are defined."
     475# endif
     476# ifdef TMPL_PP16
     477#  error "Both 'TMPL_PAE16' and 'TMPL_PP16' are defined."
     478# endif
     479# ifdef TMPL_PP32
     480#  error "Both 'TMPL_PAE16' and 'TMPL_PP32' are defined."
     481# endif
     482# ifdef TMPL_PPV86
     483#  error "Both 'TMPL_PAE16' and 'TMPL_PPV86' are defined."
     484# endif
     485# ifdef TMPL_PAE32
     486#  error "Both 'TMPL_PAE16' and 'TMPL_PAE32' are defined."
     487# endif
     488# ifdef TMPL_LM16
     489#  error "Both 'TMPL_PAE16' and 'TMPL_LM16' are defined."
     490# endif
     491# ifdef TMPL_PAEV86
     492#  error "Both 'TMPL_PAE16' and 'TMPL_PAEV86' are defined."
     493# endif
     494# ifdef TMPL_LM32
     495#  error "Both 'TMPL_PAE16' and 'TMPL_LM32' are defined."
     496# endif
     497# ifdef TMPL_LM64
     498#  error "Both 'TMPL_PAE16' and 'TMPL_LM64' are defined."
     499# endif
     500# if ARCH_BITS != 16
     501#  error "TMPL_PAE16 requires ARCH_BITS to be 16."
     502# endif
     503# define TMPL_CMN_PAE
     504# define TMPL_16BIT
     505# define TMPL_CMN_P16
     506# define TMPL_BITS              16
     507# define TMPL_NM(Name)          RT_CONCAT(Name,_pae16)
     508# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     509# define TMPL_MODE_STR          "16-bit pae protected mode"
     510#endif
     511
     512#ifdef TMPL_PAE32
     513# ifdef TMPL_RM
     514#  error "Both 'TMPL_PAE32' and 'TMPL_RM' are defined."
     515# endif
     516# ifdef TMPL_PE16
     517#  error "Both 'TMPL_PAE32' and 'TMPL_PE16' are defined."
     518# endif
     519# ifdef TMPL_PE32
     520#  error "Both 'TMPL_PAE32' and 'TMPL_PE32' are defined."
     521# endif
     522# ifdef TMPL_PEV86
     523#  error "Both 'TMPL_PAE32' and 'TMPL_PEV86' are defined."
     524# endif
     525# ifdef TMPL_PP16
     526#  error "Both 'TMPL_PAE32' and 'TMPL_PP16' are defined."
     527# endif
     528# ifdef TMPL_PP32
     529#  error "Both 'TMPL_PAE32' and 'TMPL_PP32' are defined."
     530# endif
     531# ifdef TMPL_PPV86
     532#  error "Both 'TMPL_PAE32' and 'TMPL_PPV86' are defined."
     533# endif
     534# ifdef TMPL_PAE16
     535#  error "Both 'TMPL_PAE32' and 'TMPL_PAE16' are defined."
     536# endif
     537# ifdef TMPL_PAEV86
     538#  error "Both 'TMPL_PAE32' and 'TMPL_PAEV86' are defined."
     539# endif
     540# ifdef TMPL_LM16
     541#  error "Both 'TMPL_PAE32' and 'TMPL_LM16' are defined."
     542# endif
     543# ifdef TMPL_LM32
     544#  error "Both 'TMPL_PAE32' and 'TMPL_LM32' are defined."
     545# endif
     546# ifdef TMPL_LM64
     547#  error "Both 'TMPL_PAE32' and 'TMPL_LM64' are defined."
     548# endif
     549# if ARCH_BITS != 32
     550#  error "TMPL_PAE32 requires ARCH_BITS to be 32."
     551# endif
     552# define TMPL_CMN_PAE
     553# define TMPL_CMN_P32
     554# define TMPL_32BIT
     555# define TMPL_BITS              32
     556# define TMPL_NM(Name)          RT_CONCAT(Name,_pae32)
     557# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
     558# define TMPL_MODE_STR          "32-bit pae protected mode"
     559#endif
     560
     561#ifdef TMPL_PAEV86
     562# ifdef TMPL_RM
     563#  error "Both 'TMPL_PAEV86' and 'TMPL_RM' are defined."
     564# endif
     565# ifdef TMPL_PE16
     566#  error "Both 'TMPL_PAEV86' and 'TMPL_PE16' are defined."
     567# endif
     568# ifdef TMPL_PE32
     569#  error "Both 'TMPL_PAEV86' and 'TMPL_PE32' are defined."
     570# endif
     571# ifdef TMPL_PEV86
     572#  error "Both 'TMPL_PAEV86' and 'TMPL_PEV86' are defined."
     573# endif
     574# ifdef TMPL_PP16
     575#  error "Both 'TMPL_PAEV86' and 'TMPL_PP16' are defined."
     576# endif
     577# ifdef TMPL_PP32
     578#  error "Both 'TMPL_PAEV86' and 'TMPL_PP32' are defined."
     579# endif
     580# ifdef TMPL_PPV86
     581#  error "Both 'TMPL_PAEV86' and 'TMPL_PPV86' are defined."
     582# endif
     583# ifdef TMPL_PAE16
     584#  error "Both 'TMPL_PAEV86' and 'TMPL_PAE16' are defined."
     585# endif
     586# ifdef TMPL_PAEV86
     587#  error "Both 'TMPL_PAEV86' and 'TMPL_PAEV86' are defined."
     588# endif
     589# ifdef TMPL_LM16
     590#  error "Both 'TMPL_PAEV86' and 'TMPL_LM16' are defined."
     591# endif
     592# ifdef TMPL_LM32
     593#  error "Both 'TMPL_PAEV86' and 'TMPL_LM32' are defined."
     594# endif
     595# ifdef TMPL_LM64
     596#  error "Both 'TMPL_PAEV86' and 'TMPL_LM64' are defined."
     597# endif
     598# if ARCH_BITS != 16
     599#  error "TMPL_PAEV86 requires ARCH_BITS to be 16."
     600# endif
     601# define TMPL_CMN_PAE
     602# define TMPL_CMN_V86
     603# define TMPL_CMN_R86
     604# define TMPL_16BIT
     605# define TMPL_BITS              16
     606# define TMPL_NM(Name)          RT_CONCAT(Name,_paev86)
     607# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
     608# define TMPL_MODE_STR          "v8086 pae protected mode"
     609#endif
     610
     611#ifdef TMPL_LM16
     612# ifdef TMPL_RM
     613#  error "Both 'TMPL_LM16' and 'TMPL_RM' are defined."
     614# endif
     615# ifdef TMPL_PE16
     616#  error "Both 'TMPL_LM16' and 'TMPL_PE16' are defined."
     617# endif
     618# ifdef TMPL_PE32
     619#  error "Both 'TMPL_LM16' and 'TMPL_PE32' are defined."
     620# endif
     621# ifdef TMPL_PEV86
     622#  error "Both 'TMPL_LM16' and 'TMPL_PEV86' are defined."
     623# endif
     624# ifdef TMPL_PP16
     625#  error "Both 'TMPL_LM16' and 'TMPL_PP16' are defined."
     626# endif
     627# ifdef TMPL_PP32
     628#  error "Both 'TMPL_LM16' and 'TMPL_PP32' are defined."
     629# endif
     630# ifdef TMPL_PPV86
     631#  error "Both 'TMPL_LM16' and 'TMPL_PPV86' are defined."
     632# endif
     633# ifdef TMPL_PAE16
     634#  error "Both 'TMPL_LM16' and 'TMPL_PAE16' are defined."
     635# endif
     636# ifdef TMPL_PAE32
     637#  error "Both 'TMPL_LM16' and 'TMPL_PAE32' are defined."
     638# endif
     639# ifdef TMPL_PAEV86
     640#  error "Both 'TMPL_LM16' and 'TMPL_PAEV86' are defined."
     641# endif
     642# ifdef TMPL_LM32
     643#  error "Both 'TMPL_LM16' and 'TMPL_LM32' are defined."
     644# endif
     645# ifdef TMPL_LM64
     646#  error "Both 'TMPL_LM16' and 'TMPL_LM64' are defined."
     647# endif
     648# if ARCH_BITS != 16
     649#  error "TMPL_LM16 requires ARCH_BITS to be 16."
     650# endif
     651# define TMPL_CMN_LM
     652# define TMPL_CMN_P16
     653# define TMPL_16BIT
     654# define TMPL_BITS              16
     655# define TMPL_NM(Name)          RT_CONCAT(Name,_lm16)
     656# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     657# define TMPL_MODE_STR          "16-bit long mode"
     658#endif
     659
     660#ifdef TMPL_LM32
     661# ifdef TMPL_RM
     662#  error "Both 'TMPL_LM32' and 'TMPL_RM' are defined."
     663# endif
     664# ifdef TMPL_PE16
     665#  error "Both 'TMPL_LM32' and 'TMPL_PE16' are defined."
     666# endif
     667# ifdef TMPL_PE32
     668#  error "Both 'TMPL_LM32' and 'TMPL_PE32' are defined."
     669# endif
     670# ifdef TMPL_PEV86
     671#  error "Both 'TMPL_LM32' and 'TMPL_PEV86' are defined."
     672# endif
     673# ifdef TMPL_PP16
     674#  error "Both 'TMPL_LM32' and 'TMPL_PP16' are defined."
     675# endif
     676# ifdef TMPL_PP32
     677#  error "Both 'TMPL_LM32' and 'TMPL_PP32' are defined."
     678# endif
     679# ifdef TMPL_PPV86
     680#  error "Both 'TMPL_LM32' and 'TMPL_PPV86' are defined."
     681# endif
     682# ifdef TMPL_PAE16
     683#  error "Both 'TMPL_LM32' and 'TMPL_PAE16' are defined."
     684# endif
     685# ifdef TMPL_PAE32
     686#  error "Both 'TMPL_LM32' and 'TMPL_PAE32' are defined."
     687# endif
     688# ifdef TMPL_PAEV86
     689#  error "Both 'TMPL_LM32' and 'TMPL_PAEV86' are defined."
     690# endif
     691# ifdef TMPL_LM16
     692#  error "Both 'TMPL_LM32' and 'TMPL_LM16' are defined."
     693# endif
     694# ifdef TMPL_LM64
     695#  error "Both 'TMPL_LM32' and 'TMPL_LM64' are defined."
     696# endif
     697# if ARCH_BITS != 32
     698#  error "TMPL_LM32 requires ARCH_BITS to be 32."
     699# endif
     700# define TMPL_CMN_LM
     701# define TMPL_CMN_P32
     702# define TMPL_32BIT
     703# define TMPL_BITS              32
     704# define TMPL_NM(Name)          RT_CONCAT(Name,_lm32)
     705# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
     706# define TMPL_MODE_STR          "32-bit long mode"
     707#endif
     708
     709#ifdef TMPL_LM64
     710# ifdef TMPL_RM
     711#  error ""Both 'TMPL_LM64' and 'TMPL_RM' are defined.""
     712# endif
     713# ifdef TMPL_PE16
     714#  error "Both 'TMPL_LM64' and 'TMPL_PE16' are defined."
     715# endif
     716# ifdef TMPL_PE32
     717#  error "Both 'TMPL_LM64' and 'TMPL_PE32' are defined."
     718# endif
     719# ifdef TMPL_PEV86
     720#  error "Both 'TMPL_LM64' and 'TMPL_PEV86' are defined."
     721# endif
     722# ifdef TMPL_PP16
     723#  error "Both 'TMPL_LM64' and 'TMPL_PP16' are defined."
     724# endif
     725# ifdef TMPL_PP32
     726#  error "Both 'TMPL_LM64' and 'TMPL_PP32' are defined."
     727# endif
     728# ifdef TMPL_PPV86
     729#  error "Both 'TMPL_LM64' and 'TMPL_PPV86' are defined."
     730# endif
     731# ifdef TMPL_PAE16
     732#  error "Both 'TMPL_LM64' and 'TMPL_PAE16' are defined."
     733# endif
     734# ifdef TMPL_PAE32
     735#  error "Both 'TMPL_LM64' and 'TMPL_PAE32' are defined."
     736# endif
     737# ifdef TMPL_PAEV86
     738#  error "Both 'TMPL_LM64' and 'TMPL_PAEV86' are defined."
     739# endif
     740# ifdef TMPL_LM16
     741#  error "Both 'TMPL_LM64' and 'TMPL_LM16' are defined."
     742# endif
     743# ifdef TMPL_LM32
     744#  error "Both 'TMPL_LM64' and 'TMPL_LM32' are defined."
     745# endif
     746# if ARCH_BITS != 64
     747#  error "TMPL_LM64 requires ARCH_BITS to be 64."
     748# endif
     749# define TMPL_CMN_LM
     750# define TMPL_CMN_P64
     751# define TMPL_64BIT
     752# define TMPL_BITS              64
     753# define TMPL_NM(Name)          RT_CONCAT(Name,_lm64)
     754# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
     755# define TMPL_MODE_STR          "64-bit long mode"
     756#endif
     757
     758#ifndef TMPL_MODE_STR
     759# error "internal error"
     760#endif
     761
     762#endif /* !DOXYGEN_RUNNING */
     763/** @} */
     764
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac

    r58588 r58628  
    9292 %define TMPL_BITS              16
    9393 %define TMPL_PTR_DEF           dw
    94  %define TMPL_NM(Name)          Name %+ _rm
    95  %define TMPL_NM_CMN(Name)      Name %+ _r86
     94 %define TMPL_NM(Name)          _ %+ Name %+ _rm
     95 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    9696 %define TMPL_MODE_STR          'real mode'
    9797 %define TMPL_HAVE_BIOS
     
    141141 %define TMPL_BITS              16
    142142 %define TMPL_PTR_DEF           dw
    143  %define TMPL_NM(Name)          Name %+ _pe16
    144  %define TMPL_NM_CMN(Name)      Name %+ _p16
     143 %define TMPL_NM(Name)          _ %+ Name %+ _pe16
     144 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    145145 %define TMPL_MODE_STR          '16-bit unpaged protected mode'
    146146%endif
     
    188188 %define TMPL_BITS              32
    189189 %define TMPL_PTR_DEF           dd
    190  %define TMPL_NM(Name)          Name %+ _pe32
    191  %define TMPL_NM_CMN(Name)      Name %+ _p32
     190 %define TMPL_NM(Name)          _ %+ Name %+ _pe32
     191 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    192192 %define TMPL_MODE_STR          '32-bit unpaged protected mode'
    193193%endif
     
    236236 %define TMPL_BITS              16
    237237 %define TMPL_PTR_DEF           dw
    238  %define TMPL_NM(Name)          Name %+ _pev86
    239  %define TMPL_NM_CMN(Name)      Name %+ _r86
     238 %define TMPL_NM(Name)          _ %+ Name %+ _pev86
     239 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    240240 %define TMPL_MODE_STR          'v8086 unpaged protected mode'
    241241%endif
     
    283283 %define TMPL_BITS              16
    284284 %define TMPL_PTR_DEF           dw
    285  %define TMPL_NM(Name)          Name %+ _pp16
    286  %define TMPL_NM_CMN(Name)      Name %+ _p16
     285 %define TMPL_NM(Name)          _ %+ Name %+ _pp16
     286 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    287287 %define TMPL_MODE_STR          '16-bit paged protected mode'
    288288%endif
     
    330330 %define TMPL_BITS              32
    331331 %define TMPL_PTR_DEF           dd
    332  %define TMPL_NM(Name)          Name %+ _pp32
    333  %define TMPL_NM_CMN(Name)      Name %+ _p32
     332 %define TMPL_NM(Name)          _ %+ Name %+ _pp32
     333 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    334334 %define TMPL_MODE_STR          '32-bit paged protected mode'
    335335%endif
     
    379379 %define TMPL_PTR_DEF           dw
    380380 %define TMPL_NM(Name)          Name %+ _ppv86
    381  %define TMPL_NM_CMN(Name)      Name %+ _r86
     381 %define BS3_CMN_NM(Name)       Name %+ _c86
    382382 %define TMPL_MODE_STR          'v8086 paged protected mode'
    383383%endif
     
    425425 %define TMPL_BITS              16
    426426 %define TMPL_PTR_DEF           dw
    427  %define TMPL_NM(Name)          Name %+ _pae16
    428  %define TMPL_NM_CMN(Name)      Name %+ _p16
     427 %define TMPL_NM(Name)          _ %+ Name %+ _pae16
     428 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    429429 %define TMPL_MODE_STR          '16-bit pae protected mode'
    430430%endif
     
    472472 %define TMPL_BITS              32
    473473 %define TMPL_PTR_DEF           dd
    474  %define TMPL_NM(Name)          Name %+ _pae32
    475  %define TMPL_NM_CMN(Name)      Name %+ _p32
     474 %define TMPL_NM(Name)          _ %+ Name %+ _pae32
     475 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    476476 %define TMPL_MODE_STR          '32-bit pae protected mode'
    477477%endif
     
    520520 %define TMPL_BITS              16
    521521 %define TMPL_PTR_DEF           dw
    522  %define TMPL_NM(Name)          Name %+ _paev86
    523  %define TMPL_NM_CMN(Name)      Name %+ _r86
     522 %define TMPL_NM(Name)          _ %+ Name %+ _paev86
     523 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
    524524 %define TMPL_MODE_STR          'v8086 pae protected mode'
    525525%endif
     
    567567 %define TMPL_BITS              16
    568568 %define TMPL_PTR_DEF           dw
    569  %define TMPL_NM(Name)          Name %+ _lm16
    570  %define TMPL_NM_CMN(Name)      Name %+ _p16
     569 %define TMPL_NM(Name)          _ %+ Name %+ _lm16
     570 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    571571 %define TMPL_MODE_STR          '16-bit long mode'
    572572%endif
     
    614614 %define TMPL_BITS              32
    615615 %define TMPL_PTR_DEF           dd
    616  %define TMPL_NM(Name)          Name %+ _lm32
    617  %define TMPL_NM_CMN(Name)      Name %+ _p32
     616 %define TMPL_NM(Name)          _ %+ Name %+ _lm32
     617 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    618618 %define TMPL_MODE_STR          '32-bit long mode'
    619619%endif
     
    661661 %define TMPL_BITS              64
    662662 %define TMPL_PTR_DEF           dq
    663  %define TMPL_NM(Name)          Name %+ _lm64
    664  %define TMPL_NM_CMN(Name)      Name %+ _p64
     663 %define TMPL_NM(Name)          Name %+ _lm64   ; No underscore (C/C++ compatibility).
     664 %define BS3_CMN_NM(Name)       Name %+ _c64    ; No underscore (C/C++ compatibility).
    665665 %define TMPL_MODE_STR          '64-bit long mode'
    666666%endif
     
    669669 %error "internal error"
    670670%endif
    671 
    672 
    673 ;
    674 ; Preferred spelling of TMPL_NM_CMN in BS3.
    675 ;
    676 %define TMPL_CMN_NM(Name)      TMPL_NM_CMN(Name)
    677671
    678672
     
    735729%endif
    736730
     731
    737732;
    738733; Register names corresponding to the max size for pop/push <reg>.
     
    774769
    775770;
    776 ; Default code segment.
     771; Default code segment (changes BITS too).
    777772;
    778773%ifdef TMPL_64BIT
     
    787782TMPL_BEGIN_TEXT
    788783
    789 ;
    790 ; Change the bitness.
    791 ;
    792 %ifdef TMPL_64BIT
    793 BITS 64
    794 %else
    795  %ifdef TMPL_32BIT
    796 BITS 32
    797  %else
    798 BITS 16
    799  %endif
    800 %endif
    801 
     784
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r58609 r58628  
    3232; If we don't do the latter we end up with an unused 'text' section.
    3333;
     34
     35;; Wrapper around BITS.
     36; Updates __BITS__ (built-in variable in nasm, we work it for yasm).
     37; @param    %1      The CPU bit count: 16, 32 or 64
     38; @remarks ARCH_BITS is not modified and will remain what it was on the
     39;          assembler command line.
     40%macro BS3_SET_BITS 1
     41 BITS %1
     42
     43 %ifdef __YASM__
     44  %undef  __BITS__
     45  %define __BITS__ %1
     46 %endif
     47
     48 %undef  BS3_NAME_UNDERSCORE
     49 %if %1 == 64
     50  %define BS3_NAME_UNDERSCORE
     51 %else
     52  %define BS3_NAME_UNDERSCORE _
     53 %endif
     54
     55 %undef   BS3_ONLY_16BIT
     56 %if %1 == 16
     57  %define BS3_ONLY_16BIT(a_Expr)    a_Expr
     58 %else
     59  %define BS3_ONLY_16BIT(a_Expr)
     60 %endif
     61
     62 %undef   BS3_WRT_RIP
     63 %if %1 == 64
     64  %define BS3_WRT_RIP               wrt rip
     65 %else
     66  %define BS3_WRT_RIP
     67 %endif
     68%endmacro
     69
     70;; Emulate the __BITS__ macro in NASM 2.0+. Follows BS3_SET_BITS.
     71%ifdef __YASM__
     72 %define __BITS__                   ARCH_BITS
     73%endif
     74
     75;; Mostly internal macro. Follows BS3_SET_BITS.
     76%if ARCH_BITS == 64
     77 %define BS3_NAME_UNDERSCORE
     78%else
     79 %define BS3_NAME_UNDERSCORE        _
     80%endif
     81
     82;; For RIP relative addressing in 64-bit mode and absolute addressing in
     83; other modes. Follows BS3_SET_BITS.
     84%if ARCH_BITS == 64
     85 %define BS3_WRT_RIP                wrt rip
     86%else
     87 %define BS3_WRT_RIP
     88%endif
     89
     90;; For segment overrides and stuff. Follows BS3_SET_BITS.
     91%if ARCH_BITS == 16
     92 %define BS3_ONLY_16BIT(a_Expr)     a_Expr
     93%else
     94 %define BS3_ONLY_16BIT(a_Expr)
     95%endif
     96
     97;;
     98; For instruction that should only be emitted in 16-bit mode. Follows BS3_SET_BITS.
     99%macro BS3_ONLY_16BIT_STMT 1+
     100 %if __BITS__ == 16
     101        %1
     102 %endif
     103%endmacro
     104
     105;;
     106; For instruction that should only be emitted in 32-bit mode. Follows BS3_SET_BITS.
     107%macro BS3_ONLY_32BIT_STMT 1+
     108 %if __BITS__ == 32
     109        %1
     110 %endif
     111%endmacro
     112
     113;;
     114; For instruction that should only be emitted in 64-bit mode. Follows BS3_SET_BITS.
     115%macro BS3_ONLY_64BIT_STMT 1+
     116 %if __BITS__ == 64
     117        %1
     118 %endif
     119%endmacro
     120
     121
    34122
    35123;; @name Segment definitions.
     
    41129        section BS3TEXT16 align=1 progbits alloc exec nowrite
    42130  %else
    43         section BS3TEXT16 align=1 CLASS=CODE16 PUBLIC USE16
     131        section BS3TEXT16 align=1 CLASS=BS3CODE16 PUBLIC USE16
    44132  %endif
    45133
     
    47135        section BS3TEXT16
    48136 %endif
     137        BS3_SET_BITS 16
    49138%endmacro
    50139
     
    60149        section BS3DATA16
    61150 %endif
     151        BS3_SET_BITS 16
    62152%endmacro
    63153
     
    68158        section BS3TEXT32 align=1 progbits alloc exec nowrite
    69159  %else
    70         section BS3TEXT32 align=1 CLASS=CODE32 PUBLIC USE32
     160        section BS3TEXT32 align=1 CLASS=BS3CODE32 PUBLIC USE32
    71161  %endif
    72162 %else
    73163        section BS3TEXT32
    74164 %endif
     165        BS3_SET_BITS 32
    75166%endmacro
    76167
     
    81172        section BS3DATA32 align=16 progbits alloc noexec write
    82173  %else
    83         section BS3DATA32 align=16 CLASS=DATA32 PUBLIC USE32
     174        section BS3DATA32 align=16 CLASS=FAR_DATA PUBLIC USE32
    84175  %endif
    85176 %else
    86177        section BS3DATA32
    87178 %endif
     179        BS3_SET_BITS 32
    88180%endmacro
    89181
     
    94186        section BS3TEXT64 align=1 progbits alloc exec nowrite
    95187  %else
    96         section BS3TEXT64 align=1 CLASS=CODE64 PUBLIC USE32
     188        section BS3TEXT64 align=1 CLASS=CODE PUBLIC USE32       ; class=CODE here because of 64-bit cl and/or wlink.exe
    97189  %endif
    98190 %else
    99191        section BS3TEXT64
    100192 %endif
     193        BS3_SET_BITS 64
    101194%endmacro
    102195
     
    107200        section BS3DATA64 align=16 progbits alloc noexec write
    108201  %else
    109         section BS3DATA64 align=16 CLASS=DATA64 PUBLIC USE32
     202        section BS3DATA64 align=16 CLASS=DATA PUBLIC USE32      ; class=DATA here because of 64-bit cl and/or wlink.exe
    110203  %endif
    111204 %else
    112205        section BS3DATA64
    113206 %endif
     207        BS3_SET_BITS 64
    114208%endmacro
    115209
     
    156250
    157251;;
    158 ; Extern macro which mangles the name correctly.
     252; Extern macro which mangles the name using NAME().
    159253%macro EXTERN 1
    160254 extern NAME(%1)
     
    162256
    163257;;
     258; Mangles a common name according to the current cpu bit count.
     259; @remarks Requires the use of the BS3_SET_BITS macro instead of the BITS directive.
     260%define BS3_CMN_NM(a_Name)     BS3_NAME_UNDERSCORE %+ a_Name %+ _c %+ __BITS__
     261
     262;;
    164263; Extern macro which mangles the common name correctly, redefining the unmangled
    165264; name with to the mangled one for ease of use.
    166 %macro EXTERN_CMN_NM 1
    167  %ifdef TMPL_64BIT
    168   extern NAME(%1 %+ _p64)
    169   %define %1 NAME(%1 %+ _p64)
    170 
    171  %elifdef TMPL_32BIT
    172   extern NAME(%1 %+ _p32)
    173   %define %1 NAME(%1 %+ _p32)
    174 
    175  %elifdef TMPL_16BIT
    176   extern NAME(%1 %+ _p16)
    177   %define %1 NAME(%1 %+ _p16)
    178 
    179  %else
    180   %error "Missing TMPL_xxBIT!"
    181  %endif
    182 %endmacro
    183 
     265;
     266; @param    %1  The unmangled common name.
     267;
     268; @remarks  Must enter the segment in which this name is defined.
     269;
     270%macro BS3_EXTERN_CMN 1
     271 extern BS3_CMN_NM(%1)
     272 %undef  %1
     273 %define %1 BS3_CMN_NM(%1)
     274%endmacro
     275
     276;;
     277; Global name with ELF attributes and size.
     278;
     279; This differs from GLOBALNAME_EX in that it expects a mangled symbol name,
     280; and allows for nasm style symbol size expressions.
     281;
     282; @param    %1  The mangled name.
     283; @param    %2  Symbol attributes.
     284; @param    %3  The size expression.
     285;
     286%macro BS3_GLOBAL_NAME_EX 3
     287%ifdef ASM_FORMAT_ELF
     288 %ifdef __NASM__
     289global %1:%2 %3
     290 %else
     291global %1:%2
     292 %endif
     293%else
     294global %1
     295%endif
     296%1:
     297%endmacro
     298
     299;;
     300; Starts a procedure.
     301;
     302; This differs from BEGINPROC in that it expects a mangled symbol name and
     303; does the NASM symbol size stuff.
     304;
     305; @param    %1      The mangled name.
     306;
     307%macro BS3_PROC_BEGIN 1
     308BS3_GLOBAL_NAME_EX %1, function, (%1 %+ _EndProc - %1)
     309%endmacro
     310
     311;;
     312; Ends a procedure.
     313;
     314; Counter part to BS3_PROC_BEGIN.
     315;
     316; @param    %1      The mangled name.
     317;
     318%macro BS3_PROC_END  1
     319BS3_GLOBAL_NAME_EX %1 %+ _EndProc, function hidden, (%1 %+ _EndProc - %1)
     320 %ifdef ASM_FORMAT_ELF
     321  %ifdef __YASM__
     322size %1                 %1 %+ _EndProc - %1
     323size %1 %+ _EndProc     0
     324  %endif
     325 %endif
     326%endmacro
     327
     328;; Convenience macro for defining common procedures.
     329%macro BS3_PROC_BEGIN_CMN 1
     330 BS3_PROC_BEGIN     BS3_CMN_NM(%1)
     331%endmacro
     332
     333;; Convenience macro for defining common procedures.
     334%macro BS3_PROC_END_CMN 1
     335 BS3_PROC_END       BS3_CMN_NM(%1)
     336%endmacro
     337
     338;;
     339; Prologue hacks for 64-bit code.
     340;
     341; This saves the four register parameters onto the stack so we can pretend
     342; the calling convention is stack based.  The 64-bit calling convension is
     343; the microsoft one, so this is straight forward.
     344;
     345; Pairs with BS3_CALL_CONV_EPILOG.
     346;
     347; @param    %1      The number of parameters.
     348;
     349; @remarks  Must be invoked before any stack changing instructions are emitted.
     350;
     351%macro BS3_CALL_CONV_PROLOG 1
     352 %undef  BS3_CALL_CONV_PROLOG_PARAMS
     353 %define BS3_CALL_CONV_PROLOG_PARAMS %1
     354 %if __BITS__ == 64
     355  %if %1 >= 1
     356        mov         [rsp + 008h], rcx
     357  %elifdef BS3_STRICT
     358        and         qword [rsp + 008h], 1
     359  %endif
     360  %if %1 >= 2
     361        mov         [rsp + 010h], rdx
     362  %elifdef BS3_STRICT
     363        and         qword [rsp + 010h], 2
     364  %endif
     365  %if %1 >= 3
     366        mov         [rsp + 018h], r8
     367  %elifdef BS3_STRICT
     368        and         qword [rsp + 018h], 3
     369  %endif
     370  %if %1 >= 4
     371        mov         [rsp + 020h], r9
     372  %elifdef BS3_STRICT
     373        and         qword [rsp + 020h], 4
     374  %endif
     375 %endif
     376%endmacro
     377
     378;;
     379; Epilogue hacks for 64-bit code.
     380;
     381; Counter part to BS3_CALL_CONV_PROLOG.
     382;
     383; @param    %1      The number of parameters.
     384;
     385; @remarks  Must be invoked right before the return instruction as it uses RSP.
     386;
     387%macro BS3_CALL_CONV_EPILOG 1
     388 %if BS3_CALL_CONV_PROLOG_PARAMS != %1
     389  %error "BS3_CALL_CONV_EPILOG argument differs from BS3_CALL_CONV_PROLOG."
     390 %endif
     391 %if __BITS__ == 64
     392  %ifdef BS3_STRICT
     393        mov         dword [rsp + 008h], 31h
     394        mov         dword [rsp + 010h], 32h
     395        mov         dword [rsp + 018h], 33h
     396        mov         dword [rsp + 020h], 34h
     397  %endif
     398 %endif
     399%endmacro
     400
     401;;
     402; Wrapper for the call instruction that hides calling convension differences.
     403;
     404; This always calls %1.
     405; In 64-bit code, it will load up to 4 parameters into register.
     406;
     407; @param    %1      The function to call (mangled).
     408; @param    %2      The number of parameters.
     409;
     410%macro BS3_CALL 2
     411 %if __BITS__ == 64
     412  %if %2 >= 1
     413        mov         rcx, [rsp + 008h]
     414   %ifdef BS3_STRICT
     415        and         qword [rsp + 008h], 11h
     416   %endif
     417  %endif
     418  %if %2 >= 2
     419        mov         rdx, [rsp + 010h]
     420   %ifdef BS3_STRICT
     421        and         qword [rsp + 010h], 12h
     422   %endif
     423  %endif
     424  %if %2 >= 3
     425        mov         r8,  [rsp + 018h]
     426   %ifdef BS3_STRICT
     427        and         qword [rsp + 018h], 13h
     428   %endif
     429  %endif
     430  %if %2 >= 4
     431        mov         r9,  [rsp + 020h]
     432   %ifdef BS3_STRICT
     433        and         qword [rsp + 020h], 14h
     434   %endif
     435  %endif
     436 %endif
     437        call        %1
     438%endmacro
    184439
    185440
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