Index: /trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk	(revision 58587)
+++ /trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk	(revision 58588)
@@ -187,4 +187,122 @@
 
 
+ifeq ($(USER),bird) # work in progress.
+
+#
+# BS3Kit
+#
+
+# Dummy CP "linker" tool.
+TOOL_VBoxBsCpLd = Dummy copy linker.
+TOOL_VBoxBsCpLd_LINK_MISCBIN_OUTPUT =
+TOOL_VBoxBsCpLd_LINK_MISCBIN_DEPEND =
+TOOL_VBoxBsCpLd_LINK_MISCBIN_DEPORD =
+define TOOL_VBoxBsCpLd_LINK_MISCBIN_CMDS
+	$(CP) -- $(objs) $(othersrc) "$(out)"
+endef
+
+# Dummy exit 1 "linker" tool.
+TOOL_VBoxBsUnusedLd = Dummy unused linker.
+TOOL_VBoxBsUnusedLd_LINK_MISCBIN_OUTPUT =
+TOOL_VBoxBsUnusedLd_LINK_MISCBIN_DEPEND =
+TOOL_VBoxBsUnusedLd_LINK_MISCBIN_DEPORD =
+define TOOL_VBoxBsUnusedLd_LINK_MISCBIN_CMDS
+	echo "cannot use this template for linking"
+	exit 1
+endef
+
+# 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 #-P $(PATH_SUB_CURRENT)/bootsector2-first.mac
+TEMPLATE_VBoxBS3KitImg_ASDEFS   = ASM_FORMAT_OMF __NASM__
+TEMPLATE_VBoxBS3KitImg_ARTOOL   = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CTOOL    = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CXXTOOL  = OPENWATCOM-16
+TEMPLATE_VBoxBS3KitImg_CFLAGS   = -nt=TEXT16 -nd=DATA16 -nc=CODE16
+TEMPLATE_VBoxBS3KitImg_CXXFLAGS = -nt=TEXT16 -nd=DATA16 -nc=CODE16
+TEMPLATE_VBoxBS3KitImg_INCS     = bs3kit .
+TEMPLATE_VBoxBS3KitImg_LDTOOL   = OPENWATCOM-WL
+TEMPLATE_VBoxBS3KitImg_LDFLAGS  = \
+ 	output raw offset=0x10000 \
+ 	order \
+ 	 clname CODE16 \
+ 	  segment TEXT16  segaddr=0x1000 \
+ 	 clname DATA16 \
+ 	  segment DATA16  segaddr=0x1000 \
+        clname CODE32 \
+ 	  segment TEXT32 \
+        clname DATA32 \
+ 	  segment DATA32
+
+# 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 -w+orphan-labels #-P $(PATH_SUB_CURRENT)/bootsector2-first.mac
+TEMPLATE_VBoxBS3KitImg32_ASDEFS   = ASM_FORMAT_OMF __NASM__
+TEMPLATE_VBoxBS3KitImg32_ARTOOL   = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CTOOL    = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CXXTOOL  = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg32_CFLAGS   = -nt=TEXT32 -nd=DATA32 -nc=CODE32
+TEMPLATE_VBoxBS3KitImg32_CXXFLAGS = -nt=TEXT32 -nd=DATA32 -nc=CODE32
+TEMPLATE_VBoxBS3KitImg32_INCS     = bs3kit .
+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 elf64 -g -w+orphan-labels #-P $(PATH_SUB_CURRENT)/bootsector2-first.mac
+TEMPLATE_VBoxBS3KitImg64_ASDEFS   = ASM_FORMAT_ELF __NASM__ TMPL
+TEMPLATE_VBoxBS3KitImg64_ARTOOL   = OPENWATCOM
+TEMPLATE_VBoxBS3KitImg64_CTOOL    = DUMMY
+TEMPLATE_VBoxBS3KitImg64_CXXTOOL  = DUMMY
+TEMPLATE_VBoxBS3KitImg64_INCS     = bs3kit .
+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 __YASM__
+TEMPLATE_VBoxBS3KitBS_INCS     = bs3kit
+TEMPLATE_VBoxBS3KitBS_LDTOOL   = VBoxBsCpLd
+
+# The boot sector.
+MISCBINS += bs3-bootsector
+bs3-bootsector_TEMPLATE = VBoxBS3KitBS
+bs3-bootsector_SOURCES  = bs3kit/bs3-bootsector.asm
+
+# The BS3Kit library.
+LIBRARIES += bs3kit-common-16
+bs3kit-common-16_TEMPLATE = VBoxBS3KitImg
+bs3kit-common-16_DEFS     = TMPL_PE16 BS3_CMN_ONLY
+bs3kit-common-16_SOURCES  = \
+	bs3kit/bs3-shutdown.asm
+
+# The 32-bit BS3Kit library.
+LIBRARIES += bs3kit-common-32
+bs3kit-common-32_TEMPLATE = VBoxBS3KitImg32
+bs3kit-common-32_DEFS     = TMPL_PE32 BS3_CMN_ONLY
+bs3kit-common-32_SOURCES  = \
+	bs3kit/bs3-shutdown.asm
+
+# The 64-bit BS3Kit library.
+LIBRARIES += bs3kit-common-64
+bs3kit-common-64_TEMPLATE = VBoxBS3KitImg64
+bs3kit-common-64_DEFS     = TMPL_LM64 BS3_CMN_ONLY
+bs3kit-common-64_SOURCES  = \
+	bs3kit/bs3-shutdown.asm
+
+endif # experimental
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm	(revision 58588)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm	(revision 58588)
@@ -0,0 +1,294 @@
+; $Id$
+;; @file
+; Generic bootsector for BS3.
+;
+; This sets up stack at %fff0 and loads the next sectors from the floppy at
+; %10000 (1000:0000 in real mode), then starts executing at cs:ip=1000:0000.
+;
+
+;
+; 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.
+;
+
+
+
+;*********************************************************************************************************************************
+;*      Header Files                                                                                                             *
+;*********************************************************************************************************************************
+%include "bs3kit.mac"
+%include "iprt/asmdefs.mac"
+%include "iprt/x86.mac"
+
+
+%ifdef __YASM__
+[map all]
+%endif
+
+;
+; Start with a jump just to follow the convention.
+; Also declare all segments/sections to establish them and their order.
+;
+        ORG 07c00h
+
+BITS 16
+start:
+        jmp short bs3InitCode
+        db 0ah                          ; Should be nop, but this looks better.
+g_OemId:                                ; 003h
+        db 'BS3Kit', 0ah
+
+;
+; DOS 4.0 Extended Bios Parameter Block:
+;
+g_cBytesPerSector:                      ; 00bh
+        dw 512
+g_cSectorsPerCluster:                   ; 00dh
+        db 1
+g_cReservedSectors:                     ; 00eh
+        dw 1
+g_cFATs:                                ; 010h
+        db 0
+g_cRootDirEntries:                      ; 011h
+        dw 0
+g_cTotalSectors:                        ; 013h
+        dw 0
+g_bMediaDescriptor:                     ; 015h
+        db 0
+g_cSectorsPerFAT:                       ; 016h
+        dw 0
+g_cPhysSectorsPerTrack:                 ; 018h
+        dw 18
+g_cHeads:                               ; 01ah
+        dw 2
+g_cHiddentSectors:                      ; 01ch
+        dd 1
+g_cLargeTotalSectors:                   ; 020h - We (ab)use this to indicate the number of sectors to load.
+        dd 0
+g_bBootDrv:                             ; 024h
+        db 80h
+g_bFlagsEtc:                            ; 025h
+        db 0
+g_bExtendedSignature:                   ; 026h
+        db 0x29
+g_dwSerialNumber:                       ; 027h
+        dd 0x0a458634
+g_abLabel:                              ; 02bh
+        db 'VirtualBox', 0ah
+g_abFSType:                             ; 036h
+        db 'RawCode', 0ah
+g_BpbEnd:                               ; 03ch
+
+
+;
+; Where to real init code starts.
+;
+bs3InitCode:
+        cli
+
+        ; save the registers.
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rax], eax
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rsp], esp
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rbp], ebp
+        mov     ax, ss
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.ss], ax
+        mov     ax, ds
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.ds], ax
+        mov     ax, es
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.es], ax
+        mov     ax, fs
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.fs], ax
+        mov     ax, gs
+
+        ; set up the segment reisters and stack.
+        xor     eax, eax
+        mov     ds, ax
+        mov     es, ax
+        mov     fs, ax
+        mov     gs, ax
+        mov     ss, ax
+        mov     esp, BS3_STACK_ADDR
+        mov     [esp],  eax             ; clear the first 16 bytes
+        mov     [esp + 04h],  eax
+        mov     [esp + 08h],  eax       ; fake rbp.
+        mov     [esp + 0ch],  eax       ; fake ebp and bp
+        mov     ebp, esp
+
+        ; Save more registers now that ds is known and the stack is usable.
+        pushfd
+        pop     eax
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rflags], eax
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rbx], ebx
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rcx], ecx
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rdx], edx
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rsi], esi
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.rdi], edi
+        mov     eax, cr2
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr2], eax
+        mov     eax, cr3
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr3], eax
+        mov     eax, cr4
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr4], eax
+        mov     byte [BS3_REG_SAVE_ADDR + BS3REGS.cBits], 16
+        xor     eax, eax
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.cs], ax
+        mov     ax, start
+        mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rip], eax
+
+        ; Make sure caching is enabled and alignment is off.
+        mov     eax, cr0
+        mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr0], eax
+        and     eax, ~(X86_CR0_NW | X86_CR0_CD | X86_CR0_AM)
+        mov     cr0, eax
+
+        ; Load all the code.
+        mov     [g_bBootDrv], dl
+        call    bs3InitLoadImage
+
+        ;
+        ; Call the user 'main' procedure (shouldn't return).
+        ;
+        call    1000h:0000h
+
+        ; Panic/hang.
+Bs3Panic:
+        cli
+        hlt
+        jmp     Bs3Panic
+
+
+
+;;
+; Loads the image off the floppy.
+;
+; This uses g_cLargeTotalSectors to figure out how much to load.
+;
+; Clobbers everything except ebp and esp.  Panics on failure.
+;
+; @param    dl          The boot drive number (from BIOS).
+; @uses     ax, cx, bx, esi, di
+;
+BEGINPROC bs3InitLoadImage
+        push    bp
+        mov     bp, sp
+        push    es
+%define bSavedDiskNo    byte [bp - 04h]
+        push    dx
+%define bMaxSector      byte [bp - 06h]
+        push    0
+%define bMaxHead        byte [bp - 08h]
+        push    0
+%define bMaxCylinder    byte [bp - 0ah]
+        push    0
+
+        ;
+        ; Try figure the geometry.
+        ;
+        mov     ah, 08h
+        int     13h
+        jc      .failure
+        mov     bMaxSector, cl
+        mov     bMaxHead, dh
+        mov     bMaxCylinder, ch
+        mov     dl, bSavedDiskNo
+
+        ;
+        ; Reload all the sectors one at a time (avoids problems).
+        ;
+        mov     esi, [g_cLargeTotalSectors]
+        dec     esi
+        mov     di, BS3_LOAD_ADDR / 16  ; The current load segment.
+        mov     cx, 0002h               ; ch/cylinder=0 (0-based); cl/sector=2 (1-based)
+        xor     dh, dh                  ; dh/head=0
+.the_load_loop:
+        xor     bx, bx
+        mov     es, di                  ; es:bx -> buffer
+        mov     ax, 0201h               ; al=1 sector; ah=read function
+        int     13h
+        jc      .failure
+
+        ; advance to the next sector/head/cylinder.
+        inc     cl
+        cmp     cl, bMaxSector
+        jbe     .adv_addr
+
+        mov     cl, 1
+        inc     dh
+        cmp     dh, bMaxHead
+        jbe     .adv_addr
+
+        mov     dh, 0
+        inc     ch
+
+.adv_addr:
+        add     di, 512 / 16
+        dec     si
+        jnz     .the_load_loop
+
+        add     sp, 3*2
+        pop     dx
+        pop     es
+        leave
+        ret
+
+        ;
+        ; Something went wrong, display a message.
+        ;
+.failure:
+        pusha
+
+        ; print message
+        mov     si, .s_szErrMsg
+        mov     ah, 0eh
+        xor     bx, bx
+.failure_next_char:
+        lodsb
+        int     10h
+        cmp     si, .s_szErrMsgEnd
+        jb      .failure_next_char
+
+        ; format the error number.
+        movzx   bx, byte [bp - 2 - 1]    ; read the ah of the pusha frame
+        shr     bl, 4
+        mov     al, [bx + .s_achHex]
+        int     10h
+
+        movzx   bx, byte [bp - 2 - 1]    ; read the ah of the pusha frame
+        and     bl, 0fh
+        mov     al, [bx + .s_achHex]
+        int     10h
+
+        ; panic
+        popa
+        call    Bs3Panic
+.s_szErrMsg:
+        db 13, 10, 'read error: '
+.s_szErrMsgEnd:
+.s_achHex:
+        db '0123456789abcdef'
+ENDPROC bs3InitLoadImage
+
+
+;
+; Pad the remainder of the sector with int3's and end it with the DOS signature.
+;
+bs3Padding:
+        times ( 510 - ( (bs3Padding - start) % 512 ) ) db 0cch
+        db      055h, 0aah
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.asm	(revision 58588)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.asm	(revision 58588)
@@ -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"
+
+extern TMPL_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     TMPL_CMN_NM(Bs3Panic)
+.s_szShutdown:
+        db      'Shutdown', 0
+ENDPROC TMPL_CMN_NM(Bs3Shutdown)
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 58588)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 58588)
@@ -0,0 +1,106 @@
+; $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.
+;
+; Note! The following is useful for verifying that all macros are included here:
+;
+;       for i in `grep "%define" bootsector2-template-header.mac \
+;                 | sed -e 's/^ *%define *//' -e 's/^\([^() ]*\).*$/\1/' \
+;                 | sort -u`
+;       do
+;               if ! grep -wF "%undef $i" bootsector2-template-footer.mac; then
+;                       echo $i
+;               fi
+;       done
+;
+%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
+%undef TMPL_PTR_DEF
+%undef TMPL_HAVE_BIOS
+%undef TMPL_BEGINCODE
+
+%undef xCB
+%undef xDEF
+%undef xRES
+%undef xPRE
+%undef xSP
+%undef xBP
+%undef xAX
+%undef xBX
+%undef xCX
+%undef xDX
+%undef xDI
+%undef xSI
+%undef xWrtRIP
+
+%undef sCB
+%undef sDEF
+%undef sRES
+%undef sPRE
+%undef sSP
+%undef sBP
+%undef sAX
+%undef sBX
+%undef sCX
+%undef sDX
+%undef sDI
+%undef sSI
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 58588)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 58588)
@@ -0,0 +1,801 @@
+; $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"
+
+;
+; Check and expand the mode defines.
+; One of the following must be defined:
+;       - TMPL_RM    - real mode.
+;       - TMPL_PE16  - 16-bit protected mode, unpaged.
+;       - TMPL_PE32  - 32-bit protected mode, unpaged.
+;       - TMPL_PEV86 - virtual 8086 mode under protected mode, unpaged.
+;       - TMPL_PP16  - 16-bit protected mode, paged.
+;       - TMPL_PP32  - 32-bit protected mode, paged.
+;       - TMPL_PPV86 - virtual 8086 mode under protected mode, paged.
+;       - TMPL_PAE16 - 16-bit protected mode with PAE (paged).
+;       - TMPL_PAE32 - 16-bit protected mode with PAE (paged).
+;       - TMPL_PAEV86- virtual 8086 mode under protected mode with PAE (paged).
+;       - TMPL_LM16  - 16-bit long mode (paged).
+;       - TMPL_LM32  - 32-bit long mode (paged).
+;       - TMPL_LM64  - 64-bit long mode (paged).
+;
+; Derived indicators:
+;       - TMPL_CMN_PE  = TMPL_PE16  | TMPL_PE32  | TMPL_PEV86
+;       - TMPL_CMN_PP  = TMPL_PP16  | TMPL_PP32  | TMPL_PPV86
+;       - TMPL_CMN_PAE = TMPL_PAE16 | TMPL_PAE32 | TMPL_PAEV86
+;       - TMPL_CMN_LM  = TMPL_LM16  | TMPL_LM32  | TMPL_LM64
+;       - TMPL_CMN_V86 = TMPL_PEV86 | TMPL_PPV86 | TMPL_PAEV86
+;       - TMPL_CMN_R86 = TMPL_CMN_V86 | TMPL_RM
+;
+%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
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _rm
+ %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %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
+ %define TMPL_CMN_PE
+ %define TMPL_CMN_P16
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _pe16
+ %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %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
+ %define TMPL_CMN_PE
+ %define TMPL_CMN_P32
+ %define TMPL_32BIT
+ %define TMPL_BITS              32
+ %define TMPL_PTR_DEF           dd
+ %define TMPL_NM(Name)          Name %+ _pe32
+ %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %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
+ %define TMPL_CMN_PE
+ %define TMPL_CMN_V86
+ %define TMPL_CMN_R86
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _pev86
+ %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %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
+ %define TMPL_CMN_PP
+ %define TMPL_CMN_P16
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _pp16
+ %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %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
+ %define TMPL_CMN_PP
+ %define TMPL_CMN_P32
+ %define TMPL_32BIT
+ %define TMPL_BITS              32
+ %define TMPL_PTR_DEF           dd
+ %define TMPL_NM(Name)          Name %+ _pp32
+ %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %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
+ %define TMPL_CMN_PP
+ %define TMPL_CMN_V86
+ %define TMPL_CMN_R86
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _ppv86
+ %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %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
+ %define TMPL_CMN_PAE
+ %define TMPL_16BIT
+ %define TMPL_CMN_P16
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _pae16
+ %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %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
+ %define TMPL_CMN_PAE
+ %define TMPL_CMN_P32
+ %define TMPL_32BIT
+ %define TMPL_BITS              32
+ %define TMPL_PTR_DEF           dd
+ %define TMPL_NM(Name)          Name %+ _pae32
+ %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %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
+ %define TMPL_CMN_PAE
+ %define TMPL_CMN_V86
+ %define TMPL_CMN_R86
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _paev86
+ %define TMPL_NM_CMN(Name)      Name %+ _r86
+ %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
+ %define TMPL_CMN_LM
+ %define TMPL_CMN_P16
+ %define TMPL_16BIT
+ %define TMPL_BITS              16
+ %define TMPL_PTR_DEF           dw
+ %define TMPL_NM(Name)          Name %+ _lm16
+ %define TMPL_NM_CMN(Name)      Name %+ _p16
+ %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
+ %define TMPL_CMN_LM
+ %define TMPL_CMN_P32
+ %define TMPL_32BIT
+ %define TMPL_BITS              32
+ %define TMPL_PTR_DEF           dd
+ %define TMPL_NM(Name)          Name %+ _lm32
+ %define TMPL_NM_CMN(Name)      Name %+ _p32
+ %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
+ %define TMPL_CMN_LM
+ %define TMPL_CMN_P64
+ %define TMPL_64BIT
+ %define TMPL_BITS              64
+ %define TMPL_PTR_DEF           dq
+ %define TMPL_NM(Name)          Name %+ _lm64
+ %define TMPL_NM_CMN(Name)      Name %+ _p64
+ %define TMPL_MODE_STR          '64-bit long mode'
+%endif
+
+%ifndef TMPL_MODE_STR
+ %error "internal error"
+%endif
+
+
+;
+; Preferred spelling of TMPL_NM_CMN in BS3.
+;
+%define TMPL_CMN_NM(Name)      TMPL_NM_CMN(Name)
+
+
+;
+; Register aliases.
+;
+%ifdef TMPL_64BIT
+ %define xCB  8
+ %define xDEF dq
+ %define xRES resq
+ %define xPRE qword
+ %define xSP  rsp
+ %define xBP  rbp
+ %define xAX  rax
+ %define xBX  rbx
+ %define xCX  rcx
+ %define xDX  rdx
+ %define xDI  rdi
+ %define xSI  rsi
+ %define xWrtRIP wrt rip
+ %define xPUSHF pushq
+ %define xPOPF  popfq
+%else
+ %ifdef TMPL_32BIT
+  %define xCB  4
+  %define xDEF dd
+  %define xRES resd
+  %define xPRE dword
+  %define xSP  esp
+  %define xBP  ebp
+  %define xAX  eax
+  %define xBX  ebx
+  %define xCX  ecx
+  %define xDX  edx
+  %define xDI  edi
+  %define xSI  esi
+  %define xWrtRIP
+  %define xPUSHF pushfd
+  %define xPOPF  popfd
+ %else
+  %ifndef TMPL_16BIT
+   %error "TMPL_XXBIT is not defined."
+  %endif
+  %define xCB  2
+  %define xDEF dw
+  %define xRES resw
+  %define xPRE word
+  %define xSP  sp
+  %define xBP  bp
+  %define xAX  ax
+  %define xBX  bx
+  %define xCX  cx
+  %define xDX  dx
+  %define xDI  di
+  %define xSI  si
+  %define xWrtRIP
+  %define xPUSHF pushf
+  %define xPOPF  popf
+ %endif
+%endif
+
+;
+; Register names corresponding to the max size for pop/push <reg>.
+;
+; 16-bit can push both 32-bit and 16-bit registers.  This 's' prefixed variant
+; is used when 16-bit should use the 32-bit register.
+;
+%ifdef TMPL_64BIT
+ %define sCB  8
+ %define sDEF dq
+ %define sRES resq
+ %define sPRE qword
+ %define sSP  rsp
+ %define sBP  rbp
+ %define sAX  rax
+ %define sBX  rbx
+ %define sCX  rcx
+ %define sDX  rdx
+ %define sDI  rdi
+ %define sSI  rsi
+ %define sPUSHF pushfq
+ %define sPOPF  popfq
+%else
+ %define sCB  4
+ %define sDEF dd
+ %define sRES resd
+ %define sPRE dword
+ %define sSP  esp
+ %define sBP  ebp
+ %define sAX  eax
+ %define sBX  ebx
+ %define sCX  ecx
+ %define sDX  edx
+ %define sDI  edi
+ %define sSI  esi
+ %define sPUSHF pushfd
+ %define sPOPF  popfd
+%endif
+
+;
+; Default code segment.
+;
+%ifdef TMPL_64BIT
+ %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT64
+%elifdef TMPL_32BIT
+ %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT32
+%elifdef TMPL_16BIT
+ %define TMPL_BEGIN_TEXT BS3_BEGIN_TEXT16
+%else
+ %error "Missing TMPL_xxBIT!"
+%endif
+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.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58588)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58588)
@@ -0,0 +1,173 @@
+; $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_mac___
+%define ___bs3kit_mac___
+
+%include "iprt/asmdefs.mac"
+%include "iprt/x86.mac"
+
+
+;; @name Static Memory Allocation
+; @{
+;; The flat load address for the code after the bootsector.
+%define BS3_LOAD_ADDR           010000h
+;; Where we save the boot registers during init.
+; Located right before the code.
+%define BS3_REG_SAVE_ADDR       (BS3_LOAD_ADDR - BS3REGS_size - 8)
+;; Where the stack starts (initial RSP value).
+; Located right before the saved registers. SS.BASE=0.
+%define BS3_STACK_ADDR          (BS3_REG_SAVE_ADDR - 16)
+;; @}
+
+
+;;
+; Registers.  Used by traps and such.
+;
+struc BS3REGS
+        .rax    resq 1
+        .rbx    resq 1
+        .rcx    resq 1
+        .rdx    resq 1
+        .rdi    resq 1
+        .rsi    resq 1
+        .rbp    resq 1
+        .rsp    resq 1
+        .rip    resq 1
+        .r8     resq 1
+        .r9     resq 1
+        .r10    resq 1
+        .r11    resq 1
+        .r12    resq 1
+        .r13    resq 1
+        .r14    resq 1
+        .r15    resq 1
+        .rflags resq 1
+        .cs     resw 1
+        .ds     resw 1
+        .es     resw 1
+        .fs     resw 1
+        .gs     resw 1
+        .ss     resw 1
+        .cBits  resb 1
+        .pad    resb 3
+        .cr0    resq 1
+        .cr2    resq 1
+        .cr3    resq 1
+        .cr4    resq 1
+        .cr8    resq 1
+        ;; @todo Add floating point registers when they are active.
+endstruc
+
+
+
+;;
+; Trap record.
+;
+struc BS3TRAPREC
+        ;; The trap location relative to the base address given at
+        ; registration time.
+        .offWhere               resd 1
+        ;; What to add to .offWhere to calculate the resume address.
+        .offResumeAddend        resb 1
+        ;; The trap number.
+        .u8TrapNo               resb 1
+        ;; The error code if the trap takes one.
+        .u16ErrCd               resw 1
+endstruc
+
+;; The size shift.
+%define BS3TRAPREC_SIZE_SHIFT   3
+
+
+;; @name Segment definitions.
+;; @{
+%macro BS3_BEGIN_TEXT16 0
+ %ifndef BS3_BEGIN_TEXT16_NOT_FIRST
+  %define BS3_BEGIN_TEXT16_NOT_FIRST
+        section TEXT16 CLASS=CODE16 PUBLIC USE16 ALIGN=1
+ %else
+        section TEXT16
+ %endif
+%endmacro
+
+%macro BS3_BEGIN_DATA16 0
+ %ifndef BS3_BEGIN_DATA16_NOT_FIRST
+  %define BS3_BEGIN_DATA16_NOT_FIRST
+        section DATA16 CLASS=DATA16 PUBLIC USE16 ALIGN=2
+ %else
+        section DATA16
+ %endif
+%endmacro
+
+%macro BS3_BEGIN_TEXT32 0
+ %ifndef BS3_BEGIN_TEXT16_NOT_FIRST
+  %define BS3_BEGIN_TEXT16_NOT_FIRST
+        section TEXT32 CLASS=CODE32 PUBLIC USE32 ALIGN=1
+ %else
+        section TEXT32
+ %endif
+%endmacro
+
+%macro BS3_BEGIN_DATA32 0
+ %ifndef BS3_BEGIN_DATA32_NOT_FIRST
+  %define BS3_BEGIN_DATA32_NOT_FIRST
+        section DATA32 CLASS=DATA32 PUBLIC USE32 ALIGN=16
+ %else
+        section DATA32
+ %endif
+%endmacro
+
+%macro BS3_BEGIN_TEXT64 0
+ %ifndef BS3_BEGIN_TEXT64_NOT_FIRST
+  %define BS3_BEGIN_TEXT64_NOT_FIRST
+  %ifdef ASM_FORMAT_ELF
+        section TEXT64 ALIGN=1
+  %else
+        section TEXT64 CLASS=CODE64 PUBLIC USE32 ALIGN=1
+  %endif
+ %else
+        section TEXT64
+ %endif
+%endmacro
+
+%macro BS3_BEGIN_DATA64 0
+ %ifndef BS3_BEGIN_DATA64_NOT_FIRST
+  %define BS3_BEGIN_DATA64_NOT_FIRST
+  %ifdef ASM_FORMAT_ELF
+        section DATA64 ALIGN=16
+  %else
+        section DATA64 CLASS=DATA64 PUBLIC USE32 ALIGN=16
+  %endif
+ %else
+        section DATA64
+ %endif
+%endmacro
+
+;; @}
+
+%endif
+
