1 /* 2 * Copyright (C) 2004-2010 NXP Software 3 * Copyright (C) 2010 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef __INSTALLOC_H__ 19 #define __INSTALLOC_H__ 20 21 #include "LVM_Types.h" 22 /*######################################################################################*/ 23 /* Type declarations */ 24 /*######################################################################################*/ 25 typedef struct 26 { 27 LVM_UINT32 TotalSize; /* Accumulative total memory size */ 28 uintptr_t pNextMember; /* Pointer to the next instance member to be allocated */ 29 } INST_ALLOC; 30 31 /*######################################################################################*/ 32 /* Function prototypes */ 33 /*######################################################################################*/ 34 35 /**************************************************************************************** 36 * Name : InstAlloc_Init() 37 * Input : pms - Pointer to the INST_ALLOC instance 38 StartAddr - Base address of the instance memory 39 * Returns : Error code 40 * Description : Initializes the instance distribution and memory size calculation function 41 * Remarks : 42 ****************************************************************************************/ 43 44 void InstAlloc_Init( INST_ALLOC *pms, void *StartAddr ); 45 46 /**************************************************************************************** 47 * Name : InstAlloc_AddMember() 48 * Input : pms - Pointer to the INST_ALLOC instance 49 Size - The size in bytes of the new added member 50 * Returns : A pointer to the new added member 51 * Description : Allocates space for a new member in the instance memory and returns 52 a pointer to this new member. The start address of all members will 53 be 32 bit alligned. 54 * Remarks : 55 ****************************************************************************************/ 56 57 void* InstAlloc_AddMember( INST_ALLOC *pms, LVM_UINT32 Size ); 58 59 /**************************************************************************************** 60 * Name : InstAlloc_GetTotal() 61 * Input : pms - Pointer to the INST_ALLOC instance 62 * Returns : The instance memory size 63 * Description : This functions returns the calculated instance memory size 64 * Remarks : 65 ****************************************************************************************/ 66 67 LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms); 68 69 void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms, 70 LVM_UINT32 Size[], 71 void **ptr); 72 73 void* InstAlloc_AddMemberAll( INST_ALLOC *pms, 74 LVM_UINT32 Size[], 75 LVM_MemoryTable_st *pMemoryTable); 76 77 void InstAlloc_InitAll( INST_ALLOC *pms, 78 LVM_MemoryTable_st *pMemoryTable); 79 80 void InstAlloc_InitAll_NULL( INST_ALLOC *pms); 81 82 #endif /* __JBS_INSTALLOC_H__ */ 83