1 /* $Id: segmem.h,v 1.3 1993/07/04 04:04:21 root Exp root $
4 * Copyright Robert J. Amstadt, 1993
17 #if defined(__NetBSD__) || defined(__FreeBSD__)
19 #include <sys/types.h>
22 #define SHMSEG 32 /* XXX SEMMNI /usr/src/sys/conf/param.h */
23 #define SHM_RANGE_START 0x40000000
27 * Array to track selector allocation.
29 #define SELECTOR_ISFREE 0x8000
30 #define SELECTOR_IS32BIT 0x4000
31 #define SELECTOR_INDEXMASK 0x0fff
34 #define __AHINCR (1 << __AHSHIFT)
36 extern unsigned short* SelectorMap
;
39 #define SAFEMAKEPTR(s, o) ((void *)(((int) (s) << 16) | ((o) & 0xffff)))
42 #define SAFEMAKEPTR(s, o) \
43 ((void*)(((int)SelectorMap[SelectorMap[(s)>>__AHSHIFT] & SELECTOR_INDEXMASK]\
44 << (16 + __AHSHIFT)) | 0x70000 | ((o) & 0xffff)))
45 #define FIXPTR(p) SAFEMAKEPTR((unsigned long) (p) >> 16, (p))
48 #define MAKESELECTOR(fp) ((unsigned short) (fp >> (16 + __AHSHIFT)))
52 * Structure to hold info about each selector we create.
55 typedef struct segment_descriptor_s
57 void *base_addr
; /* Pointer to segment in flat memory */
58 unsigned int length
; /* Length of segment */
59 unsigned int flags
; /* Segment flags (see neexe.h and below)*/
60 unsigned short selector
; /* Selector used to access this segment */
61 unsigned short owner
; /* Handle of owner program */
62 unsigned char type
; /* DATA or CODE */
64 key_t shm_key
; /* Shared memory key or -1 */
68 extern int IPCCopySelector(int i_old
, unsigned long new, int swap_type
);
73 #define NE_SEGFLAGS_MALLOCED 0x00010000 /* Memory allocated with malloc() */
78 #define GLOBAL_FLAGS_MOVEABLE 0x0002
79 #define GLOBAL_FLAGS_ZEROINIT 0x0040
80 #define GLOBAL_FLAGS_CODE 0x00010000
81 #define GLOBAL_FLAGS_EXECUTEONLY 0x00020000
82 #define GLOBAL_FLAGS_READONLY 0x00020000
85 #define FIRST_SELECTOR 2
86 #define IS_16_BIT_ADDRESS(addr) \
87 (!(SelectorMap[(unsigned int)(addr) >> (16+__AHSHIFT)]& SELECTOR_IS32BIT))
89 #define FIRST_SELECTOR 8
90 #define IS_16_BIT_ADDRESS(addr) \
91 ((unsigned int)(addr) >= (((FIRST_SELECTOR << __AHSHIFT) | 7) << 16))
95 extern SEGDESC
* Segments
;