Changeset 58789 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Nov 20, 2015 3:38:25 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 5 added
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r58785 r58789 364 364 bs3-cmn-PrintChr.asm \ 365 365 bs3-cmn-PrintU32.asm \ 366 bs3-cmn-PrintX32.asm \ 366 367 bs3-cmn-PrintStr.c \ 367 368 bs3-cmn-PrintStrColonSpaces.asm \ … … 374 375 bs3-cmn-MemMove.c \ 375 376 bs3-cmn-MemZero.asm \ 377 bs3-cmn-MemAlloc.c \ 378 bs3-cmn-MemAllocZ.c \ 379 bs3-cmn-MemFree.c \ 376 380 bs3-cmn-SlabInit.c \ 381 bs3-cmn-SlabAlloc.c \ 382 bs3-cmn-SlabAllocEx.c \ 377 383 bs3-cmn-SlabFree.c \ 378 384 bs3-cmn-SlabListInit.c \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm
r58628 r58789 33 33 ; Prints a 32-bit unsigned integer value. 34 34 ; 35 ; @param [x SP + xCB]32-bit value to format and print.35 ; @param [xBP + xCB*2] 32-bit value to format and print. 36 36 ; 37 37 BS3_PROC_BEGIN_CMN Bs3PrintU32 … … 43 43 push sCX 44 44 push sBX 45 BS3_ONLY_16BIT_STMT push ds 45 46 46 47 mov eax, [xBP + xCB*2] … … 48 49 ; Allocate a stack buffer and terminate it. ds:bx points ot the end. 49 50 sub xSP, 30h 51 BS3_ONLY_16BIT_STMT mov bx, ss 52 BS3_ONLY_16BIT_STMT mov ds, bx 50 53 mov xBX, xSP 51 54 add xBX, 2fh … … 68 71 69 72 add xSP, 30h + BS3_ONLY_16BIT(2 + ) xCB 73 BS3_ONLY_16BIT_STMT pop ds 70 74 pop sBX 71 75 pop sCX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm
r58779 r58789 31 31 32 32 ;; 33 ; Prints a 32-bit unsigned integer value .33 ; Prints a 32-bit unsigned integer value as hex. 34 34 ; 35 ; @param [x SP + xCB]32-bit value to format and print.35 ; @param [xBP + xCB*2] 32-bit value to format and print. 36 36 ; 37 BS3_PROC_BEGIN_CMN Bs3Print U3237 BS3_PROC_BEGIN_CMN Bs3PrintX32 38 38 BS3_CALL_CONV_PROLOG 1 39 39 push xBP … … 43 43 push sCX 44 44 push sBX 45 BS3_ONLY_16BIT_STMT push ds 45 46 46 47 mov eax, [xBP + xCB*2] … … 48 49 ; Allocate a stack buffer and terminate it. ds:bx points ot the end. 49 50 sub xSP, 30h 51 BS3_ONLY_16BIT_STMT mov bx, ss 52 BS3_ONLY_16BIT_STMT mov ds, bx 50 53 mov xBX, xSP 51 54 add xBX, 2fh 52 55 mov byte [xBX], 0 53 56 54 mov ecx, 1 0; what to divide by57 mov ecx, 16 ; what to divide by 55 58 .next: 56 59 xor edx, edx 57 60 div ecx ; edx:eax / ecx -> eax and rest in edx. 61 cmp dl, 10 62 jb .decimal 63 add dl, 'a' - '0' - 10 64 .decimal: 58 65 add dl, '0' 59 66 dec xBX … … 68 75 69 76 add xSP, 30h + BS3_ONLY_16BIT(2 + ) xCB 77 BS3_ONLY_16BIT_STMT pop ds 70 78 pop sBX 71 79 pop sCX … … 75 83 BS3_CALL_CONV_EPILOG 1 76 84 ret 77 BS3_PROC_END_CMN Bs3Print U3285 BS3_PROC_END_CMN Bs3PrintX32 78 86 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabFree.c
r58777 r58789 29 29 30 30 31 BS3_DECL(uint16_t) Bs3SlabFree(PBS3SLABC LTpSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks)31 BS3_DECL(uint16_t) Bs3SlabFree(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks) 32 32 { 33 33 uint16_t cFreed = 0; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c
r58777 r58789 29 29 30 30 31 BS3_DECL(void) Bs3SlabInit(PBS3SLABC LTpSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk)31 BS3_DECL(void) Bs3SlabInit(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk) 32 32 { 33 33 uint16_t cBits; … … 36 36 BS3_ASSERT(!(uFlatSlabPtr & (cbChunk - 1))); 37 37 38 BS3_XPTR_SET_FLAT(BS3SLABC LT, pSlabCtl->pNext, 0);39 BS3_XPTR_SET_FLAT(BS3SLABC LT, pSlabCtl->pHead, 0);40 BS3_XPTR_SET_FLAT(BS3SLABC LT, pSlabCtl->pbStart, uFlatSlabPtr);38 BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pNext, 0); 39 BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pHead, 0); 40 BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pbStart, uFlatSlabPtr); 41 41 pSlabCtl->cbChunk = cbChunk; 42 42 pSlabCtl->cChunkShift = ASMBitFirstSetU16(cbChunk) - 1; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAdd.c
r58720 r58789 28 28 29 29 30 BS3_DECL(void) Bs3SlabListAdd(PBS3SLABHEAD pHead, PBS3SLABC LTpSlabCtl)30 BS3_DECL(void) Bs3SlabListAdd(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl) 31 31 { 32 32 BS3_ASSERT(pHead->cbChunk == pSlabCtl->cbChunk); 33 33 BS3_ASSERT(BS3_XPTR_IS_NULL(BS3SLABHEAD, pSlabCtl->pNext)); 34 34 35 BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pNext, BS3_XPTR_GET_FLAT(BS3SLABCLT, pHead->pFirst)); 36 BS3_XPTR_SET(BS3SLABCLT, pHead->pFirst, pSlabCtl); 35 BS3_XPTR_SET_FLAT(BS3SLABCTL, pSlabCtl->pNext, BS3_XPTR_GET_FLAT(BS3SLABCTL, pHead->pFirst)); 36 BS3_XPTR_SET(BS3SLABCTL, pHead->pFirst, pSlabCtl); 37 37 38 pHead->cSlabs += 1; 38 39 pHead->cChunks += pSlabCtl->cChunks; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c
r58777 r58789 33 33 if (pHead->cFreeChunks) 34 34 { 35 PBS3SLABC LTpCur;36 for (pCur = BS3_XPTR_GET(BS3SLABC LT, pHead->pFirst);35 PBS3SLABCTL pCur; 36 for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst); 37 37 pCur != NULL; 38 pCur = BS3_XPTR_GET(BS3SLABC LT, pCur->pNext))38 pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext)) 39 39 { 40 40 if (pCur->cFreeChunks) 41 41 { 42 int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->cChunks);43 if ( iBit >= 0)42 void BS3_FAR *pvRet = Bs3SlabAlloc(pCur); 43 if (pvRet) 44 44 { 45 BS3_XPTR_AUTO(void, pvRet);46 ASMBitSet(&pCur->bmAllocated, iBit);47 pCur->cFreeChunks -= 1;48 45 pHead->cFreeChunks -= 1; 49 50 BS3_XPTR_SET_FLAT(void, pvRet, 51 BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart) + ((uint32_t)iBit << pCur->cChunkShift)); 52 return BS3_XPTR_GET(void, pvRet); 46 return pvRet; 53 47 } 54 48 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAllocEx.c
r58777 r58789 34 34 if (pHead->cFreeChunks >= cChunks) 35 35 { 36 PBS3SLABC LTpCur;37 for (pCur = BS3_XPTR_GET(BS3SLABC LT, pHead->pFirst);36 PBS3SLABCTL pCur; 37 for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst); 38 38 pCur != NULL; 39 pCur = BS3_XPTR_GET(BS3SLABC LT, pCur->pNext))39 pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext)) 40 40 { 41 41 if (pCur->cFreeChunks >= cChunks) 42 42 { 43 int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->cChunks);44 if ( iBit >= 0)43 void BS3_FAR *pvRet = Bs3SlabAllocEx(pCur, cChunks, fFlags); 44 if (pvRet) 45 45 { 46 while ((uint32_t)iBit + cChunks <= pCur->cChunks) 47 { 48 /* Check that we've got the requested number of free chunks here. */ 49 uint16_t i; 50 for (i = 1; i < cChunks; i++) 51 if (!ASMBitTest(&pCur->bmAllocated, iBit + i)) 52 break; 53 if (i == cChunks) 54 { 55 BS3_XPTR_AUTO(void, pvRet); 56 57 /* Check if the chunks are all in the same tiled segment. */ 58 BS3_XPTR_SET_FLAT(void, pvRet, 59 BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart) + ((uint32_t)iBit << pCur->cChunkShift)); 60 if ( !(fFlags & BS3_SLAB_ALLOC_F_SAME_TILE) 61 || (BS3_XPTR_GET_FLAT(void, pvRet) >> 16) 62 == (BS3_XPTR_GET_FLAT(void, pvRet) + ((uint32_t)cChunks << pCur->cChunkShift)) ) 63 { 64 /* Complete the allocation. */ 65 for (i = 0; i < cChunks; i++) 66 ASMBitSet(&pCur->bmAllocated, iBit + i); 67 pCur->cFreeChunks -= cChunks; 68 pHead->cFreeChunks -= cChunks; 69 70 return BS3_XPTR_GET(void, pvRet); 71 } 72 73 /* 74 * We're crossing a tiled segment boundrary. 75 * Skip to the start of the next segment and retry there. 76 * (We already know that the first chunk in the next tiled 77 * segment is free, otherwise we wouldn't have a crossing.) 78 */ 79 BS3_ASSERT(((uint32_t)cChunks << pCur->cChunkShift) <= _64K); 80 i = BS3_XPTR_GET_FLAT_LOW(void, pvRet); 81 i = UINT16_C(0) - i; 82 i >>= pCur->cChunkShift; 83 iBit += i; 84 } 85 else 86 { 87 /* 88 * Continue searching. 89 */ 90 iBit = ASMBitNextClear(&pCur->bmAllocated, pCur->cChunks, iBit + i); 91 if (iBit < 0) 92 break; 93 } 94 } 46 pHead->cFreeChunks -= cChunks; 47 return pvRet; 95 48 } 96 49 } … … 100 53 } 101 54 102 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListFree.c
r58777 r58789 33 33 if (cChunks > 0) 34 34 { 35 PBS3SLABC LTpCur;35 PBS3SLABCTL pCur; 36 36 BS3_XPTR_AUTO(void, pvFlatChunk); 37 37 BS3_XPTR_SET(void, pvFlatChunk, pvChunks); 38 38 39 for (pCur = BS3_XPTR_GET(BS3SLABC LT, pHead->pFirst);39 for (pCur = BS3_XPTR_GET(BS3SLABCTL, pHead->pFirst); 40 40 pCur != NULL; 41 pCur = BS3_XPTR_GET(BS3SLABC LT, pCur->pNext))41 pCur = BS3_XPTR_GET(BS3SLABCTL, pCur->pNext)) 42 42 { 43 43 if ( ((BS3_XPTR_GET_FLAT(void, pvFlatChunk) - BS3_XPTR_GET_FLAT(uint8_t, pCur->pbStart)) >> pCur->cChunkShift) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListInit.c
r58720 r58789 31 31 { 32 32 BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk)); 33 BS3_XPTR_SET(struct BS3SLABC LT, pHead->pFirst, 0);33 BS3_XPTR_SET(struct BS3SLABCTL, pHead->pFirst, 0); 34 34 pHead->cbChunk = cbChunk; 35 35 pHead->cSlabs = 0; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-memory.h
r58785 r58789 29 29 30 30 #include "bs3kit.h" 31 #include <iprt/asm.h> 31 32 32 33 RT_C_DECLS_BEGIN; 33 34 34 35 35 typedef union BS3SLABC LTLOW36 typedef union BS3SLABCTLLOW 36 37 { 37 BS3SLABC LTCore;38 uint32_t au32Alloc[(sizeof(BS3SLABC LT) + (0xA0000 / _4K / 8) ) / 4];39 } BS3SLABC LTLOW;40 extern BS3SLABC LTLOW BS3_DATA_NM(g_LowMemory);38 BS3SLABCTL Core; 39 uint32_t au32Alloc[(sizeof(BS3SLABCTL) + (0xA0000 / _4K / 8) ) / 4]; 40 } BS3SLABCTLLOW; 41 extern BS3SLABCTLLOW BS3_DATA_NM(g_Bs3Mem4KLow); 41 42 42 43 43 44 typedef union BS3SLABCTLUPPERTILED 44 45 { 45 BS3SLABC LTCore;46 uint32_t au32Alloc[(sizeof(BS3SLABC LT) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4];46 BS3SLABCTL Core; 47 uint32_t au32Alloc[(sizeof(BS3SLABCTL) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4]; 47 48 } BS3SLABCTLUPPERTILED; 48 extern BS3SLABCTLUPPERTILED BS3_DATA_NM(g_ UpperTiledMemory);49 extern BS3SLABCTLUPPERTILED BS3_DATA_NM(g_Bs3Mem4KUpperTiled); 49 50 50 51 … … 53 54 #define BS3_MEM_SLAB_LIST_COUNT 6 54 55 56 extern uint8_t const BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[12]; 55 57 extern uint16_t const BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT]; 56 58 extern BS3SLABHEAD BS3_DATA_NM(g_aBs3LowSlabLists)[BS3_MEM_SLAB_LIST_COUNT]; 57 59 extern BS3SLABHEAD BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[BS3_MEM_SLAB_LIST_COUNT]; 60 extern uint16_t const BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[BS3_MEM_SLAB_LIST_COUNT]; 61 62 63 /** 64 * Translates a allocation request size to a slab list index. 65 * 66 * @returns Slab list index if small request, UINT8_MAX if large. 67 * @param cbRequest The number of bytes requested. 68 */ 69 DECLINLINE(uint8_t) bs3MemSizeToSlabListIndex(size_t cbRequest) 70 { 71 if (cbRequest <= BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT - 1]) 72 return BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[cbRequest ? ASMBitLastSetU16((uint16_t)(cbRequest - 1)) : 0]; 73 return UINT8_MAX; 74 } 58 75 59 76 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm
r58785 r58789 45 45 %endif 46 46 47 BS3_GLOBAL_DATA Bs3Text16_Size, 248 dw BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt BS3TEXT1649 47 BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0 50 48 … … 57 55 BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0 58 56 db 10,13,'eye-catcher: BS3DATA16',10,13 57 58 ALIGNDATA(16) 59 BS3_GLOBAL_DATA Bs3Data16_Size, 4 60 dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3DATA16_GROUP 61 BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4 62 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3DATA16_GROUP 63 BS3_GLOBAL_DATA Bs3TotalImageSize, 4 64 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt CGROUP16 65 BS3_GLOBAL_DATA Bs3Text16_Size, 2 66 dd BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16 67 59 68 %ifdef ASM_FORMAT_ELF 60 69 section BS3DATA16CONST align=2 progbits alloc noexec write … … 85 94 section BS3TEXT32_END align=1 CLASS=BS3CODE32 PUBLIC USE32 FLAT 86 95 %endif 87 BS3_GLOBAL_DATA Bs3Data16_Size, 4 88 dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3DATA16 96 89 97 BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0 90 98 … … 121 129 section BS3DATA64_END align=16 CLASS=DATA PUBLIC USE32 FLAT 122 130 %endif 123 124 ALIGNDATA(16)125 db 10,13,'eye-catcher: sizes ',10,13126 BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4127 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3DATA16128 BS3_GLOBAL_DATA Bs3TotalImageSize, 4129 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3TEXT16130 131 BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0 131 132 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c
r58785 r58789 99 99 *********************************************************************************************************************************/ 100 100 /** Slab control structure for the 4K management of low memory (< 1MB). */ 101 BS3SLABC LTLOW BS3_DATA_NM(g_Bs3Mem4KLow);101 BS3SLABCTLLOW BS3_DATA_NM(g_Bs3Mem4KLow); 102 102 /** Slab control structure for the 4K management of tiled upper memory, 103 103 * between 1 MB and 16MB. */ 104 104 BS3SLABCTLUPPERTILED BS3_DATA_NM(g_Bs3Mem4KUpperTiled); 105 106 107 /** Translates a power of two request size to an slab list index. */ 108 uint8_t const BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[12] = 109 { 110 /* 2^0 = 1 */ 0, 111 /* 2^1 = 2 */ 0, 112 /* 2^2 = 4 */ 0, 113 /* 2^3 = 8 */ 0, 114 /* 2^4 = 16 */ 0, 115 /* 2^5 = 32 */ 1, 116 /* 2^6 = 64 */ 2, 117 /* 2^7 = 128 */ 3, 118 /* 2^8 = 256 */ 4, 119 /* 2^9 = 512 */ 5, 120 /* 2^10 = 1024 */ -1 121 /* 2^11 = 2048 */ -1 122 }; 105 123 106 124 /** The slab list chunk sizes. */ … … 114 132 512, 115 133 }; 134 116 135 /** Low memory slab lists, sizes given by g_acbBs3SlabLists. */ 117 136 BS3SLABHEAD BS3_DATA_NM(g_aBs3LowSlabLists)[BS3_MEM_SLAB_LIST_COUNT]; 118 137 /** Upper tiled memory slab lists, sizes given by g_acbBs3SlabLists. */ 119 138 BS3SLABHEAD BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[BS3_MEM_SLAB_LIST_COUNT]; 139 140 /** Slab control structure sizes for the slab lists. 141 * This is to help the allocator when growing a list. */ 142 uint16_t const BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[BS3_MEM_SLAB_LIST_COUNT] = 143 { 144 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 16 / 8 /*=32*/), 16), 145 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 32 / 8 /*=16*/), 32), 146 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 64 / 8 /*=8*/), 64), 147 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 128 / 8 /*=4*/), 128), 148 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 256 / 8 /*=2*/), 256), 149 RT_ALIGN(sizeof(BS3SLABCTL) - 4 + (4096 / 512 / 8 /*=1*/), 512), 150 }; 120 151 121 152 … … 141 172 * - 0xf0000 to 0xfffff - PC BIOS. 142 173 */ 143 Bs3SlabInit(&g_Bs3Mem4KLow.Core, sizeof(g_Bs3Mem4KLow), 0 /*uFlatSlabPtr*/, 0xA0000 /* 640 KB*/, _4K); 174 Bs3SlabInit(&BS3_DATA_NM(g_Bs3Mem4KLow).Core, sizeof(BS3_DATA_NM(g_Bs3Mem4KLow)), 175 0 /*uFlatSlabPtr*/, 0xA0000 /* 640 KB*/, _4K); 144 176 145 177 /* Mark the stacks and whole image as allocated. */ 146 178 cPages = (BS3_DATA_NM(Bs3TotalImageSize) + _4K - 1U) >> 12; 147 ASMBitSetRange( g_Bs3Mem4KLow.Core.bmAllocated, 0, 0x10 + cPages);179 ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0, 0x10 + cPages); 148 180 149 181 /* Mark any unused pages between BS3TEXT16 and BS3SYSTEM16 as free. */ 150 182 cPages = (BS3_DATA_NM(Bs3Text16_Size) + _4K - 1U) >> 12; 151 ASMBitClearRange( g_Bs3Mem4KLow.Core.bmAllocated, 0x10U + cPages, 0x20U);183 ASMBitClearRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0x10U + cPages, 0x20U); 152 184 153 185 /* In case the system has less than 640KB of memory, check the BDA variable for it. */ … … 156 188 { 157 189 cPages = 640 - cPages; 190 cPages = RT_ALIGN(cPages, 4); 158 191 cPages >>= 2; 159 ASMBitSetRange( g_Bs3Mem4KLow.Core.bmAllocated, 0xA0 - cPages, 0xA0);192 ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0xA0 - cPages, 0xA0); 160 193 } 161 194 else 162 ASMBitSet( g_Bs3Mem4KLow.Core.bmAllocated, 0x9F);195 ASMBitSet(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, 0x9F); 163 196 164 197 /* Recalc free pages. */ 165 198 cPages = 0; 166 i = g_Bs3Mem4KLow.Core.cChunks;199 i = BS3_DATA_NM(g_Bs3Mem4KLow).Core.cChunks; 167 200 while (i-- > 0) 168 cPages += ASMBitTest(g_Bs3Mem4KLow.Core.bmAllocated, i); 169 g_Bs3Mem4KLow.Core.cFreeChunks = cPages; 170 201 cPages += !ASMBitTest(BS3_DATA_NM(g_Bs3Mem4KLow).Core.bmAllocated, i); 202 BS3_DATA_NM(g_Bs3Mem4KLow).Core.cFreeChunks = cPages; 171 203 172 204 /* 173 205 * First 16 MB of memory above 1MB. We start out by marking it all allocated. 174 206 */ 175 Bs3SlabInit(&g_Bs3Mem4KUpperTiled.Core, sizeof(g_Bs3Mem4KUpperTiled), _1M, BS3_SEL_TILED_AREA_SIZE - _1M, _4K); 176 177 ASMBitSetRange(g_Bs3Mem4KUpperTiled.Core.bmAllocated, 0, g_Bs3Mem4KUpperTiled.Core.cChunks); 178 g_Bs3Mem4KUpperTiled.Core.cFreeChunks = 0; 207 Bs3SlabInit(&BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core, sizeof(BS3_DATA_NM(g_Bs3Mem4KUpperTiled)), 208 _1M, BS3_SEL_TILED_AREA_SIZE - _1M, _4K); 209 210 ASMBitSetRange(BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.bmAllocated, 0, BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cChunks); 211 BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cFreeChunks = 0; 179 212 180 213 /* Ask the BIOS about where there's memory, and make pages in between 1MB … … 235 268 while (cPages-- > 0) 236 269 { 237 g_Bs3Mem4KUpperTiled.Core.cFreeChunks += !ASMBitTestAndSet(g_Bs3Mem4KUpperTiled.Core.bmAllocated,238 i);270 uint16_t uLineToLong = ASMBitTestAndClear(g_Bs3Mem4KUpperTiled.Core.bmAllocated, i); 271 BS3_DATA_NM(g_Bs3Mem4KUpperTiled).Core.cFreeChunks += uLineToLong; 239 272 i++; 240 273 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-shutdown.c
r58785 r58789 11 11 BS3_DECL(void) Main_rm(void) 12 12 { 13 void BS3_FAR *pvTmp1; 14 void BS3_FAR *pvTmp2; 15 void BS3_FAR *pvTmp3; 16 void BS3_FAR *pvTmp4; 13 17 Bs3InitMemory_rm(); 14 18 15 19 Bs3TestInit("bs3-shutdown"); 20 21 Bs3PrintStr("Bs3PrintX32:"); 22 Bs3PrintX32(UINT32_C(0xfdb97531)); 23 Bs3PrintStr("\r\n"); 24 25 pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 26 Bs3PrintStr("pvTmp2="); 27 Bs3PrintX32((uintptr_t)pvTmp2); 28 Bs3PrintStr("\r\n"); 29 30 pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 31 Bs3PrintStr("pvTmp3="); 32 Bs3PrintX32((uintptr_t)pvTmp3); 33 Bs3PrintStr("\r\n"); 34 Bs3MemFree(pvTmp2, _4K); 35 36 pvTmp4 = Bs3MemAlloc(BS3MEMKIND_REAL, _4K); 37 Bs3PrintStr("pvTmp4="); 38 Bs3PrintX32((uintptr_t)pvTmp4); 39 Bs3PrintStr("\r\n"); 40 Bs3PrintStr("\r\n"); 41 42 pvTmp1 = Bs3MemAlloc(BS3MEMKIND_REAL, 31); 43 Bs3PrintStr("pvTmp1="); 44 Bs3PrintX32((uintptr_t)pvTmp1); 45 Bs3PrintStr("\r\n"); 46 47 pvTmp2 = Bs3MemAlloc(BS3MEMKIND_REAL, 17); 48 Bs3PrintStr("pvTmp2="); 49 Bs3PrintX32((uintptr_t)pvTmp2); 50 Bs3PrintStr("\r\n"); 51 52 Bs3MemFree(pvTmp1, 31); 53 pvTmp3 = Bs3MemAlloc(BS3MEMKIND_REAL, 17); 54 Bs3PrintStr("pvTmp3="); 55 Bs3PrintX32((uintptr_t)pvTmp3); 56 Bs3PrintStr("\r\n"); 57 16 58 17 59 Bs3Panic(); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r58785 r58789 599 599 * @{ */ 600 600 /** Start of the BS3TEXT16 segment. */ 601 extern uint8_t BS3_DATA_NM(Bs3Text16_StartOfSegment);601 extern uint8_t BS3_DATA_NM(Bs3Text16_StartOfSegment); 602 602 /** End of the BS3TEXT16 segment. */ 603 extern uint8_t BS3_DATA_NM(Bs3Text16_EndOfSegment);603 extern uint8_t BS3_DATA_NM(Bs3Text16_EndOfSegment); 604 604 /** The size of the BS3TEXT16 segment. */ 605 extern uint 8_t BS3_DATA_NM(Bs3Text16_Size);605 extern uint16_t BS3_DATA_NM(Bs3Text16_Size); 606 606 607 607 /** Start of the BS3SYSTEM16 segment. */ 608 extern uint8_t BS3_DATA_NM(Bs3System16_StartOfSegment);608 extern uint8_t BS3_DATA_NM(Bs3System16_StartOfSegment); 609 609 /** End of the BS3SYSTEM16 segment. */ 610 extern uint8_t BS3_DATA_NM(Bs3System16_EndOfSegment);610 extern uint8_t BS3_DATA_NM(Bs3System16_EndOfSegment); 611 611 612 612 /** Start of the BS3DATA16 segment. */ 613 extern uint8_t BS3_DATA_NM(Bs3Data16_StartOfSegment);613 extern uint8_t BS3_DATA_NM(Bs3Data16_StartOfSegment); 614 614 /** End of the BS3DATA16 segment. */ 615 extern uint8_t BS3_DATA_NM(Bs3Data16_EndOfSegment);615 extern uint8_t BS3_DATA_NM(Bs3Data16_EndOfSegment); 616 616 617 617 /** Start of the BS3TEXT32 segment. */ 618 extern uint8_t BS3_DATA_NM(Bs3Text32_StartOfSegment);618 extern uint8_t BS3_DATA_NM(Bs3Text32_StartOfSegment); 619 619 /** Start of the BS3TEXT32 segment. */ 620 extern uint8_t BS3_DATA_NM(Bs3Text32_EndOfSegment);620 extern uint8_t BS3_DATA_NM(Bs3Text32_EndOfSegment); 621 621 622 622 /** Start of the BS3DATA32 segment. */ 623 extern uint8_t BS3_DATA_NM(Bs3Data32_StartOfSegment);623 extern uint8_t BS3_DATA_NM(Bs3Data32_StartOfSegment); 624 624 /** Start of the BS3DATA32 segment. */ 625 extern uint8_t BS3_DATA_NM(Bs3Data32_EndOfSegment);625 extern uint8_t BS3_DATA_NM(Bs3Data32_EndOfSegment); 626 626 627 627 /** Start of the BS3TEXT64 segment. */ 628 extern uint8_t BS3_DATA_NM(Bs3Text64_StartOfSegment);628 extern uint8_t BS3_DATA_NM(Bs3Text64_StartOfSegment); 629 629 /** Start of the BS3TEXT64 segment. */ 630 extern uint8_t BS3_DATA_NM(Bs3Text64_EndOfSegment);630 extern uint8_t BS3_DATA_NM(Bs3Text64_EndOfSegment); 631 631 632 632 /** Start of the BS3DATA64 segment. */ 633 extern uint8_t BS3_DATA_NM(Bs3Data64_StartOfSegment);633 extern uint8_t BS3_DATA_NM(Bs3Data64_StartOfSegment); 634 634 /** Start of the BS3DATA64 segment. */ 635 extern uint8_t BS3_DATA_NM(Bs3Data64_EndOfSegment);635 extern uint8_t BS3_DATA_NM(Bs3Data64_EndOfSegment); 636 636 637 637 /** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */ 638 extern uint 8_t BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize);638 extern uint32_t BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize); 639 639 /** The total image size (from Text16 thu Data64). */ 640 extern uint 8_t BS3_DATA_NM(Bs3TotalImageSize);640 extern uint32_t BS3_DATA_NM(Bs3TotalImageSize); 641 641 /** @} */ 642 642 … … 845 845 } \ 846 846 else \ 847 (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ( BS3_FP_SEG(pTypeCheck) << 4); \847 (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \ 848 848 } while (0) 849 849 #elif ARCH_BITS == 32 … … 911 911 912 912 /** 913 * Prints a 32-bit unsigned value as hexto the screen.913 * Prints a 32-bit unsigned value as decimal to the screen. 914 914 * 915 915 * @param uValue The 32-bit value. … … 919 919 BS3_DECL(void) Bs3PrintU32_c64(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */ 920 920 #define Bs3PrintU32 BS3_CMN_NM(Bs3PrintU32) /**< Selects #Bs3PrintU32_c16, #Bs3PrintU32_c32 or #Bs3PrintU32_c64. */ 921 922 /** 923 * Prints a 32-bit unsigned value as hex to the screen. 924 * 925 * @param uValue The 32-bit value. 926 */ 927 BS3_DECL(void) Bs3PrintX32_c16(uint32_t uValue); 928 BS3_DECL(void) Bs3PrintX32_c32(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */ 929 BS3_DECL(void) Bs3PrintX32_c64(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */ 930 #define Bs3PrintX32 BS3_CMN_NM(Bs3PrintX32) /**< Selects #Bs3PrintX32_c16, #Bs3PrintX32_c32 or #Bs3PrintX32_c64. */ 921 931 922 932 /** … … 1084 1094 { 1085 1095 /** Pointer to the first slab. */ 1086 BS3_XPTR_MEMBER(struct BS3SLABC LT, pFirst);1096 BS3_XPTR_MEMBER(struct BS3SLABCTL, pFirst); 1087 1097 /** The allocation chunk size. */ 1088 1098 uint16_t cbChunk; … … 1103 1113 * static location for the larger ones. 1104 1114 */ 1105 typedef struct BS3SLABC LT1115 typedef struct BS3SLABCTL 1106 1116 { 1107 1117 /** Pointer to the next slab control structure in this list. */ 1108 BS3_XPTR_MEMBER(struct BS3SLABC LT, pNext);1118 BS3_XPTR_MEMBER(struct BS3SLABCTL, pNext); 1109 1119 /** Pointer to the slab list head. */ 1110 1120 BS3_XPTR_MEMBER(BS3SLABHEAD, pHead); … … 1123 1133 * multiple of 4). */ 1124 1134 uint8_t bmAllocated[4]; 1125 } BS3SLABC LT;1135 } BS3SLABCTL; 1126 1136 /** Pointer to a bs3kit slab control structure. */ 1127 typedef BS3SLABCLT BS3_FAR *PBS3SLABCLT; 1137 typedef BS3SLABCTL BS3_FAR *PBS3SLABCTL; 1138 1139 /** The chunks must all be in the same 16-bit segment tile. */ 1140 #define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001) 1128 1141 1129 1142 /** … … 1136 1149 * @param cbChunk The chunk size. 1137 1150 */ 1138 BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABC LTpSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);1151 BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk); 1139 1152 /** @copydoc Bs3SlabInit_c16 */ 1140 BS3_DECL(void) Bs3SlabInit_c32(PBS3SLABC LTpSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);1153 BS3_DECL(void) Bs3SlabInit_c32(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk); 1141 1154 /** @copydoc Bs3SlabInit_c16 */ 1142 BS3_DECL(void) Bs3SlabInit_c64(PBS3SLABC LTpSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);1155 BS3_DECL(void) Bs3SlabInit_c64(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk); 1143 1156 #define Bs3SlabInit BS3_CMN_NM(Bs3SlabInit) /**< Selects #Bs3SlabInit_c16, #Bs3SlabInit_c32 or #Bs3SlabInit_c64. */ 1157 1158 /** 1159 * Allocates one chunk from a slab. 1160 * 1161 * @returns Pointer to a chunk on success, NULL if we're out of chunks. 1162 * @param pSlabCtl The slab constrol structure to allocate from. 1163 */ 1164 BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c16(PBS3SLABCTL pSlabCtl); 1165 BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c32(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */ 1166 BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c64(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */ 1167 #define Bs3SlabAlloc BS3_CMN_NM(Bs3SlabAlloc) /**< Selects #Bs3SlabAlloc_c16, #Bs3SlabAlloc_c32 or #Bs3SlabAlloc_c64. */ 1168 1169 /** 1170 * Allocates one or more chunks rom a slab. 1171 * 1172 * @returns Pointer to the request number of chunks on success, NULL if we're 1173 * out of chunks. 1174 * @param pSlabCtl The slab constrol structure to allocate from. 1175 * @param cChunks The number of contiguous chunks we want. 1176 * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX 1177 */ 1178 BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c16(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); 1179 BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c32(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */ 1180 BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c64(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */ 1181 #define Bs3SlabAllocEx BS3_CMN_NM(Bs3SlabAllocEx) /**< Selects #Bs3SlabAllocEx_c16, #Bs3SlabAllocEx_c32 or #Bs3SlabAllocEx_c64. */ 1182 1183 /** 1184 * Frees one or more chunks from a slab. 1185 * 1186 * @returns Number of chunks actually freed. When correctly used, this will 1187 * match the @a cChunks parameter, of course. 1188 * @param pSlabCtl The slab constrol structure to free from. 1189 * @param uFlatChunkPtr The flat address of the chunks to free. 1190 * @param cChunks The number of contiguous chunks to free. 1191 */ 1192 BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); 1193 BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */ 1194 BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */ 1195 #define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */ 1144 1196 1145 1197 … … 1161 1213 * @param pSlabCtl The slab control structure to add. 1162 1214 */ 1163 BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABC LTpSlabCtl);1215 BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl); 1164 1216 /** @copydoc Bs3SlabListAdd_c16 */ 1165 BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABC LTpSlabCtl);1217 BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl); 1166 1218 /** @copydoc Bs3SlabListAdd_c16 */ 1167 BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABC LTpSlabCtl);1219 BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl); 1168 1220 #define Bs3SlabListAdd BS3_CMN_NM(Bs3SlabListAdd) /**< Selects #Bs3SlabListAdd_c16, #Bs3SlabListAdd_c32 or #Bs3SlabListAdd_c64. */ 1169 1221 … … 1192 1244 BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c64(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */ 1193 1245 #define Bs3SlabListAllocEx BS3_CMN_NM(Bs3SlabListAllocEx) /**< Selects #Bs3SlabListAllocEx_c16, #Bs3SlabListAllocEx_c32 or #Bs3SlabListAllocEx_c64. */ 1194 /** The chunks must all be in the same 16-bit segment tile. */1195 #define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001)1196 1197 /**1198 * Frees one or more chunks from a slab.1199 *1200 * @returns Number of chunks actually freed. When correctly used, this will1201 * match the @a cChunks parameter, of course.1202 * @param pSlabCtl The slab constrol structure to free from.1203 * @param uFlatChunkPtr The flat address of the chunks to free.1204 * @param cChunks The number of contiguous chunks to free.1205 */1206 BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks);1207 BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */1208 BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */1209 #define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */1210 1246 1211 1247 /**
Note:
See TracChangeset
for help on using the changeset viewer.