Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aO8iF-0001Ev-JQ for mharc-grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO8iC-0001CR-Pb for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO8iA-0001pU-Id for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:32 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:54566 helo=homiemail-a114.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO8iA-0001pC-9D for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:30 -0500 Received: from homiemail-a114.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a114.g.dreamhost.com (Postfix) with ESMTP id A433E600CF230; Tue, 26 Jan 2016 10:51:29 -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=m/CXPbGX7dwciVEW4AcJ/0L1dNE=; b=B8TvshwjZKEVrpBgtKwM5RJjT8hR THpFNhCfp81gwrtuDI4+NLUrq77YgpG3SGahVxx6/jAqPccmfHb5tix8soNGkZQi Y1NZagknOQS4DxZezas1rpnBhtrq/jhtabAfwjmzkOI39g0IQHP0g8V6Xzzl3hWZ 0HQzxU5DDJQFFrE= Received: from shlevy-laptop.hsd1.nh.comcast.net. (c-73-186-74-217.hsd1.nh.comcast.net [73.186.74.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shea@shealevy.com) by homiemail-a114.g.dreamhost.com (Postfix) with ESMTPSA id 4124C600CF22E; Tue, 26 Jan 2016 10:51:29 -0800 (PST) From: Shea Levy To: The development of GNU GRUB Subject: [PATCH 1/7] Add stub module for android bootimgs Date: Tue, 26 Jan 2016 13:51:16 -0500 Message-Id: <1453834282-28691-2-git-send-email-shea@shealevy.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453834282-28691-1-git-send-email-shea@shealevy.com> References: <1453834282-28691-1-git-send-email-shea@shealevy.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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: Tue, 26 Jan 2016 18:51:34 -0000 --- grub-core/Makefile.core.def | 7 +++ grub-core/fs/android_bootimg.c | 105 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 grub-core/fs/android_bootimg.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 0cc40bb..a726abd 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1231,6 +1231,13 @@ module = { }; module = { + name = android_bootimg; + common = fs/android_bootimg.c; + cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; + cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; +}; + +module = { name = bfs; common = fs/bfs.c; }; diff --git a/grub-core/fs/android_bootimg.c b/grub-core/fs/android_bootimg.c new file mode 100644 index 0000000..f6b2283 --- /dev/null +++ b/grub-core/fs/android_bootimg.c @@ -0,0 +1,105 @@ +/* android-bootimg.c - android bootimg filesystem. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +/* from https://android.googlesource.com/platform/system/core/+/506d233e7ac8ca4efa80768153d842c296477f99/mkbootimg/bootimg.h */ +#define BOOT_MAGIC "ANDROID!" +#define BOOT_MAGIC_SIZE 8 +#define BOOT_NAME_SIZE 16 +#define BOOT_ARGS_SIZE 512 +#define BOOT_EXTRA_ARGS_SIZE 1024 + +struct boot_img_hdr +{ + uint8_t magic[BOOT_MAGIC_SIZE]; + + uint32_t kernel_size; + uint32_t kernel_addr; + + uint32_t ramdisk_size; + uint32_t ramdisk_addr; + + uint32_t second_size; + uint32_t second_addr; + + uint32_t tags_addr; + uint32_t page_size; + uint32_t unused[2]; + + uint8_t name[BOOT_NAME_SIZE]; + + uint8_t cmdline[BOOT_ARGS_SIZE]; + + uint32_t id[8]; + + uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; +} GRUB_PACKED; + +static grub_err_t +grub_android_bootimg_dir (grub_device_t device, const char *path_in, + grub_fs_dir_hook_t hook, void *hook_data) +{ + return GRUB_ERR_NOT_IMPLEMENTED_YET; +} + +static grub_err_t +grub_android_bootimg_open (grub_file_t file, const char *name_in) +{ + return GRUB_ERR_NOT_IMPLEMENTED_YET; +} + +static grub_ssize_t +grub_android_bootimg_read (grub_file_t file, char *buf, grub_size_t len) +{ + grub_errno = GRUB_ERR_NOT_IMPLEMENTED_YET; + return -1; +} + +static grub_err_t +grub_android_bootimg_close (grub_file_t file) +{ + return GRUB_ERR_NOT_IMPLEMENTED_YET; +} + +static struct grub_fs grub_android_bootimg_fs = { + .name = "android_bootimg", + .dir = grub_android_bootimg_dir, + .open = grub_android_bootimg_open, + .read = grub_android_bootimg_read, + .close = grub_android_bootimg_close, +#ifdef GRUB_UTIL + .reserved_first_sector = 0, + .blocklist_install = 0, +#endif +}; + +GRUB_MOD_INIT (android_bootimg) +{ + grub_fs_register (&grub_android_bootimg_fs); +} + +GRUB_MOD_FINI (android_bootimg) +{ + grub_fs_unregister (&grub_android_bootimg_fs); +} -- 2.7.0