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 #include <sys/ipc_impl.h> 307c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 317c478bd9Sstevel@tonic-gate #include <sys/shm.h> 327c478bd9Sstevel@tonic-gate #include <sys/avl.h> 337c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * shmsys system call subcodes 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate #define SHMAT 0 447c478bd9Sstevel@tonic-gate #define SHMCTL 1 457c478bd9Sstevel@tonic-gate #define SHMDT 2 467c478bd9Sstevel@tonic-gate #define SHMGET 3 477c478bd9Sstevel@tonic-gate #define SHMIDS 4 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * There is a shared mem id data structure (shmid_ds) for each 517c478bd9Sstevel@tonic-gate * segment in the system. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 547c478bd9Sstevel@tonic-gate typedef struct kshmid { 557c478bd9Sstevel@tonic-gate kipc_perm_t shm_perm; /* operation permission struct */ 567c478bd9Sstevel@tonic-gate size_t shm_segsz; /* size of segment in bytes */ 577c478bd9Sstevel@tonic-gate struct anon_map *shm_amp; /* segment anon_map pointer */ 587c478bd9Sstevel@tonic-gate ushort_t shm_lkcnt; /* number of times it is being locked */ 59*c6939658Ssl108498 pgcnt_t shm_lkpages; /* number of pages locked by shmctl */ 60*c6939658Ssl108498 kmutex_t shm_mlock; /* held when locking physical pages */ 61*c6939658Ssl108498 /* Therefore, protects p_lckcnt for */ 62*c6939658Ssl108498 /* pages that back shm */ 637c478bd9Sstevel@tonic-gate pid_t shm_lpid; /* pid of last shmop */ 647c478bd9Sstevel@tonic-gate pid_t shm_cpid; /* pid of creator */ 657c478bd9Sstevel@tonic-gate ulong_t shm_ismattch; /* number of ISM attaches */ 667c478bd9Sstevel@tonic-gate time_t shm_atime; /* last shmat time */ 677c478bd9Sstevel@tonic-gate time_t shm_dtime; /* last shmdt time */ 687c478bd9Sstevel@tonic-gate time_t shm_ctime; /* last change time */ 697c478bd9Sstevel@tonic-gate struct sptinfo *shm_sptinfo; /* info about ISM segment */ 707c478bd9Sstevel@tonic-gate struct seg *shm_sptseg; /* pointer to ISM segment */ 717c478bd9Sstevel@tonic-gate long shm_sptprot; /* was reserved (still a "long") */ 727c478bd9Sstevel@tonic-gate } kshmid_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Segacct Flags. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define SHMSA_ISM 1 /* uses shared page table */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate typedef struct sptinfo { 807c478bd9Sstevel@tonic-gate struct as *sptas; /* dummy as ptr. for spt segment */ 817c478bd9Sstevel@tonic-gate } sptinfo_t; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * Protected by p->p_lock 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate typedef struct segacct { 877c478bd9Sstevel@tonic-gate avl_node_t sa_tree; 887c478bd9Sstevel@tonic-gate caddr_t sa_addr; 897c478bd9Sstevel@tonic-gate size_t sa_len; 907c478bd9Sstevel@tonic-gate ulong_t sa_flags; 917c478bd9Sstevel@tonic-gate kshmid_t *sa_id; 927c478bd9Sstevel@tonic-gate } segacct_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * Error codes for shmgetid(). 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate #define SHMID_NONE (-1) 987c478bd9Sstevel@tonic-gate #define SHMID_FREE (-2) 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern void shminit(void); 1017c478bd9Sstevel@tonic-gate extern void shmfork(struct proc *, struct proc *); 1027c478bd9Sstevel@tonic-gate extern void shmexit(struct proc *); 1037c478bd9Sstevel@tonic-gate extern int shmgetid(struct proc *, caddr_t); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * LP64 view of the ILP32 shmid_ds structure 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate struct shmid_ds32 { 1127c478bd9Sstevel@tonic-gate struct ipc_perm32 shm_perm; /* operation permission struct */ 1137c478bd9Sstevel@tonic-gate size32_t shm_segsz; /* size of segment in bytes */ 1147c478bd9Sstevel@tonic-gate caddr32_t shm_amp; /* segment anon_map pointer */ 1157c478bd9Sstevel@tonic-gate uint16_t shm_lkcnt; /* number of times it is being locked */ 1167c478bd9Sstevel@tonic-gate pid32_t shm_lpid; /* pid of last shmop */ 1177c478bd9Sstevel@tonic-gate pid32_t shm_cpid; /* pid of creator */ 1187c478bd9Sstevel@tonic-gate uint32_t shm_nattch; /* number of attaches */ 1197c478bd9Sstevel@tonic-gate uint32_t shm_cnattch; /* number of ISM attaches */ 1207c478bd9Sstevel@tonic-gate time32_t shm_atime; /* last shmat time */ 1217c478bd9Sstevel@tonic-gate int32_t shm_pad1; /* reserved for time_t expansion */ 1227c478bd9Sstevel@tonic-gate time32_t shm_dtime; /* last shmdt time */ 1237c478bd9Sstevel@tonic-gate int32_t shm_pad2; /* reserved for time_t expansion */ 1247c478bd9Sstevel@tonic-gate time32_t shm_ctime; /* last change time */ 1257c478bd9Sstevel@tonic-gate int32_t shm_pad3; /* reserved for time_t expansion */ 1267c478bd9Sstevel@tonic-gate int32_t shm_pad4[4]; /* reserve area */ 1277c478bd9Sstevel@tonic-gate }; 1287c478bd9Sstevel@tonic-gate #endif 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate #endif 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #endif /* _SYS_SHM_IMPL_H */ 135