NetBSD/sys/arch/xen/include/frameasm.h
bouyer 8f162b7ed8 Snapshot of work in progress on NetBSD port to Xen3:
- kernel (both dom0 and domU) boot, console is functionnal and it can starts
  software from a ramdisk
- there is no driver front-end expect console for domU yet.
- dom0 can probe devices and ex(4) work when Xen3 is booted without acpi
  and apic support. But the on-board IDE doens't get interrupts.
  The PCI code still needs work (it's hardcoded to mode 1). Some of this
  code should be shared with ../x86
  The physical insterrupt code needs to get MPBIOS and ACPI support, and
  do interrupt routing to properly interract with Xen.
To enable Xen-3.0 support, add
options XEN3
to your kernel config file (this will disable Xen2 support)
Changes affecting Xen-2.0 support (no functionnal changes intended):
- get more constants from genassym for assembly code
- remove some unneeded registers move from start()
- map the shared info page from start(), and remove the pte = 0xffffffff hack
- vector.S: in hypervisor_callback() make sure %esi points to
  HYPERVISOR_shared_info before accessing the info page. Remplace some
  hand-written assembly with the equivalent macro defined in frameasm.h
- more debug code, dissabled by default.

while here added my copyright on some files I worked on in 2005.
2006-01-15 22:09:51 +00:00

124 lines
3.0 KiB
C

/* $NetBSD: frameasm.h,v 1.4 2006/01/15 22:09:51 bouyer Exp $ */
/* NetBSD: frameasm.h,v 1.4 2004/02/20 17:35:01 yamt Exp */
#ifndef _I386_FRAMEASM_H_
#define _I386_FRAMEASM_H_
#ifdef _KERNEL_OPT
#include "opt_multiprocessor.h"
#include "opt_xen.h"
#endif
/* XXX assym.h */
#define TRAP_INSTR int $0x82
#ifndef TRAPLOG
#define TLOG /**/
#else
/*
* Fill in trap record
*/
#define TLOG \
9: \
movl %fs:CPU_TLOG_OFFSET, %eax; \
movl %fs:CPU_TLOG_BASE, %ebx; \
addl $SIZEOF_TREC,%eax; \
andl $SIZEOF_TLOG-1,%eax; \
addl %eax,%ebx; \
movl %eax,%fs:CPU_TLOG_OFFSET; \
movl %esp,TREC_SP(%ebx); \
movl $9b,TREC_HPC(%ebx); \
movl TF_EIP(%esp),%eax; \
movl %eax,TREC_IPC(%ebx); \
rdtsc ; \
movl %eax,TREC_TSC(%ebx); \
movl $MSR_LASTBRANCHFROMIP,%ecx; \
rdmsr ; \
movl %eax,TREC_LBF(%ebx); \
incl %ecx ; \
rdmsr ; \
movl %eax,TREC_LBT(%ebx); \
incl %ecx ; \
rdmsr ; \
movl %eax,TREC_IBF(%ebx); \
incl %ecx ; \
rdmsr ; \
movl %eax,TREC_IBT(%ebx)
#endif
/*
* These are used on interrupt or trap entry or exit.
*/
#define INTRENTRY \
cld; \
subl $TF_PUSHSIZE,%esp ; \
movl %gs,TF_GS(%esp) ; \
movl %fs,TF_FS(%esp) ; \
movl %eax,TF_EAX(%esp) ; \
movl %es,TF_ES(%esp) ; \
movl %ds,TF_DS(%esp) ; \
movl $GSEL(GDATA_SEL, SEL_KPL),%eax ; \
movl %edi,TF_EDI(%esp) ; \
movl %esi,TF_ESI(%esp) ; \
movl %eax,%ds ; \
movl %ebp,TF_EBP(%esp) ; \
movl %eax,%es ; \
movl %ebx,TF_EBX(%esp) ; \
movl %eax,%gs ; \
movl %edx,TF_EDX(%esp) ; \
movl $GSEL(GCPU_SEL, SEL_KPL),%eax ; \
movl %ecx,TF_ECX(%esp) ; \
movl %eax,%fs ; \
TLOG
#define INTRFASTEXIT \
movl TF_GS(%esp),%gs ; \
movl TF_FS(%esp),%fs ; \
movl TF_ES(%esp),%es ; \
movl TF_DS(%esp),%ds ; \
movl TF_EDI(%esp),%edi ; \
movl TF_ESI(%esp),%esi ; \
movl TF_EBP(%esp),%ebp ; \
movl TF_EBX(%esp),%ebx ; \
movl TF_EDX(%esp),%edx ; \
movl TF_ECX(%esp),%ecx ; \
movl TF_EAX(%esp),%eax ; \
addl $(TF_PUSHSIZE+8),%esp ; \
iret
#define DO_DEFERRED_SWITCH(reg) \
cmpl $0, CPUVAR(WANT_PMAPLOAD) ; \
jz 1f ; \
call _C_LABEL(pmap_load) ; \
1:
#define CHECK_DEFERRED_SWITCH(reg) \
cmpl $0, CPUVAR(WANT_PMAPLOAD)
#define CHECK_ASTPENDING(reg) movl CPUVAR(CURLWP),reg ; \
cmpl $0, reg ; \
je 1f ; \
movl L_PROC(reg),reg ; \
cmpl $0, P_MD_ASTPENDING(reg); \
1:
#define CLEAR_ASTPENDING(reg) movl $0, P_MD_ASTPENDING(reg)
#if !defined(XEN)
#define CLI(reg) cli
#define STI(reg) sti
#else
#define XEN_BLOCK_EVENTS(reg) movb $1,EVTCHN_UPCALL_MASK(reg)
#define XEN_UNBLOCK_EVENTS(reg) movb $0,EVTCHN_UPCALL_MASK(reg)
#define XEN_TEST_PENDING(reg) testb $0xFF,EVTCHN_UPCALL_PENDING(reg)
#define CLI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
XEN_BLOCK_EVENTS(reg)
#define STI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
XEN_UNBLOCK_EVENTS(reg)
#define STIC(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
XEN_UNBLOCK_EVENTS(reg) ; \
testb $0xff,EVTCHN_UPCALL_PENDING(reg)
#endif
#endif /* _I386_FRAMEASM_H_ */