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