Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58789)
@@ -364,4 +364,5 @@
 	bs3-cmn-PrintChr.asm \
 	bs3-cmn-PrintU32.asm \
+	bs3-cmn-PrintX32.asm \
 	bs3-cmn-PrintStr.c \
        bs3-cmn-PrintStrColonSpaces.asm \
@@ -374,5 +375,10 @@
        bs3-cmn-MemMove.c \
        bs3-cmn-MemZero.asm \
+       bs3-cmn-MemAlloc.c \
+       bs3-cmn-MemAllocZ.c \
+       bs3-cmn-MemFree.c \
        bs3-cmn-SlabInit.c \
+       bs3-cmn-SlabAlloc.c \
+       bs3-cmn-SlabAllocEx.c \
        bs3-cmn-SlabFree.c \
        bs3-cmn-SlabListInit.c \
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAlloc.c	(revision 58789)
@@ -0,0 +1,89 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3MemAlloc
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include "bs3kit-template-header.h"
+#include "bs3-cmn-memory.h"
+#include <iprt/asm.h>
+
+
+BS3_DECL(void BS3_FAR *) Bs3MemAlloc(BS3MEMKIND enmKind, size_t cb)
+{
+    void BS3_FAR   *pvRet;
+    uint8_t         idxSlabList = bs3MemSizeToSlabListIndex(cb);
+    if (idxSlabList < BS3_MEM_SLAB_LIST_COUNT)
+    {
+        /*
+         * Try allocate a chunk from the list.
+         */
+        PBS3SLABHEAD pHead = enmKind == BS3MEMKIND_REAL
+                           ? &BS3_DATA_NM(g_aBs3LowSlabLists)[idxSlabList]
+                           : &BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[idxSlabList];
+
+        BS3_ASSERT(BS3_DATA_NM(g_aBs3LowSlabLists)[idxSlabList].cbChunk >= cb);
+        pvRet = Bs3SlabListAlloc(pHead);
+        if (pvRet)
+        { /* likely */ }
+        else
+        {
+            /*
+             * Grow the list.
+             */
+            PBS3SLABCTL pNew = (PBS3SLABCTL)Bs3SlabAlloc(  enmKind == BS3MEMKIND_REAL
+                                                         ? &BS3_DATA_NM(g_Bs3Mem4KLow).Core
+                                                         : &BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core);
+            BS3_ASSERT(((uintptr_t)pNew & 0xfff) == 0);
+            if (pNew)
+            {
+                uint16_t const      cbHdr = BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[idxSlabList];
+                BS3_XPTR_AUTO(void, pvNew);
+                BS3_XPTR_SET(void, pvNew, pNew);
+
+                Bs3SlabInit(pNew, cbHdr, BS3_XPTR_GET_FLAT(void, pvNew) + cbHdr, _4K - cbHdr, pHead->cbChunk);
+                Bs3SlabListAdd(pHead, pNew);
+
+                pvRet = Bs3SlabListAlloc(pHead);
+            }
+        }
+    }
+    else
+    {
+        /*
+         * Allocate one or more pages.
+         */
+        size_t   const cbAligned = RT_ALIGN_Z(cb, _4K);
+        uint16_t const cPages    = cbAligned >> 12 /* div _4K */;
+
+        pvRet = Bs3SlabAllocEx(enmKind == BS3MEMKIND_REAL
+                               ? &BS3_DATA_NM(g_Bs3Mem4KLow).Core : &BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core,
+                               cPages,
+                               cPages <= _64K / _4K ? BS3_SLAB_ALLOC_F_SAME_TILE : 0);
+    }
+    return pvRet;
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemAllocZ.c	(revision 58789)
@@ -0,0 +1,42 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3MemAllocZ
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include "bs3kit-template-header.h"
+#include "bs3-cmn-memory.h"
+#include <iprt/asm.h>
+
+
+BS3_DECL(void BS3_FAR *) Bs3MemAllocZ(BS3MEMKIND enmKind, size_t cb)
+{
+    void BS3_FAR *pvRet = Bs3MemAlloc(enmKind, cb);
+    if (pvRet)
+        Bs3MemZero(pvRet, cb);
+    return pvRet;
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-MemFree.c	(revision 58789)
@@ -0,0 +1,62 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3MemFree
+ */
+
+/*
+ * Copyright (C) 2007-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include "bs3kit-template-header.h"
+#include "bs3-cmn-memory.h"
+#include <iprt/asm.h>
+
+
+BS3_DECL(void) Bs3MemFree(void BS3_FAR *pv, size_t cb)
+{
+    if (pv != NULL)
+    {
+        uint16_t    cChunks;
+        PBS3SLABCTL pCtl;
+        BS3_XPTR_AUTO(void, pvFlat);
+        BS3_XPTR_SET(void, pvFlat, pv);
+
+        if (BS3_XPTR_GET_FLAT(void, pvFlat) & 0xfffU)
+        {
+            /* Use an XPTR here in case we're in real mode and the caller has
+               messed around with the pointer. */
+            BS3_XPTR_AUTO(BS3SLABCTL, pTmp);
+            BS3_XPTR_SET_FLAT(BS3SLABCTL, pTmp, BS3_XPTR_GET_FLAT(void, pvFlat) & ~(uint32_t)0xfff);
+            pCtl = BS3_XPTR_GET(BS3SLABCTL, pTmp);
+            BS3_ASSERT(pCtl->cbChunk >= cb);
+            cChunks = 1;
+        }
+        else
+        {
+            pCtl = BS3_XPTR_GET_FLAT(void, pvFlat) < _1M ? &BS3_DATA_NM(g_Bs3Mem4KLow).Core : &BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core;
+            cChunks = RT_ALIGN_Z(cb, _4K) >> 12;
+        }
+        Bs3SlabFree(pCtl, BS3_XPTR_GET_FLAT(void, pvFlat), cChunks);
+    }
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm	(revision 58789)
@@ -33,5 +33,5 @@
 ; Prints a 32-bit unsigned integer value.
 ;
