## The framework consists of:
-* PV 32 and 64 bit entry points
+* PV and HVM, 32 and 64 bit entry points
* Hypercall interface
* PV console driver (output)
## TODO List:
* More introductory text
-* Entry points for 32 and 64bit HVM guests
* Common reporting framework
* Tests
--- /dev/null
+#include <xtf/asm_macros.h>
+
+#include <arch/x86/page.h>
+#include <arch/x86/processor.h>
+#include <arch/x86/msr-index.h>
+#include <arch/x86/segment.h>
+
+ .code32 /* Always starts in 32bit flat mode. */
+
+
+/* HVM common setup for pae paging. */
+GLOBAL(_start)
+
+ /* CR4.PAE = 1 */
+ mov $X86_CR4_PAE, %eax
+ mov %eax, %cr4
+
+ /* CR3 = l?_???map */
+#ifdef __x86_64__
+ mov $l4_identmap, %eax
+#else
+ mov $l3_paemap, %eax
+#endif
+ mov %eax, %cr3
+
+#ifdef __x86_64__
+ /* EFER.LME = 1 */
+ mov $MSR_EFER, %ecx
+ rdmsr
+ bts $_EFER_LME, %eax
+ wrmsr
+#endif
+
+ /* CR0.{PG,PE} = 1 */
+ mov %cr0, %eax
+ or $(X86_CR0_PG | X86_CR0_PE), %eax
+ mov %eax, %cr0
+
+ lgdt gdt_ptr
+
+ /* Load code segment. */
+ ljmp $__KERN_CS, $1f
+#ifdef __x86_64__
+ .code64
+#endif
+
+ /* Load data segments. */
+1: mov $__KERN_DS, %eax
+ mov %eax, %ds
+ mov %eax, %es
+ mov %eax, %fs
+ mov %eax, %gs
+ mov %eax, %ss
+
+ /* Move onto the boot stack. */
+ mov $boot_stack + PAGE_SIZE, %esp
+
+ /* Reset flags. */
+ push $X86_EFLAGS_MBS
+ popf
+
+ call xtf_main
+
+ /* panic() if xtf_main manages to return. */
+#ifdef __x86_64__
+ lea main_err_msg(%rip), %rdi
+#else
+ push $main_err_msg
+#endif
+ call panic
+SIZE(_start)
+
+.section .rodata.str1, "aMS", @progbits, 1
+
+main_err_msg: .asciz "xtf_main() returned\n"
+SIZE(main_err_msg)
DESTDIR ?= $(ROOT)/dist/
PV_ENVIRONMENTS := pv64 pv32
-ALL_ENVIRONMENTS := $(PV_ENVIRONMENTS)
+HVM_ENVIRONMENTS := hvm64 hvm32
+ALL_ENVIRONMENTS := $(PV_ENVIRONMENTS) $(HVM_ENVIRONMENTS)
pv64_arch := x86_64
pv32_arch := x86_32
+hvm64_arch := x86_64
+hvm32_arch := x86_32
COMMON_FLAGS := -pipe -I$(ROOT)/include -MMD -MP
head-pv64 := $(ROOT)/arch/x86/boot/head_pv64.o
head-pv32 := $(ROOT)/arch/x86/boot/head_pv32.o
+head-hvm64 := $(ROOT)/arch/x86/boot/head_hvm64.o
+head-hvm32 := $(ROOT)/arch/x86/boot/head_hvm32.o
obj-perarch :=
obj-perenv :=
%/head_$(1).o: %/head_pv.S
$$(CC) $$(AFLAGS_$(1)) -c $$< -o $$@
endif
+ifneq ($(findstring $(1),$(HVM_ENVIRONMENTS)),)
+# HVM guests generate head_hvm64.o and head_hvm32.o from head_hvm.S
+%/head_$(1).o: %/head_hvm.S
+ $$(CC) $$(AFLAGS_$(1)) -c $$< -o $$@
+endif
# Generate .lds with approprate flags
%/link-$(1).lds: %/link.lds.S
#if defined(CONFIG_ENV_pv64) || defined(CONFIG_ENV_pv32)
# define CONFIG_ENV_pv
+#elif defined(CONFIG_ENV_hvm64) || defined(CONFIG_ENV_hvm32)
+# define CONFIG_ENV_hvm
#endif
#endif /* XTF_X86_CONFIG_H */