17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*c6939658Ssl108498 * Common Development and Distribution License (the "License"). 6*c6939658Ssl108498 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*c6939658Ssl108498 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_SHM_IMPL_H 277c478bd9Sstevel@tonic-gate #define _SYS_SHM_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/ipc_impl.h> 327c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 337c478bd9Sstevel@tonic-gate #include <sys/shm.h> 347c478bd9Sstevel@tonic-gate #include <sys/avl.h> 357c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * shmsys system call subcodes 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate #define SHMAT 0 467c478bd9Sstevel@tonic-gate #define SHMCTL 1 477c478bd9Sstevel@tonic-gate #define SHMDT 2 487c478bd9Sstevel@tonic-gate #define SHMGET 3 497c478bd9Sstevel@tonic-gate #define SHMIDS 4 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * There is a shared mem id data structure (shmid_ds) for each 537c478bd9Sstevel@tonic-gate * segment in the system. 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 567c478bd9Sstevel@tonic-gate typedef struct kshmid { 577c478bd9Sstevel@tonic-gate kipc_perm_t shm_perm; /* operation permission struct */ 587c478bd9Sstevel@tonic-gate size_t shm_segsz; /* size of segment in bytes */ 597c478bd9Sstevel@tonic-gate struct anon_map *shm_amp; /* segment anon_map pointer */ 607c478bd9Sstevel@tonic-gate ushort_t shm_lkcnt; /* number of times it is being locked */ 61*c6939658Ssl108498 pgcnt_t shm_lkpages; /* number of pages locked by shmctl */ 62*c6939658Ssl108498 kmutex_t shm_mlock; /* held when locking physical pages */ 63*c6939658Ssl108498 /* Therefore, protects p_lckcnt for */ 64*c6939658Ssl108498 /* pages that back shm */ 657c478bd9Sstevel@tonic-gate pid_t shm_lpid; /* pid of last shmop */ 667c478bd9Sstevel@tonic-gate pid_t shm_cpid; /* pid of creator */ 677c478bd9Sstevel@tonic-gate ulong_t shm_ismattch; /* number of ISM attaches */ 687c478bd9Sstevel@tonic-gate time_t shm_atime; /* last shmat time */ 697c478bd9Sstevel@tonic-gate time_t shm_dtime; /* last shmdt time */ 707c478bd9Sstevel@tonic-gate time_t shm_ctime; /* last change time */ 717c478bd9Sstevel@tonic-gate struct sptinfo *shm_sptinfo; /* info about ISM segment */ 727c478bd9Sstevel@tonic-gate struct seg *shm_sptseg; /* pointer to ISM segment */ 737c478bd9Sstevel@tonic-gate long shm_sptprot; /* was reserved (still a "long") */ 747c478bd9Sstevel@tonic-gate } kshmid_t; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * Segacct Flags. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define SHMSA_ISM 1 /* uses shared page table */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate typedef struct sptinfo { 827c478bd9Sstevel@tonic-gate struct as *sptas; /* dummy as ptr. for spt segment */ 837c478bd9Sstevel@tonic-gate } sptinfo_t; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Protected by p->p_lock 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate typedef struct segacct { 897c478bd9Sstevel@tonic-gate avl_node_t sa_tree; 907c478bd9Sstevel@tonic-gate caddr_t sa_addr; 917c478bd9Sstevel@tonic-gate size_t sa_len; 927c478bd9Sstevel@tonic-gate ulong_t sa_flags; 937c478bd9Sstevel@tonic-gate kshmid_t *sa_id; 947c478bd9Sstevel@tonic-gate } segacct_t; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Error codes for shmgetid(). 987c478bd9Sstevel@tonic-gate */ 997c478bd9Sstevel@tonic-gate #define SHMID_NONE (-1) 1007c478bd9Sstevel@tonic-gate #define SHMID_FREE (-2) 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate extern void shminit(void); 1037c478bd9Sstevel@tonic-gate extern void shmfork(struct proc *, struct proc *); 1047c478bd9Sstevel@tonic-gate extern void shmexit(struct proc *); 1057c478bd9Sstevel@tonic-gate extern int shmgetid(struct proc *, caddr_t); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * LP64 view of the ILP32 shmid_ds structure 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate struct shmid_ds32 { 1147c478bd9Sstevel@tonic-gate struct ipc_perm32 shm_perm; /* operation permission struct */ 1157c478bd9Sstevel@tonic-gate size32_t shm_segsz; /* size of segment in bytes */ 1167c478bd9Sstevel@tonic-gate caddr32_t shm_amp; /* segment anon_map pointer */ 1177c478bd9Sstevel@tonic-gate uint16_t shm_lkcnt; /* number of times it is being locked */ 1187c478bd9Sstevel@tonic-gate pid32_t shm_lpid; /* pid of last shmop */ 1197c478bd9Sstevel@tonic-gate pid32_t shm_cpid; /* pid of creator */ 1207c478bd9Sstevel@tonic-gate uint32_t shm_nattch; /* number of attaches */ 1217c478bd9Sstevel@tonic-gate uint32_t shm_cnattch; /* number of ISM attaches */ 1227c478bd9Sstevel@tonic-gate time32_t shm_atime; /* last shmat time */ 1237c478bd9Sstevel@tonic-gate int32_t shm_pad1; /* reserved for time_t expansion */ 1247c478bd9Sstevel@tonic-gate time32_t shm_dtime; /* last shmdt time */ 1257c478bd9Sstevel@tonic-gate int32_t shm_pad2; /* reserved for time_t expansion */ 1267c478bd9Sstevel@tonic-gate time32_t shm_ctime; /* last change time */ 1277c478bd9Sstevel@tonic-gate int32_t shm_pad3; /* reserved for time_t expansion */ 1287c478bd9Sstevel@tonic-gate int32_t shm_pad4[4]; /* reserve area */ 1297c478bd9Sstevel@tonic-gate }; 1307c478bd9Sstevel@tonic-gate #endif 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate #endif 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #endif /* _SYS_SHM_IMPL_H */ 137