Initial commit
[o-du/l2.git] / src / cm / cm_mblk.x
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
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 \f
19 /********************************************************************20**
20   
21      Name:     common memory allocation library 
22   
23      Type:     C include file
24   
25      Desc:     Structures, variables and typedefs required by the
26                memory library routines 
27  
28      File:     cm_mblk.x
29  
30 *********************************************************************21*/
31   
32 #ifndef __CMMBLKX__
33 #define __CMMBLKX__
34
35 #ifdef __cplusplus
36 EXTERN "C" {
37 #endif
38
39 /************************************************
40  Memory Management Control Block 
41 ************************************************/
42
43 typedef struct cmMemCb
44 {
45    Size      maxSize;      /* Size of memory chunk */ 
46    Mem       sMem;         /* Static memory region and pool */ 
47    U32       memAllocated; /* amount of memory already allocated */
48    PTR       initPtr;      /* Initial pointer */
49    PTR       runPtr;       /* Start of avaliable memory chunk */ 
50 } CmMemCb;
51
52 /************************************************
53  Memory Link List Node Structure
54 ************************************************/
55 typedef struct  cmMemList CmMemList;
56
57 struct cmMemList
58 {
59    CmMemList *next;        /* next */
60    CmMemList *prev;        /* previous */
61    /* cm_mblk_x_001.101: added new element "size" */
62    Size       size;        /* block size */
63 };
64
65 /************************************************
66  Memory Link List Control Point 
67 ************************************************/
68
69 typedef struct cmMemListCp
70 {
71    CmMemList *first;       /* first entry in list */
72    CmMemList *last;        /* last entry in list */
73    U32       count;        /* number of entries */
74    CmMemCb   memCb;        /* Memory Control Block */
75 }CmMemListCp;
76
77 /***********************************************
78  Memory Status structure 
79 ***********************************************/
80 typedef struct cmMemStatus
81 {
82    Mem       sMem;          /* Static Memory region,pool */
83    U32       memBlkCnt;     /* Memory Blocks Count */ 
84    Size      maxBlkSize;    /* Size of memory Block */
85    Size      memAllocated;  /* Memory allocated off chunk */
86 } CmMemStatus;
87
88
89 /***********************************************
90  Extern Declarations
91 ***********************************************/
92
93 #ifdef TFU_ALLOC_EVENT_NO_INIT
94 EXTERN  S16 cmAllocEvntNoInit ARGS((
95                                    Size evntSize,
96                                    Size maxBlkSize,
97                                    Mem  *sMem, 
98                                    Ptr  *ptr));
99 #endif
100 #ifdef TFU_ALLOC_EVENT_NO_INIT
101 EXTERN  S16 cmGetMemNoInit ARGS((
102                                Ptr  memPtr,
103                                Size size, 
104                                Ptr  *allocPtr));
105 #endif
106 EXTERN  S16 cmAllocEvnt ARGS((
107                                    Size evntSize,
108                                    Size maxBlkSize,
109                                    Mem  *sMem, 
110                                    Ptr  *ptr));
111
112 EXTERN  Void cmInitMemCp ARGS((
113                                    CmMemListCp *memCp,
114                                    Size  maxBlkSize,
115                                    Mem   *sMem )); 
116
117 #ifdef TFU_ALLOC_EVENT_NO_INIT
118 EXTERN  S16 cmGetMemNoInit ARGS((
119                                Ptr  memPtr,
120                                Size size, 
121                                Ptr  *allocPtr));
122 #endif
123 EXTERN  S16 cmGetMem ARGS((
124                                Ptr  memPtr,
125                                Size size, 
126                                Ptr  *allocPtr));
127
128 EXTERN  Void cmFreeMem ARGS((
129                                 Ptr memPtr));
130
131 EXTERN  Void cmGetMemStatus ARGS((
132                                   Ptr         memPtr,
133                                   CmMemStatus *status));
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif /* __CMMBLKX__ */
140
141 \f 
142 /********************************************************************30**
143   
144          End of file
145 **********************************************************************/