• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

android_external_rust_crates/15-Dec-2024-327290

docs/15-Dec-2024-411304

efi/15-Dec-2024-2,6081,830

integration/aosp_u-boot-mainline/15-Dec-2024-281244

libabr/15-Dec-2024-1,262836

libavb/15-Dec-2024-437322

libboot/15-Dec-2024-737389

libbootconfig/15-Dec-2024-308230

libbootimg/15-Dec-2024-148117

libc/15-Dec-2024-15684

libefi/15-Dec-2024-3,4072,207

libelf/15-Dec-2024-563360

libfastboot/15-Dec-2024-1,6291,173

libfdt/15-Dec-2024-604456

libgbl/15-Dec-2024-5,0183,294

libmisc/15-Dec-2024-205143

libsafemath/15-Dec-2024-537335

libstorage/15-Dec-2024-3,8332,588

patches/15-Dec-2024-5348

smoltcp/15-Dec-2024-317237

tests/15-Dec-2024-3432

third_party/libzbi/15-Dec-2024-2,9941,984

toolchain/15-Dec-2024-1,106984

tools/15-Dec-2024-197141

BUILDD15-Dec-20241.2 KiB3835

MODULE.bazelD15-Dec-2024399 76

OWNERSD15-Dec-202497 65

README.mdD15-Dec-20243 KiB10376

WORKSPACE.bazelD15-Dec-2024624 1614

bazel.MODULE.bazelD15-Dec-20242.2 KiB8670

bazel.WORKSPACED15-Dec-2024881 2621

bazel.bazelrcD15-Dec-2024151 43

build.config.constantsD15-Dec-202445 32

readme.bzlD15-Dec-20242.8 KiB118105

rustfmt.tomlD15-Dec-202493 64

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