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