-; @param    [xSP + xCB]     32-bit value to format and print.
+; @param    [xBP + xCB*2]   32-bit value to format and print.
 ;
 BS3_PROC_BEGIN_CMN Bs3PrintU32
@@ -43,4 +43,5 @@
         push    sCX
         push    sBX
+        BS3_ONLY_16BIT_STMT push ds
 
         mov     eax, [xBP + xCB*2]
@@ -48,4 +49,6 @@
         ; Allocate a stack buffer and terminate it. ds:bx points ot the end.
         sub     xSP, 30h
+        BS3_ONLY_16BIT_STMT mov bx, ss
+        BS3_ONLY_16BIT_STMT mov ds, bx
         mov     xBX, xSP
         add     xBX, 2fh
@@ -68,4 +71,5 @@
 
         add     xSP, 30h + BS3_ONLY_16BIT(2 + ) xCB
+        BS3_ONLY_16BIT_STMT pop ds
         pop     sBX
         pop     sCX
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm	(revision 58789)
@@ -0,0 +1,86 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3PrintU32, Common.
+;
+
+;
+; Copyright (C) 2007-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+BS3_EXTERN_CMN Bs3PrintStr
+
+;;
+; Prints a 32-bit unsigned integer value as hex.
+;
+; @param    [xBP + xCB*2]   32-bit value to format and print.
+;
+BS3_PROC_BEGIN_CMN Bs3PrintX32
+        BS3_CALL_CONV_PROLOG 1
+        push    xBP
+        mov     xBP, xSP
+        push    sAX
+        push    sDX
+        push    sCX
+        push    sBX
+        BS3_ONLY_16BIT_STMT push ds
+
+        mov     eax, [xBP + xCB*2]
+
+        ; Allocate a stack buffer and terminate it. ds:bx points ot the end.
+        sub     xSP, 30h
+        BS3_ONLY_16BIT_STMT mov bx, ss
+        BS3_ONLY_16BIT_STMT mov ds, bx
+        mov     xBX, xSP
+        add     xBX, 2fh
+        mov     byte [xBX], 0
+
+        mov     ecx, 16                 ; what to divide by
+.next:
+        xor     edx, edx
+        div     ecx                     ; edx:eax / ecx -> eax and rest in edx.
+        cmp     dl, 10
+        jb      .decimal
+        add     dl, 'a' - '0' - 10
+.decimal:
+        add     dl, '0'
+        dec     xBX
+        mov     [BS3_ONLY_16BIT(ss:)xBX], dl
+        cmp     eax, 0
+        jnz     .next
+
+        ; Print the string.
+        BS3_ONLY_16BIT_STMT push    ss
+        push    xBX
+        call    Bs3PrintStr
+
+        add     xSP, 30h + BS3_ONLY_16BIT(2 + ) xCB
+        BS3_ONLY_16BIT_STMT pop ds
+        pop     sBX
+        pop     sCX
+        pop     sDX
+        pop     sAX
+        leave
+        BS3_CALL_CONV_EPILOG 1
+        ret
+BS3_PROC_END_CMN   Bs3PrintX32
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAlloc.c	(revision 58789)
@@ -0,0 +1,49 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3SlabAlloc
+ */
+
+/*
+ * 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.h"
+#include <iprt/asm.h>
+
+
+BS3_DECL(void BS3_FAR *) Bs3SlabAlloc(PBS3SLABCTL pSlabCtl)
+{
+    if (pSlabCtl->cFreeChunks)
+    {
+        int32_t iBit = ASMBitFirstClear(&pSlabCtl->bmAllocated, pSlabCtl->cChunks);
+        if (iBit >= 0)
+        {
+            BS3_XPTR_AUTO(void, pvRet);
+            ASMBitSet(&pSlabCtl->bmAllocated, iBit);
+            pSlabCtl->cFreeChunks  -= 1;
+
+            BS3_XPTR_SET_FLAT(void, pvRet,
+                              BS3_XPTR_GET_FLAT(uint8_t, pSlabCtl->pbStart) + ((uint32_t)iBit << pSlabCtl->cChunkShift));
+            return BS3_XPTR_GET(void, pvRet);
+        }
+    }
+    return NULL;
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c	(revision 58789)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabAllocEx.c	(revision 58789)
@@ -0,0 +1,89 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3SlabAllocEx
+ */
+
+/*
+ * 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.h"
+#include <iprt/asm.h>
+
+
+BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags)
+{
+    if (pSlabCtl->cFreeChunks >= cChunks)
+    {
+        int32_t iBit = ASMBitFirstClear(&pSlabCtl->bmAllocated, pSlabCtl->cChunks);
+        if (iBit >= 0)
+        {
+            while ((uint32_t)iBit + cChunks <= pSlabCtl->cChunks)
+            {
+                /* Check that we've got the requested number of free chunks here. */
+                uint16_t i;
+                for (i = 1; i < cChunks; i++)
+                    if (!ASMBitTest(&pSlabCtl->bmAllocated, iBit + i))
+                        break;
+                if (i == cChunks)
+                {
+                    /* Check if the chunks are all in the same tiled segment. */
+                    BS3_XPTR_AUTO(void, pvRet);
+                    BS3_XPTR_SET_FLAT(void, pvRet,
+                                      BS3_XPTR_GET_FLAT(uint8_t, pSlabCtl->pbStart) + ((uint32_t)iBit << pSlabCtl->cChunkShift));
+                    if (   !(fFlags & BS3_SLAB_ALLOC_F_SAME_TILE)
+                        ||    (BS3_XPTR_GET_FLAT(void, pvRet) >> 16)
+                           == ((BS3_XPTR_GET_FLAT(void, pvRet) + ((uint32_t)cChunks << pSlabCtl->cChunkShift) - 1) >> 16) )
+                    {
+                        /* Complete the allocation. */
+                        for (i = 0; i < cChunks; i++)
+                            ASMBitSet(&pSlabCtl->bmAllocated, iBit + i);
+                        pSlabCtl->cFreeChunks  -= cChunks;
+
+                        return BS3_XPTR_GET(void, pvRet);
+                    }
+
+                    /*
+                     * We're crossing a tiled segment boundrary.
+                     * Skip to the start of the next segment and retry there.
+                     * (We already know that the first chunk in the next tiled
+                     * segment is free, otherwise we wouldn't have a crossing.)
+                     */
+                    BS3_ASSERT(((uint32_t)cChunks << pSlabCtl->cChunkShift) <= _64K);
+                    i = BS3_XPTR_GET_FLAT_LOW(void, pvRet);
+                    i = UINT16_C(0) - i;
+                    i >>= pSlabCtl->cChunkShift;
+                    iBit += i;
+                }
+                else
+                {
+                    /*
+                     * Continue searching.
+                     */
+                    iBit = ASMBitNextClear(&pSlabCtl->bmAllocated, pSlabCtl->cChunks, iBit + i);
+                    if (iBit < 0)
+                        break;
+                }
+            }
+        }
+    }
+    return NULL;
+}
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c	(revision 58789)
@@ -29,5 +29,5 @@
 
 
-BS3_DECL(uint16_t) Bs3SlabFree(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks)
+BS3_DECL(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 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c	(revision 58789)
@@ -29,5 +29,5 @@
 
 
-BS3_DECL(void) Bs3SlabInit(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk)
+BS3_DECL(void) Bs3SlabInit(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk)
 {
     uint16_t cBits;
@@ -36,7 +36,7 @@
     BS3_ASSERT(!(uFlatSlabPtr & (cbChunk - 1)));
 
-    BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pNext, 0);
-    BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pHead, 0);
-    BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pbStart, uFlatSlabPtr);
+    BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pNext, 0);
+    BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pHead, 0);
+    BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pbStart, uFlatSlabPtr);
     pSlabCtl->cbChunk           = cbChunk;
     pSlabCtl->cChunkShift       = ASMBitFirstSetU16(cbChunk) - 1;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c	(revision 58789)
