Subject: kern/1140: SD dumps
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: James Jegers <jimj@enigma.cs.uwm.edu>
List: netbsd-bugs
Date: 06/20/1995 04:05:06
>Number: 1140
>Category: kern
>Synopsis: SD dump code
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Jun 20 04:05:01 1995
>Originator: James Jegers
>Organization:
>Release: 6/1/95<NetBSD-current source date>
>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;
}
!
>Audit-Trail:
>Unformatted: