Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
android_external_rust_crates/ | 06-Sep-2024 | - | 327 | 290 | ||
docs/ | 06-Sep-2024 | - | 411 | 304 | ||
efi/ | 06-Sep-2024 | - | 2,608 | 1,830 | ||
integration/aosp_u-boot-mainline/ | 06-Sep-2024 | - | 281 | 244 | ||
libabr/ | 06-Sep-2024 | - | 1,262 | 836 | ||
libavb/ | 06-Sep-2024 | - | 437 | 322 | ||
libboot/ | 06-Sep-2024 | - | 737 | 389 | ||
libbootconfig/ | 06-Sep-2024 | - | 308 | 230 | ||
libbootimg/ | 06-Sep-2024 | - | 148 | 117 | ||
libc/ | 06-Sep-2024 | - | 156 | 84 | ||
libefi/ | 06-Sep-2024 | - | 3,407 | 2,207 | ||
libelf/ | 06-Sep-2024 | - | 563 | 360 | ||
libfastboot/ | 06-Sep-2024 | - | 1,629 | 1,173 | ||
libfdt/ | 06-Sep-2024 | - | 604 | 456 | ||
libgbl/ | 06-Sep-2024 | - | 5,018 | 3,294 | ||
libmisc/ | 06-Sep-2024 | - | 205 | 143 | ||
libsafemath/ | 06-Sep-2024 | - | 537 | 335 | ||
libstorage/ | 06-Sep-2024 | - | 3,833 | 2,588 | ||
patches/ | 06-Sep-2024 | - | 53 | 48 | ||
smoltcp/ | 06-Sep-2024 | - | 317 | 237 | ||
tests/ | 06-Sep-2024 | - | 34 | 32 | ||
third_party/libzbi/ | 06-Sep-2024 | - | 2,994 | 1,984 | ||
toolchain/ | 06-Sep-2024 | - | 1,106 | 984 | ||
tools/ | 06-Sep-2024 | - | 197 | 141 | ||
BUILD | D | 06-Sep-2024 | 1.2 KiB | 38 | 35 | |
MODULE.bazel | D | 06-Sep-2024 | 399 | 7 | 6 | |
OWNERS | D | 06-Sep-2024 | 97 | 6 | 5 | |
README.md | D | 06-Sep-2024 | 3 KiB | 103 | 76 | |
WORKSPACE.bazel | D | 06-Sep-2024 | 624 | 16 | 14 | |
bazel.MODULE.bazel | D | 06-Sep-2024 | 2.2 KiB | 86 | 70 | |
bazel.WORKSPACE | D | 06-Sep-2024 | 881 | 26 | 21 | |
bazel.bazelrc | D | 06-Sep-2024 | 151 | 4 | 3 | |
build.config.constants | D | 06-Sep-2024 | 45 | 3 | 2 | |
readme.bzl | D | 06-Sep-2024 | 2.8 KiB | 118 | 105 | |
rustfmt.toml | D | 06-Sep-2024 | 93 | 6 | 4 |
README.md
1# Generic Bootloader Library 2 3This directory hosts the Generic Bootloader Library project. A Bazel 4workspace is setup for building the library as well as an EFI executable that 5can be loaded directly from the firmware. 6 7## Build 8 9The GBL project are intended to be built from the 10[Android UEFI Manifest](https://android.googlesource.com/kernel/manifest/+/refs/heads/uefi-gbl-mainline/default.xml) 11checkout. 12 13To build the EFI application: 14 15``` 16./tools/bazel run //bootable/libbootloader:gbl_efi_dist --extra_toolchains=@gbl//toolchain:all 17``` 18The above builds the EFI application for all of `x86_64`, `x86_32`, `aarch64` 19and `riscv64` platforms. 20 21To run the set of unit tests: 22 23``` 24./tools/bazel test @gbl//tests --extra_toolchains=@gbl//toolchain:all 25``` 26 27## Run the EFI application 28 29### Boot Android on Cuttlefish 30 31If you have a main AOSP checkout and is setup to run 32[Cuttlefish](https://source.android.com/docs/setup/create/cuttlefish), you can 33run the EFI image directly with: 34 35``` 36launch_cvd --android_efi_loader=<path to the EFI image> ... 37``` 38 39The above uses the same setting as a normal `launch_cvd` run, except that 40insted of booting Android directly, the emulator first hands off to the EFI 41application, which will take over booting android. 42 43Note: For x86 platform, use the EFI image built for `x86_32`. 44 45### Boot Fuchsia on Vim3 46 47Booting Fuchsia on a Vim3 development board is supported. To run the 48application: 49 501. Complete all 51[bootstrap steps](https://fuchsia.dev/fuchsia-src/development/hardware/khadas-vim3?hl=en) 52to setup Vim3 as a Fuchsia device. 532. Reboot the device into fastboot mode. 543. Run fastboot command: 55``` 56fastboot stage <path to the EFI binary> && fastboot oem run-staged-efi 57``` 58 59### Run on standalone QEMU 60 61If you want to test the EFI image directly on QEMU with your custom 62configurations: 63 641. Install EDK, QEMU and u-boot prebuilts 65 66 ``` 67 sudo apt-get install qemu-system ovmf u-boot-qemu 68 ``` 69 701. Depending on the target achitecture you want to run: 71 72 For `x86_64`: 73 ``` 74 mkdir -p /tmp/esp/EFI/BOOT && \ 75 cp <path to EFI image> /tmp/esp/EFI/BOOT/bootx64.efi && \ 76 qemu-system-x86_64 -nographic \ 77 -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd \ 78 -drive format=raw,file=fat:rw:/tmp/esp 79 ``` 80 81 For `aarch64`: 82 ``` 83 mkdir -p /tmp/esp/EFI/BOOT && \ 84 cp <path to EFI image> /tmp/esp/EFI/BOOT/bootaa64.efi && \ 85 qemu-system-aarch64 -nographic -machine virt -m 1G -cpu cortex-a57 \ 86 -drive if=pflash,format=raw,readonly=on,file=/usr/share/AAVMF/AAVMF_CODE.fd \ 87 -drive format=raw,file=fat:rw:/tmp/esp 88 ``` 89 90 For `riscv64`: 91 ``` 92 mkdir -p /tmp/esp/EFI/BOOT && \ 93 cp <path to EFI image> /tmp/esp/EFI/BOOT/bootriscv64.efi && \ 94 qemu-system-riscv64 -nographic -machine virt -m 256M \ 95 -bios /usr/lib/u-boot/qemu-riscv64/u-boot.bin \ 96 -drive format=raw,file=fat:rw:/tmp/esp,id=blk0 \ 97 -device virtio-blk-device,drive=blk0 98 ``` 99 100## EFI Protocols 101 102List of EFI protocols used by GBL and a brief description of each [here](./docs/efi_protocols.md). 103
readme.bzl
1# Copyright (C) 2024 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15""" 16Action that verifies all EFI protocols used by GBL are explicitly listed in README.md 17""" 18 19load("@rules_rust//rust/private:providers.bzl", "CrateInfo") 20 21def _readme_test_rule_impl(ctx): 22 shell_script = """ 23while [[ $# -gt 0 ]]; do 24 case $1 in 25 --in) 26 INPUT=$2 27 shift 28 shift 29 ;; 30 --out) 31 OUTPUT=$2 32 shift 33 shift 34 ;; 35 --readme) 36 README=$2 37 shift 38 shift 39 ;; 40 *) 41 echo "Unexpected argument: $1" 42 exit 1 43 ;; 44 esac 45done 46 47if [ ! -f $README ]; then 48 echo "README file doesn't exist: ${README}" 49 exit 1 50fi 51 52ALL_INPUTS=$(echo ${INPUT} | sed 's/,/ /g') 53 54DOCLESS_PROTOCOLS="" 55PROTOCOLS=($(grep -hE 'impl ProtocolInfo for .* \\{' ${ALL_INPUTS} | awk '{print $4}' | sort)) 56for P in ${PROTOCOLS[@]} 57do 58 grep -Lq $P ${README} || DOCLESS_PROTOCOLS+="\n\t$P" 59done 60 61if [ ! -z "${DOCLESS_PROTOCOLS}" ]; then 62 echo -e "Missing documentation for protocol(s):$DOCLESS_PROTOCOLS" 63 exit 1 64fi 65 66UNUSED_PROTOCOLS="" 67README_PROTOCOLS=($(grep -P " ?.*?Protocol$" ${README} | awk '{print $NF}' | sort | uniq)) 68for P in ${README_PROTOCOLS[@]} 69do 70 grep -qhE "impl ProtocolInfo for $P" ${ALL_INPUTS} || UNUSED_PROTOCOLS+="\n\t$P" 71done 72 73if [ ! -z "${UNUSED_PROTOCOLS}" ]; then 74 echo -e "Unused protocol(s) found in documentation:$UNUSED_PROTOCOLS" 75 exit 1 76fi 77 78touch $OUTPUT 79""" 80 81 out_file = ctx.actions.declare_file("%s.script" % ctx.attr.name) 82 in_files = [s for d in ctx.attr.deps for s in d[CrateInfo].srcs.to_list()] 83 readme = ctx.attr.readme 84 args = ctx.actions.args() 85 args.add_joined( 86 "--in", 87 in_files, 88 join_with = ",", 89 ) 90 args.add( 91 "--out", 92 out_file, 93 ) 94 args.add( 95 "--readme", 96 readme[DefaultInfo].files.to_list()[0], 97 ) 98 ctx.actions.run_shell( 99 inputs = in_files + readme[DefaultInfo].files.to_list(), 100 outputs = [out_file], 101 arguments = [args], 102 command = shell_script, 103 ) 104 return [DefaultInfo(executable = out_file)] 105 106readme_test = rule( 107 implementation = _readme_test_rule_impl, 108 attrs = { 109 "deps": attr.label_list( 110 providers = [CrateInfo], 111 ), 112 "readme": attr.label( 113 allow_single_file = [".md"], 114 ), 115 }, 116 test = True, 117) 118