@@ -28,11 +28,12 @@
 
 
-BS3_DECL(void) Bs3SlabListAdd(PBS3SLABHEAD pHead, PBS3SLABCLT pSlabCtl)
+BS3_DECL(void) Bs3SlabListAdd(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl)
 {
     BS3_ASSERT(pHead->cbChunk == pSlabCtl->cbChunk);
     BS3_ASSERT(BS3_XPTR_IS_NULL(BS3SLABHEAD, pSlabCtl->pNext));
 
-    BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pNext, BS3_XPTR_GET_FLAT(BS3SLABCLT, pHead->pFirst));
-    BS3_XPTR_SET(BS3SLABCLT, pHead->pFirst, pSlabCtl);
+    BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pNext, BS3_XPTR_GET_FLAT(BS3SLABCTL, pHead->pFirst));
+    BS3_XPTR_SET(BS3SLABCTL, pHead->pFirst, pSlabCtl);
+
     pHead->cSlabs      += 1;
     pHead->cChunks     += pSlabCtl->cChunks;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c	(revision 58789)
@@ -33,22 +33,16 @@
     if (pHead->cFreeChunks)
     {
-        PBS3SLABCLT pCur;
-        for (pCur = BS3_XPTR_GET(BS3SLABCLT, pHead->pFirst);
+        PBS3SLABCTL pCur;
+        for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst);
              pCur != NULL;
-             pCur = BS3_XPTR_GET(BS3SLABCLT, pCur->pNext))
+             pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext))
         {
             if (pCur->cFreeChunks)
             {
-                int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->cChunks);
-                if (iBit >= 0)
+                void BS3_FAR *pvRet = Bs3SlabAlloc(pCur);
+                if (pvRet)
                 {
-                    BS3_XPTR_AUTO(void, pvRet);
-                    ASMBitSet(&pCur->bmAllocated, iBit);
-                    pCur->cFreeChunks  -= 1;
                     pHead->cFreeChunks -= 1;
-
-                    BS3_XPTR_SET_FLAT(void, pvRet,
-                                      BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart) + ((uint32_t)iBit << pCur->cChunkShift));
-                    return BS3_XPTR_GET(void, pvRet);
+                    return pvRet;
                 }
             }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c	(revision 58789)
@@ -34,63 +34,16 @@
     if (pHead->cFreeChunks >= cChunks)
     {
-        PBS3SLABCLT pCur;
-        for (pCur = BS3_XPTR_GET(BS3SLABCLT, pHead->pFirst);
+        PBS3SLABCTL pCur;
+        for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst);
              pCur != NULL;
-             pCur = BS3_XPTR_GET(BS3SLABCLT, pCur->pNext))
+             pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext))
         {
             if (pCur->cFreeChunks >= cChunks)
             {
-                int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->cChunks);
-                if (iBit >= 0)
+                void BS3_FAR *pvRet = Bs3SlabAllocEx(pCur, cChunks, fFlags);
+                if (pvRet)
                 {
-                    while ((uint32_t)iBit + cChunks <= pCur->cChunks)
-                    {
-                        /* Check that we've got the requested number of free chunks here. */
-                        uint16_t i;
-                        for (i = 1; i < cChunks; i++)
-                            if (!ASMBitTest(&pCur->bmAllocated, iBit + i))
-                                break;
-                        if (i == cChunks)
-                        {
-                            BS3_XPTR_AUTO(void, pvRet);
-
-                            /* Check if the chunks are all in the same tiled segment. */
-                            BS3_XPTR_SET_FLAT(void, pvRet,
-                                              BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart) + ((uint32_t)iBit << pCur->cChunkShift));
-                            if (   !(fFlags & BS3_SLAB_ALLOC_F_SAME_TILE)
-                                ||    (BS3_XPTR_GET_FLAT(void, pvRet) >> 16)
-                                   == (BS3_XPTR_GET_FLAT(void, pvRet) + ((uint32_t)cChunks << pCur->cChunkShift)) )
-                            {
-                                /* Complete the allocation. */
-                                for (i = 0; i < cChunks; i++)
-                                    ASMBitSet(&pCur->bmAllocated, iBit + i);
-                                pCur->cFreeChunks  -= cChunks;
-                                pHead->cFreeChunks -= cChunks;
-
-                                return BS3_XPTR_GET(void, pvRet);
-                            }
-
-                            /*
-                             * We're crossing a tiled segment boundrary.
-                             * Skip to the start of the next segment and retry there.
-                             * (We already know that the first chunk in the next tiled
-                             * segment is free, otherwise we wouldn't have a crossing.)
-                             */
-                            BS3_ASSERT(((uint32_t)cChunks << pCur->cChunkShift) <= _64K);
-                            i = BS3_XPTR_GET_FLAT_LOW(void, pvRet);
-                            i = UINT16_C(0) - i;
-                            i >>= pCur->cChunkShift;
-                            iBit += i;
-                        }
-                        else
-                        {
-                            /*
-                             * Continue searching.
-                             */
-                            iBit = ASMBitNextClear(&pCur->bmAllocated, pCur->cChunks, iBit + i);
-                            if (iBit < 0)
-                                break;
-                        }
-                    }
+                    pHead->cFreeChunks -= cChunks;
+                    return pvRet;
                 }
             }
@@ -100,3 +53,2 @@
 }
 
