• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 #include "LVM_Types.h"
26 /*######################################################################################*/
27 /*  Type declarations                                                                   */
28 /*######################################################################################*/
29 typedef struct
30 {
31     LVM_UINT32              TotalSize;      /*  Accumulative total memory size                      */
32     uintptr_t               pNextMember;    /*  Pointer to the next instance member to be allocated */
33 }   INST_ALLOC;
34 
35 
36 /*######################################################################################*/
37 /*  Function prototypes                                                          */
38 /*######################################################################################*/
39 
40 /****************************************************************************************
41  *  Name        : InstAlloc_Init()
42  *  Input       : pms  - Pointer to the INST_ALLOC instance
43                   StartAddr - Base address of the instance memory
44  *  Returns     : Error code
45  *  Description : Initializes the instance distribution and memory size calculation function
46  *  Remarks     :
47  ****************************************************************************************/
48 
49 void   InstAlloc_Init( INST_ALLOC *pms, void *StartAddr );
50 
51 
52 /****************************************************************************************
53  *  Name        : InstAlloc_AddMember()
54  *  Input       : pms  - Pointer to the INST_ALLOC instance
55                   Size - The size in bytes of the new added member
56  *  Returns     : A pointer to the new added member
57  *  Description : Allocates space for a new member in the instance memory and returns
58                   a pointer to this new member.  The start address of all members will
59                   be 32 bit alligned.
60  *  Remarks     :
61  ****************************************************************************************/
62 
63 void* InstAlloc_AddMember( INST_ALLOC *pms, LVM_UINT32 Size );
64 
65 /****************************************************************************************
66  *  Name        : InstAlloc_GetTotal()
67  *  Input       : pms  - Pointer to the INST_ALLOC instance
68  *  Returns     : The instance memory size
69  *  Description : This functions returns the calculated instance memory size
70  *  Remarks     :
71  ****************************************************************************************/
72 
73 LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms);
74 
75 void*   InstAlloc_AddMemberAllRet(     INST_ALLOC                 *pms,
76                                      LVM_UINT32               Size[],
77                                      void                    **ptr);
78 
79 void*   InstAlloc_AddMemberAll( INST_ALLOC                     *pms,
80                                  LVM_UINT32                   Size[],
81                                  LVM_MemoryTable_st           *pMemoryTable);
82 
83 void    InstAlloc_InitAll( INST_ALLOC                      *pms,
84                            LVM_MemoryTable_st             *pMemoryTable);
85 
86 void    InstAlloc_InitAll_NULL( INST_ALLOC              *pms);
87 
88 #ifdef __cplusplus
89 }
90 #endif /* __cplusplus */
91 
92 #endif /* __JBS_INSTALLOC_H__ */
93