Index: /trunk/src/VBox/ValidationKit/bootsectors/Config.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/Config.kmk	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/Config.kmk	(revision 60527)
@@ -70,4 +70,33 @@
 endif
 
+
+##
+# Macro for generating near-call aliases for zero or more 16-bit C functions.
+# @param    1   The target name.
+# @param    2   List of functions.
+BS3KIT_FN_GEN_NEARSTUBS = $(foreach fn,$2,$(evalcall2 def_Bs3KitGenNearStubSource,$1,$(fn)))
+define def_Bs3KitGenNearStubSource
+$1_SOURCES += $$($1_0_OUTDIR)/near-call-to-$2_f16.asm
+$1_CLEAN   += $$($1_0_OUTDIR)/near-call-to-$2_f16.asm
+$$$$($1_0_OUTDIR)/near-call-to-$2_f16.asm: | $$$$(dir $$$$@)
+	$(QUIET)$(APPEND) -tn $$@ \
+		'%include "bs3kit.mac"' \
+       	'BS3_BEGIN_TEXT16' \
+               '      extern  _$2_f16' \
+       	'BS3_BEGIN_TEXT16_NEARSTUBS' \
+               'GROUP CGROUP16 BS3TEXT16 BS3TEXT16_NEARSTUBS' \
+		'BS3_GLOBAL_NAME_EX _$2_c16, function, 6' \
+               '      pop     ax' \
+               '      push    cs' \
+               '      push    ax' \
+               '      jmp     _$2_f16 wrt CGROUP16'
+endef
+
+
+#
+# Tools Tools Tools
+# Tools Tools Tools
+# Tools Tools Tools
+#
 
 # Dummy CP "linker" tool.
@@ -530,4 +559,6 @@
  	 clname $(BS3KIT_CLASS_CODE16) segaddr=0x1000 \
  	  segment BS3TEXT16 \
+ 	  segment BS3TEXT16_NEARSTUBS \
+         segment BS3TEXT16_FARSTUBS \
  	  segment BS3TEXT16_END \
         clname BS3SYSTEM16 segaddr=0x2000 \
@@ -571,8 +602,16 @@
  	  segment BS3DATA64_BSS \
  	  segment BS3DATA64_END \
+        clname BS3CLASS16RMCODE \
+ 	  segment BS3RMCODE16_START \
+ 	  segment BS3RMCODE16 \
+ 	  segment BS3RMCODE16_END \
         clname BS3CLASS32CODE \
+ 	  segment BS3TEXT32_START \
  	  segment BS3TEXT32 \
+ 	  segment BS3TEXT32_END \
         clname BS3CLASS64CODE \
- 	  segment BS3TEXT64
+ 	  segment BS3TEXT64_START \
+ 	  segment BS3TEXT64 \
+ 	  segment BS3TEXT64_END
 
 TEMPLATE_VBoxBS3KitImg_LNK_DEPS = \
@@ -705,4 +744,6 @@
  	  segment BS3TEXT16 \
  	  segment _TEXT \
+ 	  segment BS3TEXT16_NEARSTUBS \
+ 	  segment BS3TEXT16_FARSTUBS \
  	  segment BS3TEXT16_END \
         clname BS3SYSTEM16  \
@@ -764,8 +805,14 @@
  	  segment BS3DATA64_BSS \
  	  segment BS3DATA64_END \
+        clname BS3CLASS16RMCODE \
+ 	  segment BS3RMCODE16_START \
+ 	  segment BS3RMCODE16 \
+ 	  segment BS3RMCODE16_END \
         clname BS3CLASS32CODE \
  	  segment BS3TEXT32 \
+ 	  segment BS3TEXT32_END \
         clname BS3CLASS64CODE \
- 	  segment BS3TEXT64
+ 	  segment BS3TEXT64 \
+ 	  segment BS3TEXT64_END
 # 	 clname BS3FLAT segaddr=0x0000 \
 # 	   segment BS3FLAT segaddr=0x0000
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-c.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-c.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-c.c	(revision 60527)
@@ -49,8 +49,8 @@
 {
     //BS3TESTMODEENTRY_MODE("tss / gate / esp", bs3CpuBasic2_TssGateEsp),
-    //BS3TESTMODEENTRY_MODE("raise xcpt #1", bs3CpuBasic2_RaiseXcpt1),
+    BS3TESTMODEENTRY_MODE("raise xcpt #1", bs3CpuBasic2_RaiseXcpt1),
     //BS3TESTMODEENTRY_CMN("iret", bs3CpuBasic2_iret),
-    //BS3TESTMODEENTRY_MODE("iret", bs3CpuBasic2_iret),
-    BS3TESTMODEENTRY_MODE("sidt", bs3CpuBasic2_sidt),
+//    BS3TESTMODEENTRY_MODE("iret", bs3CpuBasic2_iret),
+//    BS3TESTMODEENTRY_MODE("sidt", bs3CpuBasic2_sidt),
 };
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c	(revision 60527)
@@ -351,5 +351,5 @@
 # if TMPL_BITS == 16
     bool const      f386Plus = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386;
-    bool const      f286     = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80286;
+    bool const      f286     = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) == BS3CPU_80286;
 # else
     bool const      f286     = false;
@@ -1571,4 +1571,8 @@
     g_f16BitSys   = BS3_MODE_IS_16BIT_SYS(TMPL_MODE);
 
+    Bs3PrintStrN(RT_STR_TUPLE("Hello world!\n"));
+#if !BS3_MODE_IS_V86(TMPL_MODE)
+    Bs3TestPrintf(RT_STR_TUPLE("Hi there!\n"));
+#endif
     return BS3TESTDOMODE_SKIPPED;
 }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 60527)
@@ -66,6 +66,4 @@
 	bs3-cmn-PrintStr.c \
 	bs3-cmn-PrintStrN.asm \
-       bs3-cmn-PrintStrColonSpaces.asm \
-       bs3-cmn-PrintStrSpacesColonSpace.c \
        bs3-cmn-StrFormatV.c \
        bs3-cmn-StrPrintf.c \
@@ -124,4 +122,6 @@
 	bs3-cmn-TestCheckRegCtxEx.c \
 	bs3-cmn-TestPrintf.c \
+	bs3-cmn-TrapRmV86Init.c \
+	bs3-cmn-TrapRmV86SetGate.c \
 	bs3-cmn-Trap16Init.c \
 	bs3-cmn-Trap16SetGate.c \
@@ -151,4 +151,19 @@
        ../../../Runtime/common/asm/ASMSerializeInstruction-rdtscp.asm \
 
+#
+# We generate a list of files with 16-bit far functions for which we generate
+# near jump stubs.
+#
+#$(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk.ts \
+#+| $(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk: $(VBOX_PATH_BS3KIT_SRC)/bs3kit.h
+#       $(SED) \
+#       	-n -e '/no-near-stub/d' \
+#       	-e 's/^ *BS3_DECL(.*)  *\([a-zA-Z][a-zA-Z0-9_]*\)(.*[;,][^;]*$/\1/p' \
+#               --output $@ \
+#       	bs3kit.h
+#       .$(CP_CHANGED) --changed -f -- $@ $(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk
+#include $(PATH)
+
+
 # The 16-bit BS3Kit library.
 LIBRARIES += bs3kit-common-16
@@ -176,6 +191,24 @@
 	bs3-wc16-U4D.asm \
 	bs3-wc16-I4D.asm \
-       bs3-c16-Trap16Generic.asm
+       bs3-c16-Trap16Generic.asm \
+	bs3-c16-CreateHybridFarRet.asm
 bs3kit-common-16_bs3-cmn-UInt64Div.c_CFLAGS = -oh -d0 # -d1+ vs -d0 saves 0x6a3-0x577 = 0x12C (300)!
+bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS := \
+	$(sort $(subst bs3-cmn-,Bs3,$(basename $(filter-out \
+		%Data.c \
+		bs3-rm-% \
+		bs3-cmn-hexdigits.c \
+	,$(filter %.c,$(bs3kit-common-16_SOURCES)))))) \
+       Bs3PrintfV \
+       Bs3StrPrintfV \
+       Bs3TestPrintfV \
+       Bs3TestFailedF \
+       Bs3TestFailedV \
+       Bs3TestSkippedF \
+       Bs3TestSkippedV \
+       Bs3TestSubF \
+       Bs3TestSubV \
+       Bs3Trap16InitEx
+$(call BS3KIT_FN_GEN_NEARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS))
 
 # The 32-bit BS3Kit library.
@@ -431,5 +464,15 @@
 
 
+#
+# Rule for regenerating bs3kit-mangling-functions-undef.h.
+#
+bs3kit-mangling-code-undef.h: $(PATH_SUB_CURRENT)/bs3kit-mangling-code-define.h
+	$(SED) \
+		-e 's/#define \([a-zA-Z_][a-zA-Z0-9_]*\) .*$(DOLLAR)/#undef \1/' \
+       	-e 's/Function needing mangling\./Undefining function mangling - automatically generated by the $@ makefile rule./' \
+       	--output $(dir $<)bs3kit-mangling-code-undef.h \
+		$<
+
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
-.PRECIOUS: $(PATH_OBJ)/bs3-shutdown/bs3-shutdown.map
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp	(revision 60527)
@@ -56,4 +56,12 @@
 # define ELF_FMT_D64  "lld"
 #endif
+
+/** Compares an OMF string with a constant string. */
+#define IS_OMF_STR_EQUAL_EX(a_cch1, a_pch1, a_szConst2) \
+    ( (a_cch1) == sizeof(a_szConst2) - 1 && memcmp(a_pch1, a_szConst2, sizeof(a_szConst2) - 1) == 0 )
+
+/** Compares an OMF string with a constant string. */
+#define IS_OMF_STR_EQUAL(a_pchZeroPrefixed, a_szConst2) \
+    IS_OMF_STR_EQUAL_EX((uint8_t)((a_pchZeroPrefixed)[0]), &((a_pchZeroPrefixed)[1]), a_szConst2)
 
 
@@ -3594,4 +3602,37 @@
 
 /**
+ * Segment definition.
+ */
+typedef struct OMFSEGDEF
+{
+    uint32_t    cbSeg;
+    uint8_t     bSegAttr;
+    uint16_t    idxName;
+    uint16_t    idxClass;
+    uint16_t    idxOverlay;
+    uint8_t     cchName;
+    uint8_t     cchClass;
+    uint8_t     cchOverlay;
+    const char *pchName;
+    const char *pchClass;
+    const char *pchOverlay;
+    bool        fUse32;
+} OMFSEGDEF;
+typedef OMFSEGDEF *POMFSEGDEF;
+
+/**
+ * Group definition.
+ */
+typedef struct OMFGRPDEF
+{
+    const char *pchName;
+    uint16_t    idxName;
+    uint8_t     cchName;
+    uint16_t    cSegDefs;
+    uint16_t   *pidxSegDefs;
+} OMFGRPDEF;
+typedef OMFGRPDEF *POMFGRPDEF;
+
+/**
  * Records line number information for a file in a segment (for CV8 debug info).
  */
@@ -3620,4 +3661,7 @@
     /** The segment index. */
     uint16_t        idxSeg;
+    /** The group index for this segment.  This is zero if not yet determined and
+     * UINT16_MAX if no group applicable to this segment. */
+    uint16_t        idxGrp;
     /** File table. */
     POMFFILEINES    paFiles;
@@ -3638,6 +3682,6 @@
     /** Set if this module may need mangling. */
     bool            fMayNeedMangling;
-    /** Number of SEGDEFs records. */
-    uint32_t        cSegDefs;
+    /** Set if this module needs CGROUP16 for line number fixupes. */
+    bool            fNeedsCGroup16;
     /** The LNAME index of '$$SYMBOLS' or UINT16_MAX it not found. */
     uint16_t        iSymbolsNm;
@@ -3646,4 +3690,22 @@
     /** The '$$SYMBOLS' segment index. */
     uint16_t        iSymbolsSeg;
+    /** The LNAME index of 'CGROUP16' or UINT16_MAX it not found. */
+    uint16_t        iCGroup16Nm;
+    /** The 'CGROUP16' group definition index or UINT16_MAX it not found. */
+    uint16_t        iCGroup16Grp;
+
+    /** Number of SEGDEFs records. */
+    uint16_t        cSegDefs;
+    /** Number of GRPDEFs records. */
+    uint16_t        cGrpDefs;
+    /** Number of listed names. */
+    uint16_t        cLNames;
+
+    /** Segment defintions. */
+    POMFSEGDEF      paSegDefs;
+    /** Group defintions. */
+    POMFGRPDEF      paGrpDefs;
+    /** Name list.  Points to the size repfix. */
+    char          **papchLNames;
 
     /** CV8: Filename string table size. */
@@ -3667,4 +3729,35 @@
 typedef OMFDETAILS const *PCOMFDETAILS;
 
+/** Grows a table to a given size (a_cNewEntries). */
+#define OMF_GROW_TABLE_EX_RET_ERR(a_EntryType, a_paTable, a_cEntries, a_cNewEntries) \
+    do\
+    { \
+        size_t cbOld = (a_cEntries) * sizeof(a_EntryType); \
+        size_t cbNew = (a_cNewEntries) * sizeof(a_EntryType); \
+        void  *pvNew = realloc(a_paTable, cbNew); \
+        if (pvNew) \
+        { \
+            memset((uint8_t *)pvNew + cbOld, 0, cbNew - cbOld); \
+            (a_paTable) = (a_EntryType *)pvNew; \
+        } \
+        else return error("???", "Out of memory!\n"); \
+    } while (0)
+
+/** Grows a table. */
+#define OMF_GROW_TABLE_RET_ERR(a_EntryType, a_paTable, a_cEntries, a_cEvery) \
+    if ((a_cEntries) % (a_cEvery) != 0) { /* likely */ } \
+    else do\
+    { \
+        size_t cbOld = (a_cEntries) * sizeof(a_EntryType); \
+        size_t cbNew = cbOld + (a_cEvery) * sizeof(a_EntryType); \
+        void  *pvNew = realloc(a_paTable, cbNew); \
+        if (pvNew) \
+        { \
+            memset((uint8_t *)pvNew + cbOld, 0, (a_cEvery) * sizeof(a_EntryType)); \
+            (a_paTable) = (a_EntryType *)pvNew; \
+        } \
+        else return error("???", "Out of memory!\n"); \
+    } while (0)
+
 
 /**
@@ -3756,14 +3849,9 @@
     if (idxSeg >= pOmfStuff->cSegLines)
     {
-        void *pvNew = realloc(pOmfStuff->paSegLines, (idxSeg + 1) * sizeof(pOmfStuff->paSegLines[0]));
-        if (!pvNew)
-            return error("???", "out of memory");
-        pOmfStuff->paSegLines = (POMFSEGLINES)pvNew;
-
-        memset(&pOmfStuff->paSegLines[pOmfStuff->cSegLines], 0,
-               (idxSeg + 1 - pOmfStuff->cSegLines) * sizeof(pOmfStuff->paSegLines[0]));
+        OMF_GROW_TABLE_EX_RET_ERR(OMFSEGLINES, pOmfStuff->paSegLines, pOmfStuff->cSegLines, idxSeg + 1);
         for (uint32_t i = pOmfStuff->cSegLines; i <= idxSeg; i++)
         {
             pOmfStuff->paSegLines[i].idxSeg = i;
+            pOmfStuff->paSegLines[i].idxGrp = UINT16_MAX;
             pOmfStuff->paSegLines[i].cb = sizeof(RTCV8LINESHDR);
         }
@@ -3786,12 +3874,5 @@
     {
         i = pSegLines->cFiles;
-        if ((i % 4) == 0)
-        {
-            void *pvNew = realloc(pSegLines->paFiles, (i + 4) * sizeof(pSegLines->paFiles[0]));
-            if (!pvNew)
-                return error("???", "out of memory");
-            pSegLines->paFiles = (POMFFILEINES)pvNew;
-        }
-
+        OMF_GROW_TABLE_RET_ERR(OMFFILEINES, pSegLines->paFiles, pSegLines->cFiles, 4);
         pSegLines->cFiles = i + 1;
         pSegLines->cb    += sizeof(RTCV8LINESSRCMAP);
@@ -3802,4 +3883,20 @@
         pFileLines->cPairsAlloc = 0;
         pFileLines->paPairs     = NULL;
+
+        /*
+         * Check for segment group requirements the first time a segment is used.
+         */
+        if (i == 0)
+        {
+            if (idxSeg >= pOmfStuff->cSegDefs)
+                return error("???", "collectOmfAddLine: idxSeg=%#x is out of bounds (%#x)!\n", idxSeg, pOmfStuff->cSegDefs);
+            POMFSEGDEF pSegDef = &pOmfStuff->paSegDefs[idxSeg];
+            if (   IS_OMF_STR_EQUAL_EX(pSegDef->cchClass, pSegDef->pchClass, "BS3CLASS16CODE")
+                || IS_OMF_STR_EQUAL_EX(pSegDef->cchClass, pSegDef->pchClass, "CODE"))
+            {
+                pOmfStuff->fNeedsCGroup16 = true;
+                pSegLines->idxGrp = 0;  /* We'll replace zeros by the actual CGROUP16 index later. */
+            }
+        }
     }
 
@@ -3852,5 +3949,4 @@
 static bool collectOmfDetails(const char *pszFile, uint8_t const *pbFile, size_t cbFile, POMFDETAILS pOmfStuff)
 {
-    uint32_t        cLNames = 0;
     uint32_t        cExtDefs = 0;
     uint32_t        cPubDefs = 0;
@@ -3861,8 +3957,24 @@
 
     memset(pOmfStuff, 0, sizeof(*pOmfStuff));
-    pOmfStuff->iDebSymNm   = UINT16_MAX;
-    pOmfStuff->iSymbolsNm  = UINT16_MAX;
-    pOmfStuff->iSymbolsSeg = UINT16_MAX;
-
+    pOmfStuff->iDebSymNm    = UINT16_MAX;
+    pOmfStuff->iSymbolsNm   = UINT16_MAX;
+    pOmfStuff->iSymbolsSeg  = UINT16_MAX;
+    pOmfStuff->iCGroup16Nm  = UINT16_MAX;
+    pOmfStuff->iCGroup16Grp = UINT16_MAX;
+
+    /* Dummy entries. */
+    OMF_GROW_TABLE_RET_ERR(char *, pOmfStuff->papchLNames, pOmfStuff->cLNames, 16);
+    pOmfStuff->papchLNames[0] = (char *)"";
+    pOmfStuff->cLNames = 1;
+
+    OMF_GROW_TABLE_RET_ERR(OMFSEGDEF, pOmfStuff->paSegDefs, pOmfStuff->cSegDefs, 16);
+    pOmfStuff->cSegDefs = 1;
+
+    OMF_GROW_TABLE_RET_ERR(OMFGRPDEF, pOmfStuff->paGrpDefs, pOmfStuff->cGrpDefs, 16);
+    pOmfStuff->cGrpDefs = 1;
+
+    /*
+     * Process the OMF records.
+     */
     while (off + 3 < cbFile)
     {
@@ -3888,4 +4000,26 @@
             } while (0)
 
+#define OMF_READ_U16(a_u16, a_Name) \
+            do { \
+                OMF_CHECK_RET(4, a_Name); \
+                a_u16 = RT_MAKE_U16(pbRec[offRec], pbRec[offRec + 1]); \
+                offRec += 2; \
+            } while (0)
+#define OMF_READ_U32(a_u32, a_Name) \
+            do { \
+                OMF_CHECK_RET(4, a_Name); \
+                a_u32 = RT_MAKE_U32_FROM_U8(pbRec[offRec], pbRec[offRec + 1], pbRec[offRec + 2], pbRec[offRec + 3]); \
+                offRec += 4; \
+            } while (0)
+#define OMF_EXPLODE_LNAME(a_idxName, a_pchName, a_cchName, a_Name) \
+            do { \
+                if ((a_idxName) < pOmfStuff->cLNames) \
+                { \
+                    a_cchName = (uint8_t)*pOmfStuff->papchLNames[(a_idxName)]; \
+                    a_pchName = pOmfStuff->papchLNames[(a_idxName)] + 1; \
+                } \
+                else return error(pszFile, "Invalid LNAME reference %#x in " #a_Name "!\n", a_idxName); \
+            } while (0)
+
         switch (bRecType)
         {
@@ -3901,20 +4035,21 @@
                                      off, offRec, cch, (unsigned long)cbFile);
 
-                    cLNames++;
                     if (g_cVerbose > 2)
-                        printf("  LNAME[%u]: %-*.*s\n", cLNames, cch, cch, &pbRec[offRec + 1]);
-
-                    if (cch == 4 && memcmp(&pbRec[offRec + 1], "FLAT", 4) == 0)
+                        printf("  LNAME[%u]: %-*.*s\n", pOmfStuff->cLNames, cch, cch, &pbRec[offRec + 1]);
+
+                    OMF_GROW_TABLE_RET_ERR(char *, pOmfStuff->papchLNames, pOmfStuff->cLNames, 16);
+                    pOmfStuff->papchLNames[pOmfStuff->cLNames] = (char *)&pbRec[offRec];
+
+                    if (IS_OMF_STR_EQUAL_EX(cch, &pbRec[offRec + 1], "FLAT"))
                         pOmfStuff->fProbably32bit = true;
 
-                    if (   cch == 6
-                        && pOmfStuff->iDebSymNm == UINT16_MAX
-                        && memcmp(&pbRec[offRec + 1], "DEBSYM", 6) == 0)
-                        pOmfStuff->iDebSymNm = cLNames;
-                    if (   cch == 9
-                        && pOmfStuff->iSymbolsNm == UINT16_MAX
-                        && memcmp(&pbRec[offRec + 1], "$$SYMBOLS", 9) == 0)
-                        pOmfStuff->iSymbolsNm = cLNames;
-
+                    if (IS_OMF_STR_EQUAL_EX(cch, &pbRec[offRec + 1], "DEBSYM"))
+                        pOmfStuff->iDebSymNm = pOmfStuff->cLNames;
+                    if (IS_OMF_STR_EQUAL_EX(cch, &pbRec[offRec + 1], "$$SYMBOLS"))
+                        pOmfStuff->iSymbolsNm = pOmfStuff->cLNames;
+                    if (IS_OMF_STR_EQUAL_EX(cch, &pbRec[offRec + 1], "CGROUP16"))
+                        pOmfStuff->iCGroup16Nm = pOmfStuff->cLNames;
+
+                    pOmfStuff->cLNames++;
                     offRec += cch + 1;
                 }
@@ -3922,5 +4057,5 @@
 
             /*
-             * Display external defitions if -v is specified, also check if anything needs mangling.
+             * Display external definitions if -v is specified, also check if anything needs mangling.
              */
             case OMF_EXTDEF:
@@ -4024,10 +4159,61 @@
 
             /*
-             * Must count segment defitions to figure the index of our segment.
+             * Must count segment definitions to figure the index of our segment.
              */
             case OMF_SEGDEF16:
             case OMF_SEGDEF32:
-                pOmfStuff->cSegDefs++;
+            {
+                OMF_GROW_TABLE_RET_ERR(OMFSEGDEF, pOmfStuff->paSegDefs, pOmfStuff->cSegDefs, 16);
+                POMFSEGDEF pSegDef = &pOmfStuff->paSegDefs[pOmfStuff->cSegDefs++];
+
+                OMF_CHECK_RET(1 + (bRecType == OMF_SEGDEF16 ? 2 : 4) + 1 + 1 + 1, SEGDEF);
+                pSegDef->bSegAttr = pbRec[offRec++];
+                pSegDef->fUse32   = pSegDef->bSegAttr & 1;
+                if ((pSegDef->bSegAttr >> 5) == 0)
+                {
+                    /* A=0: skip frame number of offset. */
+                    OMF_CHECK_RET(3, SEGDEF);
+                    offRec += 3;
+                }
+                if (bRecType == OMF_SEGDEF16)
+                    OMF_READ_U16(pSegDef->cbSeg, SEGDEF16);
+                else
+                    OMF_READ_U32(pSegDef->cbSeg, SEGDEF32);
+                OMF_READ_IDX(pSegDef->idxName, SEGDEF);
+                OMF_READ_IDX(pSegDef->idxClass, SEGDEF);
+                OMF_READ_IDX(pSegDef->idxOverlay, SEGDEF);
+                OMF_EXPLODE_LNAME(pSegDef->idxName, pSegDef->pchName, pSegDef->cchName, SEGDEF);
+                OMF_EXPLODE_LNAME(pSegDef->idxClass, pSegDef->pchClass, pSegDef->cchClass, SEGDEF);
+                OMF_EXPLODE_LNAME(pSegDef->idxOverlay, pSegDef->pchOverlay, pSegDef->cchOverlay, SEGDEF);
                 break;
+            }
+
+            /*
+             * Must count segment definitions to figure the index of our segment.
+             */
+            case OMF_GRPDEF:
+            {
+                OMF_GROW_TABLE_RET_ERR(OMFGRPDEF, pOmfStuff->paGrpDefs, pOmfStuff->cGrpDefs, 8);
+                POMFGRPDEF pGrpDef = &pOmfStuff->paGrpDefs[pOmfStuff->cGrpDefs];
+
+                OMF_READ_IDX(pGrpDef->idxName, GRPDEF);
+                OMF_EXPLODE_LNAME(pGrpDef->idxName, pGrpDef->pchName, pGrpDef->cchName, GRPDEF);
+                if (pGrpDef->idxName == pOmfStuff->iCGroup16Grp)
+                    pOmfStuff->iCGroup16Grp = pOmfStuff->cGrpDefs;
+
+                pGrpDef->cSegDefs    = 0;
+                pGrpDef->pidxSegDefs = NULL;
+                while (offRec + 2 + 1 < cbRec)
+                {
+                    if (pbRec[offRec] != 0xff)
+                        return error(pszFile, "Unsupported GRPDEF member type: %#x\n", pbRec[offRec]);
+                    offRec++;
+                    OMF_GROW_TABLE_RET_ERR(uint16_t, pGrpDef->pidxSegDefs, pGrpDef->cSegDefs, 16);
+                    OMF_READ_IDX(pGrpDef->pidxSegDefs[pGrpDef->cSegDefs], GRPDEF);
+                    pGrpDef->cSegDefs++;
+                }
+                pOmfStuff->cGrpDefs++;
+                break;
+            }
 
             /*
@@ -4149,7 +4335,7 @@
 
     /*
-     * Emit the segment defitions.
-     */
-    pOmfStuff->iSymbolsSeg = ++pOmfStuff->cSegDefs;
+     * Emit the segment definitions.
+     */
+    pOmfStuff->iSymbolsSeg = pOmfStuff->cSegDefs++;
 
     uint8_t   bSegAttr = 0;
@@ -4172,4 +4358,38 @@
 
 /**
+ * Writes additional segment group definitions.
+ *
+ * @returns success indicator.
+ * @param   pThis       The OMF writer.
+ * @param   pOmfStuff   The OMF stuff with CV8 line number info.
+ */
+static bool convertOmfWriteDebugGrpDefs(POMFWRITER pThis, POMFDETAILS pOmfStuff)
+{
+    if (   pOmfStuff->cSegLines == 0
+        || !pOmfStuff->fNeedsCGroup16)
+        return true;
+
+    if (pOmfStuff->iCGroup16Grp == UINT16_MAX)
+    {
+        if (pOmfStuff->iCGroup16Nm == UINT16_MAX)
+            if (   !omfWriter_LNamesBegin(pThis, true)
+                || !omfWriter_LNamesAdd(pThis, "CGROUP16", &pOmfStuff->iCGroup16Nm)
+                || !omfWriter_LNamesEnd(pThis))
+                return false;
+
+        if (   !omfWriter_GrpDefBegin(pThis, pOmfStuff->iCGroup16Nm)
+            || !omfWriter_GrpDefEnd(pThis))
+            return false;
+        pOmfStuff->iCGroup16Grp = pOmfStuff->cGrpDefs;
+    }
+
+    for (unsigned i = 0; i < pOmfStuff->cSegLines; i++)
+        if (pOmfStuff->paSegLines[i].idxGrp == 0)
+            pOmfStuff->paSegLines[i].idxGrp = pOmfStuff->iCGroup16Grp;
+    return true;
+}
+
+
+/**
  * Writes the debug segment data.
  *
@@ -4237,8 +4457,18 @@
                 return false;
 
+            /* Default to the segment (BS3TEXT32, BS3TEXT64) or the group (CGROUP16,
+               RMGROUP16, etc).  The important thing is that we're framing the fixups
+               using a segment or group which ends up in the codeview segment map. */
+            uint16_t idxFrame = pSegLines->idxSeg;
+            uint8_t  bFrame   = OMF_FIX_F_SEGDEF;
+            if (pSegLines->idxGrp != UINT16_MAX)
+            {
+                idxFrame = pSegLines->idxGrp;
+                bFrame   = OMF_FIX_F_GRPDEF;
+            }
+
             /* Fixup #1: segment offset - IMAGE_REL_AMD64_SECREL. */
             if (!omfWriter_LEDataAddFixupNoDisp(pThis, 4 + 4 + RT_OFFSETOF(RTCV8LINESHDR, offSection), OMF_FIX_LOC_32BIT_OFFSET,
-                                                OMF_FIX_F_SEGDEF, pSegLines->idxSeg,
-                                                OMF_FIX_T_SEGDEF_NO_DISP, pSegLines->idxSeg))
+                                                bFrame, idxFrame, OMF_FIX_T_SEGDEF_NO_DISP, pSegLines->idxSeg))
                 return false;
 
@@ -4246,6 +4476,5 @@
             /* Fixup #2: segment number - IMAGE_REL_AMD64_SECTION. */
             if (!omfWriter_LEDataAddFixupNoDisp(pThis, 4 + 4 + RT_OFFSETOF(RTCV8LINESHDR, iSection), OMF_FIX_LOC_16BIT_SEGMENT,
-                                                OMF_FIX_F_SEGDEF, pSegLines->idxSeg,
-                                                OMF_FIX_T_SEGDEF_NO_DISP, pSegLines->idxSeg))
+                                                bFrame, idxFrame, OMF_FIX_T_SEGDEF_NO_DISP, pSegLines->idxSeg))
                 return false;
 
@@ -4387,5 +4616,6 @@
                     fSkip = pbRec[1] == OMF_CCLS_BORLAND_SRC_FILE;
                     if (pbRec[1] == OMF_CCLS_LINK_PASS_SEP)
-                        if (!convertOmfWriteDebugSegDefs(pThis, pOmfStuff))
+                        if (   !convertOmfWriteDebugSegDefs(pThis, pOmfStuff)
+                            || !convertOmfWriteDebugGrpDefs(pThis, pOmfStuff))
                             return false;
                 }
