1 #ifndef_LINUX_SHM_H_ 2 #define_LINUX_SHM_H_ 3 #include <linux/ipc.h>
4
5 structshmid_ds{ 6 structipc_permshm_perm; /* operation perms */ 7 intshm_segsz; /* size of segment (bytes) */ 8 time_tshm_atime; /* last attach time */ 9 time_tshm_dtime; /* last detach time */ 10 time_tshm_ctime; /* last change time */ 11 unsignedshortshm_cpid; /* pid of creator */ 12 unsignedshortshm_lpid; /* pid of last operator */ 13 shortshm_nattch; /* no. of current attaches */ 14 /* the following are private */ 15 unsignedshortshm_npages; /* size of segment (pages) */ 16 unsignedlong *shm_pages; /* array of ptrs to frames -> SHMMAX */ 17 structshm_desc *attaches; /* descriptors for attaches */ 18 };
19
20 /* mode for attach */ 21 #defineSHM_RDONLY 010000 /* read-only access */ 22 #defineSHM_RND 020000 /* round attach address to SHMLBA boundary */ 23 #defineSHM_REMAP 040000 /* take-over region on attach */ 24
25 /* super user shmctl commands */ 26 #defineSHM_LOCK 11
27 #defineSHM_UNLOCK 12
28
29 structshminfo{ 30 intshmmax;
31 intshmmin;
32 intshmmni;
33 intshmseg;
34 intshmall;
35 };
36
37 #defineSHM_RANGE_START 0x40000000
38 #defineSHM_RANGE_END 0x60000000
39
40 /* _SHM_ID_BITS is a variable you can adjust to */ 41 /* tune the kernel. It determines the value of */ 42 /* SHMMNI, which specifies the maximum no. of */ 43 /* shared segments (system wide). SRB. */ 44 #define_SHM_ID_BITS 7 /* keep as low as possible */ 45 /* a static array is declared */ 46 /* using SHMMNI */ 47
48 #define__SHM_IDX_BITS (BITS_PER_PTR-2-SHM_IDX_SHIFT)
49
50 /* !!!!!!!????? 51 * Why reserve the two (2) high bits of the signature (shm_sgn) field? 52 * Since, as far as I can see, only the high bit is used (SHM_READ_ONLY). 53 * SRB. 54 */ 55
56 #define_SHM_IDX_BITS (__SHM_IDX_BITS+PAGE_SHIFT>=BITS_PER_PTR?\
57 BITS_PER_PTR-PAGE_SHIFT-1:__SHM_IDX_BITS) /* sanity check */ 58
59 /* not present page table entry format bit 0 is 0, low byte defined in mm.h */ 60 #defineSHM_ID_SHIFT 8
61 #defineSHM_ID_MASK ((1<<_SHM_ID_BITS)-1)
62 #defineSHM_IDX_SHIFT (SHM_ID_SHIFT+_SHM_ID_BITS)
63 #defineSHM_IDX_MASK ((1<<_SHM_IDX_BITS)-1)
64 #defineSHM_READ_ONLY (1<<(BITS_PER_PTR-1))
65
66 #defineSHMMAX 0x3fa000 /* max shared seg size (bytes) */ 67 #defineSHMMIN 1 /* really PAGE_SIZE *//* min shared seg size (bytes) */ 68 #defineSHMMNI (1<<_SHM_ID_BITS) /* max num of segs system wide */ 69 #defineSHMALL (1<<(_SHM_IDX_BITS+_SHM_ID_BITS))/* max shm system wide (pages) */ 70 #defineSHMLBA 0x1000 /* attach addr a multiple of this */ 71 #defineSHMSEGSHMMNI/* max shared segs per process */ 72
73 #ifdef__KERNEL__ 74
75 /* shm_mode upper byte flags */ 76 #defineSHM_DEST 01000 /* segment will be destroyed on last detach */ 77 #defineSHM_LOCKED 02000 /* segment will not be swapped */ 78
79 /* ipcs ctl commands */ 80 #defineSHM_STAT 13
81 #defineSHM_INFO 14
82 structshm_info{ 83 intused_ids;
84 ulongshm_tot; /* total allocated shm */ 85 ulongshm_rss; /* total resident shm */ 86 ulongshm_swp; /* total swapped shm */ 87 ulongswap_attempts;
88 ulongswap_successes;
89 };
90
91
92 /* 93 * Per process internal structure for managing segments. 94 * A shmat will add to and shmdt will remove from the list. 95 */ 96 structshm_desc{ 97 structtask_struct *task; /* attacher */ 98 unsignedlongshm_sgn; /* signature for this attach */ 99 unsignedlongstart; /* virt addr of attach, multiple of SHMLBA */ 100 unsignedlongend; /* multiple of SHMLBA */ 101 structshm_desc *task_next; /* next attach for task */ 102 structshm_desc *seg_next; /* next attach for segment */ 103 };
104
105 #endif/* __KERNEL__ */ 106
107 #endif/* _LINUX_SHM_H_ */ 108
109