Enumerations

enum RebootMode
Name Value
kNormal 0x1
kRecovery 0x2
kBootloader 0x4
kBootloaderDefault 0xFF

Defined at line 133 of file ../../src/firmware/gigaboot/cpp/utils.h

Records

Functions

  • template <class Protocol>
    fit::result<efi_status, EfiProtocolPtr<Protocol>> EfiLocateProtocol ()

    This calls into the LocateProtocol() boot service. It returns a null pointer if operation fails.

    Defined at line 67 of file ../../src/firmware/gigaboot/cpp/utils.h

  • template <class Protocol>
    fit::result<efi_status, EfiProtocolPtr<Protocol>> EfiLocateProtocol ()

    This calls into the LocateProtocol() boot service. It returns a null pointer if operation fails.

    Defined at line 67 of file ../../src/firmware/gigaboot/cpp/utils.h

  • zx::result<> FastbootTcpMain ()

    Defined at line 90 of file ../../src/firmware/gigaboot/cpp/fastboot_tcp.cc

  • const char * EfiStatusToString (efi_status status)

    Convert a given efi_status code to informative string.

    Defined at line 50 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • template <class... Ts>
    overload<Ts...> <deduction guide for overload> (Ts... )
  • std::u16string_view ToU16StringView (const fbl::Vector<char16_t> & v)

    Defined at line 19 of file ../../src/firmware/gigaboot/cpp/efi_variables.h

  • zx::result<> LaunchGbl (bool stop_in_fastboot)

    Launches embedded GBL EFI app.

    Defined at line 78 of file ../../src/firmware/gigaboot/cpp/gbl_loader.cc

  • const std::span<const PartitionMap::PartitionEntry> GetPartitionCustomizations ()

    Get factory default partition information

    Defined at line 27 of file ../../src/firmware/gigaboot/cpp/backends_nuc.cc

  • MacAddr MulticastMacFromIp6 (const Ip6Addr & addr)

    Given a multicast IPv6 address, generate the destination multicast MAC address for

    link-local transmission.

    Defined in RFC 2464.

    Defined at line 37 of file ../../src/firmware/gigaboot/cpp/network.h

  • MacAddr MulticastMacFromIp6 (const Ip6Addr & addr)

    Given a multicast IPv6 address, generate the destination multicast MAC address for

    link-local transmission.

    Defined in RFC 2464.

    Defined at line 37 of file ../../src/firmware/gigaboot/cpp/network.h

  • Ip6Addr LocalIp6AddrFromMac (MacAddr mac_addr)

    IPv6 Stateless Address Auto-configuration (SLAAC) allows the definition of

    link-local, deterministic IP addresses without input from other network elements.

    The address must use have the prefix fe80::/64, but the precise generation mechanism

    is deferred to the implementation.

    Defined at line 47 of file ../../src/firmware/gigaboot/cpp/network.h

  • Ip6Addr LocalIp6AddrFromMac (MacAddr mac_addr)

    IPv6 Stateless Address Auto-configuration (SLAAC) allows the definition of

    link-local, deterministic IP addresses without input from other network elements.

    The address must use have the prefix fe80::/64, but the precise generation mechanism

    is deferred to the implementation.

    Defined at line 47 of file ../../src/firmware/gigaboot/cpp/network.h

  • efi_status InstallGblEfiBootControlProtocol ()

    Defined at line 48 of file ../../src/firmware/gigaboot/cpp/gbl_efi_boot_control_protocol.cc

  • template <typename T>
    decltype(t1 + t2) DivideRoundUp (T t1, T t2)

    This is a utility function useful for calculating e.g. the number of pages to allocate to back a

    certain number of bytes, or the number of disk blocks to back a partition, rounding up for a

    margin of safety.

    Defined at line 61 of file ../../src/firmware/gigaboot/cpp/utils.h

  • bool operator== (const Iterator & a, const Iterator & b)

    Defined at line 81 of file ../../src/firmware/gigaboot/cpp/acpi.h

  • bool operator!= (const Iterator & a, const Iterator & b)

    Defined at line 82 of file ../../src/firmware/gigaboot/cpp/acpi.h

  • uint16_t CalculateChecksum (std::span<const uint8_t> data, uint64_t start)

    Calculate the 1s complement checksum on a payload.

    Defined at line 87 of file ../../src/firmware/gigaboot/cpp/network.cc

  • uint16_t CalculateChecksum (std::span<const uint8_t> data, uint64_t start)

    Calculate the 1s complement checksum on a payload.

    Defined at line 87 of file ../../src/firmware/gigaboot/cpp/network.cc

  • const char * EfiStatusToString (efi_status status)

    Convert a given efi_status code to informative string.

    Defined at line 50 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • std::unique_ptr<Tss2UefiTctiContext> CreateTss2UefiTctiContext ()

    Defined at line 96 of file ../../src/firmware/gigaboot/cpp/tss2_uefi.cc

  • template <class Protocol>
    fit::result<efi_status, HandleBuffer> EfiLocateHandleBufferByProtocol ()

    This calls into LocateHandleBuffer() with ByProtocol search type and the given protocol.

    It returns a list of efi_handles that support the given protocol

    Defined at line 97 of file ../../src/firmware/gigaboot/cpp/utils.h

  • template <class Protocol>
    fit::result<efi_status, HandleBuffer> EfiLocateHandleBufferByProtocol ()

    This calls into LocateHandleBuffer() with ByProtocol search type and the given protocol.

    It returns a list of efi_handles that support the given protocol

    Defined at line 97 of file ../../src/firmware/gigaboot/cpp/utils.h

  • template <typename IntCtrlType>
    const IntCtrlType * GetInterruptController (const InterruptControllerHeader & hdr)

    Given an interrupt controller header,

    check that its type field matches the type constant of IntCtrlType.

    If the field matches, reinterpret the header and (subsequent memory)

    as a controller of type IntCtrlType.

    Return nullptr if the type field does not match.

    Defined at line 335 of file ../../src/firmware/gigaboot/cpp/acpi.h

  • std::span<uint8_t> GblFdt ()

    Defined at line 408 of file ../../src/firmware/gigaboot/cpp/gbl_dt.cc

  • std::span<uint8_t> GblFdtZbiBlob ()

    Defined at line 410 of file ../../src/firmware/gigaboot/cpp/gbl_dt.cc

  • std::span<uint8_t> GblFdtPermAttr ()

    Defined at line 412 of file ../../src/firmware/gigaboot/cpp/gbl_dt.cc

  • std::span<uint8_t> GblFdtPermAttrHash ()

    Defined at line 414 of file ../../src/firmware/gigaboot/cpp/gbl_dt.cc

  • std::span<uint8_t> GblFdtStopInFastboot ()

    Defined at line 416 of file ../../src/firmware/gigaboot/cpp/gbl_dt.cc

  • const std::span<const uint8_t> GetPermanentAttributes ()
  • const std::span<const uint8_t> GetPermanentAttributesHash ()
  • zx::result<size_t> AddMemoryItems (void * zbi, size_t capacity, const ZbiContext * context)

    Add memory related zbi items.

    Returns memory map key on success, which will be used for ExitBootService.

    Defined at line 447 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • zx::result<size_t> AddMemoryItems (void * zbi, size_t capacity, const ZbiContext * context)

    Add memory related zbi items.

    Returns memory map key on success, which will be used for ExitBootService.

    Defined at line 447 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • zx::result<std::span<zbi_mem_range_t>> CollectPeripheralMemoryItems (const ZbiContext * context, std::span<zbi_mem_range_t> & out)

    Collects ZBI_MEM_TYPE_PERIPHERAL type memory ranges into the given buffer `out`.

    Defined at line 353 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • zx::result<std::span<zbi_mem_range_t>> CollectPeripheralMemoryItems (const ZbiContext * context, std::span<zbi_mem_range_t> & out)

    Collects ZBI_MEM_TYPE_PERIPHERAL type memory ranges into the given buffer `out`.

    Defined at line 353 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • bool AddGigabootZbiItems (zbi_header_t * image, size_t capacity, const AbrSlotIndex * slot, ZbiContext * context)

    Defined at line 506 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • bool AddGigabootZbiItems (zbi_header_t * image, size_t capacity, const AbrSlotIndex * slot, ZbiContext * context)

    Defined at line 506 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • zbi_result_t AddBootloaderFiles (const char * name, const void * data, size_t len)

    Defined at line 336 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • zbi_result_t AddBootloaderFiles (const char * name, const void * data, size_t len)

    Defined at line 336 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • std::span<uint8_t> GetZbiFiles ()

    Defined at line 351 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • void ClearBootloaderFiles ()

    Defined at line 349 of file ../../src/firmware/gigaboot/cpp/boot_zbi_items.cc

  • efi_status generate_efi_memory_attributes_table_item (void * ramdisk, const size_t ramdisk_size, efi_system_table * sys, const void * mmap, size_t memory_map_size, size_t dsize)
  • const std::span<const uint8_t> GetGblEfiApp ()
  • efi_status InstallGblEfiFastbootProtocol ()

    Defined at line 102 of file ../../src/firmware/gigaboot/cpp/gbl_efi_fastboot_protocol.cc

  • uint32_t EfiToZbiMemRangeType (uint32_t efi_mem_type)

    Convert efi memory type code to zbi memory type code.

    Defined at line 100 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • uint64_t ToBigEndian (uint64_t val)

    Convert an integer to big endian byte order

    Defined at line 112 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • uint64_t ToBigEndian (uint64_t val)

    Convert an integer to big endian byte order

    Defined at line 112 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • fbl::Vector<char16_t> ToVector (std::u16string_view str)

    Defined at line 170 of file ../../src/firmware/gigaboot/cpp/efi_variables.cc

  • fbl::Vector<char16_t> ToVector (std::u16string_view str)

    Defined at line 170 of file ../../src/firmware/gigaboot/cpp/efi_variables.cc

  • uint64_t BigToHostEndian (uint64_t val)

    Convert an given integer, assuming in big endian to little endian order.

    Defined at line 120 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • uint64_t BigToHostEndian (uint64_t val)

    Convert an given integer, assuming in big endian to little endian order.

    Defined at line 120 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • efi_status PrintTpm2Capability ()

    Defined at line 122 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • template <typename Protocol>
    bool IsProtocol (const efi_guid & guid)

    Check if the given guid correspond to the protocol of a efi protocol structure.

    i.e. IsProtocol

    <efi

    _disk_io_protocol>().

    Defined at line 138 of file ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.h

  • uint8_t RebootModeToByte (RebootMode m)

    Defined at line 140 of file ../../src/firmware/gigaboot/cpp/utils.h

  • fit::result<efi_status, bool> IsSecureBootOn ()

    Check whether secure boot is turned on by querying the `SecureBoot` global variable.

    Returns error if fail to query `SecureBoot`.

    Defined at line 177 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • ZirconBootOps GetZirconBootOps ()

    TODO(b/269178761): write unit tests for "default" implementation of zircon boot ops code.

    Defined at line 181 of file ../../src/firmware/gigaboot/cpp/zircon_boot_ops.cc

  • std::string_view MaybeMapPartitionName (const EfiGptBlockDevice & device, std::string_view partition)

    Defined at line 191 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • std::string_view MaybeMapPartitionName (const EfiGptBlockDevice & device, std::string_view partition)

    Defined at line 191 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • size_t StringJoin (std::span<const std::string_view> names, char delimiter, std::span<char> buffer)

    Inspired by python's str.join()

    Take a span of string_views

    (really could be any iterable/range of string-like objects),

    a delimiter character, and an output buffer, and put into the output buffer

    the concatenation of all the input strings, in order, with a single delimiter

    between each string.

    Note: empty strings are not treated specially. If any input strings are empty,

    the output will contain consecutive delimiters.

    Defined at line 210 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • size_t StringJoin (std::span<const std::string_view> names, char delimiter, std::span<char> buffer)

    Inspired by python's str.join()

    Take a span of string_views

    (really could be any iterable/range of string-like objects),

    a delimiter character, and an output buffer, and put into the output buffer

    the concatenation of all the input strings, in order, with a single delimiter

    between each string.

    Note: empty strings are not treated specially. If any input strings are empty,

    the output will contain consecutive delimiters.

    Defined at line 210 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • deferred_action<(lambda at ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.h:235:21)> SetupEfiGlobalState (MockStubService & stub, Device & image, const EfiConfigTable & config)

    The following overrides Efi global variables for test.

    Defined at line 221 of file ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.h

  • fit::result<efi_status, EfiGptBlockDevice> FindEfiGptDevice ()

    TODO(https://fxbug.dev/42159406): The function currently only finds the storage devie that hosts

    the currently running image. This can be a problem when booting from USB. Add support to handle

    the USB case.

    Defined at line 456 of file ../../src/firmware/gigaboot/cpp/gpt.cc

  • bool SetRebootMode (RebootMode mode)

    Set reboot mode. Returns true if succeeds, false otherwise.

    Defined at line 313 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • void hexdump_printer_printf (void * printf_arg, const char * fmt)

    Defined at line 584 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • std::optional<RebootMode> GetCommandlineRebootMode (bool allow_disk_fallback)

    Gets the reboot mode indicated by the commandline, or std::nullopt if none was found.

    If `allow_disk_fallback` is set, then if this function doesn't find a commandline it will also

    search the disk for a commandline to use, as follows:

    1. locate the boot disk (i.e. the disk that Gigaboot itself came from)

    2. read the GPT and locate a partition named `kDiskCommandlinePartitionName`

    3. read `kDiskCommandlineMaxSize` bytes from the partition

    4. the commandline will be these UTF-8 contents up until the first `

    \

    0` terminator

    WARNING: This is unsafe on real devices as these contents are not verified in any way, and should

    only be used for testing with emulators.

    Defined at line 287 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • std::optional<RebootMode> GetOneShotRebootMode (AbrDataOneShotFlags one_shot_flags)

    Get the reboot mode indicated by |one_shot_flags| and/or the bootbyte data.

    Returns std::nullopt on failure

    Defined at line 318 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • fit::result<efi_status, efi_guid> ToGuid (std::string_view guid_str)

    Convert hex string to `efi_guid`

    Input string should be in RFC4122 "registry format"

    `aabbccdd-eeff-gghh-iijj-kkllmmnnoopp`

    Defined at line 338 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • fit::result<efi_status, efi_guid> ToGuid (std::string_view guid_str)

    Convert hex string to `efi_guid`

    Input string should be in RFC4122 "registry format"

    `aabbccdd-eeff-gghh-iijj-kkllmmnnoopp`

    Defined at line 338 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • fbl::Vector<char> ToStr (const efi_guid & g)

    String format is specified at https://www.rfc-editor.org/rfc/rfc4122

    And also described here: https://uefi.org/specs/UEFI/2.10/Apx_A_GUID_and_Time_Formats.html

    This specification also defines a standard text representation of the GUID. This format is also

    sometimes called the “registry format”. It consists of 36 characters, as follows:

    `aabbccdd-eeff-gghh-iijj-kkllmmnnoopp`

    The pairs aa - pp are two characters in the range ‘0’ -‘9’, ‘a’ -‘f’ or ‘A’ - F’, with each pair

    representing a single byte hexadecimal value.

    The following table describes the relationship between the text representation and a 16 - byte

    buffer, the structure defined in EFI GUID Format and the EFI_GUID structure.

    +--------+-----------+--------------------------------+-----------------+

    | String | Offset In | Relationship to EFI GUID | Relationship To |

    | | Buffer | Format | EFI_GUID |

    +--------+-----------+--------------------------------+-----------------+

    | aa | 3 | TimeLow[24:31] | Data1[24:31] |

    | bb | 2 | TimeLow[16:23] | Data1[16:23] |

    | cc | 1 | TimeLow[8:15] | Data1[8:15] |

    | dd | 0 | TimeLow[0:7] | Data1[0:7] |

    | ee | 5 | TimeMid[8:15] | Data2[8:15] |

    | ff | 4 | TimeMid[0:7] | Data2[0:7] |

    | gg | 7 | TimeHigh And Version[8:15] | Data3[8:15] |

    | hh | 6 | TimeHigh And Version[0:7] | Data3[0:7] |

    | ii | 8 | ClockSeqHigh And Reserved[0:7] | Data4[0:7] |

    | jj | 9 | ClockSeqLow[0:7] | Data4[8:15] |

    | kk | 10 | Node[0:7] | Data4[16:23] |

    | ll | 11 | Node[8:15] | Data4[24:31] |

    | mm | 12 | Node[16:23] | Data4[32:39] |

    | nn | 13 | Node[24:31] | Data4[40:47] |

    | oo | 14 | Node[32:39] | Data4[48:55] |

    | pp | 15 | Node[40:47] | Data4[56:63] |

    +--------+-----------+--------------------------------+-----------------+

    First 4 blocks are in little endian.

    Defined at line 434 of file ../../src/firmware/gigaboot/cpp/utils.cc

  • fbl::Vector<char> StringPrintf (const char * fmt, va_list va)

    Defined at line 528 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • void hexdump8_short (const void * ptr, size_t len, hexdump_printf_func_t * printf_func, void * printf_arg)

    Hex dump function with shortened output line length. Mostly taken from:

    http://cs/fuchsia/zircon/system/ulib/pretty/hexdump.cc

    void hexdump8_very_ex(const void* ptr, size_t len, uint64_t disp_addr, hexdump_printf_func_t*

    printf_func, void* printf_arg);

    It differs from original in:

    - offset column removed

    - spaces between quartets of bytes are removed

    Output format looks like:

    ```

    01010102 00000100 00000000 00000001 |................

    00 |.

    ```

    Short hexdump version is required to make it readable when send via kInfo channel.

    In order to make it easier to use with kInfo channel this function calls `printf_func` only to

    print full line.

    Defined at line 610 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • void FastbootTcpSession (TcpTransportInterface & interface, Fastboot & fastboot)

    Run a fastboot session after tcp connection is established.

    Defined at line 837 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • void SetGptEntryName (const char * name, gpt_entry_t & entry)

    Defined at line 304 of file ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.cc

  • std::vector<zbitl::ByteView> FindItems (const void * zbi, uint32_t type)

    Defined at line 363 of file ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.cc

  • const AcpiRsdp * FindAcpiRsdp ()

    Find and validate the pointer to the Root System Description Table.

    Defined at line 291 of file ../../src/firmware/gigaboot/cpp/acpi.cc

  • fbl::Vector<char> StringPrintf (const char * fmt, va_list va)

    Defined at line 528 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

  • void hexdump8_short (const void * ptrsize_t lenhexdump_printf_func_t * printf_funcvoid * printf_arg)

    Hex dump function with shortened output line length. Mostly taken from:

    http://cs/fuchsia/zircon/system/ulib/pretty/hexdump.cc

    void hexdump8_very_ex(const void* ptr, size_t len, uint64_t disp_addr, hexdump_printf_func_t*

    printf_func, void* printf_arg);

    It differs from original in:

    - offset column removed

    - spaces between quartets of bytes are removed

    Output format looks like:

    ```

    01010102 00000100 00000000 00000001 |................

    00 |.

    ```

    Short hexdump version is required to make it readable when send via kInfo channel.

    In order to make it easier to use with kInfo channel this function calls `printf_func` only to

    print full line.

    Defined at line 610 of file ../../src/firmware/gigaboot/cpp/fastboot.cc

Variables

const fbl::NoDestructor<EfiConfigTable> kDefaultEfiConfigTable

Defined at line 360 of file ../../src/firmware/gigaboot/cpp/tests/mock_boot_service.cc