ae115bc77f6fcde83175c75b4206dc2e50747966mrj * CDDL HEADER START
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The contents of this file are subject to the terms of the
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Common Development and Distribution License (the "License").
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * You may not use this file except in compliance with the License.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * See the License for the specific language governing permissions
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * and limitations under the License.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * When distributing Covered Code, include this CDDL HEADER in each
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * If applicable, add the following below this CDDL HEADER, with the
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * fields enclosed by brackets "[]" replaced with your own identifying
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * information: Portions Copyright [yyyy] [name of copyright owner]
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * CDDL HEADER END
5420b8055570e39d22735d20973c2979c9adba94Seth Goldberg * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Use is subject to license terms.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj#if defined(__lint)
ae115bc77f6fcde83175c75b4206dc2e50747966mrj#else /* __lint */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The multiboot header has to be at the start of the file
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The 32 bit kernel is ELF32, so the MB header is mostly ignored.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The 64 bit kernel is ELF64, so we get grub to load the entire
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * ELF file into memory and trick it into jumping into this code.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The trick is done by a binary utility run after unix is linked,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * that rewrites the mb_header.
5420b8055570e39d22735d20973c2979c9adba94Seth Goldberg .long 0x11111111 /* header_addr: patched by mbh_patch */
5420b8055570e39d22735d20973c2979c9adba94Seth Goldberg .long 0x100000 /* load_addr: patched by mbh_patch */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* load_end_addr - 0 means entire file */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* bss_end_addr */
5420b8055570e39d22735d20973c2979c9adba94Seth Goldberg .long 0x2222222 /* entry_addr: patched by mbh_patch */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* video mode.. */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* width 0 == don't care */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* height 0 == don't care */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj .long 0 /* depth 0 == don't care */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * At entry we are in protected mode, 32 bit execution, paging and
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * interrupts are disabled.
193974072f41a843678abf5f61979c748687e66bSherry Moore * EAX == MB_BOOTLOADER_MAGIC
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * EBX points to multiboot information
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * segment registers all have segments with base 0, limit == 0xffffffff
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * setup a global descriptor table with known contents
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * go off and determine memory config, build page tables, etc.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * On amd64 we'll want the stack pointer to be 16 byte aligned.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Enable PGE, PAE and large pages
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * enable NX protection if processor supports it
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * load the pagetable base address into cr3
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * enable long mode
843e19887f64dde75055cf8842fc4db2171eff45johnlev * enable paging, write protection, alignment masking, but disable
843e19887f64dde75055cf8842fc4db2171eff45johnlev * the cache disable and write through only bits.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The xboot_info ptr gets passed to the kernel as its argument
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * We're still in compatibility mode with 32 bit execution.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Switch to 64 bit mode now by switching to a 64 bit code segment.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * then set up and do a lret to get into 64 bit execution.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * if reset fails halt the system
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * flush the TLB
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Detect if we can do cpuid, see if we can change bit 21 of eflags.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Note we don't do the bizarre tests for Cyrix CPUs in ml/locore.s.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * If you're on such a CPU, you're stuck with non-PAE 32 bit kernels.
0cfdb6036e046270988a17ac442e4d717d426a44josephb * We want the GDT to be on its own page for better performance
0cfdb6036e046270988a17ac442e4d717d426a44josephb * running under hypervisors.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj#include "../boot/boot_gdt.s"
ae115bc77f6fcde83175c75b4206dc2e50747966mrj#endif /* __lint */