Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aSsj8-0000TH-FD for mharc-grub-devel@gnu.org; Mon, 08 Feb 2016 15:48:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSsj5-0000SF-VZ for grub-devel@gnu.org; Mon, 08 Feb 2016 15:48:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSsj2-0001Us-Vu for grub-devel@gnu.org; Mon, 08 Feb 2016 15:48:03 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:45486 helo=homiemail-a91.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSsj2-0001Ub-Qa for grub-devel@gnu.org; Mon, 08 Feb 2016 15:48:00 -0500 Received: from homiemail-a91.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a91.g.dreamhost.com (Postfix) with ESMTP id E871CAE070; Mon, 8 Feb 2016 12:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=shealevy.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=shealevy.com; bh=jOphoMMAK8e2YZE0wRo4PuKLaPI=; b=HIuf1W3PStrvDgMjazA1dfh+B9Z2 tEUXEh1Ax20b3c220AnH9530nr8G0JFIuLXpCwacKu1u3o59uzzJ9czeXY0WlV+y KWyQNo5bRUVjwU4ybevW45UvE/MBjDcTFRGHQ23cuqc8M6st+TsNkMqc1IzBT5S3 ri8mwRlqjb5YONQ= Received: from shlevy-laptop.hsd1.nh.comcast.net. (c-73-186-74-217.hsd1.nh.comcast.net [73.186.74.217]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: shea@shealevy.com) by homiemail-a91.g.dreamhost.com (Postfix) with ESMTPSA id 8BBA6AE059; Mon, 8 Feb 2016 12:47:58 -0800 (PST) From: Shea Levy To: The development of GNU GRUB Subject: [PATCH v3 2/3] i386: Add support for loading from android bootimg Date: Mon, 8 Feb 2016 15:47:38 -0500 Message-Id: <1454964459-28213-3-git-send-email-shea@shealevy.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454964459-28213-1-git-send-email-shea@shealevy.com> References: <1454964459-28213-1-git-send-email-shea@shealevy.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 208.113.200.129 Cc: Shea Levy X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2016 20:48:05 -0000 --- grub-core/loader/i386/linux.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index fddcc46..6ab8d3c 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -35,6 +35,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + char android_cmdline[BOOT_ARGS_SIZE]; + android_cmdline[0] = '\0'; + if (grub_memcmp (argv[0], "android_bootimg:", sizeof "android_bootimg:" - 1) == 0) + grub_android_bootimg_load_kernel (argv[0] + sizeof "android_bootimg:" - 1, + &file, android_cmdline); + else + file = grub_file_open (argv[0]); if (! file) goto fail; @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), linux_cmdline = grub_zalloc (maximal_cmdline_size + 1); if (!linux_cmdline) goto fail; - grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_size_t cmdline_offset = 0; + if (android_cmdline[0]) + { + cmdline_offset = grub_strlen (android_cmdline) + 1; + grub_memcpy (linux_cmdline, android_cmdline, cmdline_offset - 1); + linux_cmdline[cmdline_offset - 1] = ' '; + } + grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + cmdline_offset += sizeof LINUX_IMAGE - 1; grub_create_loader_cmdline (argc, argv, - linux_cmdline - + sizeof (LINUX_IMAGE) - 1, - maximal_cmdline_size - - (sizeof (LINUX_IMAGE) - 1)); + linux_cmdline + + cmdline_offset, + maximal_cmdline_size + - cmdline_offset); len = prot_file_size; if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno) -- 2.7.0