Annotation of kernel/machdep/i386/gdt.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:  * Copyright (c) 1992 NeXT Computer, Inc.
                     27:  *
                     28:  * Intel386 Family:    Global descriptor table.
                     29:  *
                     30:  * HISTORY
                     31:  *
                     32:  * 3 April 1992 ? at NeXT
                     33:  *     Created.
                     34:  */
                     35: 
                     36: #import <mach/mach_types.h>
                     37: 
                     38: #import <machdep/i386/seg.h>
                     39: #import <machdep/i386/table_inline.h>
                     40: #import <machdep/i386/desc_inline.h>
                     41: 
                     42: void
                     43: locate_gdt(
                     44:     vm_offset_t                base
                     45: )
                     46: {
                     47:     extern
                     48:        unsigned int    gdt_base;
                     49:     extern
                     50:        unsigned short  gdt_limit;
                     51:        
                     52:     gdt_base = base;
                     53:     gdt_limit = (GDTSZ * sizeof (gdt_entry_t)) - 1;
                     54:     
                     55:     asm volatile("lgdt %0"
                     56:                    :
                     57:                    : "m" (gdt_limit));
                     58: }
                     59: 
                     60: void
                     61: gdt_init(
                     62:     void
                     63: )
                     64: {
                     65:     extern void                unix_syscall_(void),
                     66:                        mach_kernel_trap_(void),
                     67:                        machdep_call_(void);
                     68:     
                     69:     map_code((code_desc_t *) sel_to_gdt_entry(KCS_SEL),
                     70:             KERNEL_LINEAR_BASE,
                     71:             (vm_size_t)(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
                     72:             KERN_PRIV,
                     73:             FALSE
                     74:            );
                     75: 
                     76:     map_data((data_desc_t *) sel_to_gdt_entry(KDS_SEL),
                     77:             KERNEL_LINEAR_BASE,
                     78:             (vm_size_t)(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
                     79:             KERN_PRIV,
                     80:             FALSE
                     81:            );
                     82: 
                     83:     map_code((code_desc_t *) sel_to_gdt_entry(LCODE_SEL),
                     84:             (vm_offset_t) VM_MIN_ADDRESS,
                     85:             (vm_size_t) (VM_MAX_ADDRESS - VM_MIN_ADDRESS),
                     86:             KERN_PRIV,
                     87:             FALSE
                     88:            );
                     89: 
                     90:     map_data((data_desc_t *) sel_to_gdt_entry(LDATA_SEL),
                     91:             (vm_offset_t) VM_MIN_ADDRESS,
                     92:             (vm_size_t) (VM_MAX_ADDRESS - VM_MIN_ADDRESS),
                     93:             KERN_PRIV,
                     94:             FALSE
                     95:            );
                     96: 
                     97:     map_code((code_desc_t *) sel_to_gdt_entry(UCODE_SEL),
                     98:             (vm_offset_t) VM_MIN_ADDRESS,
                     99:             (vm_size_t) (VM_MAX_ADDRESS - VM_MIN_ADDRESS),
                    100:             USER_PRIV,
                    101:             FALSE
                    102:            );
                    103: 
                    104:     map_data((data_desc_t *) sel_to_gdt_entry(UDATA_SEL),
                    105:             (vm_offset_t) VM_MIN_ADDRESS,
                    106:             (vm_size_t) (VM_MAX_ADDRESS - VM_MIN_ADDRESS),
                    107:             USER_PRIV,
                    108:             FALSE
                    109:            );
                    110: 
                    111: /* XXX This is needed for protected mode WINDOWS support */        
                    112:     map_data((data_desc_t *) sel_to_gdt_entry(BIOSDATA_SEL),
                    113:             (vm_offset_t) 0x400,
                    114:             (vm_size_t) 0x300,
                    115:             USER_PRIV,
                    116:             FALSE
                    117:            );
                    118: /* XXX */
                    119: 
                    120:     make_call_gate(sel_to_gdt_entry(SCALL_SEL),
                    121:                                    KCS_SEL, unix_syscall_,
                    122:                                    USER_PRIV,
                    123:                                    1                           /* argcnt */
                    124:                    );
                    125: 
                    126:     make_call_gate(sel_to_gdt_entry(MACHCALL_SEL),
                    127:                                    KCS_SEL, mach_kernel_trap_,
                    128:                                    USER_PRIV,
                    129:                                    1                           /* argcnt */
                    130:                    );
                    131: 
                    132:     make_call_gate(sel_to_gdt_entry(MDCALL_SEL),
                    133:                                    KCS_SEL, machdep_call_,
                    134:                                    USER_PRIV,
                    135:                                    1                           /* argcnt */
                    136:                    );
                    137: 
                    138:     locate_gdt((vm_offset_t) gdt);
                    139: }
                    140: 
                    141: static gdt_t   gdt_store[GDTSZ] = { 0 };
                    142: 
                    143: gdt_t          *gdt = gdt_store;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.