Sreelakshmi Gownipalli | cb8893d | 2016-10-19 16:02:34 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2008-2014, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef DIAGMEM_H |
| 14 | #define DIAGMEM_H |
| 15 | #include "diagchar.h" |
| 16 | |
| 17 | #define POOL_TYPE_COPY 0 |
| 18 | #define POOL_TYPE_HDLC 1 |
| 19 | #define POOL_TYPE_USER 2 |
| 20 | #define POOL_TYPE_MUX_APPS 3 |
| 21 | #define POOL_TYPE_DCI 4 |
| 22 | #define POOL_TYPE_LOCAL_LAST 5 |
| 23 | |
| 24 | #define POOL_TYPE_REMOTE_BASE POOL_TYPE_LOCAL_LAST |
| 25 | #define POOL_TYPE_MDM POOL_TYPE_REMOTE_BASE |
| 26 | #define POOL_TYPE_MDM2 (POOL_TYPE_REMOTE_BASE + 1) |
| 27 | #define POOL_TYPE_MDM_DCI (POOL_TYPE_REMOTE_BASE + 2) |
| 28 | #define POOL_TYPE_MDM2_DCI (POOL_TYPE_REMOTE_BASE + 3) |
| 29 | #define POOL_TYPE_MDM_MUX (POOL_TYPE_REMOTE_BASE + 4) |
| 30 | #define POOL_TYPE_MDM2_MUX (POOL_TYPE_REMOTE_BASE + 5) |
| 31 | #define POOL_TYPE_MDM_DCI_WRITE (POOL_TYPE_REMOTE_BASE + 6) |
| 32 | #define POOL_TYPE_MDM2_DCI_WRITE (POOL_TYPE_REMOTE_BASE + 7) |
| 33 | #define POOL_TYPE_QSC_MUX (POOL_TYPE_REMOTE_BASE + 8) |
| 34 | #define POOL_TYPE_REMOTE_LAST (POOL_TYPE_REMOTE_BASE + 9) |
| 35 | |
| 36 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
| 37 | #define NUM_MEMORY_POOLS POOL_TYPE_REMOTE_LAST |
| 38 | #else |
| 39 | #define NUM_MEMORY_POOLS POOL_TYPE_LOCAL_LAST |
| 40 | #endif |
| 41 | |
| 42 | #define DIAG_MEMPOOL_NAME_SZ 24 |
| 43 | #define DIAG_MEMPOOL_GET_NAME(x) (diag_mempools[x].name) |
| 44 | |
| 45 | struct diag_mempool_t { |
| 46 | int id; |
| 47 | char name[DIAG_MEMPOOL_NAME_SZ]; |
| 48 | mempool_t *pool; |
| 49 | unsigned int itemsize; |
| 50 | unsigned int poolsize; |
| 51 | int count; |
| 52 | spinlock_t lock; |
| 53 | } __packed; |
| 54 | |
| 55 | extern struct diag_mempool_t diag_mempools[NUM_MEMORY_POOLS]; |
| 56 | |
| 57 | void diagmem_setsize(int pool_idx, int itemsize, int poolsize); |
| 58 | void *diagmem_alloc(struct diagchar_dev *driver, int size, int pool_type); |
| 59 | void diagmem_free(struct diagchar_dev *driver, void *buf, int pool_type); |
| 60 | void diagmem_init(struct diagchar_dev *driver, int type); |
| 61 | void diagmem_exit(struct diagchar_dev *driver, int type); |
| 62 | |
| 63 | #endif |