Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Apr 2003 20:23:39 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 28160 for review
Message-ID:  <200304050423.h354Ndbs004250@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28160

Change 28160 by peter@peter_overcee on 2003/04/04 20:22:57

	argh. get exception.s to compile.  Lotsa broken stuff here still,
	its doing stack param passing instead of registers.

Affected files ...

.. //depot/projects/hammer/sys/x86_64/isa/icu_ipl.s#2 edit
.. //depot/projects/hammer/sys/x86_64/isa/icu_vector.s#4 edit
.. //depot/projects/hammer/sys/x86_64/isa/vector.s#5 edit
.. //depot/projects/hammer/sys/x86_64/x86_64/exception.s#11 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/isa/icu_ipl.s#2 (text+ko) ====

@@ -48,7 +48,7 @@
 	SUPERALIGN_TEXT
 
 ENTRY(INTREN)
-	movl	4(%esp), %eax
+	movq	8(%rsp), %rax	# XXX wrong, use regparm
 	movl	%eax, %ecx
 	notl	%eax
 	andl	%eax, imen
@@ -65,7 +65,7 @@
 	ret
 
 ENTRY(INTRDIS)
-	movl	4(%esp), %eax
+	movq	8(%rsp), %rax	# XXX wrong, use regparm
 	movl	%eax, %ecx
 	orl	%eax, imen
 	movl	imen, %eax

==== //depot/projects/hammer/sys/x86_64/isa/icu_vector.s#4 (text+ko) ====

@@ -20,33 +20,48 @@
  * Macros for interrupt interrupt entry, call to handler, and exit.
  */
 
-#define	FAST_INTR(irq_num, vec_name, icu, enable_icus)			\
+#define	FAST_INTR(irq_num, vec_name, enable_icus)			\
 	.text ;								\
 	SUPERALIGN_TEXT ;						\
 IDTVEC(vec_name) ;							\
-	pushl	$0 ;		/* dummy error code */			\
-	pushl	$0 ;		/* dummy trap type */			\
-	pushal ;							\
-	pushl	%ds ;		/* save our data and extra segments */	\
-	pushl	%es ;							\
-	pushl	%fs ;							\
+	pushq	$0 ;		/* dummy error code */			\
+	pushq	$0 ;		/* dummy trap type */			\
+	pushq	%rax ;							\
+	pushq	%rcx ;							\
+	pushq	%rdx ;							\
+	pushq	%rbx ;							\
+	pushq	%rbp ;							\
+	pushq	%rsi ;							\
+	pushq	%rdi ;							\
+	pushq	%r8 ;							\
+	pushq	%r9 ;							\
+	pushq	%r10 ;							\
+	pushq	%r11 ;							\
+	pushq	%r12 ;							\
+	pushq	%r13 ;							\
+	pushq	%r14 ;							\
+	pushq	%r15 ;							\
+	pushq	%ds ;		/* save our data and extra segments */	\
+	pushq	%es ;							\
+	pushq	%fs ;							\
+	pushq	%gs ;							\
 	mov	$KDSEL,%ax ;						\
 	mov	%ax,%ds ;						\
 	mov	%ax,%es ;						\
 	mov	$KPSEL,%ax ;						\
 	mov	%ax,%fs ;						\
-	FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ;			\
+	FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%rsp)) ;			\
 	call	critical_enter ;					\
-	movl	PCPU(CURTHREAD),%ebx ;					\
-	incl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
-	pushl	intr_unit + (irq_num) * 4 ;				\
+	movq	PCPU(CURTHREAD),%rbx ;					\
+	incl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
+	pushq	intr_unit + (irq_num) * 4 ;				\
 	call	*intr_handler + (irq_num) * 4 ;	/* do the work ASAP */	\
 	enable_icus ;		/* (re)enable ASAP (helps edge trigger?) */ \
-	addl	$4,%esp ;						\
+	addq	$8,%rsp ;						\
 	incl	cnt+V_INTR ;	/* book-keeping can wait */		\
-	movl	intr_countp + (irq_num) * 4,%eax ;			\
-	incl	(%eax) ;						\
-	decl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
+	movq	intr_countp + (irq_num) * 4,%rax ;			\
+	incq	(%rax) ;						\
+	decl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
 	call	critical_exit ;						\
 	MEXITCOUNT ;							\
 	jmp	doreti
@@ -60,16 +75,31 @@
  * interrupt handler and don't run anything.  We could just do an
  * iret.  FIXME.
  */
-#define	INTR(irq_num, vec_name, icu, enable_icus, maybe_extra_ipending) \
+#define	INTR(irq_num, vec_name, enable_icus, maybe_extra_ipending) \
 	.text ;								\
 	SUPERALIGN_TEXT ;						\
 IDTVEC(vec_name) ;							\
-	pushl	$0 ;		/* dummy error code */			\
-	pushl	$0 ;		/* dummy trap type */			\
-	pushal ;							\
-	pushl	%ds ;		/* save our data and extra segments */	\
-	pushl	%es ;							\
-	pushl	%fs ;							\
+	pushq	$0 ;		/* dummy error code */			\
+	pushq	$0 ;		/* dummy trap type */			\
+	pushq	%rax ;							\
+	pushq	%rcx ;							\
+	pushq	%rdx ;							\
+	pushq	%rbx ;							\
+	pushq	%rbp ;							\
+	pushq	%rsi ;							\
+	pushq	%rdi ;							\
+	pushq	%r8 ;							\
+	pushq	%r9 ;							\
+	pushq	%r10 ;							\
+	pushq	%r11 ;							\
+	pushq	%r12 ;							\
+	pushq	%r13 ;							\
+	pushq	%r14 ;							\
+	pushq	%r15 ;							\
+	pushq	%ds ;		/* save our data and extra segments */	\
+	pushq	%es ;							\
+	pushq	%fs ;							\
+	pushq	%gs ;							\
 	mov	$KDSEL,%ax ;	/* load kernel ds, es and fs */		\
 	mov	%ax,%ds ;						\
 	mov	%ax,%es ;						\
@@ -79,15 +109,15 @@
 	movb	imen + IRQ_BYTE(irq_num),%al ;				\
 	orb	$IRQ_BIT(irq_num),%al ;					\
 	movb	%al,imen + IRQ_BYTE(irq_num) ;				\
-	outb	%al,$icu+ICU_IMR_OFFSET ;				\
+	#XXXoutb	%al,$icu+ICU_IMR_OFFSET ;				\
 	enable_icus ;							\
-	movl	PCPU(CURTHREAD),%ebx ;					\
+	movq	PCPU(CURTHREAD),%rbx ;					\
 	incl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
-	FAKE_MCOUNT(13*4(%esp)) ;	/* XXX late to avoid double count */ \
-	pushl	$irq_num; 	/* pass the IRQ */			\
+	FAKE_MCOUNT(13*4(%rsp)) ;	/* XXX late to avoid double count */ \
+	pushq	$irq_num; 	/* pass the IRQ */			\
 	call	sched_ithd ;						\
-	addl	$4, %esp ;	/* discard the parameter */		\
-	decl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
+	addq	$8, %rsp ;	/* discard the parameter */		\
+	decl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
 	MEXITCOUNT ;							\
 	/* We could usually avoid the following jmp by inlining some of */ \
 	/* doreti, but it's probably better to use less cache. */	\

==== //depot/projects/hammer/sys/x86_64/isa/vector.s#5 (text+ko) ====

@@ -91,4 +91,4 @@
  * loading segregs.
  */
 
-#include "i386/isa/icu_vector.s"
+#include "x86_64/isa/icu_vector.s"

==== //depot/projects/hammer/sys/x86_64/x86_64/exception.s#11 (text+ko) ====

@@ -74,29 +74,29 @@
  */
 #define	IDTVEC(name)	ALIGN_TEXT; .globl __CONCAT(X,name); \
 			.type __CONCAT(X,name),@function; __CONCAT(X,name):
-#define	TRAP(a)		pushl $(a) ; jmp alltraps
+#define	TRAP(a)		pushq $(a) ; jmp alltraps
 
 MCOUNT_LABEL(user)
 MCOUNT_LABEL(btrap)
 
 IDTVEC(div)
-	pushl $0; TRAP(T_DIVIDE)
+	pushq $0; TRAP(T_DIVIDE)
 IDTVEC(dbg)
-	pushl $0; TRAP(T_TRCTRAP)
+	pushq $0; TRAP(T_TRCTRAP)
 IDTVEC(nmi)
-	pushl $0; TRAP(T_NMI)
+	pushq $0; TRAP(T_NMI)
 IDTVEC(bpt)
-	pushl $0; TRAP(T_BPTFLT)
+	pushq $0; TRAP(T_BPTFLT)
 IDTVEC(ofl)
-	pushl $0; TRAP(T_OFLOW)
+	pushq $0; TRAP(T_OFLOW)
 IDTVEC(bnd)
-	pushl $0; TRAP(T_BOUND)
+	pushq $0; TRAP(T_BOUND)
 IDTVEC(ill)
-	pushl $0; TRAP(T_PRIVINFLT)
+	pushq $0; TRAP(T_PRIVINFLT)
 IDTVEC(dna)
-	pushl $0; TRAP(T_DNA)
+	pushq $0; TRAP(T_DNA)
 IDTVEC(fpusegm)
-	pushl $0; TRAP(T_FPOPFLT)
+	pushq $0; TRAP(T_FPOPFLT)
 IDTVEC(tss)
 	TRAP(T_TSSFLT)
 IDTVEC(missing)
@@ -108,16 +108,16 @@
 IDTVEC(page)
 	TRAP(T_PAGEFLT)
 IDTVEC(mchk)
-	pushl $0; TRAP(T_MCHK)
+	pushq $0; TRAP(T_MCHK)
 IDTVEC(rsvd)
-	pushl $0; TRAP(T_RESERVED)
+	pushq $0; TRAP(T_RESERVED)
 IDTVEC(fpu)
-	pushl $0; TRAP(T_ARITHTRAP)
+	pushq $0; TRAP(T_ARITHTRAP)
 IDTVEC(align)
 	TRAP(T_ALIGNFLT)
 
 IDTVEC(xmm)
-	pushl $0; TRAP(T_XMMFLT)
+	pushq $0; TRAP(T_XMMFLT)
 	
 	/*
 	 * alltraps entry point.  Interrupts are enabled if this was a trap
@@ -130,17 +130,31 @@
 	.globl	alltraps
 	.type	alltraps,@function
 alltraps:
-	pushal
-	pushl	%ds
-	pushl	%es
-	pushl	%fs
+	pushq	%rax
+	pushq	%rcx
+	pushq	%rdx
+	pushq	%rbx
+	pushq	%rbp
+	pushq	%rsi
+	pushq	%rdi
+	pushq	%r8
+	pushq	%r9
+	pushq	%r10
+	pushq	%r11
+	pushq	%r12
+	pushq	%r13
+	pushq	%r14
+	pushq	%r15
+	pushq	%ds
+	pushq	%es
+	pushq	%fs
 alltraps_with_regs_pushed:
 	mov	$KDSEL,%ax
 	mov	%ax,%ds
 	mov	%ax,%es
 	mov	$KPSEL,%ax
 	mov	%ax,%fs
-	FAKE_MCOUNT(13*4(%esp))
+	FAKE_MCOUNT(13*4(%rsp))
 calltrap:
 	FAKE_MCOUNT(btrap)		/* init "from" btrap -> calltrap */
 	call	trap
@@ -165,20 +179,35 @@
  */
 	SUPERALIGN_TEXT
 IDTVEC(lcall_syscall)
-	pushfl				/* save eflags */
-	popl	8(%esp)			/* shuffle into tf_eflags */
-	pushl	$7			/* sizeof "lcall 7,0" */
-	subl	$4,%esp			/* skip over tf_trapno */
-	pushal
-	pushl	%ds
-	pushl	%es
-	pushl	%fs
+	pushfq				/* save eflags */
+	popq	16(%rsp)		/* shuffle into tf_eflags */
+	pushq	$7			/* sizeof "lcall 7,0" */
+	subq	$8,%rsp			/* skip over tf_trapno */
+	pushq	%rax
+	pushq	%rcx
+	pushq	%rdx
+	pushq	%rbx
+	pushq	%rbp
+	pushq	%rsi
+	pushq	%rdi
+	pushq	%r8
+	pushq	%r9
+	pushq	%r10
+	pushq	%r11
+	pushq	%r12
+	pushq	%r13
+	pushq	%r14
+	pushq	%r15
+	pushq	%ds
+	pushq	%ds
+	pushq	%es
+	pushq	%fs
 	mov	$KDSEL,%ax		/* switch to kernel segments */
 	mov	%ax,%ds
 	mov	%ax,%es
 	mov	$KPSEL,%ax
 	mov	%ax,%fs
-	FAKE_MCOUNT(13*4(%esp))
+	FAKE_MCOUNT(13*4(%rsp))
 	call	syscall
 	MEXITCOUNT
 	jmp	doreti
@@ -192,31 +221,45 @@
  */
 	SUPERALIGN_TEXT
 IDTVEC(int0x80_syscall)
-	pushl	$2			/* sizeof "int 0x80" */
-	subl	$4,%esp			/* skip over tf_trapno */
-	pushal
-	pushl	%ds
-	pushl	%es
-	pushl	%fs
+	pushq	$2			/* sizeof "int 0x80" */
+	subq	$8,%rsp			/* skip over tf_trapno */
+	pushq	%rax
+	pushq	%rcx
+	pushq	%rdx
+	pushq	%rbx
+	pushq	%rbp
+	pushq	%rsi
+	pushq	%rdi
+	pushq	%r8
+	pushq	%r9
+	pushq	%r10
+	pushq	%r11
+	pushq	%r12
+	pushq	%r13
+	pushq	%r14
+	pushq	%r15
+	pushq	%ds
+	pushq	%es
+	pushq	%fs
 	mov	$KDSEL,%ax		/* switch to kernel segments */
 	mov	%ax,%ds
 	mov	%ax,%es
 	mov	$KPSEL,%ax
 	mov	%ax,%fs
