Annotation of XNU/osfmk/i386/AT386/mp/slave_boot.s, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * @OSF_COPYRIGHT@
        !            24:  */
        !            25: 
        !            26: /* 
        !            27:  * Mach Operating System
        !            28:  * Copyright (c) 1991,1990 Carnegie Mellon University
        !            29:  * All Rights Reserved.
        !            30:  * 
        !            31:  * Permission to use, copy, modify and distribute this software and its
        !            32:  * documentation is hereby granted, provided that both the copyright
        !            33:  * notice and this permission notice appear in all copies of the
        !            34:  * software, derivative works or modified versions, and any portions
        !            35:  * thereof, and that both notices appear in supporting documentation.
        !            36:  * 
        !            37:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            38:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            39:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            40:  * 
        !            41:  * Carnegie Mellon requests users of this software to return to
        !            42:  * 
        !            43:  *  Software Distribution Coordinator  or  [email protected]
        !            44:  *  School of Computer Science
        !            45:  *  Carnegie Mellon University
        !            46:  *  Pittsburgh PA 15213-3890
        !            47:  * 
        !            48:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            49:  * the rights to redistribute these changes.
        !            50:  */
        !            51: 
        !            52: 
        !            53: #include "i386/asm.h"
        !            54: #include "i386/AT386/mp/boot.h"
        !            55: 
        !            56: #define CR0_PE_ON      0x1
        !            57: #define CR0_PE_OFF     0xfffffffe
        !            58: 
        !            59:        .file   "slave_boot.s"
        !            60: 
        !            61:        .text   
        !            62: 
        !            63: #define        LJMP(segment,address)   \
        !            64:        .byte   0xea            ;\
        !            65:        .long   address-EXT(slave_boot_base)            ;\
        !            66:        .word   segment
        !            67: 
        !            68: #define        LGDT(address)   \
        !            69:        .word   0x010f ;\
        !            70:        .byte   0x15 ;\
        !            71:        .long   address-EXT(slave_boot_base)
        !            72: 
        !            73: ENTRY(slave_boot_base)
        !            74:        /* code is loaded at 0x0:0x1000 */
        !            75:        /* ljmp to the next instruction to set up %cs */
        !            76:        data16
        !            77:        LJMP(MP_BOOTSEG, EXT(slave_pstart))
        !            78: 
        !            79: ENTRY(slave_pstart)
        !            80:        /* set up %ds */
        !            81:        mov     %cs, %ax
        !            82:        mov     %ax, %ds
        !            83: 
        !            84:        /* set up %ss and %esp */
        !            85:        data16
        !            86:        mov     $MP_BOOTSEG, %eax
        !            87:        mov     %ax, %ss
        !            88:        data16
        !            89:        mov     $MP_BOOTSTACK, %esp
        !            90: 
        !            91:        /*set up %es */
        !            92:        mov     %ax, %es
        !            93: 
        !            94:        /* change to protected mode */
        !            95:        data16
        !            96:        call    EXT(real_to_prot)
        !            97: 
        !            98:        push    MP_MACH_START
        !            99:        call    EXT(startprog)
        !           100: 
        !           101: /*
        !           102:  real_to_prot()
        !           103:        transfer from real mode to protected mode.
        !           104: */
        !           105: 
        !           106: ENTRY(real_to_prot)
        !           107:        /* guarantee that interrupt is disabled when in prot mode */
        !           108:        cli
        !           109: 
        !           110:        /* load the gdtr */
        !           111:        addr16
        !           112:        data16
        !           113:        LGDT(EXT(gdtr))
        !           114: 
        !           115:        /* set the PE bit of CR0 */
        !           116:        mov     %cr0, %eax
        !           117: 
        !           118:        data16
        !           119:        or      $CR0_PE_ON, %eax
        !           120:        mov     %eax, %cr0 
        !           121: 
        !           122:        /* make intrasegment jump to flush the processor pipeline and */
        !           123:        /* reload CS register */
        !           124:        data16
        !           125:        LJMP(0x08, xprot)
        !           126: 
        !           127: xprot:
        !           128:        /* we are in USE32 mode now */
        !           129:        /* set up the protective mode segment registers : DS, SS, ES */
        !           130:        mov     $0x10, %eax
        !           131:        movw    %ax, %ds
        !           132:        movw    %ax, %ss
        !           133:        movw    %ax, %es
        !           134: 
        !           135:        ret
        !           136: 
        !           137: /*
        !           138:  startprog(phyaddr)
        !           139:        start the program on protected mode where phyaddr is the entry point
        !           140: */
        !           141: 
        !           142: ENTRY(startprog)
        !           143:        push    %ebp
        !           144:        mov     %esp, %ebp
        !           145:        
        !           146:        mov     0x8(%ebp), %ecx         /* entry offset  */
        !           147:        mov     $0x28, %ebx             /* segment */
        !           148:        push    %ebx
        !           149:        push    %ecx
        !           150: 
        !           151:        /* set up %ds and %es */
        !           152:        mov     $0x20, %ebx
        !           153:        movw    %bx, %ds
        !           154:        movw    %bx, %es
        !           155: 
        !           156:        lret
        !           157: 
        !           158: 
        !           159:        . = MP_GDT-MP_BOOT      /* GDT location */
        !           160: ENTRY(Gdt)
        !           161: 
        !           162: /*  Segment Descriptor
        !           163:  *
        !           164:  * 31          24         19   16                 7           0
        !           165:  * ------------------------------------------------------------
        !           166:  * |             | |B| |A|       | |   |1|0|E|W|A|            |
        !           167:  * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
        !           168:  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
        !           169:  * ------------------------------------------------------------
        !           170:  * |                             |                            |
        !           171:  * |        BASE 15..0           |       LIMIT 15..0          |
        !           172:  * |                             |                            |
        !           173:  * ------------------------------------------------------------
        !           174:  */
        !           175:        .word   0,0             /* 0x0 : null */
        !           176:        .byte   0,0,0,0
        !           177: 
        !           178:        .word   0xffff,MP_BOOT  /* 0x8 : boot code */
        !           179:        .byte   0,0x9e,0x40,0
        !           180: 
        !           181:        .word   0xffff,MP_BOOT  /* 0x10 : boot data */
        !           182:        .byte   0,0x92,0x40,0
        !           183: 
        !           184:        .word   0xffff,MP_BOOT  /* 0x18 : boot code, 16 bits */
        !           185:        .byte   0,0x9e,0x0,0
        !           186: 
        !           187:        .word   0xffff,0        /* 0x20 : init data */
        !           188:        .byte   0,0x92,0xcf,0
        !           189: 
        !           190:        .word   0xffff,0        /* 0x28 : init code */
        !           191:        .byte   0,0x9e,0xcf,0
        !           192: 
        !           193: ENTRY(gdtr)
        !           194:        .short  48              /* limit (8*6 segs) */
        !           195:        .short  MP_GDT          /* base low */
        !           196:        .short  0               /* base high */
        !           197: 
        !           198: ENTRY(slave_boot_end)
        !           199: 
        !           200: 
        !           201: 
        !           202: 
        !           203: 
        !           204: 
        !           205: 
        !           206: 
        !           207: 
        !           208: 
        !           209: 
        !           210: 
        !           211: 
        !           212: 

unix.superglobalmegacorp.com

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