@@ -4420,4 +4650,5 @@
                 {
                     if (   convertOmfWriteDebugSegDefs(pThis, pOmfStuff)
+                        && convertOmfWriteDebugGrpDefs(pThis, pOmfStuff)
                         && convertOmfWriteDebugData(pThis, pOmfStuff))
                     { /* likely */ }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac	(revision 60527)
@@ -34,11 +34,19 @@
 %include "bs3kit-template-header.mac"
 
+;
 ; Redefine some macros to suite us.
+;
+; We do near 16-bit code and produce far stubs separately as needed.
+;
 %define BEGINCODE               TMPL_BEGIN_TEXT
-%define BEGINPROC_EXPORTED      BS3_PROC_BEGIN_CMN
+%define BEGINPROC_EXPORTED      BS3_BEGINPROC_EXPORTED_WRAPPER
 %define ENDPROC                 BS3_PROC_END_CMN
 %undef  NAME
 %define NAME(a)                 BS3_CMN_NM(a)
 
+%macro BS3_BEGINPROC_EXPORTED_WRAPPER 1
+BS3_PROC_BEGIN_CMN %1, BS3_PBC_NEAR
+%endmacro
+
 %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-CreateHybridFarRet.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-CreateHybridFarRet.asm	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-CreateHybridFarRet.asm	(revision 60527)
@@ -0,0 +1,53 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3A20Disable.
+;
+
+;
+; 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"
+
+
+;;
+; Worker for BS3_PROC_BEGIN_CMN
+; @uses nothing
+BS3_PROC_BEGIN Bs3CreateHybridFarRet_c16
+        push    ax                      ; reserve space
+        push    bp
+        mov     bp, sp
+        push    ax                      ; save it
+
+        ; Move the return address up a word.
+        mov     ax, [bp + 4]
+        mov     [bp + 2], ax
+        ; Move the caller's return address up a word.
+        mov     ax, [bp + 6]
+        mov     [bp + 4], ax
+        ; Add CS to the caller's far return address.
+        mov     [bp + 6], cs
+
+        pop     ax
+        pop     bp
+        ret
+BS3_PROC_END   Bs3CreateHybridFarRet_c16
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Disable.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Disable.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Disable.asm	(revision 60527)
@@ -5,5 +5,5 @@
 
 ;
-; Copyright (C) 2007-2015 Oracle Corporation
+; Copyright (C) 2007-2016 Oracle Corporation
 ;
 ; This file is part of VirtualBox Open Source Edition (OSE), as
@@ -38,5 +38,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20Disable
+BS3_PROC_BEGIN_CMN Bs3A20Disable, BS3_PBC_HYBRID_0_ARGS
         ; Must call both because they may be ORed together on real HW.
         BS3_ONLY_64BIT_STMT sub     rsp, 20h
@@ -44,5 +44,5 @@
         call    BS3_CMN_NM(Bs3A20DisableViaPortA)
         BS3_ONLY_64BIT_STMT add     rsp, 20h
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20Disable
 
@@ -53,5 +53,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20DisableViaPortA
+BS3_PROC_BEGIN_CMN Bs3A20DisableViaPortA, BS3_PBC_HYBRID_0_ARGS
         push    xAX
 
@@ -65,5 +65,5 @@
 .done:
         pop     xAX
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20DisableViaPortA
 
@@ -74,5 +74,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20DisableViaKbd
+BS3_PROC_BEGIN_CMN Bs3A20DisableViaKbd, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
@@ -100,6 +100,6 @@
         popf
         pop     xAX
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20DisableViaKbd
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Enable.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Enable.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Enable.asm	(revision 60527)
@@ -38,5 +38,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20Enable
+BS3_PROC_BEGIN_CMN Bs3A20Enable, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
@@ -47,6 +47,6 @@
 ;        call    TMPL_NM_CMN(Bs3A20EnableViaKbd)
 
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20Enable
 
@@ -57,5 +57,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20EnableViaKbd
+BS3_PROC_BEGIN_CMN Bs3A20EnableViaKbd, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
@@ -83,6 +83,6 @@
         popf
         pop     xAX
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20EnableViaKbd
 
@@ -93,5 +93,5 @@
 ; @uses     Nothing.
 ;
-BS3_PROC_BEGIN_CMN Bs3A20EnableViaPortA
+BS3_PROC_BEGIN_CMN Bs3A20EnableViaPortA, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
@@ -107,6 +107,6 @@
 .done:
         pop     xAX
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3A20EnableViaPortA
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ConvertRMStackToP16UsingCxReturnToAx.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ConvertRMStackToP16UsingCxReturnToAx.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ConvertRMStackToP16UsingCxReturnToAx.asm	(revision 60527)
@@ -43,5 +43,5 @@
 ; @uses     cx, ss, esp
 ;
-BS3_PROC_BEGIN_CMN Bs3ConvertRMStackToP16UsingCxReturnToAx
+BS3_PROC_BEGIN_CMN Bs3ConvertRMStackToP16UsingCxReturnToAx, BS3_PBC_NEAR
 
         ;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdRead.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdRead.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdRead.asm	(revision 60527)
@@ -40,5 +40,5 @@
 ; @cproto   BS3_DECL(uint8_t) Bs3KbdRead_c16(uint8_t bCmd);
 ;
-BS3_PROC_BEGIN_CMN Bs3KbdRead
+BS3_PROC_BEGIN_CMN Bs3KbdRead, BS3_PBC_NEAR
         push    xBP
         mov     xBP, xSP
@@ -54,6 +54,12 @@
         in      al, 60h                 ; Read the data.
 
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3KbdRead
 
+;
+; We may be using the near code in some critical code paths, so don't
+; penalize it.
+;
+BS3_CMN_FAR_STUB   Bs3KbdRead, 2
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWait.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWait.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWait.asm	(revision 60527)
@@ -32,5 +32,5 @@
 ; @cproto   BS3_DECL(void) Bs3KbdWait_c16(void);
 ;
-BS3_PROC_BEGIN_CMN Bs3KbdWait
+BS3_PROC_BEGIN_CMN Bs3KbdWait, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
@@ -45,6 +45,6 @@
 
         pop     xAX
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 
 .read_data_and_status:
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWrite.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWrite.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWrite.asm	(revision 60527)
@@ -45,5 +45,5 @@
 ; @cproto   BS3_DECL(void) Bs3KbdWait_c16(uint8_t bCmd, uint8_t bData);
 ;
-BS3_PROC_BEGIN_CMN Bs3KbdWrite
+BS3_PROC_BEGIN_CMN Bs3KbdWrite, BS3_PBC_NEAR
         push    xBP
         mov     xBP, xSP
@@ -61,6 +61,12 @@
         BS3_ONLY_64BIT_STMT add     rsp, 20h
         pop     xAX
-        leave
-        ret
+        pop     xBP
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3KbdWrite
 
+;
+; We may be using the near code in some critical code paths, so don't
+; penalize it.
+;
+BS3_CMN_FAR_STUB   Bs3KbdWrite, 4
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c	(revision 60527)
@@ -33,5 +33,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3MemAlloc(BS3MEMKIND enmKind, size_t cb)
+#undef Bs3MemAlloc
+BS3_CMN_DEF(void BS3_FAR *, Bs3MemAlloc,(BS3MEMKIND enmKind, size_t cb))
 {
     void BS3_FAR   *pvRet;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3MemAllocZ(BS3MEMKIND enmKind, size_t cb)
+#undef Bs3MemAllocZ
+BS3_CMN_DEF(void BS3_FAR *, Bs3MemAllocZ,(BS3MEMKIND enmKind, size_t cb))
 {
     void BS3_FAR *pvRet = Bs3MemAlloc(enmKind, cb);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCpy.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCpy.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemCpy.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3MemCpy
-BS3_DECL(void BS3_FAR *) BS3_CMN_NM(Bs3MemCpy)(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy)
+BS3_CMN_DEF(void BS3_FAR *, Bs3MemCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy))
 {
 #if 1
@@ -74,3 +74,2 @@
 }
 
-
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(void) Bs3MemFree(void BS3_FAR *pv, size_t cb)
+#undef Bs3MemFree
+BS3_CMN_DEF(void, Bs3MemFree,(void BS3_FAR *pv, size_t cb))
 {
     if (pv != NULL)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemMove.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemMove.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemMove.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3MemMove
-BS3_DECL(void BS3_FAR *) BS3_CMN_NM(Bs3MemMove)(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy)
+BS3_CMN_DEF(void BS3_FAR *, Bs3MemMove,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy))
 {
     size_t          cLargeRounds;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemPCpy.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemPCpy.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemPCpy.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3MemPCpy
-BS3_DECL(void BS3_FAR *) BS3_CMN_NM(Bs3MemPCpy)(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy)
+BS3_CMN_DEF(void BS3_FAR *, Bs3MemPCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy))
 {
     size_t          cLargeRounds;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemZero.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemZero.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemZero.asm	(revision 60527)
@@ -30,5 +30,5 @@
 ; @cproto   BS3_DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);
 ;
-BS3_PROC_BEGIN_CMN Bs3MemZero
+BS3_PROC_BEGIN_CMN Bs3MemZero, BS3_PBC_HYBRID
 %ifdef RT_ARCH_AMD64
         push    rdi
@@ -46,5 +46,5 @@
 
         pop     rdi
-        ret
+        BS3_HYBRID_RET
 
 %elif ARCH_BITS == 16
@@ -54,14 +54,14 @@
         push    es
 
-        mov     di, [bp + 4]            ; pvDst.off
-        mov     dx, [bp + 4 + 2]        ; pvDst.sel
+        mov     di, [bp + 2 + cbCurRetAddr]     ; pvDst.off
+        mov     dx, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel
         mov     es, dx
-        mov     cx, [bp + 4 + 4]        ; cbDst
-        shr     cx, 1                   ; calc dword count.
+        mov     cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst
+        shr     cx, 1                           ; calc dword count.
         xor     ax, ax
         rep stosw
 
-        mov     cx, [bp + 4 + 4]        ; cbDst
-        and     cx, 1                   ; calc tailing byte count.
+        mov     cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst
+        and     cx, 1                           ; calc tailing byte count.
         rep stosb
 
@@ -69,5 +69,5 @@
         pop     di
         pop     bp
-        ret
+        BS3_HYBRID_RET
 
 %elif ARCH_BITS == 32
@@ -85,5 +85,5 @@
 
         pop     edi
-        ret
+        BS3_HYBRID_RET
 
 %else
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForLM.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForLM.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForLM.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(int) Bs3PagingInitRootForLM(void)
+#undef Bs3PagingInitRootForLM
+BS3_CMN_DEF(int, Bs3PagingInitRootForLM,(void))
 {
     X86PML4 BS3_FAR *pPml4;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPAE.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPAE.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPAE.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(int) Bs3PagingInitRootForPAE(void)
+#undef Bs3PagingInitRootForPAE
+BS3_CMN_DEF(int, Bs3PagingInitRootForPAE,(void))
 {
     X86PDPT BS3_FAR *pPdPtr;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPP.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPP.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingInitRootForPP.c	(revision 60527)
@@ -68,5 +68,6 @@
 
 
-BS3_DECL(int) Bs3PagingInitRootForPP(void)
+#undef Bs3PagingInitRootForPP
+BS3_CMN_DEF(int, Bs3PagingInitRootForPP,(void))
 {
     X86PD BS3_FAR *pPgDir;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingProtect.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingProtect.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PagingProtect.c	(revision 60527)
@@ -59,5 +59,6 @@
 
 
-BS3_DECL(X86PTE BS3_FAR *) bs3PagingGetLegacyPte(RTCCUINTXREG cr3, uint32_t uFlat, bool fUseInvlPg, int *prc)
+#undef bs3PagingGetLegacyPte
+BS3_CMN_DEF(X86PTE BS3_FAR *, bs3PagingGetLegacyPte,(RTCCUINTXREG cr3, uint32_t uFlat, bool fUseInvlPg, int *prc))
 {
     X86PTE BS3_FAR *pPTE = NULL;
@@ -120,5 +121,6 @@
 
 
-BS3_DECL(X86PTEPAE BS3_FAR *) bs3PagingGetPte(RTCCUINTXREG cr3, uint64_t uFlat, bool fUseInvlPg, int *prc)
+#undef bs3PagingGetPte
+BS3_CMN_DEF(X86PTEPAE BS3_FAR *, bs3PagingGetPte,(RTCCUINTXREG cr3, uint64_t uFlat, bool fUseInvlPg, int *prc))
 {
     X86PTEPAE BS3_FAR  *pPTE = NULL;
@@ -212,5 +214,6 @@
 
 
-BS3_DECL(int) Bs3PagingProtect(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear)
+#undef Bs3PagingProtect
+BS3_CMN_DEF(int, Bs3PagingProtect,(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear))
 {
     RTCCUINTXREG const  cr3        = ASMGetCR3();
@@ -242,5 +245,5 @@
         while ((uint32_t)cb > 0)
         {
-            PX86PTE pPte = bs3PagingGetLegacyPte(cr3, (uint32_t)uFlat, fUseInvlPg, &rc);
+            PX86PTE pPte = BS3_CMN_NM(bs3PagingGetLegacyPte)(cr3, (uint32_t)uFlat, fUseInvlPg, &rc);
             if (!pPte)
                 return rc;
@@ -267,5 +270,5 @@
         while (cb > 0)
         {
-            PX86PTEPAE pPte = bs3PagingGetPte(cr3, uFlat, fUseInvlPg, &rc);
+            PX86PTEPAE pPte = BS3_CMN_NM(bs3PagingGetPte)(cr3, uFlat, fUseInvlPg, &rc);
             if (!pPte)
                 return rc;
@@ -298,10 +301,11 @@
 
 
-BS3_DECL(int) Bs3PagingProtectPtr(void *pv, size_t cb, uint64_t fSet, uint64_t fClear)
+#undef Bs3PagingProtectPtr
+BS3_CMN_DEF(int, Bs3PagingProtectPtr,(void *pv, size_t cb, uint64_t fSet, uint64_t fClear))
 {
 #if ARCH_BITS == 16
-    return Bs3PagingProtect(Bs3SelPtrToFlat(pv), cb, fSet, fClear);
+    return BS3_CMN_NM(Bs3PagingProtect)(Bs3SelPtrToFlat(pv), cb, fSet, fClear);
 #else
-    return Bs3PagingProtect((uintptr_t)pv, cb, fSet, fClear);
+    return BS3_CMN_NM(Bs3PagingProtect)((uintptr_t)pv, cb, fSet, fClear);
 #endif
 }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Panic.asm	(revision 60527)
@@ -28,5 +28,5 @@
 
 
-BS3_PROC_BEGIN_CMN Bs3Panic
+BS3_PROC_BEGIN_CMN Bs3Panic, BS3_PBC_HYBRID_0_ARGS
         push    xBP
         mov     xBP, xSP
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PicMaskAll.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PicMaskAll.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PicMaskAll.c	(revision 60527)
@@ -33,5 +33,6 @@
 
 
-BS3_DECL(void) Bs3PicMaskAll(void)
+#undef Bs3PicMaskAll
+BS3_CMN_DEF(void, Bs3PicMaskAll,(void))
 {
     ASMOutU8(0xa1, 0xff);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm	(revision 60527)
@@ -46,5 +46,5 @@
 ; @cproto   BS3_DECL(void) Bs3PrintChr_c16(char ch);
 ;
-BS3_PROC_BEGIN_CMN Bs3PrintChr
+BS3_PROC_BEGIN_CMN Bs3PrintChr, BS3_PBC_NEAR
         BS3_CALL_CONV_PROLOG 1
         push    xBP
@@ -87,5 +87,5 @@
         mov     cl, [xBP + xCB*2]       ; Load the char
         mov     ax, BS3_SYSCALL_PRINT_CHR
-        call    Bs3Syscall              ; (no BS3_CALL!)
+        call    Bs3Syscall              ; near! no BS3_CALL!
 
 .return:
@@ -93,7 +93,13 @@
         pop     xCX
         pop     xAX
-        leave
+        pop     xBP
         BS3_CALL_CONV_EPILOG 1
         ret
 BS3_PROC_END_CMN   Bs3PrintChr
 
+;
+; Generate 16-bit far stub.
+; Peformance critical, so don't penalize near calls.
+;
+BS3_CMN_FAR_STUB Bs3PrintChr, 2
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStr.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStr.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStr.c	(revision 60527)
@@ -27,5 +27,6 @@
 #include "bs3kit-template-header.h"
 
-BS3_DECL(void) Bs3PrintStr(const char BS3_FAR *pszString)
+#undef Bs3PrintStr
+BS3_CMN_DEF(void, Bs3PrintStr,(const char BS3_FAR *pszString))
 {
     Bs3PrintStrN(pszString, Bs3StrLen(pszString));
Index: unk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm	(revision 60526)
+++ 	(revision )
@@ -1,77 +1,0 @@
-; $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     xSP, 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
-
-        add     xSP, 20h
-        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-PrintStrN.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrN.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrN.asm	(revision 60527)
@@ -48,5 +48,5 @@
 ; ASSUMES cchString < 64KB!
 ;
-BS3_PROC_BEGIN_CMN Bs3PrintStrN
+BS3_PROC_BEGIN_CMN Bs3PrintStrN, BS3_PBC_NEAR
         BS3_CALL_CONV_PROLOG 2
         push    xBP
@@ -74,7 +74,7 @@
 .do_bios_call:
         push    ds
-        lds     si, [xBP + xCB*2]       ; DS:SI -> string.
+        lds     si, [xBP + xCB + cbCurRetAddr]          ; DS:SI -> string.
         cld
-        mov     cx, [xBP + xCB*2 + sCB] ; Use CX for counting down.
+        mov     cx, [xBP + xCB + cbCurRetAddr + sCB]    ; Use CX for counting down.
         call    Bs3PrintStrN_c16_CX_Bytes_At_DS_SI
         pop     ds
@@ -92,10 +92,10 @@
 .do_system_call:
 %if TMPL_BITS == 16
-        mov     cx, [xBP + xCB*2 + 2]
+        mov     cx, [xBP + xCB + cbCurRetAddr + 2]
 %else
         mov     cx, ds
 %endif
-        mov     xSI, [xBP + xCB*2]
-        mov     dx, [xBP + xCB*2 + sCB]
+        mov     xSI, [xBP + xCB + cbCurRetAddr]
+        mov     dx,  [xBP + xCB + cbCurRetAddr + sCB]
 %if TMPL_BITS == 16
 
@@ -105,5 +105,5 @@
 %endif
         mov     ax, BS3_SYSCALL_PRINT_STR
-        call    Bs3Syscall              ; (no BS3_CALL!)
+        call    Bs3Syscall              ; near! no BS3_CALL!
 
 .return:
@@ -112,7 +112,7 @@
         pop     xCX
         pop     xAX
-        leave
+        pop     xBP
         BS3_CALL_CONV_EPILOG 2
-        ret
+        BS3_HYBRID_RET
 
         ;
@@ -130,5 +130,5 @@
         mov     ax, BS3_SYSCALL_PRINT_CHR
         mov     cl, [BS3_ONLY_16BIT(es:) xSI]
-        call    Bs3Syscall              ; (no BS3_CALL!)
+        call    Bs3Syscall              ; near! no BS3_CALL!
         inc     xSI
         dec     xDX
@@ -183,4 +183,12 @@
         jmp     .bios_loop_int10h
 BS3_PROC_END   Bs3PrintStrN_c16_CX_Bytes_At_DS_SI
+
+
+;
+; Generate 16-bit far stub.
+; Peformance critical, so don't penalize near calls.
+;
+BS3_CMN_FAR_STUB Bs3PrintStrN, 6
+
 %endif
 
Index: unk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrSpacesColonSpace.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrSpacesColonSpace.c	(revision 60526)
+++ 	(revision )
@@ -1,16 +1,0 @@
-
-
-#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 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm	(revision 60527)
@@ -35,5 +35,5 @@
 ; @param    [xBP + xCB*2]   32-bit value to format and print.
 ;
-BS3_PROC_BEGIN_CMN Bs3PrintU32
+BS3_PROC_BEGIN_CMN Bs3PrintU32, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 1
         push    xBP
@@ -45,5 +45,5 @@
         BS3_ONLY_16BIT_STMT push ds
 
-        mov     eax, [xBP + xCB*2]
+        mov     eax, [xBP + xCB + cbCurRetAddr]
 
         ; Allocate a stack buffer and terminate it. ds:bx points ot the end.
@@ -79,5 +79,5 @@
         leave
         BS3_CALL_CONV_EPILOG 1
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3PrintU32
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm	(revision 60527)
@@ -35,5 +35,5 @@
 ; @param    [xBP + xCB*2]   32-bit value to format and print.
 ;
-BS3_PROC_BEGIN_CMN Bs3PrintX32
+BS3_PROC_BEGIN_CMN Bs3PrintX32, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 1
         push    xBP
@@ -45,5 +45,5 @@
         BS3_ONLY_16BIT_STMT push ds
 
-        mov     eax, [xBP + xCB*2]
+        mov     eax, [xBP + xCB + cbCurRetAddr]
 
         ; Allocate a stack buffer and terminate it. ds:bx points ot the end.
@@ -83,5 +83,5 @@
         leave
         BS3_CALL_CONV_EPILOG 1
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3PrintX32
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Printf.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Printf.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Printf.c	(revision 60527)
@@ -64,5 +64,6 @@
 
 
-BS3_DECL(size_t) Bs3PrintfV(const char BS3_FAR *pszFormat, va_list va)
+#undef Bs3PrintfV
+BS3_CMN_DEF(size_t, Bs3PrintfV,(const char BS3_FAR *pszFormat, va_list va))
 {
     BS3PRINTBUF Buf;
@@ -72,10 +73,11 @@
 
 
-BS3_DECL(size_t) Bs3Printf(const char BS3_FAR *pszFormat, ...)
+#undef Bs3Printf
+BS3_CMN_DEF(size_t, Bs3Printf,(const char BS3_FAR *pszFormat, ...))
 {
     size_t cchRet;
     va_list va;
     va_start(va, pszFormat);
-    cchRet = Bs3PrintfV(pszFormat, va);
+    cchRet = BS3_CMN_NM(Bs3PrintfV)(pszFormat, va);
     va_end(va);
     return cchRet;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxConvertToRingX.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxConvertToRingX.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxConvertToRingX.c	(revision 60527)
@@ -139,5 +139,6 @@
  * @param   bRing       The target ring (0..3).
  */
-BS3_DECL(void) Bs3RegCtxConvertToRingX(PBS3REGCTX pRegCtx, uint8_t bRing)
+#undef Bs3RegCtxConvertToRingX
+BS3_CMN_DEF(void, Bs3RegCtxConvertToRingX,(PBS3REGCTX pRegCtx, uint8_t bRing))
 {
     if (   (pRegCtx->rflags.u32 & X86_EFL_VM)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxPrint.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxPrint.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxPrint.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3RegCtxPrint(PCBS3REGCTX pRegCtx)
+#undef Bs3RegCtxPrint
+BS3_CMN_DEF(void, Bs3RegCtxPrint,(PCBS3REGCTX pRegCtx))
 {
     //if (BS3_MODE_IS_64BIT_CODE(pRegCtx->bMode))
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm	(revision 60527)
@@ -47,15 +47,17 @@
 ; @note         Only respects the BS3_MODE_CODE_MASK part of pRegCtx->bMode.
 ;
-%if TMPL_BITS == 16 || TMPL_BITS == 32
-BS3_PROC_BEGIN_CMN Bs3RegCtxRestore_aborts ; special entry point for when watcom applies __aborts
- %if TMPL_BITS == 16
+%if TMPL_BITS == 16
+BS3_PROC_BEGIN_CMN Bs3RegCtxRestore_aborts, BS3_PBC_FAR  ; special entry point for when watcom applies __aborts
+BS3_PROC_BEGIN_CMN Bs3RegCtxRestore_aborts, BS3_PBC_NEAR ; special entry point for when watcom applies __aborts
         CPU 8086
         xor     xAX, xAX
         push    xAX                     ; fake return address.
- %else
+        push    xAX
+        jmp     _Bs3RegCtxRestore_f16
+%elif TMPL_BITS == 32
+BS3_PROC_BEGIN_CMN Bs3RegCtxRestore_aborts, BS3_PBC_NEAR ; special entry point for when watcom applies __aborts
         push    0feedfaceh              ; fake return address.
- %endif
-%endif
-BS3_PROC_BEGIN_CMN Bs3RegCtxRestore
+%endif
+BS3_PROC_BEGIN_CMN Bs3RegCtxRestore, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 2
         push    xBP
@@ -71,7 +73,7 @@
         jz      .in_ring0
 %if TMPL_BITS == 16
-        mov     si, [bp + 4]
-        mov     cx, [bp + 4+2]
-        mov     dx, [bp + 8]
+        mov     si, [bp + xCB + cbCurRetAddr]
+        mov     cx, [bp + xCB + cbCurRetAddr + 2]
+        mov     dx, [bp + xCB + cbCurRetAddr + sCB]
         mov     ax, BS3_SYSCALL_RESTORE_CTX
 %else
@@ -91,6 +93,6 @@
         mov     ax, BS3_SEL_DATA16
         mov     es, ax
-        lds     bx, [bp + 4]
-        mov     cx, [bp + 8]
+        lds     bx, [bp + xCB + cbCurRetAddr]
+        mov     cx, [bp + xCB + cbCurRetAddr + sCB]
 %elif TMPL_BITS == 32
         mov     ax, BS3_SEL_R0_DS32
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSave.asm	(revision 60527)
@@ -38,10 +38,10 @@
 
 ;;
-; Restores the given register context.
+; Saves the current register context.
 ;
 ; @param        pRegCtx
 ; @uses         None.
 ;
-BS3_PROC_BEGIN_CMN Bs3RegCtxSave
+BS3_PROC_BEGIN_CMN Bs3RegCtxSave, BS3_PBC_HYBRID_SAFE
         TMPL_ONLY_16BIT_STMT CPU 8086
         BS3_CALL_CONV_PROLOG 1
@@ -56,14 +56,4 @@
 
         ;
-        ; Prologue. Load ES:xDI with pRegCtx.
-        ; (ASSUMES ds is BS3KIT_GRPNM_DATA16/FLAT of course.)
-        ;
-%if TMPL_BITS == 16
-        les     di, [bp + 4]
-%else
-        mov     xDI, [xBP + xCB*2]
-%endif
-
-        ;
         ; Clear the whole structure first.
         ;
@@ -72,13 +62,13 @@
         AssertCompileSizeAlignment(BS3REGCTX, 4)
 %if TMPL_BITS == 16
-        les     xDI, [xBP + xCB*2]
+        les     xDI, [xBP + xCB + cbCurRetAddr]
         mov     xCX, BS3REGCTX_size / 2
         rep stosw
 %else
-        mov     xDI, [xBP + xCB*2]
+        mov     xDI, [xBP + xCB + cbCurRetAddr]
         mov     xCX, BS3REGCTX_size / 4
         rep stosd
 %endif
-        mov     xDI, [xBP + xCB*2]
+        mov     xDI, [xBP + xCB + cbCurRetAddr]
 
         ;
@@ -201,4 +191,6 @@
 .common_80286:
         TMPL_ONLY_16BIT_STMT CPU 286
+        cmp     cl, BS3_MODE_RM
+        je      .common_ancient
         str     [xDI + BS3REGCTX.tr]
         sldt    [xDI + BS3REGCTX.ldtr]
@@ -219,9 +211,10 @@
         mov     xAX, [xBP + xCB]
         mov     [xDI + BS3REGCTX.rip], xAX
-        lea     xAX, [xBP + xCB*2]
+        lea     xAX, [xBP + xCB + cbCurRetAddr]
         mov     [xDI + BS3REGCTX.rsp], xAX
 
-        mov     [xDI + BS3REGCTX.cs], cs
-%if TMPL_BITS == 16
+%if TMPL_BITS == 16
+        mov     ax, [xBP + xCB + 2]
+        mov     [xDI + BS3REGCTX.cs], ax
         mov     ax, [xBP - xCB*6]
         mov     [xDI + BS3REGCTX.ds], ax
@@ -229,4 +222,5 @@
         mov     [xDI + BS3REGCTX.es], ax
 %else
+        mov     [xDI + BS3REGCTX.cs], cs
         mov     [xDI + BS3REGCTX.ds], ds
         mov     [xDI + BS3REGCTX.es], es
@@ -245,5 +239,5 @@
         xPOPF
         pop     xBP
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3RegCtxSave
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelFar32ToFlat32.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelFar32ToFlat32.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelFar32ToFlat32.c	(revision 60527)
@@ -28,5 +28,6 @@
 
 
-BS3_DECL(uint32_t) Bs3SelFar32ToFlat32(uint32_t off, uint16_t uSel)
+#undef Bs3SelFar32ToFlat32
+BS3_CMN_DEF(uint32_t, Bs3SelFar32ToFlat32,(uint32_t off, uint16_t uSel))
 {
     if (g_bBs3CurrentMode == BS3_MODE_RM)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelProtFar32ToFlat32.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelProtFar32ToFlat32.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelProtFar32ToFlat32.c	(revision 60527)
@@ -28,5 +28,6 @@
 
 
-BS3_DECL(uint32_t) Bs3SelProtFar32ToFlat32(uint32_t off, uint16_t uSel)
+#undef Bs3SelProtFar32ToFlat32
+BS3_CMN_DEF(uint32_t, Bs3SelProtFar32ToFlat32,(uint32_t off, uint16_t uSel))
 {
     uint32_t    uRet;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Shutdown.asm	(revision 60527)
@@ -29,5 +29,5 @@
 BS3_EXTERN_CMN Bs3Panic
 
-BS3_PROC_BEGIN_CMN Bs3Shutdown
+BS3_PROC_BEGIN_CMN Bs3Shutdown, BS3_PBC_HYBRID_0_ARGS
         cli
         mov     bl, 64
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3SlabAlloc(PBS3SLABCTL pSlabCtl)
+#undef Bs3SlabAlloc
+BS3_CMN_DEF(void BS3_FAR *, Bs3SlabAlloc,(PBS3SLABCTL pSlabCtl))
 {
     if (pSlabCtl->cFreeChunks)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags)
+#undef Bs3SlabAllocEx
+BS3_CMN_DEF(void BS3_FAR *, Bs3SlabAllocEx,(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags))
 {
     BS3_ASSERT(cChunks > 0);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(uint16_t) Bs3SlabFree(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks)
+#undef Bs3SlabFree
+BS3_CMN_DEF(uint16_t, Bs3SlabFree,(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks))
 {
     uint16_t cFreed = 0;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c	(revision 60527)
@@ -32,5 +32,6 @@
 
 
-BS3_DECL(void) Bs3SlabInit(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk)
+#undef Bs3SlabInit
+BS3_CMN_DEF(void, Bs3SlabInit,(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk))
 {
     uint16_t cBits;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c	(revision 60527)
@@ -28,5 +28,6 @@
 
 
-BS3_DECL(void) Bs3SlabListAdd(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl)
+#undef Bs3SlabListAdd
+BS3_CMN_DEF(void, Bs3SlabListAdd,(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl))
 {
     BS3_ASSERT(pHead->cbChunk == pSlabCtl->cbChunk);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc(PBS3SLABHEAD pHead)
+#undef Bs3SlabListAlloc
+BS3_CMN_DEF(void BS3_FAR *, Bs3SlabListAlloc,(PBS3SLABHEAD pHead))
 {
     if (pHead->cFreeChunks)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags)
+#undef Bs3SlabListAllocEx
+BS3_CMN_DEF(void BS3_FAR *, Bs3SlabListAllocEx,(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags))
 {
     BS3_ASSERT(!(fFlags & ~BS3_SLAB_ALLOC_F_SAME_TILE));
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c	(revision 60527)
@@ -28,5 +28,6 @@
 
 
-BS3_DECL(void) Bs3SlabListFree(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks)
+#undef Bs3SlabListFree
+BS3_CMN_DEF(void, Bs3SlabListFree,(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks))
 {
     BS3_ASSERT(cChunks > 0);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c	(revision 60527)
@@ -28,5 +28,6 @@
 
 
-BS3_DECL(void) Bs3SlabListInit(PBS3SLABHEAD pHead, uint16_t cbChunk)
+#undef Bs3SlabListInit
+BS3_CMN_DEF(void, Bs3SlabListInit,(PBS3SLABHEAD pHead, uint16_t cbChunk))
 {
     BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk));
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrCpy.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrCpy.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrCpy.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3StrCpy
-BS3_DECL(char BS3_FAR *) BS3_CMN_NM(Bs3StrCpy)(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc)
+BS3_CMN_DEF(char BS3_FAR *, Bs3StrCpy,(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc))
 {
     char BS3_FAR *pszRet = pszDst;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrFormatV.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrFormatV.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrFormatV.c	(revision 60527)
@@ -359,6 +359,7 @@
 
 
-BS3_DECL(size_t) Bs3StrFormatV(const char BS3_FAR *pszFormat, va_list va,
-                               PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser)
+#undef Bs3StrFormatV
+BS3_CMN_DEF(size_t, Bs3StrFormatV,(const char BS3_FAR *pszFormat, va_list va,
+                               PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser))
 {
     BS3FMTSTATE State;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrLen.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrLen.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrLen.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3StrLen
-BS3_DECL(size_t) BS3_CMN_NM(Bs3StrLen)(const char BS3_FAR *pszString)
+BS3_CMN_DEF(size_t, Bs3StrLen,(const char BS3_FAR *pszString))
 {
     size_t cch = 0;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrNLen.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrNLen.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrNLen.c	(revision 60527)
@@ -28,5 +28,5 @@
 
 #undef Bs3StrNLen
-BS3_DECL(size_t) BS3_CMN_NM(Bs3StrNLen)(const char BS3_FAR *pszString, size_t cchMax)
+BS3_CMN_DEF(size_t, Bs3StrNLen,(const char BS3_FAR *pszString, size_t cchMax))
 {
     size_t cch = 0;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrPrintf.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrPrintf.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-StrPrintf.c	(revision 60527)
@@ -73,5 +73,6 @@
 
 
-BS3_DECL(size_t) Bs3StrPrintfV(char BS3_FAR *pszBuf, size_t cchBuf, const char BS3_FAR *pszFormat, va_list va)
+#undef Bs3StrPrintfV
+BS3_CMN_DEF(size_t, Bs3StrPrintfV,(char BS3_FAR *pszBuf, size_t cchBuf, const char BS3_FAR *pszFormat, va_list va))
 {
     BS3STRPRINTFSTATE State;
@@ -82,10 +83,11 @@
 
 
-BS3_DECL(size_t) Bs3StrPrintf(char BS3_FAR *pszBuf, size_t cchBuf, const char BS3_FAR *pszFormat, ...)
+#undef Bs3StrPrintf
+BS3_CMN_DEF(size_t, Bs3StrPrintf,(char BS3_FAR *pszBuf, size_t cchBuf, const char BS3_FAR *pszFormat, ...))
 {
     size_t cchRet;
     va_list va;
     va_start(va, pszFormat);
-    cchRet = Bs3StrPrintfV(pszBuf, cchBuf, pszFormat, va);
+    cchRet = BS3_CMN_NM(Bs3StrPrintfV)(pszBuf, cchBuf, pszFormat, va);
     va_end(va);
     return cchRet;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm	(revision 60527)
@@ -38,5 +38,5 @@
 ; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchTo16Bit
+BS3_PROC_BEGIN_CMN Bs3SwitchTo16Bit, BS3_PBC_NEAR
 %if TMPL_BITS == 16
         push    ax
@@ -117,2 +117,4 @@
 BS3_PROC_END_CMN   Bs3SwitchTo16Bit
 
+;; @todo far 16-bit variant.
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16BitV86.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16BitV86.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16BitV86.asm	(revision 60527)
@@ -40,5 +40,5 @@
 ;       values and the stack register converted to real mode (not ebp).
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchTo16BitV86
+BS3_PROC_BEGIN_CMN Bs3SwitchTo16BitV86, BS3_PBC_NEAR
         ; Construct basic v8086 return frame.
         BS3_ONLY_16BIT_STMT movzx   esp, sp
@@ -118,4 +118,6 @@
 BS3_PROC_END_CMN   Bs3SwitchTo16BitV86
 
+;; @todo far 16-bit variant.
+
 %endif ; ! 64-bit
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm	(revision 60527)
@@ -43,5 +43,5 @@
 ; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchTo32Bit
+BS3_PROC_BEGIN_CMN Bs3SwitchTo32Bit, BS3_PBC_NEAR
 %if TMPL_BITS == 32
         ret
@@ -148,2 +148,4 @@
 BS3_PROC_END_CMN   Bs3SwitchTo32Bit
 
+;; @todo far 16-bit variant.
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm	(revision 60527)
@@ -37,6 +37,7 @@
 ;
 ; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
+; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchTo64Bit
+BS3_PROC_BEGIN_CMN Bs3SwitchTo64Bit, BS3_PBC_NEAR
 %if TMPL_BITS == 64
         ret
@@ -105,2 +106,5 @@
 BS3_PROC_END_CMN   Bs3SwitchTo64Bit
 
+
+;; @todo far 16-bit variant.
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ;*  External Symbols                                                                                                             *
 ;*********************************************************************************************************************************
-BS3_EXTERN_CMN Bs3SwitchToRingX
+BS3_EXTERN_CMN_FAR Bs3SwitchToRingX
 TMPL_BEGIN_TEXT
 
@@ -44,5 +44,5 @@
 ; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchToRing0
+BS3_PROC_BEGIN_CMN Bs3SwitchToRing0, BS3_PBC_HYBRID_0_ARGS
 %if TMPL_BITS == 64
         push    rcx
@@ -55,8 +55,9 @@
 %else
         push    0
+        TMPL_ONLY_16BIT_STMT push cs
         call    Bs3SwitchToRingX
         add     xSP, xCB
 %endif
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3SwitchToRing0
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ;*  External Symbols                                                                                                             *
 ;*********************************************************************************************************************************
-BS3_EXTERN_CMN Bs3SwitchToRingX
+BS3_EXTERN_CMN_FAR Bs3SwitchToRingX
 TMPL_BEGIN_TEXT
 
@@ -44,5 +44,5 @@
 ; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchToRing1
+BS3_PROC_BEGIN_CMN Bs3SwitchToRing1, BS3_PBC_HYBRID_0_ARGS
 %if TMPL_BITS == 64
         push    rcx
@@ -55,8 +55,9 @@
 %else
         push    1
+        TMPL_ONLY_16BIT_STMT push cs
         call    Bs3SwitchToRingX
         add     xSP, xCB
 %endif
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3SwitchToRing1
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ;*  External Symbols                                                                                                             *
 ;*********************************************************************************************************************************
-BS3_EXTERN_CMN Bs3SwitchToRingX
+BS3_EXTERN_CMN_FAR Bs3SwitchToRingX
 TMPL_BEGIN_TEXT
 
@@ -44,5 +44,5 @@
 ; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchToRing2
+BS3_PROC_BEGIN_CMN Bs3SwitchToRing2, BS3_PBC_HYBRID_0_ARGS
 %if TMPL_BITS == 64
         push    rcx
@@ -55,8 +55,9 @@
 %else
         push    2
+        TMPL_ONLY_16BIT_STMT push cs
         call    Bs3SwitchToRingX
         add     xSP, xCB
 %endif
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3SwitchToRing2
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ;*  External Symbols                                                                                                             *
 ;*********************************************************************************************************************************
-BS3_EXTERN_CMN Bs3SwitchToRingX
+BS3_EXTERN_CMN_FAR Bs3SwitchToRingX
 TMPL_BEGIN_TEXT
 
@@ -44,5 +44,5 @@
 ; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchToRing3
+BS3_PROC_BEGIN_CMN Bs3SwitchToRing3, BS3_PBC_HYBRID_0_ARGS
 %if TMPL_BITS == 64
         push    rcx
@@ -55,8 +55,9 @@
 %else
         push    3
+        TMPL_ONLY_16BIT_STMT push cs
         call    Bs3SwitchToRingX
         add     xSP, xCB
 %endif
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3SwitchToRing3
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRingX.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRingX.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRingX.asm	(revision 60527)
@@ -43,5 +43,5 @@
 ; @uses     No GPRs.
 ;
-BS3_PROC_BEGIN_CMN Bs3SwitchToRingX
+BS3_PROC_BEGIN_CMN Bs3SwitchToRingX, BS3_PBC_HYBRID_SAFE
         BS3_CALL_CONV_PROLOG 1
         push    xBP
@@ -65,10 +65,10 @@
         mov     ax, cs
         and     al, 3
-        cmp     al, byte [xBP + xCB*2]
+        cmp     al, byte [xBP + xCB + cbCurRetAddr]
         je      .return
 
 .just_do_it:
         mov     xAX, BS3_SYSCALL_TO_RING0
-        add     al, [xBP + xCB*2]
+        add     al, [xBP + xCB + cbCurRetAddr]
         call    Bs3Syscall
 
@@ -80,10 +80,10 @@
         pop     xBP
         BS3_CALL_CONV_EPILOG 1
-        ret
+        BS3_HYBRID_RET
 
 %ifdef BS3_STRICT
 ; In real mode, only ring-0 makes any sense.
 .return_real_mode:
-        cmp     byte [xBP + xCB*2], 0
+        cmp     byte [xBP + xCB + cbCurRetAddr], 0
         je      .return
         int3
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Syscall.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Syscall.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Syscall.asm	(revision 60527)
@@ -51,5 +51,5 @@
 ; @uses     Whatever the syscall modified (xBX and XBP are always saved).
 ;
-BS3_PROC_BEGIN_CMN Bs3Syscall
+BS3_PROC_BEGIN_CMN Bs3Syscall, BS3_PBC_HYBRID_0_ARGS ; (all parameters are in registers)
         push    xBP
         mov     xBP, xSP
@@ -80,5 +80,5 @@
         pop     xBX
         pop     xBP
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3Syscall
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestCheckRegCtxEx.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestCheckRegCtxEx.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestCheckRegCtxEx.c	(revision 60527)
@@ -32,6 +32,7 @@
 
 
-BS3_DECL(bool) Bs3TestCheckRegCtxEx(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust, int16_t cbSpAcjust,
-                                    uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep)
+#undef Bs3TestCheckRegCtxEx
+BS3_CMN_DEF(bool, Bs3TestCheckRegCtxEx,(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust, int16_t cbSpAcjust,
+                                        uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep))
 {
     uint16_t cErrorsBefore = Bs3TestSubErrorCount();
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestFailed.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestFailed.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestFailed.c	(revision 60527)
@@ -95,5 +95,6 @@
  * Equivalent to RTTestIFailedV.
  */
-BS3_DECL(void) Bs3TestFailedV(const char *pszFormat, va_list va)
+#undef Bs3TestFailedV
+BS3_CMN_DEF(void, Bs3TestFailedV,(const char *pszFormat, va_list va))
 {
     BS3TESTFAILEDBUF Buf;
@@ -118,9 +119,10 @@
  * Equivalent to RTTestIFailedF.
  */
-BS3_DECL(void) Bs3TestFailedF(const char *pszFormat, ...)
+#undef Bs3TestFailedF
+BS3_CMN_DEF(void, Bs3TestFailedF,(const char *pszFormat, ...))
 {
     va_list va;
     va_start(va, pszFormat);
-    Bs3TestFailedV(pszFormat, va);
+    BS3_CMN_NM(Bs3TestFailedV)(pszFormat, va);
     va_end(va);
 }
@@ -130,7 +132,8 @@
  * Equivalent to RTTestIFailed.
  */
-BS3_DECL(void) Bs3TestFailed(const char *pszMessage)
+#undef Bs3TestFailed
+BS3_CMN_DEF(void, Bs3TestFailed,(const char *pszMessage))
 {
-    Bs3TestFailedF("%s", pszMessage);
+    BS3_CMN_NM(Bs3TestFailedF)("%s", pszMessage);
 }
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c	(revision 60527)
@@ -38,5 +38,6 @@
  * @param   pszTest         The test name.
  */
-BS3_DECL(void) Bs3TestInit(const char BS3_FAR *pszTest)
+#undef Bs3TestInit
+BS3_CMN_DEF(void, Bs3TestInit,(const char BS3_FAR *pszTest))
 {
     /*
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestIsVmmDevTestingPresent.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestIsVmmDevTestingPresent.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestIsVmmDevTestingPresent.asm	(revision 60527)
@@ -38,5 +38,5 @@
 ; @cproto   BS3_DECL(bool) bs3TestIsVmmDevTestingPresent_c16(void);
 ;
-BS3_PROC_BEGIN_CMN bs3TestIsVmmDevTestingPresent
+BS3_PROC_BEGIN_CMN bs3TestIsVmmDevTestingPresent, BS3_PBC_HYBRID_0_ARGS
         BS3_CALL_CONV_PROLOG 2
         push    xBP
@@ -59,5 +59,5 @@
         pop     xBP
         BS3_CALL_CONV_EPILOG 2
-        ret
+        BS3_HYBRID_RET
 
 .ancient_cpu:
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestPrintf.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestPrintf.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestPrintf.c	(revision 60527)
@@ -115,5 +115,6 @@
 
 
-BS3_DECL(void) Bs3TestPrintfV(const char BS3_FAR *pszFormat, va_list va)
+#undef Bs3TestPrintfV
+BS3_CMN_DEF(void, Bs3TestPrintfV,(const char BS3_FAR *pszFormat, va_list va))
 {
     BS3TESTPRINTBUF Buf;
@@ -125,9 +126,10 @@
 
 
-BS3_DECL(void) Bs3TestPrintf(const char BS3_FAR *pszFormat, ...)
+#undef Bs3TestPrintf
+BS3_CMN_DEF(void, Bs3TestPrintf,(const char BS3_FAR *pszFormat, ...))
 {
     va_list va;
     va_start(va, pszFormat);
-    Bs3TestPrintfV(pszFormat, va);
+    BS3_CMN_NM(Bs3TestPrintfV)(pszFormat, va);
     va_end(va);
 }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithStr.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithStr.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithStr.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ; @cproto   BS3_DECL(void) bs3TestSendCmdWithStr_c16(uint32_t uCmd, const char BS3_FAR *pszString);
 ;
-BS3_PROC_BEGIN_CMN bs3TestSendCmdWithStr
+BS3_PROC_BEGIN_CMN bs3TestSendCmdWithStr, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 2
         push    xBP
@@ -49,8 +49,8 @@
         mov     dx, VMMDEV_TESTING_IOPORT_CMD
 %if TMPL_BITS == 16
-        mov     ax, [xBP + xCB*2]       ; We ignore the top bits in 16-bit mode.
+        mov     ax, [xBP + xCB + cbCurRetAddr]  ; We ignore the top bits in 16-bit mode.
         out     dx, ax
 %else
-        mov     eax, [xBP + xCB*2]
+        mov     eax, [xBP + xCB + cbCurRetAddr]
         out     dx, eax
 %endif
@@ -59,7 +59,7 @@
         mov     dx, VMMDEV_TESTING_IOPORT_DATA
 %if TMPL_BITS == 16
-        lds     si, [xBP + xCB*2 + sCB]
+        lds     si,  [xBP + xCB + cbCurRetAddr + sCB]
 %else
-        mov     xSI, [xBP + xCB*2 + sCB]
+        mov     xSI, [xBP + xCB + cbCurRetAddr + sCB]
 %endif
 .next_char:
@@ -74,7 +74,7 @@
         pop     xDX
         pop     xAX
-        leave
+        pop     xBP
         BS3_CALL_CONV_EPILOG 2
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   bs3TestSendCmdWithStr
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithU32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithU32.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSendCmdWithU32.asm	(revision 60527)
@@ -34,5 +34,5 @@
 ; @cproto   BS3_DECL(void) bs3TestSendCmdWithU32_c16(uint32_t uCmd, uint32_t uValue);
 ;
-BS3_PROC_BEGIN_CMN bs3TestSendCmdWithU32
+BS3_PROC_BEGIN_CMN bs3TestSendCmdWithU32, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 2
         push    xBP
@@ -48,5 +48,5 @@
         mov     dx, VMMDEV_TESTING_IOPORT_CMD
 %if TMPL_BITS == 16
-        mov     ax, [xBP + xCB*2]       ; We ignore the top bits in 16-bit mode.
+        mov     ax, [xBP + xCB + cbCurRetAddr] ; We ignore the top bits in 16-bit mode.
         out     dx, ax
 %else
@@ -59,7 +59,7 @@
         mov     dx, VMMDEV_TESTING_IOPORT_DATA
 %if TMPL_BITS == 16
-        mov     ax, [xBP + xCB*2 + sCB]
+        mov     ax, [xBP + xCB + cbCurRetAddr + sCB]
         out     dx, ax
-        mov     ax, [xBP + xCB*2 + sCB + 2]
+        mov     ax, [xBP + xCB + cbCurRetAddr + sCB + 2]
         out     dx, ax
 %else
@@ -75,7 +75,7 @@
         pop     xDX
         pop     xAX
-        leave
+        pop     xBP
         BS3_CALL_CONV_EPILOG 2
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   bs3TestSendCmdWithU32
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSkipped.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSkipped.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSkipped.c	(revision 60527)
@@ -37,5 +37,6 @@
  * Equivalent to RTTestSkippedV.
  */
-BS3_DECL(void) Bs3TestSkippedV(const char *pszFormat, va_list va)
+#undef Bs3TestSkippedV
+BS3_CMN_DEF(void, Bs3TestSkippedV,(const char *pszFormat, va_list va))
 {
     if (g_cusBs3TestErrors == g_cusBs3SubTestAtErrors)
@@ -69,9 +70,10 @@
  * Equivalent to RTTestSkipped.
  */
-BS3_DECL(void) Bs3TestSkippedF(const char *pszFormat, ...)
+#undef Bs3TestSkippedF
+BS3_CMN_DEF(void, Bs3TestSkippedF,(const char *pszFormat, ...))
 {
     va_list va;
     va_start(va, pszFormat);
-    Bs3TestSkippedV(pszFormat, va);
+    BS3_CMN_NM(Bs3TestSkippedV)(pszFormat, va);
     va_end(va);
 }
@@ -81,7 +83,8 @@
  * Equivalent to RTTestSkipped.
  */
-BS3_DECL(void) Bs3TestSkipped(const char *pszWhy)
+#undef Bs3TestSkipped
+BS3_CMN_DEF(void, Bs3TestSkipped,(const char *pszWhy))
 {
-    Bs3TestSkippedF(pszWhy ? "%s" : NULL, pszWhy);
+    BS3_CMN_NM(Bs3TestSkippedF)(pszWhy ? "%s" : NULL, pszWhy);
 }
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSub.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSub.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSub.c	(revision 60527)
@@ -37,5 +37,6 @@
  * Equivalent to RTTestISubV.
  */
-BS3_DECL(void) Bs3TestSubV(const char *pszFormat, va_list va)
+#undef Bs3TestSubV
+BS3_CMN_DEF(void, Bs3TestSubV,(const char *pszFormat, va_list va))
 {
     size_t cch;
@@ -70,9 +71,10 @@
  * Equivalent to RTTestIFailedF.
  */
-BS3_DECL(void) Bs3TestSubF(const char *pszFormat, ...)
+#undef Bs3TestSubF
+BS3_CMN_DEF(void, Bs3TestSubF,(const char *pszFormat, ...))
 {
     va_list va;
     va_start(va, pszFormat);
-    Bs3TestSubV(pszFormat, va);
+    BS3_CMN_NM(Bs3TestSubV)(pszFormat, va);
     va_end(va);
 }
@@ -82,7 +84,8 @@
  * Equivalent to RTTestISub.
  */
-BS3_DECL(void) Bs3TestSub(const char *pszMessage)
+#undef Bs3TestSub
+BS3_CMN_DEF(void, Bs3TestSub,(const char *pszMessage))
 {
-    Bs3TestSubF("%s", pszMessage);
+    BS3_CMN_NM(Bs3TestSubF)("%s", pszMessage);
 }
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubDone.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubDone.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubDone.c	(revision 60527)
@@ -37,5 +37,6 @@
  * Equivalent to RTTestISubDone.
  */
-BS3_DECL(void) Bs3TestSubDone(void)
+#undef Bs3TestSubDone
+BS3_CMN_DEF(void, Bs3TestSubDone,(void))
 {
     bs3TestSubCleanup();
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubErrorCount.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubErrorCount.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestSubErrorCount.c	(revision 60527)
@@ -37,5 +37,6 @@
  * Equivalent to RTTestSubErrorCount.
  */
-BS3_DECL(uint16_t) Bs3TestSubErrorCount(void)
+#undef Bs3TestSubErrorCount
+BS3_CMN_DEF(uint16_t, Bs3TestSubErrorCount,(void))
 {
     return g_cusBs3TestErrors - g_cusBs3SubTestAtErrors;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestTerm.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestTerm.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestTerm.c	(revision 60527)
@@ -77,5 +77,6 @@
  * Equivalent to RTTestSummaryAndDestroy.
  */
-BS3_DECL(void) Bs3TestTerm(void)
+#undef Bs3TestTerm
+BS3_CMN_DEF(void, Bs3TestTerm,(void))
 {
     /*
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c	(revision 60527)
@@ -45,5 +45,6 @@
 
 
-BS3_DECL(void) Bs3Trap16InitEx(bool f386Plus)
+#undef Bs3Trap16InitEx
+BS3_CMN_DEF(void, Bs3Trap16InitEx,(bool f386Plus))
 {
     X86TSS16 BS3_FAR *pTss;
@@ -68,10 +69,8 @@
      * IDT entries, except the system call gate.
      */
-    for (iIdt = 0; iIdt < BS3_TRAP_SYSCALL; iIdt++)
-        Bs3Trap16SetGate(iIdt, X86_SEL_TYPE_SYS_286_INT_GATE, 0 /*bDpl*/,
-                         BS3_SEL_R0_CS16, (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIdt * 8, 0 /*cParams*/);
-    for (iIdt = BS3_TRAP_SYSCALL + 1; iIdt < 256; iIdt++)
-        Bs3Trap16SetGate(iIdt, X86_SEL_TYPE_SYS_286_INT_GATE, 0 /*bDpl*/,
-                         BS3_SEL_R0_CS16, (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIdt * 8, 0 /*cParams*/);
+    for (iIdt = 0; iIdt < 256; iIdt++)
+        if (iIdt != BS3_TRAP_SYSCALL)
+            Bs3Trap16SetGate(iIdt, X86_SEL_TYPE_SYS_286_INT_GATE, 0 /*bDpl*/,
+                             BS3_SEL_R0_CS16, (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIdt * 8, 0 /*cParams*/);
 
     /*
@@ -112,7 +111,8 @@
 
 
-BS3_DECL(void) Bs3Trap16Init(void)
+#undef Bs3Trap16Init
+BS3_CMN_DEF(void, Bs3Trap16Init,(void))
 {
-    Bs3Trap16InitEx((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386);
+    BS3_CMN_NM(Bs3Trap16InitEx)((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386);
 }
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16SetGate.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16SetGate.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16SetGate.c	(revision 60527)
@@ -1,5 +1,5 @@
 /* $Id$ */
 /** @file
- * BS3Kit - Bs3Trap32SetGate
+ * BS3Kit - Bs3Trap16SetGate
  */
 
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3Trap16SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams)
+#undef Bs3Trap16SetGate
+BS3_CMN_DEF(void, Bs3Trap16SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams))
 {
     X86DESC BS3_FAR *pIdte = &Bs3Idt16[iIdt];
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c	(revision 60527)
@@ -38,5 +38,6 @@
 
 
-BS3_DECL(void) Bs3Trap32Init(void)
+#undef Bs3Trap32Init
+BS3_CMN_DEF(void, Bs3Trap32Init,(void))
 {
      X86TSS32 BS3_FAR *pTss;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32SetGate.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32SetGate.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32SetGate.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3Trap32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams)
+#undef Bs3Trap32SetGate
+BS3_CMN_DEF(void, Bs3Trap32SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams))
 {
     X86DESC BS3_FAR *pIdte = &Bs3Idt32[iIdt];
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64Init.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64Init.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64Init.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3Trap64Init(void)
+#undef Bs3Trap64Init
+BS3_CMN_DEF(void, Bs3Trap64Init,(void))
 {
      X86TSS64 BS3_FAR *pTss;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64SetGate.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64SetGate.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64SetGate.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3Trap64SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst)
+#undef Bs3Trap64SetGate
+BS3_CMN_DEF(void, Bs3Trap64SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst))
 {
     X86DESC64 BS3_FAR *pIdte = &Bs3Idt64[iIdt];
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c	(revision 60527)
@@ -48,7 +48,9 @@
         Bs3PrintChr(pTrapFrame->Ctx.rcx.u8);
     else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_PRINT_STR)
-        Bs3PrintStrN(Bs3XptrFlatToCurrent((pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16);
+        Bs3PrintStrN(Bs3XptrFlatToCurrent(((uint32_t)pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16),
+                     pTrapFrame->Ctx.rdx.u16);
     else if (pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_RESTORE_CTX)
-        Bs3RegCtxRestore(Bs3XptrFlatToCurrent((pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16), pTrapFrame->Ctx.rdx.u16);
+        Bs3RegCtxRestore(Bs3XptrFlatToCurrent(((uint32_t)pTrapFrame->Ctx.rcx.u16 << 4) + pTrapFrame->Ctx.rsi.u16),
+                         pTrapFrame->Ctx.rdx.u16);
     else if (   pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING0
              || pTrapFrame->Ctx.rax.u16 == BS3_SYSCALL_TO_RING1
@@ -63,5 +65,6 @@
 #endif
 
-BS3_DECL(void) Bs3TrapDefaultHandler(PBS3TRAPFRAME pTrapFrame)
+#undef Bs3TrapDefaultHandler
+BS3_CMN_DEF(void, Bs3TrapDefaultHandler,(PBS3TRAPFRAME pTrapFrame))
 {
 #if TMPL_BITS != 64
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapPrintFrame.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapPrintFrame.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapPrintFrame.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3TrapPrintFrame(PCBS3TRAPFRAME pTrapFrame)
+#undef Bs3TrapPrintFrame
+BS3_CMN_DEF(void, Bs3TrapPrintFrame,(PCBS3TRAPFRAME pTrapFrame))
 {
 #if 1
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Data.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Data.c	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Data.c	(revision 60527)
@@ -0,0 +1,42 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Real mode and V86 trap data.
+ */
+
+/*
+ * Copyright (C) 2007-2016 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-template-header.h"
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+#if ARCH_BITS == 16
+/** Copy of the original real-mode interrupt vector table. */
+RTFAR16 g_aBs3RmIvtOriginal[256];
+/** Indicates whether we've copied the real-mode IVT or not. */
+bool    g_fBs3RmIvtCopied = false;
+#endif
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Init.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Init.c	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86Init.c	(revision 60527)
@@ -0,0 +1,106 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3TrapRmV86Init
+ */
+
+/*
+ * Copyright (C) 2007-2016 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-template-header.h"
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+/* We ASSUME that BS3CLASS16CODE is 64KB aligned, so the low 16-bit of the
+   flat address matches.   Also, these symbols are defined both with
+   and without underscore prefixes. */
+extern BS3_DECL(void) BS3_FAR_CODE Bs3Trap16GenericEntries(void);
+
+/* These two are ugly.  Need data access for patching purposes. */
+extern uint8_t  BS3_FAR_DATA bs3Trap16GenericTrapOrInt[];
+
+/* bs3-cmn-TrapRmV86Data.c: */
+#define g_fBs3RmIvtCopied   BS3_DATA_NM(g_fBs3RmIvtCopied)
+extern bool    g_fBs3RmIvtCopied;
+
+
+#undef Bs3TrapRmV86InitEx
+BS3_CMN_DEF(void, Bs3TrapRmV86InitEx,(bool f386Plus))
+{
+    RTFAR16 BS3_FAR *paIvt = Bs3XptrFlatToCurrent(0);
+    unsigned iIvt;
+
+    /*
+     * Copy the real mode IVT the first time we are here.
+     */
+    if (!g_fBs3RmIvtCopied)
+    {
+        Bs3MemCpy(g_aBs3RmIvtOriginal, paIvt, sizeof(g_aBs3RmIvtOriginal));
+        g_fBs3RmIvtCopied = true;
+    }
+    /*
+     * The rest of the times, we copy back the original and modify it.
+     */
+    else
+        Bs3MemCpy(paIvt, g_aBs3RmIvtOriginal, sizeof(g_aBs3RmIvtOriginal));
+
+
+    /*
+     * If 386 or later, patch the trap handler code to not jump to the 80286
+     * code but continue with the next instruction (the 386+ code).
+     */
+    if (f386Plus)
+    {
+        uint8_t BS3_FAR_DATA *pbFunction = &bs3Trap16GenericTrapOrInt[0];
+#if ARCH_BITS == 16
+        if (g_bBs3CurrentMode != BS3_MODE_RM)
+            pbFunction = (uint8_t BS3_FAR_DATA *)BS3_FP_MAKE(BS3_SEL_TILED + 1, BS3_FP_OFF(pbFunction));
+#endif
+        pbFunction[1] = 0;
+        pbFunction[2] = 0;
+    }
+
+    /*
+     * Since we want to play with V86 mode as well as 8086 and 186 CPUs, we
+     * cannot move the IVT from its default location.  So, modify it in place.
+     *
+     * Note! We must keep int 10h working, which is easy since the CPU does
+     *       use it (well, it's been reserved for 30+ years).
+     */
+    for (iIvt = 0; iIvt < 256; iIvt++)
+        if (iIvt != 0x10 && iIvt != BS3_TRAP_SYSCALL)
+        {
+            paIvt[iIvt].off = (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIvt * 8;
+            paIvt[iIvt].sel = BS3_SEL_TEXT16;
+        }
+}
+
+
+#undef Bs3TrapRmV86InitEx
+BS3_CMN_DEF(void, Bs3TrapRmV86Init,(void))
+{
+    BS3_CMN_NM(Bs3TrapRmV86InitEx)((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386);
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86SetGate.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86SetGate.c	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapRmV86SetGate.c	(revision 60527)
@@ -0,0 +1,40 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3TrapRmV86SetGate
+ */
+
+/*
+ * Copyright (C) 2007-2016 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-template-header.h"
+
+
+#undef Bs3TrapRmV86SetGate
+BS3_CMN_DEF(void, Bs3TrapRmV86SetGate,(uint8_t iIvt, uint16_t uSeg, uint16_t off))
+{
+    RTFAR16 BS3_FAR *paIvt = Bs3XptrFlatToCurrent(0);
+    paIvt[iIvt].off = off;
+    paIvt[iIvt].sel = uSeg;
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetHandler.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetHandler.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetHandler.c	(revision 60527)
@@ -37,5 +37,6 @@
 
 
-BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler)
+#undef Bs3TrapSetHandler
+BS3_CMN_DEF(PFNBS3TRAPHANDLER, Bs3TrapSetHandler,(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler))
 {
     PFNBS3TRAPHANDLER pfnOld = BS3_DATA_NM(BS3_CMN_NM(g_apfnBs3TrapHandlers))[iIdt];
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm	(revision 60527)
@@ -37,5 +37,5 @@
 BS3_EXTERN_CMN Bs3RegCtxSave
 %if TMPL_BITS == 16
-BS3_EXTERN_CMN Bs3SelFar32ToFlat32
+BS3_EXTERN_CMN_FAR Bs3SelFar32ToFlat32
 %endif
 BS3_EXTERN_DATA16 g_Bs3TrapSetJmpCtx
@@ -49,5 +49,5 @@
 ; @uses     See, applicable C calling convention.
 ;
-BS3_PROC_BEGIN_CMN Bs3TrapSetJmp
+BS3_PROC_BEGIN_CMN Bs3TrapSetJmp, BS3_PBC_HYBRID
         BS3_CALL_CONV_PROLOG 1
         push    xBP
@@ -71,7 +71,11 @@
         mov     xAX, [xBP + xCB]        ; The return address of this function
         mov     [xBX + BS3REGCTX.rip], xAX
+%if TMPL_BITS == 16
+        mov     xAX, [xBP + xCB+2]      ; The return address CS of this function.
+        mov     [xBX + BS3REGCTX.cs], xAX
+%endif
         mov     xAX, [xBP]
         mov     [xBX + BS3REGCTX.rbp], xAX
-        lea     xAX, [xBP + xCB*2]
+        lea     xAX, [xBP + xCB + cbCurRetAddr]
         mov     [xBX + BS3REGCTX.rsp], xAX
         mov     xAX, [xBP - xCB]
@@ -86,5 +90,5 @@
 %if TMPL_BITS == 16
         push    es
-        les     di, [xBP + xCB*2]
+        les     di, [xBP + xCB + cbCurRetAddr]
         mov     cx, BS3TRAPFRAME_size / 2
         mov     ax, 0faceh
@@ -104,7 +108,8 @@
 %if TMPL_BITS == 16
         xor     ax, ax
-        push    word [xBP + xCB*2 + 2]
+        push    word [xBP + xCB + cbCurRetAddr + 2]
         push    ax
-        push    word [xBP + xCB*2]
+        push    word [xBP + xCB + cbCurRetAddr]
+        push    cs
         call    Bs3SelFar32ToFlat32
         add     sp, 6h
@@ -124,5 +129,5 @@
         pop     xBP
         BS3_CALL_CONV_EPILOG 1
-        ret
+        BS3_HYBRID_RET
 BS3_PROC_END_CMN   Bs3TrapSetJmp
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmpAndRestore.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmpAndRestore.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmpAndRestore.c	(revision 60527)
@@ -31,5 +31,6 @@
 
 
-BS3_DECL(void) Bs3TrapSetJmpAndRestore(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame)
+#undef Bs3TrapSetJmpAndRestore
+BS3_CMN_DEF(void, Bs3TrapSetJmpAndRestore,(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame))
 {
     if (Bs3TrapSetJmp(pTrapFrame))
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapUnsetJmp.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapUnsetJmp.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapUnsetJmp.c	(revision 60527)
@@ -40,5 +40,6 @@
 
 
-BS3_DECL(void) Bs3TrapUnsetJmp(void)
+#undef Bs3TrapUnsetJmp
+BS3_CMN_DEF(void, Bs3TrapUnsetJmp,(void))
 {
     g_pBs3TrapSetJmpFrame = 0;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt32Div.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt32Div.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt32Div.c	(revision 60527)
@@ -33,6 +33,6 @@
 
 
-
-void BS3_CMN_NM(Bs3UInt32Div)(RTUINT32U uDividend, RTUINT32U uDivisor, RTUINT32U BS3_FAR *paQuotientReminder)
+#undef Bs3UInt32Div
+BS3_CMN_DEF(void, Bs3UInt32Div,(RTUINT32U uDividend, RTUINT32U uDivisor, RTUINT32U BS3_FAR *paQuotientReminder))
 {
     RTUInt32DivRem(&paQuotientReminder[0], &paQuotientReminder[1], &uDividend, &uDivisor);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt64Div.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt64Div.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-UInt64Div.c	(revision 60527)
@@ -33,6 +33,6 @@
 
 
-
-void BS3_CMN_NM(Bs3UInt64Div)(RTUINT64U uDividend, RTUINT64U uDivisor, RTUINT64U BS3_FAR *paQuotientReminder)
+#undef Bs3UInt64Div
+BS3_CMN_DEF(void, Bs3UInt64Div,(RTUINT64U uDividend, RTUINT64U uDivisor, RTUINT64U BS3_FAR *paQuotientReminder))
 {
     RTUInt64DivRem(&paQuotientReminder[0], &paQuotientReminder[1], &uDividend, &uDivisor);
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-test.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-test.h	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-test.h	(revision 60527)
@@ -100,8 +100,8 @@
  * @param   pszString   The string.
  */
-BS3_DECL(void) bs3TestSendCmdWithStr_c16(uint32_t uCmd, const char BS3_FAR *pszString);
-BS3_DECL(void) bs3TestSendCmdWithStr_c32(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendCmdWithStr_c16 */
-BS3_DECL(void) bs3TestSendCmdWithStr_c64(uint32_t uCmd, const char BS3_FAR *pszString); /**< @copydoc bs3TestSendCmdWithStr_c16 */
-#define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr) /**< Selects #bs3TestSendCmdWithStr_c16, #bs3TestSendCmdWithStr_c32 or #bs3TestSendCmdWithStr_c64. */
+#ifndef DOXYGEN_RUNNING
+# define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr)
+#endif
+BS3_DECL(void) bs3TestSendCmdWithStr(uint32_t uCmd, const char BS3_FAR *pszString);
 
 /**
@@ -114,8 +114,8 @@
  * @param   uValue      The value.
  */
-BS3_DECL(void) bs3TestSendCmdWithU32_c16(uint32_t uCmd, uint32_t uValue);
-BS3_DECL(void) bs3TestSendCmdWithU32_c32(uint32_t uCmd, uint32_t uValue); /**< @copydoc bs3TestSendCmdWithU32_c16 */
-BS3_DECL(void) bs3TestSendCmdWithU32_c64(uint32_t uCmd, uint32_t uValue); /**< @copydoc bs3TestSendCmdWithU32_c16 */
-#define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32) /**< Selects #bs3TestSendCmdWithU32_c16, #bs3TestSendCmdWithU32_c32 or #bs3TestSendCmdWithU32_c64. */
+#ifndef DOXYGEN_RUNNING
+# define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32)
+#endif
+BS3_DECL(void) bs3TestSendCmdWithU32(uint32_t uCmd, uint32_t uValue);
 
 /**
@@ -124,16 +124,16 @@
  * @returns true / false.
  */
-BS3_DECL(bool) bs3TestIsVmmDevTestingPresent_c16(void);
-BS3_DECL(bool) bs3TestIsVmmDevTestingPresent_c32(void); /**< @copydoc bs3TestIsVmmDevTestingPresent_c16 */
-BS3_DECL(bool) bs3TestIsVmmDevTestingPresent_c64(void); /**< @copydoc bs3TestIsVmmDevTestingPresent_c16 */
-#define bs3TestIsVmmDevTestingPresent BS3_CMN_NM(bs3TestIsVmmDevTestingPresent) /**< Selects #bs3TestIsVmmDevTestingPresent_c16, #bs3TestIsVmmDevTestingPresent_c32 or #bs3TestIsVmmDevTestingPresent_c64. */
+#ifndef DOXYGEN_RUNNING
+# define bs3TestIsVmmDevTestingPresent BS3_CMN_NM(bs3TestIsVmmDevTestingPresent)
+#endif
+BS3_DECL(bool) bs3TestIsVmmDevTestingPresent(void);
 
 /**
  * Similar to rtTestSubCleanup.
  */
-BS3_DECL(void) bs3TestSubCleanup_c16(void);
-BS3_DECL(void) bs3TestSubCleanup_c32(void); /**< @copydoc bs3TestSubCleanup_c16 */
-BS3_DECL(void) bs3TestSubCleanup_c64(void); /**< @copydoc bs3TestSubCleanup_c16 */
-#define bs3TestSubCleanup BS3_CMN_NM(bs3TestSubCleanup) /**< Selects #bs3TestSubCleanup_c16, #bs3TestSubCleanup_c32 or #bs3TestSubCleanup_c64. */
+#ifndef DOXYGEN_RUNNING
+# define bs3TestSubCleanup BS3_CMN_NM(bs3TestSubCleanup)
+#endif
+BS3_DECL(void) bs3TestSubCleanup(void);
 
 /**
@@ -143,8 +143,8 @@
  *      The @a pvUser parameter must point a BS3TESTFAILEDBUF structure. }
  */
-BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput_c16(char ch, void BS3_FAR *pvUser);
-BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput_c32(char ch, void BS3_FAR *pvUser);
-BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput_c64(char ch, void BS3_FAR *pvUser);
-#define bs3TestFailedStrOutput BS3_CMN_NM(bs3TestFailedStrOutput) /**< Selects #bs3TestFailedStrOutput_c16, #bs3TestFailedStrOutput_c32 or #bs3TestFailedStrOutput_c64. */
+#ifndef DOXYGEN_RUNNING
+# define bs3TestFailedStrOutput BS3_CMN_NM(bs3TestFailedStrOutput)
+#endif
+BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser);
 
 /**
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac	(revision 60527)
@@ -65,8 +65,12 @@
 
 %ifdef ASM_FORMAT_ELF
-section BS3TEXT16_END   align=2 progbits alloc exec nowrite
-%else
-section _TEXT           align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
-section BS3TEXT16_END   align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
+section BS3TEXT16_NEARSTUBS align=1 progbits alloc exec nowrite
+section BS3TEXT16_FARSTUBS  align=1 progbits alloc exec nowrite
+section BS3TEXT16_END       align=1 progbits alloc exec nowrite
+%else
+section _TEXT               align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
+section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
+section BS3TEXT16_FARSTUBS  align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
+section BS3TEXT16_END       align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
 %endif
 
@@ -75,7 +79,7 @@
 %ifndef ASM_FORMAT_ELF
  %ifndef BS3_IS_DOS_EXE
-GROUP CGROUP16 BS3TEXT16 BS3TEXT16_END
+GROUP CGROUP16 BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
  %else
-GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_END
+GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
  %endif
 %endif
@@ -148,4 +152,25 @@
 %endif
 
+;
+; 16-bit real-mode text
+;
+%ifdef ASM_FORMAT_ELF
+section BS3RMTEXT16_START   align=16 progbits alloc exec nowrite
+%else
+section BS3RMTEXT16_START   align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
+%endif
+BS3_GLOBAL_DATA Bs3RmText16_StartOfSegment, 0
+    db      10,13,'eye-catcher: BS3RMTEXT16',10,13
+
+BS3_BEGIN_RMTEXT16
+
+%ifdef ASM_FORMAT_ELF
+section BS3RMTEXT16_END   align=1 progbits alloc exec nowrite
+%else
+section BS3RMTEXT16_END   align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
+%endif
+
+BS3_GLOBAL_DATA Bs3RmText16_EndOfSegment, 0
+
 
 ;
@@ -161,5 +186,4 @@
 section BS3TEXT32_END   align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
 %endif
-
 BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm	(revision 60527)
@@ -262,8 +262,6 @@
 .return_stack_ok:
 %endif
-        leave
+        pop     xBP
         ret
-.dbg_str:
-    db 'CurrentMode=%#x', 0ah, 0
 BS3_PROC_END_MODE   Bs3EnteredMode
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c	(revision 60527)
@@ -29,7 +29,12 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
+//#define BS3_USE_RM_TEXT_SEG 1
 #include "bs3kit-template-header.h"
 #include "bs3-cmn-test.h"
 #include <iprt/asm-amd64-x86.h>
+
+//#ifdef __WATCOMC__
+//# pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
+//#endif
 
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c	(revision 60527)
@@ -28,7 +28,12 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
+#define BS3_USE_RM_TEXT_SEG 1
 #include "bs3kit-template-header.h"
 #include "bs3-cmn-memory.h"
 #include <iprt/asm.h>
+
+#ifdef __WATCOMC__
+# pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
+#endif
 
 
@@ -234,5 +239,5 @@
 
 
-BS3_DECL(void) Bs3InitMemory_rm(void)
+BS3_DECL(void) BS3_FAR_CODE Bs3InitMemory_rm(void)
 {
     uint16_t        i;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 60527)
@@ -0,0 +1,110 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Function needing mangling.
+ */
+
+/*
+ * Copyright (C) 2007-2016 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.
+ */
+
+
+#define Bs3A20Disable                           BS3_CMN_MANGLER(Bs3A20Disable)
+#define Bs3A20DisableViaKbd                     BS3_CMN_MANGLER(Bs3A20DisableViaKbd)
+#define Bs3A20DisableViaPortA                   BS3_CMN_MANGLER(Bs3A20DisableViaPortA)
+#define Bs3A20Enable                            BS3_CMN_MANGLER(Bs3A20Enable)
+#define Bs3A20EnableViaKbd                      BS3_CMN_MANGLER(Bs3A20EnableViaKbd)
+#define Bs3A20EnableViaPortA                    BS3_CMN_MANGLER(Bs3A20EnableViaPortA)
+#define Bs3KbdRead                              BS3_CMN_MANGLER(Bs3KbdRead)
+#define Bs3KbdWait                              BS3_CMN_MANGLER(Bs3KbdWait)
+#define Bs3KbdWrite                             BS3_CMN_MANGLER(Bs3KbdWrite)
+#define Bs3MemAlloc                             BS3_CMN_MANGLER(Bs3MemAlloc)
+#define Bs3MemAllocZ                            BS3_CMN_MANGLER(Bs3MemAllocZ)
+#define Bs3MemCpy                               BS3_CMN_MANGLER(Bs3MemCpy)
+#define Bs3MemFree                              BS3_CMN_MANGLER(Bs3MemFree)
+#define Bs3MemMove                              BS3_CMN_MANGLER(Bs3MemMove)
+#define Bs3MemPCpy                              BS3_CMN_MANGLER(Bs3MemPCpy)
+#define Bs3MemZero                              BS3_CMN_MANGLER(Bs3MemZero)
+#define Bs3PagingInitRootForLM                  BS3_CMN_MANGLER(Bs3PagingInitRootForLM)
+#define Bs3PagingInitRootForPAE                 BS3_CMN_MANGLER(Bs3PagingInitRootForPAE)
+#define Bs3PagingInitRootForPP                  BS3_CMN_MANGLER(Bs3PagingInitRootForPP)
+#define Bs3PagingProtect                        BS3_CMN_MANGLER(Bs3PagingProtect)
+#define Bs3PagingProtectPtr                     BS3_CMN_MANGLER(Bs3PagingProtectPtr)
+#define Bs3Panic                                BS3_CMN_MANGLER(Bs3Panic)
+#define Bs3PicMaskAll                           BS3_CMN_MANGLER(Bs3PicMaskAll)
+#define Bs3PrintChr                             BS3_CMN_MANGLER(Bs3PrintChr)
+#define Bs3Printf                               BS3_CMN_MANGLER(Bs3Printf)
+#define Bs3PrintfV                              BS3_CMN_MANGLER(Bs3PrintfV)
+#define Bs3PrintStr                             BS3_CMN_MANGLER(Bs3PrintStr)
+#define Bs3PrintStrN                            BS3_CMN_MANGLER(Bs3PrintStrN)
+#define Bs3PrintU32                             BS3_CMN_MANGLER(Bs3PrintU32)
+#define Bs3PrintX32                             BS3_CMN_MANGLER(Bs3PrintX32)
+#define Bs3RegCtxConvertToRingX                 BS3_CMN_MANGLER(Bs3RegCtxConvertToRingX)
+#define Bs3RegCtxPrint                          BS3_CMN_MANGLER(Bs3RegCtxPrint)
+#define Bs3RegCtxRestore                        BS3_CMN_MANGLER(Bs3RegCtxRestore)
+#define Bs3RegCtxSave                           BS3_CMN_MANGLER(Bs3RegCtxSave)
+#define Bs3SelFar32ToFlat32                     BS3_CMN_MANGLER(Bs3SelFar32ToFlat32)
+#define Bs3SelProtFar32ToFlat32                 BS3_CMN_MANGLER(Bs3SelProtFar32ToFlat32)
+#define Bs3Shutdown                             BS3_CMN_MANGLER(Bs3Shutdown)
+#define Bs3SlabAlloc                            BS3_CMN_MANGLER(Bs3SlabAlloc)
+#define Bs3SlabAllocEx                          BS3_CMN_MANGLER(Bs3SlabAllocEx)
+#define Bs3SlabFree                             BS3_CMN_MANGLER(Bs3SlabFree)
+#define Bs3SlabInit                             BS3_CMN_MANGLER(Bs3SlabInit)
+#define Bs3SlabListAdd                          BS3_CMN_MANGLER(Bs3SlabListAdd)
+#define Bs3SlabListAlloc                        BS3_CMN_MANGLER(Bs3SlabListAlloc)
+#define Bs3SlabListAllocEx                      BS3_CMN_MANGLER(Bs3SlabListAllocEx)
+#define Bs3SlabListFree                         BS3_CMN_MANGLER(Bs3SlabListFree)
+#define Bs3SlabListInit                         BS3_CMN_MANGLER(Bs3SlabListInit)
+#define Bs3StrCpy                               BS3_CMN_MANGLER(Bs3StrCpy)
+#define Bs3StrFormatV                           BS3_CMN_MANGLER(Bs3StrFormatV)
+#define Bs3StrLen                               BS3_CMN_MANGLER(Bs3StrLen)
+#define Bs3StrNLen                              BS3_CMN_MANGLER(Bs3StrNLen)
+#define Bs3StrPrintf                            BS3_CMN_MANGLER(Bs3StrPrintf)
+#define Bs3StrPrintfV                           BS3_CMN_MANGLER(Bs3StrPrintfV)
+#define Bs3TestCheckRegCtxEx                    BS3_CMN_MANGLER(Bs3TestCheckRegCtxEx)
+#define Bs3TestFailed                           BS3_CMN_MANGLER(Bs3TestFailed)
+#define Bs3TestFailedF                          BS3_CMN_MANGLER(Bs3TestFailedF)
+#define Bs3TestFailedV                          BS3_CMN_MANGLER(Bs3TestFailedV)
+#define Bs3TestInit                             BS3_CMN_MANGLER(Bs3TestInit)
+#define Bs3TestPrintf                           BS3_CMN_MANGLER(Bs3TestPrintf)
+#define Bs3TestPrintfV                          BS3_CMN_MANGLER(Bs3TestPrintfV)
+#define Bs3TestSkipped                          BS3_CMN_MANGLER(Bs3TestSkipped)
+#define Bs3TestSkippedF                         BS3_CMN_MANGLER(Bs3TestSkippedF)
+#define Bs3TestSkippedV                         BS3_CMN_MANGLER(Bs3TestSkippedV)
+#define Bs3TestSub                              BS3_CMN_MANGLER(Bs3TestSub)
+#define Bs3TestSubDone                          BS3_CMN_MANGLER(Bs3TestSubDone)
+#define Bs3TestSubErrorCount                    BS3_CMN_MANGLER(Bs3TestSubErrorCount)
+#define Bs3TestSubF                             BS3_CMN_MANGLER(Bs3TestSubF)
+#define Bs3TestSubV                             BS3_CMN_MANGLER(Bs3TestSubV)
+#define Bs3TestTerm                             BS3_CMN_MANGLER(Bs3TestTerm)
+#define Bs3Trap16Init                           BS3_CMN_MANGLER(Bs3Trap16Init)
+#define Bs3Trap16InitEx                         BS3_CMN_MANGLER(Bs3Trap16InitEx)
+#define Bs3Trap16SetGate                        BS3_CMN_MANGLER(Bs3Trap16SetGate)
+#define Bs3Trap32Init                           BS3_CMN_MANGLER(Bs3Trap32Init)
+#define Bs3Trap32SetGate                        BS3_CMN_MANGLER(Bs3Trap32SetGate)
+#define Bs3Trap64Init                           BS3_CMN_MANGLER(Bs3Trap64Init)
+#define Bs3Trap64SetGate                        BS3_CMN_MANGLER(Bs3Trap64SetGate)
+#define Bs3TrapDefaultHandler                   BS3_CMN_MANGLER(Bs3TrapDefaultHandler)
+#define Bs3TrapPrintFrame                       BS3_CMN_MANGLER(Bs3TrapPrintFrame)
+#define Bs3TrapRmV86SetGate                     BS3_CMN_MANGLER(Bs3TrapRmV86SetGate)
+#define Bs3TrapSetHandler                       BS3_CMN_MANGLER(Bs3TrapSetHandler)
+#define Bs3TrapSetJmp                           BS3_CMN_MANGLER(Bs3TrapSetJmp)
+#define Bs3TrapSetJmpAndRestore                 BS3_CMN_MANGLER(Bs3TrapSetJmpAndRestore)
+#define Bs3TrapUnsetJmp                         BS3_CMN_MANGLER(Bs3TrapUnsetJmp)
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 60527)
@@ -0,0 +1,109 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Undefining function mangling - automatically generated by bs3kit-mangling-functions-undef.h in Makefile.
+ */
+
+/*
+ * Copyright (C) 2007-2016 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.
+ */
+
+
+#undef Bs3A20Disable
+#undef Bs3A20DisableViaKbd
+#undef Bs3A20DisableViaPortA
+#undef Bs3A20Enable
+#undef Bs3A20EnableViaKbd
+#undef Bs3A20EnableViaPortA
+#undef Bs3KbdRead
+#undef Bs3KbdWait
+#undef Bs3KbdWrite
+#undef Bs3MemAlloc
+#undef Bs3MemAllocZ
+#undef Bs3MemCpy
+#undef Bs3MemFree
+#undef Bs3MemMove
+#undef Bs3MemPCpy
+#undef Bs3MemZero
+#undef Bs3PagingInitRootForLM
+#undef Bs3PagingInitRootForPAE
+#undef Bs3PagingInitRootForPP
+#undef Bs3PagingProtect
+#undef Bs3PagingProtectPtr
+#undef Bs3Panic
+#undef Bs3PicMaskAll
+#undef Bs3PrintChr
+#undef Bs3Printf
+#undef Bs3PrintfV
+#undef Bs3PrintStr
+#undef Bs3PrintStrN
+#undef Bs3PrintU32
+#undef Bs3PrintX32
+#undef Bs3RegCtxConvertToRingX
+#undef Bs3RegCtxPrint
+#undef Bs3RegCtxRestore
+#undef Bs3RegCtxSave
+#undef Bs3SelFar32ToFlat32
+#undef Bs3SelProtFar32ToFlat32
+#undef Bs3Shutdown
+#undef Bs3SlabAlloc
+#undef Bs3SlabAllocEx
+#undef Bs3SlabFree
+#undef Bs3SlabInit
+#undef Bs3SlabListAdd
+#undef Bs3SlabListAlloc
+#undef Bs3SlabListAllocEx
+#undef Bs3SlabListFree
+#undef Bs3SlabListInit
+#undef Bs3StrCpy
+#undef Bs3StrFormatV
+#undef Bs3StrLen
+#undef Bs3StrNLen
+#undef Bs3StrPrintf
+#undef Bs3StrPrintfV
+#undef Bs3TestCheckRegCtxEx
+#undef Bs3TestFailed
+#undef Bs3TestFailedF
+#undef Bs3TestFailedV
+#undef Bs3TestInit
+#undef Bs3TestPrintf
+#undef Bs3TestPrintfV
+#undef Bs3TestSkipped
+#undef Bs3TestSkippedF
+#undef Bs3TestSkippedV
+#undef Bs3TestSub
+#undef Bs3TestSubDone
+#undef Bs3TestSubErrorCount
+#undef Bs3TestSubF
+#undef Bs3TestSubV
+#undef Bs3TestTerm
+#undef Bs3Trap16Init
+#undef Bs3Trap16InitEx
+#undef Bs3Trap16SetGate
+#undef Bs3Trap32Init
+#undef Bs3Trap32SetGate
+#undef Bs3Trap64Init
+#undef Bs3Trap64SetGate
+#undef Bs3TrapDefaultHandler
+#undef Bs3TrapPrintFrame
+#undef Bs3TrapRmV86SetGate
+#undef Bs3TrapSetHandler
+#undef Bs3TrapSetJmpAndRestore
+#undef Bs3TrapUnsetJmp
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code.h	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code.h	(revision 60527)
@@ -0,0 +1,39 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Symbol mangling, code.
+ */
+
+/*
+ * Copyright (C) 2007-2016 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.
+ */
+
+
+/*
+ * Do function mangling.  This can be redone at compile time (templates).
+ */
+#undef BS3_CMN_MANGLER
+#if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
+# define BS3_CMN_MANGLER(a_Function)            BS3_CMN_NM(a_Function)
+#else
+# define BS3_CMN_MANGLER(a_Function)            BS3_CMN_FAR_NM(a_Function)
+#endif
+#include "bs3kit-mangling-code-undef.h"
+#include "bs3kit-mangling-code-define.h"
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-data.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-data.h	(revision 60527)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-data.h	(revision 60527)
@@ -0,0 +1,253 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Symbol mangling.
+ */
+
+/*
+ * Copyright (C) 2007-2016 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.
+ */
+
+
+/*
+ * First part is only applied once.  It concerns itself with data symbols.
+ */
+#ifndef ___bs3kit_mangling_data_h
+#define ___bs3kit_mangling_data_h
+
+#if ARCH_BITS == 64
+
+# define Bs3Gdt                                 BS3_DATA_NM(Bs3Gdt)
+# define Bs3Gdt_Ldt                             BS3_DATA_NM(Bs3Gdt_Ldt)
+# define Bs3Gdte_Tss16                          BS3_DATA_NM(Bs3Gdte_Tss16)
+# define Bs3Gdte_Tss16DoubleFault               BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault)
+# define Bs3Gdte_Tss16Spare0                    BS3_DATA_NM(Bs3Gdte_Tss16Spare0)
+# define Bs3Gdte_Tss16Spare1                    BS3_DATA_NM(Bs3Gdte_Tss16Spare1)
+# define Bs3Gdte_Tss32                          BS3_DATA_NM(Bs3Gdte_Tss32)
+# define Bs3Gdte_Tss32DoubleFault               BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault)
+# define Bs3Gdte_Tss32Spare0                    BS3_DATA_NM(Bs3Gdte_Tss32Spare0)
+# define Bs3Gdte_Tss32Spare1                    BS3_DATA_NM(Bs3Gdte_Tss32Spare1)
+# define Bs3Gdte_Tss32IobpIntRedirBm            BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm)
+# define Bs3Gdte_Tss32IntRedirBm                BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm)
+# define Bs3Gdte_Tss64                          BS3_DATA_NM(Bs3Gdte_Tss64)
+# define Bs3Gdte_Tss64Spare0                    BS3_DATA_NM(Bs3Gdte_Tss64Spare0)
+# define Bs3Gdte_Tss64Spare1                    BS3_DATA_NM(Bs3Gdte_Tss64Spare1)
+# define Bs3Gdte_Tss64Iobp                      BS3_DATA_NM(Bs3Gdte_Tss64Iobp)
+# define Bs3Gdte_R0_MMIO16                      BS3_DATA_NM(Bs3Gdte_R0_MMIO16)
+
+# define Bs3Gdte_R0_First                       BS3_DATA_NM(Bs3Gdte_R0_First)
+# define Bs3Gdte_R0_CS16                        BS3_DATA_NM(Bs3Gdte_R0_CS16)
+# define Bs3Gdte_R0_DS16                        BS3_DATA_NM(Bs3Gdte_R0_DS16)
+# define Bs3Gdte_R0_SS16                        BS3_DATA_NM(Bs3Gdte_R0_SS16)
+# define Bs3Gdte_R0_CS32                        BS3_DATA_NM(Bs3Gdte_R0_CS32)
+# define Bs3Gdte_R0_DS32                        BS3_DATA_NM(Bs3Gdte_R0_DS32)
+# define Bs3Gdte_R0_SS32                        BS3_DATA_NM(Bs3Gdte_R0_SS32)
+# define Bs3Gdte_R0_CS64                        BS3_DATA_NM(Bs3Gdte_R0_CS64)
+# define Bs3Gdte_R0_DS64                        BS3_DATA_NM(Bs3Gdte_R0_DS64)
+# define Bs3Gdte_R0_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS16_EO)
+# define Bs3Gdte_R0_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF)
+# define Bs3Gdte_R0_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO)
+# define Bs3Gdte_R0_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS32_EO)
+# define Bs3Gdte_R0_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF)
+# define Bs3Gdte_R0_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO)
+# define Bs3Gdte_R0_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS64_EO)
+# define Bs3Gdte_R0_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF)
+# define Bs3Gdte_R0_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO)
+
+# define Bs3Gdte_R1_First                       BS3_DATA_NM(Bs3Gdte_R1_First)
+# define Bs3Gdte_R1_CS16                        BS3_DATA_NM(Bs3Gdte_R1_CS16)
+# define Bs3Gdte_R1_DS16                        BS3_DATA_NM(Bs3Gdte_R1_DS16)
+# define Bs3Gdte_R1_SS16                        BS3_DATA_NM(Bs3Gdte_R1_SS16)
+# define Bs3Gdte_R1_CS32                        BS3_DATA_NM(Bs3Gdte_R1_CS32)
+# define Bs3Gdte_R1_DS32                        BS3_DATA_NM(Bs3Gdte_R1_DS32)
+# define Bs3Gdte_R1_SS32                        BS3_DATA_NM(Bs3Gdte_R1_SS32)
+# define Bs3Gdte_R1_CS64                        BS3_DATA_NM(Bs3Gdte_R1_CS64)
+# define Bs3Gdte_R1_DS64                        BS3_DATA_NM(Bs3Gdte_R1_DS64)
+# define Bs3Gdte_R1_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS16_EO)
+# define Bs3Gdte_R1_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF)
+# define Bs3Gdte_R1_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO)
+# define Bs3Gdte_R1_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS32_EO)
+# define Bs3Gdte_R1_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF)
+# define Bs3Gdte_R1_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO)
+# define Bs3Gdte_R1_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS64_EO)
+# define Bs3Gdte_R1_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF)
+# define Bs3Gdte_R1_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO)
+
+# define Bs3Gdte_R2_First                       BS3_DATA_NM(Bs3Gdte_R2_First)
+# define Bs3Gdte_R2_CS16                        BS3_DATA_NM(Bs3Gdte_R2_CS16)
+# define Bs3Gdte_R2_DS16                        BS3_DATA_NM(Bs3Gdte_R2_DS16)
+# define Bs3Gdte_R2_SS16                        BS3_DATA_NM(Bs3Gdte_R2_SS16)
+# define Bs3Gdte_R2_CS32                        BS3_DATA_NM(Bs3Gdte_R2_CS32)
+# define Bs3Gdte_R2_DS32                        BS3_DATA_NM(Bs3Gdte_R2_DS32)
+# define Bs3Gdte_R2_SS32                        BS3_DATA_NM(Bs3Gdte_R2_SS32)
+# define Bs3Gdte_R2_CS64                        BS3_DATA_NM(Bs3Gdte_R2_CS64)
+# define Bs3Gdte_R2_DS64                        BS3_DATA_NM(Bs3Gdte_R2_DS64)
+# define Bs3Gdte_R2_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS16_EO)
+# define Bs3Gdte_R2_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF)
+# define Bs3Gdte_R2_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO)
+# define Bs3Gdte_R2_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS32_EO)
+# define Bs3Gdte_R2_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF)
+# define Bs3Gdte_R2_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO)
+# define Bs3Gdte_R2_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS64_EO)
+# define Bs3Gdte_R2_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF)
+# define Bs3Gdte_R2_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO)
+
+# define Bs3Gdte_R3_First                       BS3_DATA_NM(Bs3Gdte_R3_First)
+# define Bs3Gdte_R3_CS16                        BS3_DATA_NM(Bs3Gdte_R3_CS16)
+# define Bs3Gdte_R3_DS16                        BS3_DATA_NM(Bs3Gdte_R3_DS16)
+# define Bs3Gdte_R3_SS16                        BS3_DATA_NM(Bs3Gdte_R3_SS16)
+# define Bs3Gdte_R3_CS32                        BS3_DATA_NM(Bs3Gdte_R3_CS32)
+# define Bs3Gdte_R3_DS32                        BS3_DATA_NM(Bs3Gdte_R3_DS32)
+# define Bs3Gdte_R3_SS32                        BS3_DATA_NM(Bs3Gdte_R3_SS32)
+# define Bs3Gdte_R3_CS64                        BS3_DATA_NM(Bs3Gdte_R3_CS64)
+# define Bs3Gdte_R3_DS64                        BS3_DATA_NM(Bs3Gdte_R3_DS64)
+# define Bs3Gdte_R3_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS16_EO)
+# define Bs3Gdte_R3_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF)
+# define Bs3Gdte_R3_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO)
+# define Bs3Gdte_R3_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS32_EO)
+# define Bs3Gdte_R3_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF)
+# define Bs3Gdte_R3_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO)
+# define Bs3Gdte_R3_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS64_EO)
+# define Bs3Gdte_R3_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF)
+# define Bs3Gdte_R3_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO)
+
+# define Bs3GdteSpare00                         BS3_DATA_NM(Bs3GdteSpare00)
+# define Bs3GdteSpare01                         BS3_DATA_NM(Bs3GdteSpare01)
+# define Bs3GdteSpare02                         BS3_DATA_NM(Bs3GdteSpare02)
+# define Bs3GdteSpare03                         BS3_DATA_NM(Bs3GdteSpare03)
+# define Bs3GdteSpare04                         BS3_DATA_NM(Bs3GdteSpare04)
+# define Bs3GdteSpare05                         BS3_DATA_NM(Bs3GdteSpare05)
+# define Bs3GdteSpare06                         BS3_DATA_NM(Bs3GdteSpare06)
+# define Bs3GdteSpare07                         BS3_DATA_NM(Bs3GdteSpare07)
+# define Bs3GdteSpare08                         BS3_DATA_NM(Bs3GdteSpare08)
+# define Bs3GdteSpare09                         BS3_DATA_NM(Bs3GdteSpare09)
+# define Bs3GdteSpare0a                         BS3_DATA_NM(Bs3GdteSpare0a)
+# define Bs3GdteSpare0b                         BS3_DATA_NM(Bs3GdteSpare0b)
+# define Bs3GdteSpare0c                         BS3_DATA_NM(Bs3GdteSpare0c)
+# define Bs3GdteSpare0d                         BS3_DATA_NM(Bs3GdteSpare0d)
+# define Bs3GdteSpare0e                         BS3_DATA_NM(Bs3GdteSpare0e)
+# define Bs3GdteSpare0f                         BS3_DATA_NM(Bs3GdteSpare0f)
+# define Bs3GdteSpare10                         BS3_DATA_NM(Bs3GdteSpare10)
+# define Bs3GdteSpare11                         BS3_DATA_NM(Bs3GdteSpare11)
+# define Bs3GdteSpare12                         BS3_DATA_NM(Bs3GdteSpare12)
+# define Bs3GdteSpare13                         BS3_DATA_NM(Bs3GdteSpare13)
+# define Bs3GdteSpare14                         BS3_DATA_NM(Bs3GdteSpare14)
+# define Bs3GdteSpare15                         BS3_DATA_NM(Bs3GdteSpare15)
+# define Bs3GdteSpare16                         BS3_DATA_NM(Bs3GdteSpare16)
+# define Bs3GdteSpare17                         BS3_DATA_NM(Bs3GdteSpare17)
+# define Bs3GdteSpare18                         BS3_DATA_NM(Bs3GdteSpare18)
+# define Bs3GdteSpare19                         BS3_DATA_NM(Bs3GdteSpare19)
+# define Bs3GdteSpare1a                         BS3_DATA_NM(Bs3GdteSpare1a)
+# define Bs3GdteSpare1b                         BS3_DATA_NM(Bs3GdteSpare1b)
+# define Bs3GdteSpare1c                         BS3_DATA_NM(Bs3GdteSpare1c)
+# define Bs3GdteSpare1d                         BS3_DATA_NM(Bs3GdteSpare1d)
+# define Bs3GdteSpare1e                         BS3_DATA_NM(Bs3GdteSpare1e)
+# define Bs3GdteSpare1f                         BS3_DATA_NM(Bs3GdteSpare1f)
+
+# define Bs3GdteTiled                           BS3_DATA_NM(Bs3GdteTiled)
+# define Bs3GdteFreePart1                       BS3_DATA_NM(Bs3GdteFreePart1)
+# define Bs3Gdte_CODE16                         BS3_DATA_NM(Bs3Gdte_CODE16)
+# define Bs3GdteFreePart2                       BS3_DATA_NM(Bs3GdteFreePart2)
+# define Bs3Gdte_SYSTEM16                       BS3_DATA_NM(Bs3Gdte_SYSTEM16)
+# define Bs3GdteFreePart3                       BS3_DATA_NM(Bs3GdteFreePart3)
+# define Bs3Gdte_DATA16                         BS3_DATA_NM(Bs3Gdte_DATA16)
+
+# define Bs3GdteFreePart4                       BS3_DATA_NM(Bs3GdteFreePart4)
+# define Bs3GdtePreTestPage08                   BS3_DATA_NM(Bs3GdtePreTestPage08)
+# define Bs3GdtePreTestPage07                   BS3_DATA_NM(Bs3GdtePreTestPage07)
+# define Bs3GdtePreTestPage06                   BS3_DATA_NM(Bs3GdtePreTestPage06)
+# define Bs3GdtePreTestPage05                   BS3_DATA_NM(Bs3GdtePreTestPage05)
+# define Bs3GdtePreTestPage04                   BS3_DATA_NM(Bs3GdtePreTestPage04)
+# define Bs3GdtePreTestPage03                   BS3_DATA_NM(Bs3GdtePreTestPage03)
+# define Bs3GdtePreTestPage02                   BS3_DATA_NM(Bs3GdtePreTestPage02)
+# define Bs3GdtePreTestPage01                   BS3_DATA_NM(Bs3GdtePreTestPage01)
+# define Bs3GdteTestPage                        BS3_DATA_NM(Bs3GdteTestPage)
+# define Bs3GdteTestPage00                      BS3_DATA_NM(Bs3GdteTestPage00)
+# define Bs3GdteTestPage01                      BS3_DATA_NM(Bs3GdteTestPage01)
+# define Bs3GdteTestPage02                      BS3_DATA_NM(Bs3GdteTestPage02)
+# define Bs3GdteTestPage03                      BS3_DATA_NM(Bs3GdteTestPage03)
+# define Bs3GdteTestPage04                      BS3_DATA_NM(Bs3GdteTestPage04)
+# define Bs3GdteTestPage05                      BS3_DATA_NM(Bs3GdteTestPage05)
+# define Bs3GdteTestPage06                      BS3_DATA_NM(Bs3GdteTestPage06)
+# define Bs3GdteTestPage07                      BS3_DATA_NM(Bs3GdteTestPage07)
+
+# define Bs3GdtEnd                              BS3_DATA_NM(Bs3GdtEnd)
+
+# define Bs3Tss16                               BS3_DATA_NM(Bs3Tss16)
+# define Bs3Tss16DoubleFault                    BS3_DATA_NM(Bs3Tss16DoubleFault)
+# define Bs3Tss16Spare0                         BS3_DATA_NM(Bs3Tss16Spare0)
+# define Bs3Tss16Spare1                         BS3_DATA_NM(Bs3Tss16Spare1)
+# define Bs3Tss32                               BS3_DATA_NM(Bs3Tss32)
+# define Bs3Tss32DoubleFault                    BS3_DATA_NM(Bs3Tss32DoubleFault)
+# define Bs3Tss32Spare0                         BS3_DATA_NM(Bs3Tss32Spare0)
+# define Bs3Tss32Spare1                         BS3_DATA_NM(Bs3Tss32Spare1)
+# define Bs3Tss64                               BS3_DATA_NM(Bs3Tss64)
+# define Bs3Tss64Spare0                         BS3_DATA_NM(Bs3Tss64Spare0)
+# define Bs3Tss64Spare1                         BS3_DATA_NM(Bs3Tss64Spare1)
+# define Bs3Tss64WithIopb                       BS3_DATA_NM(Bs3Tss64WithIopb)
+# define Bs3Tss32WithIopb                       BS3_DATA_NM(Bs3Tss32WithIopb)
+# define Bs3SharedIntRedirBm                    BS3_DATA_NM(Bs3SharedIntRedirBm)
+# define Bs3SharedIobp                          BS3_DATA_NM(Bs3SharedIobp)
+# define Bs3SharedIobpEnd                       BS3_DATA_NM(Bs3SharedIobpEnd)
+# define Bs3Idt16                               BS3_DATA_NM(Bs3Idt16)
+# define Bs3Idt32                               BS3_DATA_NM(Bs3Idt32)
+# define Bs3Idt64                               BS3_DATA_NM(Bs3Idt64)
+# define Bs3Lidt_Idt16                          BS3_DATA_NM(Bs3Lidt_Idt16)
+# define Bs3Lidt_Idt32                          BS3_DATA_NM(Bs3Lidt_Idt32)
+# define Bs3Lidt_Idt64                          BS3_DATA_NM(Bs3Lidt_Idt64)
+# define Bs3Lidt_Ivt                            BS3_DATA_NM(Bs3Lidt_Ivt)
+# define Bs3Lgdt_Gdt                            BS3_DATA_NM(Bs3Lgdt_Gdt)
+# define Bs3Ldt                                 BS3_DATA_NM(Bs3Ldt)
+# define Bs3LdtEnd                              BS3_DATA_NM(Bs3LdtEnd)
+
+# define Bs3Text16_StartOfSegment               BS3_DATA_NM(Bs3Text16_StartOfSegment)
+# define Bs3Text16_EndOfSegment                 BS3_DATA_NM(Bs3Text16_EndOfSegment)
+# define Bs3Text16_Size                         BS3_DATA_NM(Bs3Text16_Size)
+# define Bs3System16_StartOfSegment             BS3_DATA_NM(Bs3System16_StartOfSegment)
+# define Bs3System16_EndOfSegment               BS3_DATA_NM(Bs3System16_EndOfSegment)
+# define Bs3Data16_StartOfSegment               BS3_DATA_NM(Bs3Data16_StartOfSegment)
+# define Bs3Data16_EndOfSegment                 BS3_DATA_NM(Bs3Data16_EndOfSegment)
+# define Bs3Text32_StartOfSegment               BS3_DATA_NM(Bs3Text32_StartOfSegment)
+# define Bs3Text32_EndOfSegment                 BS3_DATA_NM(Bs3Text32_EndOfSegment)
+# define Bs3Data32_StartOfSegment               BS3_DATA_NM(Bs3Data32_StartOfSegment)
+# define Bs3Data32_EndOfSegment                 BS3_DATA_NM(Bs3Data32_EndOfSegment)
+# define Bs3Text64_StartOfSegment               BS3_DATA_NM(Bs3Text64_StartOfSegment)
+# define Bs3Text64_EndOfSegment                 BS3_DATA_NM(Bs3Text64_EndOfSegment)
+# define Bs3Data64_StartOfSegment               BS3_DATA_NM(Bs3Data64_StartOfSegment)
+# define Bs3Data64_EndOfSegment                 BS3_DATA_NM(Bs3Data64_EndOfSegment)
+
+# define Bs3Data16Thru64Text32And64_TotalSize   BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize)
+# define Bs3TotalImageSize                      BS3_DATA_NM(Bs3TotalImageSize)
+# define g_achBs3HexDigits                      BS3_DATA_NM(g_achBs3HexDigits)
+# define g_achBs3HexDigitsUpper                 BS3_DATA_NM(g_achBs3HexDigitsUpper)
+# define g_bBs3CurrentMode                      BS3_DATA_NM(g_bBs3CurrentMode)
+# define g_uBs3TrapEipHint                      BS3_DATA_NM(g_uBs3TrapEipHint)
+# define g_aBs3RmIvtOriginal                    BS3_DATA_NM(g_aBs3RmIvtOriginal)
+
+# define g_usBs3TestStep                        BS3_DATA_NM(g_usBs3TestStep)
+# define g_usBs3TestStep                        BS3_DATA_NM(g_usBs3TestStep)
+# define g_Bs3Trap16GenericEntriesFlatAddr      BS3_DATA_NM(g_Bs3Trap16GenericEntriesFlatAddr)
+# define g_Bs3Trap32GenericEntriesFlatAddr      BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr)
+# define g_Bs3Trap64GenericEntriesFlatAddr      BS3_DATA_NM(g_Bs3Trap64GenericEntriesFlatAddr)
+
+# define g_uBs3CpuDetected                      BS3_DATA_NM(g_uBs3CpuDetected)
+
+#endif /* ARCH_BITS == 64 */
+#endif /* !___bs3kit_mangling_data_h */
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.h	(revision 60527)
@@ -138,5 +138,6 @@
 #else /* !DOXYGEN_RUNNING */
 
-#undef BS3_CMN_NM
+//#undef BS3_CMN_NM
+//#undef BS3_CMN_FAR_NM
 
 
@@ -205,5 +206,7 @@
 # define TMPL_BITS              16
 # define TMPL_UNDERSCORE        _
-# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+//# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+//# define BS3_CMN_FAR_NM(Name)   RT_CONCAT(Name,_f16)
+
 
 #elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32
@@ -214,5 +217,6 @@
 # define TMPL_BITS              32
 # define TMPL_UNDERSCORE        _
-# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+//# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c32)
+//# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(Name,_c32)
 
 #elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86
@@ -223,5 +227,6 @@
 # define TMPL_BITS              16
 # define TMPL_UNDERSCORE        _
-# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+//# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c16)
+//# define BS3_CMN_FAR_NM(Name)   RT_CONCAT(Name,_f16)
 # define TMPL_CMN_R86
 # define TMPL_CMN_V86
@@ -234,5 +239,6 @@
 # define TMPL_BITS              64
 # define TMPL_UNDERSCORE
-# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
+//# define BS3_CMN_NM(Name)       RT_CONCAT(Name,_c64)
+//# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(Name,_c64)
 
 #else
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 60527)
@@ -55,9 +55,18 @@
  * declarations before we can define it. Thus the duplciate effort.)
  */
-#define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
+#if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
+# define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
+#else
+# define RT_MANGLER(a_Name) RT_CONCAT(a_Name,_f16)
+#endif
 #include <iprt/mangling.h>
 #include <iprt/x86.h>
 #include <iprt/err.h>
 
+/*
+ * Include data symbol mangling (function mangling/mapping must be done
+ * after the protypes).
+ */
+#include "bs3kit-mangling-data.h"
 
 
@@ -492,5 +501,17 @@
 
 /** @def BS3_DECL
- * Declares a BS3Kit function.
+ * Declares a BS3Kit function with default far/near.
+ *
+ * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
+ *
+ * @param a_Type        The return type. */
+#if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
+# define BS3_DECL(a_Type)  BS3_DECL_NEAR(a_Type)
+#else
+# define BS3_DECL(a_Type)  BS3_DECL_FAR(a_Type)
+#endif
+
+/** @def BS3_DECL_NEAR
+ * Declares a BS3Kit function, always near everywhere.
  *
  * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
@@ -498,7 +519,19 @@
  * @param a_Type        The return type. */
 #ifdef IN_BS3KIT
-# define BS3_DECL(a_Type)   DECLEXPORT(a_Type) BS3_NEAR_CODE BS3_CALL
+# define BS3_DECL_NEAR(a_Type)  DECLEXPORT(a_Type) BS3_NEAR_CODE BS3_CALL
 #else
-# define BS3_DECL(a_Type)   DECLIMPORT(a_Type) BS3_NEAR_CODE BS3_CALL
+# define BS3_DECL_NEAR(a_Type)  DECLIMPORT(a_Type) BS3_NEAR_CODE BS3_CALL
+#endif
+
+/** @def BS3_DECL_FAR
+ * Declares a BS3Kit function, far 16-bit, otherwise near.
+ *
+ * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
+ *
+ * @param a_Type        The return type. */
+#ifdef IN_BS3KIT
+# define BS3_DECL_FAR(a_Type)   DECLEXPORT(a_Type) BS3_FAR_CODE BS3_CALL
+#else
+# define BS3_DECL_FAR(a_Type)   DECLIMPORT(a_Type) BS3_FAR_CODE BS3_CALL
 #endif
 
@@ -521,9 +554,43 @@
  *
  * @param   a_Name      The name of the function or global variable.
- */
-#define BS3_CMN_NM(a_Name)  RT_CONCAT3(a_Name,_c,ARCH_BITS)
+ * @todo fix code vs data issue with _f16
+ */
+#define BS3_CMN_NM(a_Name)      RT_CONCAT3(a_Name,_c,ARCH_BITS)
+
+/**
+ * Constructs a common function name, far in 16-bit code.
+ *
+ * Example: BS3_CMN_FAR_NM(Bs3Shutdown)
+ *
+ * @param   a_Name      The name of the function.
+ */
+#if ARCH_BITS == 16
+# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(a_Name,_f16)
+#else
+# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
+#endif
+
+/**
+ * Constructs a common function name, far or near as defined by the source.
+ *
+ * Which to use in 16-bit mode is defined by BS3_USE_RM_TEXT_SEG.  In 32-bit and
+ * 64-bit mode there are no far symbols, only near ones.
+ *
+ * Example: BS3_CMN_FN_NM(Bs3Shutdown)
+ *
+ * @param   a_Name      The name of the function.
+ */
+#if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
+# define BS3_CMN_FN_NM(a_Name)  BS3_CMN_NM(a_Name)
+#else
+# define BS3_CMN_FN_NM(a_Name)  BS3_CMN_FAR_NM(a_Name)
+#endif
+
 
 /**
  * Constructs a data name.
+ *
+ * This glosses over the underscore prefix usage of our 16-bit, 32-bit and
+ * 64-bit compilers.
  *
  * Example: @code{.c}
@@ -533,4 +600,5 @@
  *
  * @param   a_Name      The name of the global variable.
+ * @remarks Mainly used in bs3kit-mangling.h, internal headers and templates.
  */
 #if ARCH_BITS == 64
@@ -618,189 +686,4 @@
 /** @defgroup grp_bs3kit_system System structures
  * @{ */
-#if ARCH_BITS == 64 && !defined(DOXYGEN_RUNNING)
-# define Bs3Gdt                                 BS3_DATA_NM(Bs3Gdt)
-# define Bs3Gdt_Ldt                             BS3_DATA_NM(Bs3Gdt_Ldt)
-# define Bs3Gdte_Tss16                          BS3_DATA_NM(Bs3Gdte_Tss16)
-# define Bs3Gdte_Tss16DoubleFault               BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault)
-# define Bs3Gdte_Tss16Spare0                    BS3_DATA_NM(Bs3Gdte_Tss16Spare0)
-# define Bs3Gdte_Tss16Spare1                    BS3_DATA_NM(Bs3Gdte_Tss16Spare1)
-# define Bs3Gdte_Tss32                          BS3_DATA_NM(Bs3Gdte_Tss32)
-# define Bs3Gdte_Tss32DoubleFault               BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault)
-# define Bs3Gdte_Tss32Spare0                    BS3_DATA_NM(Bs3Gdte_Tss32Spare0)
-# define Bs3Gdte_Tss32Spare1                    BS3_DATA_NM(Bs3Gdte_Tss32Spare1)
-# define Bs3Gdte_Tss32IobpIntRedirBm            BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm)
-# define Bs3Gdte_Tss32IntRedirBm                BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm)
-# define Bs3Gdte_Tss64                          BS3_DATA_NM(Bs3Gdte_Tss64)
-# define Bs3Gdte_Tss64Spare0                    BS3_DATA_NM(Bs3Gdte_Tss64Spare0)
-# define Bs3Gdte_Tss64Spare1                    BS3_DATA_NM(Bs3Gdte_Tss64Spare1)
-# define Bs3Gdte_Tss64Iobp                      BS3_DATA_NM(Bs3Gdte_Tss64Iobp)
-# define Bs3Gdte_R0_MMIO16                      BS3_DATA_NM(Bs3Gdte_R0_MMIO16)
-
-# define Bs3Gdte_R0_First                       BS3_DATA_NM(Bs3Gdte_R0_First)
-# define Bs3Gdte_R0_CS16                        BS3_DATA_NM(Bs3Gdte_R0_CS16)
-# define Bs3Gdte_R0_DS16                        BS3_DATA_NM(Bs3Gdte_R0_DS16)
-# define Bs3Gdte_R0_SS16                        BS3_DATA_NM(Bs3Gdte_R0_SS16)
-# define Bs3Gdte_R0_CS32                        BS3_DATA_NM(Bs3Gdte_R0_CS32)
-# define Bs3Gdte_R0_DS32                        BS3_DATA_NM(Bs3Gdte_R0_DS32)
-# define Bs3Gdte_R0_SS32                        BS3_DATA_NM(Bs3Gdte_R0_SS32)
-# define Bs3Gdte_R0_CS64                        BS3_DATA_NM(Bs3Gdte_R0_CS64)
-# define Bs3Gdte_R0_DS64                        BS3_DATA_NM(Bs3Gdte_R0_DS64)
-# define Bs3Gdte_R0_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS16_EO)
-# define Bs3Gdte_R0_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF)
-# define Bs3Gdte_R0_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO)
-# define Bs3Gdte_R0_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS32_EO)
-# define Bs3Gdte_R0_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF)
-# define Bs3Gdte_R0_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO)
-# define Bs3Gdte_R0_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R0_CS64_EO)
-# define Bs3Gdte_R0_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF)
-# define Bs3Gdte_R0_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO)
-
-# define Bs3Gdte_R1_First                       BS3_DATA_NM(Bs3Gdte_R1_First)
-# define Bs3Gdte_R1_CS16                        BS3_DATA_NM(Bs3Gdte_R1_CS16)
-# define Bs3Gdte_R1_DS16                        BS3_DATA_NM(Bs3Gdte_R1_DS16)
-# define Bs3Gdte_R1_SS16                        BS3_DATA_NM(Bs3Gdte_R1_SS16)
-# define Bs3Gdte_R1_CS32                        BS3_DATA_NM(Bs3Gdte_R1_CS32)
-# define Bs3Gdte_R1_DS32                        BS3_DATA_NM(Bs3Gdte_R1_DS32)
-# define Bs3Gdte_R1_SS32                        BS3_DATA_NM(Bs3Gdte_R1_SS32)
-# define Bs3Gdte_R1_CS64                        BS3_DATA_NM(Bs3Gdte_R1_CS64)
-# define Bs3Gdte_R1_DS64                        BS3_DATA_NM(Bs3Gdte_R1_DS64)
-# define Bs3Gdte_R1_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS16_EO)
-# define Bs3Gdte_R1_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF)
-# define Bs3Gdte_R1_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO)
-# define Bs3Gdte_R1_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS32_EO)
-# define Bs3Gdte_R1_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF)
-# define Bs3Gdte_R1_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO)
-# define Bs3Gdte_R1_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R1_CS64_EO)
-# define Bs3Gdte_R1_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF)
-# define Bs3Gdte_R1_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO)
-
-# define Bs3Gdte_R2_First                       BS3_DATA_NM(Bs3Gdte_R2_First)
-# define Bs3Gdte_R2_CS16                        BS3_DATA_NM(Bs3Gdte_R2_CS16)
-# define Bs3Gdte_R2_DS16                        BS3_DATA_NM(Bs3Gdte_R2_DS16)
-# define Bs3Gdte_R2_SS16                        BS3_DATA_NM(Bs3Gdte_R2_SS16)
-# define Bs3Gdte_R2_CS32                        BS3_DATA_NM(Bs3Gdte_R2_CS32)
-# define Bs3Gdte_R2_DS32                        BS3_DATA_NM(Bs3Gdte_R2_DS32)
-# define Bs3Gdte_R2_SS32                        BS3_DATA_NM(Bs3Gdte_R2_SS32)
-# define Bs3Gdte_R2_CS64                        BS3_DATA_NM(Bs3Gdte_R2_CS64)
-# define Bs3Gdte_R2_DS64                        BS3_DATA_NM(Bs3Gdte_R2_DS64)
-# define Bs3Gdte_R2_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS16_EO)
-# define Bs3Gdte_R2_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF)
-# define Bs3Gdte_R2_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO)
-# define Bs3Gdte_R2_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS32_EO)
-# define Bs3Gdte_R2_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF)
-# define Bs3Gdte_R2_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO)
-# define Bs3Gdte_R2_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R2_CS64_EO)
-# define Bs3Gdte_R2_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF)
-# define Bs3Gdte_R2_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO)
-
-# define Bs3Gdte_R3_First                       BS3_DATA_NM(Bs3Gdte_R3_First)
-# define Bs3Gdte_R3_CS16                        BS3_DATA_NM(Bs3Gdte_R3_CS16)
-# define Bs3Gdte_R3_DS16                        BS3_DATA_NM(Bs3Gdte_R3_DS16)
-# define Bs3Gdte_R3_SS16                        BS3_DATA_NM(Bs3Gdte_R3_SS16)
-# define Bs3Gdte_R3_CS32                        BS3_DATA_NM(Bs3Gdte_R3_CS32)
-# define Bs3Gdte_R3_DS32                        BS3_DATA_NM(Bs3Gdte_R3_DS32)
-# define Bs3Gdte_R3_SS32                        BS3_DATA_NM(Bs3Gdte_R3_SS32)
-# define Bs3Gdte_R3_CS64                        BS3_DATA_NM(Bs3Gdte_R3_CS64)
-# define Bs3Gdte_R3_DS64                        BS3_DATA_NM(Bs3Gdte_R3_DS64)
-# define Bs3Gdte_R3_CS16_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS16_EO)
-# define Bs3Gdte_R3_CS16_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF)
-# define Bs3Gdte_R3_CS16_CND_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO)
-# define Bs3Gdte_R3_CS32_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS32_EO)
-# define Bs3Gdte_R3_CS32_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF)
-# define Bs3Gdte_R3_CS32_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO)
-# define Bs3Gdte_R3_CS64_EO                     BS3_DATA_NM(Bs3Gdte_R3_CS64_EO)
-# define Bs3Gdte_R3_CS64_CNF                    BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF)
-# define Bs3Gdte_R3_CS64_CNF_EO                 BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO)
-
-# define Bs3GdteSpare00                         BS3_DATA_NM(Bs3GdteSpare00)
-# define Bs3GdteSpare01                         BS3_DATA_NM(Bs3GdteSpare01)
-# define Bs3GdteSpare02                         BS3_DATA_NM(Bs3GdteSpare02)
-# define Bs3GdteSpare03                         BS3_DATA_NM(Bs3GdteSpare03)
-# define Bs3GdteSpare04                         BS3_DATA_NM(Bs3GdteSpare04)
-# define Bs3GdteSpare05                         BS3_DATA_NM(Bs3GdteSpare05)
-# define Bs3GdteSpare06                         BS3_DATA_NM(Bs3GdteSpare06)
-# define Bs3GdteSpare07                         BS3_DATA_NM(Bs3GdteSpare07)
-# define Bs3GdteSpare08                         BS3_DATA_NM(Bs3GdteSpare08)
-# define Bs3GdteSpare09                         BS3_DATA_NM(Bs3GdteSpare09)
-# define Bs3GdteSpare0a                         BS3_DATA_NM(Bs3GdteSpare0a)
-# define Bs3GdteSpare0b                         BS3_DATA_NM(Bs3GdteSpare0b)
-# define Bs3GdteSpare0c                         BS3_DATA_NM(Bs3GdteSpare0c)
-# define Bs3GdteSpare0d                         BS3_DATA_NM(Bs3GdteSpare0d)
-# define Bs3GdteSpare0e                         BS3_DATA_NM(Bs3GdteSpare0e)
-# define Bs3GdteSpare0f                         BS3_DATA_NM(Bs3GdteSpare0f)
-# define Bs3GdteSpare10                         BS3_DATA_NM(Bs3GdteSpare10)
-# define Bs3GdteSpare11                         BS3_DATA_NM(Bs3GdteSpare11)
-# define Bs3GdteSpare12                         BS3_DATA_NM(Bs3GdteSpare12)
-# define Bs3GdteSpare13                         BS3_DATA_NM(Bs3GdteSpare13)
-# define Bs3GdteSpare14                         BS3_DATA_NM(Bs3GdteSpare14)
-# define Bs3GdteSpare15                         BS3_DATA_NM(Bs3GdteSpare15)
-# define Bs3GdteSpare16                         BS3_DATA_NM(Bs3GdteSpare16)
-# define Bs3GdteSpare17                         BS3_DATA_NM(Bs3GdteSpare17)
-# define Bs3GdteSpare18                         BS3_DATA_NM(Bs3GdteSpare18)
-# define Bs3GdteSpare19                         BS3_DATA_NM(Bs3GdteSpare19)
-# define Bs3GdteSpare1a                         BS3_DATA_NM(Bs3GdteSpare1a)
-# define Bs3GdteSpare1b                         BS3_DATA_NM(Bs3GdteSpare1b)
-# define Bs3GdteSpare1c                         BS3_DATA_NM(Bs3GdteSpare1c)
-# define Bs3GdteSpare1d                         BS3_DATA_NM(Bs3GdteSpare1d)
-# define Bs3GdteSpare1e                         BS3_DATA_NM(Bs3GdteSpare1e)
-# define Bs3GdteSpare1f                         BS3_DATA_NM(Bs3GdteSpare1f)
-
-# define Bs3GdteTiled                           BS3_DATA_NM(Bs3GdteTiled)
-# define Bs3GdteFreePart1                       BS3_DATA_NM(Bs3GdteFreePart1)
-# define Bs3Gdte_CODE16                         BS3_DATA_NM(Bs3Gdte_CODE16)
-# define Bs3GdteFreePart2                       BS3_DATA_NM(Bs3GdteFreePart2)
-# define Bs3Gdte_SYSTEM16                       BS3_DATA_NM(Bs3Gdte_SYSTEM16)
-# define Bs3GdteFreePart3                       BS3_DATA_NM(Bs3GdteFreePart3)
-# define Bs3Gdte_DATA16                         BS3_DATA_NM(Bs3Gdte_DATA16)
-
-# define Bs3GdteFreePart4                       BS3_DATA_NM(Bs3GdteFreePart4)
-# define Bs3GdtePreTestPage08                   BS3_DATA_NM(Bs3GdtePreTestPage08)
-# define Bs3GdtePreTestPage07                   BS3_DATA_NM(Bs3GdtePreTestPage07)
-# define Bs3GdtePreTestPage06                   BS3_DATA_NM(Bs3GdtePreTestPage06)
-# define Bs3GdtePreTestPage05                   BS3_DATA_NM(Bs3GdtePreTestPage05)
-# define Bs3GdtePreTestPage04                   BS3_DATA_NM(Bs3GdtePreTestPage04)
-# define Bs3GdtePreTestPage03                   BS3_DATA_NM(Bs3GdtePreTestPage03)
-# define Bs3GdtePreTestPage02                   BS3_DATA_NM(Bs3GdtePreTestPage02)
-# define Bs3GdtePreTestPage01                   BS3_DATA_NM(Bs3GdtePreTestPage01)
-# define Bs3GdteTestPage                        BS3_DATA_NM(Bs3GdteTestPage)
-# define Bs3GdteTestPage00                      BS3_DATA_NM(Bs3GdteTestPage00)
-# define Bs3GdteTestPage01                      BS3_DATA_NM(Bs3GdteTestPage01)
-# define Bs3GdteTestPage02                      BS3_DATA_NM(Bs3GdteTestPage02)
-# define Bs3GdteTestPage03                      BS3_DATA_NM(Bs3GdteTestPage03)
-# define Bs3GdteTestPage04                      BS3_DATA_NM(Bs3GdteTestPage04)
-# define Bs3GdteTestPage05                      BS3_DATA_NM(Bs3GdteTestPage05)
-# define Bs3GdteTestPage06                      BS3_DATA_NM(Bs3GdteTestPage06)
-# define Bs3GdteTestPage07                      BS3_DATA_NM(Bs3GdteTestPage07)
-
-# define Bs3GdtEnd                              BS3_DATA_NM(Bs3GdtEnd)
-
-# define Bs3Tss16                               BS3_DATA_NM(Bs3Tss16)
-# define Bs3Tss16DoubleFault                    BS3_DATA_NM(Bs3Tss16DoubleFault)
-# define Bs3Tss16Spare0                         BS3_DATA_NM(Bs3Tss16Spare0)
-# define Bs3Tss16Spare1                         BS3_DATA_NM(Bs3Tss16Spare1)
-# define Bs3Tss32                               BS3_DATA_NM(Bs3Tss32)
-# define Bs3Tss32DoubleFault                    BS3_DATA_NM(Bs3Tss32DoubleFault)
-# define Bs3Tss32Spare0                         BS3_DATA_NM(Bs3Tss32Spare0)
-# define Bs3Tss32Spare1                         BS3_DATA_NM(Bs3Tss32Spare1)
-# define Bs3Tss64                               BS3_DATA_NM(Bs3Tss64)
-# define Bs3Tss64Spare0                         BS3_DATA_NM(Bs3Tss64Spare0)
-# define Bs3Tss64Spare1                         BS3_DATA_NM(Bs3Tss64Spare1)
-# define Bs3Tss64WithIopb                       BS3_DATA_NM(Bs3Tss64WithIopb)
-# define Bs3Tss32WithIopb                       BS3_DATA_NM(Bs3Tss32WithIopb)
-# define Bs3SharedIntRedirBm                    BS3_DATA_NM(Bs3SharedIntRedirBm)
-# define Bs3SharedIobp                          BS3_DATA_NM(Bs3SharedIobp)
-# define Bs3SharedIobpEnd                       BS3_DATA_NM(Bs3SharedIobpEnd)
-# define Bs3Idt16                               BS3_DATA_NM(Bs3Idt16)
-# define Bs3Idt32                               BS3_DATA_NM(Bs3Idt32)
-# define Bs3Idt64                               BS3_DATA_NM(Bs3Idt64)
-# define Bs3Lidt_Idt16                          BS3_DATA_NM(Bs3Lidt_Idt16)
-# define Bs3Lidt_Idt32                          BS3_DATA_NM(Bs3Lidt_Idt32)
-# define Bs3Lidt_Idt64                          BS3_DATA_NM(Bs3Lidt_Idt64)
-# define Bs3Lidt_Ivt                            BS3_DATA_NM(Bs3Lidt_Ivt)
-# define Bs3Lgdt_Gdt                            BS3_DATA_NM(Bs3Lgdt_Gdt)
-# define Bs3Ldt                                 BS3_DATA_NM(Bs3Ldt)
-# define Bs3LdtEnd                              BS3_DATA_NM(Bs3LdtEnd)
-#endif /* ARCH_BITS == 64 && !DOXYGEN_RUNNING*/
-
 /** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
 extern X86DESC BS3_FAR_DATA Bs3Gdt[(BS3_SEL_GDT_LIMIT + 1) / 8];
@@ -1024,94 +907,43 @@
  * @{ */
 /** Start of the BS3TEXT16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text16_StartOfSegment BS3_DATA_NM(Bs3Text16_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text16_StartOfSegment;
 /** End of the BS3TEXT16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text16_EndOfSegment BS3_DATA_NM(Bs3Text16_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text16_EndOfSegment;
 /** The size of the BS3TEXT16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text16_Size BS3_DATA_NM(Bs3Text16_Size)
-#endif
 extern uint16_t BS3_FAR_DATA Bs3Text16_Size;
 
 /** Start of the BS3SYSTEM16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3System16_StartOfSegment BS3_DATA_NM(Bs3System16_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3System16_StartOfSegment;
 /** End of the BS3SYSTEM16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3System16_EndOfSegment BS3_DATA_NM(Bs3System16_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3System16_EndOfSegment;
 
 /** Start of the BS3DATA16/BS3KIT_GRPNM_DATA16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data16_StartOfSegment BS3_DATA_NM(Bs3Data16_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data16_StartOfSegment;
 /** End of the BS3DATA16/BS3KIT_GRPNM_DATA16 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data16_EndOfSegment BS3_DATA_NM(Bs3Data16_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data16_EndOfSegment;
 
 /** Start of the BS3TEXT32 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text32_StartOfSegment BS3_DATA_NM(Bs3Text32_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text32_StartOfSegment;
 /** Start of the BS3TEXT32 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text32_EndOfSegment BS3_DATA_NM(Bs3Text32_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text32_EndOfSegment;
 
 /** Start of the BS3DATA32 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data32_StartOfSegment BS3_DATA_NM(Bs3Data32_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data32_StartOfSegment;
 /** Start of the BS3DATA32 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data32_EndOfSegment BS3_DATA_NM(Bs3Data32_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data32_EndOfSegment;
 
 /** Start of the BS3TEXT64 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text64_StartOfSegment BS3_DATA_NM(Bs3Text64_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text64_StartOfSegment;
 /** Start of the BS3TEXT64 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Text64_EndOfSegment BS3_DATA_NM(Bs3Text64_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Text64_EndOfSegment;
 
 /** Start of the BS3DATA64 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data64_StartOfSegment BS3_DATA_NM(Bs3Data64_StartOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data64_StartOfSegment;
 /** Start of the BS3DATA64 segment.   */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data64_EndOfSegment BS3_DATA_NM(Bs3Data64_EndOfSegment)
-#endif
 extern uint8_t  BS3_FAR_DATA Bs3Data64_EndOfSegment;
 
 /** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */
-#ifndef DOXYGEN_RUNNING
-# define Bs3Data16Thru64Text32And64_TotalSize BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize)
-#endif
 extern uint32_t BS3_FAR_DATA Bs3Data16Thru64Text32And64_TotalSize;
 /** The total image size (from Text16 thu Data64). */
-#ifndef DOXYGEN_RUNNING
-# define Bs3TotalImageSize BS3_DATA_NM(Bs3TotalImageSize)
-#endif
 extern uint32_t BS3_FAR_DATA Bs3TotalImageSize;
 /** @} */
@@ -1119,26 +951,17 @@
 
 /** Lower case hex digits. */
-#ifndef DOXYGEN_RUNNING
-# define g_achBs3HexDigits BS3_DATA_NM(g_achBs3HexDigits)
-#endif
 extern char const g_achBs3HexDigits[16+1];
 /** Upper case hex digits. */
-#ifndef DOXYGEN_RUNNING
-# define g_achBs3HexDigitsUpper BS3_DATA_NM(g_achBs3HexDigitsUpper)
-#endif
 extern char const g_achBs3HexDigitsUpper[16+1];
 
 
 /** The current mode (BS3_MODE_XXX) of CPU \#0. */
-#ifndef DOXYGEN_RUNNING
-# define g_bBs3CurrentMode BS3_DATA_NM(g_bBs3CurrentMode)
-#endif
 extern uint8_t    g_bBs3CurrentMode;
 
 /** Hint for 16-bit trap handlers regarding the high word of EIP. */
-#ifndef DOXYGEN_RUNNING
-# define g_uBs3TrapEipHint BS3_DATA_NM(g_uBs3TrapEipHint)
-#endif
 extern uint32_t   g_uBs3TrapEipHint;
+
+/** Copy of the original real-mode interrupt vector table. */
+extern RTFAR16 g_aBs3RmIvtOriginal[256];
 
 
@@ -1403,4 +1226,43 @@
  */
 
+/** @def BS3_CMN_PROTO
+ * Macro for prototyping all the variations of a common function.
+ * @param   a_RetType   The return type.
+ * @param   a_Name      The function basename.
+ * @param   a_Params    The parameter list (in parentheses).
+ * @param   a_fAutoStub Whether to autogenerate a 16-bit near -> 16-bit far stub
+ *                      function. Either 'true' for stub or 'false' for no stub.
+ */
+#if ARCH_BITS == 16
+# define BS3_CMN_PROTO(a_RetType, a_Name, a_Params, a_fAutoStub) \
+    BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params;  \
+    BS3_DECL_FAR(a_RetType)  BS3_CMN_FAR_NM(a_Name) a_Params
+#else
+# define BS3_CMN_PROTO(a_RetType, a_Name, a_Params, a_fAutoStub) \
+    BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params
+#endif
+
+/** @def BS3_CMN_DEF
+ * Macro for defining a common function.
+ *
+ * This makes 16-bit common function far, while 32-bit and 64-bit are near.
+ *
+ * @param   a_RetType   The return type.
+ * @param   a_Name      The function basename.
+ * @param   a_Params    The parameter list (in parentheses).
+ */
+#if ARCH_BITS == 16
+# define BS3_CMN_DEF(a_RetType, a_Name, a_Params) \
+    BS3_DECL_FAR(a_RetType)  BS3_CMN_FAR_NM(a_Name) a_Params
+#else
+# define BS3_CMN_DEF(a_RetType, a_Name, a_Params) \
+    BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params
+#endif
+
+/** @def BS3_ASSERT
+ * Assert that an expression is true.
+ *
+ * Calls Bs3Panic if false and it's a strict build.  Does nothing in
+ * non-strict builds.  */
 #ifdef BS3_STRICT
 # define BS3_ASSERT(a_Expr) do { if (!!(a_Expr)) { /* likely */ } else { Bs3Panic(); } } while (0) /**< @todo later */
@@ -1414,10 +1276,8 @@
  * The current implementation will only halt the CPU.
  */
-BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c16(void);
-BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16  */
-BS3_DECL(DECL_NO_RETURN(void)) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16  */
-#define Bs3Panic BS3_CMN_NM(Bs3Panic) /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
+BS3_CMN_PROTO(DECL_NO_RETURN(void), Bs3Panic,(void), false);
 #if !defined(BS3_KIT_WITH_NO_RETURN) && defined(__WATCOMC__)
 # pragma aux Bs3Panic_c16 __aborts
+# pragma aux Bs3Panic_f16 __aborts
 # pragma aux Bs3Panic_c32 __aborts
 #endif
@@ -1429,8 +1289,5 @@
  * 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. */
+BS3_CMN_PROTO(void, Bs3Shutdown,(void), false);
 
 /**
@@ -1439,8 +1296,5 @@
  * @param   uValue      The 32-bit value.
  */
-BS3_DECL(void) Bs3PrintU32_c16(uint32_t uValue);
-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. */
+BS3_CMN_PROTO(void, Bs3PrintU32,(uint32_t uValue), false);
 
 /**
@@ -1449,8 +1303,5 @@
  * @param   uValue      The 32-bit value.
  */
-BS3_DECL(void) Bs3PrintX32_c16(uint32_t uValue);
-BS3_DECL(void) Bs3PrintX32_c32(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
-BS3_DECL(void) Bs3PrintX32_c64(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
-#define Bs3PrintX32 BS3_CMN_NM(Bs3PrintX32) /**< Selects #Bs3PrintX32_c16, #Bs3PrintX32_c32 or #Bs3PrintX32_c64. */
+BS3_CMN_PROTO(void, Bs3PrintX32,(uint32_t uValue), false);
 
 /**
@@ -1462,8 +1313,5 @@
  * @param   ...             Format arguments.
  */
-BS3_DECL(size_t) Bs3Printf_c16(const char BS3_FAR *pszFormat, ...);
-BS3_DECL(size_t) Bs3Printf_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
-BS3_DECL(size_t) Bs3Printf_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
-#define Bs3Printf BS3_CMN_NM(Bs3Printf) /**< Selects #Bs3Printf_c16, #Bs3Printf_c32 or #Bs3Printf_c64. */
+BS3_CMN_PROTO(size_t, Bs3Printf,(const char BS3_FAR *pszFormat, ...), true);
 
 /**
@@ -1475,8 +1323,5 @@
  * @param   va              Format arguments.
  */
-BS3_DECL(size_t) Bs3PrintfV_c16(const char BS3_FAR *pszFormat, va_list va);
-BS3_DECL(size_t) Bs3PrintfV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
-BS3_DECL(size_t) Bs3PrintfV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
-#define Bs3PrintfV BS3_CMN_NM(Bs3PrintfV) /**< Selects #Bs3PrintfV_c16, #Bs3PrintfV_c32 or #Bs3PrintfV_c64. */
+BS3_CMN_PROTO(size_t, Bs3PrintfV,(const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
@@ -1485,8 +1330,5 @@
  * @param   pszString       The string to print.
  */
-BS3_DECL(void) Bs3PrintStr_c16(const char BS3_FAR *pszString);
-BS3_DECL(void) Bs3PrintStr_c32(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
-BS3_DECL(void) Bs3PrintStr_c64(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
-#define Bs3PrintStr BS3_CMN_NM(Bs3PrintStr) /**< Selects #Bs3PrintStr_c16, #Bs3PrintStr_c32 or #Bs3PrintStr_c64. */
+BS3_CMN_PROTO(void, Bs3PrintStr,(const char BS3_FAR *pszString), true);
 
 /**
@@ -1496,8 +1338,5 @@
  * @param   cchString       The exact number of characters to print.
  */
-BS3_DECL(void) Bs3PrintStrN_c16(const char BS3_FAR *pszString, size_t cchString);
-BS3_DECL(void) Bs3PrintStrN_c32(const char BS3_FAR *pszString, size_t cchString); /**< @copydoc Bs3PrintStrN_c16 */
-BS3_DECL(void) Bs3PrintStrN_c64(const char BS3_FAR *pszString, size_t cchString); /**< @copydoc Bs3PrintStrN_c16 */
-#define Bs3PrintStrN BS3_CMN_NM(Bs3PrintStrN) /**< Selects #Bs3PrintStrN_c16, #Bs3PrintStrN_c32 or #Bs3PrintStrN_c64. */
+BS3_CMN_PROTO(void, Bs3PrintStrN,(const char BS3_FAR *pszString, size_t cchString), false);
 
 /**
@@ -1506,8 +1345,5 @@
  * @param   ch              The character to print.
  */
-BS3_DECL(void) Bs3PrintChr_c16(char ch);
-BS3_DECL(void) Bs3PrintChr_c32(char ch); /**< @copydoc Bs3PrintChr_c16 */
-BS3_DECL(void) Bs3PrintChr_c64(char ch); /**< @copydoc Bs3PrintChr_c16 */
-#define Bs3PrintChr BS3_CMN_NM(Bs3PrintChr) /**< Selects #Bs3PrintChr_c16, #Bs3PrintChr_c32 or #Bs3PrintChr_c64. */
+BS3_CMN_PROTO(void, Bs3PrintChr,(char ch), false);
 
 
@@ -1543,13 +1379,6 @@
  * @param   pvUser      The user argument for the output function.
  */
-BS3_DECL(size_t) Bs3StrFormatV_c16(const char BS3_FAR *pszFormat, va_list va,
-                                   PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
-/** @copydoc Bs3StrFormatV_c16  */
-BS3_DECL(size_t) Bs3StrFormatV_c32(const char BS3_FAR *pszFormat, va_list va,
-                                   PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
-/** @copydoc Bs3StrFormatV_c16  */
-BS3_DECL(size_t) Bs3StrFormatV_c64(const char BS3_FAR *pszFormat, va_list va,
-                                   PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
-#define Bs3StrFormatV BS3_CMN_NM(Bs3StrFormatV) /**< Selects #Bs3StrFormatV_c16, #Bs3StrFormatV_c32 or #Bs3StrFormatV_c64. */
+BS3_CMN_PROTO(size_t, Bs3StrFormatV,(const char BS3_FAR *pszFormat, va_list va,
+                                     PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser), true);
 
 /**
@@ -1565,10 +1394,5 @@
  * @param   va          Format arguments.
  */
-BS3_DECL(size_t) Bs3StrPrintfV_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
-/** @copydoc Bs3StrPrintfV_c16  */
-BS3_DECL(size_t) Bs3StrPrintfV_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
-/** @copydoc Bs3StrPrintfV_c16  */
-BS3_DECL(size_t) Bs3StrPrintfV_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
-#define Bs3StrPrintfV BS3_CMN_NM(Bs3StrPrintfV) /**< Selects #Bs3StrPrintfV_c16, #Bs3StrPrintfV_c32 or #Bs3StrPrintfV_c64. */
+BS3_CMN_PROTO(size_t, Bs3StrPrintfV,(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
@@ -1584,10 +1408,5 @@
  * @param   ...         Format arguments.
  */
-BS3_DECL(size_t) Bs3StrPrintf_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
-/** @copydoc Bs3StrPrintf_c16  */
-BS3_DECL(size_t) Bs3StrPrintf_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
-/** @copydoc Bs3StrPrintf_c16  */
-BS3_DECL(size_t) Bs3StrPrintf_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
-#define Bs3StrPrintf BS3_CMN_NM(Bs3StrPrintf) /**< Selects #Bs3StrPrintf_c16, #Bs3StrPrintf_c32 or #Bs3StrPrintf_c64. */
+BS3_CMN_PROTO(size_t, Bs3StrPrintf,(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...), true);
 
 
@@ -1598,8 +1417,5 @@
  * @param   pszString       The string to examine.
  */
-BS3_DECL(size_t) Bs3StrLen_c16(const char BS3_FAR *pszString);
-BS3_DECL(size_t) Bs3StrLen_c32(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
-BS3_DECL(size_t) Bs3StrLen_c64(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
-#define Bs3StrLen BS3_CMN_NM(Bs3StrLen) /**< Selects #Bs3StrLen_c16, #Bs3StrLen_c32 or #Bs3StrLen_c64. */
+BS3_CMN_PROTO(size_t, Bs3StrLen,(const char BS3_FAR *pszString), true);
 
 /**
@@ -1611,8 +1427,5 @@
  * @param   cchMax          The max length to examine.
  */
-BS3_DECL(size_t) Bs3StrNLen_c16(const char BS3_FAR *pszString, size_t cchMax);
-BS3_DECL(size_t) Bs3StrNLen_c32(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
-BS3_DECL(size_t) Bs3StrNLen_c64(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
-#define Bs3StrNLen BS3_CMN_NM(Bs3StrNLen) /**< Selects #Bs3StrNLen_c16, #Bs3StrNLen_c32 or #Bs3StrNLen_c64. */
+BS3_CMN_PROTO(size_t, Bs3StrNLen,(const char BS3_FAR *pszString, size_t cchMax), true);
 
 /**
@@ -1624,8 +1437,5 @@
  * @param   pszSrc          The source string.
  */
-BS3_DECL(char BS3_FAR *) Bs3StrCpy_c16(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc);
-BS3_DECL(char BS3_FAR *) Bs3StrCpy_c32(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
-BS3_DECL(char BS3_FAR *) Bs3StrCpy_c64(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
-#define Bs3StrCpy BS3_CMN_NM(Bs3StrCpy) /**< Selects #Bs3StrCpy_c16, #Bs3StrCpy_c32 or #Bs3StrCpy_c64. */
+BS3_CMN_PROTO(char BS3_FAR *, Bs3StrCpy,(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc), true);
 
 /**
@@ -1637,8 +1447,5 @@
  * @param   cbCopy          The number of bytes to copy.
  */
-BS3_DECL(void BS3_FAR *) Bs3MemCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
-BS3_DECL(void BS3_FAR *) Bs3MemCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
-BS3_DECL(void BS3_FAR *) Bs3MemCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
-#define Bs3MemCpy BS3_CMN_NM(Bs3MemCpy) /**< Selects #Bs3MemCpy_c16, #Bs3MemCpy_c32 or #Bs3MemCpy_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3MemCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy), true);
 
 /**
@@ -1650,8 +1457,5 @@
  * @param   cbCopy          The number of bytes to copy.
  */
-BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
-BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
-BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
-#define Bs3MemPCpy BS3_CMN_NM(Bs3MemPCpy) /**< Selects #Bs3MemPCpy_c16, #Bs3MemPCpy_c32 or #Bs3MemPCpy_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3MemPCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy), true);
 
 /**
@@ -1663,8 +1467,5 @@
  * @param   cbCopy          The number of bytes to copy.
  */
-BS3_DECL(void BS3_FAR *) Bs3MemMove_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
-BS3_DECL(void BS3_FAR *) Bs3MemMove_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
-BS3_DECL(void BS3_FAR *) Bs3MemMove_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
-#define Bs3MemMove BS3_CMN_NM(Bs3MemMove) /**< Selects #Bs3MemMove_c16, #Bs3MemMove_c32 or #Bs3MemMove_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3MemMove,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy), true);
 
 /**
@@ -1674,8 +1475,5 @@
  * @param   cbDst           The number of bytes to zero.
  */
-BS3_DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);
-BS3_DECL(void) Bs3MemZero_c32(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
-BS3_DECL(void) Bs3MemZero_c64(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
-#define Bs3MemZero BS3_CMN_NM(Bs3MemZero) /**< Selects #Bs3MemZero_c16, #Bs3MemZero_c32 or #Bs3MemZero_c64. */
+BS3_CMN_PROTO(void, Bs3MemZero,(void BS3_FAR *pvDst, size_t cbDst), false);
 
 
@@ -1687,8 +1485,5 @@
  * @param   uSel            The protected mode segment selector.
  */
-BS3_DECL(uint32_t) Bs3SelProtFar32ToFlat32_c16(uint32_t off, uint16_t uSel);
-BS3_DECL(uint32_t) Bs3SelProtFar32ToFlat32_c32(uint32_t off, uint16_t uSel); /**< @copydoc Bs3SelProtFar32ToFlat32_c16 */
-BS3_DECL(uint32_t) Bs3SelProtFar32ToFlat32_c64(uint32_t off, uint16_t uSel); /**< @copydoc Bs3SelProtFar32ToFlat32_c16 */
-#define Bs3SelProtFar32ToFlat32 BS3_CMN_NM(Bs3SelProtFar32ToFlat32) /**< Selects #Bs3SelProtFar32ToFlat32_c16, #Bs3SelProtFar32ToFlat32_c32 or #Bs3SelProtFar32ToFlat32_c64. */
+BS3_CMN_PROTO(uint32_t, Bs3SelProtFar32ToFlat32,(uint32_t off, uint16_t uSel), true);
 
 
@@ -1700,8 +1495,5 @@
  * @param   uSel            The current mode segment selector.
  */
-BS3_DECL(uint32_t) Bs3SelFar32ToFlat32_c16(uint32_t off, uint16_t uSel);
-BS3_DECL(uint32_t) Bs3SelFar32ToFlat32_c32(uint32_t off, uint16_t uSel); /**< @copydoc Bs3SelFar32ToFlat32_c16 */
-BS3_DECL(uint32_t) Bs3SelFar32ToFlat32_c64(uint32_t off, uint16_t uSel); /**< @copydoc Bs3SelFar32ToFlat32_c16 */
-#define Bs3SelFar32ToFlat32 BS3_CMN_NM(Bs3SelFar32ToFlat32) /**< Selects #Bs3SelFar32ToFlat32_c16, #Bs3SelFar32ToFlat32_c32 or #Bs3SelFar32ToFlat32_c64. */
+BS3_CMN_PROTO(uint32_t, Bs3SelFar32ToFlat32,(uint32_t off, uint16_t uSel), true);
 
 /**
@@ -1714,5 +1506,5 @@
 {
 #if ARCH_BITS == 16
-    return Bs3SelFar32ToFlat32(BS3_FP_OFF(pv), BS3_FP_SEG(pv));
+    return BS3_CMN_FN_NM(Bs3SelFar32ToFlat32)(BS3_FP_OFF(pv), BS3_FP_SEG(pv));
 #else
     return (uintptr_t)pv;
@@ -1784,10 +1576,6 @@
  * @param   cbChunk         The chunk size.
  */
-BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
-/** @copydoc Bs3SlabInit_c16 */
-BS3_DECL(void) Bs3SlabInit_c32(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
-/** @copydoc Bs3SlabInit_c16 */
-BS3_DECL(void) Bs3SlabInit_c64(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
-#define Bs3SlabInit BS3_CMN_NM(Bs3SlabInit) /**< Selects #Bs3SlabInit_c16, #Bs3SlabInit_c32 or #Bs3SlabInit_c64. */
+BS3_CMN_PROTO(void, Bs3SlabInit,(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr,
+                                 uint32_t cbSlab, uint16_t cbChunk), true);
 
 /**
@@ -1797,8 +1585,5 @@
  * @param   pSlabCtl        The slab constrol structure to allocate from.
  */
-BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c16(PBS3SLABCTL pSlabCtl);
-BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c32(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
-BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c64(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
-#define Bs3SlabAlloc BS3_CMN_NM(Bs3SlabAlloc) /**< Selects #Bs3SlabAlloc_c16, #Bs3SlabAlloc_c32 or #Bs3SlabAlloc_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3SlabAlloc,(PBS3SLABCTL pSlabCtl), true);
 
 /**
@@ -1811,8 +1596,5 @@
  * @param   fFlags          Flags, see BS3_SLAB_ALLOC_F_XXX
  */
-BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c16(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags);
-BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c32(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
-BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c64(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
-#define Bs3SlabAllocEx BS3_CMN_NM(Bs3SlabAllocEx) /**< Selects #Bs3SlabAllocEx_c16, #Bs3SlabAllocEx_c32 or #Bs3SlabAllocEx_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3SlabAllocEx,(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags), true);
 
 /**
@@ -1825,8 +1607,5 @@
  * @param   cChunks         The number of contiguous chunks to free.
  */
-BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks);
-BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
-BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
-#define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */
+BS3_CMN_PROTO(uint16_t, Bs3SlabFree,(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks), true);
 
 
@@ -1837,8 +1616,5 @@
  * @param   cbChunk     The chunk size.
  */
-BS3_DECL(void) Bs3SlabListInit_c16(PBS3SLABHEAD pHead, uint16_t cbChunk);
-BS3_DECL(void) Bs3SlabListInit_c32(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
-BS3_DECL(void) Bs3SlabListInit_c64(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
-#define Bs3SlabListInit BS3_CMN_NM(Bs3SlabListInit) /**< Selects #Bs3SlabListInit_c16, #Bs3SlabListInit_c32 or #Bs3SlabListInit_c64. */
+BS3_CMN_PROTO(void, Bs3SlabListInit,(PBS3SLABHEAD pHead, uint16_t cbChunk), true);
 
 /**
@@ -1848,10 +1624,5 @@
  * @param   pSlabCtl        The slab control structure to add.
  */
-BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
-/** @copydoc Bs3SlabListAdd_c16 */
-BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
-/** @copydoc Bs3SlabListAdd_c16 */
-BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
-#define Bs3SlabListAdd BS3_CMN_NM(Bs3SlabListAdd) /**< Selects #Bs3SlabListAdd_c16, #Bs3SlabListAdd_c32 or #Bs3SlabListAdd_c64. */
+BS3_CMN_PROTO(void, Bs3SlabListAdd,(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl), true);
 
 /**
@@ -1861,8 +1632,5 @@
  * @param   pHead           The slab list to allocate from.
  */
-BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c16(PBS3SLABHEAD pHead);
-BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c32(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
-BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c64(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
-#define Bs3SlabListAlloc BS3_CMN_NM(Bs3SlabListAlloc) /**< Selects #Bs3SlabListAlloc_c16, #Bs3SlabListAlloc_c32 or #Bs3SlabListAlloc_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3SlabListAlloc,(PBS3SLABHEAD pHead), true);
 
 /**
@@ -1875,8 +1643,5 @@
  * @param   fFlags          Flags, see BS3_SLAB_ALLOC_F_XXX
  */
-BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c16(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags);
-BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c32(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
-BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c64(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
-#define Bs3SlabListAllocEx BS3_CMN_NM(Bs3SlabListAllocEx) /**< Selects #Bs3SlabListAllocEx_c16, #Bs3SlabListAllocEx_c32 or #Bs3SlabListAllocEx_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3SlabListAllocEx,(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags), true);
 
 /**
@@ -1887,8 +1652,5 @@
  * @param   cChunks         The number of contiguous chunks to free.
  */
-BS3_DECL(void) Bs3SlabListFree_c16(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks);
-BS3_DECL(void) Bs3SlabListFree_c32(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
-BS3_DECL(void) Bs3SlabListFree_c64(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
-#define Bs3SlabListFree BS3_CMN_NM(Bs3SlabListFree) /**< Selects #Bs3SlabListFree_c16, #Bs3SlabListFree_c32 or #Bs3SlabListFree_c64. */
+BS3_CMN_PROTO(void, Bs3SlabListFree,(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks), true);
 
 /**
@@ -1919,8 +1681,5 @@
  * @param   cb          How much to allocate.  Must be 4KB or less.
  */
-BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c16(BS3MEMKIND enmKind, size_t cb);
-BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
-BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
-#define Bs3MemAlloc BS3_CMN_NM(Bs3MemAlloc) /**< Selects #Bs3MemAlloc_c16, #Bs3MemAlloc_c32 or #Bs3MemAlloc_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3MemAlloc,(BS3MEMKIND enmKind, size_t cb), true);
 
 /**
@@ -1931,8 +1690,5 @@
  * @param   cb          How much to allocate.  Must be 4KB or less.
  */
-BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c16(BS3MEMKIND enmKind, size_t cb);
-BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
-BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
-#define Bs3MemAllocZ BS3_CMN_NM(Bs3MemAllocZ) /**< Selects #Bs3MemAllocZ_c16, #Bs3MemAllocZ_c32 or #Bs3MemAllocZ_c64. */
+BS3_CMN_PROTO(void BS3_FAR *, Bs3MemAllocZ,(BS3MEMKIND enmKind, size_t cb), true);
 
 /**
@@ -1943,8 +1699,5 @@
  * @param   cb          The size of the allocation.
  */
-BS3_DECL(void) Bs3MemFree_c16(void BS3_FAR *pv, size_t cb);
-BS3_DECL(void) Bs3MemFree_c32(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
-BS3_DECL(void) Bs3MemFree_c64(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
-#define Bs3MemFree BS3_CMN_NM(Bs3MemFree) /**< Selects #Bs3MemFree_c16, #Bs3MemFree_c32 or #Bs3MemFree_c64. */
+BS3_CMN_PROTO(void, Bs3MemFree,(void BS3_FAR *pv, size_t cb), true);
 
 
@@ -1952,48 +1705,30 @@
  * Enables the A20 gate.
  */
-BS3_DECL(void) Bs3A20Enable_c16(void);
-BS3_DECL(void) Bs3A20Enable_c32(void); /**< @copydoc Bs3A20Enable_c16 */
-BS3_DECL(void) Bs3A20Enable_c64(void); /**< @copydoc Bs3A20Enable_c16 */
-#define Bs3A20Enable BS3_CMN_NM(Bs3A20Enable) /**< Selects #Bs3A20Enable_c16, #Bs3A20Enable_c32 or #Bs3A20Enable_c64. */
+BS3_CMN_PROTO(void, Bs3A20Enable,(void), false);
 
 /**
  * Enables the A20 gate via the keyboard controller
  */
-BS3_DECL(void) Bs3A20EnableViaKbd_c16(void);
-BS3_DECL(void) Bs3A20EnableViaKbd_c32(void); /**< @copydoc Bs3A20EnableViaKbd_c16 */
-BS3_DECL(void) Bs3A20EnableViaKbd_c64(void); /**< @copydoc Bs3A20EnableViaKbd_c16 */
-#define Bs3A20EnableViaKbd BS3_CMN_NM(Bs3A20EnableViaKbd) /**< Selects #Bs3A20EnableViaKbd_c16, #Bs3A20EnableViaKbd_c32 or #Bs3A20EnableViaKbd_c64. */
+BS3_CMN_PROTO(void, Bs3A20EnableViaKbd,(void), false);
 
 /**
  * Enables the A20 gate via the PS/2 control port A.
  */
-BS3_DECL(void) Bs3A20EnableViaPortA_c16(void);
-BS3_DECL(void) Bs3A20EnableViaPortA_c32(void); /**< @copydoc Bs3A20EnableViaPortA_c16 */
-BS3_DECL(void) Bs3A20EnableViaPortA_c64(void); /**< @copydoc Bs3A20EnableViaPortA_c16 */
-#define Bs3A20EnableViaPortA BS3_CMN_NM(Bs3A20EnableViaPortA) /**< Selects #Bs3A20EnableViaPortA_c16, #Bs3A20EnableViaPortA_c32 or #Bs3A20EnableViaPortA_c64. */
+BS3_CMN_PROTO(void, Bs3A20EnableViaPortA,(void), false);
 
 /**
  * Disables the A20 gate.
  */
-BS3_DECL(void) Bs3A20Disable_c16(void);
-BS3_DECL(void) Bs3A20Disable_c32(void); /**< @copydoc Bs3A20Disable_c16 */
-BS3_DECL(void) Bs3A20Disable_c64(void); /**< @copydoc Bs3A20Disable_c16 */
-#define Bs3A20Disable BS3_CMN_NM(Bs3A20Disable) /**< Selects #Bs3A20Disable_c16, #Bs3A20Disable_c32 or #Bs3A20Disable_c64. */
+BS3_CMN_PROTO(void, Bs3A20Disable,(void), false);
 
 /**
  * Disables the A20 gate via the keyboard controller
  */
-BS3_DECL(void) Bs3A20DisableViaKbd_c16(void);
-BS3_DECL(void) Bs3A20DisableViaKbd_c32(void); /**< @copydoc Bs3A20DisableViaKbd_c16 */
-BS3_DECL(void) Bs3A20DisableViaKbd_c64(void); /**< @copydoc Bs3A20DisableViaKbd_c16 */
-#define Bs3A20DisableViaKbd BS3_CMN_NM(Bs3A20DisableViaKbd) /**< Selects #Bs3A20DisableViaKbd_c16, #Bs3A20DisableViaKbd_c32 or #Bs3A20DisableViaKbd_c64. */
+BS3_CMN_PROTO(void, Bs3A20DisableViaKbd,(void), false);
 
 /**
  * Disables the A20 gate via the PS/2 control port A.
  */
-BS3_DECL(void) Bs3A20DisableViaPortA_c16(void);
-BS3_DECL(void) Bs3A20DisableViaPortA_c32(void); /**< @copydoc Bs3A20DisableViaPortA_c16 */
-BS3_DECL(void) Bs3A20DisableViaPortA_c64(void); /**< @copydoc Bs3A20DisableViaPortA_c16 */
-#define Bs3A20DisableViaPortA BS3_CMN_NM(Bs3A20DisableViaPortA) /**< Selects #Bs3A20DisableViaPortA_c16, #Bs3A20DisableViaPortA_c32 or #Bs3A20DisableViaPortA_c64. */
+BS3_CMN_PROTO(void, Bs3A20DisableViaPortA,(void), false);
 
 
@@ -2004,8 +1739,5 @@
  * @remarks Must not be called in real-mode!
  */
-BS3_DECL(int) Bs3PagingInitRootForPP_c16(void);
-BS3_DECL(int) Bs3PagingInitRootForPP_c32(void); /**< @copydoc Bs3PagingInitRootForPP_c16 */
-BS3_DECL(int) Bs3PagingInitRootForPP_c64(void); /**< @copydoc Bs3PagingInitRootForPP_c16 */
-#define Bs3PagingInitRootForPP BS3_CMN_NM(Bs3PagingInitRootForPP) /**< Selects #Bs3PagingInitRootForPP_c16, #Bs3PagingInitRootForPP_c32 or #Bs3PagingInitRootForPP_c64. */
+BS3_CMN_PROTO(int, Bs3PagingInitRootForPP,(void), true);
 
 /**
@@ -2016,8 +1748,5 @@
  * @remarks Must not be called in real-mode!
  */
-BS3_DECL(int) Bs3PagingInitRootForPAE_c16(void);
-BS3_DECL(int) Bs3PagingInitRootForPAE_c32(void); /**< @copydoc Bs3PagingInitRootForPAE_c16 */
-BS3_DECL(int) Bs3PagingInitRootForPAE_c64(void); /**< @copydoc Bs3PagingInitRootForPAE_c16 */
-#define Bs3PagingInitRootForPAE BS3_CMN_NM(Bs3PagingInitRootForPAE) /**< Selects #Bs3PagingInitRootForPAE_c16, #Bs3PagingInitRootForPAE_c32 or #Bs3PagingInitRootForPAE_c64. */
+BS3_CMN_PROTO(int, Bs3PagingInitRootForPAE,(void), true);
 
 /**
@@ -2028,8 +1757,5 @@
  * @remarks Must not be called in real-mode!
  */
-BS3_DECL(int) Bs3PagingInitRootForLM_c16(void);
-BS3_DECL(int) Bs3PagingInitRootForLM_c32(void); /**< @copydoc Bs3PagingInitRootForLM_c16 */
-BS3_DECL(int) Bs3PagingInitRootForLM_c64(void); /**< @copydoc Bs3PagingInitRootForLM_c16 */
-#define Bs3PagingInitRootForLM BS3_CMN_NM(Bs3PagingInitRootForLM) /**< Selects #Bs3PagingInitRootForLM_c16, #Bs3PagingInitRootForLM_c32 or #Bs3PagingInitRootForLM_c64. */
+BS3_CMN_PROTO(int, Bs3PagingInitRootForLM,(void), true);
 
 /**
@@ -2049,8 +1775,5 @@
  * @param   fClear      Mask of zero or more X86_PTE_XXX values to clear for the range.
  */
-BS3_DECL(int) Bs3PagingProtect_c16(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear);
-BS3_DECL(int) Bs3PagingProtect_c32(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear); /**< @copydoc Bs3PagingProtect_c16 */
-BS3_DECL(int) Bs3PagingProtect_c64(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear); /**< @copydoc Bs3PagingProtect_c16 */
-#define Bs3PagingProtect BS3_CMN_NM(Bs3PagingProtect) /**< Selects #Bs3PagingProtect_c16, #Bs3PagingProtect_c32 or #Bs3PagingProtect_c64. */
+BS3_CMN_PROTO(int, Bs3PagingProtect,(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear), true);
 
 /**
@@ -2070,16 +1793,10 @@
  * @param   fClear      Mask of zero or more X86_PTE_XXX values to clear for the range.
  */
-BS3_DECL(int) Bs3PagingProtectPtr_c16(void BS3_FAR *pv, size_t cb, uint64_t fSet, uint64_t fClear);
-BS3_DECL(int) Bs3PagingProtectPtr_c32(void BS3_FAR *pv, size_t cb, uint64_t fSet, uint64_t fClear); /**< @copydoc Bs3PagingProtectPtr_c16 */
-BS3_DECL(int) Bs3PagingProtectPtr_c64(void BS3_FAR *pv, size_t cb, uint64_t fSet, uint64_t fClear); /**< @copydoc Bs3PagingProtectPtr_c16 */
-#define Bs3PagingProtectPtr BS3_CMN_NM(Bs3PagingProtectPtr) /**< Selects #Bs3PagingProtectPtr_c16, #Bs3PagingProtectPtr_c32 or #Bs3PagingProtectPtr_c64. */
+BS3_CMN_PROTO(int, Bs3PagingProtectPtr,(void BS3_FAR *pv, size_t cb, uint64_t fSet, uint64_t fClear), true);
 
 /**
  * Waits for the keyboard controller to become ready.
  */
-BS3_DECL(void) Bs3KbdWait_c16(void);
-BS3_DECL(void) Bs3KbdWait_c32(void); /**< @copydoc Bs3KbdWait_c16 */
-BS3_DECL(void) Bs3KbdWait_c64(void); /**< @copydoc Bs3KbdWait_c16 */
-#define Bs3KbdWait BS3_CMN_NM(Bs3KbdWait) /**< Selects #Bs3KbdWait_c16, #Bs3KbdWait_c32 or #Bs3KbdWait_c64. */
+BS3_CMN_PROTO(void, Bs3KbdWait,(void), false);
 
 /**
@@ -2092,8 +1809,5 @@
  * @param        bCmd            The read command.
  */
-BS3_DECL(uint8_t) Bs3KbdRead_c16(uint8_t bCmd);
-BS3_DECL(uint8_t) Bs3KbdRead_c32(uint8_t bCmd); /**< @copydoc Bs3KbdRead_c16 */
-BS3_DECL(uint8_t) Bs3KbdRead_c64(uint8_t bCmd); /**< @copydoc Bs3KbdRead_c16 */
-#define Bs3KbdRead BS3_CMN_NM(Bs3KbdRead) /**< Selects #Bs3KbdRead_c16, #Bs3KbdRead_c32 or #Bs3KbdRead_c64. */
+BS3_CMN_PROTO(uint8_t, Bs3KbdRead,(uint8_t bCmd), false);
 
 /**
@@ -2106,8 +1820,5 @@
  * @param        bData          The data to write.
  */
-BS3_DECL(void) Bs3KbdWrite_c16(uint8_t bCmd, uint8_t bData);
-BS3_DECL(void) Bs3KbdWrite_c32(uint8_t bCmd, uint8_t bData); /**< @copydoc Bs3KbdWrite_c16 */
-BS3_DECL(void) Bs3KbdWrite_c64(uint8_t bCmd, uint8_t bData); /**< @copydoc Bs3KbdWrite_c16 */
-#define Bs3KbdWrite BS3_CMN_NM(Bs3KbdWrite) /**< Selects #Bs3KbdWrite_c16, #Bs3KbdWrite_c32 or #Bs3KbdWrite_c64. */
+BS3_CMN_PROTO(void, Bs3KbdWrite,(uint8_t bCmd, uint8_t bData), false);
 
 
@@ -2115,8 +1826,5 @@
  * Disables all IRQs on the PIC.
  */
-BS3_DECL(void) Bs3PicMaskAll_c16(void);
-BS3_DECL(void) Bs3PicMaskAll_c32(void); /**< @copydoc Bs3PicMaskAll_c16 */
-BS3_DECL(void) Bs3PicMaskAll_c64(void); /**< @copydoc Bs3PicMaskAll_c16 */
-#define Bs3PicMaskAll BS3_CMN_NM(Bs3PicMaskAll) /**< Selects #Bs3PicMaskAll_c16, #Bs3PicMaskAll_c32 or #Bs3PicMaskAll_c64. */
+BS3_CMN_PROTO(void, Bs3PicMaskAll,(void), true);
 
 
@@ -2218,8 +1926,5 @@
  * @param   pRegCtx     Where to store the register context.
  */
-BS3_DECL(void) Bs3RegCtxSave_c16(PCBS3REGCTX pRegCtx);
-BS3_DECL(void) Bs3RegCtxSave_c32(PCBS3REGCTX pRegCtx); /**< @copydoc Bs3RegCtxSave_c16 */
-BS3_DECL(void) Bs3RegCtxSave_c64(PCBS3REGCTX pRegCtx); /**< @copydoc Bs3RegCtxSave_c16 */
-#define Bs3RegCtxSave BS3_CMN_NM(Bs3RegCtxSave) /**< Selects #Bs3RegCtxSave_c16, #Bs3RegCtxSave_c32 or #Bs3RegCtxSave_c64. */
+BS3_CMN_PROTO(void, Bs3RegCtxSave,(PCBS3REGCTX pRegCtx), false);
 
 /**
@@ -2229,8 +1934,5 @@
  * @param   bRing       The target ring (0..3).
  */
-BS3_DECL(void) Bs3RegCtxConvertToRingX_c16(PBS3REGCTX pRegCtx, uint8_t bRing);
-BS3_DECL(void) Bs3RegCtxConvertToRingX_c32(PBS3REGCTX pRegCtx, uint8_t bRing); /**< @copydoc Bs3RegCtxConvertToRingX_c16 */
-BS3_DECL(void) Bs3RegCtxConvertToRingX_c64(PBS3REGCTX pRegCtx, uint8_t bRing); /**< @copydoc Bs3RegCtxConvertToRingX_c16 */
-#define Bs3RegCtxConvertToRingX BS3_CMN_NM(Bs3RegCtxConvertToRingX) /**< Selects #Bs3RegCtxConvertToRingX_c16, #Bs3RegCtxConvertToRingX_c32 or #Bs3RegCtxConvertToRingX_c64. */
+BS3_CMN_PROTO(void, Bs3RegCtxConvertToRingX,(PBS3REGCTX pRegCtx, uint8_t bRing), true);
 
 /**
@@ -2243,10 +1945,8 @@
  * @remarks Does not return.
  */
-BS3_DECL(DECL_NO_RETURN(void)) Bs3RegCtxRestore_c16(PCBS3REGCTX pRegCtx, uint16_t fFlags);
-BS3_DECL(DECL_NO_RETURN(void)) Bs3RegCtxRestore_c32(PCBS3REGCTX pRegCtx, uint16_t fFlags); /**< @copydoc Bs3RegCtxRestore_c16 */
-BS3_DECL(DECL_NO_RETURN(void)) Bs3RegCtxRestore_c64(PCBS3REGCTX pRegCtx, uint16_t fFlags); /**< @copydoc Bs3RegCtxRestore_c16 */
-#define Bs3RegCtxRestore BS3_CMN_NM(Bs3RegCtxRestore) /**< Selects #Bs3RegCtxRestore_c16, #Bs3RegCtxRestore_c32 or #Bs3RegCtxRestore_c64. */
+BS3_CMN_PROTO(DECL_NO_RETURN(void), Bs3RegCtxRestore,(PCBS3REGCTX pRegCtx, uint16_t fFlags), false);
 #if !defined(BS3_KIT_WITH_NO_RETURN) && defined(__WATCOMC__)
 # pragma aux Bs3RegCtxRestore_c16 "_Bs3RegCtxRestore_aborts_c16" __aborts
+# pragma aux Bs3RegCtxRestore_f16 "_Bs3RegCtxRestore_aborts_f16" __aborts
 # pragma aux Bs3RegCtxRestore_c32 "_Bs3RegCtxRestore_aborts_c32" __aborts
 #endif
@@ -2260,8 +1960,5 @@
  * @param   pRegCtx     The register context to be printed.
  */
-BS3_DECL(void) Bs3RegCtxPrint_c16(PCBS3REGCTX pRegCtx);
-BS3_DECL(void) Bs3RegCtxPrint_c32(PCBS3REGCTX pRegCtx); /**< @copydoc Bs3RegCtxPrint_c16 */
-BS3_DECL(void) Bs3RegCtxPrint_c64(PCBS3REGCTX pRegCtx); /**< @copydoc Bs3RegCtxPrint_c16 */
-#define Bs3RegCtxPrint BS3_CMN_NM(Bs3RegCtxPrint) /**< Selects #Bs3RegCtxPrint_c16, #Bs3RegCtxPrint_c32 or #Bs3RegCtxPrint_c64. */
+BS3_CMN_PROTO(void, Bs3RegCtxPrint,(PCBS3REGCTX pRegCtx), true);
 
 
@@ -2304,8 +2001,5 @@
  *          structures.
  */
-BS3_DECL(void) Bs3Trap16Init_c16(void);
-BS3_DECL(void) Bs3Trap16Init_c32(void); /**< @copydoc Bs3Trap16Init_c16 */
-BS3_DECL(void) Bs3Trap16Init_c64(void); /**< @copydoc Bs3Trap16Init_c16 */
-#define Bs3Trap16Init BS3_CMN_NM(Bs3Trap16Init) /**< Selects #Bs3Trap16Init_c16, #Bs3Trap16Init_c32 or #Bs3Trap16Init_c64. */
+BS3_CMN_PROTO(void, Bs3Trap16Init,(void), true);
 
 /**
@@ -2320,8 +2014,5 @@
  *          structures.
  */
-BS3_DECL(void) Bs3Trap16InitEx_c16(bool f386Plus);
-BS3_DECL(void) Bs3Trap16InitEx_c32(bool f386Plus); /**< @copydoc Bs3Trap16InitEx_c16 */
-BS3_DECL(void) Bs3Trap16InitEx_c64(bool f386Plus); /**< @copydoc Bs3Trap16InitEx_c16 */
-#define Bs3Trap16InitEx BS3_CMN_NM(Bs3Trap16InitEx) /**< Selects #Bs3Trap16InitEx_c16, #Bs3Trap16InitEx_c32 or #Bs3Trap16InitEx_c64. */
+BS3_CMN_PROTO(void, Bs3Trap16InitEx,(bool f386Plus), true);
 
 /**
@@ -2331,8 +2022,5 @@
  *          structures.
  */
-BS3_DECL(void) Bs3Trap32Init_c16(void);
-BS3_DECL(void) Bs3Trap32Init_c32(void); /**< @copydoc Bs3Trap32Init_c16 */
-BS3_DECL(void) Bs3Trap32Init_c64(void); /**< @copydoc Bs3Trap32Init_c16 */
-#define Bs3Trap32Init BS3_CMN_NM(Bs3Trap32Init) /**< Selects #Bs3Trap32Init_c16, #Bs3Trap32Init_c32 or #Bs3Trap32Init_c64. */
+BS3_CMN_PROTO(void, Bs3Trap32Init,(void), true);
 
 /**
@@ -2342,8 +2030,14 @@
  *          structures.
  */
-BS3_DECL(void) Bs3Trap64Init_c16(void);
-BS3_DECL(void) Bs3Trap64Init_c32(void); /**< @copydoc Bs3Trap64Init_c16 */
-BS3_DECL(void) Bs3Trap64Init_c64(void); /**< @copydoc Bs3Trap64Init_c16 */
-#define Bs3Trap64Init BS3_CMN_NM(Bs3Trap64Init) /**< Selects #Bs3Trap64Init_c16, #Bs3Trap64Init_c32 or #Bs3Trap64Init_c64. */
+BS3_CMN_PROTO(void, Bs3Trap64Init,(void), true);
+
+/**
+ * Modifies the real-mode / V86 IVT entry specified by @a iIvt.
+ *
+ * @param   iIvt        The index of the IDT entry to set.
+ * @param   uSel        The handler real-mode segment.
+ * @param   off         The handler offset.
+ */
+BS3_CMN_PROTO(void, Bs3TrapRmV86SetGate,(uint8_t iIvt, uint16_t uSeg, uint16_t off), true);
 
 /**
@@ -2357,8 +2051,6 @@
  * @param   cParams     The parameter count (for call gates).
  */
-BS3_DECL(void) Bs3Trap16SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams);
-BS3_DECL(void) Bs3Trap16SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */
-BS3_DECL(void) Bs3Trap16SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */
-#define Bs3Trap16SetGate BS3_CMN_NM(Bs3Trap16SetGate) /**< Selects #Bs3Trap16SetGate_c16, #Bs3Trap16SetGate_c32 or #Bs3Trap16SetGate_c64. */
+BS3_CMN_PROTO(void, Bs3Trap16SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl,
+                                      uint16_t uSel, uint16_t off, uint8_t cParams), true);
 
 /** The address of Bs3Trap16GenericEntries.
@@ -2366,7 +2058,4 @@
  * points, 8 bytes each, that will create a register frame and call the generic
  * C compatible trap handlers. */
-#ifndef DOXYGEN_RUNNING
-# define g_Bs3Trap16GenericEntriesFlatAddr BS3_DATA_NM(g_Bs3Trap16GenericEntriesFlatAddr)
-#endif
 extern uint32_t g_Bs3Trap16GenericEntriesFlatAddr;
 
@@ -2381,8 +2070,6 @@
  * @param   cParams     The parameter count (for call gates).
  */
-BS3_DECL(void) Bs3Trap32SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams);
-BS3_DECL(void) Bs3Trap32SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
-BS3_DECL(void) Bs3Trap32SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
-#define Bs3Trap32SetGate BS3_CMN_NM(Bs3Trap32SetGate) /**< Selects #Bs3Trap32SetGate_c16, #Bs3Trap32SetGate_c32 or #Bs3Trap32SetGate_c64. */
+BS3_CMN_PROTO(void, Bs3Trap32SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl,
+                                      uint16_t uSel, uint32_t off, uint8_t cParams), true);
 
 /** The address of Bs3Trap32GenericEntries.
@@ -2390,7 +2077,4 @@
  * points, 10 bytes each, that will create a register frame and call the generic
  * C compatible trap handlers. */
-#ifndef DOXYGEN_RUNNING
-# define g_Bs3Trap32GenericEntriesFlatAddr BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr)
-#endif
 extern uint32_t g_Bs3Trap32GenericEntriesFlatAddr;
 
@@ -2405,8 +2089,6 @@
  * @param   bIst        The interrupt stack to use.
  */
-BS3_DECL(void) Bs3Trap64SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst);
-BS3_DECL(void) Bs3Trap64SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
-BS3_DECL(void) Bs3Trap64SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
-#define Bs3Trap64SetGate BS3_CMN_NM(Bs3Trap64SetGate) /**< Selects #Bs3Trap64SetGate_c16, #Bs3Trap64SetGate_c32 or #Bs3Trap64SetGate_c64. */
+BS3_CMN_PROTO(void, Bs3Trap64SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl,
+                                      uint16_t uSel, uint64_t off, uint8_t bIst), true);
 
 /** The address of Bs3Trap64GenericEntries.
@@ -2414,7 +2096,4 @@
  * points, 8 bytes each, that will create a register frame and call the generic
  * C compatible trap handlers. */
-#ifndef DOXYGEN_RUNNING
-# define g_Bs3Trap64GenericEntriesFlatAddr BS3_DATA_NM(g_Bs3Trap64GenericEntriesFlatAddr)
-#endif
 extern uint32_t g_Bs3Trap64GenericEntriesFlatAddr;
 
@@ -2448,8 +2127,5 @@
  * @param   pfnHandler  Pointer to the handler.
  */
-BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c16(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler);
-BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c32(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
-BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c64(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
-#define Bs3Trap32SetHandler BS3_CMN_NM(Bs3Trap32SetHandler) /**< Selects #Bs3Trap32SetHandler_c16, #Bs3Trap32SetHandler_c32 or #Bs3Trap32SetHandler_c64. */
+BS3_CMN_PROTO(PFNBS3TRAPHANDLER, Bs3TrapSetHandler,(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler), true);
 
 /**
@@ -2460,8 +2136,5 @@
  * @param   pTrapFrame      Trap frame of the trap to handle.
  */
-BS3_DECL(void) Bs3TrapDefaultHandler_c16(PBS3TRAPFRAME pTrapFrame);
-BS3_DECL(void) Bs3TrapDefaultHandler_c32(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapDefaultHandler_c16 */
-BS3_DECL(void) Bs3TrapDefaultHandler_c64(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapDefaultHandler_c16 */
-#define Bs3TrapDefaultHandler BS3_CMN_NM(Bs3TrapDefaultHandler) /**< Selects #Bs3TrapDefaultHandler_c16, #Bs3TrapDefaultHandler_c32 or #Bs3TrapDefaultHandler_c64. */
+BS3_CMN_PROTO(void, Bs3TrapDefaultHandler,(PBS3TRAPFRAME pTrapFrame), true);
 
 /**
@@ -2469,8 +2142,5 @@
  * @param   pTrapFrame      Trap frame to print.
  */
-BS3_DECL(void) Bs3TrapPrintFrame_c16(PCBS3TRAPFRAME pTrapFrame);
-BS3_DECL(void) Bs3TrapPrintFrame_c32(PCBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapPrintFrame_c16 */
-BS3_DECL(void) Bs3TrapPrintFrame_c64(PCBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapPrintFrame_c16 */
-#define Bs3TrapPrintFrame BS3_CMN_NM(Bs3TrapPrintFrame) /**< Selects #Bs3TrapPrintFrame_c16, #Bs3TrapPrintFrame_c32 or #Bs3TrapPrintFrame_c64. */
+BS3_CMN_PROTO(void, Bs3TrapPrintFrame,(PCBS3TRAPFRAME pTrapFrame), true);
 
 /**
@@ -2486,8 +2156,5 @@
  * @sa      #Bs3TrapUnsetJmp
  */
-BS3_DECL(DECL_RETURNS_TWICE(bool)) Bs3TrapSetJmp_c16(PBS3TRAPFRAME pTrapFrame);
-BS3_DECL(DECL_RETURNS_TWICE(bool)) Bs3TrapSetJmp_c32(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapSetJmp_c16 */
-BS3_DECL(DECL_RETURNS_TWICE(bool)) Bs3TrapSetJmp_c64(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapSetJmp_c16 */
-#define Bs3TrapSetJmp BS3_CMN_NM(Bs3TrapSetJmp) /**< Selects #Bs3TrapSetJmp_c16, #Bs3TrapSetJmp_c32 or #Bs3TrapSetJmp_c64. */
+BS3_CMN_PROTO(DECL_RETURNS_TWICE(bool),Bs3TrapSetJmp,(PBS3TRAPFRAME pTrapFrame), false);
 
 /**
@@ -2497,16 +2164,10 @@
  * @param   pTrapFrame      Where to store the trap information.
  */
-BS3_DECL(void) Bs3TrapSetJmpAndRestore_c16(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame);
-BS3_DECL(void) Bs3TrapSetJmpAndRestore_c32(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapSetJmpAndRestore_c16 */
-BS3_DECL(void) Bs3TrapSetJmpAndRestore_c64(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapSetJmpAndRestore_c16 */
-#define Bs3TrapSetJmpAndRestore BS3_CMN_NM(Bs3TrapSetJmpAndRestore) /**< Selects #Bs3TrapSetJmpAndRestore_c16, #Bs3TrapSetJmpAndRestore_c32 or #Bs3TrapSetJmpAndRestore_c64. */
+BS3_CMN_PROTO(void, Bs3TrapSetJmpAndRestore,(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame), true);
 
 /**
  * Disables a previous #Bs3TrapSetJmp call.
  */
-BS3_DECL(void) Bs3TrapUnsetJmp_c16(void);
-BS3_DECL(void) Bs3TrapUnsetJmp_c32(void); /**< @copydoc Bs3TrapUnsetJmp_c16 */
-BS3_DECL(void) Bs3TrapUnsetJmp_c64(void); /**< @copydoc Bs3TrapUnsetJmp_c16 */
-#define Bs3TrapUnsetJmp BS3_CMN_NM(Bs3TrapUnsetJmp) /**< Selects #Bs3TrapUnsetJmp_c16, #Bs3TrapUnsetJmp_c32 or #Bs3TrapUnsetJmp_c64. */
+BS3_CMN_PROTO(void, Bs3TrapUnsetJmp,(void), true);
 
 
@@ -2514,11 +2175,5 @@
  * The current test step.
  */
-#ifndef DOXYGEN_RUNNING
-# define g_usBs3TestStep BS3_DATA_NM(g_usBs3TestStep)
-#endif
 extern uint16_t g_usBs3TestStep;
-#ifndef DOXYGEN_RUNNING
-# define g_usBs3TestStep BS3_DATA_NM(g_usBs3TestStep)
-#endif
 
 /**
@@ -2527,8 +2182,5 @@
  * @param   pszTest         The test name.
  */
-BS3_DECL(void) Bs3TestInit_c16(const char BS3_FAR *pszTest);
-BS3_DECL(void) Bs3TestInit_c32(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
-BS3_DECL(void) Bs3TestInit_c64(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
-#define Bs3TestInit BS3_CMN_NM(Bs3TestInit) /**< Selects #Bs3TestInit_c16, #Bs3TestInit_c32 or #Bs3TestInit_c64. */
+BS3_CMN_PROTO(void, Bs3TestInit,(const char BS3_FAR *pszTest), true);
 
 
@@ -2536,48 +2188,30 @@
  * Equivalent to RTTestSummaryAndDestroy.
  */
-BS3_DECL(void) Bs3TestTerm_c16(void);
-BS3_DECL(void) Bs3TestTerm_c32(void); /**< @copydoc Bs3TestTerm_c16 */
-BS3_DECL(void) Bs3TestTerm_c64(void); /**< @copydoc Bs3TestTerm_c16 */
-#define Bs3TestTerm BS3_CMN_NM(Bs3TestTerm) /**< Selects #Bs3TestTerm_c16, #Bs3TestTerm_c32 or #Bs3TestTerm_c64. */
+BS3_CMN_PROTO(void, Bs3TestTerm,(void), true);
 
 /**
  * Equivalent to RTTestISub.
  */
-BS3_DECL(void) Bs3TestSub_c16(const char BS3_FAR *pszSubTest);
-BS3_DECL(void) Bs3TestSub_c32(const char BS3_FAR *pszSubTest); /**< @copydoc Bs3TestSub_c16 */
-BS3_DECL(void) Bs3TestSub_c64(const char BS3_FAR *pszSubTest); /**< @copydoc Bs3TestSub_c16 */
-#define Bs3TestSub BS3_CMN_NM(Bs3TestSub) /**< Selects #Bs3TestSub_c16, #Bs3TestSub_c32 or #Bs3TestSub_c64. */
+BS3_CMN_PROTO(void, Bs3TestSub,(const char BS3_FAR *pszSubTest), true);
 
 /**
  * Equivalent to RTTestIFailedF.
  */
-BS3_DECL(void) Bs3TestSubF_c16(const char BS3_FAR *pszFormat, ...);
-BS3_DECL(void) Bs3TestSubF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSubF_c16 */
-BS3_DECL(void) Bs3TestSubF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSubF_c16 */
-#define Bs3TestSubF BS3_CMN_NM(Bs3TestSubF) /**< Selects #Bs3TestSubF_c16, #Bs3TestSubF_c32 or #Bs3TestSubF_c64. */
+BS3_CMN_PROTO(void, Bs3TestSubF,(const char BS3_FAR *pszFormat, ...), true);
 
 /**
  * Equivalent to RTTestISubV.
  */
-BS3_DECL(void) Bs3TestSubV_c16(const char BS3_FAR *pszFormat, va_list va);
-BS3_DECL(void) Bs3TestSubV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSubV_c16 */
-BS3_DECL(void) Bs3TestSubV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSubV_c16 */
-#define Bs3TestSubV BS3_CMN_NM(Bs3TestSubV) /**< Selects #Bs3TestSubV_c16, #Bs3TestSubV_c32 or #Bs3TestSubV_c64. */
+BS3_CMN_PROTO(void, Bs3TestSubV,(const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
  * Equivalent to RTTestISubDone.
  */
-BS3_DECL(void) Bs3TestSubDone_c16(void);
-BS3_DECL(void) Bs3TestSubDone_c32(void); /**< @copydoc Bs3TestSubDone_c16 */
-BS3_DECL(void) Bs3TestSubDone_c64(void); /**< @copydoc Bs3TestSubDone_c16 */
-#define Bs3TestSubDone BS3_CMN_NM(Bs3TestSubDone) /**< Selects #Bs3TestSubDone_c16, #Bs3TestSubDone_c32 or #Bs3TestSubDone_c64. */
+BS3_CMN_PROTO(void, Bs3TestSubDone,(void), true);
 
 /**
  * Equivalent to RTTestSubErrorCount.
  */
-BS3_DECL(uint16_t) Bs3TestSubErrorCount_c16(void);
-BS3_DECL(uint16_t) Bs3TestSubErrorCount_c32(void); /**< @copydoc Bs3TestSubErrorCount_c16 */
-BS3_DECL(uint16_t) Bs3TestSubErrorCount_c64(void); /**< @copydoc Bs3TestSubErrorCount_c16 */
-#define Bs3TestSubErrorCount BS3_CMN_NM(Bs3TestSubErrorCount) /**< Selects #Bs3TestSubErrorCount_c16, #Bs3TestSubErrorCount_c32 or #Bs3TestSubErrorCount_c64. */
+BS3_CMN_PROTO(uint16_t, Bs3TestSubErrorCount,(void), true);
 
 /**
@@ -2587,8 +2221,5 @@
  * @param   ...         String format arguments.
  */
-BS3_DECL(void) Bs3TestPrintf_c16(const char BS3_FAR *pszFormat, ...);
-BS3_DECL(void) Bs3TestPrintf_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestPrintf_c16 */
-BS3_DECL(void) Bs3TestPrintf_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestPrintf_c16 */
-#define Bs3TestPrintf BS3_CMN_NM(Bs3TestPrintf) /**< Selects #Bs3TestPrintf_c16, #Bs3TestPrintf_c32 or #Bs3TestPrintf_c64. */
+BS3_CMN_PROTO(void, Bs3TestPrintf,(const char BS3_FAR *pszFormat, ...), true);
 
 /**
@@ -2598,32 +2229,20 @@
  * @param   va          String format arguments.
  */
-BS3_DECL(void) Bs3TestPrintfV_c16(const char BS3_FAR *pszFormat, va_list va);
-BS3_DECL(void) Bs3TestPrintfV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestPrintfV_c16 */
-BS3_DECL(void) Bs3TestPrintfV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestPrintfV_c16 */
-#define Bs3TestPrintfV BS3_CMN_NM(Bs3TestPrintfV) /**< Selects #Bs3TestPrintfV_c16, #Bs3TestPrintfV_c32 or #Bs3TestPrintfV_c64. */
+BS3_CMN_PROTO(void, Bs3TestPrintfV,(const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
  * Equivalent to RTTestIFailed.
  */
-BS3_DECL(void) Bs3TestFailed_c16(const char BS3_FAR *pszMessage);
-BS3_DECL(void) Bs3TestFailed_c32(const char BS3_FAR *pszMessage); /**< @copydoc Bs3TestFailed_c16 */
-BS3_DECL(void) Bs3TestFailed_c64(const char BS3_FAR *pszMessage); /**< @copydoc Bs3TestFailed_c16 */
-#define Bs3TestFailed BS3_CMN_NM(Bs3TestFailed) /**< Selects #Bs3TestFailed_c16, #Bs3TestFailed_c32 or #Bs3TestFailed_c64. */
+BS3_CMN_PROTO(void, Bs3TestFailed,(const char BS3_FAR *pszMessage), true);
 
 /**
  * Equivalent to RTTestIFailedF.
  */
-BS3_DECL(void) Bs3TestFailedF_c16(const char BS3_FAR *pszFormat, ...);
-BS3_DECL(void) Bs3TestFailedF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestFailedF_c16 */
-BS3_DECL(void) Bs3TestFailedF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestFailedF_c16 */
-#define Bs3TestFailedF BS3_CMN_NM(Bs3TestFailedF) /**< Selects #Bs3TestFailedF_c16, #Bs3TestFailedF_c32 or #Bs3TestFailedF_c64. */
+BS3_CMN_PROTO(void, Bs3TestFailedF,(const char BS3_FAR *pszFormat, ...), true);
 
 /**
  * Equivalent to RTTestIFailedV.
  */
-BS3_DECL(void) Bs3TestFailedV_c16(const char BS3_FAR *pszFormat, va_list va);
-BS3_DECL(void) Bs3TestFailedV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestFailedV_c16 */
-BS3_DECL(void) Bs3TestFailedV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestFailedV_c16 */
-#define Bs3TestFailedV BS3_CMN_NM(Bs3TestFailedV) /**< Selects #Bs3TestFailedV_c16, #Bs3TestFailedV_c32 or #Bs3TestFailedV_c64. */
+BS3_CMN_PROTO(void, Bs3TestFailedV,(const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
@@ -2632,8 +2251,5 @@
  * @param   pszWhy          Optional reason why it's being skipped.
  */
-BS3_DECL(void) Bs3TestSkipped_c16(const char BS3_FAR *pszWhy);
-BS3_DECL(void) Bs3TestSkipped_c32(const char BS3_FAR *pszWhy); /**< @copydoc Bs3TestSkipped_c16 */
-BS3_DECL(void) Bs3TestSkipped_c64(const char BS3_FAR *pszWhy); /**< @copydoc Bs3TestSkipped_c16 */
-#define Bs3TestSkipped BS3_CMN_NM(Bs3TestSkipped) /**< Selects #Bs3TestSkipped_c16, #Bs3TestSkipped_c32 or #Bs3TestSkipped_c64. */
+BS3_CMN_PROTO(void, Bs3TestSkipped,(const char BS3_FAR *pszWhy), true);
 
 /**
@@ -2643,8 +2259,5 @@
  * @param   ...             Format arguments.
  */
-BS3_DECL(void) Bs3TestSkippedF_c16(const char BS3_FAR *pszFormat, ...);
-BS3_DECL(void) Bs3TestSkippedF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSkippedF_c16 */
-BS3_DECL(void) Bs3TestSkippedF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSkippedF_c16 */
-#define Bs3TestSkippedF BS3_CMN_NM(Bs3TestSkippedF) /**< Selects #Bs3TestSkippedF_c16, #Bs3TestSkippedF_c32 or #Bs3TestSkippedF_c64. */
+BS3_CMN_PROTO(void, Bs3TestSkippedF,(const char BS3_FAR *pszFormat, ...), true);
 
 /**
@@ -2654,8 +2267,5 @@
  * @param   va              Format arguments.
  */
-BS3_DECL(void) Bs3TestSkippedV_c16(const char BS3_FAR *pszFormat, va_list va);
-BS3_DECL(void) Bs3TestSkippedV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSkippedV_c16 */
-BS3_DECL(void) Bs3TestSkippedV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSkippedV_c16 */
-#define Bs3TestSkippedV BS3_CMN_NM(Bs3TestSkippedV) /**< Selects #Bs3TestSkippedV_c16, #Bs3TestSkippedV_c32 or #Bs3TestSkippedV_c64. */
+BS3_CMN_PROTO(void, Bs3TestSkippedV,(const char BS3_FAR *pszFormat, va_list va), true);
 
 /**
@@ -2673,11 +2283,6 @@
  * @param   idTestStep      Test step identifier.
  */
-BS3_DECL(bool) Bs3TestCheckRegCtxEx_c16(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust, int16_t cbSpAdjust,
-                                        uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep);
-BS3_DECL(bool) Bs3TestCheckRegCtxEx_c32(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust, int16_t cbSpAdjust,
-                                        uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep); /** @copydoc Bs3TestCheckRegCtxEx_c16 */
-BS3_DECL(bool) Bs3TestCheckRegCtxEx_c64(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust, int16_t cbSpAdjust,
-                                        uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep); /** @copydoc Bs3TestCheckRegCtxEx_c16 */
-#define Bs3TestCheckRegCtxEx BS3_CMN_NM(Bs3TestCheckRegCtxEx) /**< Selects #Bs3TestCheckRegCtxEx_c16, #Bs3TestCheckRegCtxEx_c32 or #Bs3TestCheckRegCtxEx_c64. */
+BS3_CMN_PROTO(bool, Bs3TestCheckRegCtxEx,(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust,
+                                          int16_t cbSpAdjust, uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep), true);
 
 /**
@@ -2845,5 +2450,5 @@
  * For proper operation on OLDer CPUs, call #Bs3CpuDetect_mmm first.
  */
-BS3_DECL(void) Bs3InitMemory_rm(void);
+BS3_DECL_FAR(void) Bs3InitMemory_rm(void);
 
 
@@ -2866,26 +2471,27 @@
  */
 #define BS3_MODE_EXPAND_PROTOTYPES(a_RetType, a_BaseFnNm, a_Parameters) \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_rm)       a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_32)  a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_v86) a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32_16)  a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pev86)    a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_32)  a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_v86) a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32_16)  a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_ppv86)    a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16)    a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_32) a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_v86)a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32)    a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32_16) a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_paev86)   a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm16)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm32)     a_Parameters; \
-    BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm64)     a_Parameters
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_rm)       a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_rm_far)   a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_32)  a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_v86) a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32_16)  a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pev86)    a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_32)  a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_v86) a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32_16)  a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_ppv86)    a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16)    a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_32) a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_v86)a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32)    a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32_16) a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_paev86)   a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_lm16)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_lm32)     a_Parameters; \
+    BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_BaseFnNm,_lm64)     a_Parameters
 
 /**
@@ -2965,7 +2571,4 @@
 
 /** The return value of #Bs3CpuDetect_mmm. (Initial value is BS3CPU_TYPE_MASK.) */
-#ifndef DOXYGEN_RUNNING
-# define g_uBs3CpuDetected BS3_DATA_NM(g_uBs3CpuDetected)
-#endif
 extern uint16_t g_uBs3CpuDetected;
 
@@ -2991,4 +2594,10 @@
 
 
-#endif
-
+/*
+ * Include default function symbol mangling.
+ */
+#include "bs3kit-mangling-code.h"
+
+
+#endif
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 60526)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 60527)
@@ -138,18 +138,8 @@
 %endmacro
 
-; Default to register aliases for ARCH_BITS.
-BS3_SET_REG_ALIASES ARCH_BITS
-
-
-;; Wrapper around BITS.
-; Updates __BITS__ (built-in variable in nasm, we work it for yasm) as well
-; a number of convenient macros and register aliases.
-;
-; @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
-
+;;
+; Redefines macros that follows __BITS__.
+%macro BS3_SET_BITS_MACROS 1
+ ;; Emulate the __BITS__ macro in NASM 2.0+. Follows BS3_SET_BITS.
  %ifdef __YASM__
   %undef  __BITS__
@@ -157,4 +147,5 @@
  %endif
 
+ ;; Mostly internal macro. Follows BS3_SET_BITS.
  %undef  BS3_NAME_UNDERSCORE
  %if %1 == 64
@@ -164,4 +155,5 @@
  %endif
 
+ ;; For segment overrides and stuff. Follows BS3_SET_BITS.
  %undef   BS3_ONLY_16BIT
  %if %1 == 16
@@ -171,4 +163,5 @@
  %endif
 
+ ;; For odd 64-bit stuff. Follows BS3_SET_BITS.
  %undef   BS3_ONLY_64BIT
  %if %1 == 64
@@ -178,4 +171,5 @@
  %endif
 
+ ;; For segment overrides and stuff. Follows BS3_SET_BITS.
  %undef   BS3_NOT_64BIT
  %if %1 == 64
@@ -185,4 +179,5 @@
  %endif
 
+ ;; For stack cleanups and similar where each bit mode is different. Follows BS3_SET_BITS.
  %undef   BS3_IF_16_32_64BIT
  %if %1 == 16
@@ -194,4 +189,6 @@
  %endif
 
+ ;; For RIP relative addressing in 64-bit mode and absolute addressing in
+ ; other modes. Follows BS3_SET_BITS.
  %undef   BS3_WRT_RIP
  %if %1 == 64
@@ -241,62 +238,35 @@
  %endif
 
+ ;;
+ ; Same as BS3_CMN_NM except in 16-bit mode, it will generate the far name.
+ ; (16-bit code generally have both near and far callable symbols, so we won't
+ ; be restricted to 64KB test code.)
+ %if %1 == 16
+  %define BS3_CMN_NM_FAR(a_Name) BS3_NAME_UNDERSCORE %+ a_Name %+ _f %+ __BITS__
+ %else
+  %define BS3_CMN_NM_FAR(a_Name) BS3_CMN_NM(a_Name)
+ %endif
+
+%endmacro
+
+; Default to register aliases for ARCH_BITS.
+BS3_SET_REG_ALIASES ARCH_BITS
+
+; Define macros for ARCH_BITS.
+BS3_SET_BITS_MACROS ARCH_BITS
+
+
+;; Wrapper around BITS.
+; Updates __BITS__ (built-in variable in nasm, we work it for yasm) as well
+; a number of convenient macros and register aliases.
+;
+; @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
+ BS3_SET_BITS_MACROS %1
  BS3_SET_REG_ALIASES %1
 %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
- %ifdef __YASM__
-  %define BS3_WRT_RIP(a_Sym)        a_Sym wrt rip
- %else
-  %define BS3_WRT_RIP(a_Sym)        rel a_Sym       ; Baka! Why couldn't they do 'wrt rip' like yasm?
- %endif
-%else
- %define BS3_WRT_RIP(a_Sym)         a_Sym
-%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 odd 64-bit stuff. Follows BS3_SET_BITS.
-%if ARCH_BITS == 64
- %define BS3_ONLY_64BIT(a_Expr)     a_Expr
-%else
- %define BS3_ONLY_64BIT(a_Expr)
-%endif
-
-;; For segment overrides and stuff. Follows BS3_SET_BITS.
-%if ARCH_BITS == 64
- %define BS3_NOT_64BIT(a_Expr)
-%else
- %define BS3_NOT_64BIT(a_Expr)     a_Expr
-%endif
-
-;; For stack cleanups and similar where each bit mode is different. Follows BS3_SET_BITS.
-%if ARCH_BITS == 16
- %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_16BitExpr
-%elif ARCH_BITS == 32
- %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_32BitExpr
-%else
- %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_64BitExpr
-%endif
-
 
 ;;
@@ -358,4 +328,54 @@
         section BS3TEXT16
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_TEXT16
+        BS3_SET_BITS 16
+%endmacro
+
+%macro BS3_BEGIN_TEXT16_NEARSTUBS 0
+ %ifndef  BS3_BEGIN_TEXT16_NEARSTUBS_NOT_FIRST
+  %define BS3_BEGIN_TEXT16_NEARSTUBS_NOT_FIRST
+  %ifdef ASM_FORMAT_ELF
+        section BS3TEXT16_NEARSTUBS align=1 progbits alloc exec nowrite
+  %else
+        section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
+  %endif
+ %else
+        section BS3TEXT16_NEARSTUBS
+ %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_TEXT16_NEARSTUBS
+        BS3_SET_BITS 16
+%endmacro
+
+%macro BS3_BEGIN_TEXT16_FARSTUBS 0
+ %ifndef  BS3_BEGIN_TEXT16_FARSTUBS_NOT_FIRST
+  %define BS3_BEGIN_TEXT16_FARSTUBS_NOT_FIRST
+  %ifdef ASM_FORMAT_ELF
+        section BS3TEXT16_FARSTUBS align=1 progbits alloc exec nowrite
+  %else
+        section BS3TEXT16_FARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
+  %endif
+ %else
+        section BS3TEXT16_FARSTUBS
+ %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_TEXT16_FARSTUBS
+        BS3_SET_BITS 16
+%endmacro
+
+%macro BS3_BEGIN_RMTEXT16 0
+ %ifndef  BS3_BEGIN_RMTEXT16_NOT_FIRST
+  %define BS3_BEGIN_RMTEXT16_NOT_FIRST
+  %ifdef ASM_FORMAT_ELF
+        section BS3RMTEXT16 align=2 progbits alloc exec nowrite
+  %else
+        section BS3RMTEXT16 align=2 CLASS=BS3CLASS16RMCODE PUBLIC USE16
+  %endif
+ %else
+        section BS3RMTEXT16
+ %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_RMTEXT16
         BS3_SET_BITS 16
 %endmacro
@@ -375,4 +395,6 @@
         section BS3DATA16
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_DATA16
         BS3_SET_BITS 16
 %endmacro
@@ -389,4 +411,6 @@
         section BS3TEXT32
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_TEXT32
         BS3_SET_BITS 32
 %endmacro
@@ -403,4 +427,6 @@
         section BS3DATA32
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_DATA32
         BS3_SET_BITS 32
 %endmacro
@@ -417,4 +443,6 @@
         section BS3TEXT64
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_TEXT64
         BS3_SET_BITS 64
 %endmacro
@@ -431,4 +459,6 @@
         section BS3DATA64
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_DATA64
         BS3_SET_BITS 64
 %endmacro
@@ -446,4 +476,6 @@
         section BS3SYSTEM16
  %endif
+ %undef   BS3_CUR_SEG_BEGIN_MACRO
+ %xdefine BS3_CUR_SEG_BEGIN_MACRO   BS3_BEGIN_SYSTEM16
         BS3_SET_BITS 16
 %endmacro
@@ -515,4 +547,17 @@
 %endmacro
 
+;;
+; Same as BS3_EXTERN_CMN except it picks the far variant in 16-bit code.
+;
+; @param    %1  The unmangled common name.
+;
+; @remarks  Must enter the segment in which this name is defined.
+;
+%macro BS3_EXTERN_CMN_FAR 1
+ extern BS3_CMN_NM_FAR(%1)
+ %undef  %1
+ %define %1 BS3_CMN_NM_FAR(%1)
+%endmacro
+
 ;; @def BS3_EXTERN_TMPL
 ; Mangles the given name into a template specific one.  For ease of use, the
@@ -629,14 +674,149 @@
 
 
+;; @name BS3_PBC_XXX - For use as the 2nd parameter to BS3_PROC_BEGIN_CMN.
+;; @{
+%define BS3_PBC_NEAR          0 ;;< Only near.
+%define BS3_PBC_FAR           1 ;;< Only far.
+%define BS3_PBC_HYBRID        2 ;;< Hybrid near/far procedure, trashing AX
+%define BS3_PBC_HYBRID_SAFE   3 ;;< Hybrid near/far procedure, no trashing but slower.
+%define BS3_PBC_HYBRID_0_ARGS 4 ;;< Hybrid near/far procedure, no parameters so separate far stub, no trashing, fast near calls.
+;; @}
+
 ;; Convenience macro for defining common procedures.
-%macro BS3_PROC_BEGIN_CMN 1
- BS3_PROC_BEGIN     BS3_CMN_NM(%1)
+; This will emit both near and far 16-bit symbols according to parameter %2 (BS3_PBC_XXX).
+%macro BS3_PROC_BEGIN_CMN 2
+ %undef BS3_CUR_PROC_FLAGS
+ %if __BITS__ == 16
+  %if %2 == BS3_PBC_NEAR
+   %define BS3_CUR_PROC_FLAGS   BS3_PBC_NEAR
+   %xdefine cbCurRetAddr        2
+   BS3_PROC_BEGIN       BS3_CMN_NM(%1)
+
+  %elif %2 == BS3_PBC_FAR
+   %define BS3_CUR_PROC_FLAGS   BS3_PBC_FAR
+   %xdefine cbCurRetAddr        4
+   BS3_PROC_BEGIN       BS3_CMN_NM_FAR(%1)
+
+  %elif %2 == BS3_PBC_HYBRID
+   %define BS3_CUR_PROC_FLAGS   BS3_PBC_HYBRID
+   %xdefine cbCurRetAddr        4
+   BS3_GLOBAL_NAME_EX   BS3_CMN_NM(%1), function, 3
+        pop     ax
+        push    cs
+        push    ax
+   BS3_PROC_BEGIN       BS3_CMN_NM_FAR(%1)
+
+  %elif %2 == BS3_PBC_HYBRID_SAFE
+   %define BS3_CUR_PROC_FLAGS   BS3_PBC_HYBRID_SAFE
+   %xdefine cbCurRetAddr        4
+   BS3_GLOBAL_NAME_EX   BS3_CMN_NM(%1), function, 3
+        extern  Bs3CreateHybridFarRet_c16
+        call    Bs3CreateHybridFarRet_c16
+   BS3_PROC_BEGIN       BS3_CMN_NM_FAR(%1)
+
+  %elif %2 == BS3_PBC_HYBRID_0_ARGS
+   %define BS3_CUR_PROC_FLAGS   BS3_PBC_NEAR
+   %xdefine cbCurRetAddr        2
+   %undef  TMP_BEGIN_PREV_SEG
+   %xdefine TMP_BEGIN_PREV_SEG   BS3_CUR_SEG_BEGIN_MACRO
+
+   BS3_BEGIN_TEXT16_FARSTUBS
+   BS3_PROC_BEGIN       BS3_CMN_NM_FAR(%1)
+        call    BS3_CMN_NM(%1)
+        retf
+   BS3_PROC_END         BS3_CMN_NM_FAR(%1)
+
+   TMP_BEGIN_PREV_SEG
+   BS3_PROC_BEGIN       BS3_CMN_NM(%1)
+
+  %else
+   %error BS3_PROC_BEGIN_CMN parameter 2 value %2 is not recognized.
+
+   %define BS3_CUR_PROC_FLAGS    BS3_PBC_NEAR
+   %xdefine cbCurRetAddr         4
+   BS3_PROC_BEGIN       BS3_CMN_NM(%1)
+  %endif
+ %else
+  %define BS3_CUR_PROC_FLAGS    BS3_PBC_NEAR
+  %xdefine cbCurRetAddr         xCB
+  BS3_PROC_BEGIN        BS3_CMN_NM(%1)
+ %endif
 %endmacro
 
 ;; Convenience macro for defining common procedures.
 %macro BS3_PROC_END_CMN 1
- BS3_PROC_END       BS3_CMN_NM(%1)
-%endmacro
-
+ %if __BITS__ == 16
+  %if BS3_CUR_PROC_FLAGS == BS3_PBC_NEAR
+   BS3_PROC_END      BS3_CMN_NM(%1)
+  %else
+   BS3_PROC_END      BS3_CMN_NM_FAR(%1)
+  %endif
+ %else
+  BS3_PROC_END       BS3_CMN_NM(%1)
+ %endif
+ %undef cbCurRetAddr
+%endmacro
+
+;; Does a far return in 16-bit code, near return in 32-bit and 64-bit.
+; This is for use with BS3_PBC_XXX
+%macro BS3_HYBRID_RET 0-1
+ %if __BITS__ == 16
+  %if %0 > 0
+   %if BS3_CUR_PROC_FLAGS == BS3_PBC_NEAR || BS3_CUR_PROC_FLAGS == BS3_PBC_HYBRID_0_ARGS
+        ret    %1
+   %else
+        retf    %1
+   %endif
+  %else
+   %if BS3_CUR_PROC_FLAGS == BS3_PBC_NEAR || BS3_CUR_PROC_FLAGS == BS3_PBC_HYBRID_0_ARGS
+        ret
+   %else
+        retf
+   %endif
+  %endif
+ %else
+  %if BS3_CUR_PROC_FLAGS != BS3_PBC_NEAR
+   %error Expected BS3_CUR_PROC_FLAGS to be BS3_PBC_NEAR in non-16-bit code.
+  %endif
+  %if %0 > 0
+        ret     %1
+  %else
+        ret
+  %endif
+ %endif
+%endmacro
+
+;;
+; Generate a safe 16-bit far stub for function %1, shuffling %2 bytes of parameters.
+;
+; This does absolutely nothing in 32-bit and 64-bit mode.
+;
+; @param    1   The function basename.
+; @param    2   The number of bytes of parameters on the stack, must be a multiple of 2.
+; @remarks  Changes the segment to TEXT16.
+;
+%macro BS3_CMN_FAR_STUB 2
+ %if %2 <= 1 || (%2 & 1)
+  %error Invalid parameter frame size passed to BS3_CMN_FAR_STUB: %2
+ %endif
+ %if __BITS__ == 16
+BS3_BEGIN_TEXT16_FARSTUBS
+BS3_PROC_BEGIN_CMN %1, BS3_PBC_FAR
+        CPU 8086
+        push    bp
+        mov     bp, sp
+  %assign offParam %2
+  %rep %2/2
+        push    word [bp + xCB + cbCurRetAddr + offParam - 2]
+  %assign offParam offParam - 2
+  %endrep
+        call    BS3_CMN_NM(%1)
+        add     sp, %2
+        pop     bp
+        retf
+BS3_PROC_END_CMN   %1
+BS3_BEGIN_TEXT16
+ %endif
+%endmacro
 
 ;; Convenience macro for defining mode specific procedures.
