1 /******************************************************************************
3 * Copyright (c) 2021 Intel.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 *******************************************************************************/
23 #include <linux/mutex.h>
31 unsigned char* StoragePtr; // The pointer to the storage where blocks are located
32 unsigned int BlockNum; // The number of blocks in storage
33 unsigned int BlockSize; // The size of block in bytes
35 unsigned long long* FreePtr; // The pointer to the storage with free object indexes
36 volatile unsigned long long FreePut; // PUT index used to put the new item to 'free' storage
37 volatile unsigned long long FreeGet; // GET index used to get the new free item from 'free' storage
39 unsigned long long* UsedPtr; // The pointer to the storage with 'Used' object indexes
40 volatile unsigned long long UsedPut; // PUT index used to put the new item to 'already used' storage
41 volatile unsigned long long UsedGet; // GET index used to get the item from 'already used' storage
50 unsigned int PoolInit (PPOOL pPool, void * pStorage, unsigned int nBlockNum, unsigned int nBlockSize, unsigned long long* pFreePtr, unsigned long long* pUsedPtr);
51 void* PoolAlloc(PPOOL pPool);
52 unsigned int PoolFree(PPOOL pPool, void * pBlock);
53 unsigned int PoolGetFreeNum(PPOOL pPool);
54 unsigned int PoolGetAllocNum(PPOOL pPool);