PERFORCE change 38902 for review

Peter Wemm peter at FreeBSD.org
Tue Sep 30 12:20:50 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=38902

Change 38902 by peter at peter_daintree on 2003/09/30 12:20:29

	IFC @38900

Affected files ...

.. //depot/projects/hammer/lib/libc/stdlib/qsort.3#4 integrate
.. //depot/projects/hammer/sys/cam/scsi/scsi_cd.c#13 integrate
.. //depot/projects/hammer/sys/cam/scsi/scsi_targ_bh.c#7 integrate
.. //depot/projects/hammer/sys/compat/linprocfs/linprocfs.c#14 integrate
.. //depot/projects/hammer/sys/dev/acpica/Osd/OsdSchedule.c#6 integrate
.. //depot/projects/hammer/sys/i386/i386/genassym.c#9 integrate
.. //depot/projects/hammer/sys/i386/i386/pmap.c#19 integrate
.. //depot/projects/hammer/sys/i386/i386/swtch.s#7 integrate
.. //depot/projects/hammer/sys/i386/include/pcb.h#8 integrate
.. //depot/projects/hammer/sys/kern/kern_synch.c#23 integrate
.. //depot/projects/hammer/sys/netkey/key.c#5 integrate
.. //depot/projects/hammer/sys/netkey/key_debug.h#3 integrate
.. //depot/projects/hammer/sys/netkey/keysock.c#6 integrate
.. //depot/projects/hammer/sys/sys/proc.h#31 integrate

Differences ...

==== //depot/projects/hammer/lib/libc/stdlib/qsort.3#4 (text+ko) ====

@@ -34,9 +34,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)qsort.3	8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdlib/qsort.3,v 1.13 2002/12/18 12:45:10 ru Exp $
+.\" $FreeBSD: src/lib/libc/stdlib/qsort.3,v 1.14 2003/09/30 07:05:46 tjr Exp $
 .\"
-.Dd September 7, 2002
+.Dd September 30, 2003
 .Dt QSORT 3
 .Os
 .Sh NAME
@@ -263,16 +263,19 @@
 .%P pp. 114-123, 145-149
 .Re
 .Rs
-.%A Mcilroy, P.M.
+.%A McIlroy, P.M.
 .%T "Optimistic Sorting and Information Theoretic Complexity"
 .%J "Fourth Annual ACM-SIAM Symposium on Discrete Algorithms"
 .%V January 1992
 .Re
 .Rs
 .%A Bentley, J.L.
+.%A McIlroy, M.D.
 .%T "Engineering a Sort Function"
-.%J "bentley at research.att.com"
-.%V January 1992
+.%J "Software--Practice and Experience"
+.%V Vol. 23(11)
+.%P pp. 1249-1265
+.%D November\ 1993
 .Re
 .Sh STANDARDS
 The

==== //depot/projects/hammer/sys/cam/scsi/scsi_cd.c#13 (text+ko) ====

@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.83 2003/09/11 19:27:24 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.84 2003/09/30 07:52:15 phk Exp $");
 
 #include "opt_cd.h"
 
@@ -63,6 +63,7 @@
 #include <sys/devicestat.h>
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
+#include <geom/geom_disk.h>
 
 #include <cam/cam.h>
 #include <cam/cam_ccb.h>
@@ -146,15 +147,10 @@
 	struct cd_params	params;
 	union ccb		saved_ccb;
 	cd_quirks		quirks;
-	struct devstat		*device_stats;
 	STAILQ_ENTRY(cd_softc)	changer_links;
 	struct cdchanger	*changer;
 	int			bufs_left;
 	struct cam_periph	*periph;
-	dev_t			dev;
-#ifdef GONE_IN_5
-	eventhandler_tag	clonetag;
-#endif
 	int			minimum_command_size;
 	int			outstanding_cmds;
 	struct task		sysctl_task;
@@ -162,6 +158,7 @@
 	struct sysctl_oid	*sysctl_tree;
 	STAILQ_HEAD(, cd_mode_params)	mode_queue;
 	struct cd_tocdata	toc;
+	struct disk		disk;
 };
 
 struct cd_page_sizes {
@@ -217,12 +214,10 @@
 	}
 };
 
-#define CD_CDEV_MAJOR 15
-
-static	d_open_t	cdopen;
-static	d_close_t	cdclose;
-static	d_ioctl_t	cdioctl;
-static	d_strategy_t	cdstrategy;
+static	disk_open_t	cdopen;
+static	disk_close_t	cdclose;
+static	disk_ioctl_t	cdioctl;
+static	disk_strategy_t	cdstrategy;
 
 static	periph_init_t	cdinit;
 static	periph_ctor_t	cdregister;
