NetBSD Problem Report #1140

From gnats  Tue Jun 20 04:00:54 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id EAA25090 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Tue, 20 Jun 1995 04:00:01 -0400
Message-Id: <199506141820.NAA05202@enigma.cs.uwm.edu>
Date: Wed, 14 Jun 1995 13:20:17 -0500
From: James Jegers <jimj@enigma.cs.uwm.edu>
Reply-To: jimj@enigma.cs.uwm.edu
To: gnats-bugs@NetBSD.ORG
Subject: SD dumps
X-Send-Pr-Version: 3.2

>Number:         1140
>Category:       kern
>Synopsis:       SD dump code
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 20 04:05:01 +0000 1995
>Closed-Date:    Mon Jun 26 07:17:11 +0000 1995
>Last-Modified:  Sat Aug 19 09:56:56 +0000 1995
>Originator:     James Jegers
>Release:        6/1/95<NetBSD-current source date>
>Organization:

>Environment:

System: NetBSD enigma.cs.uwm.edu 1.0A NetBSD 1.0A (ENIGMA) #0: Wed Apr 19 22:19:50 CDT 1995 jimj@enigma.cs.uwm.edu:/usr/src/sys/arch/i386/compile/ENIGMA i386


>Description:
	SCSI disks do not do kernel crash dumps.  This patch enables
	crash dumps to SCSI disk swap partitions when the kernel
	panics.

>How-To-Repeat:

>Fix:


diff -c3 ../sys.old/scsi/sd.c scsi/sd.c
*** ../sys.old/scsi/sd.c	Tue Jun  6 10:40:52 1995
--- scsi/sd.c	Wed Jun 14 10:24:51 1995
***************
*** 859,869 ****
  }


- #define SCSIDUMP 1
- #undef	SCSIDUMP
- #define NOT_TRUSTED 1
- 
- #ifdef SCSIDUMP
  #include <vm/vm.h>

  static struct scsi_xfer sx;
