summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chavez <kechavez@google.com>2016-06-30 19:11:22 -0400
committerKevin Chavez <kechavez@google.com>2016-07-07 13:19:02 -0400
commitdd37a6a655f3fb35b86147c736d8fe80d3968f50 (patch)
tree65e7008578d2f7cfb66277b6032ae658f40dedbb
parent84733f46ba7db6e6f9217f0aaeeca91b90567ce7 (diff)
downloadbrillo-dd37a6a655f3fb35b86147c736d8fe80d3968f50.tar.gz
brillo: Add initial EFI A/B boot source files.
BUG=29123391 TEST=Manually tested output full-disk-image.img with qemu. Checked for presence of EFI application and executed it. Change-Id: I5bc4fd5833b2c476dc6f6d4974720f42e3c2bd12
-rw-r--r--brillo_uefi_x86_64/boot_loader/Makefile60
-rwxr-xr-xbrillo_uefi_x86_64/boot_loader/brillo_boot_loader.efibin0 -> 42643 bytes
-rw-r--r--brillo_uefi_x86_64/boot_loader/main.c34
3 files changed, 94 insertions, 0 deletions
diff --git a/brillo_uefi_x86_64/boot_loader/Makefile b/brillo_uefi_x86_64/boot_loader/Makefile
new file mode 100644
index 0000000..af55a56
--- /dev/null
+++ b/brillo_uefi_x86_64/boot_loader/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Note: This is not invoked by Android build system and is innteded to aid
+# users to locally build the boot loader application.
+# TODO: Port this as an Android.mk and add gnu-efi to external/.
+
+# EFI make flags and arguments
+EFI_CC = gcc
+EFI_LD = ld
+EFI_OBJCOPY = objcopy
+
+EFI_SRC_FILES = main.c
+EFI_OBJ_FILES = $(patsubst %.c,%.o,$(EFI_SRC_FILES))
+EFI_TARGET = brillo_boot_loader.efi
+EFI_SHARED_OBJ = $(patsubst %.efi,%.so,$(EFI_TARGET))
+
+EFI_CFLAGS = -I/usr/include/efi \
+ -I/usr/include/efi/x86_64 \
+ -I/usr/include/efi/protocol \
+ -fno-stack-protector -fpic \
+ -fshort-wchar -mno-red-zone -Wall \
+ -DEFI_FUNCTION_WRAPPER
+
+EFI_LDFLAGS = -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared \
+ -Bsymbolic -L /usr/lib/ /usr/lib/crt0-efi-x86_64.o \
+ /usr/lib/elf_x86_64_efi.lds
+EFI_LDLIBS = -lefi -lgnuefi
+
+EFI_OBJCOPY_SECTIONS = -j .text -j .sdata -j .data -j .dynamic \
+ -j .dynsym -j .rel -j .rela -j .reloc
+EFI_OBJCOPY_TARGET = --target=efi-app-x86_64
+
+
+all: $(EFI_TARGET)
+
+$(EFI_OBJ_FILES): $(EFI_SRC_FILES)
+ $(EFI_CC) $(EFI_CFLAGS) -c -o $(EFI_OBJ_FILES) $(EFI_SRC_FILES)
+
+$(EFI_SHARED_OBJ): $(EFI_OBJ_FILES)
+ $(EFI_LD) $(EFI_LDFLAGS) $(EFI_OBJ_FILES) -o $@ $(EFI_LDLIBS)
+
+$(EFI_TARGET): $(EFI_SHARED_OBJ)
+ $(EFI_OBJCOPY) $(EFI_OBJCOPY_SECTIONS) $(EFI_OBJCOPY_TARGET) $^ $@
+
+clean:
+ rm $(EFI_OBJ_FILES) $(EFI_SHARED_OBJ) $(EFI_TARGET) \ No newline at end of file
diff --git a/brillo_uefi_x86_64/boot_loader/brillo_boot_loader.efi b/brillo_uefi_x86_64/boot_loader/brillo_boot_loader.efi
new file mode 100755
index 0000000..1e10013
--- /dev/null
+++ b/brillo_uefi_x86_64/boot_loader/brillo_boot_loader.efi
Binary files differ
diff --git a/brillo_uefi_x86_64/boot_loader/main.c b/brillo_uefi_x86_64/boot_loader/main.c
new file mode 100644
index 0000000..b12950e
--- /dev/null
+++ b/brillo_uefi_x86_64/boot_loader/main.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE* SystemTable) {
+ InitializeLib(ImageHandle, SystemTable);
+ Print(L"Brillo EFI A/B BOOT LOADER\n");
+
+ return EFI_SUCCESS;
+}