From ced8be4147ee89746ba99d59fa44facdfee7f85e Mon Sep 17 00:00:00 2001 From: chuck Date: Sat, 13 Jan 1996 03:45:01 +0000 Subject: [PATCH] - call mapiodev() with sizeof(struct xdc/xyc) rather than ra_len (which is zero since xdcmatch/xycmatch no longer sets it). [if you call mapiodev() with a zero size it will reuse the KVA it returns, swiping the device out from under you!] - make xdc/xyc->iopbase point in the kernels DVMA space rather than at the normal malloc'd KVA. this isn't compatable with sun4m [doesn't have a kernel DVMA space] and will need to be changed later (XXX). - move disk_attach() to before reading the disk label as per Jason. otherwise we are reading into an unallocated buffer (oops!) --- sys/arch/sparc/dev/xd.c | 11 ++++++----- sys/arch/sparc/dev/xy.c | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c index 680c61cbe97..7c649161b24 100644 --- a/sys/arch/sparc/dev/xd.c +++ b/sys/arch/sparc/dev/xd.c @@ -36,7 +36,7 @@ * x d . c x y l o g i c s 7 5 3 / 7 0 5 3 v m e / s m d d r i v e r * * author: Chuck Cranor - * id: $Id: xd.c,v 1.4 1996/01/12 23:09:08 chuck Exp $ + * id: $Id: xd.c,v 1.5 1996/01/13 03:45:01 chuck Exp $ * started: 27-Feb-95 * references: [1] Xylogics Model 753 User's Manual * part number: 166-753-001, Revision B, May 21, 1988. @@ -388,7 +388,7 @@ xdcattach(parent, self, aux) * into our xdc_softc. */ ca->ca_ra.ra_vaddr = mapiodev(ca->ca_ra.ra_reg, 0, - ca->ca_ra.ra_len, ca->ca_bustype); + sizeof(struct xdc), ca->ca_bustype); xdc->xdc = (struct xdc *) ca->ca_ra.ra_vaddr; pri = ca->ca_ra.ra_intr[0].int_pri; @@ -408,6 +408,7 @@ xdcattach(parent, self, aux) xdc->dvmaiopb = (struct xd_iopb *) dvma_malloc(XDC_MAXIOPB * sizeof(struct xd_iopb), &xdc->iopbase, M_NOWAIT); + xdc->iopbase = xdc->dvmaiopb; /* XXX TMP HACK */ bzero(xdc->iopbase, XDC_MAXIOPB * sizeof(struct xd_iopb)); /* Setup device view of DVMA address */ xdc->dvmaiopb = (struct xd_iopb *) ((u_long) xdc->iopbase - DVMA_BASE); @@ -652,6 +653,9 @@ xdattach(parent, self, aux) newstate = XD_DRIVE_NOLABEL; xd->hw_spt = spt; + /* Attach the disk: must be before getdisklabel to malloc label */ + disk_attach(&xd->sc_dk); + if (xdgetdisklabel(xd, xa->buf) != XD_ERR_AOK) goto done; @@ -718,9 +722,6 @@ xdattach(parent, self, aux) bootdv = &xd->sc_dev; } - /* Attach the disk. */ - disk_attach(&xd->sc_dk); - dk_establish(&xd->sc_dk, &xd->sc_dev); /* XXX */ done: diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c index 2b19a664b31..952522699e2 100644 --- a/sys/arch/sparc/dev/xy.c +++ b/sys/arch/sparc/dev/xy.c @@ -36,7 +36,7 @@ * x y . c x y l o g i c s 4 5 0 / 4 5 1 s m d d r i v e r * * author: Chuck Cranor - * id: $Id: xy.c,v 1.4 1996/01/12 23:09:10 chuck Exp $ + * id: $Id: xy.c,v 1.5 1996/01/13 03:45:03 chuck Exp $ * started: 14-Sep-95 * references: [1] Xylogics Model 753 User's Manual * part number: 166-753-001, Revision B, May 21, 1988. @@ -331,7 +331,7 @@ xycattach(parent, self, aux) * into our xyc_softc. */ ca->ca_ra.ra_vaddr = mapiodev(ca->ca_ra.ra_reg, 0, - ca->ca_ra.ra_len, ca->ca_bustype); + sizeof(struct xyc), ca->ca_bustype); xyc->xyc = (struct xyc *) ca->ca_ra.ra_vaddr; pri = ca->ca_ra.ra_intr[0].int_pri; @@ -366,6 +366,7 @@ xycattach(parent, self, aux) } bzero(tmp, pbsz); xyc->iopbase = tmp; + xyc->iopbase = dtmp; /* XXX TMP HACK */ xyc->dvmaiopb = (struct xy_iopb *) ((u_long)dtmp - DVMA_BASE); xyc->reqs = (struct xy_iorq *) malloc(XYC_MAXIOPB * sizeof(struct xy_iorq), M_DEVBUF, M_NOWAIT); @@ -586,6 +587,9 @@ xyattach(parent, self, aux) newstate = XY_DRIVE_NOLABEL; xy->hw_spt = spt = 0; /* XXX needed ? */ + /* Attach the disk: must be before getdisklabel to malloc label */ + disk_attach(&xy->sc_dk); + if (xygetdisklabel(xy, xa->buf) != XY_ERR_AOK) goto done; @@ -682,9 +686,6 @@ xyattach(parent, self, aux) bootdv = &xy->sc_dev; } - /* Attach the disk. */ - disk_attach(&xy->sc_dk); - dk_establish(&xy->sc_dk, &xy->sc_dev); /* XXX */ done: -- 2.20.1