10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2768Ssl108498 * Common Development and Distribution License (the "License"). 6*2768Ssl108498 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2768Ssl108498 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_SHM_IMPL_H 270Sstevel@tonic-gate #define _SYS_SHM_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/ipc_impl.h> 320Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 330Sstevel@tonic-gate #include <sys/shm.h> 340Sstevel@tonic-gate #include <sys/avl.h> 350Sstevel@tonic-gate #include <sys/t_lock.h> 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * shmsys system call subcodes 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate #define SHMAT 0 460Sstevel@tonic-gate #define SHMCTL 1 470Sstevel@tonic-gate #define SHMDT 2 480Sstevel@tonic-gate #define SHMGET 3 490Sstevel@tonic-gate #define SHMIDS 4 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * There is a shared mem id data structure (shmid_ds) for each 530Sstevel@tonic-gate * segment in the system. 540Sstevel@tonic-gate */ 550Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 560Sstevel@tonic-gate typedef struct kshmid { 570Sstevel@tonic-gate kipc_perm_t shm_perm; /* operation permission struct */ 580Sstevel@tonic-gate size_t shm_segsz; /* size of segment in bytes */ 590Sstevel@tonic-gate struct anon_map *shm_amp; /* segment anon_map pointer */ 600Sstevel@tonic-gate ushort_t shm_lkcnt; /* number of times it is being locked */ 61*2768Ssl108498 pgcnt_t shm_lkpages; /* number of pages locked by shmctl */ 62*2768Ssl108498 kmutex_t shm_mlock; /* held when locking physical pages */ 63*2768Ssl108498 /* Therefore, protects p_lckcnt for */ 64*2768Ssl108498 /* pages that back shm */ 650Sstevel@tonic-gate pid_t shm_lpid; /* pid of last shmop */ 660Sstevel@tonic-gate pid_t shm_cpid; /* pid of creator */ 670Sstevel@tonic-gate ulong_t shm_ismattch; /* number of ISM attaches */ 680Sstevel@tonic-gate time_t shm_atime; /* last shmat time */ 690Sstevel@tonic-gate time_t shm_dtime; /* last shmdt time */ 700Sstevel@tonic-gate time_t shm_ctime; /* last change time */ 710Sstevel@tonic-gate struct sptinfo *shm_sptinfo; /* info about ISM segment */ 720Sstevel@tonic-gate struct seg *shm_sptseg; /* pointer to ISM segment */ 730Sstevel@tonic-gate long shm_sptprot; /* was reserved (still a "long") */ 740Sstevel@tonic-gate } kshmid_t; 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * Segacct Flags. 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate #define SHMSA_ISM 1 /* uses shared page table */ 800Sstevel@tonic-gate 810Sstevel@tonic-gate typedef struct sptinfo { 820Sstevel@tonic-gate struct as *sptas; /* dummy as ptr. for spt segment */ 830Sstevel@tonic-gate } sptinfo_t; 840Sstevel@tonic-gate 850Sstevel@tonic-gate /* 860Sstevel@tonic-gate * Protected by p->p_lock 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate typedef struct segacct { 890Sstevel@tonic-gate avl_node_t sa_tree; 900Sstevel@tonic-gate caddr_t sa_addr; 910Sstevel@tonic-gate size_t sa_len; 920Sstevel@tonic-gate ulong_t sa_flags; 930Sstevel@tonic-gate kshmid_t *sa_id; 940Sstevel@tonic-gate } segacct_t; 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * Error codes for shmgetid(). 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate #define SHMID_NONE (-1) 1000Sstevel@tonic-gate #define SHMID_FREE (-2) 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate extern void shminit(void); 1030Sstevel@tonic-gate extern void shmfork(struct proc *, struct proc *); 1040Sstevel@tonic-gate extern void shmexit(struct proc *); 1050Sstevel@tonic-gate extern int shmgetid(struct proc *, caddr_t); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #endif /* _KERNEL */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate #if defined(_SYSCALL32) 1100Sstevel@tonic-gate /* 1110Sstevel@tonic-gate * LP64 view of the ILP32 shmid_ds structure 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate struct shmid_ds32 { 1140Sstevel@tonic-gate struct ipc_perm32 shm_perm; /* operation permission struct */ 1150Sstevel@tonic-gate size32_t shm_segsz; /* size of segment in bytes */ 1160Sstevel@tonic-gate caddr32_t shm_amp; /* segment anon_map pointer */ 1170Sstevel@tonic-gate uint16_t shm_lkcnt; /* number of times it is being locked */ 1180Sstevel@tonic-gate pid32_t shm_lpid; /* pid of last shmop */ 1190Sstevel@tonic-gate pid32_t shm_cpid; /* pid of creator */ 1200Sstevel@tonic-gate uint32_t shm_nattch; /* number of attaches */ 1210Sstevel@tonic-gate uint32_t shm_cnattch; /* number of ISM attaches */ 1220Sstevel@tonic-gate time32_t shm_atime; /* last shmat time */ 1230Sstevel@tonic-gate int32_t shm_pad1; /* reserved for time_t expansion */ 1240Sstevel@tonic-gate time32_t shm_dtime; /* last shmdt time */ 1250Sstevel@tonic-gate int32_t shm_pad2; /* reserved for time_t expansion */ 1260Sstevel@tonic-gate time32_t shm_ctime; /* last change time */ 1270Sstevel@tonic-gate int32_t shm_pad3; /* reserved for time_t expansion */ 1280Sstevel@tonic-gate int32_t shm_pad4[4]; /* reserve area */ 1290Sstevel@tonic-gate }; 1300Sstevel@tonic-gate #endif 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #ifdef __cplusplus 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate #endif 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #endif /* _SYS_SHM_IMPL_H */ 137