Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/i386/libi386/biosdisk.c
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | |||||
static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, | static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int bd_open(struct open_file *f, ...); | static int bd_open(struct open_file *f, ...); | ||||
static int bd_close(struct open_file *f); | static int bd_close(struct open_file *f); | ||||
static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | ||||
static int bd_print(int verbose); | static int bd_print(int verbose); | ||||
static void bd_cleanup(void); | |||||
#ifdef LOADER_GELI_SUPPORT | #ifdef LOADER_GELI_SUPPORT | ||||
static enum isgeli { | static enum isgeli { | ||||
ISGELI_UNKNOWN, | ISGELI_UNKNOWN, | ||||
ISGELI_NO, | ISGELI_NO, | ||||
ISGELI_YES | ISGELI_YES | ||||
}; | }; | ||||
static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS]; | static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS]; | ||||
int bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, | int bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, | ||||
size_t bytes); | size_t bytes); | ||||
#endif /* LOADER_GELI_SUPPORT */ | #endif /* LOADER_GELI_SUPPORT */ | ||||
struct devsw biosdisk = { | struct devsw biosdisk = { | ||||
"disk", | "disk", | ||||
DEVT_DISK, | DEVT_DISK, | ||||
bd_init, | bd_init, | ||||
bd_strategy, | bd_strategy, | ||||
bd_open, | bd_open, | ||||
bd_close, | bd_close, | ||||
bd_ioctl, | bd_ioctl, | ||||
bd_print, | bd_print, | ||||
bd_cleanup | NULL | ||||
}; | }; | ||||
/* | /* | ||||
* Translate between BIOS device numbers and our private unit numbers. | * Translate between BIOS device numbers and our private unit numbers. | ||||
*/ | */ | ||||
int | int | ||||
bd_bios2unit(int biosdev) | bd_bios2unit(int biosdev) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | #endif | ||||
if (base == 0x80) | if (base == 0x80) | ||||
nfd++; | nfd++; | ||||
} | } | ||||
} | } | ||||
bcache_add_dev(nbdinfo); | bcache_add_dev(nbdinfo); | ||||
return(0); | return(0); | ||||
} | } | ||||
static void | |||||
bd_cleanup(void) | |||||
{ | |||||
disk_cleanup(&biosdisk); | |||||
} | |||||
/* | /* | ||||
* Try to detect a device supported by the legacy int13 BIOS | * Try to detect a device supported by the legacy int13 BIOS | ||||
*/ | */ | ||||
static int | static int | ||||
bd_int13probe(struct bdinfo *bd) | bd_int13probe(struct bdinfo *bd) | ||||
{ | { | ||||
struct edd_params params; | struct edd_params params; | ||||
int ret = 1; /* assume success */ | int ret = 1; /* assume success */ | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | for (i = 0; i < nbdinfo; i++) { | ||||
if ((ret = pager_output(line)) != 0) | if ((ret = pager_output(line)) != 0) | ||||
break; | break; | ||||
dev.d_dev = &biosdisk; | dev.d_dev = &biosdisk; | ||||
dev.d_unit = i; | dev.d_unit = i; | ||||
dev.d_slice = -1; | dev.d_slice = -1; | ||||
dev.d_partition = -1; | dev.d_partition = -1; | ||||
if (disk_open(&dev, | if (disk_open(&dev, | ||||
bdinfo[i].bd_sectorsize * bdinfo[i].bd_sectors, | bdinfo[i].bd_sectorsize * bdinfo[i].bd_sectors, | ||||
bdinfo[i].bd_sectorsize, | bdinfo[i].bd_sectorsize) == 0) { | ||||
(bdinfo[i].bd_flags & BD_FLOPPY) ? | |||||
DISK_F_NOCACHE: 0) == 0) { | |||||
snprintf(line, sizeof(line), " disk%d", i); | snprintf(line, sizeof(line), " disk%d", i); | ||||
ret = disk_print(&dev, line, verbose); | ret = disk_print(&dev, line, verbose); | ||||
disk_close(&dev); | disk_close(&dev); | ||||
if (ret != 0) | if (ret != 0) | ||||
return (ret); | return (ret); | ||||
} | } | ||||
} | } | ||||
return (ret); | return (ret); | ||||
Show All 38 Lines | bd_open(struct open_file *f, ...) | ||||
disk.d_dev = dev->d_dev; | disk.d_dev = dev->d_dev; | ||||
disk.d_type = dev->d_type; | disk.d_type = dev->d_type; | ||||
disk.d_unit = dev->d_unit; | disk.d_unit = dev->d_unit; | ||||
disk.d_opendata = NULL; | disk.d_opendata = NULL; | ||||
disk.d_slice = -1; | disk.d_slice = -1; | ||||
disk.d_partition = -1; | disk.d_partition = -1; | ||||
disk.d_offset = 0; | disk.d_offset = 0; | ||||
if (disk_open(&disk, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | if (disk_open(&disk, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | ||||
BD(dev).bd_sectorsize, (BD(dev).bd_flags & BD_FLOPPY) ? | BD(dev).bd_sectorsize) == 0) { | ||||
DISK_F_NOCACHE: 0) == 0) { | |||||
if (disk_ioctl(&disk, DIOCGMEDIASIZE, &size) == 0) { | if (disk_ioctl(&disk, DIOCGMEDIASIZE, &size) == 0) { | ||||
size /= BD(dev).bd_sectorsize; | size /= BD(dev).bd_sectorsize; | ||||
if (size > BD(dev).bd_sectors) | if (size > BD(dev).bd_sectors) | ||||
BD(dev).bd_sectors = size; | BD(dev).bd_sectors = size; | ||||
} | } | ||||
disk_close(&disk); | disk_close(&disk); | ||||
} | } | ||||
err = disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | err = disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | ||||
BD(dev).bd_sectorsize, (BD(dev).bd_flags & BD_FLOPPY) ? | BD(dev).bd_sectorsize); | ||||
DISK_F_NOCACHE: 0); | |||||
#ifdef LOADER_GELI_SUPPORT | #ifdef LOADER_GELI_SUPPORT | ||||
static char gelipw[GELI_PW_MAXLEN]; | static char gelipw[GELI_PW_MAXLEN]; | ||||
char *passphrase; | char *passphrase; | ||||
if (err) | if (err) | ||||
return (err); | return (err); | ||||
▲ Show 20 Lines • Show All 503 Lines • ▼ Show 20 Lines | bd_getdev(struct i386_devdesc *d) | ||||
int i, unit; | int i, unit; | ||||
dev = (struct disk_devdesc *)d; | dev = (struct disk_devdesc *)d; | ||||
biosdev = bd_unit2bios(dev->d_unit); | biosdev = bd_unit2bios(dev->d_unit); | ||||
DEBUG("unit %d BIOS device %d", dev->d_unit, biosdev); | DEBUG("unit %d BIOS device %d", dev->d_unit, biosdev); | ||||
if (biosdev == -1) /* not a BIOS device */ | if (biosdev == -1) /* not a BIOS device */ | ||||
return(-1); | return(-1); | ||||
if (disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | if (disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize, | ||||
BD(dev).bd_sectorsize,(BD(dev).bd_flags & BD_FLOPPY) ? | BD(dev).bd_sectorsize) != 0) /* oops, not a viable device */ | ||||
DISK_F_NOCACHE: 0) != 0) /* oops, not a viable device */ | |||||
return (-1); | return (-1); | ||||
else | else | ||||
disk_close(dev); | disk_close(dev); | ||||
if (biosdev < 0x80) { | if (biosdev < 0x80) { | ||||
/* floppy (or emulated floppy) or ATAPI device */ | /* floppy (or emulated floppy) or ATAPI device */ | ||||
if (bdinfo[dev->d_unit].bd_type == DT_ATAPI) { | if (bdinfo[dev->d_unit].bd_type == DT_ATAPI) { | ||||
/* is an ATAPI disk */ | /* is an ATAPI disk */ | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |