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/mp_slave_boot.s

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

Cache object: 7d95d95e09b2ac80dbdabae2f68e186d


[ 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.