Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58628)
@@ -62,17 +62,20 @@
 # BS3Kit template for assembly and 16-bit code.
 TEMPLATE_VBoxBS3KitImg = Template for building BS3Kit test images.
-TEMPLATE_VBoxBS3KitImg_INST     = $(INST_VALIDATIONKIT)bootsectors/
-TEMPLATE_VBoxBS3KitImg_BINSUFF  = .img
-TEMPLATE_VBoxBS3KitImg_MODE     = 0644
-TEMPLATE_VBoxBS3KitImg_ASTOOL   = NASM
-TEMPLATE_VBoxBS3KitImg_ASFLAGS := -f obj -g -w+orphan-labels
-TEMPLATE_VBoxBS3KitImg_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=16 __NASM__
-TEMPLATE_VBoxBS3KitImg_ARTOOL   = OPENWATCOM-16
-TEMPLATE_VBoxBS3KitImg_CTOOL    = OPENWATCOM-16
-TEMPLATE_VBoxBS3KitImg_CXXTOOL  = OPENWATCOM-16
-TEMPLATE_VBoxBS3KitImg_CFLAGS   = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
-TEMPLATE_VBoxBS3KitImg_CXXFLAGS = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
-TEMPLATE_VBoxBS3KitImg_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
-TEMPLATE_VBoxBS3KitImg_LDTOOL   = OPENWATCOM-WL
+TEMPLATE_VBoxBS3KitImg_BLD_TRG      = os-agnostic
+TEMPLATE_VBoxBS3KitImg_BLD_TRG_ARCH = x86
+TEMPLATE_VBoxBS3KitImg_INST         = $(INST_VALIDATIONKIT)bootsectors/
+TEMPLATE_VBoxBS3KitImg_BINSUFF      = .img
+TEMPLATE_VBoxBS3KitImg_MODE         = 0644
+TEMPLATE_VBoxBS3KitImg_ASTOOL       = NASM
+TEMPLATE_VBoxBS3KitImg_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
+TEMPLATE_VBoxBS3KitImg_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
+TEMPLATE_VBoxBS3KitImg_DEFS         = ARCH_BITS=16 IN_BS3KIT
+TEMPLATE_VBoxBS3KitImg_ARTOOL       = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CTOOL        = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CXXTOOL      = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CFLAGS       = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
+TEMPLATE_VBoxBS3KitImg_CXXFLAGS     = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc -hc -d1+
+TEMPLATE_VBoxBS3KitImg_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
+TEMPLATE_VBoxBS3KitImg_LDTOOL       = OPENWATCOM-WL
 # 	option quiet, nofarcalls\
 #	disable 1014, 1023, 2120, 1080
@@ -81,19 +84,33 @@
 	debug codeview all \
 	option quiet, map, statics, verbose, symfile, start=_start \
-       disable 1014, 1080 \
+       disable 1014, 1080, 1150 \
 	\
  	output raw offset=0x10000 \
  	order \
- 	 clname CODE16  segaddr=0x1000 \
+ 	 clname BS3CODE16  segaddr=0x1000 \
  	  segment BS3TEXT16 \
  	  segment text \
  	 clname FAR_DATA \
  	  segment BS3DATA16 \
-        clname CODE32 \
+ 	  segment BS3DATA16CONST \
+ 	  segment BS3DATA16CONST2 \
+ 	  segment BS3DATA16_DATA \
+	  segment BS3DATA32 \
+	  segment BS3DATA32_CONST \
+	  segment BS3DATA32_CONST2 \
+	  segment BS3DATA32_DATA \
+ 	  segment DATA32 \
+        clname BS3CODE32 \
  	  segment BS3TEXT32 \
  	  segment TEXT32 \
-        clname DATA32 \
- 	  segment BS3DATA32 \
- 	  segment DATA32
+        clname CODE \
+ 	  segment BS3TEXT64 \
+ 	  segment TEXT64 \
+ 	  segment .text \
+ 	  segment .rdata \
+        clname DATA \
+ 	  segment BS3DATA64 \
+ 	  segment DATA64 \
+ 	  segment .data
 TEMPLATE_VBoxBS3KitImg_DEPS = \
 	$(bs3-bootsector_1_TARGET) \
@@ -111,39 +128,57 @@
 # BS3Kit template for 32-bit code.
 TEMPLATE_VBoxBS3KitImg32 = Template for building BS3Kit test images.
-TEMPLATE_VBoxBS3KitImg32_INSTTYPE = none
-TEMPLATE_VBoxBS3KitImg32_ASTOOL   = NASM
-TEMPLATE_VBoxBS3KitImg32_ASFLAGS := -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
-TEMPLATE_VBoxBS3KitImg32_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=32 __NASM__
-TEMPLATE_VBoxBS3KitImg32_ARTOOL   = OPENWATCOM
-TEMPLATE_VBoxBS3KitImg32_CTOOL    = OPENWATCOM
-TEMPLATE_VBoxBS3KitImg32_CXXTOOL  = OPENWATCOM
-TEMPLATE_VBoxBS3KitImg32_CFLAGS   = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -s -oas -ms -hc -d1
-TEMPLATE_VBoxBS3KitImg32_CXXFLAGS = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -s -oas -ms -hc -d1
-TEMPLATE_VBoxBS3KitImg32_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
-TEMPLATE_VBoxBS3KitImg32_LDTOOL   = VBoxBsUnusedLd
+TEMPLATE_VBoxBS3KitImg32_BLD_TRG      = os-agnostic
+TEMPLATE_VBoxBS3KitImg32_BLD_TRG_ARCH = x86
+TEMPLATE_VBoxBS3KitImg32_INSTTYPE     = none
+TEMPLATE_VBoxBS3KitImg32_ASTOOL       = NASM
+TEMPLATE_VBoxBS3KitImg32_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
+TEMPLATE_VBoxBS3KitImg32_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
+TEMPLATE_VBoxBS3KitImg32_DEFS         = ARCH_BITS=32 IN_BS3KIT
+TEMPLATE_VBoxBS3KitImg32_ARTOOL       = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CTOOL        = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CXXTOOL      = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CFLAGS       = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf -hc -d1
+TEMPLATE_VBoxBS3KitImg32_CXXFLAGS     = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf -hc -d1
+TEMPLATE_VBoxBS3KitImg32_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
+TEMPLATE_VBoxBS3KitImg32_LDTOOL       = VBoxBsUnusedLd
 
 # BS3Kit template for 64-bit code.
 TEMPLATE_VBoxBS3KitImg64 = Template for building BS3Kit test images.
