From nobody Fri Apr 26 23:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1537516131306160.39752446233626; Fri, 21 Sep 2018 00:48:51 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1g3GBG-0005v4-GO; Fri, 21 Sep 2018 09:48:50 +0200 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1g3GB3-0005ur-7I for seabios@seabios.org; Fri, 21 Sep 2018 09:48:48 +0200 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30316C047B69 for ; Fri, 21 Sep 2018 07:48:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id CACFE7FB9B; Fri, 21 Sep 2018 07:48:03 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 038EA204A8; Fri, 21 Sep 2018 09:48:03 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 21 Sep 2018 09:48:01 +0200 Message-Id: <20180921074801.27699-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 21 Sep 2018 07:48:07 +0000 (UTC) X-Spam-Score: -6.5 (------) Subject: [SeaBIOS] [PATCH] pretty boot menu entry for cdrom drives X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RDMRC_1 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- src/util.h | 1 + src/boot.c | 7 +++++++ src/cdrom.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/src/util.h b/src/util.h index 7a23b518fc..6dd080f673 100644 --- a/src/util.h +++ b/src/util.h @@ -50,6 +50,7 @@ struct disk_op_s; int cdemu_process_op(struct disk_op_s *op); void cdrom_prepboot(void); int cdrom_boot(struct drive_s *drive_g); +char *cdrom_media_info(struct drive_s *drive_g); =20 // clock.c void clock_setup(void); diff --git a/src/boot.c b/src/boot.c index ff705fd47f..80bcc13535 100644 --- a/src/boot.c +++ b/src/boot.c @@ -395,6 +395,13 @@ boot_add_hd(struct drive_s *drive, const char *desc, i= nt prio) void boot_add_cd(struct drive_s *drive, const char *desc, int prio) { + if (GET_GLOBAL(PlatformRunningOn) & PF_QEMU) { + // We want short boot times. But on physical hardware even + // the test unit ready can take several seconds. So do media + // access on qemu only, where we know it will be fast. + char *extra =3D cdrom_media_info(drive); + desc =3D znprintf(MAXDESCSIZE, "%s (%s)", desc, extra); + } bootentry_add(IPL_TYPE_CDROM, defPrio(prio, DefaultCDPrio) , (u32)drive, desc); } diff --git a/src/cdrom.c b/src/cdrom.c index 828fb3b842..b4c36622ae 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -274,3 +274,54 @@ cdrom_boot(struct drive_s *drive) =20 return 0; } + +// go figure some cdrom information, for a pretty boot menu entry. +char* +cdrom_media_info(struct drive_s *drive) +{ + ASSERT32FLAT(); + + struct disk_op_s dop; + memset(&dop, 0, sizeof(dop)); + dop.drive_fl =3D drive; + + int ret =3D scsi_is_ready(&dop); + if (ret) + return "empty"; + + // Read the Boot Record Volume Descriptor + u8 buffer[CDROM_SECTOR_SIZE]; + dop.command =3D CMD_READ; + dop.lba =3D 0x11; + dop.count =3D 1; + dop.buf_fl =3D buffer; + ret =3D process_op(&dop); + if (ret) + return "read error"; + + // Is it bootable? + if (buffer[0]) + return "not bootable"; + if (strcmp((char*)&buffer[1], "CD001\001EL TORITO SPECIFICATION") !=3D= 0) + return "not bootable"; + + // Read the Primary Volume Descriptor + dop.command =3D CMD_READ; + dop.lba =3D 0x10; + dop.count =3D 1; + dop.buf_fl =3D buffer; + ret =3D process_op(&dop); + if (ret) + return "read error"; + + // Read volume id, trim trailing spaces + char *volume =3D znprintf(30, "%s", buffer + 40); + char *h =3D volume + strlen(volume); + while (h > volume) { + h--; + if (*h !=3D ' ') + break; + *h =3D 0; + } + return volume; +} --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios