The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/osfmk/i386/seg.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*
   26  * @OSF_COPYRIGHT@
   27  */
   28 /* 
   29  * Mach Operating System
   30  * Copyright (c) 1991,1990 Carnegie Mellon University
   31  * All Rights Reserved.
   32  * 
   33  * Permission to use, copy, modify and distribute this software and its
   34  * documentation is hereby granted, provided that both the copyright
   35  * notice and this permission notice appear in all copies of the
   36  * software, derivative works or modified versions, and any portions
   37  * thereof, and that both notices appear in supporting documentation.
   38  * 
   39  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   40  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   41  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   42  * 
   43  * Carnegie Mellon requests users of this software to return to
   44  * 
   45  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   46  *  School of Computer Science
   47  *  Carnegie Mellon University
   48  *  Pittsburgh PA 15213-3890
   49  * 
   50  * any improvements or extensions that they make and grant Carnegie Mellon
   51  * the rights to redistribute these changes.
   52  */
   53 /*
   54  */
   55 
   56 #ifndef _I386_SEG_H_
   57 #define _I386_SEG_H_
   58 #include <mach_kdb.h>
   59 
   60 /*
   61  * i386 segmentation.
   62  */
   63 
   64 #ifndef __ASSEMBLER__
   65 /*
   66  * Real segment descriptor.
   67  */
   68 struct real_descriptor {
   69         unsigned int    limit_low:16,   /* limit 0..15 */
   70                         base_low:16,    /* base  0..15 */
   71                         base_med:8,     /* base  16..23 */
   72                         access:8,       /* access byte */
   73                         limit_high:4,   /* limit 16..19 */
   74                         granularity:4,  /* granularity */
   75                         base_high:8;    /* base 24..31 */
   76 };
   77 
   78 struct real_gate {
   79         unsigned int    offset_low:16,  /* offset 0..15 */
   80                         selector:16,
   81                         word_count:8,
   82                         access:8,
   83                         offset_high:16; /* offset 16..31 */
   84 };
   85 
   86 /*
   87  * We build descriptors and gates in a 'fake' format to let the
   88  * fields be contiguous.  We shuffle them into the real format
   89  * at runtime.
   90  */
   91 struct fake_descriptor {
   92         unsigned int    offset:32;              /* offset */
   93         unsigned int    lim_or_seg:20;          /* limit */
   94                                                 /* or segment, for gate */
   95         unsigned int    size_or_wdct:4;         /* size/granularity */
   96                                                 /* word count, for gate */
   97         unsigned int    access:8;               /* access */
   98 };
   99 #endif  /*__ASSEMBLER__*/
  100 
  101 #define SZ_32           0x4                     /* 32-bit segment */
  102 #define SZ_G            0x8                     /* 4K limit field */
  103 
  104 #define ACC_A           0x01                    /* accessed */
  105 #define ACC_TYPE        0x1e                    /* type field: */
  106 
  107 #define ACC_TYPE_SYSTEM 0x00                    /* system descriptors: */
  108 
  109 #define ACC_LDT         0x02                        /* LDT */
  110 #define ACC_CALL_GATE_16 0x04                       /* 16-bit call gate */
  111 #define ACC_TASK_GATE   0x05                        /* task gate */
  112 #define ACC_TSS         0x09                        /* task segment */
  113 #define ACC_CALL_GATE   0x0c                        /* call gate */
  114 #define ACC_INTR_GATE   0x0e                        /* interrupt gate */
  115 #define ACC_TRAP_GATE   0x0f                        /* trap gate */
  116 
  117 #define ACC_TSS_BUSY    0x02                        /* task busy */
  118 
  119 #define ACC_TYPE_USER   0x10                    /* user descriptors */
  120 
  121 #define ACC_DATA        0x10                        /* data */
  122 #define ACC_DATA_W      0x12                        /* data, writable */
  123 #define ACC_DATA_E      0x14                        /* data, expand-down */
  124 #define ACC_DATA_EW     0x16                        /* data, expand-down,
  125                                                              writable */
  126 #define ACC_CODE        0x18                        /* code */
  127 #define ACC_CODE_R      0x1a                        /* code, readable */
  128 #define ACC_CODE_C      0x1c                        /* code, conforming */
  129 #define ACC_CODE_CR     0x1e                        /* code, conforming,
  130                                                        readable */
  131 #define ACC_PL          0x60                    /* access rights: */
  132 #define ACC_PL_K        0x00                    /* kernel access only */
  133 #define ACC_PL_U        0x60                    /* user access */
  134 #define ACC_P           0x80                    /* segment present */
  135 
  136 /*
  137  * Components of a selector
  138  */
  139 #define SEL_LDTS        0x04                    /* local selector */
  140 #define SEL_PL          0x03                    /* privilege level: */
  141 #define SEL_PL_K        0x00                        /* kernel selector */
  142 #define SEL_PL_U        0x03                        /* user selector */
  143 
  144 /*
  145  * Convert selector to descriptor table index.
  146  */
  147 #define sel_idx(sel)    ((sel)>>3)
  148 
  149 /*
  150  * User descriptors for MACH - 32-bit flat address space
  151  */
  152 #define USER_SCALL      0x07            /* system call gate */
  153 #define USER_RPC        0x0f            /* mach rpc call gate */
  154 #define USER_CS         0x17            /* user code segment */
  155 #define USER_DS         0x1f            /* user data segment */
  156 #define USER_CTHREAD    0x27            /* user cthread area */
  157 
  158 #define LDTSZ           5
  159 
  160 /*
  161  * Kernel descriptors for MACH - 32-bit flat address space.
  162  */
  163 #define KERNEL_CS       0x08            /* kernel code */
  164 #define KERNEL_DS       0x10            /* kernel data */
  165 #define KERNEL_LDT      0x18            /* master LDT */
  166 #define KERNEL_TSS      0x20            /* master TSS (uniprocessor) */
  167 #ifdef  MACH_BSD
  168 #define BSD_SCALL_SEL   0x28            /* BSD System calls */
  169 #define MK25_SCALL_SEL  0x30            /* MK25 System Calls */
  170 #define MACHDEP_SCALL_SEL 0x38          /* Machdep SYstem calls */
  171 #else
  172 #define USER_LDT        0x28            /* place for per-thread LDT */
  173 #define USER_TSS        0x30            /* place for per-thread TSS
  174                                            that holds IO bitmap */
  175 #define FPE_CS          0x38            /* floating-point emulator code */
  176 #endif
  177 #define USER_FPREGS     0x40            /* user-mode access to saved
  178                                            floating-point registers */
  179 #define CPU_DATA        0x48            /* per-cpu data */
  180 
  181 #ifdef  MACH_BSD
  182 #define USER_LDT        0x58
  183 #define USER_TSS        0x60
  184 #define FPE_CS          0x68
  185 #endif
  186 
  187 #if     MACH_KDB
  188 #define DEBUG_TSS       0x50            /* debug TSS (uniprocessor) */
  189 
  190 #ifdef MACH_BSD
  191 #define GDTSZ           14
  192 #else
  193 #define GDTSZ           11
  194 #endif
  195 #else
  196 
  197 #ifdef  MACH_BSD
  198 #define GDTSZ           13
  199 #else
  200 #define GDTSZ           10
  201 #endif
  202 #endif
  203 
  204 /*
  205  * Interrupt table is always 256 entries long.
  206  */
  207 #define IDTSZ           256
  208 
  209 #endif  /* _I386_SEG_H_ */

Cache object: 3f46ed80e7c348f283f3a15395a2c6d0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.