]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/amd64/amd64/xen-locore.S
Add mkimg, a utility for making disk images from raw partition contents.
[FreeBSD/FreeBSD.git] / sys / amd64 / amd64 / xen-locore.S
1 /*-
2  * Copyright (c) 2003 Peter Wemm <peter@FreeBSD.org>
3  * Copyright (c) 2013 Roger Pau Monne <royger@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29
30 #include <machine/asmacros.h>
31 #include <machine/psl.h>
32 #include <machine/pmap.h>
33 #include <machine/specialreg.h>
34
35 #include <xen/xen-os.h>
36 #define __ASSEMBLY__
37 #include <xen/interface/elfnote.h>
38
39 #include "assym.s"
40
41 .section __xen_guest
42         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz, "FreeBSD")
43         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz, __XSTRING(__FreeBSD_version))
44         ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz, "xen-3.0")
45         ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .quad,  KERNBASE)
46         ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad,  KERNBASE) /* Xen honours elf->p_paddr; compensate for this */
47         ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad,  xen_start)
48         ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad,  hypercall_page)
49         ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   .quad,  HYPERVISOR_VIRT_START)
50         ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector")
51         ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz, "yes")
52         ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .long,  PG_V, PG_V)
53         ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")
54         ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long,  0)
55         ELFNOTE(Xen, XEN_ELFNOTE_BSD_SYMTAB,     .asciz, "yes")
56
57         .text
58 .p2align PAGE_SHIFT, 0x90       /* Hypercall_page needs to be PAGE aligned */
59
60 NON_GPROF_ENTRY(hypercall_page)
61         .skip   0x1000, 0x90    /* Fill with "nop"s */
62
63 NON_GPROF_ENTRY(xen_start)
64         /* Don't trust what the loader gives for rflags. */
65         pushq   $PSL_KERNEL
66         popfq
67
68         /* Parameters for the xen init function */
69         movq    %rsi, %rdi              /* shared_info (arg 1) */
70         movq    %rsp, %rsi              /* xenstack    (arg 2) */
71
72         /* Use our own stack */
73         movq    $bootstack,%rsp
74         xorl    %ebp, %ebp
75
76         /* u_int64_t hammer_time_xen(start_info_t *si, u_int64_t xenstack); */
77         call    hammer_time_xen
78         movq    %rax, %rsp              /* set up kstack for mi_startup() */
79         call    mi_startup              /* autoconfiguration, mountroot etc */
80
81         /* NOTREACHED */
82 0:      hlt
83         jmp     0b