@@ -294,17 +289,6 @@
 
 PERIPHDRIVER_DECLARE(cd, cddriver);
 
-static struct cdevsw cd_cdevsw = {
-	.d_open =	cdopen,
-	.d_close =	cdclose,
-	.d_read =	physread,
-	.d_write =	physwrite,
-	.d_ioctl =	cdioctl,
-	.d_strategy =	cdstrategy,
-	.d_name =	"cd",
-	.d_maj =	CD_CDEV_MAJOR,
-	.d_flags =	D_DISK,
-};
 
 static int num_changers;
 
@@ -343,27 +327,6 @@
 
 static STAILQ_HEAD(changerlist, cdchanger) changerq;
 
-#ifdef GONE_IN_5
-static void
-cdclone(void *arg, char *name, int namelen, dev_t *dev)
-{
-	struct cd_softc *softc;
-	const char *p;
-	int l;
-
-	softc = arg;
-	p = devtoname(softc->dev);
-	l = strlen(p);
-	if (bcmp(name, p, l))
-		return;
-	if (name[l] != 'a' && name[l] != 'c')
-		return;
-	if (name[l + 1] != '\0')
-		return;
-	*dev = softc->dev;
-	return;
-}
-#endif
 
 static void
 cdinit(void)
@@ -533,11 +496,6 @@
 		free(softc->changer, M_DEVBUF);
 		num_changers--;
 	}
-	devstat_remove_entry(softc->device_stats);
-	destroy_dev(softc->dev);
-#ifdef GONE_IN_5
-	EVENTHANDLER_DEREGISTER(dev_clone, softc->clonetag);
-#endif
 	free(softc, M_DEVBUF);
 	splx(s);
 }
@@ -774,18 +732,18 @@
 	 * WORM peripheral driver.  WORM drives will also have the WORM
 	 * driver attached to them.
 	 */
-	softc->device_stats = devstat_new_entry("cd", 
+	softc->disk.d_devstat = devstat_new_entry("cd", 
 			  periph->unit_number, 0,
 	  		  DEVSTAT_BS_UNAVAILABLE,
 			  DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_SCSI,
 			  DEVSTAT_PRIORITY_CD);
-	softc->dev = make_dev(&cd_cdevsw, periph->unit_number,
-		UID_ROOT, GID_OPERATOR, 0640, "cd%d", periph->unit_number);
-	softc->dev->si_drv1 = periph;
-#ifdef GONE_IN_5
-	softc->clonetag =
-	    EVENTHANDLER_REGISTER(dev_clone, cdclone, softc, 1000);
-#endif
+	softc->disk.d_open = cdopen;
+	softc->disk.d_close = cdclose;
+	softc->disk.d_strategy = cdstrategy;
+	softc->disk.d_ioctl = cdioctl;
+	softc->disk.d_name = "cd";
+	disk_create(periph->unit_number, &softc->disk, 0, NULL, NULL);
+	softc->disk.d_drv1 = periph;
 
 	/*
 	 * Add an async callback so that we get
@@ -1028,14 +986,14 @@
 }
 
 static int
-cdopen(dev_t dev, int flags, int fmt, struct thread *td)
+cdopen(struct disk *dp)
 {
 	struct cam_periph *periph;
 	struct cd_softc *softc;
 	int error;
 	int s;
 
-	periph = (struct cam_periph *)dev->si_drv1;
+	periph = (struct cam_periph *)dp->d_drv1;
 	if (periph == NULL)
 		return (ENXIO);
 
@@ -1075,13 +1033,13 @@
 }
 
 static int
-cdclose(dev_t dev, int flag, int fmt, struct thread *td)
+cdclose(struct disk *dp)
 {
 	struct 	cam_periph *periph;
 	struct	cd_softc *softc;
 	int	error;
 
-	periph = (struct cam_periph *)dev->si_drv1;
+	periph = (struct cam_periph *)dp->d_drv1;
 	if (periph == NULL)
 		return (ENXIO);	
 
@@ -1097,7 +1055,7 @@
 	 * Since we're closing this CD, mark the blocksize as unavailable.
 	 * It will be marked as available when the CD is opened again.
 	 */
-	softc->device_stats->flags |= DEVSTAT_BS_UNAVAILABLE;
+	softc->disk.d_devstat->flags |= DEVSTAT_BS_UNAVAILABLE;
 
 	/*
 	 * We'll check the media and toc again at the next open().
@@ -1391,7 +1349,7 @@
 	softc = (struct cd_softc *)periph->softc;
 
 	error = cam_periph_runccb(ccb, error_routine, cam_flags, sense_flags,
-				  softc->device_stats);
+				  softc->disk.d_devstat);
 
 	if (softc->flags & CD_FLAG_CHANGER)
 		cdchangerschedule(softc);
@@ -1453,7 +1411,7 @@
 	struct cd_softc *softc;
 	int    s;
 
-	periph = (struct cam_periph *)bp->bio_dev->si_drv1;
+	periph = (struct cam_periph *)bp->bio_disk->d_drv1;
 	if (periph == NULL) {
 		biofinish(bp, NULL, ENXIO);
 		return;
@@ -1547,7 +1505,7 @@
 		} else {
 			bioq_remove(&softc->bio_queue, bp);
 
-			devstat_start_transaction_bio(softc->device_stats, bp);
+			devstat_start_transaction_bio(softc->disk.d_devstat, bp);
 
 			scsi_read_write(&start_ccb->csio,
 					/*retries*/4,
@@ -1703,7 +1661,7 @@
 		if (softc->flags & CD_FLAG_CHANGER)
 			cdchangerschedule(softc);
 
-		biofinish(bp, softc->device_stats, 0);
+		biofinish(bp, softc->disk.d_devstat, 0);
 		break;
 	}
 	case CD_CCB_PROBE:
