Changeset 58777 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Nov 19, 2015 5:20:00 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r58761 r58777 136 136 define TOOL_Bs3Vcc64_COMPILE_C_CMDS 137 137 $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_CMDS) 138 -$(VBoxBs3ObjConverter_1_TARGET) "$(obj)"138 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 139 139 endef 140 140 … … 375 375 bs3-cmn-MemZero.asm \ 376 376 bs3-cmn-SlabInit.c \ 377 bs3-cmn-SlabFree.c \ 377 378 bs3-cmn-SlabListInit.c \ 378 379 bs3-cmn-SlabListAdd.c \ 379 380 bs3-cmn-SlabListAlloc.c \ 381 bs3-cmn-SlabListAllocEx.c \ 382 bs3-cmn-SlabListFree.c \ 380 383 bs3-cmn-TestData.c \ 381 384 bs3-cmn-TestInit.c \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c
r58720 r58777 1 1 /* $Id$ */ 2 2 /** @file 3 * BS3Kit - Bs3Slab ListAdd3 * BS3Kit - Bs3SlabInit 4 4 */ 5 5 … … 31 31 BS3_DECL(void) Bs3SlabInit(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk) 32 32 { 33 uint16_t cBits; 33 34 BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk)); 34 35 BS3_ASSERT(cbSlab >= cbChunk * 4); … … 39 40 BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pbStart, uFlatSlabPtr); 40 41 pSlabCtl->cbChunk = cbChunk; 41 pSlabCtl->cChunks = cbSlab / cbChunk; 42 pSlabCtl->cChunkShift = ASMBitFirstSetU16(cbChunk) - 1; 43 pSlabCtl->cChunks = cbSlab >> pSlabCtl->cChunkShift; 42 44 pSlabCtl->cFreeChunks = pSlabCtl->cChunks; 43 pSlabCtl->cBits= RT_ALIGN_T(pSlabCtl->cChunks, 32, uint16_t);44 BS3_ASSERT(cbSlabCtl >= RT_OFFSETOF(BS3SLABCTL, bmAllocated[ pSlabCtl->cBits >> 3]));45 Bs3MemZero(&pSlabCtl->bmAllocated, pSlabCtl->cBits >> 3);45 cBits = RT_ALIGN_T(pSlabCtl->cChunks, 32, uint16_t); 46 BS3_ASSERT(cbSlabCtl >= RT_OFFSETOF(BS3SLABCTL, bmAllocated[cBits >> 3])); 47 Bs3MemZero(&pSlabCtl->bmAllocated, cBits >> 3); 46 48 47 49 /* Mark excess bitmap padding bits as allocated. */ 48 if ( pSlabCtl->cBits != pSlabCtl->cChunks)50 if (cBits != pSlabCtl->cChunks) 49 51 { 50 52 uint16_t iBit; 51 for (iBit = pSlabCtl->cChunks; iBit < pSlabCtl->cBits; iBit++)53 for (iBit = pSlabCtl->cChunks; iBit < cBits; iBit++) 52 54 ASMBitSet(pSlabCtl->bmAllocated, iBit); 53 55 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabListAlloc.c
r58720 r58777 26 26 27 27 #include "bs3kit-template-header.h" 28 #include <iprt/asm.h> 28 29 29 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc(PBS3SLABHEAD pHead, uint16_t cChunks) 30 31 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc(PBS3SLABHEAD pHead) 30 32 { 31 if (pHead->cFreeChunks >= cChunks)33 if (pHead->cFreeChunks) 32 34 { 33 35 PBS3SLABCLT pCur; … … 36 38 pCur = BS3_XPTR_GET(BS3SLABCLT, pCur->pNext)) 37 39 { 38 if (pCur->cFreeChunks >= cChunks)40 if (pCur->cFreeChunks) 39 41 { 40 int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->c Bits);41 if (iBit >= )42 int32_t iBit = ASMBitFirstClear(&pCur->bmAllocated, pCur->cChunks); 43 if (iBit >= 0) 42 44 { 45 BS3_XPTR_AUTO(void, pvRet); 46 ASMBitSet(&pCur->bmAllocated, iBit); 47 pCur->cFreeChunks -= 1; 48 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); 43 53 } 44 54 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r58765 r58777 683 683 #endif 684 684 685 /** @def BS3_XPTR_DEF_MEMB 685 /** @def BS3_XPTR_DEF_MEMBER 686 686 * Defines a pointer member that can be shared by all CPU modes. 687 687 * … … 690 690 */ 691 691 #define BS3_XPTR_MEMBER(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name) 692 693 /** @def BS3_XPTR_DEF_AUTO 694 * Defines a pointer static variable for working with an XPTR. 695 * 696 * This is typically used to convert flat pointers into context specific 697 * pointers. 698 * 699 * @param a_Type The type we're pointing to. 700 * @param a_Name The member or variable name. 701 */ 702 #define BS3_XPTR_AUTO(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name) 692 703 693 704 /** @def BS3_XPTR_SET … … 706 717 * Gets the flat address of a cross context pointer. 707 718 * 719 * @returns 32-bit flat pointer. 708 720 * @param a_Type The type we're pointing to. 709 721 * @param a_Name The member or variable name. 710 722 */ 711 723 #define BS3_XPTR_GET_FLAT(a_Type, a_Name) (a_Name.XPtr.uFlat) 724 725 /** @def BS3_XPTR_GET_FLAT_LOW 726 * Gets the low 16 bits of the flat address. 727 * 728 * @returns Low 16 bits of the flat pointer. 729 * @param a_Type The type we're pointing to. 730 * @param a_Name The member or variable name. 731 */ 732 #define BS3_XPTR_GET_FLAT_LOW(a_Type, a_Name) (a_Name.XPtr.u.uLow) 712 733 713 734 … … 815 836 */ 816 837 817 #define BS3_ASSERT(a_Expr) do { } while (0) /**< @todo later */ 838 #define BS3_STRICT /**< @todo later */ 839 #ifdef BS3_STRICT 840 # define BS3_ASSERT(a_Expr) do { } while (0) /**< @todo later */ 841 #else 842 # define BS3_ASSERT(a_Expr) do { } while (0) /**< @todo later */ 843 #endif 818 844 819 845 /** … … 1045 1071 /** The chunk size. */ 1046 1072 uint16_t cbChunk; 1047 /** Number of bits in the bitmap (cChunks rounded up to 32). */ 1048 uint16_t cBits; 1073 /** The shift count corresponding to cbChunk. 1074 * This is for turning a chunk number into a byte offset and vice versa. */ 1075 uint16_t cChunkShift; 1049 1076 /** Bitmap where set bits indicates allocated blocks (variable size, 1050 1077 * multiple of 4). */ … … 1096 1123 1097 1124 /** 1098 * Allocates one or more chunks.1125 * Allocates one chunk. 1099 1126 * 1100 1127 * @returns Pointer to a chunk on success, NULL if we're out of chunks. 1101 1128 * @param pHead The slab list to allocate from. 1129 */ 1130 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c16(PBS3SLABHEAD pHead); 1131 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c32(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */ 1132 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c64(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */ 1133 #define Bs3SlabListAlloc BS3_CMN_NM(Bs3SlabListAlloc) /**< Selects #Bs3SlabListAlloc_c16, #Bs3SlabListAlloc_c32 or #Bs3SlabListAlloc_c64. */ 1134 1135 /** 1136 * Allocates one or more chunks. 1137 * 1138 * @returns Pointer to the request number of chunks on success, NULL if we're 1139 * out of chunks. 1140 * @param pHead The slab list to allocate from. 1102 1141 * @param cChunks The number of contiguous chunks we want. 1103 */ 1104 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c16(PBS3SLABHEAD pHead, uint16_t cChunks); 1105 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c32(PBS3SLABHEAD pHead, uint16_t cChunks); /**< @copydoc Bs3SlabListAlloc_c16 */ 1106 BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c64(PBS3SLABHEAD pHead, uint16_t cChunks); /**< @copydoc Bs3SlabListAlloc_c16 */ 1107 #define Bs3SlabListAlloc BS3_CMN_NM(Bs3SlabListAlloc) /**< Selects #Bs3SlabListAlloc_c16, #Bs3SlabListAlloc_c32 or #Bs3SlabListAlloc_c64. */ 1108 1109 /** 1110 * Frees one or more chunks. 1142 * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX 1143 */ 1144 BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c16(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); 1145 BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c32(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */ 1146 BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c64(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */ 1147 #define Bs3SlabListAllocEx BS3_CMN_NM(Bs3SlabListAllocEx) /**< Selects #Bs3SlabListAllocEx_c16, #Bs3SlabListAllocEx_c32 or #Bs3SlabListAllocEx_c64. */ 1148 /** The chunks must all be in the same 16-bit segment tile. */ 1149 #define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001) 1150 1151 /** 1152 * Frees one or more chunks from a slab. 1153 * 1154 * @returns Number of chunks actually freed. When correctly used, this will 1155 * match the @a cChunks parameter, of course. 1156 * @param pSlabCtl The slab constrol structure to free from. 1157 * @param uFlatChunkPtr The flat address of the chunks to free. 1158 * @param cChunks The number of contiguous chunks to free. 1159 */ 1160 BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); 1161 BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */ 1162 BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCLT pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */ 1163 #define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */ 1164 1165 /** 1166 * Frees one or more chunks from a slab list. 1111 1167 * 1112 1168 * @param pHead The slab list to allocate from. 1113 1169 * @param pvChunks Pointer to the first chunk to free. 1114 * @param cChunks The number of contiguous chunks we want.1170 * @param cChunks The number of contiguous chunks to free. 1115 1171 */ 1116 1172 BS3_DECL(void) Bs3SlabListFree_c16(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks);
Note:
See TracChangeset
for help on using the changeset viewer.