--- 859,864 ----
***************
*** 877,889 ****
  sddump(dev_t dev)
  {				/* dump core after a system crash */
  	register struct sd_softc *sd;	/* disk unit to do the IO */
! 	int32	num;		/* number of sectors to write */
! 	u_int32	unit, part;
! 	int32	blkoff, blkno, nblks = MAXTRANSFER;
! 	int32	nblocks;
  	char	*addr;
  	struct	scsi_rw_big cmd;
! 	extern	int Maxmem;
  	static	int sddoingadump = 0;
  #define MAPTO CADDR1
  	extern	caddr_t MAPTO;	/* map the page we are about to write, here */
--- 872,884 ----
  sddump(dev_t dev)
  {				/* dump core after a system crash */
  	register struct sd_softc *sd;	/* disk unit to do the IO */
! 	int32_t	num;		/* number of sectors to write */
! 	u_int32_t unit, part;
! 	int32_t	blkoff, blkno, nblks = MAXTRANSFER;
! 	int32_t	nblocks;
  	char	*addr;
  	struct	scsi_rw_big cmd;
! 	extern	int physmem;
  	static	int sddoingadump = 0;
  #define MAPTO CADDR1
  	extern	caddr_t MAPTO;	/* map the page we are about to write, here */
***************
*** 894,917 ****
  	addr = (char *) 0;	/* starting address */

  	/* toss any characters present prior to dump */
! 	while ((c = sgetc(1)) && (c != 0x100)); /*syscons and pccons differ */

  	/* size of memory to dump */
! 	num = Maxmem;
  	unit = SDUNIT(dev);	/* eventually support floppies? */
  	part = SDPART(dev);	/* file system */
  	/* check for acceptable drive number */
  	if (unit >= sdcd.cd_ndevs)
  		return ENXIO;

! 	sd = sd_softc[unit];
  	if (!sd)
  		return ENXIO;
  	if (sd->sc_link->flags & SDEV_MEDIA_LOADED != SDEV_MEDIA_LOADED)
  		return ENXIO;

  	/* Convert to disk sectors */
! 	num = (u_int32)num * NBPG / sd->sc_dk.dk_label.d_secsize;

  	/* check if controller active */
  	if (sddoingadump)
--- 889,913 ----
  	addr = (char *) 0;	/* starting address */

  	/* toss any characters present prior to dump */
! 	/* XXX What's the new way of doing this?? */
! 	/* while ((c = sgetc(1)) && (c != 0x100)); */ /*syscons and pccons differ */

  	/* size of memory to dump */
! 	num = physmem;		/* XXX Is there something better than this? */
  	unit = SDUNIT(dev);	/* eventually support floppies? */
  	part = SDPART(dev);	/* file system */
  	/* check for acceptable drive number */
  	if (unit >= sdcd.cd_ndevs)
  		return ENXIO;

! 	sd = sdcd.cd_devs[unit];
  	if (!sd)
  		return ENXIO;
  	if (sd->sc_link->flags & SDEV_MEDIA_LOADED != SDEV_MEDIA_LOADED)
  		return ENXIO;

  	/* Convert to disk sectors */
! 	num = (u_int32_t)num * NBPG / sd->sc_dk.dk_label.d_secsize;

  	/* check if controller active */
  	if (sddoingadump)
***************
*** 929,939 ****
  	blkno = dumplo + blkoff;
  	while (num > 0) {
  		pmap_enter(pmap_kernel(),
! 		    MAPTO,
  		    trunc_page(addr),
  		    VM_PROT_READ,
  		    TRUE);
- #ifndef	NOT_TRUSTED
  		/*
  		 *  Fill out the scsi command
  		 */
--- 925,934 ----
  	blkno = dumplo + blkoff;
  	while (num > 0) {
  		pmap_enter(pmap_kernel(),
! 		    (vm_offset_t)MAPTO,
  		    trunc_page(addr),
  		    VM_PROT_READ,
  		    TRUE);
  		/*
  		 *  Fill out the scsi command
  		 */
***************
*** 970,979 ****
  		retval = (*(sd->sc_link->adapter->scsi_cmd)) (xs);
  		if (retval != COMPLETE)
  			return ENXIO;
! #else	/* NOT_TRUSTED */
  		/* lets just talk about this first... */
! 		printf("sd%d: dump addr 0x%x, blk %d\n", unit, addr, blkno);
! #endif	/* NOT_TRUSTED */

  		if ((unsigned)addr % (1024 * 1024) == 0)
  			printf("%d ", num / 2048);
--- 965,973 ----
  		retval = (*(sd->sc_link->adapter->scsi_cmd)) (xs);
  		if (retval != COMPLETE)
  			return ENXIO;
! 
  		/* lets just talk about this first... */
! 		/* printf("sd%d: dump addr 0x%x, blk %d\n", unit, addr, blkno); */

  		if ((unsigned)addr % (1024 * 1024) == 0)
  			printf("%d ", num / 2048);
***************
*** 983,999 ****
  		(int)addr += 512 * nblks;

  		/* operator aborting dump? */
  		if ((c = sgetc(1)) && (c != 0x100))
  			return EINTR;
  	}
  	return 0;
  }
! #else	/* SCSIDUMP */
! int
! sddump()
! {
! 	printf("\nsddump()        -- not implemented\n");
! 	delay(6000000);		/* 6 seconds */
! 	return -1;
! }
! #endif	/* SCSIDUMP */
--- 977,987 ----
  		(int)addr += 512 * nblks;

  		/* operator aborting dump? */
+ 		/* XXX Again, what the new way to do this?
  		if ((c = sgetc(1)) && (c != 0x100))
  			return EINTR;
+ 		*/
  	}
  	return 0;
  }
! 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: cgd 
State-Changed-When: Sun Jun 25 02:48:55 EDT 1995 
State-Changed-Why:  
claim it. 

This can't be done this way.  however, i've now got a handle on how it can 
be done, etc., and have implemented (but not yet committed) a solution. 


Responsible-Changed-From-To: kern-bug-people->cgd 
Responsible-Changed-By: cgd 
Responsible-Changed-When: Sun Jun 25 02:48:55 EDT 1995 
Responsible-Changed-Why:  
see above. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: cgd 
State-Changed-When: Mon Jun 26 03:17:11 EDT 1995 
State-Changed-Why:  
fixed (drastically) differently. 
Responsible-Changed-From-To: cgd->kern-bug-people 
Responsible-Changed-By: cgd 
Responsible-Changed-When: Sat Aug 19 05:56:42 EDT 1995 
Responsible-Changed-Why:  
remove my name from Responsible line, so future greps for it will fail. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.