[comp.sys.tandy] Neat program and info for Tandy 6000 users

monty@larry.sal.wisc.edu (Monty) (01/01/90)

Hello all you Tandy 6000 folks! Here is a public domain program that does 
basically the same thing as the diskstat command.  It has a little nicer
output and I am mainly posting it for instructional purposes.  I figured
out how to do this by dis-assembling and commenting out the T6000 boot-rom,
boot-track, and z80ctl.  I have not yet finished z80ctl but the other 2
are complete.  As time permits I will post some more tricks and tips for
you.  There is some pretty fun stuff in those programs  <For instance
the code that checks to see if you modified z80ctl and then prints out
"Unsupported Version">!  

I also have a file and schematic which show you how to get 7 meg of ram space
out of your 68000 board.  I have converted two machines myself and both of them
have been running with 2 meg for some time.  A friend of mine has done the same
conversion and has been running his 9 user PD unix system with 2 meg for about
6 months with a huge increase in speed.  I have sent the conversion to one
other person to let him try it.  If all goes well I will post the file and then
send the schematic to all those who feel brave enough to try it themselves. It
only costs about $4 to do and 2 hours of time.

If there are others out there interested in the z80 source code I have
commented send me mail.  You may be able to talk me out of some of it.  It
did take quite a bit of time to do so I am a little leary about distributing
it publicly but I did the same thing for the TI-99/4a years ago <UGH!>.  The
main reason I did it was to be able to write driver code for a 8 port serial
board I wanted to build.  <This is currently pushed back in the queue do to
other impending projects and the recent purchase of a 25Mhz 386.>  I also
did it because I hate orphaned machines with no internal documentation!

Oh yes.. just thought of something... the program was compiled using the 3.2
development system.  Thus the -+ option to the compiler.  If you don't have
3.2 you may have to make sure I didn't use any conflicting names in the 
program. Zoiks!

Well.. good luck and have fun!

Monty

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  Makefile
#	  drivestat.c
#	  tracks.doc
#
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#Makefile for drivestat a PD version of diskstat for the T6000
XCC=cc
XCFLAGS=-O -s
XLIBS=
X
Xall: drivestat
X
Xdrivestat: drivestat.o 
X	${CC} -o drivestat drivestat.o ${LIBS}
SHAR_EOF
chmod 0644 Makefile || echo "restore of Makefile fails"
echo "x - extracting drivestat.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > drivestat.c &&
X/* drivestat.c find out info on a hard drive */
X/* Copyright (C) 1989 Monty Schmidt , 1020 E. Johnson #1, Madison, WI 53703 */
X/* This software is released into the public domain, do what you like with
X/* it.  I assume no responsibility whatsoever for it and my purpose in
X/* putting it out is to hopefully spark some other Tandy 6000 users to also
X/* dig around in there system and write some neat utilities.  Use at your
X   own risk! */
X
X
X#define	H_BOOTFILE	"/dev/rhdbt"    /* hard device name */
X#define	PVH_ID		".pvh"		/* tandy pvh identifier */
X#define	BADTRK_ID	".bad"		/* tandy bad track identifier */
X
X#include "fcntl.h"
X
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
Xchar bootfile[50];
Xchar drivename[50];
Xfloat percbad;
Xint i;
Xint rawfd;
Xint heads,sectors,cylinders;
Xint badtmax,totbadt;
Xlong blocks,totbadb;
Xchar pvhbuf[512];
Xchar btbuf[512];
X
Xsprintf(bootfile,"%s0",H_BOOTFILE); /* set default name to HD0 */
Xsprintf(drivename,"Statting Hard drive 0");
X
Xif (argc>1){
X	if (argv[1][0]<'0' || argv[1][0]>'3'){
X	  	printf("\
X%s usage -- %s <[0-3]>\n\
XShow stats on a hard disk device\n",argv[0],argv[0]);
X		exit(1);
X		}	
X	sprintf(bootfile,"%s%c",H_BOOTFILE,argv[1][0]);
X	sprintf(drivename,"Statting Hard drive %c",argv[1][0]);
X	}	
X
Xprintf("\n%s\n\n",drivename);
X
Xif ((rawfd=open(bootfile,O_RDONLY))<0){
X	printf("ERROR could not open raw boot device %s\n",bootfile);
X	exit(1);
X	}
X
Xread(rawfd,pvhbuf,512);		/* read the pvh sector */
X
Xif (check_id(PVH_ID,pvhbuf))
X	printf("* ERROR * Inconsistent pvh identifier results may be incorrect.\n");
X
Xread(rawfd,btbuf,512);		/* skip next sector */
Xread(rawfd,btbuf,512);		/* read bad track sector */
X
Xif (check_id(BADTRK_ID,btbuf))
X	printf("* ERROR * Inconsistent bad track identifier results may be incorrect.\n");
X
Xprintf("Cylinders %d Heads %d Sectors %d\n",
X			cylinders=get_val(pvhbuf,6),heads=get_val(pvhbuf,8),
X			sectors=get_val(pvhbuf,10));
X
Xblocks=cylinders*sectors*heads;
X
Xprintf("Max bad tracks allowed %d Total Bad tracks %d\n",
X			badtmax=get_val(btbuf,4),totbadt=get_val(btbuf,6));
Xtotbadb=totbadt*heads*sectors;
X
Xprintf("%ld bad blocks <%.2fM> %ld good blocks <%.2fM>\n",
X		totbadb,(float) totbadb/2000,blocks,(float)blocks/2000);
X
Xprintf("total blocks %ld <%.2fM>   ",(totbadb+blocks),
X			(float) (totbadb+blocks)/2000);
X
Xpercbad=(float) totbadb * 100 ;
Xpercbad/= (float) (totbadb+blocks);
Xprintf("%.2f%% in bad blocks\n",percbad);
X
Xprintf("\nbad track list <cylinder>,<head>: \n");
Xfor (i=0;i<totbadt;i++){
X	printf("%d,%d     ",get_val(btbuf,(i*4+8)),get_val(btbuf,(i*4+10)));
X	if (i%6==5)
X		printf("\n");
X}
Xprintf("\n");
X
X}
X
X
X/* compare the 2 id's passed in */
X
Xcheck_id(id,sector)
Xchar *id;
Xchar *sector;
X{
Xint i;
X
Xfor (i=0;i<4;i++){
X	if (*id != *sector)
X		return(1);
X	id++; sector++;
X	}
Xreturn(0);
X}
X
X
X/* get a int val from a sector buffer offset bytes in */
X
Xget_val(sector,offset)
Xchar *sector;
Xint offset;
X{
Xint rval=0;
X
Xsector+=offset;
Xrval= *sector;
Xrval=(rval & 0xff) * 256;
Xsector++;
Xoffset= *sector;
Xrval+= (0xff & offset);
Xreturn(rval);
X}
X	
X
SHAR_EOF
chmod 0644 drivestat.c || echo "restore of drivestat.c fails"
echo "x - extracting tracks.doc (Text)"
sed 's/^X//' << 'SHAR_EOF' > tracks.doc &&
XBoot track Information for Tandy 6000 
X
XMonty Schmidt
X1020 E. Johnson #1
XMadison, WI 53703
XNov 21, 1989
X
XThis information is my best guess after disassembly of the Tandy 6000 boot rom,
Xboot track, and z80ctl.  Use it as you see fit but don't blame if it is wrong.
XI'd appreciate it if you can fill in any of the blanks!
X
X
XThe boot track of the Tandy 6000 is organized as follows:
X
XAll references are to cylinder 0.
X
X
XSector 1 : Pvh 
XSector 2 : Unused?
XSector 3 : Bad track table
XSector 4 : Unused
XSector 5 : Start of boot code
XSector X : contains "/* END BOOT */" starting in first byte
X
XSectors 5-X are the boot code
X
X
XFormat of Pvh :
X
Xbytes
X
X0-3h	:	".pvh"	pvh sector identifier
X4-5h	:	?????	<16>
X6-7h	:	number of cylinders
X8-9h	:	number of heads
Xa-bh	:	number of sectors per track
Xc-dh	:	??????	<512>
Xe-fh	:	??????	<512>
X10-11h	:	keyboard type	0000=normal 0001h=tandy 2000 or 1000
X12-200h : 	0000h 
X
XFormat of Bad Track table :
X
Xbytes
X
X0-3h	:	".bad"	bad track table identifier
X4-5h	:	0060h	max bad track entries
X6-7h	:	number of bad track entries in table
X8-bh	:	1st bad track entry, ww,ww cylinder,head
Xc-fh	:	next entry and so on
X
SHAR_EOF
chmod 0644 tracks.doc || echo "restore of tracks.doc fails"
exit 0