VirtualBox

Changeset 59863 in vbox for trunk


Ignore:
Timestamp:
Feb 26, 2016 8:59:52 PM (9 years ago)
Author:
vboxsync
Message:

bs3kit: Updates.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
5 added
19 edited
1 moved

Legend:

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

    r59803 r59863  
    343343TEMPLATE_VBoxBS3KitImg_CXXFLAGS     = \
    344344        -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os
    345 TEMPLATE_VBoxBS3KitImg_INCS         = $(VBOX_PATH_BS3KIT_SRC)
     345TEMPLATE_VBoxBS3KitImg_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
    346346TEMPLATE_VBoxBS3KitImg_LDTOOL       = OPENWATCOM-WL
    347347#       option quiet, nofarcalls\
     
    451451TEMPLATE_VBoxBS3KitImg32_CXXFLAGS     = \
    452452        -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zl -mf $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os
    453 TEMPLATE_VBoxBS3KitImg32_INCS         = $(VBOX_PATH_BS3KIT_SRC)
     453TEMPLATE_VBoxBS3KitImg32_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
    454454TEMPLATE_VBoxBS3KitImg32_LDTOOL       = VBoxBsUnusedLd
    455455
     
    465465TEMPLATE_VBoxBS3KitImg64_DEFS.debug   = BS3_STRICT
    466466TEMPLATE_VBoxBS3KitImg64_ARTOOL       = OPENWATCOM
    467 TEMPLATE_VBoxBS3KitImg64_INCS         = $(VBOX_PATH_BS3KIT_SRC)
     467TEMPLATE_VBoxBS3KitImg64_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
    468468if1of ($(KBUILD_HOST), win)
    469469 ifndef TOOL_VCC100AMD64 # For win.x86 builds.
     
    494494TEMPLATE_VBoxBS3KitBS_ASFLAGS         = -f bin --mapfile
    495495TEMPLATE_VBoxBS3KitBS_ASDEFS          = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__
    496 TEMPLATE_VBoxBS3KitBS_INCS            = $(VBOX_PATH_BS3KIT_SRC)
     496TEMPLATE_VBoxBS3KitBS_INCS            = $(VBOX_PATH_BS3KIT_SRC) .
    497497TEMPLATE_VBoxBS3KitBS_LDTOOL          = VBoxBsCpLd
    498498
  • trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk

    r59316 r59863  
    229229bs3-cpu-basic-2_TEMPLATE = VBoxBS3KitImg
    230230bs3-cpu-basic-2_SOURCES = \
    231         bs3-cpu-basic-2.asm
     231        bs3kit/bs3-first-rm.asm \
     232        bs3-cpu-basic-2-c.c
     233#       bs3-cpu-basic-2.asm
    232234endif
    233235
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2.asm

    r59789 r59863  
    6363        ;
    6464
     65
     66
    6567        ;
    6668        ; Done.
     
    7274
    7375
     76;
     77; Instantiate the test template code.
     78;
     79%include "bs3kit-template-footer.mac"  ; reset the initial environemnt.
    7480
     81
     82BS3_INSTANTIATE_TEMPLATE_WITH_WEIRD_ONES "bs3-cpu-basic-2-template.mac"
     83
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r59789 r59863  
    55
    66#
    7 # Copyright (C) 2006-2015 Oracle Corporation
     7# Copyright (C) 2006-2016 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    100100       bs3-cmn-TestData.c \
    101101       bs3-cmn-TestInit.c \
    102         bs3-cmn-TestSendStrCmd.asm \
     102       bs3-cmn-TestTerm.c \
     103        bs3-cmn-TestSendCmdWithStr.asm \
     104        bs3-cmn-TestSendCmdWithU32.asm \
    103105        bs3-cmn-TestIsVmmDevTestingPresent.asm \
    104106        bs3-cmn-Trap16SetGate.c \
     
    136138        bs3-cmn-hexdigits.c \
    137139        bs3-cmn-CpuDetectData.c \
     140        bs3-cmn-PerCpuData.c \
    138141        bs3-cmn-ConvertRMStackToP16UsingCxReturnToAx.asm \
    139142        bs3-wc16-U8DR.asm \
     
    204207bs3kit-rm_TEMPLATE = VBoxBS3KitImg
    205208bs3kit-rm_INSTTYPE = none
    206 bs3kit-rm_DEFS     = TMPL_RM
     209bs3kit-rm_DEFS     = TMPL_MODE=BS3_MODE_RM
    207210bs3kit-rm_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    208211        bs3-first-rm.asm \
     
    210213
    211214
    212 # The 16-bit protected mode BS3Kit library.
     215# The 16-bit BS3Kit library for 16-bit protected kernel+tss.
    213216LIBRARIES += bs3kit-pe16
    214217bs3kit-pe16_TEMPLATE = VBoxBS3KitImg
    215218bs3kit-pe16_INSTTYPE = none
    216 bs3kit-pe16_DEFS     = TMPL_PE16
     219bs3kit-pe16_DEFS     = TMPL_MODE=BS3_MODE_PE16
    217220bs3kit-pe16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    218221        bs3-first-pe16.asm \
    219222#       bs3-mode-CpuDetect.asm
    220223
    221 # The virtual 8086 under protected mode BS3Kit library.
     224# The 32-bit BS3Kit library for 16-bit protected kernel+tss.
     225LIBRARIES += bs3kit-pe16_32
     226bs3kit-pe16_32_TEMPLATE = VBoxBS3KitImg32
     227bs3kit-pe16_32_INSTTYPE = none
     228bs3kit-pe16_32_DEFS     = TMPL_MODE=BS3_MODE_PE16_32
     229bs3kit-pe16_32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     230
     231# The v86 BS3Kit library for 16-bit protected kernel+tss.
     232LIBRARIES += bs3kit-pe16_v86
     233bs3kit-pe16_v86_TEMPLATE = VBoxBS3KitImg
     234bs3kit-pe16_v86_INSTTYPE = none
     235bs3kit-pe16_v86_DEFS     = TMPL_MODE=BS3_MODE_PE16_V86
     236bs3kit-pe16_v86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     237
     238# The 32-bit BS3Kit library for 32-bit protected kernel+tss.
     239LIBRARIES += bs3kit-pe32
     240bs3kit-pe32_TEMPLATE = VBoxBS3KitImg32
     241bs3kit-pe32_INSTTYPE = none
     242bs3kit-pe32_DEFS     = TMPL_MODE=BS3_MODE_PE32
     243bs3kit-pe32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     244
     245# The 16-bit BS3Kit library for 32-bit protected kernel+tss.
     246LIBRARIES += bs3kit-pe32_16
     247bs3kit-pe32_16_TEMPLATE = VBoxBS3KitImg
     248bs3kit-pe32_16_INSTTYPE = none
     249bs3kit-pe32_16_DEFS     = TMPL_MODE=BS3_MODE_PE32_16
     250bs3kit-pe32_16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     251
     252# The v8086 BS3Kit library for 32-bit protected kernel+tss.
    222253LIBRARIES += bs3kit-pev86
    223254bs3kit-pev86_TEMPLATE = VBoxBS3KitImg
    224255bs3kit-pev86_INSTTYPE = none
    225 bs3kit-pev86_DEFS     = TMPL_PEV86
    226 bs3kit-pev86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    227 
    228 # The 32-bit protected mode BS3Kit library.
    229 LIBRARIES += bs3kit-pe32
    230 bs3kit-pe32_TEMPLATE = VBoxBS3KitImg32
    231 bs3kit-pe32_INSTTYPE = none
    232 bs3kit-pe32_DEFS     = TMPL_PE32
    233 bs3kit-pe32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    234 
    235 
    236 # The 16-bit paged protected mode BS3Kit library.
     256bs3kit-pev86_DEFS     = TMPL_MODE=BS3_MODE_PEV86
     257bs3kit-pev86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     258
     259
     260# The 16-bit BS3Kit library for 16-bit paged protected kernel+tss.
    237261LIBRARIES += bs3kit-pp16
    238262bs3kit-pp16_TEMPLATE = VBoxBS3KitImg
    239263bs3kit-pp16_INSTTYPE = none
    240 bs3kit-pp16_DEFS     = TMPL_PP16
     264bs3kit-pp16_DEFS     = TMPL_MODE=BS3_MODE_PP16
    241265bs3kit-pp16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    242266        bs3-mode-CpuDetect.asm
    243267
    244 # The 32-bit paged protected mode BS3Kit library.
     268# The 32-bit BS3Kit library for 16-bit paged protected kernel+tss.
     269LIBRARIES += bs3kit-pp16_32
     270bs3kit-pp16_32_TEMPLATE = VBoxBS3KitImg32
     271bs3kit-pp16_32_INSTTYPE = none
     272bs3kit-pp16_32_DEFS     = TMPL_MODE=BS3_MODE_PP16_32
     273bs3kit-pp16_32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     274
     275# The v8086 BS3Kit library for 16-bit paged protected kernel+tss.
     276LIBRARIES += bs3kit-pp16_v86
     277bs3kit-pp16_v86_TEMPLATE = VBoxBS3KitImg
     278bs3kit-pp16_v86_INSTTYPE = none
     279bs3kit-pp16_v86_DEFS     = TMPL_MODE=BS3_MODE_PP16_V86
     280bs3kit-pp16_v86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     281
     282# The 32-bit BS3Kit library for 32-bit paged protected kernel+tss.
    245283LIBRARIES += bs3kit-pp32
    246284bs3kit-pp32_TEMPLATE = VBoxBS3KitImg32
    247285bs3kit-pp32_INSTTYPE = none
    248 bs3kit-pp32_DEFS     = TMPL_PP32
     286bs3kit-pp32_DEFS     = TMPL_MODE=BS3_MODE_PP32
    249287bs3kit-pp32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    250288
    251 # The virtual 8086 under protected mode BS3Kit library.
     289# The 16-bit BS3Kit library for 32-bit paged protected kernel+tss.
     290LIBRARIES += bs3kit-pp32_16
     291bs3kit-pp32_16_TEMPLATE = VBoxBS3KitImg
     292bs3kit-pp32_16_INSTTYPE = none
     293bs3kit-pp32_16_DEFS     = TMPL_MODE=BS3_MODE_PP32_16
     294bs3kit-pp32_16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     295
     296# The v8086 BS3Kit library for 32-bit paged protected kernel+tss.
    252297LIBRARIES += bs3kit-ppv86
    253298bs3kit-ppv86_TEMPLATE = VBoxBS3KitImg
    254299bs3kit-ppv86_INSTTYPE = none
    255 bs3kit-ppv86_DEFS     = TMPL_PPV86
    256 bs3kit-ppv86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    257 
    258 
    259 # The 16-bit paged protected mode BS3Kit library.
     300bs3kit-ppv86_DEFS     = TMPL_MODE=BS3_MODE_PPV86
     301bs3kit-ppv86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     302
     303
     304# The 16-bit BS3Kit library for 16-bit PAE paged protected kernel+tss.
    260305LIBRARIES += bs3kit-pae16
    261306bs3kit-pae16_TEMPLATE = VBoxBS3KitImg
    262307bs3kit-pae16_INSTTYPE = none
    263 bs3kit-pae16_DEFS     = TMPL_PAE16
     308bs3kit-pae16_DEFS     = TMPL_MODE=BS3_MODE_PAE16
    264309bs3kit-pae16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
    265310        bs3-mode-CpuDetect.asm
    266311
    267 # The 32-bit paged protected mode BS3Kit library.
     312# The 16-bit BS3Kit library for 16-bit PAE paged protected kernel+tss.
     313LIBRARIES += bs3kit-pae16_32
     314bs3kit-pae16_32_TEMPLATE = VBoxBS3KitImg32
     315bs3kit-pae16_32_INSTTYPE = none
     316bs3kit-pae16_32_DEFS     = TMPL_MODE=BS3_MODE_PAE16_32
     317bs3kit-pae16_32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     318
     319# The v8086 BS3Kit library for 16-bit PAE paged protected kernel+tss.
     320LIBRARIES += bs3kit-pae16_v86
     321bs3kit-pae16_v86_TEMPLATE = VBoxBS3KitImg
     322bs3kit-pae16_v86_INSTTYPE = none
     323bs3kit-pae16_v86_DEFS     = TMPL_MODE=BS3_MODE_PAE16_V86
     324bs3kit-pae16_v86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     325
     326# The 32-bit BS3Kit library for 32-bit PAE paged protected kernel+tss.
    268327LIBRARIES += bs3kit-pae32
    269328bs3kit-pae32_TEMPLATE = VBoxBS3KitImg32
    270329bs3kit-pae32_INSTTYPE = none
    271 bs3kit-pae32_DEFS     = TMPL_PAE32
     330bs3kit-pae32_DEFS     = TMPL_MODE=BS3_MODE_PAE32
    272331bs3kit-pae32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    273332
    274 # The virtual 8086 under protected mode BS3Kit library.
     333# The 16-bit BS3Kit library for 32-bit PAE paged protected kernel+tss.
     334LIBRARIES += bs3kit-pae32_16
     335bs3kit-pae32_16_TEMPLATE = VBoxBS3KitImg
     336bs3kit-pae32_16_INSTTYPE = none
     337bs3kit-pae32_16_DEFS     = TMPL_MODE=BS3_MODE_PAE32_16
     338bs3kit-pae32_16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
     339
     340# The v8086 BS3Kit library for 32-bit PAE paged protected kernel+tss.
    275341LIBRARIES += bs3kit-paev86
    276342bs3kit-paev86_TEMPLATE = VBoxBS3KitImg
    277343bs3kit-paev86_INSTTYPE = none
    278 bs3kit-paev86_DEFS     = TMPL_PAEV86
    279 bs3kit-paev86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
     344bs3kit-paev86_DEFS     = TMPL_MODE=BS3_MODE_PAEV86
     345bs3kit-paev86_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    280346
    281347
     
    284350bs3kit-lm16_TEMPLATE = VBoxBS3KitImg
    285351bs3kit-lm16_INSTTYPE = none
    286 bs3kit-lm16_DEFS     = TMPL_LM16
    287 bs3kit-lm16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
     352bs3kit-lm16_DEFS     = TMPL_MODE=BS3_MODE_LM16
     353bs3kit-lm16_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    288354
    289355# The 32-bit long mode BS3Kit library.
     
    291357bs3kit-lm32_TEMPLATE = VBoxBS3KitImg32
    292358bs3kit-lm32_INSTTYPE = none
    293 bs3kit-lm32_DEFS     = TMPL_LM32
    294 bs3kit-lm32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES) \
     359bs3kit-lm32_DEFS     = TMPL_MODE=BS3_MODE_LM32
     360bs3kit-lm32_SOURCES  = $(VBOX_BS3KIT_MODE_SOURCES)
    295361
    296362# The 64-bit long mode BS3Kit library.
     
    298364bs3kit-lm64-asm_TEMPLATE = VBoxBS3KitImg64
    299365bs3kit-lm64-asm_INSTTYPE = none
    300 bs3kit-lm64-asm_DEFS     = TMPL_LM64
    301 bs3kit-lm64-asm_SOURCES  = $(filter %.asm,$(VBOX_BS3KIT_MODE_SOURCES)) \
     366bs3kit-lm64-asm_DEFS     = TMPL_MODE=BS3_MODE_LM64
     367bs3kit-lm64-asm_SOURCES  = $(filter %.asm,$(VBOX_BS3KIT_MODE_SOURCES))
    302368
    303369# The 64-bit long mode BS3Kit library.
     
    305371bs3kit-lm64-c_TEMPLATE = VBoxBS3KitImg64
    306372bs3kit-lm64-c_INSTTYPE = none
    307 bs3kit-lm64-c_DEFS     = TMPL_LM64
    308 bs3kit-lm64-c_SOURCES  = $(filter-out %.asm, $(VBOX_BS3KIT_MODE_SOURCES)) \
     373bs3kit-lm64-c_DEFS     = TMPL_MODE=BS3_MODE_LM64
     374bs3kit-lm64-c_SOURCES  = $(filter-out %.asm, $(VBOX_BS3KIT_MODE_SOURCES))
    309375
    310376
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm

    r59287 r59863  
    2626
    2727%include "bs3kit-template-header.mac"
     28
     29%if TMPL_BITS != 16
     30BS3_EXTERN_DATA16 g_bBs3CurrentMode
     31TMPL_BEGIN_TEXT
     32%endif
     33
    2834
    2935;;
     
    6268        mov     es, ax
    6369
     70        ; Update globals.
     71        and     byte [g_bBs3CurrentMode], ~BS3_MODE_CODE_MASK
     72        or      byte [g_bBs3CurrentMode], BS3_MODE_CODE_16
     73
    6474        popfd
    6575 %if TMPL_BITS == 64
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm

    r59287 r59863  
    2626
    2727%include "bs3kit-template-header.mac"
     28
     29
     30%if TMPL_BITS != 32
     31BS3_EXTERN_DATA16 g_bBs3CurrentMode
     32TMPL_BEGIN_TEXT
     33%endif
     34
    2835
    2936;;
     
    7279        mov     es, ax
    7380
     81        ; Update globals.
     82        and     byte [g_bBs3CurrentMode], ~BS3_MODE_CODE_MASK
     83        or      byte [g_bBs3CurrentMode], BS3_MODE_CODE_32
     84
    7485 %if TMPL_BITS == 16
    7586        ; Adjust the return address.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm

    r59287 r59863  
    2727%include "bs3kit-template-header.mac"
    2828
    29 %ifndef TMPL_CMN_LM
     29%if TMPL_BITS != 64
     30BS3_EXTERN_DATA16 g_bBs3CurrentMode
     31TMPL_BEGIN_TEXT
     32%endif
     33
    3034
    3135;;
     
    3539;
    3640BS3_PROC_BEGIN_CMN Bs3SwitchTo64Bit
    37  %if TMPL_BITS == 64
     41%if TMPL_BITS == 64
    3842        ret
     43%else
     44 %if TMPL_BITS == 16
     45        sub     sp, 6                   ; Space for extended return value (corrected in 64-bit mode).
    3946 %else
    40   %if TMPL_BITS == 16
    41         sub     sp, 6                   ; Space for extended return value (corrected in 64-bit mode).
    42   %else
    4347        push    xPRE [xSP]              ; Duplicate the return address.
    4448        and     dword [xSP + xCB], 0    ; Clear the high dword or it.
    45   %endif
     49 %endif
    4650        push    dword 0
    4751        push    sAX
     
    5862        ; setup far return.
    5963        push    sAX
    60  %if TMPL_BITS == 16
     64%if TMPL_BITS == 16
    6165        push    dword .sixty_four_bit
    6266        o32 retf
    63  %else
     67%else
    6468        push    .sixty_four_bit
    6569        retf
    66  %endif
     70%endif
    6771
    6872BS3_SET_BITS 64
     
    7579        mov     es, ax
    7680
    77   %if TMPL_BITS == 16
     81        ; Update globals.
     82        and     byte [BS3_WRT_RIP(g_bBs3CurrentMode)], ~BS3_MODE_CODE_MASK
     83        or      byte [BS3_WRT_RIP(g_bBs3CurrentMode)], BS3_MODE_CODE_64
     84
     85 %if TMPL_BITS == 16
    7886        movzx   eax, word [rsp + 8*2+6]
    7987        add     eax, BS3_ADDR_BS3TEXT16
    8088        mov     [rsp + 8*2], rax
    81   %endif
     89 %endif
    8290
    8391        popfq
    8492        pop     rax
    8593        ret
    86  %endif
     94%endif
    8795BS3_PROC_END_CMN   Bs3SwitchTo64Bit
    8896
    89 %endif
    90 
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestData.c

    r59237 r59863  
    4242
    4343/** The number of tests that have failed. */
    44 uint16_t    g_uscBs3TestErrors = 0;
     44uint16_t    g_cusBs3TestErrors = 0;
    4545
    4646/** The start error count of the current subtest. */
    47 uint16_t    g_uscBs3SubTestAtErrors = 0;
     47uint16_t    g_cusBs3SubTestAtErrors = 0;
    4848
    4949/** Whether we've reported the sub-test result or not. */
     
    5151
    5252/** The number of sub tests. */
    53 uint16_t    g_uscBs3SubTests = 0;
     53uint16_t    g_cusBs3SubTests = 0;
    5454
    5555/** The number of sub tests that failed. */
    56 uint16_t    g_uscBs3SubTestsFailed = 0;
     56uint16_t    g_cusBs3SubTestsFailed = 0;
    5757
    5858/** VMMDEV_TESTING_UNIT_XXX -> string */
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c

    r58675 r59863  
    4343    BS3_CMN_NM(g_pszBs3Test)    = pszTest;
    4444    BS3_CMN_NM(g_pszBs3SubTest) = NULL;
    45     g_uscBs3TestErrors          = 0;
    46     g_uscBs3SubTestAtErrors     = 0;
     45    g_cusBs3TestErrors          = 0;
     46    g_cusBs3SubTestAtErrors     = 0;
    4747    g_fbBs3SubTestReported      = true;
    48     g_uscBs3SubTests            = 0;
    49     g_uscBs3SubTestsFailed      = 0;
     48    g_cusBs3SubTests            = 0;
     49    g_cusBs3SubTestsFailed      = 0;
    5050    g_fbBs3VMMDevTesting        = bs3TestIsVmmDevTestingPresent();
    5151
     
    5959     * Report it to the VMMDev.
    6060     */
    61     bs3TestSendStrCmd(VMMDEV_TESTING_CMD_INIT, pszTest);
     61    bs3TestSendCmdWithStr(VMMDEV_TESTING_CMD_INIT, pszTest);
    6262}
    6363
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithStr.asm

    r59827 r59863  
    3232
    3333;;
    34 ; @cproto   BS3_DECL(void) bs3TestSendStrCmd_c16(uint32_t uCmd, const char BS3_FAR *pszString);
     34; @cproto   BS3_DECL(void) bs3TestSendCmdWithStr_c16(uint32_t uCmd, const char BS3_FAR *pszString);
    3535;
    36 BS3_PROC_BEGIN_CMN bs3TestSendStrCmd
     36BS3_PROC_BEGIN_CMN bs3TestSendCmdWithStr
    3737        BS3_CALL_CONV_PROLOG 2
    3838        push    xBP
     
    4848        ; The command (uCmd).
    4949        mov     dx, VMMDEV_TESTING_IOPORT_CMD
    50         mov     eax, [xBP + xCB]
     50        mov     eax, [xBP + xCB*2]
    5151        out     dx, eax
    5252
     
    5454        mov     dx, VMMDEV_TESTING_IOPORT_DATA
    5555%ifdef TMPL_16BIT
    56         lds     si, [xBP + xCB + sCB]
     56        lds     si, [xBP + xCB*2 + sCB]
    5757%else
    58         mov     xSI, [xBP + xCB + sCB]
     58        mov     xSI, [xBP + xCB*2 + sCB]
    5959%endif
    6060.next_char:
     
    7272        BS3_CALL_CONV_EPILOG 2
    7373        ret
    74 BS3_PROC_END_CMN   bs3TestSendStrCmd
     74BS3_PROC_END_CMN   bs3TestSendCmdWithStr
    7575
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-test.h

    r58675 r59863  
    3636
    3737/** The number of tests that have failed. */
    38 extern uint16_t             g_uscBs3TestErrors;
     38extern uint16_t             g_cusBs3TestErrors;
    3939
    4040/** The start error count of the current subtest. */
    41 extern uint16_t             g_uscBs3SubTestAtErrors;
     41extern uint16_t             g_cusBs3SubTestAtErrors;
    4242
    4343/**  Whether we've reported the sub-test result or not. */
     
    4545
    4646/** The number of sub tests. */
    47 extern uint16_t             g_uscBs3SubTests;
     47extern uint16_t             g_cusBs3SubTests;
    4848
    4949/** The number of sub tests that failed. */
    50 extern uint16_t             g_uscBs3SubTestsFailed;
     50extern uint16_t             g_cusBs3SubTestsFailed;
    5151
    5252/** VMMDEV_TESTING_UNIT_XXX -> string */
     
    6969 * do nothing.
    7070 *
    71  * @param   uCmd       The command.
    72  * @param   pszString  The string.
     71 * @param   uCmd        The command.
     72 * @param   pszString   The string.
    7373 */
    74 BS3_DECL(void) bs3TestSendStrCmd_c16(uint32_t uCmd, const char BS3_FAR *pszString);
    75 BS3_DECL(void) bs3TestSendStrCmd_c32(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendStrCmd_c16 */
    76 BS3_DECL(void) bs3TestSendStrCmd_c64(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendStrCmd_c16 */
    77 #define bs3TestSendStrCmd BS3_CMN_NM(bs3TestSendStrCmd) /**< Selects #bs3TestSendStrCmd_c16, #bs3TestSendStrCmd_c32 or #bs3TestSendStrCmd_c64. */
     74BS3_DECL(void) bs3TestSendCmdWithStr_c16(uint32_t uCmd, const char BS3_FAR *pszString);
     75BS3_DECL(void) bs3TestSendCmdWithStr_c32(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendCmdWithStr_c16 */
     76BS3_DECL(void) bs3TestSendCmdWithStr_c64(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendCmdWithStr_c16 */
     77#define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr) /**< Selects #bs3TestSendCmdWithStr_c16, #bs3TestSendCmdWithStr_c32 or #bs3TestSendCmdWithStr_c64. */
     78
     79/**
     80 * Sends a command to VMMDev followed by a 32-bit unsigned integer value.
     81 *
     82 * If the VMMDev is not present or is not being used, this function will
     83 * do nothing.
     84 *
     85 * @param   uCmd        The command.
     86 * @param   uValue      The value.
     87 */
     88BS3_DECL(void) bs3TestSendCmdWithU32_c16(uint32_t uCmd, uint32_t uValue);
     89BS3_DECL(void) bs3TestSendCmdWithU32_c32(uint32_t uCmd, uint32_t uValue); /**< @copydoc bs3TestSendCmdWithU32_c16 */
     90BS3_DECL(void) bs3TestSendCmdWithU32_c64(uint32_t uCmd, uint32_t uValue); /**< @copydoc bs3TestSendCmdWithU32_c16 */
     91#define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32) /**< Selects #bs3TestSendCmdWithU32_c16, #bs3TestSendCmdWithU32_c32 or #bs3TestSendCmdWithU32_c64. */
    7892
    7993
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm

    r58812 r59863  
    3838EXTERN Main_rm
    3939BS3_EXTERN_CMN Bs3Shutdown
     40        push    word 0                  ; zero return address.
     41        push    word 0                  ; zero caller BP
     42        mov     bp, sp
    4043
    41     ;
    42     ; Nothing to init here, just call main and shutdown if it returns.
    43     ;
    44     mov     ax, BS3DATA16
    45     mov     es, ax
    46     mov     ds, ax
    47     call    NAME(Main_rm)
    48     call    Bs3Shutdown
     44        ;
     45        ; Nothing to init here, just call main and shutdown if it returns.
     46        ;
     47        mov     ax, BS3DATA16
     48        mov     es, ax
     49        mov     ds, ax
     50        call    NAME(Main_rm)
     51        call    Bs3Shutdown
    4952
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm

    r59287 r59863  
    2727%include "bs3kit-template-header.mac"
    2828
     29BS3_EXTERN_DATA16 g_bBs3CurrentMode
     30TMPL_BEGIN_TEXT
    2931
    3032;;
     
    3941        mov     xBP, xSP
    4042        push    xAX
    41 %if TMPL_BITS == 64
     43%if BS3_MODE_IS_64BIT_CODE(TMPL_MODE)
    4244        push    rcx
    4345        push    rdx
     
    4951        ; Load stack selector (not always necessary) and sometimes CS too.
    5052        ;
    51 %ifdef TMPL_RM
     53%if BS3_MODE_IS_RM_SYS(TMPL_MODE)
    5254        xor     ax, ax
    53 %elifdef TMPL_CMN_V86
     55%elif BS3_MODE_IS_V86(TMPL_MODE)
    5456        extern  v86_versions_of_Bs3EnteredMode_should_not_be_dragged_into_the_link
    5557        call    v86_versions_of_Bs3EnteredMode_should_not_be_dragged_into_the_link
    56 %elif TMPL_BITS == 16
     58%elif BS3_MODE_IS_16BIT_CODE(TMPL_MODE)
    5759        jmp     BS3_SEL_R0_CS16:.reloaded_cs
    5860.reloaded_cs:
    5961        mov     ax, BS3_SEL_R0_SS16
    60 %elif TMPL_BITS == 32
     62%elif BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
    6163        mov     ax, BS3_SEL_R0_SS32
    62 %elif TMPL_BITS == 64
     64%elif BS3_MODE_IS_64BIT_CODE(TMPL_MODE)
    6365        mov     ax, BS3_SEL_R0_DS64
    6466%else
    65  %error "TMPL_BITS"
     67 %error "TMPL_MODE"
    6668%endif
    6769        mov     ss, ax
     
    7072        ; Load selector appropriate for accessing BS3SYSTEM16 data.
    7173        ;
    72 %if TMPL_BITS == 16
     74%if BS3_MODE_IS_16BIT_CODE(TMPL_MODE)
    7375        mov     ax, BS3_SEL_SYSTEM16
    7476%else
     
    8183        ; Always 64-bit in long mode, otherwise according to TMPL_BITS.
    8284        ;
    83 %ifdef TMPL_CMN_R86
     85%if BS3_MODE_IS_RM_SYS(TMPL_MODE)
    8486        BS3_EXTERN_SYSTEM16 Bs3Lidt_Ivt
    8587        TMPL_BEGIN_TEXT
    8688        lidt    [Bs3Lidt_Ivt]
    87 %elifdef TMPL_CMN_LM
     89
     90%elif BS3_MODE_IS_16BIT_SYS(TMPL_MODE)
     91        BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt16
     92        TMPL_BEGIN_TEXT
     93        lidt    [Bs3Lidt_Idt16 TMPL_WRT_SYSTEM16_OR_FLAT]
     94
     95%elif BS3_MODE_IS_32BIT_SYS(TMPL_MODE)
     96        BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt32
     97        TMPL_BEGIN_TEXT
     98        lidt    [Bs3Lidt_Idt32 TMPL_WRT_SYSTEM16_OR_FLAT]
     99
     100%elif BS3_MODE_IS_64BIT_SYS(TMPL_MODE)
    88101        BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt64
    89102        TMPL_BEGIN_TEXT
    90103        lidt    [Bs3Lidt_Idt64 TMPL_WRT_SYSTEM16_OR_FLAT]
    91104%else
    92         BS3_EXTERN_SYSTEM16 RT_CONCAT(Bs3Lidt_Idt,TMPL_BITS)
    93         TMPL_BEGIN_TEXT
    94         lidt    [RT_CONCAT(Bs3Lidt_Idt,TMPL_BITS) TMPL_WRT_SYSTEM16_OR_FLAT]
    95 %endif
    96 
    97 %ifndef TMPL_CMN_R86
     105 %error "TMPL_MODE"
     106%endif
     107
     108%if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
    98109        ;
    99110        ; Load the appropriate task selector.
     
    101112        ;
    102113        mov     ax, X86DESCGENERIC_BIT_OFF_TYPE + 1 ; For clearing the busy bit in the TSS descriptor type.
    103  %ifdef TMPL_CMN_LM
     114 %if BS3_MODE_IS_64BIT_SYS(TMPL_MODE)
    104115        BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss64
    105116        TMPL_BEGIN_TEXT
     
    107118        mov     ax, BS3_SEL_TSS64
    108119
    109  %elif TMPL_BITS == 16
     120 %elif BS3_MODE_IS_16BIT_SYS(TMPL_MODE)
    110121        BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16
    111122        BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16DoubleFault
     
    115126        mov     ax, BS3_SEL_TSS16
    116127
    117  %elif TMPL_BITS == 32
     128 %elif BS3_MODE_IS_32BIT_SYS(TMPL_MODE)
    118129        BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32
    119130        BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32DoubleFault
     
    128139        mov     ax, BS3_SEL_TSS32
    129140 %else
    130  %error "TMPL_BITS"
     141  %error "TMPL_BITS"
    131142 %endif
    132143        ltr     ax
    133144%endif ; !TMPL_CMN_R86
    134145
    135 %ifndef TMPL_CMN_R86
     146%if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
    136147        ;
    137148        ; Load the LDT.
     
    153164
    154165        ;
     166        ; Set global indicating CPU mode.
     167        ;
     168        mov     byte [BS3_WRT_RIP(g_bBs3CurrentMode)], TMPL_MODE
     169
     170        ;
    155171        ; Install system call handler.
    156172        ; Always 64-bit in long mode, otherwise according to TMPL_BITS.
    157173        ;
    158 %ifdef TMPL_CMN_RM
    159         mov     word [ss: BS3_TRAP_SYSCALL*4], TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16
     174%if BS3_MODE_IS_RM_SYS(TMPL_MODE)
     175        extern         _Bs3TrapSystemCallHandler_rm
     176        mov     word [ss: BS3_TRAP_SYSCALL*4], _Bs3TrapSystemCallHandler_rm wrt BS3TEXT16
    160177        mov     word [ss: BS3_TRAP_SYSCALL*4 + 2], BS3TEXT16
    161 %elifdef TMPL_CMN_LM
     178
     179%elif BS3_MODE_IS_16BIT_SYS(TMPL_MODE)
     180        BS3_EXTERN_CMN Bs3Trap16SetGate
     181        extern         TMPL_NM(Bs3TrapSystemCallHandler)
     182        BS3_BEGIN_TEXT16
     183        TMPL_BEGIN_TEXT
     184        push    0                       ; cParams
     185        push    TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16
     186        push    BS3_SEL_R0_CS16
     187        push    3                       ; DPL
     188        push    X86_SEL_TYPE_SYS_286_INT_GATE
     189        push    BS3_TRAP_SYSCALL
     190        BS3_CALL Bs3Trap16SetGate,6
     191        add     xSP, xCB * 6
     192
     193%elif BS3_MODE_IS_32BIT_SYS(TMPL_MODE)
     194        BS3_EXTERN_CMN Bs3Trap32SetGate
     195        extern         TMPL_NM(Bs3TrapSystemCallHandler)
     196        TMPL_BEGIN_TEXT
     197        push    0                       ; cParams
     198        push    dword TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT
     199        push    BS3_SEL_R0_CS32
     200        push    3                       ; DPL
     201        push    X86_SEL_TYPE_SYS_386_INT_GATE
     202        push    BS3_TRAP_SYSCALL
     203        BS3_CALL Bs3Trap32SetGate,6
     204        add     xSP, xCB * 6
     205
     206%elif BS3_MODE_IS_64BIT_SYS(TMPL_MODE)
    162207        BS3_EXTERN_CMN Bs3Trap64SetGate
    163208        extern         Bs3TrapSystemCallHandler_lm64
    164209        TMPL_BEGIN_TEXT
    165210        push    0                       ; bIst
    166  %ifdef TMPL_64BIT
     211 %if BS3_MODE_IS_64BIT_CODE(TMPL_MODE)
    167212        push    Bs3TrapSystemCallHandler_lm64 wrt FLAT
    168213 %else
     
    176221        BS3_CALL Bs3Trap64SetGate,6
    177222        add     xSP, xCB * 5 + 8
    178 
    179 %elif TMPL_BITS == 16
    180         BS3_EXTERN_CMN Bs3Trap16SetGate
    181         extern         TMPL_NM(Bs3TrapSystemCallHandler)
    182         TMPL_BEGIN_TEXT
    183         push    0                       ; cParams
    184         push    TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16
    185         push    BS3_SEL_R0_CS16
    186         push    3                       ; DPL
    187         push    X86_SEL_TYPE_SYS_286_INT_GATE
    188         push    BS3_TRAP_SYSCALL
    189         BS3_CALL Bs3Trap16SetGate,6
    190         add     xSP, xCB * 6
    191 
    192 %elif TMPL_BITS == 32
    193         BS3_EXTERN_CMN Bs3Trap32SetGate
    194         extern         TMPL_NM(Bs3TrapSystemCallHandler)
    195         TMPL_BEGIN_TEXT
    196         push    0                       ; cParams
    197         push    TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT
    198         push    BS3_SEL_R0_CS32
    199         push    3                       ; DPL
    200         push    X86_SEL_TYPE_SYS_386_INT_GATE
    201         push    BS3_TRAP_SYSCALL
    202         BS3_CALL Bs3Trap32SetGate,6
    203         add     xSP, xCB * 6
    204223%else
    205224 %error "TMPL_BITS"
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm

    r59287 r59863  
    3434; Switch to real mode from any other mode.
    3535;
    36 ; @cproto   BS3_DECL(void) Bs3SwitchToRealMode(void);
     36; @cproto   BS3_DECL(void) Bs3SwitchToRM(void);
    3737;
    3838; @uses     Nothing (except high 32-bit register parts).
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.h

    r59311 r59863  
    55
    66/*
    7  * Copyright (C) 2007-2015 Oracle Corporation
     7 * Copyright (C) 2007-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232#undef TMPL_RM
    3333#undef TMPL_PE16
     34#undef TMPL_PE16_32
     35#undef TMPL_PE16_V86
    3436#undef TMPL_PE32
     37#undef TMPL_PE32_16
    3538#undef TMPL_PEV86
    3639#undef TMPL_PP16
     40#undef TMPL_PP16_32
     41#undef TMPL_PP16_V86
    3742#undef TMPL_PP32
     43#undef TMPL_PP32_16
    3844#undef TMPL_PPV86
    3945#undef TMPL_PAE16
     46#undef TMPL_PAE16_32
     47#undef TMPL_PAE16_V86
    4048#undef TMPL_PAE32
     49#undef TMPL_PAE32_16
    4150#undef TMPL_PAEV86
    4251#undef TMPL_LM16
     
    4554
    4655#undef TMPL_CMN_PE
     56#undef TMPL_SYS_PE16
     57#undef TMPL_SYS_PE32
    4758#undef TMPL_CMN_PP
     59#undef TMPL_SYS_PP16
     60#undef TMPL_SYS_PP32
    4861#undef TMPL_CMN_PAE
     62#undef TMPL_SYS_PAE16
     63#undef TMPL_SYS_PAE32
    4964#undef TMPL_CMN_LM
    5065#undef TMPL_CMN_V86
     66#undef TMPL_CMN_R86
    5167#undef TMPL_CMN_PAGING
     68#undef TMPL_CMN_WEIRD
     69#undef TMPL_CMN_WEIRD_V86
    5270
    53 #undef TMPL_CMN_P16
    54 #undef TMPL_CMN_P32
    55 #undef TMPL_CMN_P64
    56 #undef TMPL_CMN_R16
    5771#undef TMPL_CMN_R86
    5872
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac

    r59311 r59863  
    4242%undef TMPL_RM
    4343%undef TMPL_PE16
     44%undef TMPL_PE16_32
     45%undef TMPL_PE16_V86
    4446%undef TMPL_PE32
     47%undef TMPL_PE32_16
    4548%undef TMPL_PEV86
    4649%undef TMPL_PP16
     50%undef TMPL_PP16_32
     51%undef TMPL_PP16_V86
    4752%undef TMPL_PP32
     53%undef TMPL_PP32_16
    4854%undef TMPL_PPV86
    4955%undef TMPL_PAE16
     56%undef TMPL_PAE16_32
     57%undef TMPL_PAE16_V86
    5058%undef TMPL_PAE32
     59%undef TMPL_PAE32_16
    5160%undef TMPL_PAEV86
    5261%undef TMPL_LM16
     
    5564
    5665%undef TMPL_CMN_PE
     66%undef TMPL_SYS_PE16
     67%undef TMPL_SYS_PE32
    5768%undef TMPL_CMN_PP
     69%undef TMPL_SYS_PP16
     70%undef TMPL_SYS_PP32
    5871%undef TMPL_CMN_PAE
     72%undef TMPL_SYS_PAE16
     73%undef TMPL_SYS_PAE32
    5974%undef TMPL_CMN_LM
    6075%undef TMPL_CMN_V86
     76%undef TMPL_CMN_R86
    6177%undef TMPL_CMN_PAGING
     78%undef TMPL_CMN_WEIRD
     79%undef TMPL_CMN_WEIRD_V86
    6280
    63 %undef TMPL_CMN_P16
    64 %undef TMPL_CMN_P32
    65 %undef TMPL_CMN_P64
    66 %undef TMPL_CMN_R16
    6781%undef TMPL_CMN_R86
    6882
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h

    r59311 r59863  
    5454 *
    5555 * @{ */
    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). */
     56# define TMPL_RM            /**< real mode. */
     57
     58# define TMPL_PE16          /**< 16-bit protected mode kernel+tss, running 16-bit code, unpaged. */
     59# define TMPL_PE16_32       /**< 16-bit protected mode kernel+tss, running 32-bit code, unpaged. */
     60# define TMPL_PE16_V86      /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
     61# define TMPL_PE32          /**< 32-bit protected mode kernel+tss, running 32-bit code, unpaged. */
     62# define TMPL_PE32_16       /**< 32-bit protected mode kernel+tss, running 16-bit code, unpaged. */
     63# define TMPL_PEV86         /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
     64
     65# define TMPL_PP16          /**< 16-bit protected mode kernel+tss, running 16-bit code, paged. */
     66# define TMPL_PP16_32       /**< 16-bit protected mode kernel+tss, running 32-bit code, paged. */
     67# define TMPL_PP16_V86      /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
     68# define TMPL_PP32          /**< 32-bit protected mode kernel+tss, running 32-bit code, paged. */
     69# define TMPL_PP32_16       /**< 32-bit protected mode kernel+tss, running 16-bit code, paged. */
     70# define TMPL_PPV86         /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
     71
     72# define TMPL_PAE16         /**< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
     73# define TMPL_PAE16_32      /**< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
     74# define TMPL_PAE16_V86     /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, PAE paging. */
     75# define TMPL_PAE32         /**< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
     76# define TMPL_PAE32_16      /**< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
     77# define TMPL_PAEV86        /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, PAE paging. */
     78
     79# define TMPL_LM16          /**< 16-bit long mode (paged), kernel+tss always 64-bit. */
     80# define TMPL_LM32          /**< 32-bit long mode (paged), kernel+tss always 64-bit. */
     81# define TMPL_LM64          /**< 64-bit long mode (paged), kernel+tss always 64-bit. */
    6982/** @} */
    7083
    7184/** @name Derived Indicators
    7285 * @{ */
    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 # define TMPL_CMN_PAGING /**< TMPL_CMN_PP | TMPL_CMN_PAE | TMPL_CMN_LM */
     86# define TMPL_CMN_PE        /**< TMPL_PE16  | TMPL_PE16_32  | TMPL_PE16_V86  | TMPL_PE32  | TMPL_PE32_16  | TMPL_PEV86 */
     87# define TMPL_SYS_PE16      /**< TMPL_PE16  | TMPL_PE16_32  | TMPL_PE16_V86 */
     88# define TMPL_SYS_PE32      /**< TMPL_PE32  | TMPL_PE32_16  | TMPL_PEV86 */
     89# define TMPL_CMN_PP        /**< TMPL_PP16  | TMPL_PP16_32  | TMPL_PP16_V86  | TMPL_PP32  | TMPL_PP32_16  | TMPL_PPV86 */
     90# define TMPL_SYS_PP16      /**< TMPL_PP16  | TMPL_PP16_32  | TMPL_PP16_V86 */
     91# define TMPL_SYS_PP32      /**< TMPL_PP32  | TMPL_PP32_16  | TMPL_PPV86 */
     92# define TMPL_CMN_PAE       /**< TMPL_PAE16 | TMPL_PAE16_32 | TMPL_PAE16_V86 | TMPL_PAE32 | TMPL_PAE32_16 | TMPL_PAEV86 */
     93# define TMPL_SYS_PAE16     /**< TMPL_PAE16 | TMPL_PAE16_32 | TMPL_PAE16_V86 */
     94# define TMPL_SYS_PAE32     /**< TMPL_PAE32 | TMPL_PAE32_16 | TMPL_PAEV86 */
     95# define TMPL_CMN_LM        /**< TMPL_LM16  | TMPL_LM32  | TMPL_LM64 */
     96# define TMPL_CMN_V86       /**< TMPL_PEV86 | TMPL_PE16_V86 | TMPL_PPV86 | TMPL_PP16_V86 | TMPL_PAEV86 | TMPL_PAE16_V86 */
     97# define TMPL_CMN_R86       /**< TMPL_CMN_V86 | TMPL_RM */
     98# define TMPL_CMN_PAGING    /**< TMPL_CMN_PP | TMPL_CMN_PAE | TMPL_CMN_LM */
     99# define TMPL_CMN_WEIRD     /**< TMPL_PE16_32 | TMPL_PE32_16 | TMPL_PP16_32 | TMPL_PP32_16 | TMPL_PAE16_32 | TMPL_PAE32_16 | TMPL_CMN_WEIRD_V86 */
     100# define TMPL_CMN_WEIRD_V86 /**< TMPL_PE16_V86 | TMPL_PP16_V86 | TMPL_PAE16_V86 */
    80101/** @} */
    81102
     
    119140#undef BS3_CMN_NM
    120141
    121 #ifdef TMPL_RM
    122 # ifdef TMPL_PE16
    123 #  error "Both 'TMPL_RM' and 'TMPL_PE16' are defined."
     142
     143/*
     144 * Convert TMPL_XXX to TMPL_MODE.
     145 */
     146#ifndef TMPL_MODE
     147# ifdef TMPL_RM
     148#  define TMPL_MODE         BS3_MODE_RM
     149# elif defined(TMPL_PE16)
     150#  define TMPL_MODE         BS3_MODE_PE16
     151# elif defined(TMPL_PE16_32)
     152#  define TMPL_MODE         BS3_MODE_PE16_32
     153# elif defined(TMPL_PE16_V86)
     154#  define TMPL_MODE         BS3_MODE_PE16_V86
     155# elif defined(TMPL_PE32)
     156#  define TMPL_MODE         BS3_MODE_PE32
     157# elif defined(TMPL_PE32_16)
     158#  define TMPL_MODE         BS3_MODE_PE32_16
     159# elif defined(TMPL_PEV86)
     160#  define TMPL_MODE         BS3_MODE_PEV86
     161# elif defined(TMPL_PP16)
     162#  define TMPL_MODE         BS3_MODE_PP16
     163# elif defined(TMPL_PP16_32)
     164#  define TMPL_MODE         BS3_MODE_PP16_32
     165# elif defined(TMPL_PP16_V86)
     166#  define TMPL_MODE         BS3_MODE_PP16_V86
     167# elif defined(TMPL_PP32)
     168#  define TMPL_MODE         BS3_MODE_PP32
     169# elif defined(TMPL_PP32_16)
     170#  define TMPL_MODE         BS3_MODE_PP32_16
     171# elif defined(TMPL_PPV86)
     172#  define TMPL_MODE         BS3_MODE_PPV86
     173# elif defined(TMPL_PAE16)
     174#  define TMPL_MODE         BS3_MODE_PAE16
     175# elif defined(TMPL_PAE16_32)
     176#  define TMPL_MODE         BS3_MODE_PAE16_32
     177# elif defined(TMPL_PAE16_V86)
     178#  define TMPL_MODE         BS3_MODE_PAE16_V86
     179# elif defined(TMPL_PAE32)
     180#  define TMPL_MODE         BS3_MODE_PAE32
     181# elif defined(TMPL_PAE32_16)
     182#  define TMPL_MODE         BS3_MODE_PAE32_16
     183# elif defined(TMPL_PAEV86)
     184#  define TMPL_MODE         BS3_MODE_PAEV86
     185# elif defined(TMPL_LM16)
     186#  define TMPL_MODE         BS3_MODE_LM16
     187# elif defined(TMPL_LM32)
     188#  define TMPL_MODE         BS3_MODE_LM32
     189# elif defined(TMPL_LM64)
     190#  define TMPL_MODE         BS3_MODE_LM64
     191# else
     192#  error "Unable to to figure out the template mode."
    124193# endif
    125 # ifdef TMPL_PE32
    126 #  error "Both 'TMPL_RM' and 'TMPL_PE32' are defined."
    127 # endif
    128 # ifdef TMPL_PEV86
    129 #  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    130 # endif
    131 # ifdef TMPL_PP16
    132 #  error "Both 'TMPL_RM' and 'TMPL_PP16' are defined."
    133 # endif
    134 # ifdef TMPL_PP32
    135 #  error "Both 'TMPL_RM' and 'TMPL_PP32' are defined."
    136 # endif
    137 # ifdef TMPL_PPV86
    138 #  error "Both 'TMPL_RM' and 'TMPL_PPV86' are defined."
    139 # endif
    140 # ifdef TMPL_PAE16
    141 #  error "Both 'TMPL_RM' and 'TMPL_PAE16' are defined."
    142 # endif
    143 # ifdef TMPL_PAE32
    144 #  error "Both 'TMPL_RM' and 'TMPL_PAE32' are defined."
    145 # endif
    146 # ifdef TMPL_PAEV86
    147 #  error "Both 'TMPL_RM' and 'TMPL_PAEV86' are defined."
    148 # endif
    149 # ifdef TMPL_LM16
    150 #  error "Both 'TMPL_RM' and 'TMPL_LM16' are defined."
    151 # endif
    152 # ifdef TMPL_LM32
    153 #  error "Both 'TMPL_RM' and 'TMPL_LM32' are defined."
    154 # endif
    155 # ifdef TMPL_LM64
    156 #  error "Both 'TMPL_RM' and 'TMPL_LM64' are defined."
    157 # endif
     194#endif
     195
     196
     197/*
     198 * Check the code bitness and set derived defines.
     199 */
     200#if (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16
    158201# if ARCH_BITS != 16
    159 #  error "TMPL_RM requires ARCH_BITS to be 16."
     202#  error "BS3_MODE_CODE_16 requires ARCH_BITS to be 16."
    160203# endif
    161204# define TMPL_16BIT
    162205# define TMPL_BITS              16
    163 # define TMPL_NM(Name)          RT_CONCAT(Name,_rm)
     206# define TMPL_UNDERSCORE        _
    164207# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    165 # define TMPL_MODE_STR          "real mode"
     208
     209#elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32
     210# if ARCH_BITS != 32
     211#  error "BS3_MODE_CODE_32 requires ARCH_BITS to be 32."
     212# endif
     213# define TMPL_32BIT
     214# define TMPL_BITS              32
     215# define TMPL_UNDERSCORE        _
     216# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
     217
     218#elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86
     219# if ARCH_BITS != 16
     220#  error "BS3_MODE_CODE_V86 requires ARCH_BITS to be 16."
     221# endif
     222# define TMPL_16BIT
     223# define TMPL_BITS              16
     224# define TMPL_UNDERSCORE        _
     225# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
     226# define TMPL_CMN_R86
     227# define TMPL_CMN_V86
     228
     229#elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64
     230# if ARCH_BITS != 64
     231#  error "BS3_MODE_CODE_64 requires ARCH_BITS to be 64."
     232# endif
     233# define TMPL_64BIT
     234# define TMPL_BITS              64
     235# define TMPL_UNDERSCORE
     236# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
     237
     238#else
     239# error "Invalid TMPL_MODE value!"
     240#endif
     241
     242
     243/*
     244 * Check the system specific mask and set derived values.
     245 */
     246#if (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM
    166247# define TMPL_HAVE_BIOS
    167248# define TMPL_CMN_R86
    168 #endif
    169 
    170 #ifdef TMPL_PE16
    171 # ifdef TMPL_RM
    172 #  error "Both 'TMPL_PE16' and 'TMPL_RM' are defined."
    173 # endif
    174 # ifdef TMPL_PE32
    175 #  error "Both 'TMPL_PE16' and 'TMPL_PE32' are defined."
    176 # endif
    177 # ifdef TMPL_PEV86
    178 #  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    179 # endif
    180 # ifdef TMPL_PP16
    181 #  error "Both 'TMPL_PE16' and 'TMPL_PP16' are defined."
    182 # endif
    183 # ifdef TMPL_PP32
    184 #  error "Both 'TMPL_PE16' and 'TMPL_PP32' are defined."
    185 # endif
    186 # ifdef TMPL_PPV86
    187 #  error "Both 'TMPL_PE16' and 'TMPL_PPV86' are defined."
    188 # endif
    189 # ifdef TMPL_PAE16
    190 #  error "Both 'TMPL_PE16' and 'TMPL_PAE16' are defined."
    191 # endif
    192 # ifdef TMPL_PAE32
    193 #  error "Both 'TMPL_PE16' and 'TMPL_PAE32' are defined."
    194 # endif
    195 # ifdef TMPL_PAEV86
    196 #  error "Both 'TMPL_PE32' and 'TMPL_PAEV86' are defined."
    197 # endif
    198 # ifdef TMPL_LM16
    199 #  error "Both 'TMPL_PE16' and 'TMPL_LM16' are defined."
    200 # endif
    201 # ifdef TMPL_LM32
    202 #  error "Both 'TMPL_PE16' and 'TMPL_LM32' are defined."
    203 # endif
    204 # ifdef TMPL_LM64
    205 #  error "Both 'TMPL_PE16' and 'TMPL_LM64' are defined."
    206 # endif
    207 # if ARCH_BITS != 16
    208 #  error "TMPL_PE16 requires ARCH_BITS to be 16."
    209 # endif
     249
     250#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16
     251# define TMPL_SYS_PE16
    210252# define TMPL_CMN_PE
    211 # define TMPL_CMN_P16
    212 # define TMPL_16BIT
    213 # define TMPL_BITS              16
    214 # define TMPL_NM(Name)          RT_CONCAT(Name,_pe16)
    215 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    216 # define TMPL_MODE_STR          "16-bit unpaged protected mode"
    217 #endif
    218 
    219 #ifdef TMPL_PE32
    220 # ifdef TMPL_RM
    221 #  error "Both 'TMPL_PE32' and 'TMPL_RM' are defined."
    222 # endif
    223 # ifdef TMPL_PE16
    224 #  error "Both 'TMPL_PE32' and 'TMPL_PE16' are defined."
    225 # endif
    226 # ifdef TMPL_PEV86
    227 #  error "Both 'TMPL_PE32' and 'TMPL_PEV86' are defined."
    228 # endif
    229 # ifdef TMPL_PP16
    230 #  error "Both 'TMPL_PE32' and 'TMPL_PP16' are defined."
    231 # endif
    232 # ifdef TMPL_PP32
    233 #  error "Both 'TMPL_PE32' and 'TMPL_PP32' are defined."
    234 # endif
    235 # ifdef TMPL_PPV86
    236 #  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    237 # endif
    238 # ifdef TMPL_PAE16
    239 #  error "Both 'TMPL_PE32' and 'TMPL_PAE16' are defined."
    240 # endif
    241 # ifdef TMPL_PAE32
    242 #  error "Both 'TMPL_PE32' and 'TMPL_PAE32' are defined."
    243 # endif
    244 # ifdef TMPL_PAE86
    245 #  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    246 # endif
    247 # ifdef TMPL_LM16
    248 #  error "Both 'TMPL_PE32' and 'TMPL_LM16' are defined."
    249 # endif
    250 # ifdef TMPL_LM32
    251 #  error "Both 'TMPL_PE32' and 'TMPL_LM32' are defined."
    252 # endif
    253 # ifdef TMPL_LM64
    254 #  error "Both 'TMPL_PE32' and 'TMPL_LM64' are defined."
    255 # endif
    256 # if ARCH_BITS != 32
    257 #  error "TMPL_PE32 requires ARCH_BITS to be 32."
    258 # endif
     253
     254#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32
     255# define TMPL_SYS_PE32
    259256# define TMPL_CMN_PE
    260 # define TMPL_CMN_P32
    261 # define TMPL_32BIT
    262 # define TMPL_BITS              32
    263 # define TMPL_NM(Name)          RT_CONCAT(Name,_pe32)
    264 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
    265 # define TMPL_MODE_STR          "32-bit unpaged protected mode"
    266 #endif
    267 
    268 #ifdef TMPL_PEV86
    269 # ifdef TMPL_RM
    270 #  error "Both 'TMPL_PEV86' and 'TMPL_RM' are defined."
    271 # endif
    272 # ifdef TMPL_PE16
    273 #  error "Both 'TMPL_PEV86' and 'TMPL_PE16' are defined."
    274 # endif
    275 # ifdef TMPL_PP32
    276 #  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    277 # endif
    278 # ifdef TMPL_PP16
    279 #  error "Both 'TMPL_PEV86' and 'TMPL_PP16' are defined."
    280 # endif
    281 # ifdef TMPL_PP32
    282 #  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    283 # endif
    284 # ifdef TMPL_PPV86
    285 #  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    286 # endif
    287 # ifdef TMPL_PAE16
    288 #  error "Both 'TMPL_PEV86' and 'TMPL_PAE16' are defined."
    289 # endif
    290 # ifdef TMPL_PAE32
    291 #  error "Both 'TMPL_PEV86' and 'TMPL_PAE32' are defined."
    292 # endif
    293 # ifdef TMPL_PAE86
    294 #  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    295 # endif
    296 # ifdef TMPL_LM16
    297 #  error "Both 'TMPL_PEV86' and 'TMPL_LM16' are defined."
    298 # endif
    299 # ifdef TMPL_LM32
    300 #  error "Both 'TMPL_PEV86' and 'TMPL_LM32' are defined."
    301 # endif
    302 # ifdef TMPL_LM64
    303 #  error "Both 'TMPL_PEV86' and 'TMPL_LM64' are defined."
    304 # endif
    305 # if ARCH_BITS != 16
    306 #  error "TMPL_PEV86 requires ARCH_BITS to be 16."
    307 # endif
    308 # define TMPL_CMN_PE
    309 # define TMPL_CMN_V86
    310 # define TMPL_CMN_R86
    311 # define TMPL_16BIT
    312 # define TMPL_BITS              16
    313 # define TMPL_NM(Name)          RT_CONCAT(Name,_pev86)
    314 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    315 # define TMPL_MODE_STR          "v8086 unpaged protected mode"
    316 #endif
    317 
    318 #ifdef TMPL_PP16
    319 # ifdef TMPL_RM
    320 #  error "Both 'TMPL_PP16' and 'TMPL_RM' are defined."
    321 # endif
    322 # ifdef TMPL_PE16
    323 #  error "Both 'TMPL_PP16' and 'TMPL_PE16' are defined."
    324 # endif
    325 # ifdef TMPL_PE32
    326 #  error "Both 'TMPL_PP16' and 'TMPL_PE32' are defined."
    327 # endif
    328 # ifdef TMPL_PEV86
    329 #  error "Both 'TMPL_PP16' and 'TMPL_PEV86' are defined."
    330 # endif
    331 # ifdef TMPL_PP32
    332 #  error "Both 'TMPL_PP16' and 'TMPL_PP32' are defined."
    333 # endif
    334 # ifdef TMPL_PPV86
    335 #  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    336 # endif
    337 # ifdef TMPL_PAE16
    338 #  error "Both 'TMPL_PP16' and 'TMPL_PAE16' are defined."
    339 # endif
    340 # ifdef TMPL_PAE32
    341 #  error "Both 'TMPL_PP16' and 'TMPL_PAE32' are defined."
    342 # endif
    343 # ifdef TMPL_PAEV86
    344 #  error "Both 'TMPL_PP16' and 'TMPL_PAEV86' are defined."
    345 # endif
    346 # ifdef TMPL_LM16
    347 #  error "Both 'TMPL_PP16' and 'TMPL_LM16' are defined."
    348 # endif
    349 # ifdef TMPL_LM32
    350 #  error "Both 'TMPL_PP16' and 'TMPL_LM32' are defined."
    351 # endif
    352 # ifdef TMPL_LM64
    353 #  error "Both 'TMPL_PP16' and 'TMPL_LM64' are defined."
    354 # endif
    355 # if ARCH_BITS != 16
    356 #  error "TMPL_PP16 requires ARCH_BITS to be 16."
    357 # endif
     257
     258#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16
     259# define TMPL_SYS_PP16
    358260# define TMPL_CMN_PP
    359261# define TMPL_CMN_PAGING
    360 # define TMPL_CMN_P16
    361 # define TMPL_16BIT
    362 # define TMPL_BITS              16
    363 # define TMPL_NM(Name)          RT_CONCAT(Name,_pp16)
    364 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    365 # define TMPL_MODE_STR          "16-bit paged protected mode"
    366 #endif
    367 
    368 #ifdef TMPL_PP32
    369 # ifdef TMPL_RM
    370 #  error "Both 'TMPL_PP32' and 'TMPL_RM' are defined."
    371 # endif
    372 # ifdef TMPL_PE16
    373 #  error "Both 'TMPL_PP32' and 'TMPL_PE16' are defined."
    374 # endif
    375 # ifdef TMPL_PE32
    376 #  error "Both 'TMPL_PP32' and 'TMPL_PE32' are defined."
    377 # endif
    378 # ifdef TMPL_PEV86
    379 #  error "Both 'TMPL_PP32' and 'TMPL_PEV86' are defined."
    380 # endif
    381 # ifdef TMPL_PP16
    382 #  error "Both 'TMPL_PP32' and 'TMPL_PP16' are defined."
    383 # endif
    384 # ifdef TMPL_PPV86
    385 #  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    386 # endif
    387 # ifdef TMPL_PAE16
    388 #  error "Both 'TMPL_PP32' and 'TMPL_PAE16' are defined."
    389 # endif
    390 # ifdef TMPL_PAE32
    391 #  error "Both 'TMPL_PP32' and 'TMPL_PAE32' are defined."
    392 # endif
    393 # ifdef TMPL_PAEV86
    394 #  error "Both 'TMPL_PP32' and 'TMPL_PAEV86' are defined."
    395 # endif
    396 # ifdef TMPL_LM16
    397 #  error "Both 'TMPL_PP32' and 'TMPL_LM16' are defined."
    398 # endif
    399 # ifdef TMPL_LM32
    400 #  error "Both 'TMPL_PP32' and 'TMPL_LM32' are defined."
    401 # endif
    402 # ifdef TMPL_LM64
    403 #  error "Both 'TMPL_PP32' and 'TMPL_LM64' are defined."
    404 # endif
    405 # if ARCH_BITS != 32
    406 #  error "TMPL_PP32 requires ARCH_BITS to be 32."
    407 # endif
     262
     263#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32
     264# define TMPL_SYS_PP32
    408265# define TMPL_CMN_PP
    409266# define TMPL_CMN_PAGING
    410 # define TMPL_CMN_P32
    411 # define TMPL_32BIT
    412 # define TMPL_BITS              32
    413 # define TMPL_NM(Name)          RT_CONCAT(Name,_pp32)
    414 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
    415 # define TMPL_MODE_STR          "32-bit paged protected mode"
    416 #endif
    417 
    418 #ifdef TMPL_PPV86
    419 # ifdef TMPL_RM
    420 #  error "Both 'TMPL_PPV86' and 'TMPL_RM' are defined."
    421 # endif
    422 # ifdef TMPL_PE16
    423 #  error "Both 'TMPL_PPV86' and 'TMPL_PE16' are defined."
    424 # endif
    425 # ifdef TMPL_PE32
    426 #  error "Both 'TMPL_PPV86' and 'TMPL_PE32' are defined."
    427 # endif
    428 # ifdef TMPL_PEV86
    429 #  error "Both 'TMPL_PPV86' and 'TMPL_PEV86' are defined."
    430 # endif
    431 # ifdef TMPL_PP16
    432 #  error "Both 'TMPL_PPV86' and 'TMPL_PP16' are defined."
    433 # endif
    434 # ifdef TMPL_PP32
    435 #  error "Both 'TMPL_PPV86' and 'TMPL_PP32' are defined."
    436 # endif
    437 # ifdef TMPL_PAE16
    438 #  error "Both 'TMPL_PPV86' and 'TMPL_PAE16' are defined."
    439 # endif
    440 # ifdef TMPL_PAE32
    441 #  error "Both 'TMPL_PPV86' and 'TMPL_PAE32' are defined."
    442 # endif
    443 # ifdef TMPL_PAEV86
    444 #  error "Both 'TMPL_PPV86' and 'TMPL_PAEV86' are defined."
    445 # endif
    446 # ifdef TMPL_LM16
    447 #  error "Both 'TMPL_PPV86' and 'TMPL_LM16' are defined."
    448 # endif
    449 # ifdef TMPL_LM32
    450 #  error "Both 'TMPL_PPV86' and 'TMPL_LM32' are defined."
    451 # endif
    452 # ifdef TMPL_LM64
    453 #  error "Both 'TMPL_PPV86' and 'TMPL_LM64' are defined."
    454 # endif
    455 # if ARCH_BITS != 16
    456 #  error "TMPL_PPV86 requires ARCH_BITS to be 16."
    457 # endif
    458 # define TMPL_CMN_PP
    459 # define TMPL_CMN_PAGING
    460 # define TMPL_CMN_V86
    461 # define TMPL_CMN_R86
    462 # define TMPL_16BIT
    463 # define TMPL_BITS              16
    464 # define TMPL_NM(Name)          RT_CONCAT(Name,_ppv86)
    465 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
    466 # define TMPL_MODE_STR          "v8086 paged protected mode"
    467 #endif
    468 
    469 #ifdef TMPL_PAE16
    470 # ifdef TMPL_RM
    471 #  error "Both 'TMPL_PAE16' and 'TMPL_RM' are defined."
    472 # endif
    473 # ifdef TMPL_PE16
    474 #  error "Both 'TMPL_PAE16' and 'TMPL_PE16' are defined."
    475 # endif
    476 # ifdef TMPL_PE32
    477 #  error "Both 'TMPL_PAE16' and 'TMPL_PE32' are defined."
    478 # endif
    479 # ifdef TMPL_PEV86
    480 #  error "Both 'TMPL_PAE16' and 'TMPL_PEV86' are defined."
    481 # endif
    482 # ifdef TMPL_PP16
    483 #  error "Both 'TMPL_PAE16' and 'TMPL_PP16' are defined."
    484 # endif
    485 # ifdef TMPL_PP32
    486 #  error "Both 'TMPL_PAE16' and 'TMPL_PP32' are defined."
    487 # endif
    488 # ifdef TMPL_PPV86
    489 #  error "Both 'TMPL_PAE16' and 'TMPL_PPV86' are defined."
    490 # endif
    491 # ifdef TMPL_PAE32
    492 #  error "Both 'TMPL_PAE16' and 'TMPL_PAE32' are defined."
    493 # endif
    494 # ifdef TMPL_LM16
    495 #  error "Both 'TMPL_PAE16' and 'TMPL_LM16' are defined."
    496 # endif
    497 # ifdef TMPL_PAEV86
    498 #  error "Both 'TMPL_PAE16' and 'TMPL_PAEV86' are defined."
    499 # endif
    500 # ifdef TMPL_LM32
    501 #  error "Both 'TMPL_PAE16' and 'TMPL_LM32' are defined."
    502 # endif
    503 # ifdef TMPL_LM64
    504 #  error "Both 'TMPL_PAE16' and 'TMPL_LM64' are defined."
    505 # endif
    506 # if ARCH_BITS != 16
    507 #  error "TMPL_PAE16 requires ARCH_BITS to be 16."
    508 # endif
     267
     268#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16
     269# define TMPL_SYS_PAE16
    509270# define TMPL_CMN_PAE
    510271# define TMPL_CMN_PAGING
    511 # define TMPL_16BIT
    512 # define TMPL_CMN_P16
    513 # define TMPL_BITS              16
    514 # define TMPL_NM(Name)          RT_CONCAT(Name,_pae16)
    515 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    516 # define TMPL_MODE_STR          "16-bit pae protected mode"
    517 #endif
    518 
    519 #ifdef TMPL_PAE32
    520 # ifdef TMPL_RM
    521 #  error "Both 'TMPL_PAE32' and 'TMPL_RM' are defined."
    522 # endif
    523 # ifdef TMPL_PE16
    524 #  error "Both 'TMPL_PAE32' and 'TMPL_PE16' are defined."
    525 # endif
    526 # ifdef TMPL_PE32
    527 #  error "Both 'TMPL_PAE32' and 'TMPL_PE32' are defined."
    528 # endif
    529 # ifdef TMPL_PEV86
    530 #  error "Both 'TMPL_PAE32' and 'TMPL_PEV86' are defined."
    531 # endif
    532 # ifdef TMPL_PP16
    533 #  error "Both 'TMPL_PAE32' and 'TMPL_PP16' are defined."
    534 # endif
    535 # ifdef TMPL_PP32
    536 #  error "Both 'TMPL_PAE32' and 'TMPL_PP32' are defined."
    537 # endif
    538 # ifdef TMPL_PPV86
    539 #  error "Both 'TMPL_PAE32' and 'TMPL_PPV86' are defined."
    540 # endif
    541 # ifdef TMPL_PAE16
    542 #  error "Both 'TMPL_PAE32' and 'TMPL_PAE16' are defined."
    543 # endif
    544 # ifdef TMPL_PAEV86
    545 #  error "Both 'TMPL_PAE32' and 'TMPL_PAEV86' are defined."
    546 # endif
    547 # ifdef TMPL_LM16
    548 #  error "Both 'TMPL_PAE32' and 'TMPL_LM16' are defined."
    549 # endif
    550 # ifdef TMPL_LM32
    551 #  error "Both 'TMPL_PAE32' and 'TMPL_LM32' are defined."
    552 # endif
    553 # ifdef TMPL_LM64
    554 #  error "Both 'TMPL_PAE32' and 'TMPL_LM64' are defined."
    555 # endif
    556 # if ARCH_BITS != 32
    557 #  error "TMPL_PAE32 requires ARCH_BITS to be 32."
    558 # endif
     272
     273#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32
     274# define TMPL_SYS_PAE32
    559275# define TMPL_CMN_PAE
    560276# define TMPL_CMN_PAGING
    561 # define TMPL_CMN_P32
    562 # define TMPL_32BIT
    563 # define TMPL_BITS              32
    564 # define TMPL_NM(Name)          RT_CONCAT(Name,_pae32)
    565 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
    566 # define TMPL_MODE_STR          "32-bit pae protected mode"
    567 #endif
    568 
    569 #ifdef TMPL_PAEV86
    570 # ifdef TMPL_RM
    571 #  error "Both 'TMPL_PAEV86' and 'TMPL_RM' are defined."
    572 # endif
    573 # ifdef TMPL_PE16
    574 #  error "Both 'TMPL_PAEV86' and 'TMPL_PE16' are defined."
    575 # endif
    576 # ifdef TMPL_PE32
    577 #  error "Both 'TMPL_PAEV86' and 'TMPL_PE32' are defined."
    578 # endif
    579 # ifdef TMPL_PEV86
    580 #  error "Both 'TMPL_PAEV86' and 'TMPL_PEV86' are defined."
    581 # endif
    582 # ifdef TMPL_PP16
    583 #  error "Both 'TMPL_PAEV86' and 'TMPL_PP16' are defined."
    584 # endif
    585 # ifdef TMPL_PP32
    586 #  error "Both 'TMPL_PAEV86' and 'TMPL_PP32' are defined."
    587 # endif
    588 # ifdef TMPL_PPV86
    589 #  error "Both 'TMPL_PAEV86' and 'TMPL_PPV86' are defined."
    590 # endif
    591 # ifdef TMPL_PAE16
    592 #  error "Both 'TMPL_PAEV86' and 'TMPL_PAE16' are defined."
    593 # endif
    594 # ifdef TMPL_PAEV86
    595 #  error "Both 'TMPL_PAEV86' and 'TMPL_PAEV86' are defined."
    596 # endif
    597 # ifdef TMPL_LM16
    598 #  error "Both 'TMPL_PAEV86' and 'TMPL_LM16' are defined."
    599 # endif
    600 # ifdef TMPL_LM32
    601 #  error "Both 'TMPL_PAEV86' and 'TMPL_LM32' are defined."
    602 # endif
    603 # ifdef TMPL_LM64
    604 #  error "Both 'TMPL_PAEV86' and 'TMPL_LM64' are defined."
    605 # endif
    606 # if ARCH_BITS != 16
    607 #  error "TMPL_PAEV86 requires ARCH_BITS to be 16."
    608 # endif
    609 # define TMPL_CMN_PAE
    610 # define TMPL_CMN_PAGING
    611 # define TMPL_CMN_V86
    612 # define TMPL_CMN_R86
    613 # define TMPL_16BIT
    614 # define TMPL_BITS              16
    615 # define TMPL_NM(Name)          RT_CONCAT(Name,_paev86)
    616 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
    617 # define TMPL_MODE_STR          "v8086 pae protected mode"
    618 #endif
    619 
    620 #ifdef TMPL_LM16
    621 # ifdef TMPL_RM
    622 #  error "Both 'TMPL_LM16' and 'TMPL_RM' are defined."
    623 # endif
    624 # ifdef TMPL_PE16
    625 #  error "Both 'TMPL_LM16' and 'TMPL_PE16' are defined."
    626 # endif
    627 # ifdef TMPL_PE32
    628 #  error "Both 'TMPL_LM16' and 'TMPL_PE32' are defined."
    629 # endif
    630 # ifdef TMPL_PEV86
    631 #  error "Both 'TMPL_LM16' and 'TMPL_PEV86' are defined."
    632 # endif
    633 # ifdef TMPL_PP16
    634 #  error "Both 'TMPL_LM16' and 'TMPL_PP16' are defined."
    635 # endif
    636 # ifdef TMPL_PP32
    637 #  error "Both 'TMPL_LM16' and 'TMPL_PP32' are defined."
    638 # endif
    639 # ifdef TMPL_PPV86
    640 #  error "Both 'TMPL_LM16' and 'TMPL_PPV86' are defined."
    641 # endif
    642 # ifdef TMPL_PAE16
    643 #  error "Both 'TMPL_LM16' and 'TMPL_PAE16' are defined."
    644 # endif
    645 # ifdef TMPL_PAE32
    646 #  error "Both 'TMPL_LM16' and 'TMPL_PAE32' are defined."
    647 # endif
    648 # ifdef TMPL_PAEV86
    649 #  error "Both 'TMPL_LM16' and 'TMPL_PAEV86' are defined."
    650 # endif
    651 # ifdef TMPL_LM32
    652 #  error "Both 'TMPL_LM16' and 'TMPL_LM32' are defined."
    653 # endif
    654 # ifdef TMPL_LM64
    655 #  error "Both 'TMPL_LM16' and 'TMPL_LM64' are defined."
    656 # endif
    657 # if ARCH_BITS != 16
    658 #  error "TMPL_LM16 requires ARCH_BITS to be 16."
    659 # endif
     277
     278#elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM
     279# define TMPL_SYS_LM
    660280# define TMPL_CMN_LM
    661281# define TMPL_CMN_PAGING
    662 # define TMPL_CMN_P16
    663 # define TMPL_16BIT
    664 # define TMPL_BITS              16
     282
     283#else
     284# error "Invalid TMPL_MODE value!"
     285#endif
     286
     287
     288/*
     289 * Mode specific stuff.
     290 */
     291#if   TMPL_MODE == BS3_MODE_RM
     292# define TMPL_RM                1
     293# define TMPL_MODE_STR          "real mode"
     294# define TMPL_NM(Name)          RT_CONCAT(Name,_rm)
     295# define TMPL_MODE_LNAME        rm
     296# define TMPL_MODE_UNAME        RM
     297
     298
     299#elif TMPL_MODE == BS3_MODE_PE16
     300# define TMPL_PE16              1
     301# define TMPL_MODE_STR          "16-bit prot, 16-bit"
     302# define TMPL_NM(Name)          RT_CONCAT(Name,_pe16)
     303# define TMPL_MODE_LNAME        pe16
     304# define TMPL_MODE_UNAME        PE16
     305
     306#elif TMPL_MODE == BS3_MODE_PE16_32
     307# define TMPL_PE16_32           1
     308# define TMPL_MODE_STR          "16-bit prot, 32-bit"
     309# define TMPL_NM(Name)          RT_CONCAT(Name,_pe16_32)
     310# define TMPL_MODE_LNAME        pe16_32
     311# define TMPL_MODE_UNAME        PE16_32
     312# define TMPL_CMN_WEIRD
     313
     314#elif TMPL_MODE == BS3_MODE_PE16_V86
     315# define TMPL_PE16_V86          1
     316# define TMPL_MODE_STR          "16-bit prot, v8086"
     317# define TMPL_NM(Name)          RT_CONCAT(Name,_pe16_v86)
     318# define TMPL_MODE_LNAME        pe16_v86
     319# define TMPL_MODE_UNAME        PE16_v86
     320# define TMPL_CMN_WEIRD
     321# define TMPL_CMN_WEIRD_V86
     322
     323
     324#elif TMPL_MODE == BS3_MODE_PE32
     325# define TMPL_PE32              1
     326# define TMPL_MODE_STR          "32-bit prot, 32-bit"
     327# define TMPL_NM(Name)          RT_CONCAT(Name,_pe32)
     328# define TMPL_MODE_LNAME        pe32
     329# define TMPL_MODE_UNAME        PE32
     330
     331#elif TMPL_MODE == BS3_MODE_PE32_16
     332# define TMPL_PE32_16           1
     333# define TMPL_MODE_STR          "32-bit prot, 16-bit"
     334# define TMPL_NM(Name)          RT_CONCAT(Name,_pe32_16)
     335# define TMPL_MODE_LNAME        pe32_16
     336# define TMPL_MODE_UNAME        PE32_16
     337# define TMPL_CMN_WEIRD
     338
     339#elif TMPL_MODE == BS3_MODE_PEV86
     340# define TMPL_PEV86             1
     341# define TMPL_MODE_STR          "32-bit prot, v8086"
     342# define TMPL_NM(Name)          RT_CONCAT(Name,_pev86)
     343# define TMPL_MODE_LNAME        pev86
     344# define TMPL_MODE_UNAME        PEV86
     345
     346
     347#elif TMPL_MODE == BS3_MODE_PP16
     348# define TMPL_PP16              1
     349# define TMPL_MODE_STR          "16-bit paged, 16-bit"
     350# define TMPL_NM(Name)          RT_CONCAT(Name,_pp16)
     351# define TMPL_MODE_LNAME        pp16
     352# define TMPL_MODE_UNAME        PP16
     353
     354#elif TMPL_MODE == BS3_MODE_PP16_32
     355# define TMPL_PP16_32           1
     356# define TMPL_MODE_STR          "16-bit paged, 32-bit"
     357# define TMPL_NM(Name)          RT_CONCAT(Name,_pp16_32)
     358# define TMPL_MODE_LNAME        pp16_32
     359# define TMPL_MODE_UNAME        PP16_32
     360# define TMPL_CMN_WEIRD
     361
     362#elif TMPL_MODE == BS3_MODE_PP16_V86
     363# define TMPL_PP16_V86          1
     364# define TMPL_MODE_STR          "16-bit paged, v8086"
     365# define TMPL_NM(Name)          RT_CONCAT(Name,_pp16_v86)
     366# define TMPL_MODE_LNAME        pp16_v86
     367# define TMPL_MODE_UNAME        PP16_v86
     368# define TMPL_CMN_WEIRD
     369# define TMPL_CMN_WEIRD_V86
     370
     371
     372#elif TMPL_MODE == BS3_MODE_PP32
     373# define TMPL_PP32              1
     374# define TMPL_MODE_STR          "32-bit paged, 32-bit"
     375# define TMPL_NM(Name)          RT_CONCAT(Name,_pp32)
     376# define TMPL_MODE_LNAME        pp32
     377# define TMPL_MODE_UNAME        PP32
     378
     379#elif TMPL_MODE == BS3_MODE_PP32_16
     380# define TMPL_PP32_16           1
     381# define TMPL_MODE_STR          "32-bit paged, 16-bit"
     382# define TMPL_NM(Name)          RT_CONCAT(Name,_pp32_16)
     383# define TMPL_MODE_LNAME        pp32_16
     384# define TMPL_MODE_UNAME        PP32_16
     385# define TMPL_CMN_WEIRD
     386
     387#elif TMPL_MODE == BS3_MODE_PPV86
     388# define TMPL_PPV86             1
     389# define TMPL_MODE_STR          "32-bit paged, v8086"
     390# define TMPL_NM(Name)          RT_CONCAT(Name,_ppv86)
     391# define TMPL_MODE_LNAME        ppv86
     392# define TMPL_MODE_UNAME        PPV86
     393
     394
     395#elif TMPL_MODE == BS3_MODE_PAE16
     396# define TMPL_PAE16             1
     397# define TMPL_MODE_STR          "16-bit pae, 16-bit"
     398# define TMPL_NM(Name)          RT_CONCAT(Name,_pae16)
     399# define TMPL_MODE_LNAME        pae16
     400# define TMPL_MODE_UNAME        PAE16
     401
     402#elif TMPL_MODE == BS3_MODE_PAE16_32
     403# define TMPL_PAE16_32          1
     404# define TMPL_MODE_STR          "16-bit pae, 32-bit"
     405# define TMPL_NM(Name)          RT_CONCAT(Name,_pae16_32)
     406# define TMPL_MODE_LNAME        pae16_32
     407# define TMPL_MODE_UNAME        PAE16_32
     408# define TMPL_CMN_WEIRD
     409
     410#elif TMPL_MODE == BS3_MODE_PAE16_V86
     411# define TMPL_PAE16_V86         1
     412# define TMPL_MODE_STR          "16-bit pae, v8086"
     413# define TMPL_NM(Name)          RT_CONCAT(Name,_pae16_v86)
     414# define TMPL_MODE_LNAME        pae16_v86
     415# define TMPL_MODE_UNAME        PAE16_v86
     416# define TMPL_CMN_WEIRD
     417# define TMPL_CMN_WEIRD_V86
     418
     419
     420#elif TMPL_MODE == BS3_MODE_PAE32
     421# define TMPL_PAE32             1
     422# define TMPL_MODE_STR          "32-bit pae, 32-bit"
     423# define TMPL_NM(Name)          RT_CONCAT(Name,_pae32)
     424# define TMPL_MODE_LNAME        pae32
     425# define TMPL_MODE_UNAME        PAE32
     426
     427#elif TMPL_MODE == BS3_MODE_PAE32_16
     428# define TMPL_PAE32_16          1
     429# define TMPL_MODE_STR          "32-bit pae, 32-bit"
     430# define TMPL_NM(Name)          RT_CONCAT(Name,_pae32_16)
     431# define TMPL_MODE_LNAME        pae32_16
     432# define TMPL_MODE_UNAME        PAE32_16
     433# define TMPL_CMN_WEIRD
     434
     435#elif TMPL_MODE == BS3_MODE_PAEV86
     436# define TMPL_PAEV86            1
     437# define TMPL_MODE_STR          "32-bit pae, v8086 pae"
     438# define TMPL_NM(Name)          RT_CONCAT(Name,_paev86)
     439# define TMPL_MODE_LNAME        paev86
     440# define TMPL_MODE_UNAME        PAEV86
     441
     442
     443#elif TMPL_MODE == BS3_MODE_LM16
     444# define TMPL_LM16              1
     445# define TMPL_MODE_STR          "long, 16-bit"
    665446# define TMPL_NM(Name)          RT_CONCAT(Name,_lm16)
    666 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
    667 # define TMPL_MODE_STR          "16-bit long mode"
     447# define TMPL_MODE_LNAME        lm16
     448# define TMPL_MODE_UNAME        LM16
     449
     450#elif TMPL_MODE == BS3_MODE_LM32
     451# define TMPL_LM32              1
     452# define TMPL_MODE_STR          "long, 32-bit"
     453# define TMPL_NM(Name)          RT_CONCAT(Name,_lm32)
     454# define TMPL_MODE_LNAME        lm32
     455# define TMPL_MODE_UNAME        LM32
     456
     457#elif TMPL_MODE == BS3_MODE_LM64
     458# define TMPL_LM64              1
     459# define TMPL_MODE_STR          "long, 64-bit"
     460# define TMPL_NM(Name)          RT_CONCAT(Name,_lm64)
     461# define TMPL_MODE_LNAME        lm64
     462# define TMPL_MODE_UNAME        LM64
     463
     464#else
     465# error "Invalid TMPL_MODE value!!"
    668466#endif
    669467
    670 #ifdef TMPL_LM32
    671 # ifdef TMPL_RM
    672 #  error "Both 'TMPL_LM32' and 'TMPL_RM' are defined."
    673 # endif
    674 # ifdef TMPL_PE16
    675 #  error "Both 'TMPL_LM32' and 'TMPL_PE16' are defined."
    676 # endif
    677 # ifdef TMPL_PE32
    678 #  error "Both 'TMPL_LM32' and 'TMPL_PE32' are defined."
    679 # endif
    680 # ifdef TMPL_PEV86
    681 #  error "Both 'TMPL_LM32' and 'TMPL_PEV86' are defined."
    682 # endif
    683 # ifdef TMPL_PP16
    684 #  error "Both 'TMPL_LM32' and 'TMPL_PP16' are defined."
    685 # endif
    686 # ifdef TMPL_PP32
    687 #  error "Both 'TMPL_LM32' and 'TMPL_PP32' are defined."
    688 # endif
    689 # ifdef TMPL_PPV86
    690 #  error "Both 'TMPL_LM32' and 'TMPL_PPV86' are defined."
    691 # endif
    692 # ifdef TMPL_PAE16
    693 #  error "Both 'TMPL_LM32' and 'TMPL_PAE16' are defined."
    694 # endif
    695 # ifdef TMPL_PAE32
    696 #  error "Both 'TMPL_LM32' and 'TMPL_PAE32' are defined."
    697 # endif
    698 # ifdef TMPL_PAEV86
    699 #  error "Both 'TMPL_LM32' and 'TMPL_PAEV86' are defined."
    700 # endif
    701 # ifdef TMPL_LM16
    702 #  error "Both 'TMPL_LM32' and 'TMPL_LM16' are defined."
    703 # endif
    704 # ifdef TMPL_LM64
    705 #  error "Both 'TMPL_LM32' and 'TMPL_LM64' are defined."
    706 # endif
    707 # if ARCH_BITS != 32
    708 #  error "TMPL_LM32 requires ARCH_BITS to be 32."
    709 # endif
    710 # define TMPL_CMN_LM
    711 # define TMPL_CMN_PAGING
    712 # define TMPL_CMN_P32
    713 # define TMPL_32BIT
    714 # define TMPL_BITS              32
    715 # define TMPL_NM(Name)          RT_CONCAT(Name,_lm32)
    716 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
    717 # define TMPL_MODE_STR          "32-bit long mode"
    718 #endif
    719 
    720 #ifdef TMPL_LM64
    721 # ifdef TMPL_RM
    722 #  error ""Both 'TMPL_LM64' and 'TMPL_RM' are defined.""
    723 # endif
    724 # ifdef TMPL_PE16
    725 #  error "Both 'TMPL_LM64' and 'TMPL_PE16' are defined."
    726 # endif
    727 # ifdef TMPL_PE32
    728 #  error "Both 'TMPL_LM64' and 'TMPL_PE32' are defined."
    729 # endif
    730 # ifdef TMPL_PEV86
    731 #  error "Both 'TMPL_LM64' and 'TMPL_PEV86' are defined."
    732 # endif
    733 # ifdef TMPL_PP16
    734 #  error "Both 'TMPL_LM64' and 'TMPL_PP16' are defined."
    735 # endif
    736 # ifdef TMPL_PP32
    737 #  error "Both 'TMPL_LM64' and 'TMPL_PP32' are defined."
    738 # endif
    739 # ifdef TMPL_PPV86
    740 #  error "Both 'TMPL_LM64' and 'TMPL_PPV86' are defined."
    741 # endif
    742 # ifdef TMPL_PAE16
    743 #  error "Both 'TMPL_LM64' and 'TMPL_PAE16' are defined."
    744 # endif
    745 # ifdef TMPL_PAE32
    746 #  error "Both 'TMPL_LM64' and 'TMPL_PAE32' are defined."
    747 # endif
    748 # ifdef TMPL_PAEV86
    749 #  error "Both 'TMPL_LM64' and 'TMPL_PAEV86' are defined."
    750 # endif
    751 # ifdef TMPL_LM16
    752 #  error "Both 'TMPL_LM64' and 'TMPL_LM16' are defined."
    753 # endif
    754 # ifdef TMPL_LM32
    755 #  error "Both 'TMPL_LM64' and 'TMPL_LM32' are defined."
    756 # endif
    757 # if ARCH_BITS != 64
    758 #  error "TMPL_LM64 requires ARCH_BITS to be 64."
    759 # endif
    760 # define TMPL_CMN_LM
    761 # define TMPL_CMN_PAGING
    762 # define TMPL_CMN_P64
    763 # define TMPL_64BIT
    764 # define TMPL_BITS              64
    765 # define TMPL_NM(Name)          RT_CONCAT(Name,_lm64)
    766 # define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
    767 # define TMPL_MODE_STR          "64-bit long mode"
    768 #endif
    769468
    770469#ifndef TMPL_MODE_STR
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac

    r59311 r59863  
    5353;       - TMPL_CMN_PAGING = TMPL_CMN_PP | TMPL_CMN_PAE | TMPL_CMN_LM
    5454;
    55 %ifdef TMPL_RM
    56  %ifdef TMPL_PE16
    57   %error "Both 'TMPL_RM' and 'TMPL_PE16' are defined."
     55
     56
     57;
     58; Convert TMPL_XXX to TMPL_MODE.
     59;
     60%ifndef TMPL_MODE
     61 %ifdef TMPL_RM
     62  %define TMPL_MODE         BS3_MODE_RM
     63 %elifdef TMPL_PE16
     64  %define TMPL_MODE         BS3_MODE_PE16
     65 %elifdef TMPL_PE16_32
     66  %define TMPL_MODE         BS3_MODE_PE16_32
     67 %elifdef TMPL_PE16_V86
     68  %define TMPL_MODE         BS3_MODE_PE16_V86
     69 %elifdef TMPL_PE32
     70  %define TMPL_MODE         BS3_MODE_PE32
     71 %elifdef TMPL_PE32_16
     72  %define TMPL_MODE         BS3_MODE_PE32_16
     73 %elifdef TMPL_PEV86
     74  %define TMPL_MODE         BS3_MODE_PEV86
     75 %elifdef TMPL_PP16
     76  %define TMPL_MODE         BS3_MODE_PP16
     77 %elifdef TMPL_PP16_32
     78  %define TMPL_MODE         BS3_MODE_PP16_32
     79 %elifdef TMPL_PP16_V86
     80  %define TMPL_MODE         BS3_MODE_PP16_V86
     81 %elifdef TMPL_PP32
     82  %define TMPL_MODE         BS3_MODE_PP32
     83 %elifdef TMPL_PP32_16
     84  %define TMPL_MODE         BS3_MODE_PP32_16
     85 %elifdef TMPL_PPV86
     86  %define TMPL_MODE         BS3_MODE_PPV86
     87 %elifdef TMPL_PAE16
     88  %define TMPL_MODE         BS3_MODE_PAE16
     89 %elifdef TMPL_PAE16_32
     90  %define TMPL_MODE         BS3_MODE_PAE16_32
     91 %elifdef TMPL_PAE16_V86
     92  %define TMPL_MODE         BS3_MODE_PAE16_V86
     93 %elifdef TMPL_PAE32
     94  %define TMPL_MODE         BS3_MODE_PAE32
     95 %elifdef TMPL_PAE32_16
     96  %define TMPL_MODE         BS3_MODE_PAE32_16
     97 %elifdef TMPL_PAEV86
     98  %define TMPL_MODE         BS3_MODE_PAEV86
     99 %elifdef TMPL_LM16
     100  %define TMPL_MODE         BS3_MODE_LM16
     101 %elifdef TMPL_LM32
     102  %define TMPL_MODE         BS3_MODE_LM32
     103 %elifdef TMPL_LM64
     104  %define TMPL_MODE         BS3_MODE_LM64
     105 %else
     106  %error "Unable to to figure out the template mode."
    58107 %endif
    59  %ifdef TMPL_PE32
    60   %error "Both 'TMPL_RM' and 'TMPL_PE32' are defined."
    61  %endif
    62  %ifdef TMPL_PEV86
    63   %error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    64  %endif
    65  %ifdef TMPL_PP16
    66   %error "Both 'TMPL_RM' and 'TMPL_PP16' are defined."
    67  %endif
    68  %ifdef TMPL_PP32
    69   %error "Both 'TMPL_RM' and 'TMPL_PP32' are defined."
    70  %endif
    71  %ifdef TMPL_PPV86
    72   %error "Both 'TMPL_RM' and 'TMPL_PPV86' are defined."
    73  %endif
    74  %ifdef TMPL_PAE16
    75   %error "Both 'TMPL_RM' and 'TMPL_PAE16' are defined."
    76  %endif
    77  %ifdef TMPL_PAE32
    78   %error "Both 'TMPL_RM' and 'TMPL_PAE32' are defined."
    79  %endif
    80  %ifdef TMPL_PAEV86
    81   %error "Both 'TMPL_RM' and 'TMPL_PAEV86' are defined."
    82  %endif
    83  %ifdef TMPL_LM16
    84   %error "Both 'TMPL_RM' and 'TMPL_LM16' are defined."
    85  %endif
    86  %ifdef TMPL_LM32
    87   %error "Both 'TMPL_RM' and 'TMPL_LM32' are defined."
    88  %endif
    89  %ifdef TMPL_LM64
    90   %error "Both 'TMPL_RM' and 'TMPL_LM64' are defined."
    91  %endif
     108%endif
     109
     110;
     111; Check the code bitness and set TMPL_XXBITS, TMPL_BITS, BS3_CMN_NM
     112;
     113%if (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16
    92114 %define TMPL_16BIT
    93115 %define TMPL_BITS              16
    94116 %define TMPL_PTR_DEF           dw
    95  %define TMPL_NM(Name)          _ %+ Name %+ _rm
     117 %define TMPL_UNDERSCORE        _
    96118 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    97  %define TMPL_UNDERSCORE        _
    98  %define TMPL_MODE_LNAME        rm
    99  %define TMPL_MODE_UNAME        RM
    100  %define TMPL_MODE_STR          'real mode'
    101  %define TMPL_HAVE_BIOS
    102  %define TMPL_CMN_R86
    103 %endif
    104 
    105 %ifdef TMPL_PE16
    106  %ifdef TMPL_RM
    107   %error "Both 'TMPL_PE16' and 'TMPL_RM' are defined."
    108  %endif
    109  %ifdef TMPL_PE32
    110   %error "Both 'TMPL_PE16' and 'TMPL_PE32' are defined."
    111  %endif
    112  %ifdef TMPL_PEV86
    113   %error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
    114  %endif
    115  %ifdef TMPL_PP16
    116   %error "Both 'TMPL_PE16' and 'TMPL_PP16' are defined."
    117  %endif
    118  %ifdef TMPL_PP32
    119   %error "Both 'TMPL_PE16' and 'TMPL_PP32' are defined."
    120  %endif
    121  %ifdef TMPL_PPV86
    122   %error "Both 'TMPL_PE16' and 'TMPL_PPV86' are defined."
    123  %endif
    124  %ifdef TMPL_PAE16
    125   %error "Both 'TMPL_PE16' and 'TMPL_PAE16' are defined."
    126  %endif
    127  %ifdef TMPL_PAE32
    128   %error "Both 'TMPL_PE16' and 'TMPL_PAE32' are defined."
    129  %endif
    130  %ifdef TMPL_PAEV86
    131   %error "Both 'TMPL_PE32' and 'TMPL_PAEV86' are defined."
    132  %endif
    133  %ifdef TMPL_LM16
    134   %error "Both 'TMPL_PE16' and 'TMPL_LM16' are defined."
    135  %endif
    136  %ifdef TMPL_LM32
    137   %error "Both 'TMPL_PE16' and 'TMPL_LM32' are defined."
    138  %endif
    139  %ifdef TMPL_LM64
    140   %error "Both 'TMPL_PE16' and 'TMPL_LM64' are defined."
    141  %endif
    142  %define TMPL_CMN_PE
    143  %define TMPL_CMN_P16
    144  %define TMPL_16BIT
    145  %define TMPL_BITS              16
    146  %define TMPL_PTR_DEF           dw
    147  %define TMPL_NM(Name)          _ %+ Name %+ _pe16
    148  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    149  %define TMPL_UNDERSCORE        _
    150  %define TMPL_MODE_LNAME        pe16
    151  %define TMPL_MODE_UNAME        PE16
    152  %define TMPL_MODE_STR          '16-bit unpaged protected mode'
    153 %endif
    154 
    155 %ifdef TMPL_PE32
    156  %ifdef TMPL_RM
    157   %error "Both 'TMPL_PE32' and 'TMPL_RM' are defined."
    158  %endif
    159  %ifdef TMPL_PE16
    160   %error "Both 'TMPL_PE32' and 'TMPL_PE16' are defined."
    161  %endif
    162  %ifdef TMPL_PEV86
    163   %error "Both 'TMPL_PE32' and 'TMPL_PEV86' are defined."
    164  %endif
    165  %ifdef TMPL_PP16
    166   %error "Both 'TMPL_PE32' and 'TMPL_PP16' are defined."
    167  %endif
    168  %ifdef TMPL_PP32
    169   %error "Both 'TMPL_PE32' and 'TMPL_PP32' are defined."
    170  %endif
    171  %ifdef TMPL_PPV86
    172   %error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    173  %endif
    174  %ifdef TMPL_PAE16
    175   %error "Both 'TMPL_PE32' and 'TMPL_PAE16' are defined."
    176  %endif
    177  %ifdef TMPL_PAE32
    178   %error "Both 'TMPL_PE32' and 'TMPL_PAE32' are defined."
    179  %endif
    180  %ifdef TMPL_PAE86
    181   %error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
    182  %endif
    183  %ifdef TMPL_LM16
    184   %error "Both 'TMPL_PE32' and 'TMPL_LM16' are defined."
    185  %endif
    186  %ifdef TMPL_LM32
    187   %error "Both 'TMPL_PE32' and 'TMPL_LM32' are defined."
    188  %endif
    189  %ifdef TMPL_LM64
    190   %error "Both 'TMPL_PE32' and 'TMPL_LM64' are defined."
    191  %endif
    192  %define TMPL_CMN_PE
    193  %define TMPL_CMN_P32
     119
     120%elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32
    194121 %define TMPL_32BIT
    195122 %define TMPL_BITS              32
    196123 %define TMPL_PTR_DEF           dd
    197  %define TMPL_NM(Name)          _ %+ Name %+ _pe32
     124 %define TMPL_UNDERSCORE        _
    198125 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    199  %define TMPL_UNDERSCORE        _
    200  %define TMPL_MODE_LNAME        pe32
    201  %define TMPL_MODE_UNAME        PE32
    202  %define TMPL_MODE_STR          '32-bit unpaged protected mode'
    203 %endif
    204 
    205 %ifdef TMPL_PEV86
    206  %ifdef TMPL_RM
    207   %error "Both 'TMPL_PEV86' and 'TMPL_RM' are defined."
    208  %endif
    209  %ifdef TMPL_PE16
    210   %error "Both 'TMPL_PEV86' and 'TMPL_PE16' are defined."
    211  %endif
    212  %ifdef TMPL_PP32
    213   %error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    214  %endif
    215  %ifdef TMPL_PP16
    216   %error "Both 'TMPL_PEV86' and 'TMPL_PP16' are defined."
    217  %endif
    218  %ifdef TMPL_PP32
    219   %error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
    220  %endif
    221  %ifdef TMPL_PPV86
    222   %error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    223  %endif
    224  %ifdef TMPL_PAE16
    225   %error "Both 'TMPL_PEV86' and 'TMPL_PAE16' are defined."
    226  %endif
    227  %ifdef TMPL_PAE32
    228   %error "Both 'TMPL_PEV86' and 'TMPL_PAE32' are defined."
    229  %endif
    230  %ifdef TMPL_PAE86
    231   %error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
    232  %endif
    233  %ifdef TMPL_LM16
    234   %error "Both 'TMPL_PEV86' and 'TMPL_LM16' are defined."
    235  %endif
    236  %ifdef TMPL_LM32
    237   %error "Both 'TMPL_PEV86' and 'TMPL_LM32' are defined."
    238  %endif
    239  %ifdef TMPL_LM64
    240   %error "Both 'TMPL_PEV86' and 'TMPL_LM64' are defined."
    241  %endif
    242  %define TMPL_CMN_PE
    243  %define TMPL_CMN_V86
    244  %define TMPL_CMN_R86
     126
     127%elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86
    245128 %define TMPL_16BIT
    246129 %define TMPL_BITS              16
    247  %define TMPL_PTR_DEF           dw
    248  %define TMPL_NM(Name)          _ %+ Name %+ _pev86
     130 %define TMPL_UNDERSCORE        _
    249131 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    250  %define TMPL_UNDERSCORE        _
    251  %define TMPL_MODE_LNAME        pev86
    252  %define TMPL_MODE_UNAME        PEV86
    253  %define TMPL_MODE_STR          'v8086 unpaged protected mode'
    254 %endif
    255 
    256 %ifdef TMPL_PP16
    257  %ifdef TMPL_RM
    258   %error "Both 'TMPL_PP16' and 'TMPL_RM' are defined."
    259  %endif
    260  %ifdef TMPL_PE16
    261   %error "Both 'TMPL_PP16' and 'TMPL_PE16' are defined."
    262  %endif
    263  %ifdef TMPL_PE32
    264   %error "Both 'TMPL_PP16' and 'TMPL_PE32' are defined."
    265  %endif
    266  %ifdef TMPL_PEV86
    267   %error "Both 'TMPL_PP16' and 'TMPL_PEV86' are defined."
    268  %endif
    269  %ifdef TMPL_PP32
    270   %error "Both 'TMPL_PP16' and 'TMPL_PP32' are defined."
    271  %endif
    272  %ifdef TMPL_PPV86
    273   %error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    274  %endif
    275  %ifdef TMPL_PAE16
    276   %error "Both 'TMPL_PP16' and 'TMPL_PAE16' are defined."
    277  %endif
    278  %ifdef TMPL_PAE32
    279   %error "Both 'TMPL_PP16' and 'TMPL_PAE32' are defined."
    280  %endif
    281  %ifdef TMPL_PAEV86
    282   %error "Both 'TMPL_PP16' and 'TMPL_PAEV86' are defined."
    283  %endif
    284  %ifdef TMPL_LM16
    285   %error "Both 'TMPL_PP16' and 'TMPL_LM16' are defined."
    286  %endif
    287  %ifdef TMPL_LM32
    288   %error "Both 'TMPL_PP16' and 'TMPL_LM32' are defined."
    289  %endif
    290  %ifdef TMPL_LM64
    291   %error "Both 'TMPL_PP16' and 'TMPL_LM64' are defined."
    292  %endif
    293  %define TMPL_CMN_PP
    294  %define TMPL_CMN_PAGING
    295  %define TMPL_CMN_P16
    296  %define TMPL_16BIT
    297  %define TMPL_BITS              16
    298  %define TMPL_PTR_DEF           dw
    299  %define TMPL_NM(Name)          _ %+ Name %+ _pp16
    300  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    301  %define TMPL_UNDERSCORE        _
    302  %define TMPL_MODE_LNAME        pp16
    303  %define TMPL_MODE_UNAME        PP16
    304  %define TMPL_MODE_STR          '16-bit paged protected mode'
    305 %endif
    306 
    307 %ifdef TMPL_PP32
    308  %ifdef TMPL_RM
    309   %error "Both 'TMPL_PP32' and 'TMPL_RM' are defined."
    310  %endif
    311  %ifdef TMPL_PE16
    312   %error "Both 'TMPL_PP32' and 'TMPL_PE16' are defined."
    313  %endif
    314  %ifdef TMPL_PE32
    315   %error "Both 'TMPL_PP32' and 'TMPL_PE32' are defined."
    316  %endif
    317  %ifdef TMPL_PEV86
    318   %error "Both 'TMPL_PP32' and 'TMPL_PEV86' are defined."
    319  %endif
    320  %ifdef TMPL_PP16
    321   %error "Both 'TMPL_PP32' and 'TMPL_PP16' are defined."
    322  %endif
    323  %ifdef TMPL_PPV86
    324   %error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
    325  %endif
    326  %ifdef TMPL_PAE16
    327   %error "Both 'TMPL_PP32' and 'TMPL_PAE16' are defined."
    328  %endif
    329  %ifdef TMPL_PAE32
    330   %error "Both 'TMPL_PP32' and 'TMPL_PAE32' are defined."
    331  %endif
    332  %ifdef TMPL_PAEV86
    333   %error "Both 'TMPL_PP32' and 'TMPL_PAEV86' are defined."
    334  %endif
    335  %ifdef TMPL_LM16
    336   %error "Both 'TMPL_PP32' and 'TMPL_LM16' are defined."
    337  %endif
    338  %ifdef TMPL_LM32
    339   %error "Both 'TMPL_PP32' and 'TMPL_LM32' are defined."
    340  %endif
    341  %ifdef TMPL_LM64
    342   %error "Both 'TMPL_PP32' and 'TMPL_LM64' are defined."
    343  %endif
    344  %define TMPL_CMN_PP
    345  %define TMPL_CMN_PAGING
    346  %define TMPL_CMN_P32
    347  %define TMPL_32BIT
    348  %define TMPL_BITS              32
    349  %define TMPL_PTR_DEF           dd
    350  %define TMPL_NM(Name)          _ %+ Name %+ _pp32
    351  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    352  %define TMPL_UNDERSCORE        _
    353  %define TMPL_MODE_LNAME        pp32
    354  %define TMPL_MODE_UNAME        PP32
    355  %define TMPL_MODE_STR          '32-bit paged protected mode'
    356 %endif
    357 
    358 %ifdef TMPL_PPV86
    359  %ifdef TMPL_RM
    360   %error "Both 'TMPL_PPV86' and 'TMPL_RM' are defined."
    361  %endif
    362  %ifdef TMPL_PE16
    363   %error "Both 'TMPL_PPV86' and 'TMPL_PE16' are defined."
    364  %endif
    365  %ifdef TMPL_PE32
    366   %error "Both 'TMPL_PPV86' and 'TMPL_PE32' are defined."
    367  %endif
    368  %ifdef TMPL_PEV86
    369   %error "Both 'TMPL_PPV86' and 'TMPL_PEV86' are defined."
    370  %endif
    371  %ifdef TMPL_PP16
    372   %error "Both 'TMPL_PPV86' and 'TMPL_PP16' are defined."
    373  %endif
    374  %ifdef TMPL_PP32
    375   %error "Both 'TMPL_PPV86' and 'TMPL_PP32' are defined."
    376  %endif
    377  %ifdef TMPL_PAE16
    378   %error "Both 'TMPL_PPV86' and 'TMPL_PAE16' are defined."
    379  %endif
    380  %ifdef TMPL_PAE32
    381   %error "Both 'TMPL_PPV86' and 'TMPL_PAE32' are defined."
    382  %endif
    383  %ifdef TMPL_PAEV86
    384   %error "Both 'TMPL_PPV86' and 'TMPL_PAEV86' are defined."
    385  %endif
    386  %ifdef TMPL_LM16
    387   %error "Both 'TMPL_PPV86' and 'TMPL_LM16' are defined."
    388  %endif
    389  %ifdef TMPL_LM32
    390   %error "Both 'TMPL_PPV86' and 'TMPL_LM32' are defined."
    391  %endif
    392  %ifdef TMPL_LM64
    393   %error "Both 'TMPL_PPV86' and 'TMPL_LM64' are defined."
    394  %endif
    395  %define TMPL_CMN_PP
    396  %define TMPL_CMN_PAGING
     132 %define TMPL_CMN_R86
    397133 %define TMPL_CMN_V86
    398  %define TMPL_CMN_R86
    399  %define TMPL_16BIT
    400  %define TMPL_BITS              16
    401  %define TMPL_PTR_DEF           dw
    402  %define TMPL_NM(Name)          _ %+ Name %+ _ppv86
    403  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
    404  %define TMPL_UNDERSCORE        _
    405  %define TMPL_MODE_LNAME        ppv86
    406  %define TMPL_MODE_UNAME        PPV86
    407  %define TMPL_MODE_STR          'v8086 paged protected mode'
    408 %endif
    409 
    410 %ifdef TMPL_PAE16
    411  %ifdef TMPL_RM
    412   %error "Both 'TMPL_PAE16' and 'TMPL_RM' are defined."
    413  %endif
    414  %ifdef TMPL_PE16
    415   %error "Both 'TMPL_PAE16' and 'TMPL_PE16' are defined."
    416  %endif
    417  %ifdef TMPL_PE32
    418   %error "Both 'TMPL_PAE16' and 'TMPL_PE32' are defined."
    419  %endif
    420  %ifdef TMPL_PEV86
    421   %error "Both 'TMPL_PAE16' and 'TMPL_PEV86' are defined."
    422  %endif
    423  %ifdef TMPL_PP16
    424   %error "Both 'TMPL_PAE16' and 'TMPL_PP16' are defined."
    425  %endif
    426  %ifdef TMPL_PP32
    427   %error "Both 'TMPL_PAE16' and 'TMPL_PP32' are defined."
    428  %endif
    429  %ifdef TMPL_PPV86
    430   %error "Both 'TMPL_PAE16' and 'TMPL_PPV86' are defined."
    431  %endif
    432  %ifdef TMPL_PAE32
    433   %error "Both 'TMPL_PAE16' and 'TMPL_PAE32' are defined."
    434  %endif
    435  %ifdef TMPL_LM16
    436   %error "Both 'TMPL_PAE16' and 'TMPL_LM16' are defined."
    437  %endif
    438  %ifdef TMPL_PAEV86
    439   %error "Both 'TMPL_PAE16' and 'TMPL_PAEV86' are defined."
    440  %endif
    441  %ifdef TMPL_LM32
    442   %error "Both 'TMPL_PAE16' and 'TMPL_LM32' are defined."
    443  %endif
    444  %ifdef TMPL_LM64
    445   %error "Both 'TMPL_PAE16' and 'TMPL_LM64' are defined."
    446  %endif
    447  %define TMPL_CMN_PAE
    448  %define TMPL_CMN_PAGING
    449  %define TMPL_16BIT
    450  %define TMPL_CMN_P16
    451  %define TMPL_BITS              16
    452  %define TMPL_PTR_DEF           dw
    453  %define TMPL_NM(Name)          _ %+ Name %+ _pae16
    454  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    455  %define TMPL_UNDERSCORE        _
    456  %define TMPL_MODE_LNAME        pae16
    457  %define TMPL_MODE_UNAME        PAE16
    458  %define TMPL_MODE_STR          '16-bit pae protected mode'
    459 %endif
    460 
    461 %ifdef TMPL_PAE32
    462  %ifdef TMPL_RM
    463   %error "Both 'TMPL_PAE32' and 'TMPL_RM' are defined."
    464  %endif
    465  %ifdef TMPL_PE16
    466   %error "Both 'TMPL_PAE32' and 'TMPL_PE16' are defined."
    467  %endif
    468  %ifdef TMPL_PE32
    469   %error "Both 'TMPL_PAE32' and 'TMPL_PE32' are defined."
    470  %endif
    471  %ifdef TMPL_PEV86
    472   %error "Both 'TMPL_PAE32' and 'TMPL_PEV86' are defined."
    473  %endif
    474  %ifdef TMPL_PP16
    475   %error "Both 'TMPL_PAE32' and 'TMPL_PP16' are defined."
    476  %endif
    477  %ifdef TMPL_PP32
    478   %error "Both 'TMPL_PAE32' and 'TMPL_PP32' are defined."
    479  %endif
    480  %ifdef TMPL_PPV86
    481   %error "Both 'TMPL_PAE32' and 'TMPL_PPV86' are defined."
    482  %endif
    483  %ifdef TMPL_PAE16
    484   %error "Both 'TMPL_PAE32' and 'TMPL_PAE16' are defined."
    485  %endif
    486  %ifdef TMPL_PAEV86
    487   %error "Both 'TMPL_PAE32' and 'TMPL_PAEV86' are defined."
    488  %endif
    489  %ifdef TMPL_LM16
    490   %error "Both 'TMPL_PAE32' and 'TMPL_LM16' are defined."
    491  %endif
    492  %ifdef TMPL_LM32
    493   %error "Both 'TMPL_PAE32' and 'TMPL_LM32' are defined."
    494  %endif
    495  %ifdef TMPL_LM64
    496   %error "Both 'TMPL_PAE32' and 'TMPL_LM64' are defined."
    497  %endif
    498  %define TMPL_CMN_PAE
    499  %define TMPL_CMN_PAGING
    500  %define TMPL_CMN_P32
    501  %define TMPL_32BIT
    502  %define TMPL_BITS              32
    503  %define TMPL_PTR_DEF           dd
    504  %define TMPL_NM(Name)          _ %+ Name %+ _pae32
    505  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    506  %define TMPL_UNDERSCORE        _
    507  %define TMPL_MODE_LNAME        pae32
    508  %define TMPL_MODE_UNAME        PAE32
    509  %define TMPL_MODE_STR          '32-bit pae protected mode'
    510 %endif
    511 
    512 %ifdef TMPL_PAEV86
    513  %ifdef TMPL_RM
    514   %error "Both 'TMPL_PAEV86' and 'TMPL_RM' are defined."
    515  %endif
    516  %ifdef TMPL_PE16
    517   %error "Both 'TMPL_PAEV86' and 'TMPL_PE16' are defined."
    518  %endif
    519  %ifdef TMPL_PE32
    520   %error "Both 'TMPL_PAEV86' and 'TMPL_PE32' are defined."
    521  %endif
    522  %ifdef TMPL_PEV86
    523   %error "Both 'TMPL_PAEV86' and 'TMPL_PEV86' are defined."
    524  %endif
    525  %ifdef TMPL_PP16
    526   %error "Both 'TMPL_PAEV86' and 'TMPL_PP16' are defined."
    527  %endif
    528  %ifdef TMPL_PP32
    529   %error "Both 'TMPL_PAEV86' and 'TMPL_PP32' are defined."
    530  %endif
    531  %ifdef TMPL_PPV86
    532   %error "Both 'TMPL_PAEV86' and 'TMPL_PPV86' are defined."
    533  %endif
    534  %ifdef TMPL_PAE16
    535   %error "Both 'TMPL_PAEV86' and 'TMPL_PAE16' are defined."
    536  %endif
    537  %ifdef TMPL_PAE32
    538   %error "Both 'TMPL_PAEV86' and 'TMPL_PAE32' are defined."
    539  %endif
    540  %ifdef TMPL_LM16
    541   %error "Both 'TMPL_PAEV86' and 'TMPL_LM16' are defined."
    542  %endif
    543  %ifdef TMPL_LM32
    544   %error "Both 'TMPL_PAEV86' and 'TMPL_LM32' are defined."
    545  %endif
    546  %ifdef TMPL_LM64
    547   %error "Both 'TMPL_PAEV86' and 'TMPL_LM64' are defined."
    548  %endif
    549  %define TMPL_CMN_PAE
    550  %define TMPL_CMN_PAGING
    551  %define TMPL_CMN_V86
    552  %define TMPL_CMN_R86
    553  %define TMPL_16BIT
    554  %define TMPL_BITS              16
    555  %define TMPL_PTR_DEF           dw
    556  %define TMPL_NM(Name)          _ %+ Name %+ _paev86
    557  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
    558  %define TMPL_UNDERSCORE        _
    559  %define TMPL_MODE_LNAME        paev86
    560  %define TMPL_MODE_UNAME        PAEV86
    561  %define TMPL_MODE_STR          'v8086 pae protected mode'
    562 %endif
    563 
    564 %ifdef TMPL_LM16
    565  %ifdef TMPL_RM
    566   %error "Both 'TMPL_LM16' and 'TMPL_RM' are defined."
    567  %endif
    568  %ifdef TMPL_PE16
    569   %error "Both 'TMPL_LM16' and 'TMPL_PE16' are defined."
    570  %endif
    571  %ifdef TMPL_PE32
    572   %error "Both 'TMPL_LM16' and 'TMPL_PE32' are defined."
    573  %endif
    574  %ifdef TMPL_PEV86
    575   %error "Both 'TMPL_LM16' and 'TMPL_PEV86' are defined."
    576  %endif
    577  %ifdef TMPL_PP16
    578   %error "Both 'TMPL_LM16' and 'TMPL_PP16' are defined."
    579  %endif
    580  %ifdef TMPL_PP32
    581   %error "Both 'TMPL_LM16' and 'TMPL_PP32' are defined."
    582  %endif
    583  %ifdef TMPL_PPV86
    584   %error "Both 'TMPL_LM16' and 'TMPL_PPV86' are defined."
    585  %endif
    586  %ifdef TMPL_PAE16
    587   %error "Both 'TMPL_LM16' and 'TMPL_PAE16' are defined."
    588  %endif
    589  %ifdef TMPL_PAE32
    590   %error "Both 'TMPL_LM16' and 'TMPL_PAE32' are defined."
    591  %endif
    592  %ifdef TMPL_PAEV86
    593   %error "Both 'TMPL_LM16' and 'TMPL_PAEV86' are defined."
    594  %endif
    595  %ifdef TMPL_LM32
    596   %error "Both 'TMPL_LM16' and 'TMPL_LM32' are defined."
    597  %endif
    598  %ifdef TMPL_LM64
    599   %error "Both 'TMPL_LM16' and 'TMPL_LM64' are defined."
    600  %endif
    601  %define TMPL_CMN_LM
    602  %define TMPL_CMN_PAGING
    603  %define TMPL_CMN_P16
    604  %define TMPL_16BIT
    605  %define TMPL_BITS              16
    606  %define TMPL_PTR_DEF           dw
    607  %define TMPL_NM(Name)          _ %+ Name %+ _lm16
    608  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
    609  %define TMPL_UNDERSCORE        _
    610  %define TMPL_MODE_LNAME        lm16
    611  %define TMPL_MODE_UNAME        LM16
    612  %define TMPL_MODE_STR          '16-bit long mode'
    613 %endif
    614 
    615 %ifdef TMPL_LM32
    616  %ifdef TMPL_RM
    617   %error "Both 'TMPL_LM32' and 'TMPL_RM' are defined."
    618  %endif
    619  %ifdef TMPL_PE16
    620   %error "Both 'TMPL_LM32' and 'TMPL_PE16' are defined."
    621  %endif
    622  %ifdef TMPL_PE32
    623   %error "Both 'TMPL_LM32' and 'TMPL_PE32' are defined."
    624  %endif
    625  %ifdef TMPL_PEV86
    626   %error "Both 'TMPL_LM32' and 'TMPL_PEV86' are defined."
    627  %endif
    628  %ifdef TMPL_PP16
    629   %error "Both 'TMPL_LM32' and 'TMPL_PP16' are defined."
    630  %endif
    631  %ifdef TMPL_PP32
    632   %error "Both 'TMPL_LM32' and 'TMPL_PP32' are defined."
    633  %endif
    634  %ifdef TMPL_PPV86
    635   %error "Both 'TMPL_LM32' and 'TMPL_PPV86' are defined."
    636  %endif
    637  %ifdef TMPL_PAE16
    638   %error "Both 'TMPL_LM32' and 'TMPL_PAE16' are defined."
    639  %endif
    640  %ifdef TMPL_PAE32
    641   %error "Both 'TMPL_LM32' and 'TMPL_PAE32' are defined."
    642  %endif
    643  %ifdef TMPL_PAEV86
    644   %error "Both 'TMPL_LM32' and 'TMPL_PAEV86' are defined."
    645  %endif
    646  %ifdef TMPL_LM16
    647   %error "Both 'TMPL_LM32' and 'TMPL_LM16' are defined."
    648  %endif
    649  %ifdef TMPL_LM64
    650   %error "Both 'TMPL_LM32' and 'TMPL_LM64' are defined."
    651  %endif
    652  %define TMPL_CMN_LM
    653  %define TMPL_CMN_PAGING
    654  %define TMPL_CMN_P32
    655  %define TMPL_32BIT
    656  %define TMPL_BITS              32
    657  %define TMPL_PTR_DEF           dd
    658  %define TMPL_NM(Name)          _ %+ Name %+ _lm32
    659  %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
    660  %define TMPL_UNDERSCORE        _
    661  %define TMPL_MODE_LNAME        lm32
    662  %define TMPL_MODE_UNAME        LM32
    663  %define TMPL_MODE_STR          '32-bit long mode'
    664 %endif
    665 
    666 %ifdef TMPL_LM64
    667  %ifdef TMPL_RM
    668   %error ""Both 'TMPL_LM64' and 'TMPL_RM' are defined.""
    669  %endif
    670  %ifdef TMPL_PE16
    671   %error "Both 'TMPL_LM64' and 'TMPL_PE16' are defined."
    672  %endif
    673  %ifdef TMPL_PE32
    674   %error "Both 'TMPL_LM64' and 'TMPL_PE32' are defined."
    675  %endif
    676  %ifdef TMPL_PEV86
    677   %error "Both 'TMPL_LM64' and 'TMPL_PEV86' are defined."
    678  %endif
    679  %ifdef TMPL_PP16
    680   %error "Both 'TMPL_LM64' and 'TMPL_PP16' are defined."
    681  %endif
    682  %ifdef TMPL_PP32
    683   %error "Both 'TMPL_LM64' and 'TMPL_PP32' are defined."
    684  %endif
    685  %ifdef TMPL_PPV86
    686   %error "Both 'TMPL_LM64' and 'TMPL_PPV86' are defined."
    687  %endif
    688  %ifdef TMPL_PAE16
    689   %error "Both 'TMPL_LM64' and 'TMPL_PAE16' are defined."
    690  %endif
    691  %ifdef TMPL_PAE32
    692   %error "Both 'TMPL_LM64' and 'TMPL_PAE32' are defined."
    693  %endif
    694  %ifdef TMPL_PAEV86
    695   %error "Both 'TMPL_LM64' and 'TMPL_PAEV86' are defined."
    696  %endif
    697  %ifdef TMPL_LM16
    698   %error "Both 'TMPL_LM64' and 'TMPL_LM16' are defined."
    699  %endif
    700  %ifdef TMPL_LM32
    701   %error "Both 'TMPL_LM64' and 'TMPL_LM32' are defined."
    702  %endif
    703  %define TMPL_CMN_LM
    704  %define TMPL_CMN_PAGING
    705  %define TMPL_CMN_P64
     134
     135%elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64
    706136 %define TMPL_64BIT
    707137 %define TMPL_BITS              64
    708138 %define TMPL_PTR_DEF           dq
    709  %define TMPL_NM(Name)          Name %+ _lm64   ; No underscore (C/C++ compatibility).
    710  %define BS3_CMN_NM(Name)       Name %+ _c64    ; No underscore (C/C++ compatibility).
    711139 %define TMPL_UNDERSCORE
     140 %define BS3_CMN_NM(Name)       Name %+ _c64
     141
     142%else
     143 %error "Invalid TMPL_MODE value!"
     144%endif
     145
     146;
     147; Check the system specific mask and set derived values.
     148;
     149%if (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM
     150 %define TMPL_HAVE_BIOS
     151 %define TMPL_CMN_R86
     152
     153%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16
     154 %define TMPL_SYS_PE16
     155 %define TMPL_CMN_PE
     156
     157%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32
     158 %define TMPL_SYS_PE32
     159 %define TMPL_CMN_PE
     160
     161%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16
     162 %define TMPL_SYS_PP16
     163 %define TMPL_CMN_PP
     164 %define TMPL_CMN_PAGING
     165
     166%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32
     167 %define TMPL_SYS_PP32
     168 %define TMPL_CMN_PP
     169 %define TMPL_CMN_PAGING
     170
     171%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16
     172 %define TMPL_SYS_PAE16
     173 %define TMPL_CMN_PAE
     174 %define TMPL_CMN_PAGING
     175
     176%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32
     177 %define TMPL_SYS_PAE32
     178 %define TMPL_CMN_PAE
     179 %define TMPL_CMN_PAGING
     180
     181%elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM
     182 %define TMPL_SYS_LM
     183 %define TMPL_CMN_LM
     184 %define TMPL_CMN_PAGING
     185
     186%else
     187 %error "Invalid TMPL_MODE value!"
     188%endif
     189
     190
     191;
     192; Mode specific stuff.
     193;
     194%if   TMPL_MODE == BS3_MODE_RM
     195 %define TMPL_RM
     196 %define TMPL_MODE_STR          "real mode"
     197 %define TMPL_NM(Name)          _ %+ Name %+ _rm
     198 %define TMPL_MODE_LNAME        rm
     199 %define TMPL_MODE_UNAME        RM
     200
     201
     202%elif TMPL_MODE == BS3_MODE_PE16
     203 %define TMPL_PE16
     204 %define TMPL_MODE_STR          "16-bit prot, 16-bit"
     205 %define TMPL_NM(Name)          _ %+ Name %+ _pe16
     206 %define TMPL_MODE_LNAME        pe16
     207 %define TMPL_MODE_UNAME        PE16
     208
     209%elif TMPL_MODE == BS3_MODE_PE16_32
     210 %define TMPL_PE16_32
     211 %define TMPL_MODE_STR          "16-bit prot, 32-bit"
     212 %define TMPL_NM(Name)          _ %+ Name %+ _pe16_32
     213 %define TMPL_MODE_LNAME        pe16_32
     214 %define TMPL_MODE_UNAME        PE16_32
     215 %define TMPL_CMN_WEIRD
     216
     217%elif TMPL_MODE == BS3_MODE_PE16_V86
     218 %define TMPL_PE16_V86
     219 %define TMPL_MODE_STR          "16-bit prot, v8086"
     220 %define TMPL_NM(Name)          _ %+ Name %+ _pe16_v86
     221 %define TMPL_MODE_LNAME        pe16_v86
     222 %define TMPL_MODE_UNAME        PE16_v86
     223 %define TMPL_CMN_WEIRD
     224 %define TMPL_CMN_WEIRD_V86
     225
     226
     227%elif TMPL_MODE == BS3_MODE_PE32
     228 %define TMPL_PE32
     229 %define TMPL_MODE_STR          "32-bit prot, 32-bit"
     230 %define TMPL_NM(Name)          _ %+ Name %+ _pe32
     231 %define TMPL_MODE_LNAME        pe32
     232 %define TMPL_MODE_UNAME        PE32
     233
     234%elif TMPL_MODE == BS3_MODE_PE32_16
     235 %define TMPL_PE32_16
     236 %define TMPL_MODE_STR          "32-bit prot, 16-bit"
     237 %define TMPL_NM(Name)          _ %+ Name %+ _pe32_16
     238 %define TMPL_MODE_LNAME        pe32_16
     239 %define TMPL_MODE_UNAME        PE32_16
     240 %define TMPL_CMN_WEIRD
     241
     242%elif TMPL_MODE == BS3_MODE_PEV86
     243 %define TMPL_PEV86
     244 %define TMPL_MODE_STR          "32-bit prot, v8086"
     245 %define TMPL_NM(Name)          _ %+ Name %+ _pev86
     246 %define TMPL_MODE_LNAME        pev86
     247 %define TMPL_MODE_UNAME        PEV86
     248
     249
     250%elif TMPL_MODE == BS3_MODE_PP16
     251 %define TMPL_PP16
     252 %define TMPL_MODE_STR          "16-bit paged, 16-bit"
     253 %define TMPL_NM(Name)          _ %+ Name %+ _pp16
     254 %define TMPL_MODE_LNAME        pp16
     255 %define TMPL_MODE_UNAME        PP16
     256
     257%elif TMPL_MODE == BS3_MODE_PP16_32
     258 %define TMPL_PP16_32
     259 %define TMPL_MODE_STR          "16-bit paged, 32-bit"
     260 %define TMPL_NM(Name)          _ %+ Name %+ _pp16_32
     261 %define TMPL_MODE_LNAME        pp16_32
     262 %define TMPL_MODE_UNAME        PP16_32
     263 %define TMPL_CMN_WEIRD
     264
     265%elif TMPL_MODE == BS3_MODE_PP16_V86
     266 %define TMPL_PP16_V86
     267 %define TMPL_MODE_STR          "16-bit paged, v8086"
     268 %define TMPL_NM(Name)          _ %+ Name %+ _pp16_v86
     269 %define TMPL_MODE_LNAME        pp16_v86
     270 %define TMPL_MODE_UNAME        PP16_v86
     271 %define TMPL_CMN_WEIRD
     272 %define TMPL_CMN_WEIRD_V86
     273
     274
     275%elif TMPL_MODE == BS3_MODE_PP32
     276 %define TMPL_PP32
     277 %define TMPL_MODE_STR          "32-bit paged, 32-bit"
     278 %define TMPL_NM(Name)          _ %+ Name %+ _pp32
     279 %define TMPL_MODE_LNAME        pp32
     280 %define TMPL_MODE_UNAME        PP32
     281
     282%elif TMPL_MODE == BS3_MODE_PP32_16
     283 %define TMPL_PP32_16
     284 %define TMPL_MODE_STR          "32-bit paged, 16-bit"
     285 %define TMPL_NM(Name)          _ %+ Name %+ _pp32_16
     286 %define TMPL_MODE_LNAME        pp32_16
     287 %define TMPL_MODE_UNAME        PP32_16
     288 %define TMPL_CMN_WEIRD
     289
     290%elif TMPL_MODE == BS3_MODE_PPV86
     291 %define TMPL_PPV86
     292 %define TMPL_MODE_STR          "32-bit paged, v8086"
     293 %define TMPL_NM(Name)          _ %+ Name %+ _ppv86
     294 %define TMPL_MODE_LNAME        ppv86
     295 %define TMPL_MODE_UNAME        PPV86
     296
     297
     298%elif TMPL_MODE == BS3_MODE_PAE16
     299 %define TMPL_PAE16
     300 %define TMPL_MODE_STR          "16-bit pae, 16-bit"
     301 %define TMPL_NM(Name)          _ %+ Name %+ _pae16
     302 %define TMPL_MODE_LNAME        pae16
     303 %define TMPL_MODE_UNAME        PAE16
     304
     305%elif TMPL_MODE == BS3_MODE_PAE16_32
     306 %define TMPL_PAE16_32
     307 %define TMPL_MODE_STR          "16-bit pae, 32-bit"
     308 %define TMPL_NM(Name)          _ %+ Name %+ _pae16_32
     309 %define TMPL_MODE_LNAME        pae16_32
     310 %define TMPL_MODE_UNAME        PAE16_32
     311 %define TMPL_CMN_WEIRD
     312
     313%elif TMPL_MODE == BS3_MODE_PAE16_V86
     314 %define TMPL_PAE16_V86
     315 %define TMPL_MODE_STR          "16-bit pae, v8086"
     316 %define TMPL_NM(Name)          _ %+ Name %+ _pae16_v86
     317 %define TMPL_MODE_LNAME        pae16_v86
     318 %define TMPL_MODE_UNAME        PAE16_v86
     319 %define TMPL_CMN_WEIRD
     320 %define TMPL_CMN_WEIRD_V86
     321
     322
     323%elif TMPL_MODE == BS3_MODE_PAE32
     324 %define TMPL_PAE32
     325 %define TMPL_MODE_STR          "32-bit pae, 32-bit"
     326 %define TMPL_NM(Name)          _ %+ Name %+ _pae32
     327 %define TMPL_MODE_LNAME        pae32
     328 %define TMPL_MODE_UNAME        PAE32
     329
     330%elif TMPL_MODE == BS3_MODE_PAE32_16
     331 %define TMPL_PAE32_16
     332 %define TMPL_MODE_STR          "32-bit pae, 32-bit"
     333 %define TMPL_NM(Name)          _ %+ Name %+ _pae32_16
     334 %define TMPL_MODE_LNAME        pae32_16
     335 %define TMPL_MODE_UNAME        PAE32_16
     336 %define TMPL_CMN_WEIRD
     337
     338%elif TMPL_MODE == BS3_MODE_PAEV86
     339 %define TMPL_PAEV86
     340 %define TMPL_MODE_STR          "32-bit pae, v8086 pae"
     341 %define TMPL_NM(Name)          _ %+ Name %+ _paev86
     342 %define TMPL_MODE_LNAME        paev86
     343 %define TMPL_MODE_UNAME        PAEV86
     344
     345
     346%elif TMPL_MODE == BS3_MODE_LM16
     347 %define TMPL_LM16
     348 %define TMPL_MODE_STR          "long, 16-bit"
     349 %define TMPL_NM(Name)          _ %+ Name %+ _lm16
     350 %define TMPL_MODE_LNAME        lm16
     351 %define TMPL_MODE_UNAME        LM16
     352
     353%elif TMPL_MODE == BS3_MODE_LM32
     354 %define TMPL_LM32
     355 %define TMPL_MODE_STR          "long, 32-bit"
     356 %define TMPL_NM(Name)          _ %+ Name %+ _lm32
     357 %define TMPL_MODE_LNAME        lm32
     358 %define TMPL_MODE_UNAME        LM32
     359
     360%elif TMPL_MODE == BS3_MODE_LM64
     361 %define TMPL_LM64
     362 %define TMPL_MODE_STR          "long, 64-bit"
     363 %define TMPL_NM(Name)          Name %+ _lm64
    712364 %define TMPL_MODE_LNAME        lm64
    713365 %define TMPL_MODE_UNAME        LM64
    714  %define TMPL_MODE_STR          '64-bit long mode'
    715 %endif
    716 
    717 %ifndef TMPL_MODE_STR
    718  %error "internal error"
     366
     367%else
     368 %error "Invalid TMPL_MODE value!!"
    719369%endif
    720370
     
    739389
    740390
    741 ;
    742 ; Register aliases.
    743 ;
    744 %ifdef TMPL_64BIT
    745  %define xCB  8
    746  %define xDEF dq
    747  %define xRES resq
    748  %define xPRE qword
    749  %define xSP  rsp
    750  %define xBP  rbp
    751  %define xAX  rax
    752  %define xBX  rbx
    753  %define xCX  rcx
    754  %define xDX  rdx
    755  %define xDI  rdi
    756  %define xSI  rsi
    757  %define xWrtRIP wrt rip
    758  %define xPUSHF pushfq
    759  %define xPOPF  popfq
    760  %define xRETF  o64 retf
    761 %else
    762  %ifdef TMPL_32BIT
    763   %define xCB  4
    764   %define xDEF dd
    765   %define xRES resd
    766   %define xPRE dword
    767   %define xSP  esp
    768   %define xBP  ebp
    769   %define xAX  eax
    770   %define xBX  ebx
    771   %define xCX  ecx
    772   %define xDX  edx
    773   %define xDI  edi
    774   %define xSI  esi
    775   %define xWrtRIP
    776   %define xPUSHF pushfd
    777   %define xPOPF  popfd
    778   %define xRETF  retf
    779  %else
    780   %ifndef TMPL_16BIT
    781    %error "TMPL_XXBIT is not defined."
    782   %endif
    783   %define xCB  2
    784   %define xDEF dw
    785   %define xRES resw
    786   %define xPRE word
    787   %define xSP  sp
    788   %define xBP  bp
    789   %define xAX  ax
    790   %define xBX  bx
    791   %define xCX  cx
    792   %define xDX  dx
    793   %define xDI  di
    794   %define xSI  si
    795   %define xWrtRIP
    796   %define xPUSHF pushf
    797   %define xPOPF  popf
    798   %define xRETF  retf
    799  %endif
    800 %endif
    801 
    802 
    803 ;
    804 ; Register names corresponding to the max size for pop/push <reg>.
    805 ;
    806 ; 16-bit can push both 32-bit and 16-bit registers.  This 's' prefixed variant
    807 ; is used when 16-bit should use the 32-bit register.
    808 ;
    809 %ifdef TMPL_64BIT
    810  %define sCB  8
    811  %define sDEF dq
    812  %define sRES resq
    813  %define sPRE qword
    814  %define sSP  rsp
    815  %define sBP  rbp
    816  %define sAX  rax
    817  %define sBX  rbx
    818  %define sCX  rcx
    819  %define sDX  rdx
    820  %define sDI  rdi
    821  %define sSI  rsi
    822  %define sPUSHF pushfq
    823  %define sPOPF  popfq
    824 %else
    825  %define sCB  4
    826  %define sDEF dd
    827  %define sRES resd
    828  %define sPRE dword
    829  %define sSP  esp
    830  %define sBP  ebp
    831  %define sAX  eax
    832  %define sBX  ebx
    833  %define sCX  ecx
    834  %define sDX  edx
    835  %define sDI  edi
    836  %define sSI  esi
    837  %define sPUSHF pushfd
    838  %define sPOPF  popfd
    839 %endif
    840 
    841391;; @def TMPL_WRT_FLAT
    842392; WRT flat when not in 16-bit modes.
     
    866416 %define TMPL_WRT_SYSTEM16_OR_FLAT  wrt FLAT
    867417%endif
    868 
    869 ;; @def BS3_EXTERN_TMPL
    870 ; Mangles the given name into a template specific one.  For ease of use, the
    871 ; name is redefined to the mangled one, just like BS3_EXTERN_CMN does.
    872 ; @note Segment does not change.
    873 %macro BS3_EXTERN_TMPL 1
    874  extern TMPL_NM(%1)
    875  %undef  %1
    876  %define %1 TMPL_NM(%1)
    877 %endmacro
    878418
    879419;
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r59789 r59863  
    5454/** @defgroup grp_bs3kit     BS3Kit
    5555 * @{ */
     56
     57/** @name Execution modes.
     58 * @{ */
     59#define BS3_MODE_INVALID    UINT8_C(0x00)
     60#define BS3_MODE_RM         UINT8_C(0x01)  /**< real mode. */
     61#define BS3_MODE_PE16       UINT8_C(0x11)  /**< 16-bit protected mode kernel+tss, running 16-bit code, unpaged. */
     62#define BS3_MODE_PE16_32    UINT8_C(0x12)  /**< 16-bit protected mode kernel+tss, running 32-bit code, unpaged. */
     63#define BS3_MODE_PE16_V86   UINT8_C(0x13)  /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
     64#define BS3_MODE_PE32       UINT8_C(0x22)  /**< 32-bit protected mode kernel+tss, running 32-bit code, unpaged. */
     65#define BS3_MODE_PE32_16    UINT8_C(0x21)  /**< 32-bit protected mode kernel+tss, running 16-bit code, unpaged. */
     66#define BS3_MODE_PEV86      UINT8_C(0x23)  /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
     67#define BS3_MODE_PP16       UINT8_C(0x31)  /**< 16-bit protected mode kernel+tss, running 16-bit code, paged. */
     68#define BS3_MODE_PP16_32    UINT8_C(0x32)  /**< 16-bit protected mode kernel+tss, running 32-bit code, paged. */
     69#define BS3_MODE_PP16_V86   UINT8_C(0x33)  /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
     70#define BS3_MODE_PP32       UINT8_C(0x42)  /**< 32-bit protected mode kernel+tss, running 32-bit code, paged. */
     71#define BS3_MODE_PP32_16    UINT8_C(0x41)  /**< 32-bit protected mode kernel+tss, running 16-bit code, paged. */
     72#define BS3_MODE_PPV86      UINT8_C(0x43)  /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
     73#define BS3_MODE_PAE16      UINT8_C(0x51)  /**< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
     74#define BS3_MODE_PAE16_32   UINT8_C(0x52)  /**< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
     75#define BS3_MODE_PAE16_V86  UINT8_C(0x53)  /**< 16-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
     76#define BS3_MODE_PAE32      UINT8_C(0x62)  /**< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
     77#define BS3_MODE_PAE32_16   UINT8_C(0x61)  /**< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
     78#define BS3_MODE_PAEV86     UINT8_C(0x63)  /**< 32-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
     79#define BS3_MODE_LM16       UINT8_C(0x71)  /**< 16-bit long mode (paged), kernel+tss always 64-bit. */
     80#define BS3_MODE_LM32       UINT8_C(0x72)  /**< 32-bit long mode (paged), kernel+tss always 64-bit. */
     81#define BS3_MODE_LM64       UINT8_C(0x74)  /**< 64-bit long mode (paged), kernel+tss always 64-bit. */
     82
     83#define BS3_MODE_CODE_MASK  UINT8_C(0x0f)  /**< Running code mask. */
     84#define BS3_MODE_CODE_16    UINT8_C(0x01)  /**< Running 16-bit code. */
     85#define BS3_MODE_CODE_32    UINT8_C(0x02)  /**< Running 32-bit code. */
     86#define BS3_MODE_CODE_V86   UINT8_C(0x03)  /**< Running 16-bit virtual 8086 code. */
     87#define BS3_MODE_CODE_64    UINT8_C(0x04)  /**< Running 64-bit code. */
     88
     89#define BS3_MODE_SYS_MASK   UINT8_C(0xf0)  /**< kernel+tss mask. */
     90#define BS3_MODE_SYS_RM     UINT8_C(0x00)  /**< Real mode kernel+tss. */
     91#define BS3_MODE_SYS_PE16   UINT8_C(0x10)  /**< 16-bit protected mode kernel+tss. */
     92#define BS3_MODE_SYS_PE32   UINT8_C(0x20)  /**< 32-bit protected mode kernel+tss. */
     93#define BS3_MODE_SYS_PP16   UINT8_C(0x30)  /**< 16-bit paged protected mode kernel+tss. */
     94#define BS3_MODE_SYS_PP32   UINT8_C(0x40)  /**< 32-bit paged protected mode kernel+tss. */
     95#define BS3_MODE_SYS_PAE16  UINT8_C(0x50)  /**< 16-bit PAE paged protected mode kernel+tss. */
     96#define BS3_MODE_SYS_PAE32  UINT8_C(0x60)  /**< 32-bit PAE paged protected mode kernel+tss. */
     97#define BS3_MODE_SYS_LM     UINT8_C(0x70)  /**< 64-bit (paged) long mode protected mode kernel+tss. */
     98
     99/** Whether the mode has paging enabled. */
     100#define BS3_MODE_IS_PAGED(a_fMode)              ((a_fMode) >= BS3_MODE_PP16)
     101
     102/** Whether the mode is running v8086 code. */
     103#define BS3_MODE_IS_V86(a_fMode)                (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86)
     104/** Whether the we're executing in real mode or v8086 mode. */
     105#define BS3_MODE_IS_RM_OR_V86(a_fMode)          ((a_fMode) == BS3_MODE_RM || BS3_MODE_IS_V86(a_fMode))
     106/** Whether the mode is running 16-bit code, except v8086. */
     107#define BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode)  (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16)
     108/** Whether the mode is running 16-bit code (includes v8086). */
     109#define BS3_MODE_IS_16BIT_CODE(a_fMode)         (BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) || BS3_MODE_IS_V86(a_fMode))
     110/** Whether the mode is running 32-bit code. */
     111#define BS3_MODE_IS_32BIT_CODE(a_fMode)         (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32)
     112/** Whether the mode is running 64-bit code. */
     113#define BS3_MODE_IS_64BIT_CODE(a_fMode)         (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64)
     114
     115/** Whether the system is in real mode. */
     116#define BS3_MODE_IS_RM_SYS(a_fMode)             (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM)
     117/** Whether the system is some 16-bit mode that isn't real mode. */
     118#define BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode)    (   ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16 \
     119                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16 \
     120                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16)
     121/** Whether the system is some 16-bit mode (includes real mode). */
     122#define BS3_MODE_IS_16BIT_SYS(a_fMode)          (BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) || BS3_MODE_IS_RM_SYS(a_fMode))
     123/** Whether the system is some 32-bit mode. */
     124#define BS3_MODE_IS_32BIT_SYS(a_fMode)          (   ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32 \
     125                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32 \
     126                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32)
     127/** Whether the system is long mode. */
     128#define BS3_MODE_IS_64BIT_SYS(a_fMode)          (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM)
     129
     130/** @todo testcase: How would long-mode handle a 16-bit TSS loaded prior to the switch? (mainly stack switching wise) Hopefully, it will tripple fault, right? */
     131/** @} */
    56132
    57133
     
    722798
    723799
     800/** The current mode (BS3_MODE_XXX) of CPU \#0. */
     801extern uint8_t BS3_FAR_DATA BS3_DATA_NM(g_bBs3CurrentMode);
     802
     803
    724804#ifdef __WATCOMC__
    725805/**
     
    741821# define BS3_IS_PROTECTED_MODE() (true)
    742822#else
    743 # define BS3_IS_PROTECTED_MODE() (Bs3AsmSmsw() & 1 /*PE*/)
     823# if 1
     824#  define BS3_IS_PROTECTED_MODE() (!BS3_MODE_IS_RM_SYS(BS3_DATA_NM(g_bBs3CurrentMode)))
     825# else
     826#  define BS3_IS_PROTECTED_MODE() (Bs3AsmSmsw() & 1 /*PE*/)
     827# endif
    744828#endif
    745829
     
    12351319BS3_DECL(void) Bs3TestInit_c64(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
    12361320#define Bs3TestInit BS3_CMN_NM(Bs3TestInit) /**< Selects #Bs3TestInit_c16, #Bs3TestInit_c32 or #Bs3TestInit_c64. */
     1321
     1322
     1323/**
     1324 * Equivalent to RTTestSummaryAndDestroy.
     1325 */
     1326BS3_DECL(void) Bs3TestTerm_c16(void);
     1327BS3_DECL(void) Bs3TestTerm_c32(void); /**< @copydoc Bs3TestTerm_c16 */
     1328BS3_DECL(void) Bs3TestTerm_c64(void); /**< @copydoc Bs3TestTerm_c16 */
     1329#define Bs3TestTerm BS3_CMN_NM(Bs3TestTerm) /**< Selects #Bs3TestTerm_c16, #Bs3TestTerm_c32 or #Bs3TestTerm_c64. */
    12371330
    12381331
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r59789 r59863  
    3636%undef RT_ASMDEFS_INC_FIRST_FILE
    3737
     38;;
     39; Macro for setting register aliases according to the bit count given by %1.
     40;
     41%macro BS3_SET_REG_ALIASES 1
     42 ;
     43 ; Register aliases.
     44 ;
     45 %if %1 == 64
     46  %define xCB  8
     47  %define xDEF dq
     48  %define xRES resq
     49  %define xPRE qword
     50  %define xSP  rsp
     51  %define xBP  rbp
     52  %define xAX  rax
     53  %define xBX  rbx
     54  %define xCX  rcx
     55  %define xDX  rdx
     56  %define xDI  rdi
     57  %define xSI  rsi
     58  %define xWrtRIP wrt rip
     59  %define xPUSHF pushfq
     60  %define xPOPF  popfq
     61  %define xRETF  o64 retf
     62 %elif %1 == 32
     63  %define xCB  4
     64  %define xDEF dd
     65  %define xRES resd
     66  %define xPRE dword
     67  %define xSP  esp
     68  %define xBP  ebp
     69  %define xAX  eax
     70  %define xBX  ebx
     71  %define xCX  ecx
     72  %define xDX  edx
     73  %define xDI  edi
     74  %define xSI  esi
     75  %define xWrtRIP
     76  %define xPUSHF pushfd
     77  %define xPOPF  popfd
     78  %define xRETF  retf
     79 %elif %1 == 16
     80  %define xCB  2
     81  %define xDEF dw
     82  %define xRES resw
     83  %define xPRE word
     84  %define xSP  sp
     85  %define xBP  bp
     86  %define xAX  ax
     87  %define xBX  bx
     88  %define xCX  cx
     89  %define xDX  dx
     90  %define xDI  di
     91  %define xSI  si
     92  %define xWrtRIP
     93  %define xPUSHF pushf
     94  %define xPOPF  popf
     95  %define xRETF  retf
     96 %else
     97  %error "Invalid BS3_SET_REG_ALIASES argument:" %1
     98 %endif
     99
     100
     101 ;
     102 ; Register names corresponding to the max size for pop/push <reg>.
     103 ;
     104 ; 16-bit can push both 32-bit and 16-bit registers.  This 's' prefixed variant
     105 ; is used when 16-bit should use the 32-bit register.
     106 ;
     107 %if %1 == 64
     108  %define sCB  8
     109  %define sDEF dq
     110  %define sRES resq
     111  %define sPRE qword
     112  %define sSP  rsp
     113  %define sBP  rbp
     114  %define sAX  rax
     115  %define sBX  rbx
     116  %define sCX  rcx
     117  %define sDX  rdx
     118  %define sDI  rdi
     119  %define sSI  rsi
     120  %define sPUSHF pushfq
     121  %define sPOPF  popfq
     122 %else
     123  %define sCB  4
     124  %define sDEF dd
     125  %define sRES resd
     126  %define sPRE dword
     127  %define sSP  esp
     128  %define sBP  ebp
     129  %define sAX  eax
     130  %define sBX  ebx
     131  %define sCX  ecx
     132  %define sDX  edx
     133  %define sDI  edi
     134  %define sSI  esi
     135  %define sPUSHF pushfd
     136  %define sPOPF  popfd
     137 %endif
     138%endmacro
     139
     140; Default to register aliases for ARCH_BITS.
     141BS3_SET_REG_ALIASES ARCH_BITS
     142
     143
    38144;; Wrapper around BITS.
    39 ; Updates __BITS__ (built-in variable in nasm, we work it for yasm).
     145; Updates __BITS__ (built-in variable in nasm, we work it for yasm) as well
     146; a number of convenient macros and register aliases.
     147;
    40148; @param    %1      The CPU bit count: 16, 32 or 64
    41149; @remarks ARCH_BITS is not modified and will remain what it was on the
     
    81189 %undef   BS3_WRT_RIP
    82190 %if %1 == 64
    83   %define BS3_WRT_RIP               wrt rip
    84  %else
    85   %define BS3_WRT_RIP
     191  %ifdef __YASM__
     192   %define BS3_WRT_RIP(a_Sym)       a_Sym wrt rip
     193  %else
     194   %define BS3_WRT_RIP(a_Sym)       rel a_Sym       ; Baka! Why couldn't they do 'wrt rip' like yasm?
     195  %endif
     196 %else
     197  %define BS3_WRT_RIP(a_Sym)        a_Sym
    86198 %endif
    87199
     
    106218  %define BS3_IF_64BIT_OTHERWISE(a_64BitExpr, a_OtherwiseExpr) a_OtherwiseExpr
    107219 %endif
    108 %endmacro
     220
     221 BS3_SET_REG_ALIASES %1
     222%endmacro
     223
    109224
    110225;; Emulate the __BITS__ macro in NASM 2.0+. Follows BS3_SET_BITS.
     
    123238; other modes. Follows BS3_SET_BITS.
    124239%if ARCH_BITS == 64
    125  %define BS3_WRT_RIP                wrt rip
     240 %ifdef __YASM__
     241  %define BS3_WRT_RIP(a_Sym)        a_Sym wrt rip
     242 %else
     243  %define BS3_WRT_RIP(a_Sym)        rel a_Sym       ; Baka! Why couldn't they do 'wrt rip' like yasm?
     244 %endif
    126245%else
    127  %define BS3_WRT_RIP
     246 %define BS3_WRT_RIP(a_Sym)         a_Sym
    128247%endif
    129248
     
    363482%endmacro
    364483
     484;; @def BS3_EXTERN_TMPL
     485; Mangles the given name into a template specific one.  For ease of use, the
     486; name is redefined to the mangled one, just like BS3_EXTERN_CMN does.
     487; @note Segment does not change.
     488%macro BS3_EXTERN_TMPL 1
     489 extern TMPL_NM(%1)
     490 %undef  %1
     491 %define %1 TMPL_NM(%1)
     492%endmacro
     493
     494
    365495;;
    366496; Mangles a 16-bit and 32-bit accessible data name.
     
    585715 %endif
    586716        call        %1
     717%endmacro
     718
     719
     720;; @name Execution Modes
     721; @{
     722%define BS3_MODE_INVALID    000h
     723%define BS3_MODE_RM         001h    ;;< real mode.
     724%define BS3_MODE_PE16       011h    ;;< 16-bit protected mode kernel+tss, running 16-bit code, unpaged.
     725%define BS3_MODE_PE16_32    012h    ;;< 16-bit protected mode kernel+tss, running 32-bit code, unpaged.
     726%define BS3_MODE_PE16_V86   013h    ;;< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged.
     727%define BS3_MODE_PE32       022h    ;;< 32-bit protected mode kernel+tss, running 32-bit code, unpaged.
     728%define BS3_MODE_PE32_16    021h    ;;< 32-bit protected mode kernel+tss, running 16-bit code, unpaged.
     729%define BS3_MODE_PEV86      023h    ;;< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged.
     730%define BS3_MODE_PP16       031h    ;;< 16-bit protected mode kernel+tss, running 16-bit code, paged.
     731%define BS3_MODE_PP16_32    032h    ;;< 16-bit protected mode kernel+tss, running 32-bit code, paged.
     732%define BS3_MODE_PP16_V86   033h    ;;< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged.
     733%define BS3_MODE_PP32       042h    ;;< 32-bit protected mode kernel+tss, running 32-bit code, paged.
     734%define BS3_MODE_PP32_16    041h    ;;< 32-bit protected mode kernel+tss, running 16-bit code, paged.
     735%define BS3_MODE_PPV86      043h    ;;< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged.
     736%define BS3_MODE_PAE16      051h    ;;< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging.
     737%define BS3_MODE_PAE16_32   052h    ;;< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging.
     738%define BS3_MODE_PAE16_V86  053h    ;;< 16-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging.
     739%define BS3_MODE_PAE32      062h    ;;< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging.
     740%define BS3_MODE_PAE32_16   061h    ;;< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging.
     741%define BS3_MODE_PAEV86     063h    ;;< 32-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging.
     742%define BS3_MODE_LM16       071h    ;;< 16-bit long mode (paged), kernel+tss always 64-bit.
     743%define BS3_MODE_LM32       072h    ;;< 32-bit long mode (paged), kernel+tss always 64-bit.
     744%define BS3_MODE_LM64       074h    ;;< 64-bit long mode (paged), kernel+tss always 64-bit.
     745
     746%define BS3_MODE_CODE_MASK  00fh    ;;< Running code mask.
     747%define BS3_MODE_CODE_16    001h    ;;< Running 16-bit code.
     748%define BS3_MODE_CODE_32    002h    ;;< Running 32-bit code.
     749%define BS3_MODE_CODE_V86   003h    ;;< Running 16-bit virtual 8086 code.
     750%define BS3_MODE_CODE_64    004h    ;;< Running 64-bit code.
     751
     752%define BS3_MODE_SYS_MASK   0f0h    ;;< kernel+tss mask.
     753%define BS3_MODE_SYS_RM     000h    ;;< Real mode kernel+tss.
     754%define BS3_MODE_SYS_PE16   010h    ;;< 16-bit protected mode kernel+tss.
     755%define BS3_MODE_SYS_PE32   020h    ;;< 32-bit protected mode kernel+tss.
     756%define BS3_MODE_SYS_PP16   030h    ;;< 16-bit paged protected mode kernel+tss.
     757%define BS3_MODE_SYS_PP32   040h    ;;< 32-bit paged protected mode kernel+tss.
     758%define BS3_MODE_SYS_PAE16  050h    ;;< 16-bit PAE paged protected mode kernel+tss.
     759%define BS3_MODE_SYS_PAE32  060h    ;;< 32-bit PAE paged protected mode kernel+tss.
     760%define BS3_MODE_SYS_LM     070h    ;;< 64-bit (paged) long mode protected mode kernel+tss.
     761
     762;; Whether the mode has paging enabled.
     763%define BS3_MODE_IS_PAGED(a_fMode)              ((a_fMode) >= BS3_MODE_PP16)
     764
     765;; Whether the mode is running v8086 code.
     766%define BS3_MODE_IS_V86(a_fMode)                (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86)
     767;; Whether the we're executing in real mode or v8086 mode.
     768%define BS3_MODE_IS_RM_OR_V86(a_fMode)          ((a_fMode) == BS3_MODE_RM || BS3_MODE_IS_V86(a_fMode))
     769;; Whether the mode is running 16-bit code, except v8086.
     770%define BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode)  (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16)
     771;; Whether the mode is running 16-bit code (includes v8086).
     772%define BS3_MODE_IS_16BIT_CODE(a_fMode)         (BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) || BS3_MODE_IS_V86(a_fMode))
     773;; Whether the mode is running 32-bit code.
     774%define BS3_MODE_IS_32BIT_CODE(a_fMode)         (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32)
     775;; Whether the mode is running 64-bit code.
     776%define BS3_MODE_IS_64BIT_CODE(a_fMode)         (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64)
     777
     778;; Whether the system is in real mode.
     779%define BS3_MODE_IS_RM_SYS(a_fMode)             (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM)
     780;; Whether the system is some 16-bit mode that isn't real mode.
     781%define BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode)    (   ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16 \
     782                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16 \
     783                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16)
     784;; Whether the system is some 16-bit mode (includes real mode).
     785%define BS3_MODE_IS_16BIT_SYS(a_fMode)          (BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) || BS3_MODE_IS_RM_SYS(a_fMode))
     786;; Whether the system is some 32-bit mode.
     787%define BS3_MODE_IS_32BIT_SYS(a_fMode)          (   ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32 \
     788                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32 \
     789                                                 || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32)
     790;; Whether the system is long mode.
     791%define BS3_MODE_IS_64BIT_SYS(a_fMode)          (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM)
     792
     793;; @}
     794
     795;;
     796; Includes the file %1 with TMPL_MODE set to all possible value.
     797; @param 1      Double quoted include file name.
     798%macro BS3_INSTANTIATE_TEMPLATE_WITH_WEIRD_ONES 1
     799 %define TMPL_MODE BS3_MODE_RM
     800 %include %1
     801
     802 %define TMPL_MODE BS3_MODE_PE16
     803 %include %1
     804 %define TMPL_MODE BS3_MODE_PE16_32
     805 %include %1
     806 %define TMPL_MODE BS3_MODE_PE16_V86
     807 %include %1
     808
     809 %define TMPL_MODE BS3_MODE_PE32
     810 %include %1
     811 %define TMPL_MODE BS3_MODE_PE32_16
     812 %include %1
     813 %define TMPL_MODE BS3_MODE_PEV86
     814 %include %1
     815
     816 %define TMPL_MODE BS3_MODE_PP16
     817 %include %1
     818 %define TMPL_MODE BS3_MODE_PP16_32
     819 %include %1
     820 %define TMPL_MODE BS3_MODE_PP16_V86
     821 %include %1
     822
     823 %define TMPL_MODE BS3_MODE_PP32
     824 %include %1
     825 %define TMPL_MODE BS3_MODE_PP32_16
     826 %include %1
     827 %define TMPL_MODE BS3_MODE_PPV86
     828 %include %1
     829
     830 %define TMPL_MODE BS3_MODE_PAE16
     831 %include %1
     832 %define TMPL_MODE BS3_MODE_PAE16_32
     833 %include %1
     834 %define TMPL_MODE BS3_MODE_PAE16_V86
     835 %include %1
     836
     837 %define TMPL_MODE BS3_MODE_PAE32
     838 %include %1
     839 %define TMPL_MODE BS3_MODE_PAE32_16
     840 %include %1
     841 %define TMPL_MODE BS3_MODE_PAEV86
     842 %include %1
     843
     844 %define TMPL_MODE BS3_MODE_LM16
     845 %include %1
     846 %define TMPL_MODE BS3_MODE_LM32
     847 %include %1
     848 %define TMPL_MODE BS3_MODE_LM64
     849 %include %1
     850%endmacro
     851
     852
     853;;
     854; Includes the file %1 with TMPL_MODE set to all but the "weird" value.
     855; @param 1      Double quoted include file name.
     856%macro BS3_INSTANTIATE_TEMPLATE_ESSENTIALS 1
     857 %define TMPL_MODE BS3_MODE_RM
     858 %include %1
     859
     860 %define TMPL_MODE BS3_MODE_PE16
     861 %include %1
     862
     863 %define TMPL_MODE BS3_MODE_PE32
     864 %include %1
     865 %define TMPL_MODE BS3_MODE_PEV86
     866 %include %1
     867
     868 %define TMPL_MODE BS3_MODE_PP16
     869 %include %1
     870
     871 %define TMPL_MODE BS3_MODE_PP32
     872 %include %1
     873 %define TMPL_MODE BS3_MODE_PPV86
     874 %include %1
     875
     876 %define TMPL_MODE BS3_MODE_PAE16
     877 %include %1
     878
     879 %define TMPL_MODE BS3_MODE_PAE32
     880 %include %1
     881 %define TMPL_MODE BS3_MODE_PAEV86
     882 %include %1
     883
     884 %define TMPL_MODE BS3_MODE_LM16
     885 %include %1
     886 %define TMPL_MODE BS3_MODE_LM32
     887 %include %1
     888 %define TMPL_MODE BS3_MODE_LM64
     889 %include %1
     890%endmacro
     891
     892;;
     893; Includes the file %1 with TMPL_MODE set to a 16-bit, a 32-bit and a 64-bit value.
     894; @param 1      Double quoted include file name.
     895%macro BS3_INSTANTIATE_COMMON_TEMPLATE 1
     896 %define TMPL_MODE BS3_MODE_RM
     897 %include %1
     898 %define TMPL_MODE BS3_MODE_PE32
     899 %include %1
     900 %define TMPL_MODE BS3_MODE_LM64
     901 %include %1
    587902%endmacro
    588903
     
    8501165%define BS3_SEL_TILED_AREA_SIZE     001000000h ;;< 16-bit data tiling: Size of addressable area, in bytes. (16 MB)
    8511166
    852 %define BS3_SEL_FREE_PART1          0e00h ;;< Free selector space - part \#1.
    853 %define BS3_SEL_FREE_PART1_LAST     0ff8h ;;< Free selector space - part \#1, last entry.
     1167%define BS3_SEL_FREE_PART1          0e00h ;;< Free selector space - part \%1.
     1168%define BS3_SEL_FREE_PART1_LAST     0ff8h ;;< Free selector space - part \%1, last entry.
    8541169
    8551170%define BS3_SEL_TEXT16              1000h ;;< The BS3TEXT16 selector.
    8561171
    857 %define BS3_SEL_FREE_PART2          1008h ;;< Free selector space - part \#2.
    858 %define BS3_SEL_FREE_PART2_LAST     1ff8h ;;< Free selector space - part \#2, last entry.
     1172%define BS3_SEL_FREE_PART2          1008h ;;< Free selector space - part \%2.
     1173%define BS3_SEL_FREE_PART2_LAST     1ff8h ;;< Free selector space - part \%2, last entry.
    8591174
    8601175%define BS3_SEL_SYSTEM16            2000h ;;< The BS3SYSTEM16 selector.
    8611176
    862 %define BS3_SEL_FREE_PART3          2008h ;;< Free selector space - part \#3.
    863 %define BS3_SEL_FREE_PART3_LAST     26f8h ;;< Free selector space - part \#3, last entry.
     1177%define BS3_SEL_FREE_PART3          2008h ;;< Free selector space - part \%3.
     1178%define BS3_SEL_FREE_PART3_LAST     26f8h ;;< Free selector space - part \%3, last entry.
    8641179
    8651180%define BS3_SEL_DATA16              2700h ;;< The BS3DATA16 selector.
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