Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/pc98/libpc98/bioscd.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* List of BIOS devices, translation from disk unit number to | * List of BIOS devices, translation from disk unit number to | ||||
* BIOS unit number. | * BIOS unit number. | ||||
*/ | */ | ||||
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 */ | |||||
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]) | |||||
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 offset, size_t size, char *buf, size_t *rsize); | ||||
static int bc_realstrategy(void *devdata, int flag, daddr_t dblk, | |||||
size_t offset, size_t size, char *buf, size_t *rsize); | |||||
static int bc_open(struct open_file *f, ...); | static int bc_open(struct open_file *f, ...); | ||||
static int bc_close(struct open_file *f); | static int bc_close(struct open_file *f); | ||||
static void bc_print(int verbose); | static void bc_print(int verbose); | ||||
struct devsw bioscd = { | struct devsw bioscd = { | ||||
"cd", | "cd", | ||||
DEVT_CD, | DEVT_CD, | ||||
bc_init, | bc_init, | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | bc_add(int biosdev) | ||||
/* SCSI CD-ROM only */ | /* SCSI CD-ROM only */ | ||||
if ((biosdev & 0xf0) != 0xa0) | if ((biosdev & 0xf0) != 0xa0) | ||||
return (-1); | return (-1); | ||||
if ((((uint32_t *)PTOV(0xA1460))[biosdev & 0x0f] & 0x1f) != 5) | if ((((uint32_t *)PTOV(0xA1460))[biosdev & 0x0f] & 0x1f) != 5) | ||||
return (-1); | return (-1); | ||||
printf("BIOS CD is cd%d\n", nbcinfo); | printf("BIOS CD is cd%d\n", nbcinfo); | ||||
nbcinfo++; | nbcinfo++; | ||||
bcache_add_dev(nbcinfo); /* register cd device in bcache */ | |||||
return(0); | return(0); | ||||
} | } | ||||
/* | /* | ||||
* Print information about disks | * Print information about disks | ||||
*/ | */ | ||||
static void | static void | ||||
bc_print(int verbose) | bc_print(int verbose) | ||||
Show All 20 Lines | bc_open(struct open_file *f, ...) | ||||
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->d_unit >= nbcinfo) { | ||||
DEBUG("attempt to open nonexistent disk"); | DEBUG("attempt to open nonexistent disk"); | ||||
return(ENXIO); | return(ENXIO); | ||||
} | } | ||||
BC(dev).bc_open++; | |||||
if (BC(dev).bc_bcache == NULL) | |||||
BC(dev).bc_bcache = bcache_allocate(); | |||||
return(0); | return(0); | ||||
} | } | ||||
static int | static int | ||||
bc_close(struct open_file *f) | bc_close(struct open_file *f) | ||||
{ | { | ||||
struct i386_devdesc *dev; | |||||
dev = (struct i386_devdesc *)f->f_devdata; | |||||
BC(dev).bc_open--; | |||||
if (BC(dev).bc_open == 0) { | |||||
bcache_free(BC(dev).bc_bcache); | |||||
BC(dev).bc_bcache = NULL; | |||||
} | |||||
return(0); | return(0); | ||||
} | } | ||||
static int | static int | ||||
bc_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, | bc_strategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size, | ||||
size_t *rsize) | char *buf, size_t *rsize) | ||||
{ | |||||
struct bcache_devdata bcd; | |||||
struct i386_devdesc *dev; | |||||
dev = (struct i386_devdesc *)devdata; | |||||
bcd.dv_strategy = bc_realstrategy; | |||||
bcd.dv_devdata = devdata; | |||||
bcd.dv_cache = BC(dev).bc_bcache; | |||||
return (bcache_strategy(&bcd, rw, dblk, offset, size, buf, rsize)); | |||||
} | |||||
static int | |||||
bc_realstrategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size, | |||||
char *buf, size_t *rsize) | |||||
{ | { | ||||
struct i386_devdesc *dev; | struct i386_devdesc *dev; | ||||
int unit; | int unit; | ||||
int blks; | int blks; | ||||
#ifdef BD_SUPPORT_FRAGS | #ifdef BD_SUPPORT_FRAGS | ||||
char fragbuf[BIOSCD_SECSIZE]; | char fragbuf[BIOSCD_SECSIZE]; | ||||
size_t fragsize; | size_t fragsize; | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |