[comp.sys.nsc.32k] Kernel diffs

sverre@lars.Seri.GOV (Sverre Froyen) (05/10/91)

Here are the diffs to scsi_hi.c to get my floppy drive to work.
The mode select commands set the controller up for IBM PC formatted
diskettes 720kB for fd0 and 1.44MB for fd1 and fdboot.  Please note
that the code that switches between the two types of diskettes is
a quick hack (ifdefed by FLOPPY).  I more general solution might be
to add a flag field to the partition structure and to the drive
structure and check for matches/mismatches between these.

NOTE1: I added a copy of my partition.h file (renamed partition.sverre)

NOTE2: Anybody who orders the disk drive and plans to program it
should also order a copy of the programming manual and the harware
manual.  I had to wait a week after receiving my drive (and realizing
it came with no documentation) before TEAC sent me the manuals.

PS. I used the fdboot partition to create a boot diskette with a kernel
image at the start of the disk.

-- 
Sverre Froyen
sverre@seri.gov, sunpeaks!seri!sverre


echo x - scsi_hi.cdiff
sed '/^X/s///' > scsi_hi.cdiff << '/'
X*** dist/scsi_hi.c	Mon May  6 21:17:28 1991
X--- scsi_hi.c	Wed May  8 19:57:13 1991
X***************
X*** 143,148 ****
X--- 143,177 ----
X  const struct cmd_desc default_init0 =	/* default device init cmd list */
X  	{test_unit_rdy_cmd, 0, &default_init1, sizeof(test_unit_rdy_cmd), 0};
X  
X+ #define FLOPPY
X+ #ifdef FLOPPY
X+ const U8 floppy_mdsl144_data[] =	/* mode select data 1.44 MB (IBM) */
X+ 	{   0, 0x28,    0,    0};
X+ const U8 floppy_mdsl720_data[] =	/* mode select data 720 kB (IBM) */
X+ 	{   0, 0x23,    0,    0,
X+ 	 0x05, 0x1e,    0, 0xfa, 0x02, 0x09, 0x02,    0,
X+ 	    0, 0x50,    0,    0,    0,    0,    0, 0x1e,
X+ 	    0,    0, 0xdc, 0x05, 0x46, 0x60, 0x01,    0,
X+ 	    0,    0, 0x25,    0,    0,    0,    0,    0};
X+ 
X+ U8 floppy_mdsl144_cmd[] = {0x15, 0x10, 0, 0, 0x04, 0};
X+ U8 floppy_mdsl720_cmd[] = {0x15, 0x10, 0, 0, 0x24, 0};
X+ 
X+ const struct cmd_desc floppy_init2 =
X+ 	{rezero_cmd, 0, 0, sizeof(rezero_cmd), 0};
X+ const struct cmd_desc floppy_init144 =	/* floppy device init 1.44 MB */
X+ 	{floppy_mdsl144_cmd, floppy_mdsl144_data, &floppy_init2,
X+ 	sizeof(floppy_mdsl144_cmd), sizeof(floppy_mdsl144_data)};
X+ const struct cmd_desc floppy_init720 =	/* floppy device init 720 kB */
X+ 	{floppy_mdsl720_cmd, floppy_mdsl720_data, &floppy_init2,
X+ 	sizeof(floppy_mdsl720_cmd), sizeof(floppy_mdsl720_data)};
X+ 
X+ const struct cmd_desc floppy_init0 =	/* floppy device init cmd list */
X+ 	{test_unit_rdy_cmd, 0, 0, sizeof(test_unit_rdy_cmd), 0};
X+ 
X+ int floppy_last = -1;
X+ #endif
X+ 
X  #ifdef OMTI
X  /* If you have an OMTI floppy/harddisk controller, then #define OMTI.
X   * These SCSI commands initialize a OMTI 5200 SCSI controller with a 360K
X***************
X*** 296,301 ****
X--- 325,345 ----
X  	    printf ("SCSI cannot initialize device\n");
X  	    return NOT_OK;
X  	  }
X+ #ifdef FLOPPY
X+ 	if (FLOPPY_DEV(drive) && floppy_last != drive) {
X+           drivep->stat &= ~INITIALIZED;
X+ 	  if (FLOPPY_HD(drive))
X+ 	    drivep->init = &floppy_init144;
X+ 	  else
X+ 	    drivep->init = &floppy_init720;
X+ 	  if (OK != sc_initialize (drivep)) {	/* mode select */
X+ 	    floppy_last = -1;
X+ 	    printf ("SCSI floppy mode select failed\n");
X+ 	    return NOT_OK;
X+ 	  }
X+ 	floppy_last = drive;
X+ 	}
X+ #endif
X        sc_format_rdwr (sector + cmd,	/* format command args */
X          m_ptr, drivep, sc_args, sec_per_cmd, len);
X        if (OK ==				/* execute the command */
/
echo x - partition.sverre
sed '/^X/s///' > partition.sverre << '/'
X/* This is the local definition file for drives and partitions. 
X
X/* Drive 0 (scsi_adr 1) is Micropolis 1375 with 142520*2 blocks */
X/* Drive 1 (scsi_adr 2) is Micropolis 1578 with 323988*2 blocks */
X/* Drive 2 (scsi_adr 4) is TEAC 720kB/1.44MB floppy drive */
X
X/* Drive table */
XPRIVATE struct drive drive_tbl[] = {
X  {1, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
X  {2, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
X#ifdef FLOPPY
X  {4, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &floppy_init0},
X#endif
X};
X#define DRV_TBL_SZ (sizeof (drive_tbl) / sizeof (struct drive))
X
X/* Partition table */
XPRIVATE
Xstruct partition_tbl part_tbl [] = {
X/* start	length	drive		interleave */
X  {0,		142520,	&drive_tbl[0], 1},		/* /dev/hd0 */
X  {0,		  1024,	&drive_tbl[0], 1},		/* /dev/hd1 */
X  {  1024,	 10000,	&drive_tbl[0], 1},		/* /dev/hd2 */
X  { 11024,	 30000,	&drive_tbl[0], 1},		/* /dev/hd3 */
X  { 41024,	 30000,	&drive_tbl[0], 1},		/* /dev/hd4 */
X  { 71024,	 40000,	&drive_tbl[0], 1},		/* /dev/hd5 */
X  {112024,	  1024,	&drive_tbl[0], 1},		/* /dev/hd6 */
X  {112048,	     0,	&drive_tbl[0], 1},		/* /dev/hd7 */
X  {0,		323988,	&drive_tbl[1], 1},		/* /dev/hd8 */
X  {0,		  1024,	&drive_tbl[1], 1},		/* /dev/hd9 */
X  {  1024,	 10000,	&drive_tbl[1], 1},		/* /dev/hd10 */
X  { 11024,	 64000,	&drive_tbl[1], 1},		/* /dev/hd11 */
X  { 75024,	 64000,	&drive_tbl[1], 1},		/* /dev/hd12 */
X  {139024,	 64000,	&drive_tbl[1], 1},		/* /dev/hd13 */
X  {203024,	 64000,	&drive_tbl[1], 1},		/* /dev/hd14 */
X  {267024,	 56964,	&drive_tbl[1], 1},		/* /dev/hd15 */
X#ifdef FLOPPY
X  {0,		   720,	&drive_tbl[2], 1},		/* /dev/fd0 (16) */
X  {0,		  1440,	&drive_tbl[2], 1},		/* /dev/fd1 (17) */
X  {256,		  1184,	&drive_tbl[2], 1},		/* /dev/fdboot (18) */
X#endif
X};
X
X#ifdef FLOPPY
X#define FLOPPY_DEV(x)	((x) == 16 || (x) == 17 || (x) == 18)
X#define FLOPPY_HD(x)	((x) == 17 || (x) == 18)
X#endif
/