Source to include/mach/gdt.h


0001  #ifndef _GDT_H
0002  #define _GDT_H
0003  /*
0004   * gdt.h
0005   *	Definitions for Global Descriptor Table and friends
0006   */
0007  #include <sys/types.h>
0008  
0009  /*
0010   * Selectors XXX move to mach/vm.h?
0011   */
0012  #define	PRIV_MASK ((s) & 3)	/* Privilege bits in a selector */
0013  #define	PRIV_KERN 0		/*  ...kernel */
0014  #define	PRIV_USER 3		/*  ...user */
0015  
0016  /*
0017   * Memory-type segment entries
0018   */
0019  struct segment {
0020  	uint seg_limit0 : 16;	/* Size 0 */
0021  	uint seg_base0 : 16;	/* Base 0 */
0022  	uint seg_base1 : 8;	/* Base 1 */
0023  	uint seg_type : 5;	/* Type */
0024  	uint seg_dpl : 2;	/* Priv level */
0025  	uint seg_p : 1;		/* Present */
0026  	uint seg_limit1 : 4;	/* Size 1 */
0027  	uint seg_pad0 : 2;	/* Pad */
0028  	uint seg_32 : 1;	/* 32-bit size? */
0029  	uint seg_gran : 1;	/* Granularity (pages if set) */
0030  	uint seg_base2 : 8;	/* Base 1 */
0031  };
0032  
0033  /*
0034   * Gateway-type segment entries
0035   */
0036  struct gate {
0037  	uint g_off0 : 16;	/* Offset 0 */
0038  	uint g_sel : 16;	/* Selector */
0039  	uint g_stkwds : 5;	/* Stack words to copy (always 0) */
0040  	uint g_pad0 : 3;	/* Pad */
0041  	uint g_type : 5;	/* Type */
0042  	uint g_dpl : 2;		/* Priv level */
0043  	uint g_p : 1;		/* Present */
0044  	uint g_off1 : 16;	/* Offset 1 */
0045  };
0046  
0047  /* Segment types used in VSTa */
0048  #define	T_INVAL		 0	/* Invalid */
0049  #define	T_LDT		 2	/* LDT */
0050  #define	T_TASK		 5	/* task gate */
0051  #define	T_TSS		 9	/* TSS */
0052  #define	T_CALL		12	/* call gate */
0053  #define	T_INTR		14	/* interrupt gate */
0054  #define	T_TRAP		15	/* trap gate */
0055  #define	T_MEMRO		16	/* read only */
0056  #define	T_MEMRW		18	/* read+write */
0057  #define	T_MEMX		24	/* execute only */
0058  #define	T_MEMXR		26	/* execute+read */
0059  
0060  /*
0061   * Linear memory description for lgdt and lidt instructions.  The
0062   * compiler tries to put l_addr on a long boundary, so you must
0063   * use &l.l_len as the argument to lgdt() and friends.
0064   */
0065  struct linmem {
0066  	ushort l_pad;	/* Pad XXX */
0067  	ushort l_len;	/* Length */
0068  	ulong l_addr;	/* Address  */
0069  };
0070  
0071  #define	NIDT	256	/* Total entries in IDT table */
0072  #define	CPUIDT	32	/* This many for CPU (come first) */
0073  #define IDTISA	16	/* This many at CPUIDT used for ISA intrs */
0074  
0075  #endif /* _GDT_H */