📄 hp.c
字号:
#ifndef lintstatic char *sccsid = "@(#)hp.c 4.1 ULTRIX 7/2/90";#endif lint/************************************************************************ * * * Copyright (c) 1984, 1986 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//* * hp.c 6.2 09/25/83 * * Modification history * * RH/RM03/RM05/RM80/RP05/RP06/RP07 disk driver * * 26-July-89 - Alan Frechette * Conditionalize out the dump code. * * 19-Sep-84 - tresvik * * Derived from 4.2BSD labeled: hp.c 6.2 83/09/25. * Fixed the algorithm for determining where a bad sector is. * The fix checks that the byte count at the time of an error is * sector aligned. * * 2-Oct-84 - reilly * * Added code to start handling the disk partitioning scheme. -001 * * 30-Nov-84 - reilly * * Fixed error message. -002 * * 19-Dec-84 - tresvik * * Unfixed algorithm for determining where a bad sector is. The * fix was added for RP07 which resulted in the RM05 exhibiting the * same symptom. * * 6-Jun-85 - tresvik * * Report contents of hpdc instead of hpcc for soft ecc errors. * hpcc unused on RM03 drives. * * 24-Sep-85 - reilly * * Added new ioctl call that will return the default partition * table. * * 4-Dec-85 - Darrell Dunnuck * * Really fixed the algorithm for determining where a bad sector * is. The most conservative half of MBA byte count register * is read to determine which block is bad. Also removed a * statement that fudged the variable "npf" - which was off by * one due to reading the wrong half of the MBA byte count register. * Added a bug fix so that when a BSE error occurs, only the needed * number of bytes is read, not always 512 as before. * * 30-Jan-86 - Tom Tresvik * * Replaced fudge factor "npf" removed below to fix the soft ECC * correction algorithm. * * 9-Apr-86 - Paul Shaughnessy * * Added partial dump code support, and removed common dump code. * * 16-Apr-86 - ricky palmer * * Added new DEVIOCGET ioctl request code along with * soft and hard error counters. V2.0 * * 22-May-86 - Paul Shaughnessy * * Added saving of the u_area to the partial dump code. * * 11-Jul-86 - ricky palmer * * Added adpt and nexus fields to DEVIOCGET code. * * 26-Aug-86 - rsp (Ricky Palmer) * * Cleaned up devioctl code to (1) zero out devget structure * upon entry and (2) use strlen instead of fixed storage * for bcopy's. * * 04-Dec-86 - pmk * * Changed mprintf's to log just one entry. */#include "hp.h"#if NHP > 0 || defined(BINARY)#ifdef HPDEBUGint hpdebug;#endif HPDEBUG#ifdef HPBDEBUGint hpbdebug;#endif HPBDEBUG#include "../h/dump.h"#include "../data/hp_data.c"/* * Table for converting Massbus drive types into * indices into the partition tables. Slots are * left for those drives defined from other means * (e.g. SI, AMPEX, etc.). */short hptypes[] = {#define HPDT_RM03 0 MBDT_RM03,#define HPDT_RM05 1 MBDT_RM05,#define HPDT_RP06 2 MBDT_RP06,#define HPDT_RM80 3 MBDT_RM80,#define HPDT_RP04 4 MBDT_RP04,#define HPDT_RP05 5 MBDT_RP05,#define HPDT_RP07 6 MBDT_RP07,#define HPDT_ML11A 7 MBDT_ML11A,#define HPDT_ML11B 8 MBDT_ML11B,#define HPDT_9775 9 -1,#define HPDT_9730 10 -1,#define HPDT_CAPRICORN 11 -1,#define HPDT_EAGLE 12 -1,#define HPDT_9300 13 -1,#define HPDT_RM02 14 MBDT_RM02, /* beware, actually capricorn or eagle */ 0};int hpattach(),hpustart(),hpstart(),hpdtint();struct mba_driver hpdriver = { hpattach, 0, hpustart, hpstart, hpdtint, 0, hptypes, "hp", 0, hpinfo };/* * Beware, sdist and rdist are not well tuned * for many of the drives listed in this table. * Try patching things with something i/o intensive * running and watch iostat. */struct hpst { short nsect; /* # sectors/track */ short ntrak; /* # tracks/cylinder */ short nspc; /* # sector/cylinders */ short ncyl; /* # cylinders */ struct size *sizes; /* partition tables */ short sdist; /* seek distance metric */ short rdist; /* rotational distance metric */} hpst[] = { { 32, 5, 32*5, 823, rm03_sizes, 3, 4 }, /* RM03 */ { 32, 19, 32*19, 823, rm05_sizes, 3, 4 }, /* RM05 */ { 22, 19, 22*19, 815, rp06_sizes, 3, 4 }, /* RP06 */ { 31, 14, 31*14, 559, rm80_sizes, 3, 4 }, /* RM80 */ { 22, 19, 22*19, 411, rp05_sizes, 3, 4 }, /* RP04 */ { 22, 19, 22*19, 411, rp05_sizes, 3, 4 }, /* RP05 */ { 50, 32, 50*32, 630, rp07_sizes, 7, 8 }, /* RP07 */ { 1, 1, 1, 1, 0, 0, 0 }, /* ML11A */ { 1, 1, 1, 1, 0, 0, 0 }, /* ML11B */ { 32, 40, 32*40, 843, cdc9775_sizes, 3, 4 }, /* 9775 */ { 32, 10, 32*10, 823, cdc9730_sizes, 3, 4 }, /* 9730 */ { 32, 16, 32*16, 1024, capricorn_sizes,7, 8 }, /* Capricorn */ { 48, 20, 48*20, 842, eagle_sizes, 7, 8 }, /* EAGLE */ { 32, 19, 32*19, 815, ampex_sizes, 3, 4 }, /* 9300 */};u_char hp_offset[16] = { HPOF_P400, HPOF_M400, HPOF_P400, HPOF_M400, HPOF_P800, HPOF_M800, HPOF_P800, HPOF_M800, HPOF_P1200, HPOF_M1200, HPOF_P1200, HPOF_M1200, 0, 0, 0, 0,};#define b_cylin b_resid/* #define ML11 0 to remove ML11 support */#define ML11 (hptypes[mi->mi_type] == MBDT_ML11A)#define RP06 (hptypes[mi->mi_type] <= MBDT_RP06)#define RM80 (hptypes[mi->mi_type] == MBDT_RM80)#define MASKREG(reg) ((reg)&0xffff)#ifdef INTRLVEdaddr_t dkblock();#endif INTRLVE/*ARGSUSED*/hpattach(mi) register struct mba_device *mi;{ register struct hp_softc *sc = &hp_softc[mi->mi_unit]; mi->mi_type = hpmaptype(mi); if (!ML11 && mi->mi_dk >= 0) { struct hpst *st = &hpst[mi->mi_type]; dk_mspw[mi->mi_dk] = 1.0 / 60 / (st->nsect * 256); sc->sc_softcnt = 0; sc->sc_hardcnt = 0; switch (*(mi->mi_driver->md_type + mi->mi_type)) { case MBDT_RM03: bcopy(DEV_RM03,sc->sc_device, strlen(DEV_RM03)); break; case MBDT_RM05: bcopy(DEV_RM05,sc->sc_device, strlen(DEV_RM05)); break; case MBDT_RM80: bcopy(DEV_RM80,sc->sc_device, strlen(DEV_RM80)); break; case MBDT_RP05: bcopy(DEV_RP05,sc->sc_device, strlen(DEV_RP05)); break; case MBDT_RP06: bcopy(DEV_RP06,sc->sc_device, strlen(DEV_RP06)); break; case MBDT_RP07: bcopy(DEV_RP07,sc->sc_device, strlen(DEV_RP07)); break; default: bcopy(DEV_UNKNOWN,sc->sc_device, strlen(DEV_UNKNOWN)); break; } }}/* * Map apparent MASSBUS drive type into manufacturer * specific configuration. For SI controllers this is done * based on codes in the serial number register. For * EMULEX controllers, the track and sector attributes are * used when the drive type is an RM02 (not supported by DEC). */hpmaptype(mi) register struct mba_device *mi;{ register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; register int type = mi->mi_type; /* * Model-byte processing for SI controllers. * NB: Only deals with RM03 and RM05 emulations. */ if (type == HPDT_RM03 || type == HPDT_RM05) { int hpsn = hpaddr->hpsn; if ((hpsn & SIMB_LU) != mi->mi_drive) return (type); switch ((hpsn & SIMB_MB) & ~(SIMB_S6|SIRM03|SIRM05)) { case SI9775D: printf("hp%d: 9775 (direct)\n", mi->mi_unit); type = HPDT_9775; break; case SI9730D: printf("hp%d: 9730 (direct)\n", mi->mi_unit); type = HPDT_9730; break; /* * Beware, since the only SI controller we * have has a 9300 instead of a 9766, we map the * drive type into the 9300. This means that * on a 9766 you lose the last 8 cylinders (argh). */ case SI9766: printf("hp%d: 9300\n", mi->mi_unit); type = HPDT_9300; break; case SI9762: printf("hp%d: 9762\n", mi->mi_unit); type = HPDT_RM03; break; case SICAPD: printf("hp%d: capricorn\n", mi->mi_unit); type = HPDT_CAPRICORN; break; case SI9751D: printf("hp%d: eagle\n", mi->mi_unit); type = HPDT_EAGLE; break; } return (type); } /* * EMULEX SC750 or SC780. Poke the holding register. */ if (type == HPDT_RM02) { int ntracks, nsectors; hpaddr->hpof = HPOF_FMT22; mbclrattn(mi); hpaddr->hpcs1 = HP_NOP; hpaddr->hphr = HPHR_MAXTRAK; ntracks = MASKREG(hpaddr->hphr) + 1; if (ntracks == 16) { printf("hp%d: capricorn\n", mi->mi_unit); type = HPDT_CAPRICORN; goto done; } if (ntracks == 19) { printf("hp%d: 9300\n", mi->mi_unit); type = HPDT_9300; goto done; } hpaddr->hpcs1 = HP_NOP; hpaddr->hphr = HPHR_MAXSECT; nsectors = MASKREG(hpaddr->hphr) + 1; if (ntracks == 20 && nsectors == 48) { type = HPDT_EAGLE; printf("hp%d: eagle\n", mi->mi_unit); goto done; } printf("hp%d: ntracks %d, nsectors %d: unknown device\n", mi->mi_unit, ntracks, nsectors);done: hpaddr->hpcs1 = HP_DCLR|HP_GO; mbclrattn(mi); /* conservative */ return (type); } /* * Map all ML11's to the same type. Also calculate * transfer rates based on device characteristics. */ if (type == HPDT_ML11A || type == HPDT_ML11B) { register struct hp_softc *sc = &hp_softc[mi->mi_unit]; register int trt; sc->sc_mlsize = hpaddr->hpmr & HPMR_SZ; if ((hpaddr->hpmr & HPMR_ARRTYP) == 0) sc->sc_mlsize >>= 2; if (mi->mi_dk >= 0) { trt = (hpaddr->hpmr & HPMR_TRT) >> 8; dk_mspw[mi->mi_dk] = 1.0 / (1<<(20-trt)); } type = HPDT_ML11A; } return (type);}hpopen(dev, flag) register dev_t dev; int flag;{ register int unit = minor(dev) >> 3; register struct mba_device *mi; register struct hp_softc *sc; register struct hpdevice *hpaddr; if (unit >= nNHP || (mi = hpinfo[unit]) == 0 || mi->mi_alive == 0) { return (ENXIO); } hpaddr = (struct hpdevice *)mi->mi_drv; sc = &hp_softc[unit]; sc->sc_flags = 0; sc->sc_category_flags = 0; if (!(hpaddr->hpds & HPDS_MOL)) { sc->sc_flags |= DEV_OFFLINE; } if (hpaddr->hpds & HPDS_WRL) { sc->sc_flags |= DEV_WRTLCK; } /* * See if we need to read in the partition table from the disk. * The conditions we will have to read from the disk is if the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -