[5737] in Athena Bugs

home help back first fref pref prev next nref lref last post

Changes to 7.1 MAKEDEV to support M38 floppies

daemon@ATHENA.MIT.EDU (epeisach@ATHENA.MIT.EDU)
Wed Aug 15 16:51:50 1990

From: epeisach@ATHENA.MIT.EDU
Date: Wed, 15 Aug 90 16:51:25 -0400
To: bugs@ATHENA.MIT.EDU


The following patches do the following:

1) util.c: Print properly character/block device
2) devices-vax.h -- 
	a) Don't overly call nlist (optimization)
		(still reopen /dev/kmem cause of bug in lseek with high
		bit set)
	b) Routine to check for an sg device (I forgot it a year ago)
	c) Routine to scan the scsi bus and determine what devices to
	   make (rz vs tz). It also will check for an rx2 and symlink it
	   as possible. /dev/tape0--n and /dev/floppy0..n will be
           created for all floppies and tapes that exist and floppy will
	   be symlinked to floppy0.
	
This has been tested on VS3100 with sdc rx23
This has been tested on VS3100 with sdc rx23 + tz1 external tape drive
This has been tested on VS3100 with rz500 rx23
This has been tested on VS3100 dialups where primary harddisk is rz9

	Ezra

RCS file: RCS/util.c,v
retrieving revision 1.1
diff -c -r1.1 util.c
*** /tmp/,RCSt1003494	Wed Aug 15 16:43:52 1990
--- util.c	Wed Aug 15 13:53:02 1990
***************
*** 222,228 ****
  	u_short corb;
  	struct stat buf;
  