-
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c	(revision 58789)
@@ -33,11 +33,11 @@
     if (cChunks > 0)
     {
-        PBS3SLABCLT         pCur;
+        PBS3SLABCTL         pCur;
         BS3_XPTR_AUTO(void, pvFlatChunk);
         BS3_XPTR_SET(void,  pvFlatChunk, pvChunks);
 
-        for (pCur = BS3_XPTR_GET(BS3SLABCLT, pHead->pFirst);
+        for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst);
              pCur != NULL;
-             pCur = BS3_XPTR_GET(BS3SLABCLT, pCur->pNext))
+             pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext))
         {
             if (  ((BS3_XPTR_GET_FLAT(void, pvFlatChunk) - BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart)) >> pCur->cChunkShift)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c	(revision 58789)
@@ -31,5 +31,5 @@
 {
     BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk));
-    BS3_XPTR_SET(struct BS3SLABCLT, pHead->pFirst, 0);
+    BS3_XPTR_SET(struct BS3SLABCTL, pHead->pFirst, 0);
     pHead->cbChunk     = cbChunk;
     pHead->cSlabs      = 0;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-memory.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-memory.h	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-memory.h	(revision 58789)
@@ -29,22 +29,23 @@
 
 #include "bs3kit.h"
+#include <iprt/asm.h>
 
 RT_C_DECLS_BEGIN;
 
 
-typedef union BS3SLABCLTLOW
+typedef union BS3SLABCTLLOW
 {
-    BS3SLABCLT  Core;
-    uint32_t    au32Alloc[(sizeof(BS3SLABCLT) + (0xA0000 / _4K / 8) ) / 4];
-} BS3SLABCLTLOW;
-extern BS3SLABCLTLOW            BS3_DATA_NM(g_LowMemory);
+    BS3SLABCTL  Core;
+    uint32_t    au32Alloc[(sizeof(BS3SLABCTL) + (0xA0000 / _4K / 8) ) / 4];
+} BS3SLABCTLLOW;
+extern BS3SLABCTLLOW            BS3_DATA_NM(g_Bs3Mem4KLow);
 
 
 typedef union BS3SLABCTLUPPERTILED
 {
-    BS3SLABCLT  Core;
-    uint32_t    au32Alloc[(sizeof(BS3SLABCLT) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4];
+    BS3SLABCTL  Core;
+    uint32_t    au32Alloc[(sizeof(BS3SLABCTL) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4];
 } BS3SLABCTLUPPERTILED;
-extern BS3SLABCTLUPPERTILED     BS3_DATA_NM(g_UpperTiledMemory);
+extern BS3SLABCTLUPPERTILED     BS3_DATA_NM(g_Bs3Mem4KUpperTiled);
 
 
@@ -53,7 +54,23 @@
 #define BS3_MEM_SLAB_LIST_COUNT 6
 
+extern uint8_t const            BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[12];
 extern uint16_t const           BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT];
 extern BS3SLABHEAD              BS3_DATA_NM(g_aBs3LowSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
 extern BS3SLABHEAD              BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
+extern uint16_t const           BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[BS3_MEM_SLAB_LIST_COUNT];
+
+
+/**
+ * Translates a allocation request size to a slab list index.
+ *
+ * @returns Slab list index if small request, UINT8_MAX if large.
+ * @param   cbRequest   The number of bytes requested.
+ */
+DECLINLINE(uint8_t) bs3MemSizeToSlabListIndex(size_t cbRequest)
+{
+    if (cbRequest <= BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT - 1])
+        return BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[cbRequest ? ASMBitLastSetU16((uint16_t)(cbRequest - 1)) : 0];
+    return UINT8_MAX;
+}
 
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm	(revision 58789)
@@ -45,6 +45,4 @@
 %endif
 
-BS3_GLOBAL_DATA Bs3Text16_Size, 2
-    dw  BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt BS3TEXT16
 BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
 
@@ -57,4 +55,15 @@
 BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
     db      10,13,'eye-catcher: BS3DATA16',10,13
+
+ALIGNDATA(16)
+BS3_GLOBAL_DATA Bs3Data16_Size, 4
+    dd  BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3DATA16_GROUP
+BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
+    dd  BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3DATA16_GROUP
+BS3_GLOBAL_DATA Bs3TotalImageSize, 4
+    dd  BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt CGROUP16
+BS3_GLOBAL_DATA Bs3Text16_Size, 2
+    dd  BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16
+
 %ifdef ASM_FORMAT_ELF
 section BS3DATA16CONST  align=2   progbits alloc noexec write
@@ -85,6 +94,5 @@
 section BS3TEXT32_END   align=1 CLASS=BS3CODE32 PUBLIC USE32 FLAT
 %endif
-BS3_GLOBAL_DATA Bs3Data16_Size, 4
-    dd  BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3DATA16
+
 BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0
 
@@ -121,11 +129,4 @@
 section BS3DATA64_END   align=16   CLASS=DATA PUBLIC USE32 FLAT
 %endif
-
-ALIGNDATA(16)
-    db      10,13,'eye-catcher: sizes  ',10,13
-BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
-    dd  BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3DATA16
-BS3_GLOBAL_DATA Bs3TotalImageSize, 4
-    dd  BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3TEXT16
 BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c	(revision 58789)
@@ -99,8 +99,26 @@
 *********************************************************************************************************************************/
 /** Slab control structure for the 4K management of low memory (< 1MB). */
-BS3SLABCLTLOW           BS3_DATA_NM(g_Bs3Mem4KLow);
+BS3SLABCTLLOW           BS3_DATA_NM(g_Bs3Mem4KLow);
 /** Slab control structure for the 4K management of tiled upper memory,
  *  between 1 MB and 16MB. */
 BS3SLABCTLUPPERTILED    BS3_DATA_NM(g_Bs3Mem4KUpperTiled);
+
+
+/** Translates a power of two request size to an slab list index. */
+uint8_t const           BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[12] =
+{
+    /* 2^0  =    1 */  0,
+    /* 2^1  =    2 */  0,
+    /* 2^2  =    4 */  0,
+    /* 2^3  =    8 */  0,
+    /* 2^4  =   16 */  0,
+    /* 2^5  =   32 */  1,
+    /* 2^6  =   64 */  2,
+    /* 2^7  =  128 */  3,
+    /* 2^8  =  256 */  4,
+    /* 2^9  =  512 */  5,
+    /* 2^10 = 1024 */  -1
+    /* 2^11 = 2048 */  -1
+};
 
 /** The slab list chunk sizes. */
@@ -114,8 +132,21 @@
     512,
 };
+
 /** Low memory slab lists, sizes given by g_acbBs3SlabLists. */
 BS3SLABHEAD             BS3_DATA_NM(g_aBs3LowSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
 /** Upper tiled memory slab lists, sizes given by g_acbBs3SlabLists. */
 BS3SLABHEAD             BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
+
+/** Slab control structure sizes for the slab lists.
+ * This is to help the allocator when growing a list. */
+uint16_t const          BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[BS3_MEM_SLAB_LIST_COUNT] =
+{
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 16  / 8 /*=32*/), 16),
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 32  / 8 /*=16*/), 32),
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 64  / 8 /*=8*/),  64),
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 128 / 8 /*=4*/), 128),
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 256 / 8 /*=2*/), 256),
+    RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 512 / 8 /*=1*/), 512),
+};
 
 
@@ -141,13 +172,14 @@
      *      - 0xf0000 to 0xfffff - PC BIOS.
      */
-    Bs3SlabInit(&g_Bs3Mem4KLow.Core, sizeof(g_Bs3Mem4KLow), 0 /*uFlatSlabPtr*/, 0xA0000 /* 640 KB*/, _4K);
+    Bs3SlabInit(&BS3_DATA_NM(g_Bs3Mem4KLow).Core, sizeof(BS3_DATA_NM(g_Bs3Mem4KLow)),
+                0 /*uFlatSlabPtr*/, 0xA0000 /* 640 KB*/, _4K);
 
     /* Mark the stacks and whole image as allocated. */
     cPages  = (BS3_DATA_NM(Bs3TotalImageSize) + _4K - 1U) >> 12;
-    ASMBitSetRange(g_Bs3Mem4KLow.Core.bmAllocated, 0, 0x10 + cPages);
+    ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0, 0x10 + cPages);
 
     /* Mark any unused pages between BS3TEXT16 and BS3SYSTEM16 as free. */
     cPages = (BS3_DATA_NM(Bs3Text16_Size) + _4K - 1U) >> 12;
-    ASMBitClearRange(g_Bs3Mem4KLow.Core.bmAllocated, 0x10U + cPages, 0x20U);
+    ASMBitClearRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0x10U + cPages, 0x20U);
 
     /* In case the system has less than 640KB of memory, check the BDA variable for it. */
@@ -156,25 +188,26 @@
     {
         cPages = 640 - cPages;
+        cPages = RT_ALIGN(cPages, 4);
         cPages >>= 2;
-        ASMBitSetRange(g_Bs3Mem4KLow.Core.bmAllocated, 0xA0 - cPages, 0xA0);
+        ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0xA0 - cPages, 0xA0);
     }
     else
-        ASMBitSet(g_Bs3Mem4KLow.Core.bmAllocated, 0x9F);
+        ASMBitSet(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0x9F);
 
     /* Recalc free pages. */
     cPages = 0;
-    i = g_Bs3Mem4KLow.Core.cChunks;
+    i = BS3_DATA_NM(g_Bs3Mem4KLow).Core.cChunks;
     while (i-- > 0)
-        cPages += ASMBitTest(g_Bs3Mem4KLow.Core.bmAllocated, i);
-    g_Bs3Mem4KLow.Core.cFreeChunks = cPages;
-
+        cPages += !ASMBitTest(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, i);
+    BS3_DATA_NM(g_Bs3Mem4KLow).Core.cFreeChunks = cPages;
 
     /*
      * First 16 MB of memory above 1MB.  We start out by marking it all allocated.
      */
-    Bs3SlabInit(&g_Bs3Mem4KUpperTiled.Core, sizeof(g_Bs3Mem4KUpperTiled), _1M, BS3_SEL_TILED_AREA_SIZE - _1M, _4K);
-
-    ASMBitSetRange(g_Bs3Mem4KUpperTiled.Core.bmAllocated, 0, g_Bs3Mem4KUpperTiled.Core.cChunks);
-    g_Bs3Mem4KUpperTiled.Core.cFreeChunks = 0;
+    Bs3SlabInit(&BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core, sizeof(BS3_DATA_NM(g_Bs3Mem4KUpperTiled)),
+                _1M, BS3_SEL_TILED_AREA_SIZE - _1M, _4K);
+
+    ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.bmAllocated, 0, BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cChunks);
+    BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cFreeChunks = 0;
 
     /* Ask the BIOS about where there's memory, and make pages in between 1MB
@@ -235,6 +268,6 @@
                             while (cPages-- > 0)
                             {
-                                g_Bs3Mem4KUpperTiled.Core.cFreeChunks += !ASMBitTestAndSet(g_Bs3Mem4KUpperTiled.Core.bmAllocated,
-                                                                                            i);
+                                uint16_t uLineToLong = ASMBitTestAndClear(g_Bs3Mem4KUpperTiled.Core.bmAllocated, i);
+                                BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cFreeChunks += uLineToLong;
                                 i++;
                             }
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c	(revision 58789)
@@ -11,7 +11,49 @@
 BS3_DECL(void) Main_rm(void)
 {
+    void BS3_FAR *pvTmp1;
+    void BS3_FAR *pvTmp2;
+    void BS3_FAR *pvTmp3;
+    void BS3_FAR *pvTmp4;
     Bs3InitMemory_rm();
 
     Bs3TestInit("bs3-shutdown");
+
+Bs3PrintStr("Bs3PrintX32:");
+Bs3PrintX32(UINT32_C(0xfdb97531));
+Bs3PrintStr("\r\n");
+
+pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K);
+Bs3PrintStr("pvTmp2=");
+Bs3PrintX32((uintptr_t)pvTmp2);
+Bs3PrintStr("\r\n");
+
+pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K);
+Bs3PrintStr("pvTmp3=");
+Bs3PrintX32((uintptr_t)pvTmp3);
+Bs3PrintStr("\r\n");
+Bs3MemFree(pvTmp2, _4K);
+
+pvTmp4 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K);
+Bs3PrintStr("pvTmp4=");
+Bs3PrintX32((uintptr_t)pvTmp4);
+Bs3PrintStr("\r\n");
+Bs3PrintStr("\r\n");
+
+pvTmp1 = Bs3MemAlloc(BS3MEMKIND_REAL, 31);
+Bs3PrintStr("pvTmp1=");
+Bs3PrintX32((uintptr_t)pvTmp1);
+Bs3PrintStr("\r\n");
+
+pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, 17);
+Bs3PrintStr("pvTmp2=");
+Bs3PrintX32((uintptr_t)pvTmp2);
+Bs3PrintStr("\r\n");
+
+Bs3MemFree(pvTmp1, 31);
+pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, 17);
+Bs3PrintStr("pvTmp3=");
+Bs3PrintX32((uintptr_t)pvTmp3);
+Bs3PrintStr("\r\n");
+
 
 Bs3Panic();
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58788)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58789)
@@ -599,44 +599,44 @@
  * @{ */
 /** Start of the BS3TEXT16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text16_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text16_StartOfSegment);
 /** End of the BS3TEXT16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text16_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text16_EndOfSegment);
 /** The size of the BS3TEXT16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text16_Size);
+extern uint16_t BS3_DATA_NM(Bs3Text16_Size);
 
 /** Start of the BS3SYSTEM16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3System16_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3System16_StartOfSegment);
 /** End of the BS3SYSTEM16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3System16_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3System16_EndOfSegment);
 
 /** Start of the BS3DATA16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data16_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data16_StartOfSegment);
 /** End of the BS3DATA16 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data16_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data16_EndOfSegment);
 
 /** Start of the BS3TEXT32 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text32_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text32_StartOfSegment);
 /** Start of the BS3TEXT32 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text32_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text32_EndOfSegment);
 
 /** Start of the BS3DATA32 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data32_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data32_StartOfSegment);
 /** Start of the BS3DATA32 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data32_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data32_EndOfSegment);
 
 /** Start of the BS3TEXT64 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text64_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text64_StartOfSegment);
 /** Start of the BS3TEXT64 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Text64_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Text64_EndOfSegment);
 
 /** Start of the BS3DATA64 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data64_StartOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data64_StartOfSegment);
 /** Start of the BS3DATA64 segment.   */