@@ -1939,14 +1897,14 @@
 }
 
 static int
-cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
+cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td)
 {
 
 	struct 	cam_periph *periph;
 	struct	cd_softc *softc;
 	int	error;
 
-	periph = (struct cam_periph *)dev->si_drv1;
+	periph = (struct cam_periph *)dp->d_drv1;
 	if (periph == NULL)
 		return(ENXIO);	
 
@@ -1977,14 +1935,6 @@
 
 	switch (cmd) {
 
-	case DIOCGMEDIASIZE:
-		*(off_t *)addr =
-		    (off_t)softc->params.blksize * softc->params.disksize;
-		break;
-	case DIOCGSECTORSIZE:
-		*(u_int *)addr = softc->params.blksize;
-		break;
-
 	case CDIOCPLAYTRACKS:
 		{
 			struct ioc_play_track *args
@@ -2749,6 +2699,10 @@
 	}
 }
 
+/*
+ * XXX: the disk media and sector size is only really able to change
+ * XXX: while the device is closed.
+ */
 static int
 cdcheckmedia(struct cam_periph *periph)
 {
@@ -2761,6 +2715,9 @@
 	softc = (struct cd_softc *)periph->softc;
 
 	cdprevent(periph, PR_PREVENT);
+	softc->disk.d_maxsize = DFLTPHYS;
+	softc->disk.d_sectorsize = 0;
+	softc->disk.d_mediasize = 0;
 
 	/*
 	 * Get the disc size and block size.  If we can't get it, we don't
@@ -2860,6 +2817,10 @@
 	}
 
 	softc->flags |= CD_FLAG_VALID_TOC;
+	softc->disk.d_maxsize = DFLTPHYS;
+	softc->disk.d_sectorsize = softc->params.blksize;
+	softc->disk.d_mediasize =
+	    (off_t)softc->params.blksize * softc->params.disksize;
 
 bailout:
 
@@ -2870,9 +2831,9 @@
 	 * XXX problems here if some slice or partition is still
 	 * open with the old size?
 	 */
-	if ((softc->device_stats->flags & DEVSTAT_BS_UNAVAILABLE) != 0)
-		softc->device_stats->flags &= ~DEVSTAT_BS_UNAVAILABLE;
-	softc->device_stats->block_size = softc->params.blksize;
+	if ((softc->disk.d_devstat->flags & DEVSTAT_BS_UNAVAILABLE) != 0)
+		softc->disk.d_devstat->flags &= ~DEVSTAT_BS_UNAVAILABLE;
+	softc->disk.d_devstat->block_size = softc->params.blksize;
 
 	return (error);
 }

==== //depot/projects/hammer/sys/cam/scsi/scsi_targ_bh.c#7 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_targ_bh.c,v 1.19 2003/09/25 05:02:19 simokawa Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_targ_bh.c,v 1.20 2003/09/30 08:03:52 simokawa Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -186,14 +186,21 @@
 	    struct cam_path *path, void *arg)
 {
 	struct cam_path *new_path;
+	struct ccb_pathinq *cpi;
+	path_id_t bus_path_id;
 	cam_status status;
 
+	cpi = (struct ccb_pathinq *)arg;
+	if (code == AC_PATH_REGISTERED)
+		bus_path_id = cpi->ccb_h.path_id;
+	else
+		bus_path_id = xpt_path_path_id(path);
 	/*
 	 * Allocate a peripheral instance for
 	 * this target instance.
 	 */
 	status = xpt_create_path(&new_path, NULL,
-				 xpt_path_path_id(path),
+				 bus_path_id,
 				 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 	if (status != CAM_REQ_CMP) {
 		printf("targbhasync: Unable to create path "
@@ -204,10 +211,6 @@
 	switch (code) {
 	case AC_PATH_REGISTERED:
 	{
-		struct ccb_pathinq *cpi;
- 
-		cpi = (struct ccb_pathinq *)arg;
-
 		/* Only attach to controllers that support target mode */
 		if ((cpi->target_sprt & PIT_PROCESSOR) == 0)
 			break;
@@ -222,7 +225,10 @@
 	}
 	case AC_PATH_DEREGISTERED:
 	{
-		cam_periph_invalidate(cam_periph_find(new_path, "targbh"));
+		struct cam_periph *periph;
+
+		if ((periph = cam_periph_find(new_path, "targbh")) != NULL)
+			cam_periph_invalidate(periph);
 		break;
 	}
 	default:

==== //depot/projects/hammer/sys/compat/linprocfs/linprocfs.c#14 (text+ko) ====

@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/linprocfs/linprocfs.c,v 1.74 2003/09/22 16:05:11 des Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/linprocfs/linprocfs.c,v 1.75 2003/09/30 13:35:19 des Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -413,7 +413,8 @@
 static int
 linprocfs_dostat(PFS_FILL_ARGS)
 {
-	int name[2], olen, plen;
+	unsigned int olen, plen;
+	int name[2];
 	int i, ncpu;
 
 	name[0] = CTL_HW;

==== //depot/projects/hammer/sys/dev/acpica/Osd/OsdSchedule.c#6 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/Osd/OsdSchedule.c,v 1.24 2003/09/29 07:29:26 njl Exp $
+ *	$FreeBSD: src/sys/dev/acpica/Osd/OsdSchedule.c,v 1.25 2003/09/30 19:12:37 njl Exp $
  */
 
 /*
@@ -262,15 +262,7 @@
 {
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
-    /* 
-     * Maximum length for stall is 100 us.  If longer, assume caller
-     * really meant "sleep".
-     */
-    if (Microseconds <= 100)
-	DELAY(Microseconds);
-    else
-	AcpiOsSleep(Microseconds / 1000, Microseconds % 1000);
-
+    DELAY(Microseconds);
     return_VOID;
 }
 

==== //depot/projects/hammer/sys/i386/i386/genassym.c#9 (text+ko) ====

@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/genassym.c,v 1.142 2003/06/27 21:50:52 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/genassym.c,v 1.143 2003/09/30 08:11:35 jeff Exp $");
 
 #include "opt_compat.h"
 #include "opt_kstack_pages.h"
@@ -89,7 +89,6 @@
 ASSYM(TD_PROC, offsetof(struct thread, td_proc));
 ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level));
 ASSYM(TD_CRITNEST, offsetof(struct thread, td_critnest));
-ASSYM(TD_SWITCHIN, offsetof(struct thread, td_switchin));
 ASSYM(TD_MD, offsetof(struct thread, td_md));
 
 ASSYM(P_MD, offsetof(struct proc, p_md));
@@ -144,6 +143,7 @@
 ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
 ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
+ASSYM(PCB_SWITCHOUT, offsetof(struct pcb, pcb_switchout));
 
 ASSYM(PCB_SIZE, sizeof(struct pcb));
 ASSYM(PCB_VM86CALL, PCB_VM86CALL);

==== //depot/projects/hammer/sys/i386/i386/pmap.c#19 (text+ko) ====

@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.437 2003/09/27 05:44:53 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.438 2003/09/30 08:11:35 jeff Exp $");
 
 /*
  *	Manages physical address maps.
@@ -2481,7 +2481,7 @@
 #ifdef SMP
 
 /*
- *	pmap_zpi_switchin*()
+ *	pmap_zpi_switchout*()
  *
  *	These functions allow us to avoid doing IPIs alltogether in certain
  *	temporary page-mapping situations (page zeroing).  Instead to deal
@@ -2490,20 +2490,20 @@
  *	very often so we remain relatively optimal with very little effort.
  */
 static void
-pmap_zpi_switchin12(void)
+pmap_zpi_switchout12(void)
 {
 	invlpg((u_int)CADDR1);
 	invlpg((u_int)CADDR2);
 }
 
 static void
-pmap_zpi_switchin2(void)
+pmap_zpi_switchout2(void)
 {
 	invlpg((u_int)CADDR2);
 }
 
 static void
-pmap_zpi_switchin3(void)
+pmap_zpi_switchout3(void)
 {
 	invlpg((u_int)CADDR3);
 }
@@ -2521,23 +2521,23 @@
 	mtx_lock(&CMAPCADDR12_lock);
 	if (*CMAP2)
 		panic("pmap_zero_page: CMAP2 busy");
-	*CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
-#ifdef I386_CPU
-	invltlb();
-#else
 #ifdef SMP
-	curthread->td_switchin = pmap_zpi_switchin2;
+	curthread->td_pcb->pcb_switchout = pmap_zpi_switchout2;
 #endif
-	invlpg((u_int)CADDR2);
-#endif
+	*CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
 #if defined(I686_CPU)
 	if (cpu_class == CPUCLASS_686)
 		i686_pagezero(CADDR2);
 	else
 #endif
 		bzero(CADDR2, PAGE_SIZE);
+#ifdef I386_CPU
+	invltlb();
+#else
+	invlpg((u_int)CADDR2);
+#endif
 #ifdef SMP
-	curthread->td_switchin = NULL;
+	curthread->td_pcb->pcb_switchout = NULL;
 #endif
 	*CMAP2 = 0;
 	mtx_unlock(&CMAPCADDR12_lock);
@@ -2556,23 +2556,23 @@
 	mtx_lock(&CMAPCADDR12_lock);
 	if (*CMAP2)
 		panic("pmap_zero_page: CMAP2 busy");
-	*CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
-#ifdef I386_CPU
-	invltlb();
-#else
 #ifdef SMP
-	curthread->td_switchin = pmap_zpi_switchin2;
+	curthread->td_pcb->pcb_switchout = pmap_zpi_switchout2;
 #endif
-	invlpg((u_int)CADDR2);
-#endif
+	*CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
 #if defined(I686_CPU)
 	if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE)
 		i686_pagezero(CADDR2);
 	else
 #endif
 		bzero((char *)CADDR2 + off, size);
+#ifdef I386_CPU
+	invltlb();
+#else
+	invlpg((u_int)CADDR2);
+#endif
 #ifdef SMP
-	curthread->td_switchin = NULL;
+	curthread->td_pcb->pcb_switchout = NULL;
 #endif
 	*CMAP2 = 0;
 	mtx_unlock(&CMAPCADDR12_lock);
@@ -2590,23 +2590,23 @@
 
 	if (*CMAP3)
 		panic("pmap_zero_page: CMAP3 busy");
-	*CMAP3 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
-#ifdef I386_CPU
-	invltlb();
-#else
 #ifdef SMP
-	curthread->td_switchin = pmap_zpi_switchin3;
+	curthread->td_pcb->pcb_switchout = pmap_zpi_switchout3;
 #endif
-	invlpg((u_int)CADDR3);
-#endif
+	*CMAP3 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M;
 #if defined(I686_CPU)
 	if (cpu_class == CPUCLASS_686)
 		i686_pagezero(CADDR3);
 	else
 #endif
 		bzero(CADDR3, PAGE_SIZE);
+#ifdef I386_CPU
+	invltlb();
+#else
+	invlpg((u_int)CADDR3);
+#endif
 #ifdef SMP
-	curthread->td_switchin = NULL;
+	curthread->td_pcb->pcb_switchout = NULL;
 #endif
 	*CMAP3 = 0;
 }
@@ -2626,20 +2626,20 @@
 		panic("pmap_copy_page: CMAP1 busy");
 	if (*CMAP2)
 		panic("pmap_copy_page: CMAP2 busy");
+#ifdef SMP
+	curthread->td_pcb->pcb_switchout = pmap_zpi_switchout12;
+#endif
 	*CMAP1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A;
 	*CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M;
+	bcopy(CADDR1, CADDR2, PAGE_SIZE);
 #ifdef I386_CPU
 	invltlb();
 #else
-#ifdef SMP
-	curthread->td_switchin = pmap_zpi_switchin12;
-#endif
 	invlpg((u_int)CADDR1);
 	invlpg((u_int)CADDR2);
 #endif
-	bcopy(CADDR1, CADDR2, PAGE_SIZE);
 #ifdef SMP
-	curthread->td_switchin = NULL;
+	curthread->td_pcb->pcb_switchout = NULL;
 #endif
 	*CMAP1 = 0;
 	*CMAP2 = 0;

==== //depot/projects/hammer/sys/i386/i386/swtch.s#7 (text+ko) ====

@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.142 2003/07/10 01:02:59 peter Exp $
+ * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.143 2003/09/30 08:11:35 jeff Exp $
  */
 
 #include "opt_npx.h"
@@ -118,7 +118,12 @@
 	movl	%gs,PCB_GS(%edx)
 	pushfl					/* PSL */
 	popl	PCB_PSL(%edx)
-
+	/* Check to see if we need to call a switchout function. */
+	movl	PCB_SWITCHOUT(%edx),%eax
+	cmpl	$0, %eax
+	je	1f
+	call	*%eax
+1:
 	/* Test if debug registers should be saved. */
 	testl	$PCB_DBREGS,PCB_FLAGS(%edx)
 	jz      1f                              /* no, skip over */

==== //depot/projects/hammer/sys/i386/include/pcb.h#8 (text+ko) ====

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)pcb.h	5.10 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/i386/include/pcb.h,v 1.49 2002/11/07 01:34:23 davidxu Exp $
+ * $FreeBSD: src/sys/i386/include/pcb.h,v 1.50 2003/09/30 08:11:36 jeff Exp $
  */
 
 #ifndef _I386_PCB_H_
