Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/libi386/bioscd.c
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
static struct bcinfo { | static struct bcinfo { | ||||
int bc_unit; /* BIOS unit number */ | int bc_unit; /* BIOS unit number */ | ||||
struct specification_packet bc_sp; | struct specification_packet bc_sp; | ||||
int bc_open; /* reference counter */ | int bc_open; /* reference counter */ | ||||
void *bc_bcache; /* buffer cache data */ | void *bc_bcache; /* buffer cache data */ | ||||
} bcinfo [MAXBCDEV]; | } bcinfo [MAXBCDEV]; | ||||
static int nbcinfo = 0; | static int nbcinfo = 0; | ||||
#define BC(dev) (bcinfo[(dev)->d_unit]) | #define BC(dev) (bcinfo[(dev)->dd.d_unit]) | ||||
static int bc_read(int unit, daddr_t dblk, int blks, caddr_t dest); | static int bc_read(int unit, daddr_t dblk, int blks, caddr_t dest); | ||||
static int bc_init(void); | static int bc_init(void); | ||||
static int bc_strategy(void *devdata, int flag, daddr_t dblk, | static int bc_strategy(void *devdata, int flag, daddr_t dblk, | ||||
size_t size, char *buf, size_t *rsize); | size_t size, char *buf, size_t *rsize); | ||||
static int bc_realstrategy(void *devdata, int flag, daddr_t dblk, | static int bc_realstrategy(void *devdata, int flag, daddr_t dblk, | ||||
size_t size, char *buf, size_t *rsize); | size_t size, char *buf, size_t *rsize); | ||||
static int bc_open(struct open_file *f, ...); | static int bc_open(struct open_file *f, ...); | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
bc_open(struct open_file *f, ...) | bc_open(struct open_file *f, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
struct i386_devdesc *dev; | struct i386_devdesc *dev; | ||||
va_start(ap, f); | va_start(ap, f); | ||||
dev = va_arg(ap, struct i386_devdesc *); | dev = va_arg(ap, struct i386_devdesc *); | ||||
va_end(ap); | va_end(ap); | ||||
if (dev->d_unit >= nbcinfo) { | if (dev->dd.d_unit >= nbcinfo) { | ||||
DEBUG("attempt to open nonexistent disk"); | DEBUG("attempt to open nonexistent disk"); | ||||
return(ENXIO); | return(ENXIO); | ||||
} | } | ||||
BC(dev).bc_open++; | BC(dev).bc_open++; | ||||
if (BC(dev).bc_bcache == NULL) | if (BC(dev).bc_bcache == NULL) | ||||
BC(dev).bc_bcache = bcache_allocate(); | BC(dev).bc_bcache = bcache_allocate(); | ||||
return(0); | return(0); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
if (size % BIOSCD_SECSIZE) | if (size % BIOSCD_SECSIZE) | ||||
return (EINVAL); | return (EINVAL); | ||||
#endif | #endif | ||||
if ((rw & F_MASK) != F_READ) | if ((rw & F_MASK) != F_READ) | ||||
return(EROFS); | return(EROFS); | ||||
dev = (struct i386_devdesc *)devdata; | dev = (struct i386_devdesc *)devdata; | ||||
unit = dev->d_unit; | unit = dev->dd.d_unit; | ||||
blks = size / BIOSCD_SECSIZE; | blks = size / BIOSCD_SECSIZE; | ||||
if (dblk % (BIOSCD_SECSIZE / DEV_BSIZE) != 0) | if (dblk % (BIOSCD_SECSIZE / DEV_BSIZE) != 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
dblk /= (BIOSCD_SECSIZE / DEV_BSIZE); | dblk /= (BIOSCD_SECSIZE / DEV_BSIZE); | ||||
DEBUG("read %d from %lld to %p", blks, dblk, buf); | DEBUG("read %d from %lld to %p", blks, dblk, buf); | ||||
if (rsize) | if (rsize) | ||||
*rsize = 0; | *rsize = 0; | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
int | int | ||||
bc_getdev(struct i386_devdesc *dev) | bc_getdev(struct i386_devdesc *dev) | ||||
{ | { | ||||
int biosdev, unit; | int biosdev, unit; | ||||
int major; | int major; | ||||
int rootdev; | int rootdev; | ||||
unit = dev->d_unit; | unit = dev->dd.d_unit; | ||||
biosdev = bc_unit2bios(unit); | biosdev = bc_unit2bios(unit); | ||||
DEBUG("unit %d BIOS device %d", unit, biosdev); | DEBUG("unit %d BIOS device %d", unit, biosdev); | ||||
if (biosdev == -1) /* not a BIOS device */ | if (biosdev == -1) /* not a BIOS device */ | ||||
return(-1); | return(-1); | ||||
/* | /* | ||||
* XXX: Need to examine device spec here to figure out if SCSI or | * XXX: Need to examine device spec here to figure out if SCSI or | ||||
* ATAPI. No idea on how to figure out device number. All we can | * ATAPI. No idea on how to figure out device number. All we can | ||||
Show All 14 Lines |