mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-10-26 23:00:47 +00:00
To reduce type conversion in HV:
Update return type of function ffs64 and ffz64 as uint16;
For ffs64, when the input is zero, INVALID_BIT_INDEX is returned;
Update temporary variable type and return value check of caller
when it call ffs64 or ffz64;
Note: In the allocate_mem, there is no return value checking for
calling ffz64, this will be updated latter.
V1-->V2:
INVALID_BIT_INDEX instead of INVALID_NUMBER
Coding style fixing;
INVALID_CPU_ID instead of INVALID_PCPU_ID or INVALID_VCPU_ID;
"%hu" is used to print vcpu id (uint16_t);
Add "U/UL" for constant value as needed.
V2-->V3:
ffs64 return INVALID_BIT_INDEX directly when
the input value is zero;
Remove excess "%hu" updates.
V3-->V4:
Clean up the comments of ffs64;
Add "U" for constant value as needed.
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
32 lines
958 B
C
32 lines
958 B
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef __MEM_MGT_H__
|
|
#define __MEM_MGT_H__
|
|
|
|
/* Macros */
|
|
#define BITMAP_WORD_SIZE 32U
|
|
|
|
struct mem_pool {
|
|
void *start_addr; /* Start Address of Memory Pool */
|
|
spinlock_t spinlock; /* To protect Memory Allocation */
|
|
uint32_t size; /* Size of Memory Pool in Bytes */
|
|
uint32_t buff_size; /* Size of one Buffer in Bytes */
|
|
uint32_t total_buffs; /* Total Buffers in Memory Pool */
|
|
uint32_t bmp_size; /* Size of Bitmap Array */
|
|
uint32_t *bitmap; /* Pointer to allocation bitmap */
|
|
uint32_t *contiguity_bitmap; /* Pointer to contiguity bitmap */
|
|
};
|
|
|
|
/* APIs exposing memory allocation/deallocation abstractions */
|
|
void *malloc(unsigned int num_bytes);
|
|
void *calloc(unsigned int num_elements, unsigned int element_size);
|
|
void *alloc_page(void);
|
|
void *alloc_pages(unsigned int page_num);
|
|
void free(void *ptr);
|
|
|
|
#endif /* MEM_MGT_H_ */
|