@@ -73,7 +73,8 @@
 	int	pcb_gs;
 	struct	pcb_ext	*pcb_ext;	/* optional pcb extension */
 	int	pcb_psl;	/* process status long */
-	u_long	__pcb_spare[2];	/* adjust to avoid core dump size changes */
+	void	(*pcb_switchout)(void);	/* Special switchout function. */
+	u_long	__pcb_spare[1];	/* adjust to avoid core dump size changes */
 };
 
 #ifdef _KERNEL

==== //depot/projects/hammer/sys/kern/kern_synch.c#23 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_synch.c,v 1.233 2003/08/19 17:51:09 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_synch.c,v 1.234 2003/09/30 08:11:34 jeff Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ktrace.h"
@@ -531,14 +531,6 @@
 	if (PCPU_GET(switchtime.sec) == 0)
 		binuptime(PCPU_PTR(switchtime));
 	PCPU_SET(switchticks, ticks);
-
-	/*
-	 * Call the switchin function while still holding the scheduler lock
-	 * (used by the idlezero code and the general page-zeroing code)
-	 */
-	if (td->td_switchin)
-		td->td_switchin();
-
 	/* 
 	 * If the last thread was exiting, finish cleaning it up.
 	 */

==== //depot/projects/hammer/sys/netkey/key.c#5 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netkey/key.c,v 1.50 2003/09/25 13:40:06 ume Exp $");
+__FBSDID("$FreeBSD: src/sys/netkey/key.c,v 1.52 2003/09/30 10:52:49 ume Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -823,7 +823,7 @@
 			/*NOTREACHED*/
 		}
 
