forked from koukaipan/xen-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Files are modified from Mini-OS.
- Loading branch information
Showing
5 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <arch-x86_64.h> | ||
|
||
.section __xen_guest | ||
.ascii "GUEST_OS=Mini-OS" | ||
.ascii ",XEN_VER=xen-3.0" | ||
.ascii ",VIRT_BASE=0x0" /* &_text from minios_x86_64.lds */ | ||
.ascii ",ELF_PADDR_OFFSET=0x0" | ||
.ascii ",HYPERCALL_PAGE=0x2" | ||
.ascii ",LOADER=generic" | ||
.byte 0 | ||
.text | ||
|
||
#define ENTRY(X) .globl X ; X : | ||
.globl _start, shared_info, hypercall_page | ||
|
||
|
||
_start: | ||
cld | ||
movq stack_start(%rip),%rsp | ||
andq $(~(8192-1)), %rsp | ||
movq %rsi,%rdi | ||
call start_kernel | ||
|
||
stack_start: | ||
.quad stack+(2*8192) | ||
|
||
/* Unpleasant -- the PTE that maps this page is actually overwritten */ | ||
/* to map the real shared-info page! :-) */ | ||
.org 0x1000 | ||
shared_info: | ||
.org 0x2000 | ||
|
||
hypercall_page: | ||
.org 0x3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef __HYPERCALL_X86_64_H__ | ||
#define __HYPERCALL_X86_64_H__ | ||
|
||
#include <xen.h> | ||
|
||
#define __STR(x) #x | ||
#define STR(x) __STR(x) | ||
|
||
#define _hypercall3(type, name, a1, a2, a3) \ | ||
({ \ | ||
long __res, __ign1, __ign2, __ign3; \ | ||
__asm__ volatile ( \ | ||
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\ | ||
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \ | ||
"=d" (__ign3) \ | ||
: "1" ((long)(a1)), "2" ((long)(a2)), \ | ||
"3" ((long)(a3)) \ | ||
: "memory" ); \ | ||
(type)__res; \ | ||
}) | ||
|
||
static inline int HYPERVISOR_console_io(int cmd, int count, char *str) | ||
{ | ||
return _hypercall3(int, console_io, cmd, count, str); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") | ||
OUTPUT_ARCH(i386:x86-64) | ||
ENTRY(_start) | ||
SECTIONS | ||
{ | ||
. = 0x0; | ||
_text = .; /* Text and read-only data */ | ||
.text : { | ||
*(.text) | ||
*(.gnu.warning) | ||
} = 0x9090 | ||
|
||
_etext = .; /* End of text section */ | ||
|
||
.rodata : { *(.rodata) *(.rodata.*) } | ||
. = ALIGN(4096); | ||
_erodata = .; | ||
|
||
/* newlib initialization functions */ | ||
. = ALIGN(64 / 8); | ||
PROVIDE (__preinit_array_start = .); | ||
.preinit_array : { *(.preinit_array) } | ||
PROVIDE (__preinit_array_end = .); | ||
PROVIDE (__init_array_start = .); | ||
.init_array : { *(.init_array) } | ||
PROVIDE (__init_array_end = .); | ||
PROVIDE (__fini_array_start = .); | ||
.fini_array : { *(.fini_array) } | ||
PROVIDE (__fini_array_end = .); | ||
|
||
.ctors : { | ||
__CTOR_LIST__ = .; | ||
*(.ctors) | ||
CONSTRUCTORS | ||
QUAD(0) | ||
__CTOR_END__ = .; | ||
} | ||
|
||
.dtors : { | ||
__DTOR_LIST__ = .; | ||
*(.dtors) | ||
QUAD(0) | ||
__DTOR_END__ = .; | ||
} | ||
|
||
.data : { /* Data */ | ||
*(.data) | ||
} | ||
|
||
_edata = .; /* End of data section */ | ||
|
||
__bss_start = .; /* BSS */ | ||
.bss : { | ||
*(.bss) | ||
*(.app.bss) | ||
} | ||
_end = . ; | ||
|
||
/* Sections to be discarded */ | ||
/DISCARD/ : { | ||
*(.text.exit) | ||
*(.data.exit) | ||
*(.exitcall.exit) | ||
} | ||
|
||
/* Stabs debugging sections. */ | ||
.stab 0 : { *(.stab) } | ||
.stabstr 0 : { *(.stabstr) } | ||
.stab.excl 0 : { *(.stab.excl) } | ||
.stab.exclstr 0 : { *(.stab.exclstr) } | ||
.stab.index 0 : { *(.stab.index) } | ||
.stab.indexstr 0 : { *(.stab.indexstr) } | ||
.comment 0 : { *(.comment) } | ||
} |