1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef _LOS_IPC_CONTAINER_PRI_H 31 #define _LOS_IPC_CONTAINER_PRI_H 32 33 #include "los_atomic.h" 34 #include "los_list.h" 35 #include "mqueue.h" 36 #include "fs/file.h" 37 38 #ifdef LOSCFG_IPC_CONTAINER 39 struct shmIDSource; 40 struct Container; 41 typedef struct TagQueueCB LosQueueCB; 42 typedef struct OsMux LosMux; 43 typedef LosMux pthread_mutex_t; 44 typedef struct ProcessCB LosProcessCB; 45 46 typedef struct IpcContainer { 47 Atomic rc; 48 LosQueueCB *allQueue; 49 LOS_DL_LIST freeQueueList; 50 fd_set queueFdSet; 51 struct mqarray queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT]; 52 pthread_mutex_t mqueueMutex; 53 struct mqpersonal *mqPrivBuf[MAX_MQ_FD]; 54 struct shminfo shmInfo; 55 LosMux sysvShmMux; 56 struct shmIDSource *shmSegs; 57 UINT32 shmUsedPageCount; 58 UINT32 containerID; 59 } IpcContainer; 60 61 UINT32 OsInitRootIpcContainer(IpcContainer **ipcContainer); 62 63 UINT32 OsCopyIpcContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent); 64 65 UINT32 OsUnshareIpcContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer); 66 67 UINT32 OsSetNsIpcContainer(UINT32 flags, struct Container *container, struct Container *newContainer); 68 69 VOID OsIpcContainerDestroy(struct Container *container); 70 71 UINT32 OsGetIpcContainerID(IpcContainer *ipcContainer); 72 73 IpcContainer *OsGetCurrIpcContainer(VOID); 74 75 UINT32 OsGetIpcContainerCount(VOID); 76 77 #define IPC_ALL_QUEUE (OsGetCurrIpcContainer()->allQueue) 78 79 #define FREE_QUEUE_LIST (OsGetCurrIpcContainer()->freeQueueList) 80 81 #define IPC_QUEUE_FD_SET (OsGetCurrIpcContainer()->queueFdSet) 82 83 #define IPC_QUEUE_TABLE (OsGetCurrIpcContainer()->queueTable) 84 85 #define IPC_QUEUE_MUTEX (OsGetCurrIpcContainer()->mqueueMutex) 86 87 #define IPC_QUEUE_MQ_PRIV_BUF (OsGetCurrIpcContainer()->mqPrivBuf) 88 89 #define IPC_SHM_INFO (OsGetCurrIpcContainer()->shmInfo) 90 91 #define IPC_SHM_SYS_VSHM_MUTEX (OsGetCurrIpcContainer()->sysvShmMux) 92 93 #define IPC_SHM_SEGS (OsGetCurrIpcContainer()->shmSegs) 94 95 #define IPC_SHM_USED_PAGE_COUNT (OsGetCurrIpcContainer()->shmUsedPageCount) 96 97 #endif 98 #endif /* _LOS_IPC_CONTAINER_PRI_H */ 99