-	FAKE_MCOUNT(13*4(%esp))
+	FAKE_MCOUNT(13*4(%rsp))
 	call	syscall
 	MEXITCOUNT
 	jmp	doreti
 
 ENTRY(fork_trampoline)
-	pushl	%esp			/* trapframe pointer */
-	pushl	%ebx			/* arg1 */
-	pushl	%esi			/* function */
-	movl    PCPU(CURTHREAD),%ebx	/* setup critnest */
-	movl	$1,TD_CRITNEST(%ebx)
+	pushq	%rsp			/* trapframe pointer */
+	pushq	%rbx			/* arg1 */
+	pushq	%rsi			/* function */
+	movq	PCPU(CURTHREAD),%rbx	/* setup critnest */
+	movl	$1,TD_CRITNEST(%rbx)
 	sti				/* enable interrupts */
 	call	fork_exit
-	addl	$12,%esp
+	addq	$24,%rsp
 	/* cut from syscall */
 
 	/*
@@ -250,7 +293,7 @@
 	/*
 	 * Check if ASTs can be handled now.
 	 */
-	testb	$SEL_RPL_MASK,TF_CS(%esp) /* are we returning to user mode? */
+	testb	$SEL_RPL_MASK,TF_CS(%rsp) /* are we returning to user mode? */
 	jz	doreti_exit		/* can't handle ASTs now if not */
 
 doreti_ast:
@@ -260,13 +303,13 @@
 	 * since we will be informed of any new ASTs by an IPI.
 	 */
 	cli
-	movl	PCPU(CURTHREAD),%eax
-	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%eax)
+	movq	PCPU(CURTHREAD),%rax
+	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
 	je	doreti_exit
 	sti
-	pushl	%esp			/* pass a pointer to the trapframe */
+	pushq	%rsp			/* pass a pointer to the trapframe */
 	call	ast
-	add	$4,%esp
+	addq	$8,%rsp
 	jmp	doreti_ast
 
 	/*
@@ -281,15 +324,29 @@
 
 	.globl	doreti_popl_fs
 doreti_popl_fs:
-	popl	%fs
+	popq	%fs
 	.globl	doreti_popl_es
 doreti_popl_es:
-	popl	%es
+	popq	%es
 	.globl	doreti_popl_ds
 doreti_popl_ds:
-	popl	%ds
-	popal
-	addl	$8,%esp
+	popq	%ds
+	popq	%r15
+	popq	%r14
+	popq	%r13
+	popq	%r12
+	popq	%r11
+	popq	%r10
+	popq	%r9
+	popq	%r8
+	popq	%rdi
+	popq	%rsi
+	popq	%rbp
+	popq	%rbx
+	popq	%rdx
+	popq	%rcx
+	popq	%rax
+	addq	$16,%rsp
 	.globl	doreti_iret
 doreti_iret:
 	iret
@@ -304,19 +361,33 @@
 	ALIGN_TEXT
 	.globl	doreti_iret_fault
 doreti_iret_fault:
-	subl	$8,%esp
-	pushal
-	pushl	%ds
+	subq	$16,%rsp
+	pushq	%rax
+	pushq	%rcx
+	pushq	%rdx
+	pushq	%rbx
+	pushq	%rbp
+	pushq	%rsi
+	pushq	%rdi
+	pushq	%r8
+	pushq	%r9
+	pushq	%r10
+	pushq	%r11
+	pushq	%r12
+	pushq	%r13
+	pushq	%r14
+	pushq	%r15
+	pushq	%ds
 	.globl	doreti_popl_ds_fault
 doreti_popl_ds_fault:
-	pushl	%es
+	pushq	%es
 	.globl	doreti_popl_es_fault
 doreti_popl_es_fault:
-	pushl	%fs
+	pushq	%fs
 	.globl	doreti_popl_fs_fault
 doreti_popl_fs_fault:
-	movl	$0,TF_ERR(%esp)	/* XXX should be the error code */
-	movl	$T_PROTFLT,TF_TRAPNO(%esp)
+	movq	$0,TF_ERR(%rsp)	/* XXX should be the error code */
+	movq	$T_PROTFLT,TF_TRAPNO(%rsp)
 	jmp	alltraps_with_regs_pushed
 
 #include "x86_64/isa/icu_ipl.s"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304050423.h354Ndbs004250>