xref: /illumos-gate/usr/src/uts/i86pc/dboot/dboot_xen.S (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
1*5d9d9091SRichard Lowe/*
2*5d9d9091SRichard Lowe * CDDL HEADER START
3*5d9d9091SRichard Lowe *
4*5d9d9091SRichard Lowe * The contents of this file are subject to the terms of the
5*5d9d9091SRichard Lowe * Common Development and Distribution License (the "License").
6*5d9d9091SRichard Lowe * You may not use this file except in compliance with the License.
7*5d9d9091SRichard Lowe *
8*5d9d9091SRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5d9d9091SRichard Lowe * or http://www.opensolaris.org/os/licensing.
10*5d9d9091SRichard Lowe * See the License for the specific language governing permissions
11*5d9d9091SRichard Lowe * and limitations under the License.
12*5d9d9091SRichard Lowe *
13*5d9d9091SRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each
14*5d9d9091SRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5d9d9091SRichard Lowe * If applicable, add the following below this CDDL HEADER, with the
16*5d9d9091SRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
17*5d9d9091SRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
18*5d9d9091SRichard Lowe *
19*5d9d9091SRichard Lowe * CDDL HEADER END
20*5d9d9091SRichard Lowe */
21*5d9d9091SRichard Lowe
22*5d9d9091SRichard Lowe/*
23*5d9d9091SRichard Lowe * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24*5d9d9091SRichard Lowe * Use is subject to license terms.
25*5d9d9091SRichard Lowe */
26*5d9d9091SRichard Lowe
27*5d9d9091SRichard Lowe#include <sys/asm_linkage.h>
28*5d9d9091SRichard Lowe#include <sys/asm_misc.h>
29*5d9d9091SRichard Lowe#include "dboot_xboot.h"
30*5d9d9091SRichard Lowe
31*5d9d9091SRichard Lowe#if defined(__amd64)
32*5d9d9091SRichard Lowe	ENTRY_NP(_start)
33*5d9d9091SRichard Lowe	/*
34*5d9d9091SRichard Lowe	 * At entry we are passed a (start_info_t *) in %rsi.
35*5d9d9091SRichard Lowe	 */
36*5d9d9091SRichard Lowe	movq	%rsi, xen_info(%rip)
37*5d9d9091SRichard Lowe
38*5d9d9091SRichard Lowe	/*
39*5d9d9091SRichard Lowe	 * make sure we have sane processor state
40*5d9d9091SRichard Lowe	 */
41*5d9d9091SRichard Lowe	xorw	%ax, %ax
42*5d9d9091SRichard Lowe	movw	%ax, %fs
43*5d9d9091SRichard Lowe	movw	%ax, %gs
44*5d9d9091SRichard Lowe	pushq	$0
45*5d9d9091SRichard Lowe	popfq
46*5d9d9091SRichard Lowe	pushq	$0
47*5d9d9091SRichard Lowe
48*5d9d9091SRichard Lowe	/*
49*5d9d9091SRichard Lowe	 * go off and unpack the kernel bits, adjust page tables, etc.
50*5d9d9091SRichard Lowe	 */
51*5d9d9091SRichard Lowe	call	startup_kernel
52*5d9d9091SRichard Lowe
53*5d9d9091SRichard Lowe	/*
54*5d9d9091SRichard Lowe	 * we can only setup a stack after startup_kernel().
55*5d9d9091SRichard Lowe	 * Its in the lower part of memroy.
56*5d9d9091SRichard Lowe	 */
57*5d9d9091SRichard Lowe	leaq	stack_space(%rip), %rsp
58*5d9d9091SRichard Lowe	addq	$STACK_SIZE, %rsp
59*5d9d9091SRichard Lowe	andl	$0xfffffff0, %esp
60*5d9d9091SRichard Lowe
61*5d9d9091SRichard Lowe	pushq	$0x0			/* push a dead-end frame */
62*5d9d9091SRichard Lowe	pushq	$0x0
63*5d9d9091SRichard Lowe	movq	%rsp, %rbp
64*5d9d9091SRichard Lowe
65*5d9d9091SRichard Lowe	/*
66*5d9d9091SRichard Lowe	 * when we get back, load the kernel entry point and jump to it
67*5d9d9091SRichard Lowe	 * The address of the xboot_info is the kernel's only argument.
68*5d9d9091SRichard Lowe	 */
69*5d9d9091SRichard Lowe	movl	entry_addr_low, %esi
70*5d9d9091SRichard Lowe	movq	$0xffffffff00000000,%rdx
71*5d9d9091SRichard Lowe	orq	%rdx, %rsi		/* set upper bits of entry addr */
72*5d9d9091SRichard Lowe
73*5d9d9091SRichard Lowe        movl    bi, %edi
74*5d9d9091SRichard Lowe	call	*%rsi
75*5d9d9091SRichard Lowe	SET_SIZE(_start)
76*5d9d9091SRichard Lowe
77*5d9d9091SRichard Lowe#elif defined(__i386)
78*5d9d9091SRichard Lowe	ENTRY_NP(_start)
79*5d9d9091SRichard Lowe	/*
80*5d9d9091SRichard Lowe	 * At entry we are passed a (start_info_t *) in %esi.
81*5d9d9091SRichard Lowe	 */
82*5d9d9091SRichard Lowe	movl	%esi, xen_info
83*5d9d9091SRichard Lowe
84*5d9d9091SRichard Lowe	/*
85*5d9d9091SRichard Lowe	 * make sure we have sane processor state
86*5d9d9091SRichard Lowe	 */
87*5d9d9091SRichard Lowe	cld
88*5d9d9091SRichard Lowe	xorw	%ax, %ax
89*5d9d9091SRichard Lowe	movw	%ax, %fs
90*5d9d9091SRichard Lowe	movw	%ax, %gs
91*5d9d9091SRichard Lowe
92*5d9d9091SRichard Lowe
93*5d9d9091SRichard Lowe	/*
94*5d9d9091SRichard Lowe	 * go off and unpack the kernel bits, adjust page tables, etc.
95*5d9d9091SRichard Lowe	 */
96*5d9d9091SRichard Lowe	call	startup_kernel
97*5d9d9091SRichard Lowe
98*5d9d9091SRichard Lowe	/*
99*5d9d9091SRichard Lowe	 * we can only setup a stack after startup_kernel().
100*5d9d9091SRichard Lowe	 */
101*5d9d9091SRichard Lowe	movl	$stack_space, %esp	/* load my stack pointer */
102*5d9d9091SRichard Lowe	addl	$STACK_SIZE, %esp
103*5d9d9091SRichard Lowe
104*5d9d9091SRichard Lowe	pushl	$0x0			/* push a dead-end frame */
105*5d9d9091SRichard Lowe	pushl	$0x0
106*5d9d9091SRichard Lowe	movl	%esp, %ebp
107*5d9d9091SRichard Lowe
108*5d9d9091SRichard Lowe	/*
109*5d9d9091SRichard Lowe	 * when we get back, load the kernel entry point and jump to it
110*5d9d9091SRichard Lowe	 * The address of the xboot_info is the kernel's only argument.
111*5d9d9091SRichard Lowe	 */
112*5d9d9091SRichard Lowe	movl	entry_addr_low, %esi
113*5d9d9091SRichard Lowe	movl	bi, %eax
114*5d9d9091SRichard Lowe	pushl	%eax
115*5d9d9091SRichard Lowe	call	*%esi
116*5d9d9091SRichard Lowe	SET_SIZE(_start)
117*5d9d9091SRichard Lowe#endif	/* __i386 */
118