-extern uint8_t BS3_DATA_NM(Bs3Data64_EndOfSegment);
+extern uint8_t  BS3_DATA_NM(Bs3Data64_EndOfSegment);
 
 /** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */
-extern uint8_t BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize);
+extern uint32_t BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize);
 /** The total image size (from Text16 thu Data64). */
-extern uint8_t BS3_DATA_NM(Bs3TotalImageSize);
+extern uint32_t BS3_DATA_NM(Bs3TotalImageSize);
 /** @} */
 
@@ -845,5 +845,5 @@
         } \
         else \
-            (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + (BS3_FP_SEG(pTypeCheck) << 4); \
+            (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
     } while (0)
 #elif ARCH_BITS == 32
@@ -911,5 +911,5 @@
 
 /**
- * Prints a 32-bit unsigned value as hex to the screen.
+ * Prints a 32-bit unsigned value as decimal to the screen.
  *
  * @param   uValue      The 32-bit value.
@@ -919,4 +919,14 @@
 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. */
+
+/**
+ * Prints a 32-bit unsigned value as hex to the screen.
+ *
+ * @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. */
 
 /**
@@ -1084,5 +1094,5 @@
 {
     /** Pointer to the first slab. */
-    BS3_XPTR_MEMBER(struct BS3SLABCLT, pFirst);
+    BS3_XPTR_MEMBER(struct BS3SLABCTL, pFirst);
     /** The allocation chunk size. */
     uint16_t                        cbChunk;
@@ -1103,8 +1113,8 @@
  * static location for the larger ones.
  */
-typedef struct BS3SLABCLT
+typedef struct BS3SLABCTL
 {
     /** Pointer to the next slab control structure in this list. */
-    BS3_XPTR_MEMBER(struct BS3SLABCLT, pNext);
+    BS3_XPTR_MEMBER(struct BS3SLABCTL, pNext);
     /** Pointer to the slab list head. */
     BS3_XPTR_MEMBER(BS3SLABHEAD,    pHead);
@@ -1123,7 +1133,10 @@
      * multiple of 4). */
     uint8_t                         bmAllocated[4];
-} BS3SLABCLT;
+} BS3SLABCTL;
 /** Pointer to a bs3kit slab control structure. */
-typedef BS3SLABCLT BS3_FAR *PBS3SLABCLT;
+typedef BS3SLABCTL BS3_FAR *PBS3SLABCTL;
+
+/** The chunks must all be in the same 16-bit segment tile. */
+#define BS3_SLAB_ALLOC_F_SAME_TILE      UINT16_C(0x0001)
 
 /**
@@ -1136,10 +1149,49 @@
  * @param   cbChunk         The chunk size.
  */
-BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
+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(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
+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(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
+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. */
+
+/**
+ * Allocates one chunk from a slab.
+ *
+ * @returns Pointer to a chunk on success, NULL if we're out of chunks.
+ * @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. */
+
+/**
+ * Allocates one or more chunks rom a slab.
+ *
+ * @returns Pointer to the request number of chunks on success, NULL if we're
+ *          out of chunks.
+ * @param   pSlabCtl        The slab constrol structure to allocate from.
+ * @param   cChunks         The number of contiguous chunks we want.
+ * @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. */
+
+/**
+ * Frees one or more chunks from a slab.
+ *
+ * @returns Number of chunks actually freed.  When correctly used, this will
+ *          match the @a cChunks parameter, of course.
+ * @param   pSlabCtl        The slab constrol structure to free from.
+ * @param   uFlatChunkPtr   The flat address of the chunks to free.
+ * @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. */
 
 
@@ -1161,9 +1213,9 @@
  * @param   pSlabCtl        The slab control structure to add.
  */
-BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCLT pSlabCtl);
+BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
 /** @copydoc Bs3SlabListAdd_c16 */
-BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCLT pSlabCtl);
+BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
 /** @copydoc Bs3SlabListAdd_c16 */
-BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCLT pSlabCtl);
+BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
 #define Bs3SlabListAdd BS3_CMN_NM(Bs3SlabListAdd) /**< Selects #Bs3SlabListAdd_c16, #Bs3SlabListAdd_c32 or #Bs3SlabListAdd_c64. */
 
@@ -1192,20 +1244,4 @@
 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. */
-/** The chunks must all be in the same 16-bit segment tile. */
-#define BS3_SLAB_ALLOC_F_SAME_TILE      UINT16_C(0x0001)
-
-/**
- * Frees one or more chunks from a slab.
- *
- * @returns Number of chunks actually freed.  When correctly used, this will
- *          match the @a cChunks parameter, of course.
- * @param   pSlabCtl        The slab constrol structure to free from.
- * @param   uFlatChunkPtr   The flat address of the chunks to free.
- * @param   cChunks         The number of contiguous chunks to free.
- */
-BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks);
-BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
-BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
-#define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */
 
 /**
