Subject: new config
To: Phil Budne <budd@cs.bu.edu>
From: Matthias Pfaller <leo@marco.de>
List: port-pc532
Date: 10/21/1994 14:09:00
Hi,

the following are my current patches to get newconfig working with 532bsd.
I didn't do intensive testing (I'm still running the oldconfig kernel as
my development kernel). As you'll see it's only necessary to delete code
to get the newconf stuff working...

	Matthias

#!/bin/sh
# This is a shell archive (shar 3.24)
# made 10/21/1994 13:06 UTC by leo@ra.marco.de
# Source directory /node/ra/leo/tmp/532
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   1184 -rw-r--r-- autoconf.c.cd
#   5087 -rw-r--r-- nncr.c.cd
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= autoconf.c.cd ==============
echo "x - extracting autoconf.c.cd (Text)"
sed 's/^X//' << 'SHAR_EOF' > autoconf.c.cd &&
X+++ autoconf.c	Tue Oct 18 00:05:21 1994
X@@ -279,47 +279,22 @@
X       {	NULL, "membus", membusprobe, membusattach,
X 	DV_DULL, sizeof(struct device), NULL, 0 };
X 
X-static int
X-membusprint(aux, name)
X-	void	*aux;
X-	char	*name;
X-{
X-	if (name)
X-		printf("%s at %s", *(char **)aux, name);
X-	return(UNCONF);
X-}
X-
X membusprobe(parent, cf, aux)
X 	struct device	*parent;
X 	struct cfdata	*cf;
X 	void		*aux;
X {
X-  return (strcmp(cf->cf_driver->cd_name, "membus") == 0);
X+	return (strcmp(cf->cf_driver->cd_name, "membus") == 0);
X }
X 
X-static	char *name_list[] =
X-	{"scn", "scn", "scn", "scn", "scn", "scn", "scn", "scn",
X-	 "ncr", /* "dp", "aic", */ NULL };
X-
X void
X-membusattach(parent, dev, aux)
X-	struct device	*parent, *dev;
X- 	void		*aux;
X+membusattach(parent, self, args)
X+	struct device *parent, *self;
X+ 	void *args;
X {
X-	char **name;
X-	int	fail=0;
X-
X 	printf ("\n");
X 
X-	for (name=name_list ; name ; name++) {
X-		if (!config_found(dev, name, membusprint)) {
X-			fail++;
X-		}
X-	}
X-
X-	if (fail) {
X-		printf("Failed to find %d required devices.\n", fail);
X-		panic("Can't continue.");
X-	}
X+	while (config_found(self, NULL, NULL))
X+		;
X }
X #endif
SHAR_EOF
$TOUCH -am 1020225994 autoconf.c.cd &&
chmod 0644 autoconf.c.cd ||
echo "restore of autoconf.c.cd failed"
set `wc -c autoconf.c.cd`;Wc_c=$1
if test "$Wc_c" != "1184"; then
	echo original size 1184, current size $Wc_c
fi
# ============= nncr.c.cd ==============
echo "x - extracting nncr.c.cd (Text)"
sed 's/^X//' << 'SHAR_EOF' > nncr.c.cd &&
X+++ nncr.c	Wed Oct 19 17:50:12 1994
X@@ -113,20 +113,17 @@
X 
X #define NNCR5380	1
X 
X-struct ncr5380_data {
X+struct ncr5380_softc {
X 	struct device		sc_dev;
X-
X-	void			*reg_base;
X-	int			adapter_target;
X 	struct scsi_link	sc_link;
X-} *ncr5380data[NNCR5380];
X+};
X 
X /* From the mapping of the pc532 address space.  See pc532/machdep.c */
X static volatile sci_padded_regmap_t	*ncr  =   (sci_regmap_t *) 0xffd00000;
X static volatile long			*sci_4byte_addr=  (long *) 0xffe00000;
X static volatile u_char			*sci_1byte_addr=(u_char *) 0xffe00000;
X 
X-static unsigned int	ncr5380_adapter_info(struct ncr5380_data *ncr5380);
X+static unsigned int	ncr5380_adapter_info(struct ncr5380_softc *ncr5380);
X static void		ncr5380_minphys(struct buf *bp);
X static int		ncr5380_scsi_cmd(struct scsi_xfer *xs);
X 
X@@ -175,7 +172,7 @@
X 
X struct cfdriver ncrcd =
X       {	NULL, "ncr", ncrprobe, ncrattach,
X-	DV_DULL, sizeof(struct ncr5380_data), NULL, 0 };
X+	DV_DULL, sizeof(struct ncr5380_softc), NULL, 0 };
X 
X static int
X ncr_print(aux, name)
X@@ -187,31 +184,11 @@
X }
X 
X static int
X-ncrprobe(parent, cf, aux)
X-	struct device	*parent;
X-	struct cfdata	*cf;
X+ncrprobe(parent, self, aux)
X+	struct device	*parent, *self;
X 	void		*aux;
X {
X-	int			unit = cf->cf_unit;
X-	struct ncr5380_data	*ncr5380;
X-
X-	if (strcmp(*((char **) aux), ncrcd.cd_name)) {
X-		return 0;
X-	}
X-
X- 	if (unit >= NNCR5380) {
X-			unit+1, NNCR5380);
X-		return 0;
X-	}
X-	ncr5380 = malloc(sizeof(struct ncr5380_data), M_TEMP, M_NOWAIT);
X-	if (!ncr5380) {
X-		return 0;
X-	}
X-
X-	bzero(ncr5380, sizeof(*ncr5380));
X-	ncr5380data[unit] = ncr5380;
X+	struct nc5380_softc *ncr5380 = (void *)self;
X 
X 	/* If we call this, we need to add SPL_DP to the bio mask! */
X 	/*  PL_bio |= SPL_DP;  Not yet ... no interrupts */
X@@ -221,34 +198,27 @@
X }
X 
X static void
X-ncrattach(parent, dev, aux)
X-	struct device	*parent, *dev;
X+ncrattach(parent, self, aux)
X+	struct device	*parent, *self;
X 	void		*aux;
X {
X-register volatile sci_padded_regmap_t	*regs = ncr;
X-	int				unit = dev->dv_unit;
X-	struct ncr5380_data		*ncr5380 = ncr5380data[unit];
X-	int				r;
X-
X-	bcopy((char *) ncr5380 + sizeof(struct device),
X-	      (char *) dev + sizeof(struct device),
X-	      sizeof(struct ncr5380_data) - sizeof(struct device));
X-	free(ncr5380, M_TEMP);
X-
X-	ncr5380data[unit] = ncr5380 = (struct ncr5380_data *) dev;
X+	register volatile sci_padded_regmap_t *regs = ncr;
X+	struct ncr5380_softc *ncr5380 = (void *)self;
X+	int r;
X 
X-	ncr5380->sc_link.scsibus = unit;
X+	ncr5380->sc_link.adapter_softc = ncr5380;
X+	ncr5380->sc_link.scsibus = 0;
X 	ncr5380->sc_link.adapter_targ = 7;
X 	ncr5380->sc_link.adapter = &ncr5380_switch;
X 	ncr5380->sc_link.device = &ncr_dev;
X 
X 	printf("\n");
X 
X-	config_found(dev, &(ncr5380->sc_link), ncr_print);
X+	config_found(self, &(ncr5380->sc_link), ncr_print);
X }
X 
X static unsigned int
X-ncr5380_adapter_info(struct ncr5380_data *ncr5380)
X+ncr5380_adapter_info(struct ncr5380_softc *ncr5380)
X {
X 	return 1;
X }
X@@ -308,16 +278,15 @@
X 	}
X 	 */
X 
X-printf ("before ncr5380_send_cmd\n");
X 	r = ncr5380_send_cmd(xs);
X-printf ("after ncr5380_send_cmd\n");
X 	xs->flags |= ITSDONE;
X-	scsi_done(xs);
X 	switch(r) {
X+		case COMPLETE:
X+		case SUCCESSFULLY_QUEUED:
X 			r = SUCCESSFULLY_QUEUED;
X 			if (xs->flags&SCSI_NOMASK)
X 				r = COMPLETE;
X+			scsi_done(xs);
X 			break;
X 		default:
X 			break;
X@@ -346,8 +315,8 @@
X 		printf("ncr5380(%d:%d:%d)-",
X 			xs->sc_link->scsibus, xs->sc_link->target, xs->sc_link->lun);
X 		while (i < xs->cmdlen) {
X-			if (i) printf(",");
X-			printf("%x",b[i++]);
X+			if (i) printf(" ");
X+			printf("%02x",b[i++]);
X 		}
X 		printf("-\n");
X 	} else {
X@@ -437,7 +406,12 @@
X 	int	s;
X 	int	sense;
X 
X-	ncr5380_show_scsi_cmd(xs); 
X+#if 0
X+	if (xs->sc_link->target > 1) {
X+		ncr5380_show_scsi_cmd(xs);
X+		show_mem(xs->data, xs->datalen);
X+	}
X+#endif
X 	s = splbio();
X 	sense = scsi_gen( xs->sc_link->scsibus, xs->sc_link->target,
X 			  xs->sc_link->lun, xs->cmd, xs->cmdlen,
X@@ -445,8 +419,11 @@
X 	splx(s);
X 	if (sense) {
X 		switch (sense) {
X-/*				printf("check cond. target %d.\n", xs->targ);*/
X+		case 0x02:	/* Check condition */
X+#if 0
X+				if (xs->sc_link->target > 1)
X+					printf("check cond target %d\n", xs->sc_link->target);
X+#endif
X 				s = splbio();
X 				scsi_group0(xs->sc_link->scsibus,
X 					    xs->sc_link->target,
X@@ -455,6 +432,10 @@
X 					    sizeof(struct scsi_sense_data),
X 					    0, (caddr_t) &(xs->sense),
X 					    sizeof(struct scsi_sense_data));
X+#if 0
X+				if (xs->sc_link->target > 1)
X+					show_mem(&xs->sense, sizeof(struct scsi_sense_data));
X+#endif
X 				splx(s);
X 				xs->error = XS_SENSE;
X 				return HAD_ERROR;
X@@ -822,7 +803,7 @@
X   register volatile sci_padded_regmap_t *regs = ncr;
X   int i,j,sent,ret;
X 
X-  cmd->bytes[0] = ((u_char) lun << 5);
X+  cmd->bytes[0] |= ((u_char) lun << 5);
X 
X   i = scsi_request(regs, id, lun, (u_char *) cmd, cmdlen,
X 		   databuf, datalen, &sent, &ret);
SHAR_EOF
$TOUCH -am 1020225494 nncr.c.cd &&
chmod 0644 nncr.c.cd ||
echo "restore of nncr.c.cd failed"
set `wc -c nncr.c.cd`;Wc_c=$1
if test "$Wc_c" != "5087"; then
	echo original size 5087, current size $Wc_c
fi
exit 0