Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Sep 2003 18:16:05 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 38822 for review
Message-ID:  <200309300116.h8U1G5xH026752@repoman.freebsd.org>

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

Change 38822 by peter@peter_hammer on 2003/09/29 18:15:57

	make this compile

Affected files ...

.. //depot/projects/hammer/sys/amd64/amd64/apic_vector.s#4 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/amd64/apic_vector.s#4 (text+ko) ====

@@ -49,19 +49,65 @@
  * Macros to create and destroy a trap frame.
  */
 #define PUSH_FRAME							\
-	pushl	$0 ;		/* dummy error code */			\
-	pushl	$0 ;		/* dummy trap type */			\
-	pushal ;		/* 8 ints */				\
-	pushl	%ds ;		/* save data and extra segments ... */	\
-	pushl	%es ;							\
-	pushl	%fs
+	subq	$TF_RIP,%rsp ;	/* skip dummy tf_err and tf_trapno */	\
+	testb	$SEL_RPL_MASK,TF_CS(%rsp) ; /* come from kernel? */	\
+	jz	1f ;		/* Yes, dont swapgs again */		\
+	swapgs ;							\
+1:	movq	%rdi,TF_RDI(%rsp) ;					\
+	movq	%rsi,TF_RSI(%rsp) ;					\
+	movq	%rdx,TF_RDX(%rsp) ;					\
+	movq	%rcx,TF_RCX(%rsp) ;					\
+	movq	%r8,TF_R8(%rsp) ;					\
+	movq	%r9,TF_R9(%rsp) ;					\
+	movq	%rax,TF_RAX(%rsp) ;					\
+	movq	%rbx,TF_RBX(%rsp) ;					\
+	movq	%rbp,TF_RBP(%rsp) ;					\
+	movq	%r10,TF_R10(%rsp) ;					\
+	movq	%r11,TF_R11(%rsp) ;					\
+	movq	%r12,TF_R12(%rsp) ;					\
+	movq	%r13,TF_R13(%rsp) ;					\
+	movq	%r14,TF_R14(%rsp) ;					\
+	movq	%r15,TF_R15(%rsp)					\
+
+#if 0
+	maybe_extra_ipending ;						\
+	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 ;				\
+	enable_icus ;							\
+	movq	PCPU(CURTHREAD),%rbx ;					\
+	incl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
+	FAKE_MCOUNT(13*4(%rsp)) ;	/* XXX late to avoid double count */ \
+	movq	$irq_num, %rdi;	/* pass the IRQ */			\
+	call	sched_ithd ;						\
+	decl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
+	MEXITCOUNT ;							\
+	jmp	doreti
+#endif
 
 #define POP_FRAME							\
-	popl	%fs ;							\
-	popl	%es ;							\
-	popl	%ds ;							\
-	popal ;								\
-	addl	$4+4,%esp
+	movq	TF_RDI(%rsp),%rdi ;					\
+	movq	TF_RSI(%rsp),%rsi ;					\
+	movq	TF_RDX(%rsp),%rdx ;					\
+	movq	TF_RCX(%rsp),%rcx ;					\
+	movq	TF_R8(%rsp),%r8 ;					\
+	movq	TF_R9(%rsp),%r9 ;					\
+	movq	TF_RAX(%rsp),%rax ;					\
+	movq	TF_RBX(%rsp),%rbx ;					\
+	movq	TF_RBP(%rsp),%rbp ;					\
+	movq	TF_R10(%rsp),%r10 ;					\
+	movq	TF_R11(%rsp),%r11 ;					\
+	movq	TF_R12(%rsp),%r12 ;					\
+	movq	TF_R13(%rsp),%r13 ;					\
+	movq	TF_R14(%rsp),%r14 ;					\
+	movq	TF_R15(%rsp),%r15 ;					\
+	testb	$SEL_RPL_MASK,TF_CS(%rsp) ; /* come from kernel? */	\
+	jz	1f ;		/* keep kernel GS.base */		\
+	cli ;								\
+	swapgs ;							\
+1:	addq	$TF_RIP,%rsp	/* skip over tf_err, tf_trapno */
+
 
 /*
  * I/O Interrupt Entry Point.  Rather than having one entry point for
@@ -75,24 +121,18 @@
 	SUPERALIGN_TEXT ;						\
 IDTVEC(vec_name) ;							\
 	PUSH_FRAME ;							\
-	movl	$KDSEL, %eax ;	/* reload with kernel's data segment */	\
-	mov	%ax, %ds ;						\
-	mov	%ax, %es ;						\
-	movl	$KPSEL, %eax ;	/* reload with per-CPU data segment */	\
-	mov	%ax, %fs ;						\
-	movl	lapic, %edx ;	/* pointer to local APIC */		\
-	movl	PCPU(CURTHREAD), %ebx ;					\
-	movl	LA_ISR + 16 * (index)(%edx), %eax ;	/* load ISR */	\
-	incl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
+	movq	lapic, %rdx ;	/* pointer to local APIC */		\
+	movq	PCPU(CURTHREAD), %rbx ;					\
+	movl	LA_ISR + 16 * (index)(%rdx), %eax ;	/* load ISR */	\
+	incl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
 	bsrl	%eax, %eax ;	/* index of highset set bit in ISR */	\
 	jz	2f ;							\
 	addl	$(32 * (index - 1)),%eax ;				\
 1: ;									\
 	FAKE_MCOUNT(13*4(%esp)) ;	/* XXX avoid double count */	\
