/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah Hdr: rd.c 1.20 92/12/21
*
* @(#)rd.c 8.1 (Berkeley) 7/15/93
*/
/*
* CS80/SS80 disk driver
*/
#include <sys/param.h>
#include <sys/disklabel.h>
static int
rdident(int ctlr, int unit)
{
struct cs80_describe desc;
uint8_t stat, cmd[3];
char name[7];
int id, i;
id = hpibid(ctlr, unit);
if ((id & 0x200) == 0)
return -1;
for (i = 0; i < numrdidentinfo; i++)
if (id == rdidentinfo[i].ri_hwid)
break;
if (i == numrdidentinfo)
return -1;
id = i;
rdreset(ctlr, unit);
cmd[0] = C_SUNIT(0);
cmd[1] = C_SVOL(0);
cmd[2] = C_DESC;
hpibsend(ctlr, unit, C_CMD, cmd, sizeof(cmd));
hpibrecv(ctlr, unit, C_EXEC, (uint8_t *)&desc, sizeof(desc));
hpibrecv(ctlr, unit, C_QSTAT, &stat, sizeof(stat));
memset(name, 0, sizeof(name));
if (!stat) {
int n = desc.d_name;
for (i = 5; i >= 0; i--) {
name[i] = (n & 0xf) + '0';
n >>= 4;
}
}
/*
* Take care of a couple of anomalies:
* 1. 7945A and 7946A both return same HW id
* 2. 9122S and 9134D both return same HW id
* 3. 9122D and 9134L both return same HW id
*/
switch (rdidentinfo[id].ri_hwid) {
case RD7946AID:
if (memcmp(name, "079450", 6) == 0)
id = RD7945A;
else if (memcmp(name, "079410", 6) == 0)
id = RD7941A;
else
id = RD7946A;
break;
case RD9134LID:
if (memcmp(name, "091340", 6) == 0)
id = RD9134L;
else
id = RD9122D;
break;
case RD9134DID:
if (memcmp(name, "091220", 6) == 0)
id = RD9122S;
else
id = RD9134D;
break;
}
return id;
}