Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eoCCc-0006SQ-QF for mharc-grub-devel@gnu.org; Tue, 20 Feb 2018 12:59:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoCCb-0006RG-2F for grub-devel@gnu.org; Tue, 20 Feb 2018 12:59:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoCCW-0007hH-2o for grub-devel@gnu.org; Tue, 20 Feb 2018 12:59:41 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:33816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoCCV-0007fm-R2 for grub-devel@gnu.org; Tue, 20 Feb 2018 12:59:36 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1KHwgP6096503; Tue, 20 Feb 2018 17:59:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=B/E6PVD4cyv/mXT6f8ASSWxfcI0g8XJaeaEsn0t0XPw=; b=AWyugnNtRGLiP3Q70SgfI7Qvkm6F6TFPKfl9HOjVJNlKsbtsZdLe4nTRsrUtpiE0Ai3y 7Qvp0VjN8VI+IpuVfCDOmz1jsTrB/G42ZSR9xXjvjDhyL2tQ5W1wNLE/ynlesbeuI0wM WvUdC9C5wckwhhlvdzOMeRutJZ/cdzN2uISqMF2e79cK4zwvXU0gmd4Zk8kTV3HrB1l0 /S0c6hokbe5DrYtzBqvHwkGaZK7Zj6Qet/Bv05VRlqvgshL/9mygOWnAR/366kmKYsG/ 76hZz28zi6Uhc3BYBqgnBA9ySrs9+VML42b/SCuh+JZwVvc3+VLrqMKIw8PlyPY74KYO bQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2g8ptb8pv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Feb 2018 17:59:27 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1KHxR0I012040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 20 Feb 2018 17:59:27 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1KHxQrY020655; Tue, 20 Feb 2018 17:59:26 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Feb 2018 09:59:25 -0800 From: Eric Snowberg To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, glaubitz@physik.fu-berlin.de, Eric Snowberg Subject: [PATCH] ieee1275: add nvme support within ofpath Date: Tue, 20 Feb 2018 09:57:14 -0800 Message-Id: <1519149434-38174-1-git-send-email-eric.snowberg@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8810 signatures=668675 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=711 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802200217 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Feb 2018 17:59:42 -0000 Add NVMe support within ofpath. The Open Firmware text representation for a NVMe device contains the Namespace ID. An invalid namespace ID is one whose value is zero or whose value is greater than the value reported by the Number of Namespaces (NN) field in the Identify Controller data structure. At the moment only a single Namespace is supported, therefore the value is currently hard coded to one. Signed-off-by: Eric Snowberg --- grub-core/osdep/linux/ofpath.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 8d7d683..af068f9 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -350,6 +350,50 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi return ret; } +static char * +of_path_of_nvme(const char *sys_devname __attribute__((unused)), + const char *device, + const char *devnode __attribute__((unused)), + const char *devicenode) +{ + char *sysfs_path, *of_path, disk[MAX_DISK_CAT]; + const char *digit_string, *part_end; + + digit_string = trailing_digits (device); + part_end = devicenode + strlen (devicenode) - 1; + + if ((digit_string != '\0') && (*part_end == 'p')) + { + /* We have a partition number, strip it off. */ + int part; + char *nvmedev, *end; + + nvmedev = strdup (devicenode); + + if (nvmedev == NULL) + return NULL; + + end = nvmedev + strlen (nvmedev) - 1; + /* Remove the p. */ + *end = '\0'; + sscanf (digit_string, "%d", &part); + snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1)); + sysfs_path = block_device_get_sysfs_path_and_link (nvmedev); + free (nvmedev); + } + else + { + /* We do not have the parition. */ + snprintf (disk, sizeof (disk), "/disk@1"); + sysfs_path = block_device_get_sysfs_path_and_link (device); + } + + of_path = find_obppath (sysfs_path); + free (sysfs_path); + strcat (of_path, disk); + return of_path; +} + static int vendor_is_ATA(const char *path) { @@ -681,6 +725,9 @@ grub_util_devname_to_ofpath (const char *sys_devname) /* All the models I've seen have a devalias "floppy". New models have no floppy at all. */ ofpath = xstrdup ("floppy"); + else if (device[0] == 'n' && device[1] == 'v' && device[2] == 'm' + && device[3] == 'e') + ofpath = of_path_of_nvme (name_buf, device, devnode, devicenode); else { grub_util_warn (_("unknown device type %s"), device); -- 1.7.1