Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 17 05:41:57 UTC 2024

Modified Files:
        src/sys/arch/m68k/m68k: switch_subr.s

Log Message:
cpu_switchto(): No need for the pmap_activate() dance here; it's
already done for us in mi_switch().


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/m68k/m68k/switch_subr.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/m68k/m68k/switch_subr.s
diff -u src/sys/arch/m68k/m68k/switch_subr.s:1.36 src/sys/arch/m68k/m68k/switch_subr.s:1.37
--- src/sys/arch/m68k/m68k/switch_subr.s:1.36	Tue Sep 26 14:33:55 2023
+++ src/sys/arch/m68k/m68k/switch_subr.s	Wed Jan 17 05:41:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: switch_subr.s,v 1.36 2023/09/26 14:33:55 tsutsui Exp $	*/
+/*	$NetBSD: switch_subr.s,v 1.37 2024/01/17 05:41:57 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation.
@@ -88,7 +88,7 @@ GLOBAL(_Idle)				/* For sun2/sun3's cloc
  * Switch to the specific next LWP.
  */
 ENTRY(cpu_switchto)
-	movl	4(%sp),%a1		| fetch `current' lwp
+	movl	4(%sp),%a1		| fetch outgoing lwp
 	/*
 	 * Save state of previous process in its pcb.
 	 */
@@ -133,78 +133,38 @@ ENTRY(cpu_switchto)
 #endif	/* !_M68K_CUSTOM_FPU_CTX */
 
 	movl	8(%sp),%a0		| get newlwp
-	movl	%a0,_C_LABEL(curlwp)
+	movl	%a0,_C_LABEL(curlwp)	| curlwp = new lwp
 	movl	L_PCB(%a0),%a1		| get its pcb
-	movl	%a1,_C_LABEL(curpcb)
+	movl	%a1,_C_LABEL(curpcb)	| curpcb = new pcb
 
-#if defined(sun2) || defined(sun3)
-	movl	L_PROC(%a0),%a2
-	movl	P_VMSPACE(%a2),%a2	| vm = p->p_vmspace
-#if defined(DIAGNOSTIC) && !defined(sun2)
-	tstl	%a2			| vm == VM_MAP_NULL?
-	jeq	.Lcpu_switch_badsw	| panic
-#endif
-	pea	(%a0)			| save newlwp
-#if !defined(_SUN3X_) || defined(PMAP_DEBUG)
-	movl	VM_PMAP(%a2),-(%sp)	| push vm->vm_map.pmap
-	jbsr	_C_LABEL(_pmap_switch)	| _pmap_switch(pmap)
-	addql	#4,%sp
-	movl	_C_LABEL(curpcb),%a1	| restore curpcb
-| Note: _pmap_switch() will clear the cache if needed.
-#else
-	/* Use this inline version on sun3x when not debugging the pmap. */
-	lea	_C_LABEL(kernel_crp),%a3 | our CPU Root Ptr. (CRP)
-	movl	VM_PMAP(%a2),%a2	| pmap = vm->vm_map.pmap
-	movl	PM_A_PHYS(%a2),%d0	| phys = pmap->pm_a_phys
-	cmpl	4(%a3),%d0		|  == kernel_crp.rp_addr ?
-	jeq	.Lsame_mmuctx		| skip loadcrp/flush
-	/* OK, it is a new MMU context.  Load it up. */
-	movl	%d0,4(%a3)
-	movl	#CACHE_CLR,%d0
-	movc	%d0,%cacr		| invalidate cache(s)
-	pflusha				| flush entire TLB
-	pmove	(%a3),%crp		| load new user root pointer
-.Lsame_mmuctx:
-#endif	/* !defined(_SUN3X_) || defined(PMAP_DEBUG) */
-#else	/* !defined(sun2) && !defined(sun3) */
 	/*
-	 * Activate process's address space.
-	 * XXX Should remember the last USTP value loaded, and call this
-	 * XXX only of it has changed.
+	 * Check for restartable atomic sequences (RAS)
 	 */
-	pea	(%a0)			| push newlwp
-	jbsr	_C_LABEL(pmap_activate)	| pmap_activate(newlwp)
-	/* Note that newlwp will be popped off the stack later. */
-#endif
-
-	/*
-	 *  Check for restartable atomic sequences (RAS)
-	 */
-	movl	_C_LABEL(curlwp),%a0
 	movl	L_PROC(%a0),%a2
-	tstl	P_RASLIST(%a2)
-	jeq	1f
+	tstl	P_RASLIST(%a2)		| p->p_raslist == NULL?
+	jeq	2f			| yes, skip it.
 	movl	L_MD_REGS(%a0),%a1
-	movl	TF_PC(%a1),-(%sp)
-	movl	%a2,-(%sp)
-	jbsr	_C_LABEL(ras_lookup)
+	movl	TF_PC(%a1),-(%sp)	| push return PC
+	movl	%a2,-(%sp)		| push proc
+	jbsr	_C_LABEL(ras_lookup)	| a0 = ras_lookup(p, pc)
 	addql	#8,%sp
 	movql	#-1,%d0
-	cmpl	%a0,%d0
-	jeq	1f
+	cmpl	%a0,%d0			| a0 == -1?
+	jeq	1f			| yes, skip it.
 	movl	_C_LABEL(curlwp),%a1
 	movl	L_MD_REGS(%a1),%a1
-	movl	%a0,TF_PC(%a1)
+	movl	%a0,TF_PC(%a1)		| fixup return PC
 1:
-	movl	(%sp)+,%d0		| restore newlwp
-	movl	_C_LABEL(curpcb),%a1	| restore pcb
+	movl	_C_LABEL(curlwp),%a0	| recover new lwp
+	movl	_C_LABEL(curpcb),%a1	| recover new pcb
+2:
+	movl	%a0,%d0			| free up %a0
+	movl	4(%sp),%d1		| get oldlwp for return value
+	lea	_ASM_LABEL(tmpstk),%sp	| switch to tmp stack in case of NMI
 
-	movl	4(%sp),%d1		| restore oldlwp for a return value
-	lea     _ASM_LABEL(tmpstk),%sp	| now goto a tmp stack for NMI
-
-	moveml	PCB_REGS(%a1),%d2-%d7/%a2-%a7	| and registers
+	moveml	PCB_REGS(%a1),%d2-%d7/%a2-%a7 | restore registers
 	movl	PCB_USP(%a1),%a0
-	movl	%a0,%usp		| and USP
+	movl	%a0,%usp		      | and USP
 
 #ifdef _M68K_CUSTOM_FPU_CTX
 	moveml	%d0/%d1,-(%sp)
@@ -245,14 +205,10 @@ ENTRY(cpu_switchto)
 #endif /* !_M68K_CUSTOM_FPU_CTX */
 
 .Lcpu_switch_nofprest:
-	movl	%d1,%d0
-	movl	%d0,%a0
+	movl	%d1,%d0			| return outgoing lwp
+	movl	%d0,%a0			| (in a0, too)
 	rts
 
-.Lcpu_switch_badsw:
-	PANIC("switch")
-	/*NOTREACHED*/
-
 /*
  * savectx(pcb)
  * Update pcb, saving current processor state.

Reply via email to