plan 9 kernel history: overview | file list | diff list

2001/1022/port/sd.h (diff list | history)

port/sd.h on 2000/0506
2000/0506    
/* 
 * Storage Device. 
 */ 
typedef struct SDev SDev; 
typedef struct SDifc SDifc; 
typedef struct SDpart SDpart; 
2000/0706    
typedef struct SDperm SDperm; 
2000/0506    
typedef struct SDreq SDreq; 
typedef struct SDunit SDunit; 
 
2000/0706    
typedef struct SDperm { 
2001/1022    
	char*	name; 
	char*	user; 
2000/0506    
	ulong	perm; 
2000/0706    
} SDperm; 
 
typedef struct SDpart { 
	ulong	start; 
	ulong	end; 
	SDperm; 
2000/0506    
	int	valid; 
2000/0617    
	ulong	vers; 
2000/0506    
} SDpart; 
 
typedef struct SDunit { 
	SDev*	dev; 
	int	subno; 
	uchar	inquiry[256];		/* format follows SCSI spec */ 
2000/0706    
	SDperm; 
2000/0506    
	Rendez	rendez; 
 
	QLock	ctl; 
	ulong	sectors; 
	ulong	secsize; 
2000/0809    
	SDpart*	part;			/* nil or array of size npart */ 
	int	npart; 
2000/0617    
	ulong	vers; 
2000/0706    
	SDperm	ctlperm; 
2000/0506    
 
2001/1022    
	QLock	raw;			/* raw read or write in progress */ 
2000/0531    
	Lock	rawinuse;		/* really just a test-and-set */ 
2000/0506    
	int	state; 
	SDreq*	req; 
2000/0706    
	SDperm	rawperm; 
2000/1129    
 
2001/1022    
	Log	log; 
2000/0506    
} SDunit; 
 
2001/0905    
/*  
2001/1022    
 * Each controller is represented by a SDev. 
 * Each controller is responsible for allocating its unit structures. 
 * Each controller has at least one unit. 
 */  
2000/0506    
typedef struct SDev { 
2001/1022    
	Ref	r;			/* Number of callers using device */ 
2000/0506    
	SDifc*	ifc;			/* pnp/legacy */ 
2001/1022    
	void*	ctlr; 
2000/0506    
	int	idno; 
2001/1022    
	char*	name; 
2000/0506    
	SDev*	next; 
 
	QLock;				/* enable/disable */ 
	int	enabled; 
2001/1022    
	int	nunit;			/* Number of units */ 
2001/0905    
	QLock	unitlock;		/* `Loading' of units */ 
2001/1022    
	int*	unitflg;		/* Unit flags */ 
	SDunit**unit; 
2000/0506    
} SDev; 
 
typedef struct SDifc { 
	char*	name; 
 
	SDev*	(*pnp)(void); 
	SDev*	(*legacy)(int, int); 
	SDev*	(*id)(SDev*); 
	int	(*enable)(SDev*); 
	int	(*disable)(SDev*); 
 
	int	(*verify)(SDunit*); 
	int	(*online)(SDunit*); 
	int	(*rio)(SDreq*); 
	int	(*rctl)(SDunit*, char*, int); 
	int	(*wctl)(SDunit*, Cmdbuf*); 
 
	long	(*bio)(SDunit*, int, int, void*, long, long); 
2001/1022    
	SDev*	(*probe)(DevConf*); 
	void	(*clear)(SDev*); 
2001/0905    
	char*	(*stat)(SDev*, char*, char*); 
2000/0506    
} SDifc; 
 
typedef struct SDreq { 
	SDunit*	unit; 
	int	lun; 
	int	write; 
	uchar	cmd[16]; 
	int	clen; 
	void*	data; 
	int	dlen; 
 
	int	flags; 
 
	int	status; 
	long	rlen; 
	uchar	sense[256]; 
} SDreq; 
 
enum { 
	SDnosense	= 0x00000001, 
	SDvalidsense	= 0x00010000, 
}; 
 
enum { 
2000/0607    
	SDretry		= -5,		/* internal to controllers */ 
2000/0506    
	SDmalloc	= -4, 
	SDeio		= -3, 
	SDtimeout	= -2, 
	SDnostatus	= -1, 
 
	SDok		= 0, 
 
	SDcheck		= 0x02,		/* check condition */ 
	SDbusy		= 0x08,		/* busy */ 
 
	SDmaxio		= 2048*1024, 
	SDnpart		= 16, 
}; 
 
#define sdmalloc(n)	malloc(n) 
#define sdfree(p)	free(p) 
 
/* sdscsi.c */ 
extern int scsiverify(SDunit*); 
extern int scsionline(SDunit*); 
extern long scsibio(SDunit*, int, int, void*, long, long); 
extern SDev* scsiid(SDev*, SDifc*); 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)