-TEMPLATE_VBoxBS3KitImg64_INSTTYPE = none
-TEMPLATE_VBoxBS3KitImg64_ASTOOL   = NASM
-TEMPLATE_VBoxBS3KitImg64_ASFLAGS := -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
-TEMPLATE_VBoxBS3KitImg64_ASDEFS   = ASM_FORMAT_OMF RT_NOINC_SEGMENTS ARCH_BITS=64 __NASM__
-TEMPLATE_VBoxBS3KitImg64_ARTOOL   = OPENWATCOM
-TEMPLATE_VBoxBS3KitImg64_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
-TEMPLATE_VBoxBS3KitImg64_CTOOL    = VBoxBsUnusedLd
-TEMPLATE_VBoxBS3KitImg64_CXXTOOL  = VBoxBsUnusedLd
-TEMPLATE_VBoxBS3KitImg64_LDTOOL   = VBoxBsUnusedLd
+TEMPLATE_VBoxBS3KitImg64_BLD_TRG      = os-agnostic
+TEMPLATE_VBoxBS3KitImg64_BLD_TRG_ARCH = amd64
+TEMPLATE_VBoxBS3KitImg64_INSTTYPE     = none
+TEMPLATE_VBoxBS3KitImg64_ASTOOL       = NASM
+TEMPLATE_VBoxBS3KitImg64_ASFLAGS      = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels
+TEMPLATE_VBoxBS3KitImg64_ASDEFS       = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__
+TEMPLATE_VBoxBS3KitImg64_DEFS         = IN_BS3KIT ARCH_BITS=64
+TEMPLATE_VBoxBS3KitImg64_ARTOOL       = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg64_INCS         = $(VBOX_PATH_BS3KIT_SRC) .
+if1of ($(KBUILD_HOST), win)
+ TEMPLATE_VBoxBS3KitImg64_BLD_TYPE   := release# Must avoid debug info as it contains fixups not supported by the linker.
+ TEMPLATE_VBoxBS3KitImg64_CTOOL      := $(VBOX_VCC_TOOL_STEM)AMD64
+ TEMPLATE_VBoxBS3KitImg64_CXXTOOL    := $(VBOX_VCC_TOOL_STEM)AMD64
+ TEMPLATE_VBoxBS3KitImg64_CFLAGS      = -O1 -Oi -GF -GS- -Gy -Gs65536
+ TEMPLATE_VBoxBS3KitImg64_CXXFLAGS    = -O1 -Oi -GF -GS- -Gy -Gs65536
+else
+ TEMPLATE_VBoxBS3KitImg64_CTOOL      := $(VBOX_GCC_TOOL)
+ TEMPLATE_VBoxBS3KitImg64_CXXTOOL    := $(VBOX_GCC_TOOL)
+ TEMPLATE_VBoxBS3KitImg64_CFLAGS      = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_C)
+ TEMPLATE_VBoxBS3KitImg64_CXXFLAGS    = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_CXX)
+endif
+TEMPLATE_VBoxBS3KitImg64_LDTOOL       = VBoxBsUnusedLd
 
 # BS3Kit template for the bootsector.
 TEMPLATE_VBoxBS3KitBS = Template for building BS3Kit test images.
-TEMPLATE_VBoxBS3KitBS_INST     = $(INST_VALIDATIONKIT)bootsectors/
-TEMPLATE_VBoxBS3KitBS_INSTTYPE = none
-TEMPLATE_VBoxBS3KitBS_BINSUFF  = .img
-TEMPLATE_VBoxBS3KitBS_MODE     = 0644
-TEMPLATE_VBoxBS3KitBS_ASTOOL   = YASM
-TEMPLATE_VBoxBS3KitBS_ASFLAGS := -f bin --mapfile
-TEMPLATE_VBoxBS3KitBS_ASDEFS   = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__
-TEMPLATE_VBoxBS3KitBS_INCS     = $(VBOX_PATH_BS3KIT_SRC) .
-TEMPLATE_VBoxBS3KitBS_LDTOOL   = VBoxBsCpLd
+TEMPLATE_VBoxBS3KitBS_BLD_TRG         = os-agnostic
+TEMPLATE_VBoxBS3KitBS_BLD_TRG_ARCH    = x86
+TEMPLATE_VBoxBS3KitBS_INST            = $(INST_VALIDATIONKIT)bootsectors/
+TEMPLATE_VBoxBS3KitBS_INSTTYPE        = none
+TEMPLATE_VBoxBS3KitBS_BINSUFF         = .img
+TEMPLATE_VBoxBS3KitBS_MODE            = 0644
+TEMPLATE_VBoxBS3KitBS_ASTOOL          = YASM
+TEMPLATE_VBoxBS3KitBS_ASFLAGS         = -f bin --mapfile
+TEMPLATE_VBoxBS3KitBS_ASDEFS          = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__
+TEMPLATE_VBoxBS3KitBS_INCS            = $(VBOX_PATH_BS3KIT_SRC) .
+TEMPLATE_VBoxBS3KitBS_LDTOOL          = VBoxBsCpLd
 
 #
@@ -159,6 +194,9 @@
 # Common sources to be compiled into _p16, _p32 and _p64 versions.
 VBOX_BS3KIT_COMMON_SOURCES = \
-	bs3-cmn-shutdown.asm \
-	bs3-cmn-panic.asm
+	bs3-cmn-Shutdown.asm \
+	bs3-cmn-Panic.asm \
+	bs3-cmn-PrintU32.asm \
+       bs3-cmn-PrintStrColonSpaces.asm \
+       bs3-cmn-PrintStrSpacesColonSpace.c \
 
 # The BS3Kit library.
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm	(revision 58628)
@@ -0,0 +1,36 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3Panic, Common.
+;
+
+;
+; Copyright (C) 2007-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+BS3_PROC_BEGIN_CMN Bs3Panic
+        cli
+.panic_again:
+        hlt
+        jmp     .panic_again
+BS3_PROC_END_CMN   Bs3Panic
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm	(revision 58628)
@@ -0,0 +1,76 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3PrintStrColonSpaces, Common.
+;
+
+;
+; Copyright (C) 2007-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+BS3_EXTERN_CMN Bs3PrintStr
+BS3_EXTERN_CMN Bs3StrLen
+BS3_EXTERN_CMN Bs3PrintChr
+
+;; @todo If we can get 64-bit C code to link smoothly, this should be done in C!
+;;       It's really annoying unreadable stuff in multi-mode assembly.
+
+;;
+; Prints a 32-bit unsigned integer value.
+;
+; @param    [xSP + xCB+sCB] The desired minimum length of the output. That is
+;                           string + colon + spaces.
+; @param    [xSP + xCB]     The string to print.
+
+BS3_PROC_BEGIN_CMN Bs3PrintStrColonSpaces
+        BS3_CALL_CONV_PROLOG 2
+        push    xBP
+        mov     xBP, xSP
+        push    xAX
+        push    xDI
+        sub     esp, 20h
+
+        mov     sAX, [xBP + xCB*2]
+        mov     [xBP - 20h], sAX
+        BS3_CALL Bs3PrintStr, 1
+
+        mov     sAX, [xBP + xCB*2]
+        mov     [xBP - 20h], sAX
+        BS3_CALL Bs3StrLen, 1
+        mov     di, ax
+        mov     byte [xBP - 20h], ':'
+        BS3_CALL Bs3PrintChr, 1
+        inc     di
+.next_space:
+        mov     byte [xBP - 20h], ' '
+        BS3_CALL Bs3PrintChr, 1
+        inc     di
+        cmp     di, word [xBP + xCB*2 + sCB]
+        jb      .next_space
+
+        pop     xDI
+        pop     xAX
+        leave
+        BS3_CALL_CONV_EPILOG 2
+        ret
+BS3_PROC_END_CMN   Bs3PrintStrColonSpaces
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrSpacesColonSpace.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrSpacesColonSpace.c	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrSpacesColonSpace.c	(revision 58628)
@@ -0,0 +1,16 @@
+
+
+#include "bs3kit.h"
+
+
+BS3_DECL(void) BS3_CMN_NM(Bs3PrintStrSpacesColonSpace)(const char BS3_FAR *pszString, unsigned cch)
+{
+    static volatile char s_szStuff[] = "stuff";
+    static volatile const char s_szStuff2[] = "stuff";
+    //size_t cchString;
+
+    //Bs3PrintStr(pszString);
+
+    s_szStuff[0] = s_szStuff2[0];
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm	(revision 58628)
@@ -0,0 +1,78 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3PrintU32, Common.
+;
+
+;
+; Copyright (C) 2007-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+BS3_EXTERN_CMN Bs3PrintStr
+
+;;
+; Prints a 32-bit unsigned integer value.
+;
+; @param    [xSP + xCB]     32-bit value to format and print.
+;
+BS3_PROC_BEGIN_CMN Bs3PrintU32
+        BS3_CALL_CONV_PROLOG 1
+        push    xBP
+        mov     xBP, xSP
+        push    sAX
+        push    sDX
+        push    sCX
+        push    sBX
+
+        mov     eax, [xBP + xCB*2]
+
+        ; Allocate a stack buffer and terminate it. ds:bx points ot the end.
+        sub     xSP, 30h
+        mov     xBX, xSP
+        add     xBX, 2fh
+        mov     byte [xBX], 0
+
+        mov     ecx, 10                 ; what to divide by
+.next:
+        xor     edx, edx
+        div     ecx                     ; edx:eax / ecx -> eax and rest in edx.
+        add     dl, '0'
+        dec     xBX
+        mov     [BS3_ONLY_16BIT(ss:)xBX], dl
+        cmp     eax, 0
+        jnz     .next
+
+        ; Print the string.
+        BS3_ONLY_16BIT_STMT push    ss
+        push    xBX
+        call    Bs3PrintStr
+
+        add     xSP, 30h + BS3_ONLY_16BIT(2 + ) xCB
+        pop     sBX
+        pop     sCX
+        pop     sDX
+        pop     sAX
+        leave
+        BS3_CALL_CONV_EPILOG 1
+        ret
+BS3_PROC_END_CMN   Bs3PrintU32
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm	(revision 58628)
@@ -0,0 +1,50 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3Shutdown
+;
+
+;
+; Copyright (C) 2007-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "bs3kit-template-header.mac"
+
+BS3_EXTERN_CMN Bs3Panic
+
+BS3_PROC_BEGIN_CMN Bs3Shutdown
+        cli
+        mov     bl, 64
+        mov     dx, 08900h
+%ifdef TMPL_16BIT
+        mov     ax, cs
+        mov     ds, ax
+%endif
+.retry:
+        mov     ecx, 8
+        mov     esi, .s_szShutdown
+        rep outsb
+        dec     bl
+        jnz     .retry
+        ; Shutdown failed!
+        jmp     Bs3Panic
+.s_szShutdown:
+        db      'Shutdown', 0
+BS3_PROC_END_CMN Bs3Shutdown
+
Index: unk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-panic.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-panic.asm	(revision 58627)
+++ 	(revision )
@@ -1,36 +1,0 @@
-; $Id$
-;; @file
-; BS3Kit - Bs3Panic, Common.
-;
-
-;
-; Copyright (C) 2007-2015 Oracle Corporation
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; The contents of this file may alternatively be used under the terms
-; of the Common Development and Distribution License Version 1.0
-; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
-; VirtualBox OSE distribution, in which case the provisions of the
-; CDDL are applicable instead of those of the GPL.
-;
-; You may elect to license modified versions of this file under the
-; terms and conditions of either the GPL or the CDDL or both.
-;
-
-%include "bs3kit-template-header.mac"
-
-
-BEGINPROC TMPL_CMN_NM(Bs3Panic)
-        cli
-.panic_again:
-        hlt
-        jmp     .panic_again
-ENDPROC TMPL_CMN_NM(Bs3Panic)
-
Index: unk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-shutdown.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-shutdown.asm	(revision 58627)
+++ 	(revision )
@@ -1,50 +1,0 @@
-; $Id$
-;; @file
-; BS3Kit - Bs3Shutdown
-;
-
-;
-; Copyright (C) 2007-2015 Oracle Corporation
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; The contents of this file may alternatively be used under the terms
-; of the Common Development and Distribution License Version 1.0
-; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
-; VirtualBox OSE distribution, in which case the provisions of the
-; CDDL are applicable instead of those of the GPL.
-;
-; You may elect to license modified versions of this file under the
-; terms and conditions of either the GPL or the CDDL or both.
-;
-
-%include "bs3kit-template-header.mac"
-
-EXTERN_CMN_NM Bs3Panic
-
-BEGINPROC TMPL_CMN_NM(Bs3Shutdown)
-        cli
-        mov     bl, 64
-        mov     dx, 08900h
-%ifdef TMPL_16BIT
-        mov     ax, cs
-        mov     ds, ax
-%endif
-.retry:
-        mov     ecx, 8
-        mov     esi, .s_szShutdown
-        rep outsb
-        dec     bl
-        jnz     .retry
-        ; Shutdown failed!
-        jmp     Bs3Panic
-.s_szShutdown:
-        db      'Shutdown', 0
-ENDPROC TMPL_CMN_NM(Bs3Shutdown)
-
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm	(revision 58628)
@@ -47,6 +47,9 @@
 ;*********************************************************************************************************************************
 BS3_BEGIN_TEXT16
-extern NAME(Bs3Shutdown_p16)
+extern BS3_CMN_NM(Bs3Shutdown)
 extern NAME(Main_rm)
+extern _Bs3PrintStrSpacesColonSpace_c16
+extern _Bs3PrintStrSpacesColonSpace_c32
+extern Bs3PrintStrSpacesColonSpace_c64
 
 
@@ -55,5 +58,4 @@
 ;
 BS3_BEGIN_TEXT16
-BITS 16
 GLOBALNAME start
     mov     ax, BS3DATA16
@@ -61,4 +63,4 @@
     mov     ds, ax
     call    NAME(Main_rm)
-    call    NAME(Bs3Shutdown_p16)
+    call    BS3_CMN_NM(Bs3Shutdown)
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c	(revision 58628)
@@ -1,8 +1,15 @@
+
+#include "bs3kit.h"
+#include <iprt/assert.h>
+
+AssertCompileSize(uint16_t, 2);
+AssertCompileSize(uint32_t, 4);
+AssertCompileSize(uint64_t, 8);
+
 
 /* Just a sample. */
 void Main_rm(void)
 {
-//    for (;;)
-//        { }
+    Bs3Shutdown();
     return;
 }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.h	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.h	(revision 58628)
@@ -0,0 +1,66 @@
+/* $Id$ */
+/** @file
+ * BS3Kit footer for multi-mode code templates.
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*
+ * Undefine macros defined by the header.
+ * This is a subset of what bs3kit-template-footer.mac does.
+ */
+#undef TMPL_RM
+#undef TMPL_PE16
+#undef TMPL_PE32
+#undef TMPL_PEV86
+#undef TMPL_PP16
+#undef TMPL_PP32
+#undef TMPL_PPV86
+#undef TMPL_PAE16
+#undef TMPL_PAE32
+#undef TMPL_PAEV86
+#undef TMPL_LM16
+#undef TMPL_LM32
+#undef TMPL_LM64
+
+#undef TMPL_CMN_PE
+#undef TMPL_CMN_PP
+#undef TMPL_CMN_PAE
+#undef TMPL_CMN_LM
+#undef TMPL_CMN_V86
+
+#undef TMPL_CMN_P16
+#undef TMPL_CMN_P32
+#undef TMPL_CMN_P64
+#undef TMPL_CMN_R16
+#undef TMPL_CMN_R86
+
+#undef TMPL_NM
+#undef TMPL_NM_CMN
+#undef TMPL_MODE
+#undef TMPL_MODE_STR
+#undef TMPL_16BIT
+#undef TMPL_32BIT
+#undef TMPL_64BIT
+#undef TMPL_BITS
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 58628)
@@ -67,5 +67,5 @@
 
 %undef TMPL_NM
-%undef TMPL_NM_CMN
+%undef BS3_CMN_NM
 %undef TMPL_MODE
 %undef TMPL_MODE_STR
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h	(revision 58628)
@@ -0,0 +1,764 @@
+/* $Id$ */
+/** @file
+ * BS3Kit header for multi-mode code templates.
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#include "bs3kit.mac"
+
+/** @defgroup grp_bs3kit_tmpl       BS3Kit Multi-Mode Code Templates
+ * @ingroup grp_bs3kit
+ *
+ * Multi-mode code templates avoid duplicating code for each of the CPU modes.
+ * Instead the code is compiled multiple times, either via multiple inclusions
+ * into a source files with different mode selectors defined or by multiple
+ * compiler invocations.
+ *
+ * In C/C++ code we're restricted to the compiler target bit count, whereas in
+ * assembly we can do everything in assembler run (with some 64-bit
+ * restrictions, that is).
+ *
+ * Before \#defining the next mode selector and including
+ * bs3kit-template-header.h again, include bs3kit-template-footer.h to undefine
+ * all the previous mode selectors and the macros defined by the header.
+ *
+ * @{
+ */
+
+#ifdef DOXYGEN_RUNNING
+/** @name Template mode selectors.
+ *
+ * Exactly one of these are defined by the file including the
+ * bs3kit-template-header.h header file.  When building the code libraries, the
+ * kBuild target defines this.
+ *
+ * @{ */
+# define TMPL_RM     /**< real mode. */
+# define TMPL_PE16   /**< 16-bit protected mode, unpaged. */
+# define TMPL_PE32   /**< 32-bit protected mode, unpaged. */
+# define TMPL_PEV86  /**< virtual 8086 mode under protected mode, unpaged. */
+# define TMPL_PP16   /**< 16-bit protected mode, paged. */
+# define TMPL_PP32   /**< 32-bit protected mode, paged. */
+# define TMPL_PPV86  /**< virtual 8086 mode under protected mode, paged. */
+# define TMPL_PAE16  /**< 16-bit protected mode with PAE (paged). */
+# define TMPL_PAE32  /**< 16-bit protected mode with PAE (paged). */
+# define TMPL_PAEV86 /**< virtual 8086 mode under protected mode with PAE (paged). */
+# define TMPL_LM16   /**< 16-bit long mode (paged). */
+# define TMPL_LM32   /**< 32-bit long mode (paged). */
+# define TMPL_LM64   /**< 64-bit long mode (paged). */
+/** @} */
+
+/** @name Derived Indicators
+ * @{ */
+# define TMPL_CMN_PE    /**< TMPL_PE16  | TMPL_PE32  | TMPL_PEV86  */
+# define TMPL_CMN_PP    /**< TMPL_PP16  | TMPL_PP32  | TMPL_PPV86  */
+# define TMPL_CMN_PAE   /**< TMPL_PAE16 | TMPL_PAE32 | TMPL_PAEV86 */
+# define TMPL_CMN_LM    /**< TMPL_LM16  | TMPL_LM32  | TMPL_LM64   */
+# define TMPL_CMN_V86   /**< TMPL_PEV86 | TMPL_PPV86 | TMPL_PAEV86 */
+# define TMPL_CMN_R86   /**< TMPL_CMN_V86 | TMPL_RM                */
+/** @} */
+
+/** @def TMPL_NM
+ * Name mangling macro for the current mode.
+ *
+ * Example: TMPL_NM(PrintChr)
+ *
+ * @param   Name        The function or variable name to mangle.
+ */
+# define TMPL_NM(Name)  RT_CONCAT(Name,_mode)
+
+/** @def TMPL_MODE_STR
+ * Short mode description. */
+# define TMPL_MODE_STR
+
+/** @def TMPL_HAVE_BIOS
+ * Indicates that we have direct access to the BIOS (only in real mode). */
+# define TMPL_HAVE_BIOS
+
+
+/** @name For ASM compatability
+ * @{ */
+/** @def TMPL_16BIT
+ * For ASM compatibility - please use ARCH_BITS == 16. */
+# define TMPL_16BIT
+/** @def TMPL_32BIT
+ * For ASM compatibility - please use ARCH_BITS == 32. */
+# define TMPL_32BIT
+/** @def TMPL_64BIT
+ * For ASM compatibility - please use ARCH_BITS == 64. */
+# define TMPL_64BIT
+
+/** @def TMPL_BITS
+ * For ASM compatibility - please use ARCH_BITS instead. */
+# define TMPL_BITS  ARCH_BITS
+/** @} */
+
+#else /* !DOXYGEN_RUNNING */
+
+#ifdef TMPL_RM
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_RM' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_RM' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_RM' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_RM' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_RM' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_RM' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_RM' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_RM' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_RM' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_RM' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_RM' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_RM requires ARCH_BITS to be 16."
+# endif
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_rm)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "real mode"
+# define TMPL_HAVE_BIOS
+# define TMPL_CMN_R86
+#endif
+
+#ifdef TMPL_PE16
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PE16' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PE16' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_RM' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PE16' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PE16' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PE16' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PE16' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PE16' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PE32' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PE16' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PE16' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PE16' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PE16 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PE
+# define TMPL_CMN_P16
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pe16)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "16-bit unpaged protected mode"
+#endif
+
+#ifdef TMPL_PE32
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PE32' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PE32' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PE32' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PE32' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PE32' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PE32' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PE32' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAE86
+#  error "Both 'TMPL_PE32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PE32' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PE32' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PE32' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 32
+#  error "TMPL_PE32 requires ARCH_BITS to be 32."
+# endif
+# define TMPL_CMN_PE
+# define TMPL_CMN_P32
+# define TMPL_32BIT
+# define TMPL_BITS              32
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pe32)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+# define TMPL_MODE_STR          "32-bit unpaged protected mode"
+#endif
+
+#ifdef TMPL_PEV86
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PEV86' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PEV86' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PEV86' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PEV86' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PEV86' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PEV86' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAE86
+#  error "Both 'TMPL_PEV86' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PEV86' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PEV86' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PEV86' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PEV86 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PE
+# define TMPL_CMN_V86
+# define TMPL_CMN_R86
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pev86)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "v8086 unpaged protected mode"
+#endif
+
+#ifdef TMPL_PP16
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PP16' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PP16' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PP16' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PP16' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PP16' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PP16' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PP16' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PP16' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PP16' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PP16' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PP16' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PP16 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PP
+# define TMPL_CMN_P16
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pp16)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "16-bit paged protected mode"
+#endif
+
+#ifdef TMPL_PP32
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PP32' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PP32' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PP32' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PP32' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PP32' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PP32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PP32' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PP32' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PP32' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PP32' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PP32' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PP32' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 32
+#  error "TMPL_PP32 requires ARCH_BITS to be 32."
+# endif
+# define TMPL_CMN_PP
+# define TMPL_CMN_P32
+# define TMPL_32BIT
+# define TMPL_BITS              32
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pp32)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+# define TMPL_MODE_STR          "32-bit paged protected mode"
+#endif
+
+#ifdef TMPL_PPV86
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PPV86' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PPV86' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PPV86' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PPV86' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PPV86' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PPV86' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PPV86' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PPV86' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PPV86' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PPV86' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PPV86' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PPV86' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PPV86 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PP
+# define TMPL_CMN_V86
+# define TMPL_CMN_R86
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_ppv86)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
+# define TMPL_MODE_STR          "v8086 paged protected mode"
+#endif
+
+#ifdef TMPL_PAE16
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PAE16' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PAE16' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PAE16' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PAE16' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PAE16' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PAE16' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PAE16' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_PAE16' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PAE16' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PAE16' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PAE16' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PAE16' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PAE16 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PAE
+# define TMPL_16BIT
+# define TMPL_CMN_P16
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pae16)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "16-bit pae protected mode"
+#endif
+
+#ifdef TMPL_PAE32
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PAE32' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PAE32' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PAE32' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PAE32' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PAE32' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PAE32' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PAE32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PAE32' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PAE32' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PAE32' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PAE32' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PAE32' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 32
+#  error "TMPL_PAE32 requires ARCH_BITS to be 32."
+# endif
+# define TMPL_CMN_PAE
+# define TMPL_CMN_P32
+# define TMPL_32BIT
+# define TMPL_BITS              32
+# define TMPL_NM(Name)          RT_CONCAT(Name,_pae32)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+# define TMPL_MODE_STR          "32-bit pae protected mode"
+#endif
+
+#ifdef TMPL_PAEV86
+# ifdef TMPL_RM
+#  error "Both 'TMPL_PAEV86' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_PAEV86' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_PAEV86' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_PAEV86' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_PAEV86' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_PAEV86 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_PAE
+# define TMPL_CMN_V86
+# define TMPL_CMN_R86
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_paev86)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c86)
+# define TMPL_MODE_STR          "v8086 pae protected mode"
+#endif
+
+#ifdef TMPL_LM16
+# ifdef TMPL_RM
+#  error "Both 'TMPL_LM16' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_LM16' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_LM16' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_LM16' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_LM16' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_LM16' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_LM16' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_LM16' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_LM16' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_LM16' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_LM16' and 'TMPL_LM32' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_LM16' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 16
+#  error "TMPL_LM16 requires ARCH_BITS to be 16."
+# endif
+# define TMPL_CMN_LM
+# define TMPL_CMN_P16
+# define TMPL_16BIT
+# define TMPL_BITS              16
+# define TMPL_NM(Name)          RT_CONCAT(Name,_lm16)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+# define TMPL_MODE_STR          "16-bit long mode"
+#endif
+
+#ifdef TMPL_LM32
+# ifdef TMPL_RM
+#  error "Both 'TMPL_LM32' and 'TMPL_RM' are defined."
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_LM32' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_LM32' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_LM32' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_LM32' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_LM32' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_LM32' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_LM32' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_LM32' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_LM32' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_LM32' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM64
+#  error "Both 'TMPL_LM32' and 'TMPL_LM64' are defined."
+# endif
+# if ARCH_BITS != 32
+#  error "TMPL_LM32 requires ARCH_BITS to be 32."
+# endif
+# define TMPL_CMN_LM
+# define TMPL_CMN_P32
+# define TMPL_32BIT
+# define TMPL_BITS              32
+# define TMPL_NM(Name)          RT_CONCAT(Name,_lm32)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+# define TMPL_MODE_STR          "32-bit long mode"
+#endif
+
+#ifdef TMPL_LM64
+# ifdef TMPL_RM
+#  error ""Both 'TMPL_LM64' and 'TMPL_RM' are defined.""
+# endif
+# ifdef TMPL_PE16
+#  error "Both 'TMPL_LM64' and 'TMPL_PE16' are defined."
+# endif
+# ifdef TMPL_PE32
+#  error "Both 'TMPL_LM64' and 'TMPL_PE32' are defined."
+# endif
+# ifdef TMPL_PEV86
+#  error "Both 'TMPL_LM64' and 'TMPL_PEV86' are defined."
+# endif
+# ifdef TMPL_PP16
+#  error "Both 'TMPL_LM64' and 'TMPL_PP16' are defined."
+# endif
+# ifdef TMPL_PP32
+#  error "Both 'TMPL_LM64' and 'TMPL_PP32' are defined."
+# endif
+# ifdef TMPL_PPV86
+#  error "Both 'TMPL_LM64' and 'TMPL_PPV86' are defined."
+# endif
+# ifdef TMPL_PAE16
+#  error "Both 'TMPL_LM64' and 'TMPL_PAE16' are defined."
+# endif
+# ifdef TMPL_PAE32
+#  error "Both 'TMPL_LM64' and 'TMPL_PAE32' are defined."
+# endif
+# ifdef TMPL_PAEV86
+#  error "Both 'TMPL_LM64' and 'TMPL_PAEV86' are defined."
+# endif
+# ifdef TMPL_LM16
+#  error "Both 'TMPL_LM64' and 'TMPL_LM16' are defined."
+# endif
+# ifdef TMPL_LM32
+#  error "Both 'TMPL_LM64' and 'TMPL_LM32' are defined."
+# endif
+# if ARCH_BITS != 64
+#  error "TMPL_LM64 requires ARCH_BITS to be 64."
+# endif
+# define TMPL_CMN_LM
+# define TMPL_CMN_P64
+# define TMPL_64BIT
+# define TMPL_BITS              64
+# define TMPL_NM(Name)          RT_CONCAT(Name,_lm64)
+# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
+# define TMPL_MODE_STR          "64-bit long mode"
+#endif
+
+#ifndef TMPL_MODE_STR
+# error "internal error"
+#endif
+
+#endif /* !DOXYGEN_RUNNING */
+/** @} */
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 58628)
@@ -92,6 +92,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _rm
- %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %define TMPL_NM(Name)          _ %+ Name %+ _rm
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          'real mode'
  %define TMPL_HAVE_BIOS
@@ -141,6 +141,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _pe16
- %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %define TMPL_NM(Name)          _ %+ Name %+ _pe16
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          '16-bit unpaged protected mode'
 %endif
@@ -188,6 +188,6 @@
  %define TMPL_BITS              32
  %define TMPL_PTR_DEF           dd
- %define TMPL_NM(Name)          Name %+ _pe32
- %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %define TMPL_NM(Name)          _ %+ Name %+ _pe32
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
  %define TMPL_MODE_STR          '32-bit unpaged protected mode'
 %endif
@@ -236,6 +236,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _pev86
- %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %define TMPL_NM(Name)          _ %+ Name %+ _pev86
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          'v8086 unpaged protected mode'
 %endif
@@ -283,6 +283,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _pp16
- %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %define TMPL_NM(Name)          _ %+ Name %+ _pp16
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          '16-bit paged protected mode'
 %endif
@@ -330,6 +330,6 @@
  %define TMPL_BITS              32
  %define TMPL_PTR_DEF           dd
- %define TMPL_NM(Name)          Name %+ _pp32
- %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %define TMPL_NM(Name)          _ %+ Name %+ _pp32
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
  %define TMPL_MODE_STR          '32-bit paged protected mode'
 %endif
@@ -379,5 +379,5 @@
  %define TMPL_PTR_DEF           dw
  %define TMPL_NM(Name)          Name %+ _ppv86
- %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %define BS3_CMN_NM(Name)       Name %+ _c86
  %define TMPL_MODE_STR          'v8086 paged protected mode'
 %endif
@@ -425,6 +425,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _pae16
- %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %define TMPL_NM(Name)          _ %+ Name %+ _pae16
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          '16-bit pae protected mode'
 %endif
@@ -472,6 +472,6 @@
  %define TMPL_BITS              32
  %define TMPL_PTR_DEF           dd
- %define TMPL_NM(Name)          Name %+ _pae32
- %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %define TMPL_NM(Name)          _ %+ Name %+ _pae32
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
  %define TMPL_MODE_STR          '32-bit pae protected mode'
 %endif
@@ -520,6 +520,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _paev86
- %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %define TMPL_NM(Name)          _ %+ Name %+ _paev86
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
  %define TMPL_MODE_STR          'v8086 pae protected mode'
 %endif
@@ -567,6 +567,6 @@
  %define TMPL_BITS              16
  %define TMPL_PTR_DEF           dw
- %define TMPL_NM(Name)          Name %+ _lm16
- %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %define TMPL_NM(Name)          _ %+ Name %+ _lm16
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
  %define TMPL_MODE_STR          '16-bit long mode'
 %endif
@@ -614,6 +614,6 @@
  %define TMPL_BITS              32
  %define TMPL_PTR_DEF           dd
- %define TMPL_NM(Name)          Name %+ _lm32
- %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %define TMPL_NM(Name)          _ %+ Name %+ _lm32
+ %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
  %define TMPL_MODE_STR          '32-bit long mode'
 %endif
@@ -661,6 +661,6 @@
  %define TMPL_BITS              64
  %define TMPL_PTR_DEF           dq
- %define TMPL_NM(Name)          Name %+ _lm64
- %define TMPL_NM_CMN(Name)      Name %+ _p64
+ %define TMPL_NM(Name)          Name %+ _lm64   ; No underscore (C/C++ compatibility).
+ %define BS3_CMN_NM(Name)       Name %+ _c64    ; No underscore (C/C++ compatibility).
  %define TMPL_MODE_STR          '64-bit long mode'
 %endif
@@ -669,10 +669,4 @@
  %error "internal error"
 %endif
-
-
-;
-; Preferred spelling of TMPL_NM_CMN in BS3.
-;
-%define TMPL_CMN_NM(Name)      TMPL_NM_CMN(Name)
 
 
@@ -735,4 +729,5 @@
 %endif
 
+
 ;
 ; Register names corresponding to the max size for pop/push <reg>.
@@ -774,5 +769,5 @@
 
 ;
-; Default code segment.
+; Default code segment (changes BITS too).
 ;
 %ifdef TMPL_64BIT
@@ -787,15 +782,3 @@
 TMPL_BEGIN_TEXT
 
-;
-; Change the bitness.
-;
-%ifdef TMPL_64BIT
-BITS 64
-%else
- %ifdef TMPL_32BIT
-BITS 32
- %else
-BITS 16
- %endif
-%endif
-
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58628)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58628)
@@ -0,0 +1,151 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - structures, symbols, macros and stuff.
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___bs3kit_h
+#define ___bs3kit_h
+
+#ifndef DOXYGEN_RUNNING
+# define IN_RING0
+#endif
+#include <iprt/cdefs.h>
+#include <iprt/types.h>
+#ifndef DOXYGEN_RUNNING
+# undef  IN_RING0
+#endif
+
+
+/** @defgroup grp_bs3kit     BS3Kit
+ * @{ */
+
+/** @def BS3_FAR
+ * For inidicating far pointers in 16-bit code.
+ * Does nothing in 32-bit and 64-bit code. */
+/** @def BS3_NEAR
+ * For inidicating near pointers in 16-bit code.
+ * Does nothing in 32-bit and 64-bit code. */
+#ifdef M_I86
+# define BS3_FAR            __far
+# define BS3_NEAR           __near
+#else
+# define BS3_FAR
+# define BS3_NEAR
+#endif
+
+/** @def BS3_CALL
+ * The calling convension used by BS3 functions.  */
+#if ARCH_BITS != 64
+# define BS3_CALL           __cdecl
+#elif !defined(_MSC_VER)
+# define BS3_CALL           __attribute__((__ms_abi__))
+#else
+# define BS3_CALL
+#endif
+
+/** @def IN_BS3KIT
+ * Indicates that we're in the same link job as the BS3Kit code. */
+#ifdef DOXYGEN_RUNNING
+# define IN_BS3KIT
+#endif
+
+/** @def BS3_DECL
+ * Declares a BS3Kit function.
+ * @param a_Type        The return type. */
+#ifdef IN_BS3KIT
+# define BS3_DECL(a_Type)   DECLEXPORT(a_Type) BS3_CALL
+#else
+# define BS3_DECL(a_Type)   DECLIMPORT(a_Type) BS3_CALL
+#endif
+
+/**
+ * Constructs a common name.
+ *
+ * Example: BS3_CMN_NM(Bs3Shutdown)
+ *
+ * @param   a_Name      The name of the function or global variable.
+ */
+#define BS3_CMN_NM(a_Name)  RT_CONCAT3(a_Name,_c,ARCH_BITS)
+
+
+
+/** @defgroup grp_bs3kit_cmn    Common Functions and Data
+ *
+ * The common functions comes in three variations: 16-bit, 32-bit and 64-bit.
+ * Templated code uses the #BS3_CMN_NM macro to mangle the name according to the
+ * desired
+ *
+ * @{
+ */
+
+/**
+ * Panic, never return.
+ *
+ * The current implementation will only halt the CPU.
+ */
+BS3_DECL(void) Bs3Panic_c16(void);
+BS3_DECL(void) Bs3Panic_c32(void);              /**< @copydoc Bs3Panic_c16  */
+BS3_DECL(void) Bs3Panic_c64(void);              /**< @copydoc Bs3Panic_c16  */
+#define Bs3Panic BS3_CMN_NM(Bs3Panic)           /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
+
+/**
+ * Shutdown the system, never returns.
+ *
+ * This currently only works for VMs.  When running on real systems it will
+ * just halt the CPU.
+ */
+BS3_DECL(void) Bs3Shutdown_c16(void);
+BS3_DECL(void) Bs3Shutdown_c32(void);           /**< @copydoc Bs3Shutdown_c16 */
+BS3_DECL(void) Bs3Shutdown_c64(void);           /**< @copydoc Bs3Shutdown_c16 */
+#define Bs3Shutdown BS3_CMN_NM(Bs3Shutdown)     /**< Selects #Bs3Shutdown_c16, #Bs3Shutdown_c32 or #Bs3Shutdown_c64. */
+
+/**
+ * Prints a 32-bit unsigned value as hex to the screen.
+ *
+ * @param   uValue      The 32-bit value.
+ */
+BS3_DECL(void) Bs3PrintU32_c16(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
+BS3_DECL(void) Bs3PrintU32_c32(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
+BS3_DECL(void) Bs3PrintU32_c64(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
+#define Bs3PrintU32 BS3_CMN_NM(Bs3PrintU32)      /**< Selects #Bs3PrintU32_c16, #Bs3PrintU32_c32 or #Bs3PrintU32_c64. */
+
+/** @} */
+
+
+
+/** @defgroup grp_bs3kit_mode   Mode Specific Functions and Data
+ *
+ * The mode specific functions come in bit count variations and CPU mode
+ * variations.  The bs3kit-template-header.h/mac defines the BS3_NM macro to
+ * mangle a function or variable name according to the target CPU mode.  In
+ * non-templated code, it's common to spell the name out in full.
+ *
+ * @{
+ */
+
+
+/** @} */
+
+#endif
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58627)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58628)
@@ -32,4 +32,92 @@
 ; If we don't do the latter we end up with an unused 'text' section.
 ;
+
+;; Wrapper around BITS.
+; Updates __BITS__ (built-in variable in nasm, we work it for yasm).
+; @param    %1      The CPU bit count: 16, 32 or 64
+; @remarks ARCH_BITS is not modified and will remain what it was on the
+;          assembler command line.
+%macro BS3_SET_BITS 1
+ BITS %1
+
+ %ifdef __YASM__
+  %undef  __BITS__
+  %define __BITS__ %1
+ %endif
+
+ %undef  BS3_NAME_UNDERSCORE
+ %if %1 == 64
+  %define BS3_NAME_UNDERSCORE
+ %else
+  %define BS3_NAME_UNDERSCORE _
+ %endif
+
+ %undef   BS3_ONLY_16BIT
+ %if %1 == 16
+  %define BS3_ONLY_16BIT(a_Expr)    a_Expr
+ %else
+  %define BS3_ONLY_16BIT(a_Expr)
+ %endif
+
+ %undef   BS3_WRT_RIP
+ %if %1 == 64
+  %define BS3_WRT_RIP               wrt rip
+ %else
+  %define BS3_WRT_RIP
+ %endif
+%endmacro
+
+;; Emulate the __BITS__ macro in NASM 2.0+. Follows BS3_SET_BITS.
+%ifdef __YASM__
+ %define __BITS__                   ARCH_BITS
+%endif
+
+;; Mostly internal macro. Follows BS3_SET_BITS.
+%if ARCH_BITS == 64
+ %define BS3_NAME_UNDERSCORE
+%else
+ %define BS3_NAME_UNDERSCORE        _
+%endif
+
+;; For RIP relative addressing in 64-bit mode and absolute addressing in
+; other modes. Follows BS3_SET_BITS.
+%if ARCH_BITS == 64
+ %define BS3_WRT_RIP                wrt rip
+%else
+ %define BS3_WRT_RIP
+%endif
+
+;; For segment overrides and stuff. Follows BS3_SET_BITS.
+%if ARCH_BITS == 16
+ %define BS3_ONLY_16BIT(a_Expr)     a_Expr
+%else
+ %define BS3_ONLY_16BIT(a_Expr)
+%endif
+
+;;
+; For instruction that should only be emitted in 16-bit mode. Follows BS3_SET_BITS.
+%macro BS3_ONLY_16BIT_STMT 1+
+ %if __BITS__ == 16
+        %1
+ %endif
+%endmacro
+
+;;
+; For instruction that should only be emitted in 32-bit mode. Follows BS3_SET_BITS.
+%macro BS3_ONLY_32BIT_STMT 1+
+ %if __BITS__ == 32
+        %1
+ %endif
+%endmacro
+
+;;
+; For instruction that should only be emitted in 64-bit mode. Follows BS3_SET_BITS.
+%macro BS3_ONLY_64BIT_STMT 1+
+ %if __BITS__ == 64
+        %1
+ %endif
+%endmacro
+
+
 
 ;; @name Segment definitions.
@@ -41,5 +129,5 @@
         section BS3TEXT16 align=1 progbits alloc exec nowrite
   %else
-        section BS3TEXT16 align=1 CLASS=CODE16 PUBLIC USE16
+        section BS3TEXT16 align=1 CLASS=BS3CODE16 PUBLIC USE16
   %endif
 
@@ -47,4 +135,5 @@
         section BS3TEXT16
  %endif
+        BS3_SET_BITS 16
 %endmacro
 
@@ -60,4 +149,5 @@
         section BS3DATA16
  %endif
+        BS3_SET_BITS 16
 %endmacro
 
@@ -68,9 +158,10 @@
         section BS3TEXT32 align=1 progbits alloc exec nowrite
   %else
-        section BS3TEXT32 align=1 CLASS=CODE32 PUBLIC USE32
+        section BS3TEXT32 align=1 CLASS=BS3CODE32 PUBLIC USE32
   %endif
  %else
         section BS3TEXT32
  %endif
+        BS3_SET_BITS 32
 %endmacro
 
@@ -81,9 +172,10 @@
         section BS3DATA32 align=16 progbits alloc noexec write
   %else
-        section BS3DATA32 align=16 CLASS=DATA32 PUBLIC USE32
+        section BS3DATA32 align=16 CLASS=FAR_DATA PUBLIC USE32
   %endif
  %else
         section BS3DATA32
  %endif
+        BS3_SET_BITS 32
 %endmacro
 
@@ -94,9 +186,10 @@
         section BS3TEXT64 align=1 progbits alloc exec nowrite
   %else
-        section BS3TEXT64 align=1 CLASS=CODE64 PUBLIC USE32
+        section BS3TEXT64 align=1 CLASS=CODE PUBLIC USE32       ; class=CODE here because of 64-bit cl and/or wlink.exe
   %endif
  %else
         section BS3TEXT64
  %endif
+        BS3_SET_BITS 64
 %endmacro
 
@@ -107,9 +200,10 @@
         section BS3DATA64 align=16 progbits alloc noexec write
   %else
-        section BS3DATA64 align=16 CLASS=DATA64 PUBLIC USE32
+        section BS3DATA64 align=16 CLASS=DATA PUBLIC USE32      ; class=DATA here because of 64-bit cl and/or wlink.exe
   %endif
  %else
         section BS3DATA64
  %endif
+        BS3_SET_BITS 64
 %endmacro
 
@@ -156,5 +250,5 @@
 
 ;;
-; Extern macro which mangles the name correctly.
+; Extern macro which mangles the name using NAME().
 %macro EXTERN 1
  extern NAME(%1)
@@ -162,24 +256,185 @@
 
 ;;
+; Mangles a common name according to the current cpu bit count.
+; @remarks Requires the use of the BS3_SET_BITS macro instead of the BITS directive.
+%define BS3_CMN_NM(a_Name)     BS3_NAME_UNDERSCORE %+ a_Name %+ _c %+ __BITS__
+
+;;
 ; Extern macro which mangles the common name correctly, redefining the unmangled
 ; name with to the mangled one for ease of use.
-%macro EXTERN_CMN_NM 1
- %ifdef TMPL_64BIT
-  extern NAME(%1 %+ _p64)
-  %define %1 NAME(%1 %+ _p64)
-
- %elifdef TMPL_32BIT
-  extern NAME(%1 %+ _p32)
-  %define %1 NAME(%1 %+ _p32)
-
- %elifdef TMPL_16BIT
-  extern NAME(%1 %+ _p16)
-  %define %1 NAME(%1 %+ _p16)
-
- %else
-  %error "Missing TMPL_xxBIT!"
- %endif
-%endmacro
-
+;
+; @param    %1  The unmangled common name.
+;
+; @remarks  Must enter the segment in which this name is defined.
+;
+%macro BS3_EXTERN_CMN 1
+ extern BS3_CMN_NM(%1)
+ %undef  %1
+ %define %1 BS3_CMN_NM(%1)
+%endmacro
+
+;;
+; Global name with ELF attributes and size.
+;
+; This differs from GLOBALNAME_EX in that it expects a mangled symbol name,
+; and allows for nasm style symbol size expressions.
+;
+; @param    %1  The mangled name.
+; @param    %2  Symbol attributes.
+; @param    %3  The size expression.
+;
+%macro BS3_GLOBAL_NAME_EX 3
+%ifdef ASM_FORMAT_ELF
+ %ifdef __NASM__
+global %1:%2 %3
+ %else
+global %1:%2
+ %endif
+%else
+global %1
+%endif
+%1:
+%endmacro
+
+;;
+; Starts a procedure.
+;
+; This differs from BEGINPROC in that it expects a mangled symbol name and
+; does the NASM symbol size stuff.
+;
+; @param    %1      The mangled name.
+;
+%macro BS3_PROC_BEGIN 1
+BS3_GLOBAL_NAME_EX %1, function, (%1 %+ _EndProc - %1)
+%endmacro
+
+;;
+; Ends a procedure.
+;
+; Counter part to BS3_PROC_BEGIN.
+;
+; @param    %1      The mangled name.
+;
+%macro BS3_PROC_END  1
+BS3_GLOBAL_NAME_EX %1 %+ _EndProc, function hidden, (%1 %+ _EndProc - %1)
+ %ifdef ASM_FORMAT_ELF
+  %ifdef __YASM__
+size %1                 %1 %+ _EndProc - %1
+size %1 %+ _EndProc     0
+  %endif
+ %endif
+%endmacro
+
+;; Convenience macro for defining common procedures.
+%macro BS3_PROC_BEGIN_CMN 1
+ BS3_PROC_BEGIN     BS3_CMN_NM(%1)
+%endmacro
+
+;; Convenience macro for defining common procedures.
+%macro BS3_PROC_END_CMN 1
+ BS3_PROC_END       BS3_CMN_NM(%1)
+%endmacro
+
+;;
+; Prologue hacks for 64-bit code.
+;
+; This saves the four register parameters onto the stack so we can pretend
+; the calling convention is stack based.  The 64-bit calling convension is
+; the microsoft one, so this is straight forward.
+;
+; Pairs with BS3_CALL_CONV_EPILOG.
+;
+; @param    %1      The number of parameters.
+;
+; @remarks  Must be invoked before any stack changing instructions are emitted.
+;
+%macro BS3_CALL_CONV_PROLOG 1
+ %undef  BS3_CALL_CONV_PROLOG_PARAMS
+ %define BS3_CALL_CONV_PROLOG_PARAMS %1
+ %if __BITS__ == 64
+  %if %1 >= 1
+        mov         [rsp + 008h], rcx
+  %elifdef BS3_STRICT
+        and         qword [rsp + 008h], 1
+  %endif
+  %if %1 >= 2
+        mov         [rsp + 010h], rdx
+  %elifdef BS3_STRICT
+        and         qword [rsp + 010h], 2
+  %endif
+  %if %1 >= 3
+        mov         [rsp + 018h], r8
+  %elifdef BS3_STRICT
+        and         qword [rsp + 018h], 3
+  %endif
+  %if %1 >= 4
+        mov         [rsp + 020h], r9
+  %elifdef BS3_STRICT
+        and         qword [rsp + 020h], 4
+  %endif
+ %endif
+%endmacro
+
+;;
+; Epilogue hacks for 64-bit code.
+;
+; Counter part to BS3_CALL_CONV_PROLOG.
+;
+; @param    %1      The number of parameters.
+;
+; @remarks  Must be invoked right before the return instruction as it uses RSP.
+;
+%macro BS3_CALL_CONV_EPILOG 1
+ %if BS3_CALL_CONV_PROLOG_PARAMS != %1
+  %error "BS3_CALL_CONV_EPILOG argument differs from BS3_CALL_CONV_PROLOG."
+ %endif
+ %if __BITS__ == 64
+  %ifdef BS3_STRICT
+        mov         dword [rsp + 008h], 31h
+        mov         dword [rsp + 010h], 32h
+        mov         dword [rsp + 018h], 33h
+        mov         dword [rsp + 020h], 34h
+  %endif
+ %endif
+%endmacro
+
+;;
+; Wrapper for the call instruction that hides calling convension differences.
+;
+; This always calls %1.
+; In 64-bit code, it will load up to 4 parameters into register.
+;
+; @param    %1      The function to call (mangled).
+; @param    %2      The number of parameters.
+;
+%macro BS3_CALL 2
+ %if __BITS__ == 64
+  %if %2 >= 1
+        mov         rcx, [rsp + 008h]
+   %ifdef BS3_STRICT
+        and         qword [rsp + 008h], 11h
+   %endif
+  %endif
+  %if %2 >= 2
+        mov         rdx, [rsp + 010h]
+   %ifdef BS3_STRICT
+        and         qword [rsp + 010h], 12h
+   %endif
+  %endif
+  %if %2 >= 3
+        mov         r8,  [rsp + 018h]
+   %ifdef BS3_STRICT
+        and         qword [rsp + 018h], 13h
+   %endif
+  %endif
+  %if %2 >= 4
+        mov         r9,  [rsp + 020h]
+   %ifdef BS3_STRICT
+        and         qword [rsp + 020h], 14h
+   %endif
+  %endif
+ %endif
+        call        %1
+%endmacro
 
 
