lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /*******************************************************************************
|
| 2 | * Copyright (C) 2007, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name:hal_qalloc.h
|
| 5 | * File Mark:
|
| 6 | * Description:
|
| 7 | * Others:
|
| 8 | * Version: 1.0
|
| 9 | * Author: geanfeng
|
| 10 | * Date: 2013-09-25
|
| 11 | * History 1:
|
| 12 | * Date:
|
| 13 | * Version:
|
| 14 | * Author:
|
| 15 | * Modification:
|
| 16 | * History 2:
|
| 17 | ********************************************************************************/
|
| 18 |
|
| 19 | #ifndef _HAL_QALLOC_H
|
| 20 | #define _HAL_QALLOC_H
|
| 21 |
|
| 22 |
|
| 23 | /****************************************************************************
|
| 24 | * Include files
|
| 25 | ****************************************************************************/
|
| 26 | #include "drvs_general.h"
|
| 27 | #include "drvs_list.h"
|
| 28 | /****************************************************************************
|
| 29 | * Macros
|
| 30 | ****************************************************************************/
|
| 31 |
|
| 32 | /****************************************************************************
|
| 33 | * Types
|
| 34 | ****************************************************************************/
|
| 35 | /*
|
| 36 | * General purpose special memory pool descriptor.
|
| 37 | */
|
| 38 | typedef struct _T_Quick_Pool {
|
| 39 | struct list_head node; /* node*/
|
| 40 | struct list_head chunks; /* list of chunks in this pool */
|
| 41 | UINT32 count;
|
| 42 | UINT8* name;
|
| 43 | }T_Quick_Pool;
|
| 44 |
|
| 45 | /****************************************************************************
|
| 46 | * Constants
|
| 47 | ****************************************************************************/
|
| 48 |
|
| 49 | /****************************************************************************
|
| 50 | * Global Variables
|
| 51 | ****************************************************************************/
|
| 52 |
|
| 53 | /****************************************************************************
|
| 54 | * Function Prototypes
|
| 55 | ****************************************************************************/
|
| 56 |
|
| 57 | /**
|
| 58 | * QPool_Create - create a new special memory pool
|
| 59 | *
|
| 60 | * Create a new special memory pool that can be used to manage special purpose
|
| 61 | * memory not managed by the regular kmalloc/kfree interface.
|
| 62 | */
|
| 63 | T_Quick_Pool *QPool_Create(UINT8* name);
|
| 64 |
|
| 65 | /**
|
| 66 | * QPool_AddVirt - add a new chunk of special memory to the pool
|
| 67 | * @pool: pool to add new memory chunk to
|
| 68 | * @virt: virtual starting address of memory chunk to add to pool
|
| 69 | * @phys: physical starting address of memory chunk to add to pool
|
| 70 | * @size: size in bytes of the memory chunk to add to pool
|
| 71 | *
|
| 72 | * Add a new chunk of special memory to the specified pool.
|
| 73 | *
|
| 74 | * Returns 0 on success or a -ve errno on failure.
|
| 75 | */
|
| 76 | SINT32 QPool_AddVirt(T_Quick_Pool *pool,UINT32 virt, UINT32 size,
|
| 77 | UINT32 page_size, UINT32 max_alloc_order);
|
| 78 |
|
| 79 | /**
|
| 80 | * QPool_Alloc - allocate special memory from the pool
|
| 81 | * @pool: pool to allocate from
|
| 82 | * @size: number of bytes to allocate from the pool
|
| 83 | * @debug_info: some debug info
|
| 84 | *
|
| 85 | * Allocate the requested number of bytes from the specified pool.
|
| 86 | * Uses a first-fit algorithm.
|
| 87 | */
|
| 88 | UINT32 QPool_Alloc(T_Quick_Pool *pool, UINT32 size, VOID *debug_info);
|
| 89 |
|
| 90 | /**
|
| 91 | * QPool_Free - free allocated special memory back to the pool
|
| 92 | * @pool: pool to free to
|
| 93 | * @addr: starting address of memory to free back to pool
|
| 94 | * @size: size in bytes of memory to free
|
| 95 | *
|
| 96 | */
|
| 97 | VOID QPool_Free(T_Quick_Pool *pool, UINT32 addr, VOID *debug_info);
|
| 98 |
|
| 99 | /**
|
| 100 | * QPool_Destroy - destroy a special memory pool
|
| 101 | *
|
| 102 | * Destroy the specified special memory pool. Verifies that there are no
|
| 103 | * outstanding allocations.
|
| 104 | */
|
| 105 | VOID QPool_Destroy(T_Quick_Pool *pool);
|
| 106 |
|
| 107 | /**
|
| 108 | * gen_pool_avail - get available free space of the pool
|
| 109 | * @pool: pool to get available free space
|
| 110 | *
|
| 111 | * Return available free space of the specified pool.
|
| 112 | */
|
| 113 | UINT32 QPool_Avail(T_Quick_Pool *pool);
|
| 114 |
|
| 115 | /**
|
| 116 | * QPool_Size - get size in bytes of memory managed by the pool
|
| 117 | * @pool: pool to get size
|
| 118 | *
|
| 119 | * Return size in bytes of memory managed by the pool.
|
| 120 | */
|
| 121 | UINT32 QPool_Size(T_Quick_Pool *pool);
|
| 122 |
|
| 123 | /**
|
| 124 | * QPool_Print - print the pool debug info.
|
| 125 | * @pool: pool to print
|
| 126 | *
|
| 127 | */
|
| 128 | VOID QPool_Print(T_Quick_Pool *pool);
|
| 129 |
|
| 130 | /**
|
| 131 | * QPool_PrintAll - print the all pool debug info.
|
| 132 | *
|
| 133 | */
|
| 134 | VOID QPool_PrintAll(VOID);
|
| 135 |
|
| 136 | #endif/*_HAL_TCLK_REG_H*/
|
| 137 |
|