#ident "@(#)sr.c 1.1 92/07/30 Copyr 1990 Sun Micro"
#include "sr.h"
#if NSR > 0
/************************************************************************
*************************************************************************
** *
** *
** SCSI CDROM driver (for CDROM, read-only) *
** for SunOs v4.0, 4.0.1, 4.0.3 & 4.1 *
** *
** Copyright (c) 1989 by Sun Microsystem, Inc. *
** *
*************************************************************************
*************************************************************************
*/
#define SRDEBUG /* Allow compiling of debug code */
#define REL4 /* enable release 4.00 mods */
/*
** SCSI driver for SCSI disks.
*/
#ifndef REL4
#include "sr.h"
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/dk.h"
#include "../h/buf.h"
#include "../h/conf.h"
#include "../h/dir.h"
#include "../h/user.h"
#include "../h/map.h"
#include "../h/vmmac.h"
#include "../h/ioctl.h"
#include "../h/uio.h"
#include "../h/kernel.h"
#include "../h/dkbad.h"
#include "../h/fcntl.h"
#include "../h/file.h"
#include "../h/proc.h"
#include "../machine/pte.h"
#include "../machine/psl.h"
#include "../machine/mmu.h"
#include "../machine/cpu.h"
#include "../sun/dklabel.h"
#include "../sun/dkio.h"
#include "../sundev/mbvar.h"
#include "../sundev/screg.h"
#include "../sundev/sireg.h"
#include "../sundev/scsi.h"
#include "../sundev/srreg.h"
#else REL4
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dk.h>
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/user.h>
#include <sys/map.h>
#include <sys/vmmac.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/dkbad.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/kmem_alloc.h>
#include <machine/pte.h>
#include <machine/psl.h>
#include <machine/mmu.h>
#include <machine/cpu.h>
#include <sun/dklabel.h>
#include <sun/dkio.h>
#include <sundev/mbvar.h>
#include <sundev/screg.h>
#include <sundev/sireg.h>
#include <sundev/scsi.h>
#include <sundev/srreg.h>
#endif REL4
#define MAX_CDROM 8
#define SR_TIMEOUT /* define for scsi recovery */
#define MAX_RETRIES 4 /* retry limit */
#define MAX_RESTORES 4 /* rezero unit limit (after retries) */
#define MAX_FAILS 20 /* soft errors before reassign */
#define MAX_LABEL_RETRIES 2
#define MAX_LABEL_RESTORES 1
#define MAX_BUSY 10
#define EL_RETRY 2 /* Error msg threshold, retries */
#define EL_REST 0 /* Error msg threshold, restores */
#define EL_FAILS 10 /* Error msg threshold, soft errors */
#define CD_SIZE 0x400000 /* default dev size = 2**21==2E6 */
/* typical size = 560 Mb =~ 1E6 blks */
#define LPART(dev) (dev & (NLPART - 1))
#define SRUNIT(dev) ((dev >> 3) & (NUNIT - 1))
#define SRNUM(un) (un - srunits)
#define SRIOPBALLOC(size) ((caddr_t)rmalloc(iopbmap, (long)(size + 4)))
#define SRIOPBFREE(ptr, size) (rmfree(iopbmap, (long)(size +4), (u_long)ptr))
#ifdef SRDEBUG
short sr_debug = 0; /*
** 0 = normal operation
** 1 = extended error info only
** 2 = debug and error info
** 3 = all status info
*/
/* Handy debugging 0, 1, and 2 argument printfs */
#define SR_PRINT_CMD(un) \
if (sr_debug > 1) sr_print_cmd(un)
#define DPRINTF(str) \
if (sr_debug > 1) printf(str)
#define DPRINTF1(str, arg1) \
if (sr_debug > 1) printf(str, arg1)
#define DPRINTF2(str, arg1, arg2) \
if (sr_debug > 1) printf(str, arg1, arg2)
/* Handy extended error reporting 0, 1, and 2 argument printfs */
#define EPRINTF(str) \
if (sr_debug) printf(str)
#define EPRINTF1(str, arg1) \
if (sr_debug) printf(str, arg1)
#define EPRINTF2(str, arg1, arg2) \
if (sr_debug) printf(str, arg1, arg2)
#define DEBUG_DELAY(cnt) \
if (sr_debug) DELAY(cnt)
#else SRDEBUG
#define SR_PRINT_CMD(un)
#define DPRINTF(str)
#define DPRINTF1(str, arg2)
#define DPRINTF2(str, arg1, arg2)
#define EPRINTF(str)
#define EPRINTF1(str, arg2)
#define EPRINTF2(str, arg1, arg2)
#define DEBUG_DELAY(cnt)
#endif SRDEBUG
extern char *strncpy();
extern struct scsi_unit srunits[];
extern struct scsi_unit_subr scsi_unit_subr[];
extern struct scsi_disk srdisk[];
extern int ncdrom;
short sr_max_retries = MAX_RETRIES;
short sr_max_restores = MAX_RESTORES;
short sr_max_fails = MAX_FAILS;
short sr_restores = EL_REST;
short sr_fails = EL_FAILS;
short disconenbl = 1; /* allow disconnect / re-connect on cdrom */
/* set to 0 to disable disconnect - reconnect */
/*
** flag locking and unlocking purposes.
** to make sure that only the very last close
** unlocks the drive
*/
struct cdrom_open_flag {
u_char cdopen_flag0;
u_char cdopen_flag1;
u_char cdxopen_flag; /* exclusive open flag */
} sr_open_flag[MAX_CDROM];
static void sr_setup_openflag();
/*
** A string to keep track of the vendor id.
** This is needed since the scsi_disk structure does not
** has a place to put this information.
*/
struct cdrom_inquiry {
char cdrom_vid[8]; /* vendor ID */
char cdrom_pid[16]; /* product ID */
char cdrom_rev[4]; /* revision level */
} sr_inq[MAX_CDROM];
#ifndef SRDEBUG
short sr_retry = EL_RETRY; /*
* Error message threshold, retries.
* Make it global so manufacturing can
* override setting.
*/
#else SRDEBUG
short sr_retry = 0; /* For debug, set retries to 0. */
/************************************************************************
** *
** Local Function Declarations *
** *
*************************************************************************/
static int sr_medium_removal();
static int sr_pause_resume(), sr_play_msf(), sr_play_trkind();
static int sr_read_tochdr(), sr_read_tocentry();
sr_print_buffer(y, count)
register u_char *y;
register int count;
{
register int x;
for (x = 0; x < count; x++)
printf("%x ", *y++);
printf("\n");
}
#endif SRDEBUG
/*
** Return a pointer to this unit's unit structure.
*/
srunitptr(md)
register struct mb_device *md;
{
return ((int)&srunits[md->md_unit]);
}
static
srtimer(dev)
register dev_t dev;
{
register struct scsi_disk *dsi;
register struct scsi_unit *un;
register struct scsi_ctlr *c;
register u_int unit;
unit = SRUNIT(dev);
un = &srunits[unit];
dsi = &srdisk[unit];
c = un->un_c;
/* DPRINTF("srtimer:\n"); */
if (dsi->un_openf >= OPENING) {
(*un->un_c->c_ss->scs_start)(un);
#ifdef SR_TIMEOUT
if ((dsi->un_timeout != 0) && (--dsi->un_timeout == 0)) {
/* Process command timeout for normal I/O operations */
printf("sr%d: srtimer: I/O request timeout\n", unit);
if ((*c->c_ss->scs_deque)(c, un)) {
/* Can't Find CDB I/O request to kill, help! */
printf("sr%d: srtimer: can't abort request\n",
unit);
(*un->un_c->c_ss->scs_reset)(un->un_c, 0);
}
} else if (dsi->un_timeout != 0) {
DPRINTF2("srtimer: running, open= %d, timeout= %d\n",
dsi->un_openf, dsi->un_timeout);
}
#endif SR_TIMEOUT
/* Process opening delay timeout */
} else if ((dsi->un_timeout != 0) && (--dsi->un_timeout == 0)) {
DPRINTF("srtimer: running...\n");
wakeup((caddr_t)dev);
}
timeout(srtimer, (caddr_t)dev, 30*hz);
}
/* */
/************************************************************************
*************************************************************************
** *
** *
** Autoconfiguration Routines *
** *
** *
*************************************************************************
/************************************************************************/
/*
** Attach device (boot time). The controller is there. Since this is a
** CDROM, there is no need to check the label.
*/
srattach(md)
register struct mb_device *md;
{
register struct scsi_unit *un;
register struct scsi_disk *dsi;
struct scsi_inquiry_data *sid;
int i;
dsi = &srdisk[md->md_unit];
un = &srunits[md->md_unit];
sr_open_flag[md->md_unit].cdopen_flag0 = 0;
sr_open_flag[md->md_unit].cdopen_flag1 = 0;
sr_open_flag[md->md_unit].cdxopen_flag = 0;
/*
* link in, fill in unit struct.
*/
un->un_md = md;
un->un_mc = md->md_mc;
sr.rar_scsi cdrom
版权申诉
68 浏览量
2022-09-14
22:42:23
上传
评论
收藏 17KB RAR 举报
JonSco
- 粉丝: 76
- 资源: 1万+
最新资源
- 连接Redis服务器 在使用Redis之前,首先需要使用redis-cli工具连接到Redis服务器 redis-cli是Re
- 连接Redis服务器 在使用Redis之前,首先需要使用redis-cli工具连接到Redis服务器 redis-cli是Red
- 连接Redis服务器 在使用Redis之前,首先需要使用redis-cli工具连接到Redis服务器 redis-cli是Red
- redis命令实践 详细教程
- redis命令实践 详细教程
- redis命令实践 详细教程
- redis命令实践 详细教程
- redis命令实践 详细教程
- redis命令实践 详细教程
- cadvisor.tar 容器镜像,可以监控容器
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