-	pushl	%eax ;		/* pass the IRQ */			\
+	movq	%rax, %rdi ;	/* pass the IRQ */			\
 	call	lapic_handle_intr ;					\
-	addl	$4, %esp ;	/* discard parameter */			\
-	decl	TD_INTR_NESTING_LEVEL(%ebx) ;				\
+	decl	TD_INTR_NESTING_LEVEL(%rbx) ;				\
 	MEXITCOUNT ;							\
 	jmp	doreti ;						\
 2:	movl	$-1, %eax ;	/* send a vector of -1 */		\
@@ -111,7 +151,7 @@
 
 	/* No EOI cycle used here */
 
-	iret
+	iretq
 
 MCOUNT_LABEL(bintr)
 	ISR_VEC(1,apic_isr1)
@@ -128,23 +168,19 @@
 	.text
 	SUPERALIGN_TEXT
 IDTVEC(invltlb)
-	pushl	%eax
-	pushl	%ds
-	movl	$KDSEL, %eax		/* Kernel data selector */
-	mov	%ax, %ds
+	pushq	%rax
 
-	movl	%cr3, %eax		/* invalidate the TLB */
-	movl	%eax, %cr3
+	movq	%cr3, %rax		/* invalidate the TLB */
+	movq	%rax, %cr3
 
-	movl	lapic, %eax
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
+	movq	lapic, %rax
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
 
 	lock
 	incl	smp_tlb_wait
 
-	popl	%ds
-	popl	%eax
-	iret
+	popq	%rax
+	iretq
 
 /*
  * Single page TLB shootdown
@@ -152,23 +188,19 @@
 	.text
 	SUPERALIGN_TEXT
 IDTVEC(invlpg)
-	pushl	%eax
-	pushl	%ds
-	movl	$KDSEL, %eax		/* Kernel data selector */
-	mov	%ax, %ds
+	pushq	%rax
 
-	movl	smp_tlb_addr1, %eax
-	invlpg	(%eax)			/* invalidate single page */
+	movq	smp_tlb_addr1, %rax
+	invlpg	(%rax)			/* invalidate single page */
 
-	movl	lapic, %eax
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
+	movq	lapic, %rax
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
 
 	lock
 	incl	smp_tlb_wait
 
-	popl	%ds
-	popl	%eax
-	iret
+	popq	%rax
+	iretq
 
 /*
  * Page range TLB shootdown.
@@ -176,29 +208,25 @@
 	.text
 	SUPERALIGN_TEXT
 IDTVEC(invlrng)
-	pushl	%eax
-	pushl	%edx
-	pushl	%ds
-	movl	$KDSEL, %eax		/* Kernel data selector */
-	mov	%ax, %ds
+	pushq	%rax
+	pushq	%rdx
 
-	movl	smp_tlb_addr1, %edx
-	movl	smp_tlb_addr2, %eax
-1:	invlpg	(%edx)			/* invalidate single page */
-	addl	$PAGE_SIZE, %edx
-	cmpl	%eax, %edx
+	movq	smp_tlb_addr1, %rdx
+	movq	smp_tlb_addr2, %rax
+1:	invlpg	(%rdx)			/* invalidate single page */
+	addq	$PAGE_SIZE, %rdx
+	cmpq	%rax, %rdx
 	jb	1b
 
-	movl	lapic, %eax
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
+	movq	lapic, %rax
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
 
 	lock
 	incl	smp_tlb_wait
 
-	popl	%ds
-	popl	%edx
-	popl	%eax
-	iret
+	popq	%rdx
+	popq	%rax
+	iretq
 
 /*
  * Forward hardclock to another CPU.  Pushes a clockframe and calls
@@ -208,21 +236,16 @@
 	SUPERALIGN_TEXT
 IDTVEC(hardclock)
 	PUSH_FRAME
-	movl	$KDSEL, %eax	/* reload with kernel's data segment */
-	mov	%ax, %ds
-	mov	%ax, %es
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
 
-	movl	lapic, %edx
-	movl	$0, LA_EOI(%edx)	/* End Of Interrupt to APIC */
+	movq	lapic, %rdx
+	movl	$0, LA_EOI(%rdx)	/* End Of Interrupt to APIC */
 
-	movl	PCPU(CURTHREAD),%ebx
-	incl	TD_INTR_NESTING_LEVEL(%ebx)
-	pushl	$0		/* XXX convert trapframe to clockframe */
+	movq	PCPU(CURTHREAD),%rbx
+	incl	TD_INTR_NESTING_LEVEL(%rbx)
+	pushq	$0		/* XXX convert trapframe to clockframe */
 	call	forwarded_hardclock
-	addl	$4, %esp	/* XXX convert clockframe to trapframe */
-	decl	TD_INTR_NESTING_LEVEL(%ebx)
+	addq	$8, %rsp	/* XXX convert clockframe to trapframe */
+	decl	TD_INTR_NESTING_LEVEL(%rbx)
 	MEXITCOUNT
 	jmp	doreti
 
@@ -234,23 +257,18 @@
 	SUPERALIGN_TEXT
 IDTVEC(statclock)
 	PUSH_FRAME
-	movl	$KDSEL, %eax	/* reload with kernel's data segment */
-	mov	%ax, %ds
-	mov	%ax, %es
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
 
-	movl	lapic, %edx
-	movl	$0, LA_EOI(%edx)	/* End Of Interrupt to APIC */
+	movq	lapic, %rdx
+	movl	$0, LA_EOI(%rdx)	/* End Of Interrupt to APIC */
 
 	FAKE_MCOUNT(13*4(%esp))
 
-	movl	PCPU(CURTHREAD),%ebx
-	incl	TD_INTR_NESTING_LEVEL(%ebx)
-	pushl	$0		/* XXX convert trapframe to clockframe */
+	movq	PCPU(CURTHREAD),%rbx
+	incl	TD_INTR_NESTING_LEVEL(%rbx)
+	pushq	$0		/* XXX convert trapframe to clockframe */
 	call	forwarded_statclock
-	addl	$4, %esp	/* XXX convert clockframe to trapframe */
-	decl	TD_INTR_NESTING_LEVEL(%ebx)
+	addq	$8, %rsp	/* XXX convert clockframe to trapframe */
+	decl	TD_INTR_NESTING_LEVEL(%rbx)
 	MEXITCOUNT
 	jmp	doreti
 
@@ -266,14 +284,9 @@
 	SUPERALIGN_TEXT
 IDTVEC(cpuast)
 	PUSH_FRAME
-	movl	$KDSEL, %eax
-	mov	%ax, %ds		/* use KERNEL data segment */
-	mov	%ax, %es
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
 
