1d6aed566Sopenharmony_ci/* 2d6aed566Sopenharmony_ci * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3d6aed566Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4d6aed566Sopenharmony_ci * 5d6aed566Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 6d6aed566Sopenharmony_ci * are permitted provided that the following conditions are met: 7d6aed566Sopenharmony_ci * 8d6aed566Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 9d6aed566Sopenharmony_ci * conditions and the following disclaimer. 10d6aed566Sopenharmony_ci * 11d6aed566Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12d6aed566Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 13d6aed566Sopenharmony_ci * provided with the distribution. 14d6aed566Sopenharmony_ci * 15d6aed566Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16d6aed566Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 17d6aed566Sopenharmony_ci * permission. 18d6aed566Sopenharmony_ci * 19d6aed566Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20d6aed566Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21d6aed566Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22d6aed566Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23d6aed566Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24d6aed566Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25d6aed566Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26d6aed566Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27d6aed566Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28d6aed566Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29d6aed566Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30d6aed566Sopenharmony_ci */ 31d6aed566Sopenharmony_ci 32d6aed566Sopenharmony_ci#ifndef __MMZ_H__ 33d6aed566Sopenharmony_ci#define __MMZ_H__ 34d6aed566Sopenharmony_ci 35d6aed566Sopenharmony_ci#include "los_typedef.h" 36d6aed566Sopenharmony_ci#include "sys/ioctl.h" 37d6aed566Sopenharmony_ci 38d6aed566Sopenharmony_citypedef enum { 39d6aed566Sopenharmony_ci MMZ_CACHE = 1, /* allocate mmz with cache attribute */ 40d6aed566Sopenharmony_ci MMZ_NOCACHE, /* allocate mmz with nocache attribute */ 41d6aed566Sopenharmony_ci MMZ_FREE, /* free mmz */ 42d6aed566Sopenharmony_ci MAP_CACHE, 43d6aed566Sopenharmony_ci MAP_NOCACHE, 44d6aed566Sopenharmony_ci UNMAP, 45d6aed566Sopenharmony_ci FLUSH_CACHE, 46d6aed566Sopenharmony_ci FLUSH_NOCACHE, 47d6aed566Sopenharmony_ci INVALIDATE, 48d6aed566Sopenharmony_ci MMZ_MAX 49d6aed566Sopenharmony_ci} MMZ_TYPE; 50d6aed566Sopenharmony_ci 51d6aed566Sopenharmony_citypedef struct { 52d6aed566Sopenharmony_ci void *vaddr; 53d6aed566Sopenharmony_ci uint64_t paddr; 54d6aed566Sopenharmony_ci int32_t size; 55d6aed566Sopenharmony_ci} MmzMemory; 56d6aed566Sopenharmony_ci 57d6aed566Sopenharmony_ci#define MMZ_IOC_MAGIC 'M' 58d6aed566Sopenharmony_ci#define MMZ_CACHE_TYPE _IOR(MMZ_IOC_MAGIC, MMZ_CACHE, MmzMemory) 59d6aed566Sopenharmony_ci#define MMZ_NOCACHE_TYPE _IOR(MMZ_IOC_MAGIC, MMZ_NOCACHE, MmzMemory) 60d6aed566Sopenharmony_ci#define MMZ_FREE_TYPE _IOR(MMZ_IOC_MAGIC, MMZ_FREE, MmzMemory) 61d6aed566Sopenharmony_ci#define MMZ_MAP_CACHE_TYPE _IOR(MMZ_IOC_MAGIC, MAP_CACHE, MmzMemory) 62d6aed566Sopenharmony_ci#define MMZ_MAP_NOCACHE_TYPE _IOR(MMZ_IOC_MAGIC, MAP_NOCACHE, MmzMemory) 63d6aed566Sopenharmony_ci#define MMZ_UNMAP_TYPE _IOR(MMZ_IOC_MAGIC, UNMAP, MmzMemory) 64d6aed566Sopenharmony_ci#define MMZ_FLUSH_CACHE_TYPE _IOR(MMZ_IOC_MAGIC, FLUSH_CACHE, MmzMemory) 65d6aed566Sopenharmony_ci#define MMZ_FLUSH_NOCACHE_TYPE _IOR(MMZ_IOC_MAGIC, FLUSH_NOCACHE, MmzMemory) 66d6aed566Sopenharmony_ci#define MMZ_INVALIDATE_TYPE _IOR(MMZ_IOC_MAGIC, INVALIDATE, MmzMemory) 67d6aed566Sopenharmony_ci 68d6aed566Sopenharmony_ci#define MMZ_NODE "/dev/mmz" 69d6aed566Sopenharmony_ci 70d6aed566Sopenharmony_ciint DevMmzRegister(void); 71d6aed566Sopenharmony_ci 72d6aed566Sopenharmony_ci#endif 73