1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Decription: mailbox memory managing for sharing memory with TEE. 4 * 5 * This software is licensed under the terms of the GNU General Public 6 * License version 2, as published by the Free Software Foundation, and 7 * may be copied, distributed, and modified under those terms. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 #ifndef MAILBOX_MEMPOOOL_H 15 #define MAILBOX_MEMPOOOL_H 16 17 #include <linux/kernel.h> 18 #include <linux/types.h> 19 #include "teek_ns_client.h" 20 21 #ifndef MAILBOX_POOL_SIZE 22 #define MAILBOX_POOL_SIZE SZ_4M 23 #endif 24 25 /* alloc options */ 26 #define MB_FLAG_ZERO 0x1 /* set 0 after alloc page */ 27 #define GLOBAL_UUID_LEN 17 /* first char represent global cmd */ 28 29 void *mailbox_alloc(size_t size, unsigned int flag); 30 void mailbox_free(const void *ptr); 31 int mailbox_mempool_init(void); 32 void free_mailbox_mempool(void); 33 struct mb_cmd_pack *mailbox_alloc_cmd_pack(void); 34 void *mailbox_copy_alloc(const void *src, size_t size); 35 int re_register_mailbox(void); 36 uintptr_t mailbox_virt_to_phys(uintptr_t addr); 37 38 #endif 39