-	movl	lapic, %edx
-	movl	$0, LA_EOI(%edx)	/* End Of Interrupt to APIC */
+	movq	lapic, %rdx
+	movl	$0, LA_EOI(%rdx)	/* End Of Interrupt to APIC */
 
 	FAKE_MCOUNT(13*4(%esp))
 
@@ -290,60 +303,41 @@
 	.text
 	SUPERALIGN_TEXT
 IDTVEC(cpustop)
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%eax
-	pushl	%ecx
-	pushl	%edx
-	pushl	%ds			/* save current data segment */
-	pushl	%fs
+	PUSH_FRAME
 
-	movl	$KDSEL, %eax
-	mov	%ax, %ds		/* use KERNEL data segment */
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
+	movq	lapic, %rax
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
 
-	movl	lapic, %eax
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
-
 	movl	PCPU(CPUID), %eax
 	imull	$PCB_SIZE, %eax
-	leal	CNAME(stoppcbs)(%eax), %eax
-	pushl	%eax
-	call	CNAME(savectx)		/* Save process context */
-	addl	$4, %esp
+	leaq	stoppcbs(%rax), %rdi
+	call	savectx			/* Save process context */
 		
 	movl	PCPU(CPUID), %eax
 
 	lock
-	btsl	%eax, CNAME(stopped_cpus) /* stopped_cpus |= (1<<id) */
+	btsl	%eax, stopped_cpus	/* stopped_cpus |= (1<<id) */
 1:
-	btl	%eax, CNAME(started_cpus) /* while (!(started_cpus & (1<<id))) */
+	btl	%eax, started_cpus	/* while (!(started_cpus & (1<<id))) */
 	jnc	1b
 
 	lock
-	btrl	%eax, CNAME(started_cpus) /* started_cpus &= ~(1<<id) */
+	btrl	%eax, started_cpus	/* started_cpus &= ~(1<<id) */
 	lock
-	btrl	%eax, CNAME(stopped_cpus) /* stopped_cpus &= ~(1<<id) */
+	btrl	%eax, stopped_cpus	/* stopped_cpus &= ~(1<<id) */
 
 	test	%eax, %eax
 	jnz	2f
 
-	movl	CNAME(cpustop_restartfunc), %eax
-	test	%eax, %eax
+	movq	cpustop_restartfunc, %rax
+	testq	%rax, %rax
 	jz	2f
-	movl	$0, CNAME(cpustop_restartfunc)	/* One-shot */
+	movq	$0, cpustop_restartfunc	/* One-shot */
 
-	call	*%eax
+	call	*%rax
 2:
-	popl	%fs
-	popl	%ds			/* restore previous data segment */
-	popl	%edx
-	popl	%ecx
-	popl	%eax
-	movl	%ebp, %esp
-	popl	%ebp
-	iret
+	POP_FRAME
+	iretq
 
 /*
  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
@@ -354,18 +348,11 @@
 	SUPERALIGN_TEXT
 IDTVEC(rendezvous)
 	PUSH_FRAME
-	movl	$KDSEL, %eax
-	mov	%ax, %ds		/* use KERNEL data segment */
-	mov	%ax, %es
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
-
 	call	smp_rendezvous_action
-
-	movl	lapic, %eax
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
-	POP_FRAME
-	iret
+	movq	lapic, %rax
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
+	POP_FRAME			/* Why not doreti? */
+	iretq
 	
 /*
  * Clean up when we lose out on the lazy context switch optimization.
@@ -374,16 +361,9 @@
 	SUPERALIGN_TEXT
 IDTVEC(lazypmap)
 	PUSH_FRAME
-	movl	$KDSEL, %eax
-	mov	%ax, %ds		/* use KERNEL data segment */
-	mov	%ax, %es
-	movl	$KPSEL, %eax
-	mov	%ax, %fs
-
 	call	pmap_lazyfix_action
-
-	movl	lapic, %eax	
-	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
-	POP_FRAME
-	iret
+	movq	lapic, %rax	
+	movl	$0, LA_EOI(%rax)	/* End Of Interrupt to APIC */
+	POP_FRAME			/* Why not doreti? */
+	iretq
 #endif /* SMP */



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