Received: from list by lists.gnu.org with archive (Exim 4.71) id 1etgvc-0005P5-Js for mharc-grub-devel@gnu.org; Wed, 07 Mar 2018 16:48:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etgva-0005Oq-Dv for grub-devel@gnu.org; Wed, 07 Mar 2018 16:48:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etgvX-0002ul-6H for grub-devel@gnu.org; Wed, 07 Mar 2018 16:48:50 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etgvW-0002ta-Tp for grub-devel@gnu.org; Wed, 07 Mar 2018 16:48:47 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w27Lis5C075604 for ; Wed, 7 Mar 2018 21:48:44 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=HvIN0QKvtSyCa70dGGuTz7EI+kuwHSVab3IDM403pwI=; b=VQya9Nh8yaGu8wNK4gCYVSdgVdQAZ9fwhNk9Aq6hc6bYdWJ2unIPGV+RXPlKSqtCbU9N N64lYu0+CcrnMjDmz/AVNfS/Tw3aKX33greYkHv2cgtHcsQQXGJEkUK3mzi0VWh5bdF+ fFWJ71npEt/MwFAQM8FQGOYdU+RC9BhbIZVSvbwNxSc/M4qulZ5N+XDVoSbbmpGj1LiQ mqPA+EHhpmcGmMpi8H+RTS/SgqsQzZcOISBpKwzPJKCCSpg7iOND/fvUaVgnoaSocnAv 3Q6i988vhBgKljwAViysyrIk74ICrqb8aiagqmR8qpN2Lo4Gqphxef85vT8bQ4Aevhd4 Vg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2gjr9400pb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 07 Mar 2018 21:48:44 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w27LmhKp003144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 7 Mar 2018 21:48:43 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w27LmgUB011354 for ; Wed, 7 Mar 2018 21:48:43 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Mar 2018 13:48:42 -0800 From: Eric Snowberg To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, eric.snowberg@oracle.com Subject: [PATCH] ieee1275: split up grub_machine_get_bootlocation Date: Wed, 7 Mar 2018 13:48:10 -0800 Message-Id: <1520459290-145494-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=8825 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1711220000 definitions=main-1803070246 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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: Wed, 07 Mar 2018 21:48:51 -0000 Split up some of the functionality in grub_machine_get_bootlocation into grub_ieee1275_get_boot_dev. This will allow for code reuse in a follow on patch. Signed-off-by: Eric Snowberg --- grub-core/kern/ieee1275/init.c | 24 ++++-------------------- grub-core/kern/ieee1275/openfw.c | 27 +++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 1 + 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 1259022..dff2184 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -93,29 +93,13 @@ void (*grub_ieee1275_net_config) (const char *dev, char **device, char **path, void grub_machine_get_bootlocation (char **device, char **path) { - char *bootpath; - grub_ssize_t bootpath_size; + char *bootpath = NULL; char *filename; char *type; - if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", - &bootpath_size) - || bootpath_size <= 0) - { - /* Should never happen. */ - grub_printf ("/chosen/bootpath property missing!\n"); - return; - } - - bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); - if (! bootpath) - { - grub_print_error (); - return; - } - grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, - (grub_size_t) bootpath_size + 1, 0); - bootpath[bootpath_size] = '\0'; + grub_ieee1275_get_boot_dev (&bootpath); + if (bootpath == NULL) + return; /* Transform an OF device path to a GRUB path. */ diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index ddb7783..81c03cf 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char *path) return NULL; } +void +grub_ieee1275_get_boot_dev (char **boot_dev) +{ + char *bootpath; + grub_ssize_t bootpath_size; + + if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", + &bootpath_size) + || bootpath_size <= 0) + { + /* Should never happen. */ + grub_printf ("/chosen/bootpath property missing!\n"); + return; + } + + bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); + if (! bootpath) + { + grub_print_error (); + return; + } + grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, + (grub_size_t) bootpath_size + 1, 0); + bootpath[bootpath_size] = '\0'; + + *boot_dev = bootpath; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index d0dc274..7c9bb48 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -253,6 +253,7 @@ void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *al void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, struct grub_ieee1275_devalias *alias); +void EXPORT_FUNC(grub_ieee1275_get_boot_dev) (char **boot_dev); #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) #define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \ -- 1.7.1