Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/libi386/biosdisk.c
Show First 20 Lines • Show All 397 Lines • ▼ Show 20 Lines | bd_open(struct open_file *f, ...) | ||||
/* | /* | ||||
* Read disk size from partition. | * Read disk size from partition. | ||||
* This is needed to work around buggy BIOS systems returning | * This is needed to work around buggy BIOS systems returning | ||||
* wrong (truncated) disk media size. | * wrong (truncated) disk media size. | ||||
* During bd_probe() we tested if the mulitplication of bd_sectors | * During bd_probe() we tested if the mulitplication of bd_sectors | ||||
* would overflow so it should be safe to perform here. | * would overflow so it should be safe to perform here. | ||||
*/ | */ | ||||
disk.d_dev = dev->d_dev; | disk.d_dev = dev->d_dev; | ||||
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) == 0) { | BD(dev).bd_sectorsize) == 0) { | ||||
Show All 21 Lines | #ifdef LOADER_GELI_SUPPORT | ||||
struct dsk dskp; | struct dsk dskp; | ||||
struct ptable *table = NULL; | struct ptable *table = NULL; | ||||
struct ptable_entry part; | struct ptable_entry part; | ||||
struct pentry *entry; | struct pentry *entry; | ||||
int geli_part = 0; | int geli_part = 0; | ||||
dskp.drive = bd_unit2bios(dev->d_unit); | dskp.drive = bd_unit2bios(dev->d_unit); | ||||
dskp.type = dev->d_type; | dskp.type = dev->d_dev->dv_type; | ||||
dskp.unit = dev->d_unit; | dskp.unit = dev->d_unit; | ||||
dskp.slice = dev->d_slice; | dskp.slice = dev->d_slice; | ||||
dskp.part = dev->d_partition; | dskp.part = dev->d_partition; | ||||
dskp.start = dev->d_offset; | dskp.start = dev->d_offset; | ||||
memcpy(&rdev, dev, sizeof(rdev)); | memcpy(&rdev, dev, sizeof(rdev)); | ||||
/* to read the GPT table, we need to read the first sector */ | /* to read the GPT table, we need to read the first sector */ | ||||
rdev.d_offset = 0; | rdev.d_offset = 0; | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | if (diff == 0) { | ||||
} | } | ||||
} | } | ||||
err = bd_io(dev, alignlba, alignblks, tmpbuf, 0); | err = bd_io(dev, alignlba, alignblks, tmpbuf, 0); | ||||
if (err) | if (err) | ||||
return (err); | return (err); | ||||
dskp.drive = bd_unit2bios(dev->d_unit); | dskp.drive = bd_unit2bios(dev->d_unit); | ||||
dskp.type = dev->d_type; | dskp.type = dev->d_dev->dv_type; | ||||
dskp.unit = dev->d_unit; | dskp.unit = dev->d_unit; | ||||
dskp.slice = dev->d_slice; | dskp.slice = dev->d_slice; | ||||
dskp.part = dev->d_partition; | dskp.part = dev->d_partition; | ||||
dskp.start = dev->d_offset; | dskp.start = dev->d_offset; | ||||
/* GELI needs the offset relative to the partition start */ | /* GELI needs the offset relative to the partition start */ | ||||
p_off = alignlba - dskp.start; | p_off = alignlba - dskp.start; | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | |||||
#ifdef LOADER_GELI_SUPPORT | #ifdef LOADER_GELI_SUPPORT | ||||
int | int | ||||
bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes) | bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes) | ||||
{ | { | ||||
struct disk_devdesc dev; | struct disk_devdesc dev; | ||||
struct dsk *priv = xpriv; | struct dsk *priv = xpriv; | ||||
dev.d_dev = &biosdisk; | dev.d_dev = &biosdisk; | ||||
dev.d_type = priv->type; | |||||
dev.d_unit = priv->unit; | dev.d_unit = priv->unit; | ||||
dev.d_slice = priv->slice; | dev.d_slice = priv->slice; | ||||
dev.d_partition = priv->part; | dev.d_partition = priv->part; | ||||
dev.d_offset = priv->start; | dev.d_offset = priv->start; | ||||
off = off / BD(&dev).bd_sectorsize; | off = off / BD(&dev).bd_sectorsize; | ||||
/* GELI gives us the offset relative to the partition start */ | /* GELI gives us the offset relative to the partition start */ | ||||
off += dev.d_offset; | off += dev.d_offset; | ||||
bytes = bytes / BD(&dev).bd_sectorsize; | bytes = bytes / BD(&dev).bd_sectorsize; | ||||
return (bd_io(&dev, off, bytes, buf, 0)); | return (bd_io(&dev, off, bytes, buf, 0)); | ||||
} | } | ||||
#endif /* LOADER_GELI_SUPPORT */ | #endif /* LOADER_GELI_SUPPORT */ |