! 	corb = ((mode & MASK_TYPE == CHAR) ? CHARACTER : BLOCK);
  
  	if(!lstat(name, &buf)) { /*file exists*/
  		if(buf.st_rdev != rdev) {
--- 222,228 ----
  	u_short corb;
  	struct stat buf;
  
! 	corb = (((mode & MASK_TYPE) == CHAR) ? CHARACTER : BLOCK);
  
  	if(!lstat(name, &buf)) { /*file exists*/
  		if(buf.st_rdev != rdev) {
***************
*** 262,268 ****
  		return(0);
  	}
  	else {
! 		if(vflag || nflag) print("Creating %s device %s\n",
  					 TYPE(corb), name);
  		if(nflag) return(0);
  make:	
--- 262,268 ----
  		return(0);
  	}
  	else {
! 		if(vflag || nflag) print("Creating %s %s\n",
  					 TYPE(corb), name);
  		if(nflag) return(0);
  make:	
===================================================================
RCS file: RCS/devices-vax.h,v
retrieving revision 1.1
diff -c -r1.1 devices-vax.h
*** /tmp/,RCSt1003494	Wed Aug 15 16:43:55 1990
--- devices-vax.h	Wed Aug 15 16:43:24 1990
***************
*** 5,10 ****
--- 5,16 ----
   * $Header: /afs/athena.mit.edu/user/e/epeisach/dev/RCS/devices-vax.h,v 1.1 90/08/09 14:45:23 epeisach Exp Locker: epeisach $
   */
  
+ #include <sys/devio.h>
+ #include <sys/time.h>
+ #include <vaxscsi/scsivar.h>
+ #include <vaxscsi/scsireg.h>
+ #include <machineio/sdcreg.h>
+ 
  /*
   * Local procedures (forward declarations)
   */
***************
*** 11,17 ****
  int build_tape();
  int build_mt(), build_dz_np();
  int build_iilock();
! int make_vs2_fl_links(), make_vax(), make_tmscp();
  /*
   * Local tables (forward declarations)
   */
--- 17,25 ----
  int build_tape();
  int build_mt(), build_dz_np();
  int build_iilock();
! int make_vs2_fl_links(), make_vax(), make_tmscp(), make_vax_scsi(),
! 	check_sg_create();
! 
  /*
   * Local tables (forward declarations)
   */
***************
*** 33,39 ****
  	tbl_uu[],
  	tbl_rx[],
          tbl_vs[],
!         tbl_cp[]
  	;
  
  /*
--- 41,48 ----
  	tbl_uu[],
  	tbl_rx[],
          tbl_vs[],
!         tbl_cp[],
! 	tbl_sg[]
  	;
  
  /*
***************
*** 192,197 ****
--- 201,207 ----
  	TABLE("sm",	tbl_sm),
  	TABLE("cp",	tbl_cp),
  	TABLE("qd",	tbl_qd),
+ 	TABLE("sg",	tbl_sg),
  	TABLE("plx",	tbl_plx),
  	
  	TABLE("vd",	tbl_vd),
***************
*** 259,264 ****
--- 269,275 ----
  
  struct dev_tbl tbl_vs2000[] = {
  	INCLUDE("sm"),
+ 	{NULL, check_sg_create,	NULL},
  	LINK("floppy",		"rd2a"),
  	LINK("rfloppy",		"rrd2a"),
  	LINK("floppy0",		"floppy"),
***************
*** 270,275 ****
--- 281,288 ----
  
  struct dev_tbl tbl_vax420[] = {
  	INCLUDE("sm"),
+ 	{NULL, check_sg_create,	NULL},
+ #if 0
  	INCLUDE("tz0"),
  	INCLUDE("rz3"),
  	LINK("floppy",		"rd2a"),
***************
*** 278,283 ****
--- 291,298 ----
  	LINK("rfloppy0",	"rfloppy"),
  	DEV_CHANGE("rd2a",	-1, -1, 0666),
  	DEV_CHANGE("rrd2a",	-1, -1, 0666),
+ #endif
+ 	{ NULL, make_vax_scsi, NULL},
  	{ NULL, NULL, NULL }
  };
  
***************
*** 357,362 ****
--- 372,383 ----
  	{NULL, NULL, NULL }
  };
  
+ struct dev_tbl tbl_sg[] = {
+ 	LINK("sgscreen",	"smscreen"),
+ 	DEVICE("sg0",		CHAR, 0, 1,	0, G_WHEEL,	0666),
+ 	{NULL, NULL, NULL }
+ };
+ 
  struct dev_tbl tbl_qd[] = {
  	DEVICE("qd0",		CHAR, 42, 2,	0, G_WHEEL,	0666),
  	DEVICE("mouse",		CHAR,  0, 1,	0, G_WHEEL, 	0666),
***************
*** 601,606 ****
--- 622,635 ----
  		{ "_cpu" },
  #define X_tmsdinfo 3
  		{ "_tmsdinfo" },
+ #define X_sgdinfo 4
+ 		{ "_sgdinfo" },
+ #define X_sz_softc 5
+ 		{ "_sz_softc" },
+ #define	X_nscsi 6
+ 		{ "_nNSCSI" },
+ #define	X_sd_st 7
+ 		{ "_sd_st" },
  		{ "" },
  	};
  
***************
*** 624,640 ****
  	char t[64], t1[64], t2[64], t3[64];
  
  
! 	if (nlist("/vmunix", nl) < 0) {
! 		ERROR("MAKEDEV: make_fl_links - can't get namelist\n");
! 		return;
! 	}
! 	if ((mf = open("/dev/kmem", 0)) < 0) {
! 		ERROR("MAKEDEV: make_fl_links - can't open memory\n");
! 		return;
! 	}
  
  	if (nl[X_ra_info].n_type == 0)
  	  return;
  
  	lseek(mf, (long) nl[X_ra_info].n_value, 0);
  	read(mf, ra_info, sizeof(ra_info));
--- 653,666 ----
  	char t[64], t1[64], t2[64], t3[64];
  
  
! 	if(get_nlist() < 0) return 1;
  
  	if (nl[X_ra_info].n_type == 0)
  	  return;
+ 	if ((mf = open("/dev/kmem", 0)) < 0) {
+ 	    ERROR("MAKEDEV: can't open memory\n");
+ 	    return -1;
+ 	}
  
  	lseek(mf, (long) nl[X_ra_info].n_value, 0);
  	read(mf, ra_info, sizeof(ra_info));
***************
*** 678,695 ****
  	   cpu dependant tables */
  	int mf, cpu;
  
! 	if (nlist("/vmunix", nl) < 0) {
! 		ERROR("MAKEDEV: make_vax - can't get namelist\n");
! 		return 1;
! 	}
  	if (nl[X_cpu].n_type == 0) {
  		ERROR("MAKEDEV: make_vax - cpu not found\n");
  		return 1;
  	}
  	if ((mf = open("/dev/kmem", 0)) < 0) {
! 		ERROR("MAKEDEV: make_vax - can't open memory\n");
! 		return 1;
  	}
  	lseek(mf, nl[X_cpu].n_value, 0);
  	read(mf, &cpu, sizeof(cpu));
  	close(mf);
--- 704,719 ----
  	   cpu dependant tables */
  	int mf, cpu;
  
! 	if(get_nlist() < 0) return 1;
  	if (nl[X_cpu].n_type == 0) {
  		ERROR("MAKEDEV: make_vax - cpu not found\n");
  		return 1;
  	}
  	if ((mf = open("/dev/kmem", 0)) < 0) {
! 	    ERROR("MAKEDEV: can't open memory\n");
! 	    return -1;
  	}
+ 
  	lseek(mf, nl[X_cpu].n_value, 0);
  	read(mf, &cpu, sizeof(cpu));
  	close(mf);
***************
*** 757,774 ****
      int mf, tmsdinfo[NTMS];
      int i;
  
!     if (nlist("/vmunix", nl) < 0) {
! 	ERROR("MAKEDEV: make_vax - can't get namelist\n");
! 	return 1;
!     }
      if (nl[X_cpu].n_type == 0) {
  	ERROR("MAKEDEV: make_vax - cpu not found\n");
  	return 1;
      }
      if ((mf = open("/dev/kmem", 0)) < 0) {
! 	ERROR("MAKEDEV: make_vax - can't open memory\n");
! 	return 1;
      }
      lseek(mf, nl[X_tmsdinfo].n_value, 0);
      read(mf, tmsdinfo, sizeof(tmsdinfo));
  	
--- 781,798 ----
      int mf, tmsdinfo[NTMS];
      int i;
  
!     if(get_nlist() < 0) return 1;
! 
      if (nl[X_cpu].n_type == 0) {
  	ERROR("MAKEDEV: make_vax - cpu not found\n");
  	return 1;
      }
+ 
      if ((mf = open("/dev/kmem", 0)) < 0) {
! 	ERROR("MAKEDEV: can't open memory\n");
! 	return -1;
      }
+ 
      lseek(mf, nl[X_tmsdinfo].n_value, 0);
      read(mf, tmsdinfo, sizeof(tmsdinfo));
  	
***************
*** 805,807 ****
--- 829,989 ----
  	}
      }
  }
+ 
+ check_sg_create()
+ {
+ 	/* Routine to decide if an sg board exists on a particular machine */
+ 	/* Only used for VAX420 and VS2000 */
+ 	int mf;
+ 	caddr_t value;
+ 
+ 	if(get_nlist() < 0) return 1;
+ 	if (nl[X_sgdinfo].n_type == 0) return 0; /* No sg */
+ 
+ 	if ((mf = open("/dev/kmem", 0)) < 0) {
+ 		ERROR("MAKEDEV: can't open memory\n");
+ 		return 1;
+ 	}
+ 
+ 	lseek(mf, nl[X_sgdinfo].n_value, 0);
+ 	read(mf, &value, sizeof(value));
+ 	if(value) return(dev_tbl_lookup("sg"));
+ 	return 0;
+ }
+ 
+ /* VARARGS */
+ int make_vax_scsi(dev, args)
+ char *dev;
+ u_long args[];
+ {
+ 	/* Scan the scsi bus and determine what symlinks are needed
+ 	   for /dev/floppy and /dev/tape.
+ 	*/
+ 
+ 	int mf;
+ 	caddr_t value;
+ 	int nscsi;
+ 	int base, ctl, ret, i, pos, j;
+ 	char buf[10];
+ 	struct sz_softc sz;
+ 	struct sd_st st;
+ 	int found_floppy = 0, found_tape = 0;
+ 	char t[64], t1[64], t2[64], t3[64];
+ 
+ 	if(get_nlist() < 0) return 1;
+ 	if ((nl[X_nscsi].n_type == 0) && (nl[X_sd_st].n_type == 0)) return 0; /* scsi/floppy */
+ 
+ 	if ((mf = open("/dev/kmem", 0)) < 0) {
+ 	    ERROR("MAKEDEV: can't open memory\n");
+ 	    return -1;
+ 	}
+ 
+ /* First check to see if need to create the sdc links */
+ 	if(nl[X_sd_st].n_type) {
+ 	    /* Check for sd_st device */
+ 	    lseek(mf, nl[X_sd_st].n_value, 0);
+ 	    if(read(mf, &st, sizeof(st)) < 0) return 1;
+ 	    if(st.sd_type[2] == DT_RX23H || st.sd_type[2] == DT_RX23D) {
+ 		create_link("floppy0", "rd2a");
+ 		create_link("rfloppy0", "rrd2a");
+ 		change("rd2a", -1, -1, 0666);
+ 		change("rrd2a", -1, -1, 0666);
+ 		found_floppy++;
+ 	    }
+ 	}
+ 
+ 	if(nl[X_nscsi].n_type) {
+ 	    lseek(mf, nl[X_nscsi].n_value, 0);
+ 	    if(read(mf, &nscsi, sizeof(value)) < 0) return 1;
+ 
+ 	    base = nl[X_sz_softc].n_value;
+ 	    
+ 	    for(ctl=0; ctl < nscsi; ctl++) {
+ 		pos = base + ctl*sizeof(struct sz_softc);
+ 		lseek(mf, pos, 0);
+ 		if(read(mf, &sz, sizeof(sz)) < 0 ) {
+ 		    ERROR("MAKEDEV: could not read sz_softc\n");
+ 		    return 1;
+ 		}
+ 		for(i=0; i<NDPS; i++) {
+ 		    if(sz.sc_device[i][0]) {
+ 			sprintf(buf, "rz%d", i + ctl*8);
+ 			if(sz.sc_device[i][0] == 'T') buf[0]='t';
+ 			if(ret=dev_tbl_lookup(buf)) return ret;
+ 			/* The devices have been made, create the links */
+ 			switch (sz.sc_device[i][0]) {
+ 			case 'R':
+ 			    if(sz.sc_device[i][1] != 'X') break;
+ 			    sprintf(t, "rz%da", i + ctl*8);
+ 			    strcpy(t1, "r");
+ 			    strcat(t1, t);
+ 			    strcpy(t2, "floppy0");
+ 			    t2[6] = '0' + found_floppy;
+ 			    strcpy(t3, "r");
+ 			    strcat(t3, t2);
+ 			    create_link(t2, t);
+ 			    create_link(t3, t1);
+ 			    change(t,-1,-1,0666);
+ 			    change(t1,-1,-1,0666);
+ 			    found_floppy++;
+ 			    break;
+ 			case 'T':
+ 			    sprintf(t, "mt%dh", i + ctl*8); /* mt */
+ 			    strcat(t1, "tape0");
+ 			    t1[4] = '0' + found_tape;
+ 			    for(j=0; j<= 3; j++) {
+ 				t2[0]=0;
+ 				t2[1]=0;
+ 				if(j%2 == 1) {
+ 				    t2[0]='n';
+ 				}
+ 				if(j >= 2) {
+ 				    strcat(t2, "r");
+ 				}
+ 				strcpy(t3, t2);
+ 				strcat(t2, t);
+ 				strcat(t3, t1);
+ 				create_link(t3, t2);
+ 				change(t2,-1,-1,0666);
+ 			    }
+ 			    found_tape++;
+ 			    break;
+ 			    
+ 			default:
+ 			    ERROR("Unknown device on SCSI bus\n");
+ 			    break;
+ 			}
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 
+ 	if(found_floppy) {
+ 	    create_link("floppy", "floppy0");
+ 	    create_link("rfloppy", "rfloppy0");
+ 	}
+ 	if(found_tape) {
+ 	    create_link("tape", "tape0");
+ 	    create_link("ntape", "ntape0");
+ 	    create_link("nrtape", "nrtape0");
+ 	    create_link("rtape", "rtape0");
+ 	}
+ 	return 0;
+     }
+ 		    
+ 
+ get_nlist()
+ {
+     static int nlist_done = 0;
+ 
+     if(nlist_done) return 0;
+     if (nlist("/vmunix", nl) < 0) {
+ 	ERROR("MAKEDEV: can't get namelist\n");
+ 	return -1;
+     }
+     nlist_done = 1;
+     return 0;
+ }
+     
+ 
+ 

home help back first fref pref prev next nref lref last post