[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [SeaBIOS] [PATCH v3 1/4] geometry: Read LCHS from fw_cfg
From: |
Sam Eiderman |
Subject: |
[Qemu-block] [SeaBIOS] [PATCH v3 1/4] geometry: Read LCHS from fw_cfg |
Date: |
Wed, 19 Jun 2019 12:23:49 +0300 |
Read bios geometry for boot devices from fw_cfg.
By receiving LCHS values directly from QEMU through fw_cfg we will be
able to support logical geometries which can not be inferred by SeaBIOS
itself.
(For instance: A 8GB virtio-blk hard drive which was originally created
as an IDE and must report LCHS of */32/63 for its operating system to
function will always break under SeaBIOS since a LARGE/LBA translation
will be used, causing the number of reported logical heads to be > 32.)
The only LCHS paravirtual interface available at the moment is for IDE
disks (rtc_read() in get_translation()) and it's limited to a maximum
of 4 disks (this code existed in SeaBIOS's translation function before
SCSI and VirtIO were even introduced).
This is why we create a new interface which allows passing LCHS
information per hdd.
Boot device information is serialized in the following way:
* device_path lcyls lheads lsecs\n
...
* device_path lcyls lheads lsecs\0
Device path is a null terminated string in the "Open Firmware" device
path format, the same path as used in bootorder.
Reviewed-by: Karl Heubaum <address@hidden>
Reviewed-by: Arbel Moshe <address@hidden>
Signed-off-by: Sam Eiderman <address@hidden>
---
src/boot.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/src/boot.c b/src/boot.c
index 5acf94fe..a2cb167c 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -24,6 +24,79 @@
/****************************************************************
+ * Boot device logical geometry
+ ****************************************************************/
+
+typedef struct BootDeviceLCHS {
+ char *name;
+ u32 lcyls;
+ u32 lheads;
+ u32 lsecs;
+} BootDeviceLCHS;
+
+static BootDeviceLCHS *BiosGeometry VARVERIFY32INIT;
+static int BiosGeometryCount;
+
+static char *
+parse_u32(char *cur, u32 *n)
+{
+ u32 m = 0;
+ if (cur) {
+ while ('0' <= *cur && *cur <= '9') {
+ m = 10 * m + (*cur - '0');
+ cur++;
+ }
+ if (*cur != '\0')
+ cur++;
+ }
+ *n = m;
+ return cur;
+}
+
+static void
+loadBiosGeometry(void)
+{
+ char *f = romfile_loadfile("bios-geometry", NULL);
+ if (!f)
+ return;
+
+ int i = 0;
+ BiosGeometryCount = 1;
+ while (f[i]) {
+ if (f[i] == '\n')
+ BiosGeometryCount++;
+ i++;
+ }
+ BiosGeometry = malloc_tmphigh(BiosGeometryCount * sizeof(BootDeviceLCHS));
+ if (!BiosGeometry) {
+ warn_noalloc();
+ free(f);
+ BiosGeometryCount = 0;
+ return;
+ }
+
+ dprintf(1, "bios geometry:\n");
+ i = 0;
+ do {
+ BootDeviceLCHS *d = &BiosGeometry[i];
+ d->name = f;
+ f = strchr(f, '\n');
+ if (f)
+ *(f++) = '\0';
+ char *chs_values = strchr(d->name, ' ');
+ if (chs_values)
+ *(chs_values++) = '\0';
+ chs_values = parse_u32(chs_values, &d->lcyls);
+ chs_values = parse_u32(chs_values, &d->lheads);
+ chs_values = parse_u32(chs_values, &d->lsecs);
+ dprintf(1, "%s: (%u, %u, %u)\n",
+ d->name, d->lcyls, d->lheads, d->lsecs);
+ i++;
+ } while (f);
+}
+
+
+/****************************************************************
* Boot priority ordering
****************************************************************/
@@ -288,6 +361,7 @@ boot_init(void)
BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000);
loadBootOrder();
+ loadBiosGeometry();
}
--
2.13.3
- [Qemu-block] [SeaBIOS] [PATCH v3 0/4] Add Qemu to SeaBIOS LCHS interface, Sam Eiderman, 2019/06/19
- [Qemu-block] [SeaBIOS] [PATCH v3 1/4] geometry: Read LCHS from fw_cfg,
Sam Eiderman <=
- [Qemu-block] [SeaBIOS] [PATCH v3 2/4] boot: Reorder functions in boot.c, Sam Eiderman, 2019/06/19
- [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Sam Eiderman, 2019/06/19
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Kevin O'Connor, 2019/06/20
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Sam Eiderman, 2019/06/21
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Kevin O'Connor, 2019/06/21
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Sam Eiderman, 2019/06/22
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Kevin O'Connor, 2019/06/22
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Sam Eiderman, 2019/06/22
- Re: [Qemu-block] [SeaBIOS] [PATCH v3 3/4] geometry: Add boot_lchs_find_*() utility functions, Sam Eiderman, 2019/06/26
[Qemu-block] [SeaBIOS] [PATCH v3 4/4] geometry: Apply LCHS values for boot devices, Sam Eiderman, 2019/06/19