/*********************************************************************** * file: sony_sys.h * * ************************************************************** * * "(c)Copyright Hewlett-Packard Company, 1984.* All * * * rights are reserved. Copying or other reproduction * * * of this program except for archival purposes is * * * prohibited without the prior written consent of * * * Hewlett-Packard Company." * * ************************************************************** * * Pisces project * Jim Andreas * ----------------------------------------------------- * ***********************************************************************/ #define SPARES 4 #define SECTORSIZE 256 #define SECTORSHIFT 8 #define SECTPERBLK (BSIZE/SECTORSIZE) /* * general READ, WRITE operation definitions for parm passing */ #define READ 1 /* read parameter */ #define WRITE 0 /* write parmater */ /* * Phsyical track 79 is designated the priviledged track */ #define PRIVTRACK 79 /* * The sector numbers for the special sectors on the * priviledged track are described below: */ #define WEAR_SECTOR 0x61 /* has wear and boundary info */ #define CONFIG_SECTOR 0x62 /* has diskette config info */ #define RWTEST_SECTOR 0x63 /* sector for self test */ #define KEY_SECTOR 0x64 /* has 14 byte key to diskette */ #define TEST_SECTOR 0x65 /* another test sector */ /* * max track to format (2*77 because physical track * is decoded by track/2; bit 0 determines which head * Two spares, sony double sided drive. Allows for four * spared tracks, plus the priviledged track. */ #define MAX_TRACK 2*77-1 #define SONY_BASE 0x610000 /* base address for Pisces */ #define FALSE 0 #define TRUE 1 #define SOFT_RETRY 10 /* Number of soft error retries per op */ /* * TIMEOUT RETRY defines the number of retry loops to attempt * when a timeout occurs on a read or write of a sector. * NB: The actual loop count is SOFT_RETRY * TIMEOUT_RETRY due * to for loop nesting. */ #define TIMEOUT_RETRY 3 #define unit(x) ((x & 0x18)>>3) /* extract unit field from dev */ #define MIN(x) (x & 0x07) /* " Mount Instance Number from dev */ /* * the timeout values for operation with 256, 512, and 1024 * byte sectors are defined below. The sony_timeout * variable is set to the appropriate value before sector r/w * operation is attempted. The timeout value is "tuned", * that is, adjusted to be the count required to get through * the sector transfer loop plus a safety margin. */ #define SONY_TIMEOUT_256 600 #define SONY_TIMEOUT_512 1300 #define SONY_TIMEOUT_1024 2600 /* * sony_timeout must be a short!! (Wired in to sony_rws.s). */ short sony_timeout; /* timeout value for sector r/w */ /* * variables shared between sony1.c and sony2.c follow: * The variables may be in array form so as to keep track * of two discs independently. */ int ltrack; /* logical track requested */ short sony_doublesided[2]; /* double sided flag */ short just_seeked; /* flag indicating if a seek just took place */ int sony_wear[2]; /* wear accumulator */ int sony_access[2]; /* disc usage flag, used to signal head load */ /* * sony_click is a flag which indicates that first level wear has * been accumulated on the disc media. The sony_checkdisc routine * examines this flag, and clicks the disc head if the flag is set. */ int sony_click[2]; /* * sony_writeprotect flags that second level wear has been * accumulated on the disc media, and the disc should be write * protected to discourage further use of the media. */ int sony_writeprotect[2]; /* * sony_seek_table is used by sony_seek to perform * a quick divide. It is setup to contain * multiples of the sectors per track for a given disc. */ struct { int times100; int times10; int times1; } sony_seek_table[2]; /* * sony_privbuf is a buffer used when operating on the * priviledged track */ #define PRIVBUFSIZE 1024 unsigned char sony_privbuf[PRIVBUFSIZE]; /* * invis_tracks is a flag indicating if invisible tracks have been * encountered. Cleared in sony_open, set in sony_seeklog, * tested in sony_seek. When set, it indicates that a logical * to physical conversion need to take place. */ unsigned short invis_tracks[2]; /* * sony_gotspecs flags when the specs for the current * disc have been determined. The specs refer to whether * the disc is single or double sided. */ unsigned short sony_gotspecs[2]; #ifdef notdef /* * sony_devcache and sony_trkcache remember the device number * and track which are associated with the track cache */ int sony_devcache; int sony_trkcache; #endif /* * sony_savetime saves the time of creation for the disc * currently being used, for subsequent requests. */ time_t sony_savetime[2]; /* * sony_ctrack keeps track of the current track, sony_chead for * the current head. */ unsigned short sony_ctrack[2]; /* contains current track location */ unsigned short sony_chead[2]; /* contains current head info */ /* * sony_otherhead flags to the seek routine to use the physical * head opposite of logical head called for by sony_chead */ unsigned short sony_otherhead[2]; /* contains head flag info */ /* * The disc_changed flags are set either in the strategy * routine or by an interrupt poller routine. The latter * senses asynchronous disc changing. */ unsigned short disc_changed[2]; /* disk changed flag */ unsigned short no_disk[2]; /* no disk flag */ unsigned short sony_sector[2]; /* which sector to operate on */ /* * the volume label for the current discs is kept around * in case an application, such as .daemon, wants to mount * the disc */ unsigned char sony_volume[2][6]; /* volume label for current disc */ dev_t dev_in_use[2]; /* current device number being used */ unsigned short sony_poweron; /* 1 if discs are powered on */ unsigned short sony_busy; /* flag for driver busy */ unsigned short sony_pwofftimeout; /* counter for disc poweroff timeout */ /* * the sony_time array keeps track of the timestamp for * the "multiply mounted" discs. Only seven mount instances * are used in the array, as mount instance zero is reserved * for no checking of time stamps, and thus does not * have to be saved. Eight locations are reserved for ease * in calculating indexes. */ time_t sony_time[2][8]; /* * The following variables describe the current disc for * each drive. */ short sony_sector_size[2]; /* size of a sector in bytes */ short sony_max_block[2]; /* max addressable block */ /* * the disc_characteristics structure contains information * about a diskette. The structure is located in sector * CONFIG_SECTOR on the priviledged track. */ struct disc_characteristics { unsigned char tracks_per_side; unsigned char sides_per_disc; /* addressing_mode: * 0x44 for surface, 0x88 for cylinder addr. mode */ unsigned char addressing_mode; unsigned char sectors_per_track; /* sector_size_code: * 0 for 128 byte sectors, * 1 for 256 byte sectors, * 2 for 512 byte sectors, ... */ unsigned char sector_size_code; unsigned char interleave; unsigned char allowed_spares_per_side; unsigned char base_sector_num; unsigned char short_sector_flag; unsigned char system_cyl_flag; /* override_format: * 0x23 if the default formatting values are to be * used, 0xA3 if the values given here are to * override the normal values from now on */ unsigned char override_format; unsigned char wear_start_value; unsigned char post_index_gap; unsigned char id_gap; unsigned char data_gap; unsigned char spiral_offset; }; /* * sony_dc is an array of two structures contiaining the * characteristics for the two discs this driver may control. * The elements in the array are filled out by reading the * CONFIG_SECTOR in the priviledged track on a disc. * This is done in the getvol routine in sony2.c */ struct disc_characteristics sony_dc[2]; /* * READ bits for the id register */ #define INT_BIT 0x40 /* bit to test for interrupt */ #define WRPBIT 01 /* bit to test for write protect */ #define WRPROT 01 /* value if diskette is write protected */ #define DISC_CHANGED 0x02 /* disc changed bit */ /* * WRITE bits for id register */ #define DISC_RESET 0x01 /* reset disc change status */ #define UNIT0 0x00 /* select disc 0 */ #define UNIT1 0x02 /* select disc 1 */ #define DDHEAD0 0x00 /* select physical head 0 (on the drive) */ #define DDHEAD1 0x08 /* select physical head 1 */ #define MOTOR_ON 0x80 /* turn on +12 to disc drives */ /* * commands: */ #define RESTORE 0x0B /* seek to track 00, no track vfy */ #define SEEK 0x1F #define SEEKNOVFY 0x1B /* seek w/o on track verify */ /* * step in, head loaded, no track vfy * and no track update */ #define STEP_IN 0x4B /* step toward hub */ #define STEP_OUT 0x6B /* toward track 00 */ #define STEP_OUT_NO_LOAD 0x63 /* toward track 00 */ /* * READ_SECTOR and WRITE_SECTOR both tell the FDC to use * a 256 byte sector, while READ_SECTOR_128 asks for a 128 * byte sector. */ #define READ_SECTOR 0x88 #define READ_SECTOR_128 0x80 #define WRITE_SECTOR 0xA8 #define READ_ADDR 0xC0 /* read sector header */ #define READ_TRACK 0xE0 /* read a track without CRC checking */ #define WRITE_TRACK 0xF0 /* write an entire track to format it */ /* * possible modifier bits for the above group of commands: */ #define HEAD0 0x00 /* enable head 0 */ #define HEAD1 0x02 /* enable head 1 */ #define DELAY15 0x04 /* flag to delay 15 ms */ #define FORCE_INT 0xD8 /* force an interrupt */ #define RESET_INT 0xD0 /* reset forced interrupt */ /* * masks for FDC command register bits (on read of status) */ #define BUSY 0x01 #define DATA_REQ 0x02 #define LOST_DATA 0x04 #define CRC_ERROR 0x08 #define RECNF 0x10 #define NOT_READY 0x80 #define FDC_ERRORS (LOST_DATA|CRC_ERROR|RECNF|NOT_READY) /* N.B.: write protect is not used in FDC status */ /* * Image of disk controller interface and the Western Digital * 2797 Floppy Disk Controller (FDC): */ struct regs { unsigned char sf1, /* sf1 is a place holder for the high * (unused) byte */ id, /* card id reg. */ sf2[7], /* filler to cmd address */ cmd, /* FDC command reg. */ sf6, track, /* FDC track reg. */ sf7, sector, /* FDC sector reg. */ sf8, data; /* FDC data reg. */ }; /* Notes on the above registers: * * 1) The ID register contains the following bits: * * On Read: * * Bit 6 is set to one if the FDC is interrupting. * Bit 2 is set if the drive reports that its disc * has been changed. * Bit 1 is set if the diskette is write protected. * * On Write: * * Bit 7, when set to one, will turn the disk drive on. * Bit 2, when set to one, selects drive 0. * When set to zero, selects drive 1. * Bit 0, resets the disc_changed status in the sony * floppy disc hardware. Note that this status * is available on a per drive basis. The * reset pulse is generated by a 0->1->0 * transition, with a minimum pulse width of * 30 microseconds. * * 2) See the Western Digital documentation for details on the Floppy * Disc Controller's registers and operation. * */