xref: /titanic_44/usr/src/uts/common/sys/shm_impl.h (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SHM_IMPL_H
28 #define	_SYS_SHM_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/ipc_impl.h>
33 #if defined(_KERNEL) || defined(_KMEMUSER)
34 #include <sys/shm.h>
35 #include <sys/avl.h>
36 #include <sys/t_lock.h>
37 #endif
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * shmsys system call subcodes
45  */
46 #define	SHMAT	0
47 #define	SHMCTL	1
48 #define	SHMDT	2
49 #define	SHMGET	3
50 #define	SHMIDS	4
51 
52 /*
53  *	There is a shared mem id data structure (shmid_ds) for each
54  *	segment in the system.
55  */
56 #if defined(_KERNEL) || defined(_KMEMUSER)
57 typedef struct kshmid {
58 	kipc_perm_t	shm_perm;	/* operation permission struct */
59 	size_t		shm_segsz;	/* size of segment in bytes */
60 	struct anon_map	*shm_amp;	/* segment anon_map pointer */
61 	ushort_t	shm_lkcnt;	/* number of times it is being locked */
62 	pid_t		shm_lpid;	/* pid of last shmop */
63 	pid_t		shm_cpid;	/* pid of creator */
64 	ulong_t		shm_ismattch;	/* number of ISM attaches */
65 	time_t		shm_atime;	/* last shmat time */
66 	time_t		shm_dtime;	/* last shmdt time */
67 	time_t		shm_ctime;	/* last change time */
68 	struct sptinfo	*shm_sptinfo;	/* info about ISM segment */
69 	struct seg	*shm_sptseg;	/* pointer to ISM segment */
70 	long		shm_sptprot;	/* was reserved (still a "long") */
71 } kshmid_t;
72 
73 /*
74  *	Segacct Flags.
75  */
76 #define	SHMSA_ISM	1	/* uses shared page table */
77 
78 typedef struct sptinfo {
79 	struct as	*sptas;		/* dummy as ptr. for spt segment */
80 } sptinfo_t;
81 
82 /*
83  * Protected by p->p_lock
84  */
85 typedef struct segacct {
86 	avl_node_t	sa_tree;
87 	caddr_t		sa_addr;
88 	size_t		sa_len;
89 	ulong_t		sa_flags;
90 	kshmid_t	*sa_id;
91 } segacct_t;
92 
93 /*
94  * Error codes for shmgetid().
95  */
96 #define	SHMID_NONE	(-1)
97 #define	SHMID_FREE	(-2)
98 
99 extern void shminit(void);
100 extern void shmfork(struct proc *, struct proc *);
101 extern void shmexit(struct proc *);
102 extern int shmgetid(struct proc *, caddr_t);
103 
104 #endif	/* _KERNEL */
105 
106 #if defined(_SYSCALL32)
107 /*
108  * LP64 view of the ILP32 shmid_ds structure
109  */
110 struct shmid_ds32 {
111 	struct ipc_perm32 shm_perm;	/* operation permission struct */
112 	size32_t	shm_segsz;	/* size of segment in bytes */
113 	caddr32_t	shm_amp;	/* segment anon_map pointer */
114 	uint16_t	shm_lkcnt;	/* number of times it is being locked */
115 	pid32_t		shm_lpid;	/* pid of last shmop */
116 	pid32_t		shm_cpid;	/* pid of creator */
117 	uint32_t	shm_nattch;	/* number of attaches */
118 	uint32_t	shm_cnattch;	/* number of ISM attaches */
119 	time32_t	shm_atime;	/* last shmat time */
120 	int32_t		shm_pad1;	/* reserved for time_t expansion */
121 	time32_t	shm_dtime;	/* last shmdt time */
122 	int32_t		shm_pad2;	/* reserved for time_t expansion */
123 	time32_t	shm_ctime;	/* last change time */
124 	int32_t		shm_pad3;	/* reserved for time_t expansion */
125 	int32_t		shm_pad4[4];	/* reserve area  */
126 };
127 #endif
128 
129 #ifdef	__cplusplus
130 }
131 #endif
132 
133 #endif	/* _SYS_SHM_IMPL_H */
134