Module Name:    src
Committed By:   oster
Date:           Sun Dec 11 18:02:40 UTC 2022

Modified Files:
        src/sys/arch/vax/include: cpu.h pcb.h
        src/sys/arch/vax/vax: pmap.c trap.c

Log Message:
Support save/restore of AST levels in the PCB for context switching.

Code written by ragge@ , tested by oster@.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/vax/include/cpu.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/vax/include/pcb.h
cvs rdiff -u -r1.194 -r1.195 src/sys/arch/vax/vax/pmap.c
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/vax/vax/trap.c

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/vax/include/cpu.h
diff -u src/sys/arch/vax/include/cpu.h:1.105 src/sys/arch/vax/include/cpu.h:1.106
--- src/sys/arch/vax/include/cpu.h:1.105	Sat Aug 14 17:51:19 2021
+++ src/sys/arch/vax/include/cpu.h	Sun Dec 11 18:02:40 2022
@@ -1,4 +1,4 @@
-/*      $NetBSD: cpu.h,v 1.105 2021/08/14 17:51:19 ryo Exp $      */
+/*      $NetBSD: cpu.h,v 1.106 2022/12/11 18:02:40 oster Exp $      */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
@@ -157,9 +157,11 @@ extern int cpu_printfataltraps;
 #define	curlwp			((struct lwp *)mfpr(PR_SSP))
 #define	cpu_number()		(curcpu()->ci_cpuid)
 #define	cpu_need_resched(ci, l, flags)		\
-	do {					\
-		__USE(flags);			\
-		mtpr(AST_OK,PR_ASTLVL);		\
+	do {							\
+		struct pcb *pcb = lwp_getpcb(curlwp);		\
+		__USE(flags);					\
+		pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON;	\
+		mtpr(AST_OK,PR_ASTLVL);				\
 	} while (/*CONSTCOND*/ 0)
 #define	cpu_proc_fork(x, y)	do { } while (/*CONSCOND*/0)
 
@@ -198,7 +200,12 @@ extern char vax_mp_tramp;
  * process as soon as possible.
  */
 
-#define cpu_signotify(l)     mtpr(AST_OK,PR_ASTLVL)
+#define cpu_signotify(l)					\
+	do {							\
+		struct pcb *pcb = lwp_getpcb(l);		\
+		pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON;	\
+		mtpr(AST_OK,PR_ASTLVL);				\
+	} while (/*CONSTCOND*/ 0)
 
 
 /*
@@ -206,7 +213,13 @@ extern char vax_mp_tramp;
  * buffer pages are invalid.  On the hp300, request an ast to send us
  * through trap, marking the proc as needing a profiling tick.
  */
-#define cpu_need_proftick(l) do { (l)->l_pflag |= LP_OWEUPC; mtpr(AST_OK,PR_ASTLVL); } while (/*CONSTCOND*/ 0)
+#define cpu_need_proftick(l) 					\
+	do {							\
+		struct pcb *pcb = lwp_getpcb(l);		\
+		(l)->l_pflag |= LP_OWEUPC;			\
+		pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON;	\
+		mtpr(AST_OK,PR_ASTLVL);				\
+	} while (/*CONSTCOND*/ 0)
 
 /*
  * This defines the I/O device register space size in pages.

Index: src/sys/arch/vax/include/pcb.h
diff -u src/sys/arch/vax/include/pcb.h:1.15 src/sys/arch/vax/include/pcb.h:1.16
--- src/sys/arch/vax/include/pcb.h:1.15	Mon May 22 17:12:11 2017
+++ src/sys/arch/vax/include/pcb.h	Sun Dec 11 18:02:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcb.h,v 1.15 2017/05/22 17:12:11 ragge Exp $	*/
+/*	$NetBSD: pcb.h,v 1.16 2022/12/11 18:02:40 oster Exp $	*/
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -49,6 +49,7 @@ struct pcb {
 	long	P0LR;		/*  Page 0 Length Register    */
 	struct	pte *P1BR;	/*  Page 1 Base Register      */
 	long	P1LR;		/*  Page 1 Length Register    */
+	long	ASN;		/*  Address space number      */
 
 	/* Software registers, only used by kernel software */
 	void   *pcb_onfault;	/* Tells whether fault copy */
@@ -58,7 +59,8 @@ struct pcb {
 };
 
 #define	AST_MASK 0x07000000
-#define	AST_PCB	 0x04000000
+#define	AST_PCB	 0x04000000	/* disable AST */
+#define	AST_ON	 0x03000000	/* request AST */
 
 /* machine-specific core dump; save trapframe */
 struct	md_coredump {

Index: src/sys/arch/vax/vax/pmap.c
diff -u src/sys/arch/vax/vax/pmap.c:1.194 src/sys/arch/vax/vax/pmap.c:1.195
--- src/sys/arch/vax/vax/pmap.c:1.194	Fri Feb 11 17:26:55 2022
+++ src/sys/arch/vax/vax/pmap.c	Sun Dec 11 18:02:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.194 2022/02/11 17:26:55 riastradh Exp $	   */
+/*	$NetBSD: pmap.c,v 1.195 2022/12/11 18:02:40 oster Exp $	   */
 /*
  * Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.194 2022/02/11 17:26:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.195 2022/12/11 18:02:40 oster Exp $");
 
 #include "opt_ddb.h"
 #include "opt_cputype.h"
@@ -552,7 +552,7 @@ update_pcbs(struct pmap *pm)
 	for (pcb = pm->pm_pcbs; pcb != NULL; pcb = pcb->pcb_pmnext) {
 		KASSERT(pcb->pcb_pm == pm);
 		pcb->P0BR = pm->pm_p0br;
-		pcb->P0LR = pm->pm_p0lr|AST_PCB;
+		pcb->P0LR = pm->pm_p0lr | (pcb->P0LR & AST_MASK);
 		pcb->P1BR = pm->pm_p1br;
 		pcb->P1LR = pm->pm_p1lr;
 		
@@ -561,7 +561,7 @@ update_pcbs(struct pmap *pm)
 	/* If curlwp uses this pmap update the regs too */ 
 	if (pm == curproc->p_vmspace->vm_map.pmap) {
 		mtpr((uintptr_t)pm->pm_p0br, PR_P0BR);
-		mtpr(pm->pm_p0lr|AST_PCB, PR_P0LR);
+		mtpr(pm->pm_p0lr, PR_P0LR);
 		mtpr((uintptr_t)pm->pm_p1br, PR_P1BR);
 		mtpr(pm->pm_p1lr, PR_P1LR);
 	}

Index: src/sys/arch/vax/vax/trap.c
diff -u src/sys/arch/vax/vax/trap.c:1.136 src/sys/arch/vax/vax/trap.c:1.137
--- src/sys/arch/vax/vax/trap.c:1.136	Thu Nov 21 19:24:02 2019
+++ src/sys/arch/vax/vax/trap.c	Sun Dec 11 18:02:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.136 2019/11/21 19:24:02 ad Exp $     */
+/*	$NetBSD: trap.c,v 1.137 2022/12/11 18:02:40 oster Exp $     */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -28,7 +28,7 @@
  /* All bugs are subject to removal without further notice */
 		
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.136 2019/11/21 19:24:02 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.137 2022/12/11 18:02:40 oster Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -315,6 +315,7 @@ if(faultdebug)printf("trap accflt type %
 		break;
 
 	case T_ASTFLT|T_USER:
+		pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_PCB;
 		mtpr(AST_NO,PR_ASTLVL);
 		trapsig = false;
 		break;

Reply via email to