-		/* prefered new sa rather than old sa */
+		/* preferred new sa rather than old sa */
 		if (candidate->lft_c->sadb_lifetime_addtime <
 				sav->lft_c->sadb_lifetime_addtime) {
 			d = candidate;
@@ -1790,16 +1790,16 @@
 
 	/* check policy */
 	/* key_spdadd() accepts DISCARD, NONE and IPSEC. */
-	if (xpl0->sadb_x_policy_type == IPSEC_POLICY_ENTRUST
-	 || xpl0->sadb_x_policy_type == IPSEC_POLICY_BYPASS) {
+	if (xpl0->sadb_x_policy_type == IPSEC_POLICY_ENTRUST ||
+	    xpl0->sadb_x_policy_type == IPSEC_POLICY_BYPASS) {
 		ipseclog((LOG_DEBUG, "key_spdadd: Invalid policy type.\n"));
 		return key_senderror(so, m, EINVAL);
 	}
 
 	/* policy requests are mandatory when action is ipsec. */
-        if (mhp->msg->sadb_msg_type != SADB_X_SPDSETIDX
-	 && xpl0->sadb_x_policy_type == IPSEC_POLICY_IPSEC
-	 && mhp->extlen[SADB_X_EXT_POLICY] <= sizeof(*xpl0)) {
+	if (mhp->msg->sadb_msg_type != SADB_X_SPDSETIDX &&
+	    xpl0->sadb_x_policy_type == IPSEC_POLICY_IPSEC &&
+	    mhp->extlen[SADB_X_EXT_POLICY] <= sizeof(*xpl0)) {
 		ipseclog((LOG_DEBUG, "key_spdadd: some policy requests part required.\n"));
 		return key_senderror(so, m, EINVAL);
 	}
@@ -1979,7 +1979,7 @@
  * and send,
  *   <base, address(SD), policy(*)>
  * to the ikmpd.
- * policy(*) including direction of policy.
+ * policy(*) including the direction of the policy.
  *
  * m will always be freed.
  */
@@ -2041,7 +2041,7 @@
 		return key_senderror(so, m, EINVAL);
 	}
 
-	/* save policy id to buffer to be returned. */
+	/* save policy id to be returned. */
 	xpl0->sadb_x_policy_id = sp->id;
 
 	sp->state = IPSEC_SPSTATE_DEAD;
@@ -2102,7 +2102,8 @@
 
 	/* Is there SP in SPD ? */
 	if ((sp = key_getspbyid(id)) == NULL) {
-		ipseclog((LOG_DEBUG, "key_spddelete2: no SP found id:%u.\n", id));
+		ipseclog((LOG_DEBUG, "key_spddelete2: no SP found id:%u.\n",
+		    id));
 		key_senderror(so, m, EINVAL);
 	}
 
@@ -2241,7 +2242,7 @@
 	if (sp->policy != IPSEC_POLICY_IPSEC)
 		panic("key_spdacquire: policy mismathed. IPsec is expected.");
 
-	/* Get an entry to check whether sent message or not. */
+	/* get an entry to check whether sent message or not. */
 	if ((newspacq = key_getspacq(&sp->spidx)) != NULL) {
 		if (key_blockacq_count < newspacq->count) {
 			/* reset counter and do send message. */
@@ -2616,7 +2617,7 @@
 	newsah->state = SADB_SASTATE_MATURE;
 	LIST_INSERT_HEAD(&sahtree, newsah, chain);
 
-	return(newsah);
+	return (newsah);
 }
 
 /*
@@ -2666,7 +2667,7 @@
 		}
 	}
 
-	/* don't delete sah only if there are savs. */
+	/* delete sah only if there's no sav. */
 	if (zombie) {
 		splx(s);
 		return;
@@ -3237,8 +3238,8 @@
 	switch (sav->sah->saidx.proto) {
 	case IPPROTO_ESP:
 		/* check flags */
-		if ((sav->flags & SADB_X_EXT_OLD)
-		 && (sav->flags & SADB_X_EXT_DERIV)) {
+		if ((sav->flags & SADB_X_EXT_OLD) &&
+		    (sav->flags & SADB_X_EXT_DERIV)) {
 			ipseclog((LOG_DEBUG, "key_mature: "
 			    "invalid flag (derived) given to old-esp.\n"));
 			return EINVAL;
@@ -3259,7 +3260,7 @@
 		if (sav->alg_enc != SADB_EALG_NONE) {
 			ipseclog((LOG_DEBUG, "key_mature: "
 			    "protocol and algorithm mismated.\n"));
-			return(EINVAL);
+			return (EINVAL);
 		}
 		checkmask = 2;
 		mustmask = 2;
@@ -3268,12 +3269,12 @@
 		if (sav->alg_auth != SADB_AALG_NONE) {
 			ipseclog((LOG_DEBUG, "key_mature: "
 				"protocol and algorithm mismated.\n"));
-			return(EINVAL);
+			return (EINVAL);
 		}
-		if ((sav->flags & SADB_X_EXT_RAWCPI) == 0
-		 && ntohl(sav->spi) >= 0x10000) {
+		if ((sav->flags & SADB_X_EXT_RAWCPI) == 0 &&
+		    ntohl(sav->spi) >= 0x10000) {
 			ipseclog((LOG_DEBUG, "key_mature: invalid cpi for IPComp.\n"));
-			return(EINVAL);
+			return (EINVAL);
 		}
 		checkmask = 4;
 		mustmask = 4;
@@ -3421,8 +3422,8 @@
 
 		case SADB_X_EXT_SA2:
 			m = key_setsadbxsa2(sav->sah->saidx.mode,
-					sav->replay ? sav->replay->count : 0,
-					sav->sah->saidx.reqid);
+			    sav->replay ? sav->replay->count : 0,
+			    sav->sah->saidx.reqid);
 			if (!m)
 				goto fail;
 			break;
@@ -3812,8 +3813,7 @@
 	case AF_INET:
 		sin = (struct sockaddr_in *)sa;
 		for (ia = in_ifaddrhead.tqh_first; ia;
-		     ia = ia->ia_link.tqe_next)
-		{
+		     ia = ia->ia_link.tqe_next) {
 			if (sin->sin_family == ia->ia_addr.sin_family &&
 			    sin->sin_len == ia->ia_addr.sin_len &&
 			    sin->sin_addr.s_addr == ia->ia_addr.sin_addr.s_addr)
@@ -3911,8 +3911,7 @@
 	} else {
 
 		/* CMP_MODE_REQID, CMP_REQID, CMP_HEAD */
-		if (flag == CMP_MODE_REQID
-		  ||flag == CMP_REQID) {
+		if (flag == CMP_MODE_REQID || flag == CMP_REQID) {
 			/*
 			 * If reqid of SPD is non-zero, unique SA is required.
 			 * The result must be of same reqid in this case.
@@ -3922,8 +3921,8 @@
 		}
 
 		if (flag == CMP_MODE_REQID) {
-			if (saidx0->mode != IPSEC_MODE_ANY
-			 && saidx0->mode != saidx1->mode)
+			if (saidx0->mode != IPSEC_MODE_ANY &&
+			    saidx0->mode != saidx1->mode)
 				return 0;
 		}
 
@@ -3960,9 +3959,8 @@
 	if (spidx0 == NULL || spidx1 == NULL)
 		return 0;
 
-	if (spidx0->prefs != spidx1->prefs
-	 || spidx0->prefd != spidx1->prefd
-	 || spidx0->ul_proto != spidx1->ul_proto)
+	if (spidx0->prefs != spidx1->prefs || spidx0->prefd != spidx1->prefd ||
+	    spidx0->ul_proto != spidx1->ul_proto)
 		return 0;
 
 	if (key_sockaddrcmp((struct sockaddr *)&spidx0->src,
@@ -4004,14 +4002,14 @@
 		return 0;
 
 	/* if spidx.ul_proto == IPSEC_ULPROTO_ANY, ignore. */
-	if (spidx0->ul_proto != (u_int16_t)IPSEC_ULPROTO_ANY
-	 && spidx0->ul_proto != spidx1->ul_proto)
+	if (spidx0->ul_proto != (u_int16_t)IPSEC_ULPROTO_ANY &&
+	    spidx0->ul_proto != spidx1->ul_proto)
 		return 0;
 
 	switch (spidx0->src.ss_family) {
 	case AF_INET:
-		if (satosin(&spidx0->src)->sin_port != IPSEC_PORT_ANY
-		 && satosin(&spidx0->src)->sin_port !=
+		if (satosin(&spidx0->src)->sin_port != IPSEC_PORT_ANY &&
+		    satosin(&spidx0->src)->sin_port !=
 		    satosin(&spidx1->src)->sin_port)
 			return 0;
 		if (!key_bbcmp((caddr_t)&satosin(&spidx0->src)->sin_addr,
@@ -4019,8 +4017,8 @@
 			return 0;
 		break;
 	case AF_INET6:
-		if (satosin6(&spidx0->src)->sin6_port != IPSEC_PORT_ANY
-		 && satosin6(&spidx0->src)->sin6_port !=
+		if (satosin6(&spidx0->src)->sin6_port != IPSEC_PORT_ANY &&
+		    satosin6(&spidx0->src)->sin6_port !=
 		    satosin6(&spidx1->src)->sin6_port)
 			return 0;
 		/*
@@ -4045,8 +4043,8 @@
 
 	switch (spidx0->dst.ss_family) {
 	case AF_INET:
-		if (satosin(&spidx0->dst)->sin_port != IPSEC_PORT_ANY
-		 && satosin(&spidx0->dst)->sin_port !=
+		if (satosin(&spidx0->dst)->sin_port != IPSEC_PORT_ANY &&
+		    satosin(&spidx0->dst)->sin_port !=
 		    satosin(&spidx1->dst)->sin_port)
 			return 0;
 		if (!key_bbcmp((caddr_t)&satosin(&spidx0->dst)->sin_addr,
@@ -4054,8 +4052,8 @@
 			return 0;
 		break;
 	case AF_INET6:
-		if (satosin6(&spidx0->dst)->sin6_port != IPSEC_PORT_ANY
-		 && satosin6(&spidx0->dst)->sin6_port !=
+		if (satosin6(&spidx0->dst)->sin6_port != IPSEC_PORT_ANY &&
+		    satosin6(&spidx0->dst)->sin6_port !=
 		    satosin6(&spidx1->dst)->sin6_port)
 			return 0;
 		/*
@@ -4191,7 +4189,6 @@
 		for (sp = LIST_FIRST(&sptree[dir]);
 		     sp != NULL;
 		     sp = nextsp) {
-
 			nextsp = LIST_NEXT(sp, chain);
 
 			if (sp->state == IPSEC_SPSTATE_DEAD) {
@@ -4203,10 +4200,10 @@
 				continue;
 
 			/* the deletion will occur next time */
-			if ((sp->lifetime
-			  && tv.tv_sec - sp->created > sp->lifetime)
-			 || (sp->validtime
-			  && tv.tv_sec - sp->lastused > sp->validtime)) {
+			if ((sp->lifetime &&
+			     tv.tv_sec - sp->created > sp->lifetime) ||
+			    (sp->validtime &&

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list