fb_swtch_src.s revision 193974072f41a843678abf5f61979c748687e66b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#if defined(__lint)
int fb_swtch_silence_lint = 0;
#else
#include <sys/asm_linkage.h>
#include <sys/segments.h>
#include <sys/controlregs.h>
#include <sys/machparam.h>
#include <sys/multiboot.h>
#include <sys/fastboot.h>
#include "assym.h"
/*
* This code is to switch from 64-bit or 32-bit to protected mode.
*/
/*
* For debugging with LEDs
*/
#define FB_OUTB_ASM(val) \
outb $0x80;
#define DISABLE_PAGING \
/* Disable interrupts */
#if defined(__amd64)
/* Switch to a low memory stack */
/*
* Copy from old stack to new stack
* If the content before fi_valid gets bigger than 0x200 bytes,
* the reserved stack size above will need to be changed.
*/
/* Switch to a low memory stack */
/* Copy struct to stack */
#endif
#if defined(__amd64)
#endif
/*
* zero out all the registers to make sure they're 16 bit clean
*/
#if defined(__amd64)
#endif
#if defined(__amd64)
/*
* Load our own GDT
*/
#endif
/*
* Load our own IDT
*/
#if defined(__amd64)
/*
* Shut down 64 bit mode. First get into compatiblity mode.
*/
pushq $1f
1:
/*
* Disable long mode by:
* - shutting down paging (bit 31 of cr0). This will flush the
* TLBs.
* - disabling LME (long made enable) in EFER (extended feature reg)
*/
#endif
DISABLE_PAGING /* clobbers %eax */
#if defined(__amd64)
1:
#endif
/*
* Clear PGE, PAE and PSE flags as dboot expects them to be
* cleared.
*/
#if defined(__amd64)
#endif
/*
* If fi_has_pae is set, re-enable paging with PAE.
*/
/*
* Turn on PAE
*/
/*
* Load top pagetable base address into cr3
*/
/* copy unix to final destination */
/* copy boot archive to final destination */
/* Disable paging one more time */
/* Copy sections if there are any */
je 1f
1:
/* Whatever flags we turn on we need to turn off */
/* Jump to dboot */
/*
* On entry
* %edx points to the fboot_file_t
* %eax contains the number of sections
*/
1:
/* Zero BSS */
je 2f
jmp 1b
2:
/*
* On entry
* %edx points to the fboot_file_t
* %edi has FB_HAS_PAE(%esp)
* %esi has FI_LAST_TABLE_PA(%esp)
*/
loop:
done:
.value 0x3ff
.quad 0
/*
* We need to trampoline thru a gdt we have in low memory.
*/
#include "../boot/boot_gdt.s"
#endif /* __lint */