From nobody Fri Apr 19 11:20:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1560332279; cv=none; d=zoho.com; s=zohoarc; b=VKBQF0icpZy8+DwbwiwluRyEHqAckWyqfyGroKDAgbarnq5wxZ0AxNacvUe/58h1yPDZte3N+rfhdeJIsd3GkjEYMX4s/BI/hRzEWgyfDCH20LqV+UkOdpRvVTNlEZxzCYmpKteB8dJWcbvICCLYXZbxl7yadJUkhSF1GRXb7KM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560332279; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=CV/oXTY4YsalYpdB9Ai3MQK0pr4v86KIFnmOAiKR3tY=; b=ZWKDRZHTlIjfPwUNHqQjhVb9Jty/teTP+wn05XhtO4w0qOb7GsZAOH5rNm2cA/vU3WRVdPfNhXCog4j+JQ5RT16f+76XisVtA78zSPilg0qP4OrtqAf9ieR2p0apHtl18mKE23sh6lVeWfU3+kDZDpXPH6M10ePCkP57yeM1VTA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1560332278998521.765330212421; Wed, 12 Jun 2019 02:37:58 -0700 (PDT) Received: from [192.168.203.99] (mailu_mailman-core_1.mailu_default [192.168.203.99]) by coreboot.org (Postfix) with ESMTP id 5948112E2EC4; Wed, 12 Jun 2019 09:37:54 +0000 (UTC) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by coreboot.org (Postfix) with ESMTP id CAA5912E2EAA for ; Wed, 12 Jun 2019 09:37:41 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C9XjJc193216; Wed, 12 Jun 2019 09:37:29 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2t05nqt7dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jun 2019 09:37:29 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C9aonq182430; Wed, 12 Jun 2019 09:37:28 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2t1jphx833-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jun 2019 09:37:28 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C9bRuD017025; Wed, 12 Jun 2019 09:37:27 GMT Received: from nexus.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Jun 2019 02:37:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=fwuS4OY+SX6hwpdwhnLGw0ixH/rHtEfLdA7s9goGmmM=; b=kmQl6Tquu3o+Ej3uDdF/booJ3rNHwJaxt53ejzihHW+t9TB268XzCuldLt5TBKvN/r9O wF7pLWczvkZYl4x4qtjCU9I9EUG/p2hRGeCuG9/NLwmTCeJKk3cL+ppEnJPBTkgOvPj+ 4Hop3CF+Mj53SR091qNyNJNDU3mEm68Sg96umHAsMUgRLLUKAANdJ2bIoJy416KauhyT 2WztdnE4b32qThZBEnZhRLE4fuA5GVU3HX7yYR+ajezg+2m+eooUFhN12CuctlZTF+ZU NTyKkc/7H0RH/YyX6v+gDXxyJsDkoGAJEch4A8jgcKwDpHxMEtGClbgTTFzPx5bFyJng Zw== From: Sam Eiderman To: seabios@seabios.org, kraxel@redhat.com, kevin@koconnor.net, kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Date: Wed, 12 Jun 2019 12:37:02 +0300 Message-Id: <20190612093704.47175-4-shmuel.eiderman@oracle.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20190612093704.47175-1-shmuel.eiderman@oracle.com> References: <20190612093704.47175-1-shmuel.eiderman@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120066 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120066 Message-ID-Hash: QICFCG6KGNC2X5CT67WAN6W5UCC6UJRI X-Message-ID-Hash: QICFCG6KGNC2X5CT67WAN6W5UCC6UJRI X-MailFrom: shmuel.eiderman@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: arbel.moshe@oracle.com, karl.heubaum@oracle.com X-Mailman-Version: 3.2.2 Precedence: list Subject: [SeaBIOS] [PATCH 3/5] geometry: Add boot_lchs_find_*() utility functions List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Adding the following utility functions: * boot_lchs_find_pci_device * boot_lchs_find_scsi_device * boot_lchs_find_ata_device These will be used to apply LCHS values received through fw_cfg. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- src/boot.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util.h | 6 +++++ 2 files changed, 88 insertions(+) diff --git a/src/boot.c b/src/boot.c index b3d49304..9248fab9 100644 --- a/src/boot.c +++ b/src/boot.c @@ -157,6 +157,88 @@ loadBootDevices(void) } } =20 +// Search the bootdevices list for the given glob pattern. +static BootDevice * +bootdevice_find(const char *glob) +{ + dprintf(1, "Searching bootdevices for: %s\n", glob); + int i; + for (i =3D 0; i < BootDeviceCount; i++) + if (glob_prefix(glob, BootDevices[i].name)) + return &BootDevices[i]; + return NULL; +} + +static BootDevice * +bootdevice_find_pci_device(struct pci_device *pci) +{ + // Find pci device - for example: /pci@i0cf8/ethernet@5 + char desc[256]; + build_pci_path(desc, sizeof(desc), "*", pci); + return bootdevice_find(desc); +} + +static BootDevice * +bootdevice_find_scsi_device(struct pci_device *pci, int target, int lun) +{ + if (!pci) + // support only pci machine for now + return NULL; + // Find scsi drive - for example: /pci@i0cf8/scsi@5/channel@0/disk@1,0 + char desc[256], *p; + p =3D build_pci_path(desc, sizeof(desc), "*", pci); + snprintf(p, desc+sizeof(desc)-p, "/*@0/*@%x,%x", target, lun); + return bootdevice_find(desc); +} + +static BootDevice * +bootdevice_find_ata_device(struct pci_device *pci, int chanid, int slave) +{ + if (!pci) + // support only pci machine for now + return NULL; + // Find ata drive - for example: /pci@i0cf8/ide@1,1/drive@1/disk@0 + char desc[256], *p; + p =3D build_pci_path(desc, sizeof(desc), "*", pci); + snprintf(p, desc+sizeof(desc)-p, "/drive@%x/disk@%x", chanid, slave); + return bootdevice_find(desc); +} + +int boot_lchs_find_pci_device(struct pci_device *pci, struct chs_s *chs) +{ + BootDevice *b =3D bootdevice_find_pci_device(pci); + if (!b) + return -1; + chs->cylinder =3D (u16)b->lcyls; + chs->head =3D (u16)b->lheads; + chs->sector =3D (u16)b->lsecs; + return 0; +} + +int boot_lchs_find_scsi_device(struct pci_device *pci, int target, int lun, + struct chs_s *chs) +{ + BootDevice *b =3D bootdevice_find_scsi_device(pci, target, lun); + if (!b) + return -1; + chs->cylinder =3D (u16)b->lcyls; + chs->head =3D (u16)b->lheads; + chs->sector =3D (u16)b->lsecs; + return 0; +} + +int boot_lchs_find_ata_device(struct pci_device *pci, int chanid, int slav= e, + struct chs_s *chs) +{ + BootDevice *b =3D bootdevice_find_ata_device(pci, chanid, slave); + if (!b) + return -1; + chs->cylinder =3D (u16)b->lcyls; + chs->head =3D (u16)b->lheads; + chs->sector =3D (u16)b->lsecs; + return 0; +} + =20 /**************************************************************** * Boot priority ordering diff --git a/src/util.h b/src/util.h index e2afc80c..b173fa88 100644 --- a/src/util.h +++ b/src/util.h @@ -38,6 +38,12 @@ struct usbdevice_s; int bootprio_find_usb(struct usbdevice_s *usbdev, int lun); int get_keystroke_full(int msec); int get_keystroke(int msec); +struct chs_s; +int boot_lchs_find_pci_device(struct pci_device *pci, struct chs_s *chs); +int boot_lchs_find_scsi_device(struct pci_device *pci, int target, int lun, + struct chs_s *chs); +int boot_lchs_find_ata_device(struct pci_device *pci, int chanid, int slav= e, + struct chs_s *chs); =20 // bootsplash.c void enable_vga_console(void); --=20 2.13.3 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org