From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/r-efi/.cargo-checksum.json | 1 + vendor/r-efi/AUTHORS | 68 + vendor/r-efi/Cargo.lock | 26 + vendor/r-efi/Cargo.toml | 71 ++ vendor/r-efi/NEWS.md | 205 +++ vendor/r-efi/README.md | 99 ++ vendor/r-efi/examples/freestanding.rs | 34 + vendor/r-efi/examples/gop-query.rs | 188 +++ vendor/r-efi/examples/hello-world.rs | 55 + vendor/r-efi/examples/uefi-cross-compile.rs | 41 + vendor/r-efi/src/base.rs | 867 +++++++++++++ vendor/r-efi/src/hii.rs | 1300 ++++++++++++++++++++ vendor/r-efi/src/lib.rs | 352 ++++++ vendor/r-efi/src/protocols.rs | 45 + vendor/r-efi/src/protocols/block_io.rs | 70 ++ vendor/r-efi/src/protocols/debug_support.rs | 835 +++++++++++++ vendor/r-efi/src/protocols/debugport.rs | 42 + vendor/r-efi/src/protocols/decompress.rs | 37 + vendor/r-efi/src/protocols/device_path.rs | 66 + .../r-efi/src/protocols/device_path_from_text.rs | 26 + vendor/r-efi/src/protocols/device_path_to_text.rs | 30 + .../r-efi/src/protocols/device_path_utilities.rs | 63 + vendor/r-efi/src/protocols/disk_io.rs | 40 + vendor/r-efi/src/protocols/disk_io2.rs | 58 + vendor/r-efi/src/protocols/driver_binding.rs | 42 + vendor/r-efi/src/protocols/driver_diagnostics2.rs | 38 + vendor/r-efi/src/protocols/file.rs | 183 +++ vendor/r-efi/src/protocols/graphics_output.rs | 103 ++ vendor/r-efi/src/protocols/hii_database.rs | 299 +++++ vendor/r-efi/src/protocols/hii_font.rs | 87 ++ vendor/r-efi/src/protocols/hii_font_ex.rs | 107 ++ vendor/r-efi/src/protocols/hii_string.rs | 71 ++ vendor/r-efi/src/protocols/ip4.rs | 202 +++ vendor/r-efi/src/protocols/ip6.rs | 264 ++++ vendor/r-efi/src/protocols/loaded_image.rs | 39 + .../src/protocols/loaded_image_device_path.rs | 13 + vendor/r-efi/src/protocols/managed_network.rs | 147 +++ vendor/r-efi/src/protocols/mp_services.rs | 121 ++ vendor/r-efi/src/protocols/rng.rs | 83 ++ vendor/r-efi/src/protocols/service_binding.rs | 20 + vendor/r-efi/src/protocols/shell.rs | 295 +++++ .../r-efi/src/protocols/shell_dynamic_command.rs | 33 + vendor/r-efi/src/protocols/shell_parameters.rs | 23 + vendor/r-efi/src/protocols/simple_file_system.rs | 26 + vendor/r-efi/src/protocols/simple_network.rs | 196 +++ vendor/r-efi/src/protocols/simple_text_input.rs | 38 + vendor/r-efi/src/protocols/simple_text_input_ex.rs | 85 ++ vendor/r-efi/src/protocols/simple_text_output.rs | 86 ++ vendor/r-efi/src/protocols/tcp4.rs | 224 ++++ vendor/r-efi/src/protocols/tcp6.rs | 202 +++ vendor/r-efi/src/protocols/timestamp.rs | 32 + vendor/r-efi/src/protocols/udp4.rs | 151 +++ vendor/r-efi/src/protocols/udp6.rs | 137 +++ vendor/r-efi/src/system.rs | 933 ++++++++++++++ vendor/r-efi/src/vendor.rs | 10 + vendor/r-efi/src/vendor/intel/console_control.rs | 37 + 56 files changed, 8946 insertions(+) create mode 100644 vendor/r-efi/.cargo-checksum.json create mode 100644 vendor/r-efi/AUTHORS create mode 100644 vendor/r-efi/Cargo.lock create mode 100644 vendor/r-efi/Cargo.toml create mode 100644 vendor/r-efi/NEWS.md create mode 100644 vendor/r-efi/README.md create mode 100644 vendor/r-efi/examples/freestanding.rs create mode 100644 vendor/r-efi/examples/gop-query.rs create mode 100644 vendor/r-efi/examples/hello-world.rs create mode 100644 vendor/r-efi/examples/uefi-cross-compile.rs create mode 100644 vendor/r-efi/src/base.rs create mode 100644 vendor/r-efi/src/hii.rs create mode 100644 vendor/r-efi/src/lib.rs create mode 100644 vendor/r-efi/src/protocols.rs create mode 100644 vendor/r-efi/src/protocols/block_io.rs create mode 100644 vendor/r-efi/src/protocols/debug_support.rs create mode 100644 vendor/r-efi/src/protocols/debugport.rs create mode 100644 vendor/r-efi/src/protocols/decompress.rs create mode 100644 vendor/r-efi/src/protocols/device_path.rs create mode 100644 vendor/r-efi/src/protocols/device_path_from_text.rs create mode 100644 vendor/r-efi/src/protocols/device_path_to_text.rs create mode 100644 vendor/r-efi/src/protocols/device_path_utilities.rs create mode 100644 vendor/r-efi/src/protocols/disk_io.rs create mode 100644 vendor/r-efi/src/protocols/disk_io2.rs create mode 100644 vendor/r-efi/src/protocols/driver_binding.rs create mode 100644 vendor/r-efi/src/protocols/driver_diagnostics2.rs create mode 100644 vendor/r-efi/src/protocols/file.rs create mode 100644 vendor/r-efi/src/protocols/graphics_output.rs create mode 100644 vendor/r-efi/src/protocols/hii_database.rs create mode 100644 vendor/r-efi/src/protocols/hii_font.rs create mode 100644 vendor/r-efi/src/protocols/hii_font_ex.rs create mode 100644 vendor/r-efi/src/protocols/hii_string.rs create mode 100644 vendor/r-efi/src/protocols/ip4.rs create mode 100644 vendor/r-efi/src/protocols/ip6.rs create mode 100644 vendor/r-efi/src/protocols/loaded_image.rs create mode 100644 vendor/r-efi/src/protocols/loaded_image_device_path.rs create mode 100644 vendor/r-efi/src/protocols/managed_network.rs create mode 100644 vendor/r-efi/src/protocols/mp_services.rs create mode 100644 vendor/r-efi/src/protocols/rng.rs create mode 100644 vendor/r-efi/src/protocols/service_binding.rs create mode 100644 vendor/r-efi/src/protocols/shell.rs create mode 100644 vendor/r-efi/src/protocols/shell_dynamic_command.rs create mode 100644 vendor/r-efi/src/protocols/shell_parameters.rs create mode 100644 vendor/r-efi/src/protocols/simple_file_system.rs create mode 100644 vendor/r-efi/src/protocols/simple_network.rs create mode 100644 vendor/r-efi/src/protocols/simple_text_input.rs create mode 100644 vendor/r-efi/src/protocols/simple_text_input_ex.rs create mode 100644 vendor/r-efi/src/protocols/simple_text_output.rs create mode 100644 vendor/r-efi/src/protocols/tcp4.rs create mode 100644 vendor/r-efi/src/protocols/tcp6.rs create mode 100644 vendor/r-efi/src/protocols/timestamp.rs create mode 100644 vendor/r-efi/src/protocols/udp4.rs create mode 100644 vendor/r-efi/src/protocols/udp6.rs create mode 100644 vendor/r-efi/src/system.rs create mode 100644 vendor/r-efi/src/vendor.rs create mode 100644 vendor/r-efi/src/vendor/intel/console_control.rs (limited to 'vendor/r-efi') diff --git a/vendor/r-efi/.cargo-checksum.json b/vendor/r-efi/.cargo-checksum.json new file mode 100644 index 000000000..c3c0b78b9 --- /dev/null +++ b/vendor/r-efi/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"AUTHORS":"a5c0944edd0daf49da57a0b7425726385b3563368321e9ca7ec3044978f3e122","Cargo.lock":"31d6fecf534cd92fa83bb1bdf3b5ae481078f8acb382d9eb9534a670b2c17f0c","Cargo.toml":"0cd0b25a3851af28948a15dea6ef6dc985d12c342ffb334a54c5f57ae8764964","NEWS.md":"0c251adff416a25dbe3f81696202b97c5da62a2d89a74bb5bd09e7419a7030cf","README.md":"420f65fec3ba2e89d49da51b222d2881d26959037a7b7d3794143db4bd4627b1","examples/freestanding.rs":"0be5eb60397228306aa9f8afc533e32926d210205a7359e14da903159482416d","examples/gop-query.rs":"3257c55d6ae4572db1bfcaf20bc05990ea92d46c5d292eb99c278242f1007e2c","examples/hello-world.rs":"1a398f93a54bfddaab6ba3e0145cf70496266c44b9748a11ff569a9a18063bc4","examples/uefi-cross-compile.rs":"8460ca4da6b0e27d501997b07a4ff97cee54627edc0c4847d8b2f35c0468a029","src/base.rs":"0b89e4e91f1b87a5e53a8d4fdf0bd218ec1db697ec987eab48895b51cb238a6b","src/hii.rs":"d0b19b7cc7b0c2c4d70e2891554ed6d7f941388709476eab6fa7bad129c583ed","src/lib.rs":"572edf6e771e36835fea385097cc416d4270e24fe735abf94a0c8bb5721212c4","src/protocols.rs":"05d46c1f289c8a65d6d6c5a3654b0b61a65b8a5e4d13f4aa41c90bb33fee9dc3","src/protocols/block_io.rs":"4f70d38453f057bb240988d7fac593ffa0f38a0057c6e8855f34ff37801e7f3d","src/protocols/debug_support.rs":"a03fc44a2ad151e58eff3bd72f910b63bfadd5802ac2fc157fc94c2030bd9fa9","src/protocols/debugport.rs":"bc491b03444ec35593a9cde519d0ab5fc863a046073dd813f1eb58c075da45dc","src/protocols/decompress.rs":"a4c67d958f0b9a392840a53eef69369acc6f545f90369685b3cae3c32e5cbc51","src/protocols/device_path.rs":"1b052b567629a9c3cc03a2dc39e00bad757726bb7ef02b3d20bfdffb27a72016","src/protocols/device_path_from_text.rs":"e972d7699fb031df9da2c4d5623ae289d4cc282116b634218039b97d1e7628fe","src/protocols/device_path_to_text.rs":"9929d0797ab4892051bd15ac831dc2566f7106ec9edec0fd289b3c780a2b0976","src/protocols/device_path_utilities.rs":"7d7e9ba66e9f8add3c77718bd605e6e434598f2834236e7805aba57b531eba30","src/protocols/disk_io.rs":"01a68686dae958b4fbd9fd5bbc556cf41b61e7da281a0b4ea56e62e61822d843","src/protocols/disk_io2.rs":"33aeb807ab9b78534787f44e0a3a8c52afe057e23b48ecb6703195cd0b135a8e","src/protocols/driver_binding.rs":"f48363c5afd21aac39cbd2644be0e861acc4b182bc14c68a4f84e94a5f001f8d","src/protocols/driver_diagnostics2.rs":"62b0ffe6760ae0e90e51652c667ec623cef3bbd44c17fb89881a24167b1b446c","src/protocols/file.rs":"25f09f54cf3ebd69366bde5160218247c6712ae19dac17a36ec4e2881b214f93","src/protocols/graphics_output.rs":"9e9b7ac05b92ac0a9680506edb3ed36ebbac2dc9c800268b2c54cbf539e9dd9e","src/protocols/hii_database.rs":"faa82d420085dee851f8a332db00c888e7ed1685d43e2c286790a34b2ecfdf7a","src/protocols/hii_font.rs":"092f45c74335c524ee379508e2b6925ed9033c7c10928e64b2489ca3778a4723","src/protocols/hii_font_ex.rs":"2400b2092c14da2aa09c62266356321d4b96838dc41c5918a2f3e0e1e3920318","src/protocols/hii_string.rs":"1327ba9e108900ddafec98c02534c81104c3c47cad32a7d17c7b7a7ee723c86f","src/protocols/ip4.rs":"252d244ec9b098fcee6a185ffa98cbdee34164c7872fe30b07d5e8dfdf7a8fe3","src/protocols/ip6.rs":"72a51653aa4535f7b136a7bacaa1718e0a68be847d4a716c6e76b7f75a94e6ea","src/protocols/loaded_image.rs":"ff1c0ac600feeb780fe50920cc39cb2738d0749f00fb273658c8f34e6d382609","src/protocols/loaded_image_device_path.rs":"66e8fe3477785dadf96401da10e203ba729e54d7eddedaffc4d17acc9a0daf7f","src/protocols/managed_network.rs":"592111dee58137a21f3b49211baf0d9c73a14ca9de95fa31d7e87435ded3808d","src/protocols/mp_services.rs":"509e7d483df52ab1ba1f9241bb7b286ffe205c4328557b3115cd290b4c9f8278","src/protocols/rng.rs":"279ce976d190889064d0159b10586bab9a2e5670368b460be4497ead523d6dda","src/protocols/service_binding.rs":"256920333ea26fabd3b62ba8a8b25068349acab6da01a807dfba3307a45d79a0","src/protocols/shell.rs":"3259b0bf2574da6b2343da0b9ce46980d296a8e6d8c2fe36df3a07d0629ad653","src/protocols/shell_dynamic_command.rs":"9c2f977fe4e0757b633de49627a9645d81c821a39e752cb329f6285d376fe52d","src/protocols/shell_parameters.rs":"fb88c63822a14dc94e96f7912fa5409f68b669105fb81459b969ec066002e352","src/protocols/simple_file_system.rs":"e3d870bdaf3ae0f0cded7817a4eda6d5dea2e0b77855cd21c7ac05046c77b564","src/protocols/simple_network.rs":"8b8c49872488cc0e759efe74c04fc65f5d7637dca7d9a0a1cedb5dafb2597acb","src/protocols/simple_text_input.rs":"d9a7e8cbf508daedaa26dc8301e52be957edfcc12be9e962b8504584aee669a8","src/protocols/simple_text_input_ex.rs":"84ccd2ff2c354c0447a9c46406ad76de018495d5f85979cf35d78b7070a8f63c","src/protocols/simple_text_output.rs":"05857880b5c0a6fb6ce83eedcc7fa25107f368950ab18a3d0ef1ed669d3456df","src/protocols/tcp4.rs":"2131cf06fd856017ea45135fb59264a43fabc3db1b7ddc90cd19c169ccdacae9","src/protocols/tcp6.rs":"98c24c43632acc60f2dc558c13a03657f93edca735435c50b9f2cc5625f7d3bb","src/protocols/timestamp.rs":"118cc4a54da4f53a4bb2fbf66cde8c433208266a22b59b4e370393f5a40c20a9","src/protocols/udp4.rs":"c4d344a40c674524383be51621a485d15ccfffaa94a1050c7a4642199fa91bf6","src/protocols/udp6.rs":"ea4ee2154e045a4e5992688e6cafed2d5a5de41f2796f5c070e739818b361550","src/system.rs":"a347f1cd7197e25a4ede3fa89c333d78db927a3430cccb37b2573dd041feed03","src/vendor.rs":"6cc53fe0e98220fe627d82c9b27f1468095358bb26634a8c19274495888138af","src/vendor/intel/console_control.rs":"03a7fdf97ab1836353266786811ac47171d1c425dcead707f5ed0e2e834873fb"},"package":"575fc2d9b3da54adbdfaddf6eca48fec256d977c8630a1750b8991347d1ac911"} \ No newline at end of file diff --git a/vendor/r-efi/AUTHORS b/vendor/r-efi/AUTHORS new file mode 100644 index 000000000..f293b9619 --- /dev/null +++ b/vendor/r-efi/AUTHORS @@ -0,0 +1,68 @@ +LICENSE: + This project is triple-licensed under the MIT License, the Apache + License, Version 2.0, and the GNU Lesser General Public License, + Version 2.1+. + +AUTHORS-MIT: + 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. + +AUTHORS-ASL: + 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. + +AUTHORS-LGPL: + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; If not, see . + +COPYRIGHT: (ordered alphabetically) + Copyright (C) 2017-2023 Red Hat, Inc. + Copyright (C) 2019-2020 Microsoft Corporation + +AUTHORS: (ordered alphabetically) + Alex James + Ayush Singh + Boris-Chengbiao Zhou + Bret Barkelew + David Rheinsberg + Hiroki Tokunaga + Joe Richey + Michael Kubacki + Richard Wiedenhöft + Rob Bradford + Tom Gundersen diff --git a/vendor/r-efi/Cargo.lock b/vendor/r-efi/Cargo.lock new file mode 100644 index 000000000..832d27b40 --- /dev/null +++ b/vendor/r-efi/Cargo.lock @@ -0,0 +1,26 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "compiler_builtins" +version = "0.1.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e3183e88f659a862835db8f4b67dbeed3d93e44dd4927eef78edb1c149d784" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "r-efi" +version = "4.2.0" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" diff --git a/vendor/r-efi/Cargo.toml b/vendor/r-efi/Cargo.toml new file mode 100644 index 000000000..5aac4541c --- /dev/null +++ b/vendor/r-efi/Cargo.toml @@ -0,0 +1,71 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "r-efi" +version = "4.2.0" +authors = [ + "David Rheinsberg ", + "Tom Gundersen ", +] +description = "UEFI Reference Specification Protocol Constants and Definitions" +homepage = "https://github.com/r-efi/r-efi/wiki" +readme = "README.md" +keywords = [ + "efi", + "uefi", + "boot", + "firmware", + "specification", +] +categories = [ + "embedded", + "hardware-support", + "no-std", + "os", +] +license = "MIT OR Apache-2.0 OR LGPL-2.1-or-later" +repository = "https://github.com/r-efi/r-efi" + +[[example]] +name = "freestanding" +required-features = ["native"] + +[[example]] +name = "gop-query" +required-features = ["native"] + +[[example]] +name = "hello-world" +required-features = ["native"] + +[[example]] +name = "uefi-cross-compile" +required-features = ["native"] + +[dependencies.compiler_builtins] +version = "0.1.0" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[features] +efiapi = [] +examples = ["native"] +native = [] +rustc-dep-of-std = [ + "compiler_builtins/rustc-dep-of-std", + "core", +] diff --git a/vendor/r-efi/NEWS.md b/vendor/r-efi/NEWS.md new file mode 100644 index 000000000..5378e2d70 --- /dev/null +++ b/vendor/r-efi/NEWS.md @@ -0,0 +1,205 @@ +# r-efi - UEFI Reference Specification Protocol Constants and Definitions + +## CHANGES WITH 4.2.0: + + * Bump required compiler version to: rust-1.68 + + * New Protocols: debugport, debug-support, driver-diagnostics2, + mp-services, shell, shell-dynamic-command, + shell-parameters, udp-4, udp-6 + + * Use const-generics instead of ZSTs to represent dynamic trailing + members in C structs. + + * The `examples` feature has been renamed to `native` (a backwards + compatible feature is left in place). + + * Add support for riscv64. + + * Use the official rust `efiapi` calling convention. This was + stabilized with rust-1.68. + + Contributions from: Ayush Singh, David Rheinsberg, Rob Bradford + + - Dußlingen, 2023-03-20 + +## CHANGES WITH 4.1.0: + + * New Protocols: device-path-{from,to}-text, ip4, ip6, managed-network, + rng, service-binding, tcp4, tcp6, timestamp + + * `ImageEntryPoint` is now correctly annotated as `eficall`. + + * `Time` now derives `Default`. + + * Fix nullable function pointers to use `Option`. + + * Function prototypes now have an explicit type definition and can be + used independent of their protocol definition. + + * The new `rust-dep-of-std` feature option allows pulling in r-efi + into the rust standard library. It prepares the crate workspace to + be suitable for the standard library. It has no use outside of this. + + * Adopt the MIT license as 3rd licensing option to allow for + integration into the rust compiler and ecosystem. + + Contributions from: Ayush Singh, David Rheinsberg, Joe Richey + + - Tübingen, 2022-08-23 + +## CHANGES WITH 4.0.0: + + * Convert all enums to constants with type-aliases. This is an API + break, but it is needed for spec-compliance. With the old enums, one + couldn't encode all the possible values defined by the spec. + Especially, the vendor-reserved ranges were unable to be encoded in + a safe manner. Also see commit 401a91901e860 for a detailed + discussion. + API users likely need to convert their CamelCase enum usage to the + new UPPER_CASE constants. + + * Convert all incomplete types to empty arrays. This affects all + structures that use trailing unbound arrays. These are actually ABI + incompatible with UEFI, since rust represents raw-pointers to such + types as fat-pointers. Such arrays have now been converted to empty + arrays, which should still allow accessing the memory location and + retaining structure properties, but avoids fat-pointers. + This is an API break, so you might have to adjust your accessors of + those trailing structure members. + + * Implement `Clone` and `Copy` for most basic structures. Since these + are used as plain carriers, no higher clone/copy logic is needed. It + should be clear from the project-description, that only basic UEFI + compatibility is provided. + + * Add the console-control vendor protocol. This protocol allows + controlling console properties. It is not part of the UEFI + specification, but rather defined by the TianoCore project. + + * Add a new example showing how to use the GOP functions to query the + active graphics device. + + Contributions from: David Rheinsberg, GGRei, Hiroki Tokunaga, + Richard Wiedenhöft + + - Tübingen, 2021-06-23 + +## CHANGES WITH 3.2.0: + + * Add new protocols: DiskIo, DiskIo2, BlockIo, DriverBinding + + * Extend the Device-Path payload structure and add the HardDriveMedia + payload. + + * Add HII definitions: A new top-level module `hii` with all the basic + HII constants, as well as a handful of HII protocols (hii_database, + hii_font, hii_string) + + * Document new `-Zbuild-std` based cross-compilation, serving as + official rust alternative to cargo-xbuild. + + Contributions from: Alex James, Bret Barkelew, David Rheinsberg, + Michael Kubacki + + - Tübingen, 2020-10-23 + +## CHANGES WITH 3.1.0: + + * Add the basic networking types to `r_efi::base`. This includes MAC + and IP address types. + + * Add the EFI_SIMPLE_NETWORK_PROTOCOL definitions and all required + constants to make basic networking available. + + * Add a new uefi-cross example, which is copied from upstream rustc + sources, so we can test local modifications to it. + + Contributions from: Alex James, David Rheinsberg + + - Tübingen, 2020-09-10 + +## CHANGES WITH 3.0.0: + + * Fix a missing parameter in `BootServices::locate_device_path()`. The + prototype incorrectly had 2 arguments, while the official version + takes 3. The final `handle` argument was missing. + This is an API break in `r-efi`. It should have a limited impact, + since the function was mostly useless without a handle. + Thanks to Michael Kubacki for catching this! + + * Adjust the `device_path` parameter in a bunch of `BootServices` + calls. This used to take a `*mut c_void` parameter, since the device + path protocol was not implemented. + Since we have to bump the major version anyway, we use this to also + fix these argument-types to the correct device-path protocol type, + which has been implemented some time ago. + + Contributions from: David Rheinsberg, Michael Kubacki + + - Tübingen, 2020-04-24 + +## CHANGES WITH 2.2.0: + + * Provide `as_usize()` accessor for `efi::Status` types. This allows + accessing the raw underlying value of a status object. + + * The project moved to its new home at: github.com/r-efi/r-efi + + Contributions from: David Rheinsberg, Joe Richey + + - Tübingen, 2020-04-16 + +## CHANGES WITH 2.1.0: + + * Add the graphics-output-protocol. + + * Expose reserved fields in open structures, otherwise they cannot be + instantiated from outside the crate itself. + + Contributions from: David Herrmann, Richard Wiedenhöft, Rob Bradford + + - Tübingen, 2019-03-20 + +## CHANGES WITH 2.0.0: + + * Add a set of UEFI protocols, including simple-text-input, + file-protocol, simple-file-system, device-path, and more. + + * Fix signature of `BootServices::allocate_pages`. + + Contributions from: David Rheinsberg, Richard Wiedenhöft, Tom Gundersen + + - Tübingen, 2019-03-01 + +## CHANGES WITH 1.0.0: + + * Enhance the basic UEFI type integration with the rust ecosystem. Add + `Debug`, `Eq`, `Ord`, ... derivations, provide converters to/from the + core library, and document the internal workings. + + * Fix `Boolean` to use `newtype(u8)` to make it ABI compatible to UEFI. + This now accepts any byte value that UEFI accetps without any + conversion required. + + Contributions from: Boris-Chengbiao Zhou, David Rheinsberg, Tom + Gundersen + + - Tübingen, 2019-02-14 + +## CHANGES WITH 0.1.1: + + * Feature gate examples to make `cargo test` work on non-UEFI systems + like CI. + + Contributions from: David Herrmann + + - Tübingen, 2018-12-10 + +## CHANGES WITH 0.1.0: + + * Initial release of r-efi. + + Contributions from: David Herrmann + + - Tübingen, 2018-12-10 diff --git a/vendor/r-efi/README.md b/vendor/r-efi/README.md new file mode 100644 index 000000000..b5b8f8757 --- /dev/null +++ b/vendor/r-efi/README.md @@ -0,0 +1,99 @@ +r-efi +===== + +UEFI Reference Specification Protocol Constants and Definitions + +The r-efi project provides the protocol constants and definitions of the +UEFI Reference Specification as native rust code. The scope of this project is +limited to those protocol definitions. The protocols are not actually +implemented. As such, this project serves as base for any UEFI application that +needs to interact with UEFI, or implement (parts of) the UEFI specification. + +### Project + + * **Website**: + * **Bug Tracker**: + +### Requirements + +The requirements for this project are: + + * `rustc >= 1.68.0` + +### Build + +To build this project, run: + +```sh +cargo build +``` + +Available configuration options are: + + * **native**: This feature-selector enables compilation of modules and + examples that require native UEFI targets. Those will not + compile on foreign targets and thus are guarded by this flag. + +##### Build via: official toolchains + +Starting with rust-version 1.68, rustup distributes pre-compiled toolchains for +many UEFI targets. You can enumerate and install them via `rustup`. This +example shows how to enumerate all available targets for your stable toolchain +and then install the UEFI target for the `x86_64` architecture: + +```sh +rustup target list --toolchain=stable +rustup target add --toolchain=stable x86_64-unknown-uefi +``` + +This project can then be compiled directly for the selected target: + +```sh +cargo +stable build \ + --examples \ + --features native \ + --lib \ + --target x86_64-unknown-uefi +``` + +##### Build via: cargo/rustc nightly with -Zbuild-std + +If no pre-compiled toolchains are available for your selected target, you can +compile the project and the required parts of the standard library via the +experimental `-Zbuild-std` feature of rustc. This requires a nightly compiler: + +```sh +cargo +nightly build \ + -Zbuild-std=core,compiler_builtins,alloc \ + -Zbuild-std-features=compiler-builtins-mem \ + --examples \ + --features native \ + --lib \ + --target x86_64-unknown-uefi +``` + +##### Build via: foreign target + +The project can be built for non-UEFI targets via the standard rust toolchains. +This allows non-UEFI targets to interact with UEFI systems or otherwise host +UEFI operations. Furthermore, this allows running the foreign test-suite of +this project as long as the target supports the full standard library: + +```sh +cargo +stable build --all-targets +cargo +stable test --all-targets +``` + +Note that the `native` feature must not be enabled for foreign targets as it +will not compile on non-UEFI systems. + +### Repository: + + - **web**: + - **https**: `https://github.com/r-efi/r-efi.git` + - **ssh**: `git@github.com:r-efi/r-efi.git` + +### License: + + - **MIT** OR **Apache-2.0** OR **LGPL-2.1-or-later** + - See AUTHORS file for details. diff --git a/vendor/r-efi/examples/freestanding.rs b/vendor/r-efi/examples/freestanding.rs new file mode 100644 index 000000000..1c4e3aaf4 --- /dev/null +++ b/vendor/r-efi/examples/freestanding.rs @@ -0,0 +1,34 @@ +// Example: Freestanding +// +// This example is a plain UEFI application without any external requirements +// but `core`. It immediately returns control to the caller upon execution, +// yielding the exit code 0. +// +// The `main` function serves as entry-point. Depending on your +// target-configuration, it must be exported with a pre-configured name so the +// linker will correctly mark it as entry-point. The target configurations +// shipped with upstream rust-lang use `efi_main` as symbol name. +// +// Additionally, a panic handler is provided. This is executed by rust on +// panic. For simplicity, we simply end up in an infinite loop. For real +// applications, this method should probably call into +// `SystemTable->boot_services->exit()` to exit the UEFI application. Note, +// however, that UEFI applications are likely to run in the same address space +// as the entire firmware. Hence, halting the machine might be a viable +// alternative. All that is out-of-scope for this example, though. +// +// Note that as of rust-1.31.0, all features used here are stabilized. No +// unstable features are required, nor do we rely on nightly compilers. + +#![no_main] +#![no_std] + +#[panic_handler] +fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[export_name = "efi_main"] +pub extern "C" fn main(_h: *mut core::ffi::c_void, _st: *mut core::ffi::c_void) -> usize { + 0 +} diff --git a/vendor/r-efi/examples/gop-query.rs b/vendor/r-efi/examples/gop-query.rs new file mode 100644 index 000000000..b4ab4c370 --- /dev/null +++ b/vendor/r-efi/examples/gop-query.rs @@ -0,0 +1,188 @@ +// Example: Graphics Query +// +// This is a slightly more complex UEFI application than `hello-world`. It +// locates the graphics-output-protocol, queries its current mode and prints +// the current resolution to the UEFI console. +// +// This example should make everyone aware that UEFI programing in Rust really +// asks for helper layers. While the C/FFI/Spec API can be used directly, it +// is quite cumbersome. Especially the error handling is overly difficult. +// +// Nevertheless, this example shows how to find UEFI protocol and invoke +// their member functions. +// +// Like all the other r-efi examples, it is a standalone example. That is, no +// UTF-16 helpers are pulled in, nor any allocators or panic frameworks. For +// real world scenarios, you really should choose such helpers. + +#![no_main] +#![no_std] + +use r_efi::efi; + +#[panic_handler] +fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +fn fail(_r: efi::Status) -> ! { + panic!(); +} + +// A simple `itoa()`-ish function that takes a u32 and turns it into a UTF-16 +// string. It always prints exactly 10 characters, so leading zeroes are used +// for small numbers. +fn utoa(mut u: u32, a: &mut [u16]) { + for i in 0..10 { + a[9 - i] = 0x0030u16 + ((u % 10) as u16); + u = u / 10; + } +} + +// A simple helper that takes two integers and prints them to the UEFI console +// with a short prefix. It uses a UTF-16 buffer and fills in the numbers before +// printing the entire buffer. +fn print_xy(st: *mut efi::SystemTable, x: u32, y: u32) { + let mut s = [ + 0x0058u16, 0x0059u16, 0x003au16, // "XY:" + 0x0020u16, // " " + 0x0020u16, 0x0020u16, 0x0020u16, 0x0020u16, // " " + 0x0020u16, 0x0020u16, 0x0020u16, 0x0020u16, // " " + 0x0020u16, 0x0020u16, // " " + 0x0078u16, // "x" + 0x0020u16, 0x0020u16, 0x0020u16, 0x0020u16, // " " + 0x0020u16, 0x0020u16, 0x0020u16, 0x0020u16, // " " + 0x0020u16, 0x0020u16, // " " + 0x000au16, // "\n" + 0x0000u16, // NUL + ]; + + utoa(x, &mut s[4..14]); + utoa(y, &mut s[15..25]); + + unsafe { + let r = ((*(*st).con_out).output_string)((*st).con_out, s.as_ptr() as *mut efi::Char16); + if r.is_error() { + fail(r); + } + } +} + +// This function locates singleton UEFI protocols. Those protocols do not +// require to register listener handles, but are globally available to all +// UEFI applications. It takes a GUID of the protocol to locate and returns +// the protocol pointer on success. +fn locate_singleton( + st: *mut efi::SystemTable, + guid: *const efi::Guid, +) -> Result<*mut core::ffi::c_void, efi::Status> { + let mut interface: *mut core::ffi::c_void = core::ptr::null_mut(); + let mut handles: *mut efi::Handle = core::ptr::null_mut(); + let mut n_handles: usize = 0; + let mut r: efi::Status; + + // Use `locate_handle_buffer()` to find all handles that support the + // specified protocol. + unsafe { + if (*st).hdr.revision < efi::SYSTEM_TABLE_REVISION_1_10 { + // We use `LocateHandleBuffer`, which was introduced in 1.10. + return Err(efi::Status::UNSUPPORTED); + } + + let r = ((*(*st).boot_services).locate_handle_buffer)( + efi::BY_PROTOCOL, + guid as *mut _, + core::ptr::null_mut(), + &mut n_handles, + &mut handles, + ); + match r { + efi::Status::SUCCESS => {} + efi::Status::NOT_FOUND => return Err(r), + efi::Status::OUT_OF_RESOURCES => return Err(r), + _ => panic!(), + }; + } + + // Now that we have all handles with the specified protocol, query it for + // the protocol interface. We loop here, even though every item should + // succeed. Lets be on the safe side. + // Secondly, we use `handle_protocol()` here, but really should be using + // `open_protocol()`. But for singleton protocols, this does not matter, + // so lets use the simple path for now. + unsafe { + r = efi::Status::NOT_FOUND; + for i in 0..n_handles { + r = ((*(*st).boot_services).handle_protocol)( + *handles.offset(core::convert::TryFrom::::try_from(i).unwrap()), + guid as *mut _, + &mut interface, + ); + match r { + efi::Status::SUCCESS => break, + efi::Status::UNSUPPORTED => continue, + _ => panic!(), + }; + } + } + + // Free the allocated buffer memory of `handles`. This was allocated on the + // pool by `locate_handle_buffer()`. + unsafe { + let r = ((*(*st).boot_services).free_pool)(handles as *mut core::ffi::c_void); + assert!(!r.is_error()); + } + + // In case we found nothing, return `NOT_FOUND`, otherwise return the + // interface identifier. + match r { + efi::Status::SUCCESS => Ok(interface), + _ => Err(efi::Status::NOT_FOUND), + } +} + +// A simple helper that queries the current mode of the GraphicsOutputProtocol +// and returns the x and y dimensions on success. +fn query_gop( + gop: *mut efi::protocols::graphics_output::Protocol, +) -> Result<(u32, u32), efi::Status> { + let mut info: *mut efi::protocols::graphics_output::ModeInformation = core::ptr::null_mut(); + let mut z_info: usize = 0; + + unsafe { + // We could just look at `gop->mode->info`, but lets query the mode + // instead to show how to query other modes than the active one. + let r = ((*gop).query_mode)(gop, (*(*gop).mode).mode, &mut z_info, &mut info); + match r { + efi::Status::SUCCESS => {} + efi::Status::DEVICE_ERROR => return Err(r), + _ => panic!(), + }; + if z_info < core::mem::size_of_val(&*info) { + return Err(efi::Status::UNSUPPORTED); + } + + Ok(((*info).horizontal_resolution, (*info).vertical_resolution)) + } +} + +// This is the UEFI application entrypoint. We use it to locate the GOP +// pointer, query the current mode, and then print it to the system console. +#[export_name = "efi_main"] +pub extern "C" fn main(_h: efi::Handle, st: *mut efi::SystemTable) -> efi::Status { + let r = locate_singleton(st, &efi::protocols::graphics_output::PROTOCOL_GUID); + let gop = match r { + Ok(v) => v, + Err(r) => fail(r), + }; + + let r = query_gop(gop as _); + let v = match r { + Ok(v) => v, + Err(r) => fail(r), + }; + + print_xy(st, v.0, v.1); + + efi::Status::SUCCESS +} diff --git a/vendor/r-efi/examples/hello-world.rs b/vendor/r-efi/examples/hello-world.rs new file mode 100644 index 000000000..25b5243ac --- /dev/null +++ b/vendor/r-efi/examples/hello-world.rs @@ -0,0 +1,55 @@ +// Example: Hello World! +// +// This is an example UEFI application that prints "Hello World!", then waits +// for key input before it exits. It serves as base example how to write UEFI +// applications without any helper modules other than the UEFI protocol +// definitions. +// +// This example builds upon the `freestanding.rs` example, using the same setup +// and rust integration. See there for details on the panic-handler and entry +// point configuration. +// +// Note that UEFI uses UTF-16 strings. Since rust literals are UTF-8, we have +// to use an open-coded, zero-terminated, UTF-16 array as argument to +// `output_string()`. Similarly to the panic handler, real applications should +// rather use UTF-16 modules. + +#![no_main] +#![no_std] + +use r_efi::efi; + +#[panic_handler] +fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[export_name = "efi_main"] +pub extern "C" fn main(_h: efi::Handle, st: *mut efi::SystemTable) -> efi::Status { + let s = [ + 0x0048u16, 0x0065u16, 0x006cu16, 0x006cu16, 0x006fu16, // "Hello" + 0x0020u16, // " " + 0x0057u16, 0x006fu16, 0x0072u16, 0x006cu16, 0x0064u16, // "World" + 0x0021u16, // "!" + 0x000au16, // "\n" + 0x0000u16, // NUL + ]; + + // Print "Hello World!". + let r = + unsafe { ((*(*st).con_out).output_string)((*st).con_out, s.as_ptr() as *mut efi::Char16) }; + if r.is_error() { + return r; + } + + // Wait for key input, by waiting on the `wait_for_key` event hook. + let r = unsafe { + let mut x: usize = 0; + ((*(*st).boot_services).wait_for_event)(1, &mut (*(*st).con_in).wait_for_key, &mut x) + }; + if r.is_error() { + return r; + } + + efi::Status::SUCCESS +} diff --git a/vendor/r-efi/examples/uefi-cross-compile.rs b/vendor/r-efi/examples/uefi-cross-compile.rs new file mode 100644 index 000000000..f99870a21 --- /dev/null +++ b/vendor/r-efi/examples/uefi-cross-compile.rs @@ -0,0 +1,41 @@ +// Bare UEFI Compilation +// +// This is a copy of a cross-compile test from the upstream rust repository. It +// is used to verify cross-compilation of UEFI targets works. It is included +// verbatim here to make sure we can run tests against it and get notifications +// when it breaks. + +// ----------------------------------------------------------------------------- +// COPY FROM `rust-lang/rust/src/test/codegen/uefi-cross-compile.rs` +// ----------------------------------------------------------------------------- + +// Checks whether UEFI targets cross-compile successfully. +// +// This test contains a simple UEFI program that simply exits with return code +// 0. It can be easily run from the UEFI shell (but any other UEFI environment +// works as well). This program is not run as part of the test. The test merely +// verifies the cross-compilation does not fail and an entry-point is emitted. +// +// The imported definitions from the UEFI specification are intentionally left +// incomplete. Only the bits that are actually used by this test are defined. + +// min-llvm-version 9.0 + +// compile-flags: --target x86_64-unknown-uefi + +#![feature(lang_items, no_core)] +#![no_core] +#![no_main] + +#[lang = "sized"] +pub trait Sized {} +#[lang = "freeze"] +pub trait Freeze {} +#[lang = "copy"] +pub trait Copy {} + +// CHECK: define win64cc i64 @efi_main{{.*}} +#[export_name = "efi_main"] +pub extern "efiapi" fn main(_h: *mut usize, _st: *mut usize) -> usize { + return 0; +} diff --git a/vendor/r-efi/src/base.rs b/vendor/r-efi/src/base.rs new file mode 100644 index 000000000..86beaced5 --- /dev/null +++ b/vendor/r-efi/src/base.rs @@ -0,0 +1,867 @@ +//! UEFI Base Environment +//! +//! This module defines the base environment for UEFI development. It provides types and macros as +//! declared in the UEFI specification, as well as de-facto standard additions provided by the +//! reference implementation by Intel. +//! +//! # Target Configuration +//! +//! Wherever possible, native rust types are used to represent their UEFI counter-parts. However, +//! this means the ABI depends on the implementation of said rust types. Hence, native rust types +//! are only used where rust supports a stable ABI of said types, and their ABI matches the ABI +//! defined by the UEFI specification. +//! +//! Nevertheless, even if the ABI of a specific type is marked stable, this does not imply that it +//! is the same across architectures. For instance, rust's `u64` type has the same binary +//! representation as the `UINT64` type in UEFI. But this does not imply that it has the same +//! binary representation on `x86_64` and on `ppc64be`. As a result of this, the compilation of +//! this module is tied to the target-configuration you passed to the rust compiler. Wherever +//! possible and reasonable, any architecture differences are abstracted, though. This means that +//! in most cases you can use this module even though your target-configuration might not match +//! the native UEFI target-configuration. +//! +//! The recommend way to compile your code, is to use the native target-configuration for UEFI. +//! These configurations are not necessarily included in the upstream rust compiler. Hence, you +//! might have to craft one yourself. For all systems that we can test on, we make sure to push +//! the target configuration into upstream rust-lang. +//! +//! However, there are situations where you want to access UEFI data from a non-native host. For +//! instance, a UEFI boot loader might store data in boot variables, formatted according to types +//! declared in the UEFI specification. An OS booted thereafter might want to access these +//! variables, but it might be compiled with a different target-configuration than the UEFI +//! environment that it was booted from. A similar situation occurs when you call UEFI runtime +//! functions from your OS. In all those cases, you should very likely be able to use this module +//! to interact with UEFI as well. This is, because most bits of the target-configuration of UEFI +//! and your OS very likely match. In fact, to figure out whether this is safe, you need to make +//! sure that the rust ABI would match in both target-configurations. If it is, all other details +//! are handled within this module just fine. +//! +//! In case of doubt, contact us! +//! +//! # Core Primitives +//! +//! Several of the UEFI primitives are represented by native Rust. These have no type aliases or +//! other definitions here, but you are recommended to use native rust directly. These include: +//! +//! * `NULL`, `void *`: Void pointers have a native rust implementation in +//! [`c_void`](core::ffi::c_void). `NULL` is represented through +//! [`null`](core::ptr::null) and [`is_null()`](core::ptr) for +//! all pointer types. +//! * `uint8_t`..`uint64_t`, +//! `int8_t`..`int64_t`: Fixed-size integers are represented by their native rust equivalents +//! (`u8`..`u64`, `i8`..`i64`). +//! +//! * `UINTN`, `INTN`: Native-sized (or instruction-width sized) integers are represented by +//! their native rust equivalents (`usize`, `isize`). +//! +//! # UEFI Details +//! +//! The UEFI Specification describes its target environments in detail. Each supported +//! architecture has a separate section with details on calling conventions, CPU setup, and more. +//! You are highly recommended to conduct the UEFI Specification for details on the programming +//! environment. Following a summary of key parts relevant to rust developers: +//! +//! * Similar to rust, integers are either fixed-size, or native size. This maps nicely to the +//! native rust types. The common `long`, `int`, `short` types known from ISO-C are not used. +//! Whenever you refer to memory (either pointing to it, or remember the size of a memory +//! block), the native size integers should be your tool of choice. +//! +//! * Even though the CPU might run in any endianness, all stored data is little-endian. That +//! means, if you encounter integers split into byte-arrays (e.g., +//! `CEfiDevicePathProtocol.length`), you must assume it is little-endian encoded. But if you +//! encounter native integers, you must assume they are encoded in native endianness. +//! For now the UEFI specification only defines little-endian architectures, hence this did not +//! pop up as actual issue. Future extensions might change this, though. +//! +//! * The Microsoft calling-convention is used. That is, all external calls to UEFI functions +//! follow a calling convention that is very similar to that used on Microsoft Windows. All +//! such ABI functions must be marked with the right calling-convention. The UEFI Specification +//! defines some additional common rules for all its APIs, though. You will most likely not see +//! any of these mentioned in the individual API documentions. So here is a short reminder: +//! +//! * Pointers must reference physical-memory locations (no I/O mappings, no +//! virtual addresses, etc.). Once ExitBootServices() was called, and the +//! virtual address mapping was set, you must provide virtual-memory +//! locations instead. +//! * Pointers must be correctly aligned. +//! * NULL is disallowed, unless explicitly mentioned otherwise. +//! * Data referenced by pointers is undefined on error-return from a +//! function. +//! * You must not pass data larger than native-size (sizeof(CEfiUSize)) on +//! the stack. You must pass them by reference. +//! +//! * Stack size is at least 128KiB and 16-byte aligned. All stack space might be marked +//! non-executable! Once ExitBootServices() was called, you must guarantee at least 4KiB of +//! stack space, 16-byte aligned for all runtime services you call. +//! Details might differ depending on architectures. But the numbers here should serve as +//! ball-park figures. + +// Target Architecture +// +// The UEFI Specification explicitly lists all supported target architectures. While external +// implementors are free to port UEFI to other targets, we need information on the target +// architecture to successfully compile for it. This includes calling-conventions, register +// layouts, endianness, and more. Most of these details are hidden in the rust-target-declaration. +// However, some details are still left to the actual rust code. +// +// This initial check just makes sure the compilation is halted with a suitable error message if +// the target architecture is not supported. +// +// We try to minimize conditional compilations as much as possible. A simple search for +// `target_arch` should reveal all uses throughout the code-base. If you add your target to this +// error-check, you must adjust all other uses as well. +// +// Similarly, UEFI only defines configurations for little-endian architectures so far. Several +// bits of the specification are thus unclear how they would be applied on big-endian systems. We +// therefore mark it as unsupported. If you override this, you are on your own. +#[cfg(not(any( + target_arch = "arm", + target_arch = "aarch64", + target_arch = "riscv64", + target_arch = "x86", + target_arch = "x86_64" +)))] +compile_error!("The target architecture is not supported."); +#[cfg(not(target_endian = "little"))] +compile_error!("The target endianness is not supported."); + +// eficall_abi!() +// +// This macro is the architecture-dependent implementation of eficall!(). See the documentation of +// the eficall!() macro for a description. Nowadays, this simply maps to `extern "efiapi"`, since +// this has been stabilized with rust-1.68. + +#[macro_export] +#[doc(hidden)] +macro_rules! eficall_abi { + (($($prefix:tt)*),($($suffix:tt)*)) => { $($prefix)* extern "efiapi" $($suffix)* }; +} + +/// Annotate function with UEFI calling convention +/// +/// Since rust-1.68 you can use `extern "efiapi"` as calling-convention to achieve the same +/// behavior as this macro. This macro is kept for backwards-compatibility only, but will nowadays +/// map to `extern "efiapi"`. +/// +/// This macro takes a function-declaration as argument and produces the same function-declaration +/// but annotated with the correct calling convention. Since the default `extern "C"` annotation +/// depends on your compiler defaults, we cannot use it. Instead, this macro selects the default +/// for your target platform. +/// +/// Ideally, the macro would expand to `extern ""` so you would be able to write: +/// +/// ```ignore +/// // THIS DOES NOT WORK! +/// pub fn eficall!{} foobar() { +/// // ... +/// } +/// ``` +/// +/// However, macros are evaluated too late for this to work. Instead, the entire construct must be +/// wrapped in a macro, which then expands to the same construct but with `extern ""` +/// inserted at the correct place: +/// +/// ``` +/// use r_efi::{eficall, eficall_abi}; +/// +/// eficall!{pub fn foobar() { +/// // ... +/// }} +/// +/// type FooBar = eficall!{fn(u8) -> (u8)}; +/// ``` +/// +/// The `eficall!{}` macro takes either a function-type or function-definition as argument. It +/// inserts `extern ""` after the function qualifiers, but before the `fn` keyword. +/// +/// # Internals +/// +/// The `eficall!{}` macro tries to parse the function header so it can insert `extern ""` at +/// the right place. If, for whatever reason, this does not work with a particular syntax, you can +/// use the internal `eficall_abi!{}` macro. This macro takes two token-streams as input and +/// evaluates to the concatenation of both token-streams, but separated by the selected ABI. +/// +/// For instance, the following 3 type definitions are equivalent, assuming the selected ABI +/// is "C": +/// +/// ``` +/// use r_efi::{eficall, eficall_abi}; +/// +/// type FooBar1 = unsafe extern "C" fn(u8) -> (u8); +/// type FooBar2 = eficall!{unsafe fn(u8) -> (u8)}; +/// type FooBar3 = eficall_abi!{(unsafe), (fn(u8) -> (u8))}; +/// ``` +/// +/// # Calling Conventions +/// +/// The UEFI specification defines the calling convention for each platform individually. It +/// usually refers to other standards for details, but adds some restrictions on top. As of this +/// writing, it mentions: +/// +/// * aarch32 / arm: The `aapcs` calling-convention is used. It is native to aarch32 and described +/// in a document called +/// "Procedure Call Standard for the ARM Architecture". It is openly distributed +/// by ARM and widely known under the keyword `aapcs`. +/// * aarch64: The `aapcs64` calling-convention is used. It is native to aarch64 and described in +/// a document called +/// "Procedure Call Standard for the ARM 64-bit Architecture (AArch64)". It is openly +/// distributed by ARM and widely known under the keyword `aapcs64`. +/// * ia-64: The "P64 C Calling Convention" as described in the +/// "Itanium Software Conventions and Runtime Architecture Guide". It is also +/// standardized in the "Intel Itanium SAL Specification". +/// * RISC-V: The "Standard RISC-V C Calling Convention" is used. The UEFI specification +/// describes it in detail, but also refers to the official RISC-V resources for +/// detailed information. +/// * x86 / ia-32: The `cdecl` C calling convention is used. Originated in the C Language and +/// originally tightly coupled to C specifics. Unclear whether a formal +/// specification exists (does anyone know?). Most compilers support it under the +/// `cdecl` keyword, and in nearly all situations it is the default on x86. +/// * x86_64 / amd64 / x64: The `win64` calling-convention is used. It is similar to the `sysv64` +/// convention that is used on most non-windows x86_64 systems, but not +/// exactly the same. Microsoft provides open documentation on it. See +/// MSDN "x64 Software Conventions -> Calling Conventions". +/// The UEFI Specification does not directly refer to `win64`, but +/// contains a full specification of the calling convention itself. +/// +/// Note that in most cases the UEFI Specification adds several more restrictions on top of the +/// common calling-conventions. These restrictions usually do not affect how the compiler will lay +/// out the function calls. Instead, it usually only restricts the set of APIs that are allowed in +/// UEFI. Therefore, most compilers already support the calling conventions used on UEFI. +/// +/// # Variadics +/// +/// For some reason, the rust compiler allows variadics only in combination with the `"C"` calling +/// convention, even if the selected calling-convention matches what `"C"` would select on the +/// target platform. Hence, you will very likely be unable to use variadics with this macro. +/// Luckily, all of the UEFI functions that use variadics are wrappers around more low-level +/// accessors, so they are not necessarily required. +#[macro_export] +macro_rules! eficall { + // Muncher + // + // The `@munch()` rules are internal and should not be invoked directly. We walk through the + // input, moving one token after the other from the suffix into the prefix until we find the + // position where to insert `extern ""`. This muncher never drops any tokens, hence we + // can safely match invalid statements just fine, as the compiler will later print proper + // diagnostics when parsing the macro output. + // Once done, we invoke the `eficall_abi!{}` macro, which simply inserts the correct ABI. + (@munch(($($prefix:tt)*),(pub $($suffix:tt)*))) => { eficall!{@munch(($($prefix)* pub),($($suffix)*))} }; + (@munch(($($prefix:tt)*),(unsafe $($suffix:tt)*))) => { eficall!{@munch(($($prefix)* unsafe),($($suffix)*))} }; + (@munch(($($prefix:tt)*),($($suffix:tt)*))) => { eficall_abi!{($($prefix)*),($($suffix)*)} }; + + // Entry Point + // + // This captures the entire argument and invokes its own TT-muncher, but splits the input into + // prefix and suffix, so the TT-muncher can walk through it. Note that initially everything is + // in the suffix and the prefix is empty. + ($($arg:tt)*) => { eficall!{@munch((),($($arg)*))} }; +} + +/// Boolean Type +/// +/// This boolean type works very similar to the rust primitive type of [`bool`]. However, the rust +/// primitive type has no stable ABI, hence we provide this type to represent booleans on the FFI +/// interface. +/// +/// UEFI defines booleans to be 1-byte integers, which can only have the values of `0` or `1`. +/// However, in practice anything non-zero is considered `true` by nearly all UEFI systems. Hence, +/// this type implements a boolean over `u8` and maps `0` to `false`, everything else to `true`. +/// +/// The binary representation of this type is ABI. That is, you are allowed to transmute from and +/// to `u8`. Furthermore, this type never modifies its binary representation. If it was +/// initialized as, or transmuted from, a specific integer value, this value will be retained. +/// However, on the rust side you will never see the integer value. It instead behaves truly as a +/// boolean. If you need access to the integer value, you have to transmute it back to `u8`. +#[repr(C)] +#[derive(Clone, Copy, Debug, Eq)] +pub struct Boolean(u8); + +/// Single-byte Character Type +/// +/// The `Char8` type represents single-byte characters. UEFI defines them to be ASCII compatible, +/// using the ISO-Latin-1 character set. +pub type Char8 = u8; + +/// Dual-byte Character Type +/// +/// The `Char16` type represents dual-byte characters. UEFI defines them to be UCS-2 encoded. +pub type Char16 = u16; + +/// Status Codes +/// +/// UEFI uses the `Status` type to represent all kinds of status codes. This includes return codes +/// from functions, but also complex state of different devices and drivers. It is a simple +/// `usize`, but wrapped in a rust-type to allow us to implement helpers on this type. Depending +/// on the context, different state is stored in it. Note that it is always binary compatible to a +/// usize! +#[repr(C)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Status(usize); + +/// Object Handles +/// +/// Handles represent access to an opaque object. Handles are untyped by default, but get a +/// meaning when you combine them with an interface. Internally, they are simple void pointers. It +/// is the UEFI driver model that applies meaning to them. +pub type Handle = *mut core::ffi::c_void; + +/// Event Objects +/// +/// Event objects represent hooks into the main-loop of a UEFI environment. They allow to register +/// callbacks, to be invoked when a specific event happens. In most cases you use events to +/// register timer-based callbacks, as well as chaining events together. Internally, they are +/// simple void pointers. It is the UEFI task management that applies meaning to them. +pub type Event = *mut core::ffi::c_void; + +/// Logical Block Addresses +/// +/// The LBA type is used to denote logical block addresses of block devices. It is a simple 64-bit +/// integer, that is used to denote addresses when working with block devices. +pub type Lba = u64; + +/// Thread Priority Levels +/// +/// The process model of UEFI systems is highly simplified. Priority levels are used to order +/// execution of pending tasks. The TPL type denotes a priority level of a specific task. The +/// higher the number, the higher the priority. It is a simple integer type, but its range is +/// usually highly restricted. The UEFI task management provides constants and accessors for TPLs. +pub type Tpl = usize; + +/// Physical Memory Address +/// +/// A simple 64bit integer containing a physical memory address. +pub type PhysicalAddress = u64; + +/// Virtual Memory Address +/// +/// A simple 64bit integer containing a virtual memory address. +pub type VirtualAddress = u64; + +/// Application Entry Point +/// +/// This type defines the entry-point of UEFI applications. It is ABI and cannot be changed. +/// Whenever you load UEFI images, the entry-point is called with this signature. +/// +/// In most cases the UEFI image (or application) is unloaded when control returns from the entry +/// point. In case of UEFI drivers, they can request to stay loaded until an explicit unload. +/// +/// The system table is provided as mutable pointer. This is, because there is no guarantee that +/// timer interrupts do not modify the table. Furthermore, exiting boot services causes several +/// modifications on that table. And lastly, the system table lives longer than the function +/// invocation, if invoked as an UEFI driver. +/// In most cases it is perfectly fine to cast the pointer to a real rust reference. However, this +/// should be an explicit decision by the caller. +pub type ImageEntryPoint = eficall! {fn(Handle, *mut crate::system::SystemTable) -> Status}; + +/// Globally Unique Identifiers +/// +/// The `Guid` type represents globally unique identifiers as defined by RFC-4122 (i.e., only the +/// `10x` variant is used), with the caveat that LE is used instead of BE. The type must be 64-bit +/// aligned. +/// +/// Note that only the binary representation of Guids is stable. You are highly recommended to +/// interpret Guids as 128bit integers. +/// +/// UEFI uses the Microsoft-style Guid format. Hence, a lot of documentation and code refers to +/// these Guids. If you thusly cannot treat Guids as 128-bit integers, this Guid type allows you +/// to access the individual fields of the Microsoft-style Guid. A reminder of the Guid encoding: +/// +/// ```text +/// 0 1 2 3 +/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +/// | time_low | +/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +/// | time_mid | time_hi_and_version | +/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +/// |clk_seq_hi_res | clk_seq_low | node (0-1) | +/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +/// | node (2-5) | +/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +/// ``` +/// +/// The individual fields are encoded as little-endian. Accessors are provided for the Guid +/// structure allowing access to these fields in native endian byte order. +#[repr(C, align(8))] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Guid { + time_low: [u8; 4], + time_mid: [u8; 2], + time_hi_and_version: [u8; 2], + clk_seq_hi_res: u8, + clk_seq_low: u8, + node: [u8; 6], +} + +/// Network MAC Address +/// +/// This type encapsulates a single networking media access control address +/// (MAC). It is a simple 32 bytes buffer with no special alignment. Note that +/// no comparison function are defined by default, since trailing bytes of the +/// address might be random. +/// +/// The interpretation of the content differs depending on the protocol it is +/// used with. See each documentation for details. In most cases this contains +/// an Ethernet address. +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct MacAddress { + pub addr: [u8; 32], +} + +/// IPv4 Address +/// +/// Binary representation of an IPv4 address. It is encoded in network byte +/// order (i.e., big endian). Note that no special alignment restrictions are +/// defined by the standard specification. +#[repr(C)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)] +pub struct Ipv4Address { + pub addr: [u8; 4], +} + +/// IPv6 Address +/// +/// Binary representation of an IPv6 address, encoded in network byte order +/// (i.e., big endian). Similar to the IPv4 address, no special alignment +/// restrictions are defined by the standard specification. +#[repr(C)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Ipv6Address { + pub addr: [u8; 16], +} + +/// IP Address +/// +/// A union type over the different IP addresses available. Alignment is always +/// fixed to 4-bytes. Note that trailing bytes might be random, so no +/// comparison functions are derived. +#[repr(C, align(4))] +#[derive(Clone, Copy)] +pub union IpAddress { + pub addr: [u32; 4], + pub v4: Ipv4Address, + pub v6: Ipv6Address, +} + +impl Boolean { + /// Literal False + /// + /// This constant represents the `false` value of the `Boolean` type. + pub const FALSE: Boolean = Boolean(0u8); + + /// Literal True + /// + /// This constant represents the `true` value of the `Boolean` type. + pub const TRUE: Boolean = Boolean(1u8); +} + +impl From for Boolean { + fn from(v: u8) -> Self { + Boolean(v) + } +} + +impl From for Boolean { + fn from(v: bool) -> Self { + match v { + false => Boolean::FALSE, + true => Boolean::TRUE, + } + } +} + +impl Default for Boolean { + fn default() -> Self { + Self::FALSE + } +} + +impl From for bool { + fn from(v: Boolean) -> Self { + match v.0 { + 0 => false, + _ => true, + } + } +} + +impl PartialEq for Boolean { + fn eq(&self, other: &Boolean) -> bool { + >::from(*self) == (*other).into() + } +} + +impl PartialEq for Boolean { + fn eq(&self, other: &bool) -> bool { + *other == (*self).into() + } +} + +impl Status { + const WIDTH: usize = 8usize * core::mem::size_of::(); + const MASK: usize = 0xc0 << (Status::WIDTH - 8); + const ERROR_MASK: usize = 0x80 << (Status::WIDTH - 8); + const WARNING_MASK: usize = 0x00 << (Status::WIDTH - 8); + + /// Success Code + /// + /// This code represents a successfull function invocation. Its value is guaranteed to be 0. + /// However, note that warnings are considered success as well, so this is not the only code + /// that can be returned by UEFI functions on success. However, in nearly all situations + /// warnings are not allowed, so the effective result will be SUCCESS. + pub const SUCCESS: Status = Status::from_usize(0); + + // List of predefined error codes + pub const LOAD_ERROR: Status = Status::from_usize(1 | Status::ERROR_MASK); + pub const INVALID_PARAMETER: Status = Status::from_usize(2 | Status::ERROR_MASK); + pub const UNSUPPORTED: Status = Status::from_usize(3 | Status::ERROR_MASK); + pub const BAD_BUFFER_SIZE: Status = Status::from_usize(4 | Status::ERROR_MASK); + pub const BUFFER_TOO_SMALL: Status = Status::from_usize(5 | Status::ERROR_MASK); + pub const NOT_READY: Status = Status::from_usize(6 | Status::ERROR_MASK); + pub const DEVICE_ERROR: Status = Status::from_usize(7 | Status::ERROR_MASK); + pub const WRITE_PROTECTED: Status = Status::from_usize(8 | Status::ERROR_MASK); + pub const OUT_OF_RESOURCES: Status = Status::from_usize(9 | Status::ERROR_MASK); + pub const VOLUME_CORRUPTED: Status = Status::from_usize(10 | Status::ERROR_MASK); + pub const VOLUME_FULL: Status = Status::from_usize(11 | Status::ERROR_MASK); + pub const NO_MEDIA: Status = Status::from_usize(12 | Status::ERROR_MASK); + pub const MEDIA_CHANGED: Status = Status::from_usize(13 | Status::ERROR_MASK); + pub const NOT_FOUND: Status = Status::from_usize(14 | Status::ERROR_MASK); + pub const ACCESS_DENIED: Status = Status::from_usize(15 | Status::ERROR_MASK); + pub const NO_RESPONSE: Status = Status::from_usize(16 | Status::ERROR_MASK); + pub const NO_MAPPING: Status = Status::from_usize(17 | Status::ERROR_MASK); + pub const TIMEOUT: Status = Status::from_usize(18 | Status::ERROR_MASK); + pub const NOT_STARTED: Status = Status::from_usize(19 | Status::ERROR_MASK); + pub const ALREADY_STARTED: Status = Status::from_usize(20 | Status::ERROR_MASK); + pub const ABORTED: Status = Status::from_usize(21 | Status::ERROR_MASK); + pub const ICMP_ERROR: Status = Status::from_usize(22 | Status::ERROR_MASK); + pub const TFTP_ERROR: Status = Status::from_usize(23 | Status::ERROR_MASK); + pub const PROTOCOL_ERROR: Status = Status::from_usize(24 | Status::ERROR_MASK); + pub const INCOMPATIBLE_VERSION: Status = Status::from_usize(25 | Status::ERROR_MASK); + pub const SECURITY_VIOLATION: Status = Status::from_usize(26 | Status::ERROR_MASK); + pub const CRC_ERROR: Status = Status::from_usize(27 | Status::ERROR_MASK); + pub const END_OF_MEDIA: Status = Status::from_usize(28 | Status::ERROR_MASK); + pub const END_OF_FILE: Status = Status::from_usize(31 | Status::ERROR_MASK); + pub const INVALID_LANGUAGE: Status = Status::from_usize(32 | Status::ERROR_MASK); + pub const COMPROMISED_DATA: Status = Status::from_usize(33 | Status::ERROR_MASK); + pub const IP_ADDRESS_CONFLICT: Status = Status::from_usize(34 | Status::ERROR_MASK); + pub const HTTP_ERROR: Status = Status::from_usize(35 | Status::ERROR_MASK); + + // List of error codes from protocols + // UDP4 + pub const NETWORK_UNREACHABLE: Status = Status::from_usize(100 | Status::ERROR_MASK); + pub const HOST_UNREACHABLE: Status = Status::from_usize(101 | Status::ERROR_MASK); + pub const PROTOCOL_UNREACHABLE: Status = Status::from_usize(102 | Status::ERROR_MASK); + pub const PORT_UNREACHABLE: Status = Status::from_usize(103 | Status::ERROR_MASK); + // TCP4 + pub const CONNECTION_FIN: Status = Status::from_usize(104 | Status::ERROR_MASK); + pub const CONNECTION_RESET: Status = Status::from_usize(105 | Status::ERROR_MASK); + pub const CONNECTION_REFUSED: Status = Status::from_usize(106 | Status::ERROR_MASK); + + // List of predefined warning codes + pub const WARN_UNKNOWN_GLYPH: Status = Status::from_usize(1 | Status::WARNING_MASK); + pub const WARN_DELETE_FAILURE: Status = Status::from_usize(2 | Status::WARNING_MASK); + pub const WARN_WRITE_FAILURE: Status = Status::from_usize(3 | Status::WARNING_MASK); + pub const WARN_BUFFER_TOO_SMALL: Status = Status::from_usize(4 | Status::WARNING_MASK); + pub const WARN_STALE_DATA: Status = Status::from_usize(5 | Status::WARNING_MASK); + pub const WARN_FILE_SYSTEM: Status = Status::from_usize(6 | Status::WARNING_MASK); + pub const WARN_RESET_REQUIRED: Status = Status::from_usize(7 | Status::WARNING_MASK); + + /// Create Status Code from Integer + /// + /// This takes the literal value of a status code and turns it into a `Status` object. Note + /// that we want it as `const fn` so we cannot use `core::convert::From`. + pub const fn from_usize(v: usize) -> Status { + Status(v) + } + + /// Return Underlying Integer Representation + /// + /// This takes the `Status` object and returns the underlying integer representation as + /// defined by the UEFI specification. + pub const fn as_usize(&self) -> usize { + self.0 + } + + fn value(&self) -> usize { + self.0 + } + + fn mask(&self) -> usize { + self.value() & Status::MASK + } + + /// Check whether this is an error + /// + /// This returns true if the given status code is considered an error. Errors mean the + /// operation did not succeed, nor produce any valuable output. Output parameters must be + /// considered invalid if an error was returned. That is, its content is not well defined. + pub fn is_error(&self) -> bool { + self.mask() == Status::ERROR_MASK + } + + /// Check whether this is a warning + /// + /// This returns true if the given status code is considered a warning. Warnings are to be + /// treated as success, but might indicate data loss or other device errors. However, if an + /// operation returns with a warning code, it must be considered successfull, and the output + /// parameters are valid. + pub fn is_warning(&self) -> bool { + self.value() != 0 && self.mask() == Status::WARNING_MASK + } +} + +impl From for Result { + fn from(status: Status) -> Self { + if status.is_error() { + Err(status) + } else { + Ok(status) + } + } +} + +impl Guid { + const fn u32_to_bytes_le(num: u32) -> [u8; 4] { + [ + num as u8, + (num >> 8) as u8, + (num >> 16) as u8, + (num >> 24) as u8, + ] + } + + const fn u32_from_bytes_le(bytes: &[u8; 4]) -> u32 { + (bytes[0] as u32) + | ((bytes[1] as u32) << 8) + | ((bytes[2] as u32) << 16) + | ((bytes[3] as u32) << 24) + } + + const fn u16_to_bytes_le(num: u16) -> [u8; 2] { + [num as u8, (num >> 8) as u8] + } + + const fn u16_from_bytes_le(bytes: &[u8; 2]) -> u16 { + (bytes[0] as u16) | ((bytes[1] as u16) << 8) + } + + /// Initialize a Guid from its individual fields + /// + /// This function initializes a Guid object given the individual fields as specified in the + /// UEFI specification. That is, if you simply copy the literals from the specification into + /// your code, this function will correctly initialize the Guid object. + /// + /// In other words, this takes the individual fields in native endian and converts them to the + /// correct endianness for a UEFI Guid. + pub const fn from_fields( + time_low: u32, + time_mid: u16, + time_hi_and_version: u16, + clk_seq_hi_res: u8, + clk_seq_low: u8, + node: &[u8; 6], + ) -> Guid { + Guid { + time_low: Self::u32_to_bytes_le(time_low), + time_mid: Self::u16_to_bytes_le(time_mid), + time_hi_and_version: Self::u16_to_bytes_le(time_hi_and_version), + clk_seq_hi_res: clk_seq_hi_res, + clk_seq_low: clk_seq_low, + node: *node, + } + } + + /// Access a Guid as individual fields + /// + /// This decomposes a Guid back into the individual fields as given in the specification. The + /// individual fields are returned in native-endianness. + pub const fn as_fields(&self) -> (u32, u16, u16, u8, u8, &[u8; 6]) { + ( + Self::u32_from_bytes_le(&self.time_low), + Self::u16_from_bytes_le(&self.time_mid), + Self::u16_from_bytes_le(&self.time_hi_and_version), + self.clk_seq_hi_res, + self.clk_seq_low, + &self.node, + ) + } + + /// Access a Guid as raw byte array + /// + /// This provides access to a Guid through a byte array. It is a simple re-interpretation of + /// the Guid value as a 128-bit byte array. No conversion is performed. This is a simple cast. + pub fn as_bytes(&self) -> &[u8; 16] { + unsafe { core::mem::transmute::<&Guid, &[u8; 16]>(self) } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::mem::{align_of, size_of}; + + // Verify Type Size and Alignemnt + // + // Since UEFI defines explicitly the ABI of their types, we can verify that our implementation + // is correct by checking the size and alignment of the ABI types matches what the spec + // mandates. + #[test] + fn type_size_and_alignment() { + // + // Booleans + // + + assert_eq!(size_of::(), 1); + assert_eq!(align_of::(), 1); + + // + // Char8 / Char16 + // + + assert_eq!(size_of::(), 1); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 2); + assert_eq!(align_of::(), 2); + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + // + // Status + // + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + // + // Handles / Events + // + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + assert_eq!(size_of::(), size_of::<*mut ()>()); + assert_eq!(align_of::(), align_of::<*mut ()>()); + assert_eq!(size_of::(), size_of::<*mut ()>()); + assert_eq!(align_of::(), align_of::<*mut ()>()); + + // + // Lba / Tpl + // + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + // + // PhysicalAddress / VirtualAddress + // + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + // + // ImageEntryPoint + // + + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + + // + // Guid + // + + assert_eq!(size_of::(), 16); + assert_eq!(align_of::(), 8); + + // + // Networking Types + // + + assert_eq!(size_of::(), 32); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 4); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 16); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 16); + assert_eq!(align_of::(), 4); + } + + #[test] + fn eficall() { + // + // Make sure the eficall!{} macro can deal with all kinds of function callbacks. + // + + let _: eficall! {fn()}; + let _: eficall! {unsafe fn()}; + let _: eficall! {fn(i32)}; + let _: eficall! {fn(i32) -> i32}; + let _: eficall! {fn(i32, i32) -> (i32, i32)}; + + eficall! {fn _unused00() {}} + eficall! {unsafe fn _unused01() {}} + eficall! {pub unsafe fn _unused02() {}} + } + + // Verify Boolean ABI + // + // Even though booleans are strictly 1-bit, and thus 0 or 1, in practice all UEFI systems + // treat it more like C does, and a boolean formatted as `u8` now allows any value other than + // 0 to represent `true`. Make sure we support the same. + #[test] + fn booleans() { + // Verify PartialEq works. + assert_ne!(Boolean::FALSE, Boolean::TRUE); + + // Verify Boolean<->bool conversion and comparison works. + assert_eq!(Boolean::FALSE, false); + assert_eq!(Boolean::TRUE, true); + + // Iterate all possible values for `u8` and verify 0 behaves as `false`, and everything + // else behaves as `true`. We verify both, the natural constructor through `From`, as well + // as a transmute. + for i in 0u8..=255u8 { + let v1: Boolean = i.into(); + let v2: Boolean = unsafe { std::mem::transmute::(i) }; + + assert_eq!(v1, v2); + assert_eq!(v1, v1); + assert_eq!(v2, v2); + + match i { + 0 => { + assert_eq!(v1, Boolean::FALSE); + assert_eq!(v1, false); + assert_eq!(v2, Boolean::FALSE); + assert_eq!(v2, false); + + assert_ne!(v1, Boolean::TRUE); + assert_ne!(v1, true); + assert_ne!(v2, Boolean::TRUE); + assert_ne!(v2, true); + } + _ => { + assert_eq!(v1, Boolean::TRUE); + assert_eq!(v1, true); + assert_eq!(v2, Boolean::TRUE); + assert_eq!(v2, true); + + assert_ne!(v1, Boolean::FALSE); + assert_ne!(v1, false); + assert_ne!(v2, Boolean::FALSE); + assert_ne!(v2, false); + } + } + } + } +} diff --git a/vendor/r-efi/src/hii.rs b/vendor/r-efi/src/hii.rs new file mode 100644 index 000000000..340176b62 --- /dev/null +++ b/vendor/r-efi/src/hii.rs @@ -0,0 +1,1300 @@ +//! Human Interface Infrastructure (HII) +//! +//! This module contains bindings and definitions copied from Section 33.3 of +//! the UEFI spec, as well as the core HII related definitions. + +// +// Core HII Definitions +// + +// This is the exception to the rule. It's defined in 34.8 (HII_DATABASE +// protocol), not 33.3, but it's used throughout the HII protocols, so it makes +// sense to be defined at the base. +pub type Handle = *mut core::ffi::c_void; + +// +// 33.3.1 Package Lists and Package Headers +// + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct PackageHeader { + pub length: [u8; 3], + pub r#type: u8, + pub data: [u8; N], +} + +pub const PACKAGE_TYPE_ALL: u8 = 0x00; +pub const PACKAGE_TYPE_GUID: u8 = 0x01; +pub const PACKAGE_FORMS: u8 = 0x02; +pub const PACKAGE_STRINGS: u8 = 0x04; +pub const PACKAGE_FONTS: u8 = 0x05; +pub const PACKAGE_IMAGES: u8 = 0x06; +pub const PACKAGE_SIMPLE_FONTS: u8 = 0x07; +pub const PACKAGE_DEVICE_PATH: u8 = 0x08; +pub const PACKAGE_KEYBOARD_LAYOUT: u8 = 0x09; +pub const PACKAGE_ANIMATIONS: u8 = 0x0A; +pub const PACKAGE_END: u8 = 0xDF; +pub const PACKAGE_TYPE_SYSTEM_BEGIN: u8 = 0xE0; +pub const PACKAGE_TYPE_SYSTEM_END: u8 = 0xFF; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct PackageListHeader { + pub package_list_guid: crate::base::Guid, + pub package_length: u32, +} + +// +// 33.3.3 Font Package +// + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FontPackageHdr { + pub header: PackageHeader, + pub hdr_size: u32, + pub glyph_block_offset: u32, + pub cell: GlyphInfo, + pub font_style: FontStyle, + pub font_family: [crate::base::Char16; N], +} + +pub type FontStyle = u32; + +pub const FONT_STYLE_NORMAL: FontStyle = 0x00000000; +pub const FONT_STYLE_BOLD: FontStyle = 0x00000001; +pub const FONT_STYLE_ITALIC: FontStyle = 0x00000002; +pub const FONT_STYLE_EMBOSS: FontStyle = 0x00010000; +pub const FONT_STYLE_OUTLINE: FontStyle = 0x00020000; +pub const FONT_STYLE_SHADOW: FontStyle = 0x00040000; +pub const FONT_STYLE_UNDERLINE: FontStyle = 0x00080000; +pub const FONT_STYLE_DBL_UNDER: FontStyle = 0x00100000; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GlyphBlock { + pub block_type: u8, + pub block_body: [u8; N], +} + +pub const GIBT_END: u8 = 0x00; +pub const GIBT_GLYPH: u8 = 0x10; +pub const GIBT_GLYPHS: u8 = 0x11; +pub const GIBT_GLYPH_DEFAULT: u8 = 0x12; +pub const GIBT_GLYPHS_DEFAULT: u8 = 0x13; +pub const GIBT_GLYPH_VARIABILITY: u8 = 0x14; +pub const GIBT_DUPLICATE: u8 = 0x20; +pub const GIBT_SKIP2: u8 = 0x21; +pub const GIBT_SKIP1: u8 = 0x22; +pub const GIBT_DEFAULTS: u8 = 0x23; +pub const GIBT_EXT1: u8 = 0x30; +pub const GIBT_EXT2: u8 = 0x31; +pub const GIBT_EXT4: u8 = 0x32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GlyphInfo { + pub width: u16, + pub height: u16, + pub offset_x: i16, + pub offset_y: i16, + pub advance_x: i16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtDefaultsBlock { + pub header: GlyphBlock, + pub cell: GlyphInfo, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtDuplicateBlock { + pub header: GlyphBlock, + pub char_value: crate::base::Char16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GlyphGibtEndBlock { + pub header: GlyphBlock, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtExt1Block { + pub header: GlyphBlock, + pub block_type_2: u8, + pub length: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtExt2Block { + pub header: GlyphBlock, + pub block_type_2: u8, + pub length: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtExt4Block { + pub header: GlyphBlock, + pub block_type_2: u8, + pub length: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtGlyphBlock { + pub header: GlyphBlock, + pub cell: GlyphInfo, + pub bitmap_data: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtGlyphsBlock { + pub header: GlyphBlock, + pub cell: GlyphInfo, + pub count: u16, + pub bitmap_data: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtGlyphDefaultBlock { + pub header: GlyphBlock, + pub bitmap_data: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtGlypshDefaultBlock { + pub header: GlyphBlock, + pub count: u16, + pub bitmap_data: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtSkip2Block { + pub header: GlyphBlock, + pub skip_count: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtSkip1Block { + pub header: GlyphBlock, + pub skip_count: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct GibtVariabilityBlock { + pub header: GlyphBlock, + pub cell: GlyphInfo, + pub glyph_pack_in_bits: u8, + pub bitmap_data: [u8; N], +} + +// +// 33.3.8 Forms Package +// + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FormPackageHdr { + pub header: PackageHeader, + pub op_code_header: IfrOpHeader, + // Op-Codes Follow... +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrOpHeader { + pub op_code: u8, + pub length_and_scope: u8, // Length:7, Scope:1 +} + +pub type QuestionId = u16; +pub type ImageId = u16; +pub type StringId = u16; +pub type FormId = u16; +pub type VarstoreId = u16; +pub type AnimationId = u16; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrQuestionHeader { + pub header: IfrStatementHeader, + pub question_id: QuestionId, + pub var_store_id: VarstoreId, + pub var_store_info: IfrQuestionHeaderVarstoreInfo, + pub flags: u8, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IfrQuestionHeaderVarstoreInfo { + pub var_name: StringId, + pub var_offset: u16, +} + +pub const IFR_FLAG_READ_ONLY: u8 = 0x01; +pub const IFR_FLAG_CALLBACK: u8 = 0x04; +pub const IFR_FLAG_RESET_REQUIRED: u8 = 0x10; +pub const IFR_FLAG_REST_STYLE: u8 = 0x20; +pub const IFR_FLAG_RECONNECT_REQUIRED: u8 = 0x40; +pub const IFR_FLAG_OPTIONS_ONLY: u8 = 0x80; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrStatementHeader { + pub prompt: StringId, + pub help: StringId, +} + +pub const IFR_FORM_OP: u8 = 0x01; +pub const IFR_SUBTITLE_OP: u8 = 0x02; +pub const IFR_TEXT_OP: u8 = 0x03; +pub const IFR_IMAGE_OP: u8 = 0x04; +pub const IFR_ONE_OF_OP: u8 = 0x05; +pub const IFR_CHECKBOX_OP: u8 = 0x06; +pub const IFR_NUMERIC_OP: u8 = 0x07; +pub const IFR_PASSWORD_OP: u8 = 0x08; +pub const IFR_ONE_OF_OPTION_OP: u8 = 0x09; +pub const IFR_SUPPRESS_IF_OP: u8 = 0x0A; +pub const IFR_LOCKED_OP: u8 = 0x0B; +pub const IFR_ACTION_OP: u8 = 0x0C; +pub const IFR_RESET_BUTTON_OP: u8 = 0x0D; +pub const IFR_FORM_SET_OP: u8 = 0x0E; +pub const IFR_REF_OP: u8 = 0x0F; +pub const IFR_NO_SUBMIT_IF_OP: u8 = 0x10; +pub const IFR_INCONSISTENT_IF_OP: u8 = 0x11; +pub const IFR_EQ_ID_VAL_OP: u8 = 0x12; +pub const IFR_EQ_ID_ID_OP: u8 = 0x13; +pub const IFR_EQ_ID_VAL_LIST_OP: u8 = 0x14; +pub const IFR_AND_OP: u8 = 0x15; +pub const IFR_OR_OP: u8 = 0x16; +pub const IFR_NOT_OP: u8 = 0x17; +pub const IFR_RULE_OP: u8 = 0x18; +pub const IFR_GRAY_OUT_IF_OP: u8 = 0x19; +pub const IFR_DATE_OP: u8 = 0x1A; +pub const IFR_TIME_OP: u8 = 0x1B; +pub const IFR_STRING_OP: u8 = 0x1C; +pub const IFR_REFRESH_OP: u8 = 0x1D; +pub const IFR_DISABLE_IF_OP: u8 = 0x1E; +pub const IFR_ANIMATION_OP: u8 = 0x1F; +pub const IFR_TO_LOWER_OP: u8 = 0x20; +pub const IFR_TO_UPPER_OP: u8 = 0x21; +pub const IFR_MAP_OP: u8 = 0x22; +pub const IFR_ORDERED_LIST_OP: u8 = 0x23; +pub const IFR_VARSTORE_OP: u8 = 0x24; +pub const IFR_VARSTORE_NAME_VALUE_OP: u8 = 0x25; +pub const IFR_VARSTORE_EFI_OP: u8 = 0x26; +pub const IFR_VARSTORE_DEVICE_OP: u8 = 0x27; +pub const IFR_VERSION_OP: u8 = 0x28; +pub const IFR_END_OP: u8 = 0x29; +pub const IFR_MATCH_OP: u8 = 0x2A; +pub const IFR_GET_OP: u8 = 0x2B; +pub const IFR_SET_OP: u8 = 0x2C; +pub const IFR_READ_OP: u8 = 0x2D; +pub const IFR_WRITE_OP: u8 = 0x2E; +pub const IFR_EQUAL_OP: u8 = 0x2F; +pub const IFR_NOT_EQUAL_OP: u8 = 0x30; +pub const IFR_GREATER_THAN_OP: u8 = 0x31; +pub const IFR_GREATER_EQUAL_OP: u8 = 0x32; +pub const IFR_LESS_THAN_OP: u8 = 0x33; +pub const IFR_LESS_EQUAL_OP: u8 = 0x34; +pub const IFR_BITWISE_AND_OP: u8 = 0x35; +pub const IFR_BITWISE_OR_OP: u8 = 0x36; +pub const IFR_BITWISE_NOT_OP: u8 = 0x37; +pub const IFR_SHIFT_LEFT_OP: u8 = 0x38; +pub const IFR_SHIFT_RIGHT_OP: u8 = 0x39; +pub const IFR_ADD_OP: u8 = 0x3A; +pub const IFR_SUBTRACT_OP: u8 = 0x3B; +pub const IFR_MULTIPLY_OP: u8 = 0x3C; +pub const IFR_DIVIDE_OP: u8 = 0x3D; +pub const IFR_MODULO_OP: u8 = 0x3E; +pub const IFR_RULE_REF_OP: u8 = 0x3F; +pub const IFR_QUESTION_REF1_OP: u8 = 0x40; +pub const IFR_QUESTION_REF2_OP: u8 = 0x41; +pub const IFR_UINT8_OP: u8 = 0x42; +pub const IFR_UINT16_OP: u8 = 0x43; +pub const IFR_UINT32_OP: u8 = 0x44; +pub const IFR_UINT64_OP: u8 = 0x45; +pub const IFR_TRUE_OP: u8 = 0x46; +pub const IFR_FALSE_OP: u8 = 0x47; +pub const IFR_TO_UINT_OP: u8 = 0x48; +pub const IFR_TO_STRING_OP: u8 = 0x49; +pub const IFR_TO_BOOLEAN_OP: u8 = 0x4A; +pub const IFR_MID_OP: u8 = 0x4B; +pub const IFR_FIND_OP: u8 = 0x4C; +pub const IFR_TOKEN_OP: u8 = 0x4D; +pub const IFR_STRING_REF1_OP: u8 = 0x4E; +pub const IFR_STRING_REF2_OP: u8 = 0x4F; +pub const IFR_CONDITIONAL_OP: u8 = 0x50; +pub const IFR_QUESTION_REF3_OP: u8 = 0x51; +pub const IFR_ZERO_OP: u8 = 0x52; +pub const IFR_ONE_OP: u8 = 0x53; +pub const IFR_ONES_OP: u8 = 0x54; +pub const IFR_UNDEFINED_OP: u8 = 0x55; +pub const IFR_LENGTH_OP: u8 = 0x56; +pub const IFR_DUP_OP: u8 = 0x57; +pub const IFR_THIS_OP: u8 = 0x58; +pub const IFR_SPAN_OP: u8 = 0x59; +pub const IFR_VALUE_OP: u8 = 0x5A; +pub const IFR_DEFAULT_OP: u8 = 0x5B; +pub const IFR_DEFAULTSTORE_OP: u8 = 0x5C; +pub const IFR_FORM_MAP_OP: u8 = 0x5D; +pub const IFR_CATENATE_OP: u8 = 0x5E; +pub const IFR_GUID_OP: u8 = 0x5F; +pub const IFR_SECURITY_OP: u8 = 0x60; +pub const IFR_MODAL_TAG_OP: u8 = 0x61; +pub const IFR_REFRESH_ID_OP: u8 = 0x62; +pub const IFR_WARNING_IF_OP: u8 = 0x63; +pub const IFR_MATCH2_OP: u8 = 0x64; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrAction { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub question_config: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrAction1 { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrAnimation { + pub header: IfrOpHeader, + pub id: AnimationId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrAdd { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrAnd { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrBitwiseAnd { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrBitwiseNot { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrBitwiseOr { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrCatenate { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrCheckbox { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub flags: u8, +} + +pub const IFR_CHECKBOX_DEFAULT: u8 = 0x01; +pub const IFR_CHECKBOX_DEFAULT_MFG: u8 = 0x02; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrConditional { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrDate { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub flags: u8, +} + +pub const QF_DATE_YEAR_SUPPRESS: u8 = 0x01; +pub const QF_DATE_MONTH_SUPPRESS: u8 = 0x02; +pub const QF_DATE_DAY_SUPPRESS: u8 = 0x04; +pub const QF_DATE_STORAGE: u8 = 0x30; + +pub const QF_DATE_STORAGE_NORMAL: u8 = 0x00; +pub const QF_DATE_STORAGE_TIME: u8 = 0x10; +pub const QF_DATE_STORAGE_WAKEUP: u8 = 0x20; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrDefault { + pub header: IfrOpHeader, + pub default_id: u16, + pub r#type: u8, + pub value: IfrTypeValue, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrDefault2 { + pub header: IfrOpHeader, + pub default_id: u16, + pub r#type: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrDefaultstore { + pub header: IfrOpHeader, + pub default_name: StringId, + pub default_id: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrDisableIf { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrDivide { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrDup { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrEnd { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrEqual { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrEqIdId { + pub header: IfrOpHeader, + pub question_id_1: QuestionId, + pub question_id_2: QuestionId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrEqIdValList { + pub header: IfrOpHeader, + pub question_id: QuestionId, + pub list_length: u16, + pub value_list: [u16; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrEqIdVal { + pub header: IfrOpHeader, + pub question_id: QuestionId, + pub value: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrFalse { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrFind { + pub header: IfrOpHeader, + pub format: u8, +} + +pub const IFR_FF_CASE_SENSITIVE: u8 = 0x00; +pub const IFR_FF_CASE_INSENSITIVE: u8 = 0x01; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrForm { + pub header: IfrOpHeader, + pub form_id: FormId, + pub form_title: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrFormMapMethod { + pub method_title: StringId, + pub method_identifier: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrFormMap { + pub header: IfrOpHeader, + pub form_id: FormId, + pub methods: [IfrFormMapMethod; N], +} + +pub const STANDARD_FORM_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x3bd2f4ec, + 0xe524, + 0x46e4, + 0xa9, + 0xd8, + &[0x51, 0x01, 0x17, 0x42, 0x55, 0x62], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrFormSet { + pub header: IfrOpHeader, + pub guid: crate::base::Guid, + pub form_set_title: StringId, + pub help: StringId, + pub flags: u8, + pub class_guid: [crate::base::Guid; N], +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrGet { + pub header: IfrOpHeader, + pub var_store_id: VarstoreId, + pub var_store_info: IfrGetVarStoreInfo, + pub var_store_type: u8, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IfrGetVarStoreInfo { + pub var_name: StringId, + pub var_offset: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrGrayOutIf { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrGreaterEqual { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrGreaterThan { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrGuid { + pub header: IfrOpHeader, + pub guid: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrImage { + pub id: ImageId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrInconsistentIf { + pub header: IfrOpHeader, + pub error: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrLength { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrLessEqual { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrLessThan { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrLocked { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrMap { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrMatch { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrMid { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrModalTag { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrModulo { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrMultiply { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNot { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNotEqual { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNoSubmitIf { + pub header: IfrOpHeader, + pub error: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNumericDataU8 { + pub min_value: u8, + pub max_value: u8, + pub step: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNumericDataU16 { + pub min_value: u16, + pub max_value: u16, + pub step: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNumericDataU32 { + pub min_value: u32, + pub max_value: u32, + pub step: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrNumericDataU64 { + pub min_value: u64, + pub max_value: u64, + pub step: u64, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IfrNumericData { + pub r#u8: IfrNumericDataU8, + pub r#u16: IfrNumericDataU16, + pub r#u32: IfrNumericDataU32, + pub r#u64: IfrNumericDataU64, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrNumeric { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub flags: u8, + pub data: IfrNumericData, +} + +pub const IFR_NUMERIC_SIZE: u8 = 0x03; +pub const IFR_NUMERIC_SIZE_1: u8 = 0x00; +pub const IFR_NUMERIC_SIZE_2: u8 = 0x01; +pub const IFR_NUMERIC_SIZE_4: u8 = 0x02; +pub const IFR_NUMERIC_SIZE_8: u8 = 0x03; + +pub const IFR_DISPLAY: u8 = 0x30; +pub const IFR_DISPLAY_INT_DEC: u8 = 0x00; +pub const IFR_DISPLAY_UINT_DEC: u8 = 0x10; +pub const IFR_DISPLAY_UINT_HEX: u8 = 0x20; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrOne { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrOnes { + pub header: IfrOpHeader, +} + +type IfrOneOfData = IfrNumericData; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrOneOf { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub flags: u8, + pub data: IfrOneOfData, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrOneOfOption { + pub header: IfrOpHeader, + pub option: StringId, + pub flags: u8, + pub r#type: u8, + pub value: IfrTypeValue, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IfrTypeValue { + pub r#u8: u8, + pub r#u16: u16, + pub r#u32: u32, + pub r#u64: u64, + pub b: crate::base::Boolean, + pub time: Time, + pub date: Date, + pub string: StringId, + pub r#ref: Ref, + pub buffer: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Time { + pub hour: u8, + pub minute: u8, + pub second: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Date { + pub year: u16, + pub month: u8, + pub day: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Ref { + pub question_id: QuestionId, + pub form_id: FormId, + pub form_set_guid: crate::base::Guid, + pub device_path: StringId, +} + +pub const IFR_TYPE_NUM_SIZE_8: u8 = 0x00; +pub const IFR_TYPE_NUM_SIZE_16: u8 = 0x01; +pub const IFR_TYPE_NUM_SIZE_32: u8 = 0x02; +pub const IFR_TYPE_NUM_SIZE_64: u8 = 0x03; +pub const IFR_TYPE_BOOLEAN: u8 = 0x04; +pub const IFR_TYPE_TIME: u8 = 0x05; +pub const IFR_TYPE_DATE: u8 = 0x06; +pub const IFR_TYPE_STRING: u8 = 0x07; +pub const IFR_TYPE_OTHER: u8 = 0x08; +pub const IFR_TYPE_UNDEFINED: u8 = 0x09; +pub const IFR_TYPE_ACTION: u8 = 0x0A; +pub const IFR_TYPE_BUFFER: u8 = 0x0B; +pub const IFR_TYPE_REF: u8 = 0x0C; + +pub const IFR_OPTION_DEFAULT: u8 = 0x10; +pub const IFR_OPTION_DEFAULT_MFG: u8 = 0x20; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrOr { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrOrderedList { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub max_containers: u8, + pub flags: u8, +} + +pub const IFR_UNIQUE_SET: u8 = 0x01; +pub const IFR_NO_EMPTY_SET: u8 = 0x02; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrPassword { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub min_size: u16, + pub max_size: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrQuestionRef1 { + pub header: IfrOpHeader, + pub question_id: QuestionId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrQuestionRef2 { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrQuestionRef3 { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrQuestionRef32 { + pub header: IfrOpHeader, + pub device_path: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrQuestionRef33 { + pub header: IfrOpHeader, + pub device_path: StringId, + pub guid: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrRead { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrRef { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub form_id: FormId, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrRef2 { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub form_id: FormId, + pub question_id: QuestionId, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrRef3 { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub form_id: FormId, + pub question_id: QuestionId, + pub form_set_id: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrRef4 { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub form_id: FormId, + pub question_id: QuestionId, + pub form_set_id: crate::base::Guid, + pub device_path: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrRef5 { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrRefresh { + pub header: IfrOpHeader, + pub refresh_interval: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrRefreshId { + pub header: IfrOpHeader, + pub refresh_event_group_id: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrResetButton { + pub header: IfrOpHeader, + pub statement: IfrStatementHeader, + pub deafult_id: DefaultId, +} + +pub type DefaultId = u16; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrRule { + pub header: IfrOpHeader, + pub rule_id: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrRuleRef { + pub header: IfrOpHeader, + pub rule_id: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrSecurity { + pub header: IfrOpHeader, + pub permissions: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IfrSetVarStoreInfo { + pub var_name: StringId, + pub var_offset: u16, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrSet { + pub header: IfrOpHeader, + pub var_store_id: VarstoreId, + pub var_store_info: IfrSetVarStoreInfo, + pub var_store_type: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrShiftLeft { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrShiftRight { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrSpan { + pub header: IfrOpHeader, + pub flags: u8, +} + +pub const IFR_FLAGS_FIRST_MATCHING: u8 = 0x00; +pub const IFR_FLAGS_FIRST_NON_MATCHING: u8 = 0x01; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrString { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub min_size: u8, + pub max_size: u8, + pub flags: u8, +} + +pub const IFR_STRING_MULTI_LINE: u8 = 0x01; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrStringRef1 { + pub header: IfrOpHeader, + pub string_id: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrStringRef2 { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrSubtitle { + pub header: IfrOpHeader, + pub statement: IfrStatementHeader, + pub flags: u8, +} + +pub const IFR_FLAGS_HORIZONTAL: u8 = 0x01; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrSubtract { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrSuppressIf { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrText { + pub header: IfrOpHeader, + pub statement: IfrStatementHeader, + pub text_two: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrThis { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IfrTime { + pub header: IfrOpHeader, + pub question: IfrQuestionHeader, + pub flags: u8, +} + +pub const QF_TIME_HOUR_SUPPRESS: u8 = 0x01; +pub const QF_TIME_MINUTE_SUPPRESS: u8 = 0x02; +pub const QF_TIME_SECOND_SUPPRESS: u8 = 0x04; +pub const QF_TIME_STORAGE: u8 = 0x30; + +pub const QF_TIME_STORAGE_NORMAL: u8 = 0x00; +pub const QF_TIME_STORAGE_TIME: u8 = 0x10; +pub const QF_TIME_STORAGE_WAKEUP: u8 = 0x20; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToken { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToBoolean { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToLower { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToString { + pub header: IfrOpHeader, + pub format: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToUint { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrToUpper { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrTrue { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrUint8 { + pub header: IfrOpHeader, + pub value: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrUint16 { + pub header: IfrOpHeader, + pub value: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrUint32 { + pub header: IfrOpHeader, + pub value: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrUint64 { + pub header: IfrOpHeader, + pub value: u64, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrUndefined { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrValue { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrVarstore { + pub header: IfrOpHeader, + pub guid: crate::base::Guid, + pub var_store_id: VarstoreId, + pub size: u16, + pub name: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrVarstoreNameValue { + pub header: IfrOpHeader, + pub var_store_id: VarstoreId, + pub guid: crate::base::Guid, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrVarstoreEfi { + pub header: IfrOpHeader, + pub var_store_id: VarstoreId, + pub guid: crate::base::Guid, + pub attributes: u32, + pub size: u16, + pub name: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrVarstoreDevice { + pub header: IfrOpHeader, + pub device_path: StringId, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrVersion { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrWrite { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrZero { + pub header: IfrOpHeader, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrWarningIf { + pub header: IfrOpHeader, + pub warning: StringId, + pub time_out: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IfrMatch2 { + pub header: IfrOpHeader, + pub syntax_type: crate::base::Guid, +} diff --git a/vendor/r-efi/src/lib.rs b/vendor/r-efi/src/lib.rs new file mode 100644 index 000000000..8b4de8640 --- /dev/null +++ b/vendor/r-efi/src/lib.rs @@ -0,0 +1,352 @@ +//! UEFI Reference Specification Protocol Constants and Definitions +//! +//! This project provides protocol constants and definitions as defined in the UEFI Reference +//! Specification. The aim is to provide all these constants as C-ABI compatible imports to rust. +//! Safe rust abstractions over the UEFI API are out of scope of this project. That is, the +//! purpose is really just to extract all the bits and pieces from the specification and provide +//! them as rust types and constants. +//! +//! While we strongly recommend using safe abstractions to interact with UEFI systems, this +//! project serves both as base to write those abstractions, but also as last resort if you have +//! to deal with quirks and peculiarities of UEFI systems directly. Therefore, several examples +//! are included, which show how to interact with UEFI systems from rust. These serve both as +//! documentation for anyone interested in how the system works, but also as base for anyone +//! implementing safe abstractions on top. +//! +//! # Target Configuration +//! +//! Rust code can be compiled natively for UEFI systems. However, you are quite unlikely to have a +//! rust compiler running in an UEFI environment. Therefore, you will most likely want to cross +//! compile your rust code for UEFI systems. To do this, you need a target-configuration for UEFI +//! systems. As of rust-1.61, upstream rust includes the following UEFI targets: +//! +//! * `aarch64-unknown-uefi`: A native UEFI target for aarch64 systems (64bit ARM). +//! * `i686-unknown-uefi`: A native UEFI target for i686 systems (32bit Intel x86). +//! * `x86_64-unknown-uefi`: A native UEFI target for x86-64 systems (64bit Intel x86). +//! +//! If none of these targets match your architecture, you have to create the target specification +//! yourself. Feel free to contact the `r-efi` project for help. +//! +//! # Transpose Guidelines +//! +//! The UEFI specification provides C language symbols and definitions of all +//! its protocols and features. Those are integral parts of the specification +//! and UEFI programming is often tightly coupled with the C language. For +//! better compatibility to existing UEFI documentation, all the rust symbols +//! are transposed from C following strict rules, aiming for close similarity +//! to specification. This section gives a rationale on some of the less +//! obvious choices and tries to describe as many of those rules as possible. +//! +//! * `no enums`: Rust enums do not allow random discriminant values. However, +//! many UEFI enumerations use reserved ranges for vendor defined values. +//! These cannot be represented with rust enums in an efficient manner. +//! Hence, any enumerations are turned into rust constants with an +//! accompanying type alias. +//! +//! A detailed discussion can be found in: +//! +//! ```gitlog +//! commit 401a91901e860a5c0cd0f92b75dda0a72cf65322 +//! Author: David Rheinsberg +//! Date: Wed Apr 21 12:07:07 2021 +0200 +//! +//! r-efi: convert enums to constants +//! ``` +//! +//! * `no incomplete types`: Several structures use incomplete structure types +//! by using an unbound array as last member. While rust can easily +//! represent those within its type-system, such structures become DSTs, +//! hence even raw pointers to them become fat-pointers, and would thus +//! violate the UEFI ABI. +//! +//! Instead, we use const-generics to allow compile-time adjustment of the +//! variable-sized structures, with a default value of 0. This allows +//! computing different sizes of the structures without any runtime overhead. +//! +//! * `nullable callbacks as Option`: Rust has no raw function pointers, but +//! just normal Rust function pointers. Those, however, have no valid null +//! value. The Rust ABI guarantees that `Option` is an C-ABI +//! compatible replacement for nullable function pointers, with `None` being +//! mapped to `NULL`. Hence, whenever UEFI APIs require nullable function +//! pointers, we use `Option`. +//! +//! * `prefer *mut over *const`: Whenever we transpose pointers from the +//! specification into Rust, we prefer `*mut` in almost all cases. `*const` +//! should only be used if the underlying value is known not to be accessible +//! via any other mutable pointer type. Since this is rarely the case in +//! UEFI, we avoid it. +//! +//! The reasoning is that Rust allows coercing immutable types into `*const` +//! pointers, without any explicit casting required. However, immutable Rust +//! references require that no other mutable reference exists simultaneously. +//! This is not a guarantee of `const`-pointers in C / UEFI, hence this +//! coercion is usually ill-advised or even wrong. +//! +//! Lastly, note that `*mut` and `*const` and be `as`-casted in both +//! directions without violating any Rust guarantees. Any UB concerns always +//! stem from the safety guarantees of the surrounding code, not of the +//! raw-pointer handling. +//! +//! # Examples +//! +//! To write free-standing UEFI applications, you need to disable the entry-point provided by rust +//! and instead provide your own. Most target-configurations look for a function called `efi_main` +//! during linking and set it as entry point. If you use the target-configurations provided with +//! upstream rust, they will pick the function called `efi_main` as entry-point. +//! +//! The following example shows a minimal UEFI application, which simply returns success upon +//! invocation. Note that you must provide your own panic-handler when running without `libstd`. +//! In our case, we use a trivial implementation that simply loops forever. +//! +//! ```ignore +//! #![no_main] +//! #![no_std] +//! +//! use r_efi::efi; +//! +//! #[panic_handler] +//! fn panic_handler(_info: &core::panic::PanicInfo) -> ! { +//! loop {} +//! } +//! +//! #[export_name = "efi_main"] +//! pub extern fn main(_h: efi::Handle, _st: *mut efi::SystemTable) -> efi::Status { +//! efi::Status::SUCCESS +//! } +//! ``` + +// Mark this crate as `no_std`. We have no std::* dependencies (and we better don't have them), +// so no reason to require it. This does not mean that you cannot use std::* with UEFI. You have +// to port it to UEFI first, though. +// +// In case of unit-test compilation, we pull in `std` and drop the `no_std` marker. This allows +// basic unit-tests on the compilation host. For integration tests, we have separate compilation +// units, so they will be unaffected by this. +#![cfg_attr(not(test), no_std)] + +// Import the different core modules. We separate them into different modules to make it easier to +// work on them and describe what each part implements. This is different to the reference +// implementation, which uses a flat namespace due to its origins in the C language. For +// compatibility, we provide this flat namespace as well. See the `efi` submodule. +#[macro_use] +pub mod base; +#[macro_use] +pub mod hii; +#[macro_use] +pub mod system; + +// Import the protocols. Each protocol is separated into its own module, readily imported by the +// meta `protocols` module. Note that this puts all symbols into their respective protocol +// namespace, thus clearly separating them (unlike the UEFI Specification, which more often than +// not violates its own namespacing). +pub mod protocols; + +// Import vendor protocols. They are just like protocols in `protocols`, but +// separated for better namespacing. +pub mod vendor; + +/// Flat EFI Namespace +/// +/// The EFI namespace re-exports all symbols in a single, flat namespace. This allows mirroring +/// the entire EFI namespace as given in the specification and makes it easier to refer to them +/// with the same names as the reference C implementation. +/// +/// Note that the individual protocols are put into submodules. The specification does this in +/// most parts as well (by prefixing all symbols). This is not true in all cases, as the +/// specification suffers from lack of namespaces in the reference C language. However, we decided +/// to namespace the remaining bits as well, for better consistency throughout the API. This +/// should be self-explanatory in nearly all cases. +pub mod efi { + // + // Re-export base + // + + pub use crate::base::Boolean; + pub use crate::base::Char16; + pub use crate::base::Char8; + pub use crate::base::Event; + pub use crate::base::Guid; + pub use crate::base::Handle; + pub use crate::base::ImageEntryPoint; + pub use crate::base::IpAddress; + pub use crate::base::Ipv4Address; + pub use crate::base::Ipv6Address; + pub use crate::base::Lba; + pub use crate::base::MacAddress; + pub use crate::base::PhysicalAddress; + pub use crate::base::Status; + pub use crate::base::Tpl; + pub use crate::base::VirtualAddress; + + // + // Re-export system + // + + pub use crate::system::Time; + pub use crate::system::TimeCapabilities; + pub use crate::system::TIME_ADJUST_DAYLIGHT; + pub use crate::system::TIME_IN_DAYLIGHT; + pub use crate::system::UNSPECIFIED_TIMEZONE; + + pub use crate::system::VariableAuthentication; + pub use crate::system::VariableAuthentication2; + pub use crate::system::VariableAuthentication3; + pub use crate::system::VariableAuthentication3CertId; + pub use crate::system::VariableAuthentication3Nonce; + pub use crate::system::HARDWARE_ERROR_VARIABLE_GUID; + pub use crate::system::VARIABLE_APPEND_WRITE; + pub use crate::system::VARIABLE_AUTHENTICATED_WRITE_ACCESS; + pub use crate::system::VARIABLE_AUTHENTICATION_3_CERT_ID_SHA256; + pub use crate::system::VARIABLE_AUTHENTICATION_3_NONCE_TYPE; + pub use crate::system::VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE; + pub use crate::system::VARIABLE_BOOTSERVICE_ACCESS; + pub use crate::system::VARIABLE_ENHANCED_AUTHENTICATED_ACCESS; + pub use crate::system::VARIABLE_HARDWARE_ERROR_RECORD; + pub use crate::system::VARIABLE_NON_VOLATILE; + pub use crate::system::VARIABLE_RUNTIME_ACCESS; + pub use crate::system::VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; + + pub use crate::system::OPTIONAL_POINTER; + + pub use crate::system::ResetType; + pub use crate::system::RESET_COLD; + pub use crate::system::RESET_PLATFORM_SPECIFIC; + pub use crate::system::RESET_SHUTDOWN; + pub use crate::system::RESET_WARM; + + pub use crate::system::CapsuleBlockDescriptor; + pub use crate::system::CapsuleBlockDescriptorUnion; + pub use crate::system::CapsuleHeader; + pub use crate::system::CapsuleResultVariableFMP; + pub use crate::system::CapsuleResultVariableHeader; + pub use crate::system::CAPSULE_FLAGS_INITIATE_RESET; + pub use crate::system::CAPSULE_FLAGS_PERSIST_ACROSS_RESET; + pub use crate::system::CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE; + pub use crate::system::CAPSULE_REPORT_GUID; + pub use crate::system::OS_INDICATIONS_BOOT_TO_FW_UI; + pub use crate::system::OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED; + pub use crate::system::OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; + pub use crate::system::OS_INDICATIONS_FMP_CAPSULE_SUPPORTED; + pub use crate::system::OS_INDICATIONS_START_OS_RECOVERY; + pub use crate::system::OS_INDICATIONS_START_PLATFORM_RECOVERY; + pub use crate::system::OS_INDICATIONS_TIMESTAMP_REVOCATION; + + pub use crate::system::EventNotify; + pub use crate::system::TimerDelay; + pub use crate::system::EVENT_GROUP_EXIT_BOOT_SERVICES; + pub use crate::system::EVENT_GROUP_MEMORY_MAP_CHANGE; + pub use crate::system::EVENT_GROUP_READY_TO_BOOT; + pub use crate::system::EVENT_GROUP_RESET_SYSTEM; + pub use crate::system::EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE; + pub use crate::system::EVT_NOTIFY_SIGNAL; + pub use crate::system::EVT_NOTIFY_WAIT; + pub use crate::system::EVT_RUNTIME; + pub use crate::system::EVT_SIGNAL_EXIT_BOOT_SERVICES; + pub use crate::system::EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE; + pub use crate::system::EVT_TIMER; + pub use crate::system::TIMER_CANCEL; + pub use crate::system::TIMER_PERIODIC; + pub use crate::system::TIMER_RELATIVE; + pub use crate::system::TPL_APPLICATION; + pub use crate::system::TPL_CALLBACK; + pub use crate::system::TPL_HIGH_LEVEL; + pub use crate::system::TPL_NOTIFY; + + pub use crate::system::AllocateType; + pub use crate::system::MemoryDescriptor; + pub use crate::system::MemoryType; + pub use crate::system::ACPI_MEMORY_NVS; + pub use crate::system::ACPI_RECLAIM_MEMORY; + pub use crate::system::ALLOCATE_ADDRESS; + pub use crate::system::ALLOCATE_ANY_PAGES; + pub use crate::system::ALLOCATE_MAX_ADDRESS; + pub use crate::system::BOOT_SERVICES_CODE; + pub use crate::system::BOOT_SERVICES_DATA; + pub use crate::system::CONVENTIONAL_MEMORY; + pub use crate::system::LOADER_CODE; + pub use crate::system::LOADER_DATA; + pub use crate::system::MEMORY_DESCRIPTOR_VERSION; + pub use crate::system::MEMORY_MAPPED_IO; + pub use crate::system::MEMORY_MAPPED_IO_PORT_SPACE; + pub use crate::system::MEMORY_MORE_RELIABLE; + pub use crate::system::MEMORY_NV; + pub use crate::system::MEMORY_RO; + pub use crate::system::MEMORY_RP; + pub use crate::system::MEMORY_RUNTIME; + pub use crate::system::MEMORY_UC; + pub use crate::system::MEMORY_UCE; + pub use crate::system::MEMORY_WB; + pub use crate::system::MEMORY_WC; + pub use crate::system::MEMORY_WP; + pub use crate::system::MEMORY_WT; + pub use crate::system::MEMORY_XP; + pub use crate::system::PAL_CODE; + pub use crate::system::PERSISTENT_MEMORY; + pub use crate::system::RESERVED_MEMORY_TYPE; + pub use crate::system::RUNTIME_SERVICES_CODE; + pub use crate::system::RUNTIME_SERVICES_DATA; + pub use crate::system::UNUSABLE_MEMORY; + + pub use crate::system::InterfaceType; + pub use crate::system::LocateSearchType; + pub use crate::system::OpenProtocolInformationEntry; + pub use crate::system::ALL_HANDLES; + pub use crate::system::BY_PROTOCOL; + pub use crate::system::BY_REGISTER_NOTIFY; + pub use crate::system::NATIVE_INTERFACE; + pub use crate::system::OPEN_PROTOCOL_BY_CHILD_CONTROLLER; + pub use crate::system::OPEN_PROTOCOL_BY_DRIVER; + pub use crate::system::OPEN_PROTOCOL_BY_HANDLE_PROTOCOL; + pub use crate::system::OPEN_PROTOCOL_EXCLUSIVE; + pub use crate::system::OPEN_PROTOCOL_GET_PROTOCOL; + pub use crate::system::OPEN_PROTOCOL_TEST_PROTOCOL; + + pub use crate::system::ConfigurationTable; + pub use crate::system::MemoryAttributesTable; + pub use crate::system::PropertiesTable; + pub use crate::system::MEMORY_ATTRIBUTES_TABLE_GUID; + pub use crate::system::MEMORY_ATTRIBUTES_TABLE_VERSION; + pub use crate::system::PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA; + pub use crate::system::PROPERTIES_TABLE_GUID; + pub use crate::system::PROPERTIES_TABLE_VERSION; + + pub use crate::system::BootServices; + pub use crate::system::RuntimeServices; + pub use crate::system::SystemTable; + pub use crate::system::TableHeader; + pub use crate::system::BOOT_SERVICES_REVISION; + pub use crate::system::BOOT_SERVICES_SIGNATURE; + pub use crate::system::RUNTIME_SERVICES_REVISION; + pub use crate::system::RUNTIME_SERVICES_SIGNATURE; + pub use crate::system::SPECIFICATION_REVISION; + pub use crate::system::SYSTEM_TABLE_REVISION_1_02; + pub use crate::system::SYSTEM_TABLE_REVISION_1_10; + pub use crate::system::SYSTEM_TABLE_REVISION_2_00; + pub use crate::system::SYSTEM_TABLE_REVISION_2_10; + pub use crate::system::SYSTEM_TABLE_REVISION_2_20; + pub use crate::system::SYSTEM_TABLE_REVISION_2_30; + pub use crate::system::SYSTEM_TABLE_REVISION_2_31; + pub use crate::system::SYSTEM_TABLE_REVISION_2_40; + pub use crate::system::SYSTEM_TABLE_REVISION_2_50; + pub use crate::system::SYSTEM_TABLE_REVISION_2_60; + pub use crate::system::SYSTEM_TABLE_REVISION_2_70; + pub use crate::system::SYSTEM_TABLE_SIGNATURE; + + // + // Re-export HII + // + + pub use crate::hii; + + // + // Re-export protocols + // + + pub use crate::protocols; + + // + // Re-export vendor. + // + + pub use crate::vendor; +} diff --git a/vendor/r-efi/src/protocols.rs b/vendor/r-efi/src/protocols.rs new file mode 100644 index 000000000..ae5c8bcfa --- /dev/null +++ b/vendor/r-efi/src/protocols.rs @@ -0,0 +1,45 @@ +//! UEFI Protocols +//! +//! The UEFI Specification splits most of its non-core parts into separate protocols. They can +//! refer to each other, but their documentation and implementation is split apart. We provide +//! each protocol as a separate module, so it is clearly defined where a symbol belongs to. + +pub mod block_io; +pub mod debug_support; +pub mod debugport; +pub mod decompress; +pub mod device_path; +pub mod device_path_from_text; +pub mod device_path_to_text; +pub mod device_path_utilities; +pub mod disk_io; +pub mod disk_io2; +pub mod driver_binding; +pub mod driver_diagnostics2; +pub mod file; +pub mod graphics_output; +pub mod hii_database; +pub mod hii_font; +pub mod hii_font_ex; +pub mod hii_string; +pub mod ip4; +pub mod ip6; +pub mod loaded_image; +pub mod loaded_image_device_path; +pub mod managed_network; +pub mod mp_services; +pub mod rng; +pub mod service_binding; +pub mod shell; +pub mod shell_dynamic_command; +pub mod shell_parameters; +pub mod simple_file_system; +pub mod simple_network; +pub mod simple_text_input; +pub mod simple_text_input_ex; +pub mod simple_text_output; +pub mod tcp4; +pub mod tcp6; +pub mod timestamp; +pub mod udp4; +pub mod udp6; diff --git a/vendor/r-efi/src/protocols/block_io.rs b/vendor/r-efi/src/protocols/block_io.rs new file mode 100644 index 000000000..26a2c0a10 --- /dev/null +++ b/vendor/r-efi/src/protocols/block_io.rs @@ -0,0 +1,70 @@ +//! Block I/O Protocol +//! +//! Used to abstract mass storage devices to allow code running in the EFI boot services environment +//! to access the storage devices without specific knowledge of the type of device or controller that +//! manages the device. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x964e5b21, + 0x6459, + 0x11d2, + 0x8e, + 0x39, + &[0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +pub const REVISION: u64 = 0x0000000000010000u64; +pub const REVISION2: u64 = 0x0000000000020001u64; +pub const REVISION3: u64 = 0x000000000002001fu64; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Media { + pub media_id: u32, + pub removable_media: bool, + pub media_present: bool, + pub logical_partition: bool, + pub read_only: bool, + pub write_caching: bool, + pub block_size: u32, + pub io_align: u32, + pub last_block: crate::base::Lba, + pub lowest_aligned_lba: crate::base::Lba, + pub logical_blocks_per_physical_block: u32, + pub optimal_transfer_length_granularity: u32, +} + +pub type ProtocolReset = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolReadBlocks = eficall! {fn( + *mut Protocol, + u32, + crate::base::Lba, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolWriteBlocks = eficall! {fn( + *mut Protocol, + u32, + crate::base::Lba, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolFlushBlocks = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub media: *const Media, + pub reset: ProtocolReset, + pub read_blocks: ProtocolReadBlocks, + pub write_blocks: ProtocolWriteBlocks, + pub flush_blocks: ProtocolFlushBlocks, +} diff --git a/vendor/r-efi/src/protocols/debug_support.rs b/vendor/r-efi/src/protocols/debug_support.rs new file mode 100644 index 000000000..c8272e910 --- /dev/null +++ b/vendor/r-efi/src/protocols/debug_support.rs @@ -0,0 +1,835 @@ +//! Debug Support Protocol +//! +//! It provides the services to allow the debug agent to register callback functions that are +//! called either periodically or when specific processor exceptions occur. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x2755590c, + 0x6f3c, + 0x42fa, + 0x9e, + 0xa4, + &[0xa3, 0xba, 0x54, 0x3c, 0xda, 0x25], +); + +pub type InstructionSetArchitecture = u32; + +pub const ISA_IA32: InstructionSetArchitecture = 0x014c; +pub const ISA_X64: InstructionSetArchitecture = 0x8664; +pub const ISA_IPF: InstructionSetArchitecture = 0x0200; +pub const ISA_EBC: InstructionSetArchitecture = 0x0ebc; +pub const ISA_ARM: InstructionSetArchitecture = 0x1c2; +pub const ISA_AARCH64: InstructionSetArchitecture = 0xaa64; +pub const ISA_RISCV32: InstructionSetArchitecture = 0x5032; +pub const ISA_RISCV64: InstructionSetArchitecture = 0x5064; +pub const ISA_RISCV128: InstructionSetArchitecture = 0x5128; + +#[repr(C)] +#[derive(Clone, Copy)] +pub union SystemContext { + pub system_context_ebc: *mut SystemContextEbc, + pub system_context_ia32: *mut SystemContextIa32, + pub system_context_x64: *mut SystemContextX64, + pub system_context_ipf: *mut SystemContextIpf, + pub system_context_arm: *mut SystemContextArm, + pub system_context_aarch64: *mut SystemContextAArch64, + pub system_context_riscv32: *mut SystemContextRiscV32, + pub system_context_riscv64: *mut SystemContextRiscV64, + pub system_context_riscv128: *mut SystemContextRiscV128, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextEbc { + pub r0: u64, + pub r1: u64, + pub r2: u64, + pub r3: u64, + pub r4: u64, + pub r5: u64, + pub r6: u64, + pub r7: u64, + pub flags: u64, + pub control_flags: u64, + pub ip: u64, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextRiscV32 { + // Integer registers + pub zero: u32, + pub ra: u32, + pub sp: u32, + pub gp: u32, + pub tp: u32, + pub t0: u32, + pub t1: u32, + pub t2: u32, + pub s0fp: u32, + pub s1: u32, + pub a0: u32, + pub a1: u32, + pub a2: u32, + pub a3: u32, + pub a4: u32, + pub a5: u32, + pub a6: u32, + pub a7: u32, + pub s2: u32, + pub s3: u32, + pub s4: u32, + pub s5: u32, + pub s6: u32, + pub s7: u32, + pub s8: u32, + pub s9: u32, + pub s10: u32, + pub s11: u32, + pub t3: u32, + pub t4: u32, + pub t5: u32, + pub t6: u32, + // Floating registers for F, D and Q Standard Extensions + pub ft0: u128, + pub ft1: u128, + pub ft2: u128, + pub ft3: u128, + pub ft4: u128, + pub ft5: u128, + pub ft6: u128, + pub ft7: u128, + pub fs0: u128, + pub fs1: u128, + pub fa0: u128, + pub fa1: u128, + pub fa2: u128, + pub fa3: u128, + pub fa4: u128, + pub fa5: u128, + pub fa6: u128, + pub fa7: u128, + pub fs2: u128, + pub fs3: u128, + pub fs4: u128, + pub fs5: u128, + pub fs6: u128, + pub fs7: u128, + pub fs8: u128, + pub fs9: u128, + pub fs10: u128, + pub fs11: u128, + pub ft8: u128, + pub ft9: u128, + pub ft10: u128, + pub ft11: u128, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextRiscV64 { + // Integer registers + pub zero: u64, + pub ra: u64, + pub sp: u64, + pub gp: u64, + pub tp: u64, + pub t0: u64, + pub t1: u64, + pub t2: u64, + pub s0fp: u64, + pub s1: u64, + pub a0: u64, + pub a1: u64, + pub a2: u64, + pub a3: u64, + pub a4: u64, + pub a5: u64, + pub a6: u64, + pub a7: u64, + pub s2: u64, + pub s3: u64, + pub s4: u64, + pub s5: u64, + pub s6: u64, + pub s7: u64, + pub s8: u64, + pub s9: u64, + pub s10: u64, + pub s11: u64, + pub t3: u64, + pub t4: u64, + pub t5: u64, + pub t6: u64, + // Floating registers for F, D and Q Standard Extensions + pub ft0: u128, + pub ft1: u128, + pub ft2: u128, + pub ft3: u128, + pub ft4: u128, + pub ft5: u128, + pub ft6: u128, + pub ft7: u128, + pub fs0: u128, + pub fs1: u128, + pub fa0: u128, + pub fa1: u128, + pub fa2: u128, + pub fa3: u128, + pub fa4: u128, + pub fa5: u128, + pub fa6: u128, + pub fa7: u128, + pub fs2: u128, + pub fs3: u128, + pub fs4: u128, + pub fs5: u128, + pub fs6: u128, + pub fs7: u128, + pub fs8: u128, + pub fs9: u128, + pub fs10: u128, + pub fs11: u128, + pub ft8: u128, + pub ft9: u128, + pub ft10: u128, + pub ft11: u128, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextRiscV128 { + // Integer registers + pub zero: u128, + pub ra: u128, + pub sp: u128, + pub gp: u128, + pub tp: u128, + pub t0: u128, + pub t1: u128, + pub t2: u128, + pub s0fp: u128, + pub s1: u128, + pub a0: u128, + pub a1: u128, + pub a2: u128, + pub a3: u128, + pub a4: u128, + pub a5: u128, + pub a6: u128, + pub a7: u128, + pub s2: u128, + pub s3: u128, + pub s4: u128, + pub s5: u128, + pub s6: u128, + pub s7: u128, + pub s8: u128, + pub s9: u128, + pub s10: u128, + pub s11: u128, + pub t3: u128, + pub t4: u128, + pub t5: u128, + pub t6: u128, + // Floating registers for F, D and Q Standard Extensions + pub ft0: u128, + pub ft1: u128, + pub ft2: u128, + pub ft3: u128, + pub ft4: u128, + pub ft5: u128, + pub ft6: u128, + pub ft7: u128, + pub fs0: u128, + pub fs1: u128, + pub fa0: u128, + pub fa1: u128, + pub fa2: u128, + pub fa3: u128, + pub fa4: u128, + pub fa5: u128, + pub fa6: u128, + pub fa7: u128, + pub fs2: u128, + pub fs3: u128, + pub fs4: u128, + pub fs5: u128, + pub fs6: u128, + pub fs7: u128, + pub fs8: u128, + pub fs9: u128, + pub fs10: u128, + pub fs11: u128, + pub ft8: u128, + pub ft9: u128, + pub ft10: u128, + pub ft11: u128, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextIa32 { + // ExceptionData is additional data pushed on the stack by some types of IA-32 exceptions + pub exception_data: u32, + pub fx_save_state: FxSaveStateIA32, + pub dr0: u32, + pub dr1: u32, + pub dr2: u32, + pub dr3: u32, + pub dr6: u32, + pub dr7: u32, + pub cr0: u32, + // Reserved + pub cr1: u32, + pub cr2: u32, + pub cr3: u32, + pub cr4: u32, + pub eflags: u32, + pub ldtr: u32, + pub tr: u32, + pub gdtr: [u32; 2], + pub idtr: [u32; 2], + pub eip: u32, + pub gs: u32, + pub fs: u32, + pub es: u32, + pub ds: u32, + pub cs: u32, + pub ss: u32, + pub edi: u32, + pub esi: u32, + pub ebp: u32, + pub esp: u32, + pub ebx: u32, + pub edx: u32, + pub ecx: u32, + pub eax: u32, +} + +// FXSAVE_STATE - FP / MMX / XMM registers +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FxSaveStateIA32 { + pub fcw: u16, + pub fsw: u16, + pub ftw: u16, + pub opcode: u16, + pub eip: u32, + pub cs: u16, + pub reserved_1: u16, + pub data_offset: u32, + pub ds: u16, + pub reserved_2: [u8; 10], + pub st0mm0: [u8; 10], + pub reserved_3: [u8; 6], + pub st1mm1: [u8; 10], + pub reserved_4: [u8; 6], + pub st2mm2: [u8; 10], + pub reserved_5: [u8; 6], + pub st3mm3: [u8; 10], + pub reserved_6: [u8; 6], + pub st4mm4: [u8; 10], + pub reserved_7: [u8; 6], + pub st5mm5: [u8; 10], + pub reserved_8: [u8; 6], + pub st6mm6: [u8; 10], + pub reserved_9: [u8; 6], + pub st7mm7: [u8; 10], + pub reserved_10: [u8; 6], + pub xmm0: [u8; 16], + pub xmm1: [u8; 16], + pub xmm2: [u8; 16], + pub xmm3: [u8; 16], + pub xmm4: [u8; 16], + pub xmm5: [u8; 16], + pub xmm6: [u8; 16], + pub xmm7: [u8; 16], + pub reserved_11: [u8; 14 * 16], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextX64 { + // ExceptionData is additional data pushed on the stack by some types of x64 64-bit mode exceptions + pub exception_data: u64, + pub fx_save_state: FxSaveStateX64, + pub dr0: u64, + pub dr1: u64, + pub dr2: u64, + pub dr3: u64, + pub dr6: u64, + pub dr7: u64, + pub cr0: u64, + // Reserved + pub cr1: u64, + pub cr2: u64, + pub cr3: u64, + pub cr4: u64, + pub cr8: u64, + pub rflags: u64, + pub ldtr: u64, + pub tr: u64, + pub gdtr: [u64; 2], + pub idtr: [u64; 2], + pub rip: u64, + pub gs: u64, + pub fs: u64, + pub es: u64, + pub ds: u64, + pub cs: u64, + pub ss: u64, + pub rdi: u64, + pub rsi: u64, + pub rbp: u64, + pub rsp: u64, + pub rbx: u64, + pub rdx: u64, + pub rcx: u64, + pub rax: u64, + pub r8: u64, + pub r9: u64, + pub r10: u64, + pub r11: u64, + pub r12: u64, + pub r13: u64, + pub r14: u64, + pub r15: u64, +} + +// FXSAVE_STATE – FP / MMX / XMM registers +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FxSaveStateX64 { + pub fcw: u16, + pub fsw: u16, + pub ftw: u16, + pub opcode: u16, + pub rip: u64, + pub data_offset: u64, + pub reserved_1: [u8; 8], + pub st0mm0: [u8; 10], + pub reserved_2: [u8; 6], + pub st1mm1: [u8; 10], + pub reserved_3: [u8; 6], + pub st2mm2: [u8; 10], + pub reserved_4: [u8; 6], + pub st3mm3: [u8; 10], + pub reserved_5: [u8; 6], + pub st4mm4: [u8; 10], + pub reserved_6: [u8; 6], + pub st5mm5: [u8; 10], + pub reserved_7: [u8; 6], + pub st6mm6: [u8; 10], + pub reserved_8: [u8; 6], + pub st7mm7: [u8; 10], + pub reserved_9: [u8; 6], + pub xmm0: [u8; 16], + pub xmm1: [u8; 16], + pub xmm2: [u8; 16], + pub xmm3: [u8; 16], + pub xmm4: [u8; 16], + pub xmm5: [u8; 16], + pub xmm6: [u8; 16], + pub xmm7: [u8; 16], + pub reserved_11: [u8; 14 * 16], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextIpf { + pub reserved: u64, + pub r1: u64, + pub r2: u64, + pub r3: u64, + pub r4: u64, + pub r5: u64, + pub r6: u64, + pub r7: u64, + pub r8: u64, + pub r9: u64, + pub r10: u64, + pub r11: u64, + pub r12: u64, + pub r13: u64, + pub r14: u64, + pub r15: u64, + pub r16: u64, + pub r17: u64, + pub r18: u64, + pub r19: u64, + pub r20: u64, + pub r21: u64, + pub r22: u64, + pub r23: u64, + pub r24: u64, + pub r25: u64, + pub r26: u64, + pub r27: u64, + pub r28: u64, + pub r29: u64, + pub r30: u64, + pub r31: u64, + pub f2: [u64; 2], + pub f3: [u64; 2], + pub f4: [u64; 2], + pub f5: [u64; 2], + pub f6: [u64; 2], + pub f7: [u64; 2], + pub f8: [u64; 2], + pub f9: [u64; 2], + pub f10: [u64; 2], + pub f11: [u64; 2], + pub f12: [u64; 2], + pub f13: [u64; 2], + pub f14: [u64; 2], + pub f15: [u64; 2], + pub f16: [u64; 2], + pub f17: [u64; 2], + pub f18: [u64; 2], + pub f19: [u64; 2], + pub f20: [u64; 2], + pub f21: [u64; 2], + pub f22: [u64; 2], + pub f23: [u64; 2], + pub f24: [u64; 2], + pub f25: [u64; 2], + pub f26: [u64; 2], + pub f27: [u64; 2], + pub f28: [u64; 2], + pub f29: [u64; 2], + pub f30: [u64; 2], + pub f31: [u64; 2], + pub pr: u64, + pub b0: u64, + pub b1: u64, + pub b2: u64, + pub b3: u64, + pub b4: u64, + pub b5: u64, + pub b6: u64, + pub b7: u64, + // application registers + pub ar_rsc: u64, + pub ar_bsp: u64, + pub ar_bspstore: u64, + pub ar_rnat: u64, + pub ar_fcr: u64, + pub ar_eflag: u64, + pub ar_csd: u64, + pub ar_ssd: u64, + pub ar_cflg: u64, + pub ar_fsr: u64, + pub ar_fir: u64, + pub ar_fdr: u64, + pub ar_ccv: u64, + pub ar_unat: u64, + pub ar_fpsr: u64, + pub ar_pfs: u64, + pub ar_lc: u64, + pub ar_ec: u64, + // control registers + pub cr_dcr: u64, + pub cr_itm: u64, + pub cr_iva: u64, + pub cr_pta: u64, + pub cr_ipsr: u64, + pub cr_isr: u64, + pub cr_iip: u64, + pub cr_ifa: u64, + pub cr_itir: u64, + pub cr_iipa: u64, + pub cr_ifs: u64, + pub cr_iim: u64, + pub cr_iha: u64, + // debug registers + pub dbr0: u64, + pub dbr1: u64, + pub dbr2: u64, + pub dbr3: u64, + pub dbr4: u64, + pub dbr5: u64, + pub dbr6: u64, + pub dbr7: u64, + pub ibr0: u64, + pub ibr1: u64, + pub ibr2: u64, + pub ibr3: u64, + pub ibr4: u64, + pub ibr5: u64, + pub ibr6: u64, + pub ibr7: u64, + // virtual Registers + pub int_nat: u64, // nat bits for r1-r31 +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextArm { + pub r0: u32, + pub r1: u32, + pub r2: u32, + pub r3: u32, + pub r4: u32, + pub r5: u32, + pub r6: u32, + pub r7: u32, + pub r8: u32, + pub r9: u32, + pub r10: u32, + pub r11: u32, + pub r12: u32, + pub sp: u32, + pub lr: u32, + pub pc: u32, + pub cpsr: u32, + pub dfsr: u32, + pub dfar: u32, + pub ifsr: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemContextAArch64 { + // General Purpose Registers + pub x0: u64, + pub x1: u64, + pub x2: u64, + pub x3: u64, + pub x4: u64, + pub x5: u64, + pub x6: u64, + pub x7: u64, + pub x8: u64, + pub x9: u64, + pub x10: u64, + pub x11: u64, + pub x12: u64, + pub x13: u64, + pub x14: u64, + pub x15: u64, + pub x16: u64, + pub x17: u64, + pub x18: u64, + pub x19: u64, + pub x20: u64, + pub x21: u64, + pub x22: u64, + pub x23: u64, + pub x24: u64, + pub x25: u64, + pub x26: u64, + pub x27: u64, + pub x28: u64, + pub fp: u64, // x29 - Frame Pointer + pub lr: u64, // x30 - Link Register + pub sp: u64, // x31 - Stack Pointer + // FP/SIMD Registers + pub v0: [u64; 2], + pub v1: [u64; 2], + pub v2: [u64; 2], + pub v3: [u64; 2], + pub v4: [u64; 2], + pub v5: [u64; 2], + pub v6: [u64; 2], + pub v7: [u64; 2], + pub v8: [u64; 2], + pub v9: [u64; 2], + pub v10: [u64; 2], + pub v11: [u64; 2], + pub v12: [u64; 2], + pub v13: [u64; 2], + pub v14: [u64; 2], + pub v15: [u64; 2], + pub v16: [u64; 2], + pub v17: [u64; 2], + pub v18: [u64; 2], + pub v19: [u64; 2], + pub v20: [u64; 2], + pub v21: [u64; 2], + pub v22: [u64; 2], + pub v23: [u64; 2], + pub v24: [u64; 2], + pub v25: [u64; 2], + pub v26: [u64; 2], + pub v27: [u64; 2], + pub v28: [u64; 2], + pub v29: [u64; 2], + pub v30: [u64; 2], + pub v31: [u64; 2], + pub elr: u64, // Exception Link Register + pub spsr: u64, // Saved Processor Status Register + pub fpsr: u64, // Floating Point Status Register + pub esr: u64, // Exception Syndrome Register + pub far: u64, // Fault Address Register +} + +pub type ExceptionType = isize; + +// EBC Exception types +pub const EXCEPT_EBC_UNDEFINED: ExceptionType = 0; +pub const EXCEPT_EBC_DIVIDE_ERROR: ExceptionType = 1; +pub const EXCEPT_EBC_DEBUG: ExceptionType = 2; +pub const EXCEPT_EBC_BREAKPOINT: ExceptionType = 3; +pub const EXCEPT_EBC_OVERFLOW: ExceptionType = 4; +pub const EXCEPT_EBC_INVALID_OPCODE: ExceptionType = 5; +pub const EXCEPT_EBC_STACK_FAULT: ExceptionType = 6; +pub const EXCEPT_EBC_ALIGNMENT_CHECK: ExceptionType = 7; +pub const EXCEPT_EBC_INSTRUCTION_ENCODING: ExceptionType = 8; +pub const EXCEPT_EBC_BAD_BREAK: ExceptionType = 9; +pub const EXCEPT_EBC_SINGLE_STEP: ExceptionType = 10; + +// IA-32 Exception types +pub const EXCEPT_IA32_DIVIDE_ERROR: ExceptionType = 0; +pub const EXCEPT_IA32_DEBUG: ExceptionType = 1; +pub const EXCEPT_IA32_NMI: ExceptionType = 2; +pub const EXCEPT_IA32_BREAKPOINT: ExceptionType = 3; +pub const EXCEPT_IA32_OVERFLOW: ExceptionType = 4; +pub const EXCEPT_IA32_BOUND: ExceptionType = 5; +pub const EXCEPT_IA32_INVALID_OPCODE: ExceptionType = 6; +pub const EXCEPT_IA32_DOUBLE_FAULT: ExceptionType = 8; +pub const EXCEPT_IA32_INVALID_TSS: ExceptionType = 10; +pub const EXCEPT_IA32_SEG_NOT_PRESENT: ExceptionType = 11; +pub const EXCEPT_IA32_STACK_FAULT: ExceptionType = 12; +pub const EXCEPT_IA32_GP_FAULT: ExceptionType = 13; +pub const EXCEPT_IA32_PAGE_FAULT: ExceptionType = 14; +pub const EXCEPT_IA32_FP_ERROR: ExceptionType = 16; +pub const EXCEPT_IA32_ALIGNMENT_CHECK: ExceptionType = 17; +pub const EXCEPT_IA32_MACHINE_CHECK: ExceptionType = 18; +pub const EXCEPT_IA32_SIMD: ExceptionType = 19; + +// X64 Exception types +pub const EXCEPT_X64_DIVIDE_ERROR: ExceptionType = 0; +pub const EXCEPT_X64_DEBUG: ExceptionType = 1; +pub const EXCEPT_X64_NMI: ExceptionType = 2; +pub const EXCEPT_X64_BREAKPOINT: ExceptionType = 3; +pub const EXCEPT_X64_OVERFLOW: ExceptionType = 4; +pub const EXCEPT_X64_BOUND: ExceptionType = 5; +pub const EXCEPT_X64_INVALID_OPCODE: ExceptionType = 6; +pub const EXCEPT_X64_DOUBLE_FAULT: ExceptionType = 8; +pub const EXCEPT_X64_INVALID_TSS: ExceptionType = 10; +pub const EXCEPT_X64_SEG_NOT_PRESENT: ExceptionType = 11; +pub const EXCEPT_X64_STACK_FAULT: ExceptionType = 12; +pub const EXCEPT_X64_GP_FAULT: ExceptionType = 13; +pub const EXCEPT_X64_PAGE_FAULT: ExceptionType = 14; +pub const EXCEPT_X64_FP_ERROR: ExceptionType = 16; +pub const EXCEPT_X64_ALIGNMENT_CHECK: ExceptionType = 17; +pub const EXCEPT_X64_MACHINE_CHECK: ExceptionType = 18; +pub const EXCEPT_X64_SIMD: ExceptionType = 19; + +// Itanium Processor Family Exception types +pub const EXCEPT_IPF_VHTP_TRANSLATION: ExceptionType = 0; +pub const EXCEPT_IPF_INSTRUCTION_TLB: ExceptionType = 1; +pub const EXCEPT_IPF_DATA_TLB: ExceptionType = 2; +pub const EXCEPT_IPF_ALT_INSTRUCTION_TLB: ExceptionType = 3; +pub const EXCEPT_IPF_ALT_DATA_TLB: ExceptionType = 4; +pub const EXCEPT_IPF_DATA_NESTED_TLB: ExceptionType = 5; +pub const EXCEPT_IPF_INSTRUCTION_KEY_MISSED: ExceptionType = 6; +pub const EXCEPT_IPF_DATA_KEY_MISSED: ExceptionType = 7; +pub const EXCEPT_IPF_DIRTY_BIT: ExceptionType = 8; +pub const EXCEPT_IPF_INSTRUCTION_ACCESS_BIT: ExceptionType = 9; +pub const EXCEPT_IPF_DATA_ACCESS_BIT: ExceptionType = 10; +pub const EXCEPT_IPF_BREAKPOINT: ExceptionType = 11; +pub const EXCEPT_IPF_EXTERNAL_INTERRUPT: ExceptionType = 12; +// 13 - 19 reserved +pub const EXCEPT_IPF_PAGE_NOT_PRESENT: ExceptionType = 20; +pub const EXCEPT_IPF_KEY_PERMISSION: ExceptionType = 21; +pub const EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS: ExceptionType = 22; +pub const EXCEPT_IPF_DATA_ACCESS_RIGHTS: ExceptionType = 23; +pub const EXCEPT_IPF_GENERAL_EXCEPTION: ExceptionType = 24; +pub const EXCEPT_IPF_DISABLED_FP_REGISTER: ExceptionType = 25; +pub const EXCEPT_IPF_NAT_CONSUMPTION: ExceptionType = 26; +pub const EXCEPT_IPF_SPECULATION: ExceptionType = 27; +// 28 reserved +pub const EXCEPT_IPF_DEBUG: ExceptionType = 29; +pub const EXCEPT_IPF_UNALIGNED_REFERENCE: ExceptionType = 30; +pub const EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE: ExceptionType = 31; +pub const EXCEPT_IPF_FP_FAULT: ExceptionType = 32; +pub const EXCEPT_IPF_FP_TRAP: ExceptionType = 33; +pub const EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP: ExceptionType = 34; +pub const EXCEPT_IPF_TAKEN_BRANCH: ExceptionType = 35; +pub const EXCEPT_IPF_SINGLE_STEP: ExceptionType = 36; +// 37 - 44 reserved +pub const EXCEPT_IPF_IA32_EXCEPTION: ExceptionType = 45; +pub const EXCEPT_IPF_IA32_INTERCEPT: ExceptionType = 46; +pub const EXCEPT_IPF_IA32_INTERRUPT: ExceptionType = 47; + +// ARM processor exception types +pub const EXCEPT_ARM_RESET: ExceptionType = 0; +pub const EXCEPT_ARM_UNDEFINED_INSTRUCTION: ExceptionType = 1; +pub const EXCEPT_ARM_SOFTWARE_INTERRUPT: ExceptionType = 2; +pub const EXCEPT_ARM_PREFETCH_ABORT: ExceptionType = 3; +pub const EXCEPT_ARM_DATA_ABORT: ExceptionType = 4; +pub const EXCEPT_ARM_RESERVED: ExceptionType = 5; +pub const EXCEPT_ARM_IRQ: ExceptionType = 6; +pub const EXCEPT_ARM_FIQ: ExceptionType = 7; +pub const MAX_ARM_EXCEPTION: ExceptionType = EXCEPT_ARM_FIQ; + +// AARCH64 processor exception types. +pub const EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS: ExceptionType = 0; +pub const EXCEPT_AARCH64_IRQ: ExceptionType = 1; +pub const EXCEPT_AARCH64_FIQ: ExceptionType = 2; +pub const EXCEPT_AARCH64_SERROR: ExceptionType = 3; +pub const MAX_AARCH64_EXCEPTION: ExceptionType = EXCEPT_AARCH64_SERROR; + +// RISC-V processor exception types. +pub const EXCEPT_RISCV_INST_MISALIGNED: ExceptionType = 0; +pub const EXCEPT_RISCV_INST_ACCESS_FAULT: ExceptionType = 1; +pub const EXCEPT_RISCV_ILLEGAL_INST: ExceptionType = 2; +pub const EXCEPT_RISCV_BREAKPOINT: ExceptionType = 3; +pub const EXCEPT_RISCV_LOAD_ADDRESS_MISALIGNED: ExceptionType = 4; +pub const EXCEPT_RISCV_LOAD_ACCESS_FAULT: ExceptionType = 5; +pub const EXCEPT_RISCV_STORE_AMO_ADDRESS_MISALIGNED: ExceptionType = 6; +pub const EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT: ExceptionType = 7; +pub const EXCEPT_RISCV_ENV_CALL_FROM_UMODE: ExceptionType = 8; +pub const EXCEPT_RISCV_ENV_CALL_FROM_SMODE: ExceptionType = 9; +pub const EXCEPT_RISCV_ENV_CALL_FROM_MMODE: ExceptionType = 11; +pub const EXCEPT_RISCV_INST_PAGE_FAULT: ExceptionType = 12; +pub const EXCEPT_RISCV_LOAD_PAGE_FAULT: ExceptionType = 13; +pub const EXCEPT_RISCV_STORE_AMO_PAGE_FAULT: ExceptionType = 15; + +// RISC-V processor interrupt types. +pub const EXCEPT_RISCV_SUPERVISOR_SOFTWARE_INT: ExceptionType = 1; +pub const EXCEPT_RISCV_MACHINE_SOFTWARE_INT: ExceptionType = 3; +pub const EXCEPT_RISCV_SUPERVISOR_TIMER_INT: ExceptionType = 5; +pub const EXCEPT_RISCV_MACHINE_TIMER_INT: ExceptionType = 7; +pub const EXCEPT_RISCV_SUPERVISOR_EXTERNAL_INT: ExceptionType = 9; +pub const EXCEPT_RISCV_MACHINE_EXTERNAL_INT: ExceptionType = 11; + +pub type GetMaximumProcessorIndex = eficall! {fn( + *mut Protocol, + *mut usize, +) -> crate::base::Status}; + +pub type PeriodicCallback = eficall! {fn(SystemContext)}; + +pub type RegisterPeriodicCallback = eficall! {fn( + *mut Protocol, + usize, + Option, +) -> crate::base::Status}; + +pub type ExceptionCallback = eficall! {fn(ExceptionType, SystemContext)}; + +pub type RegisterExceptionCallback = eficall! {fn( + *mut Protocol, + usize, + Option, + ExceptionType, +) -> crate::base::Status}; + +pub type InvalidateInstructionCache = eficall! {fn( + *mut Protocol, + usize, + *mut core::ffi::c_void, + u64, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub isa: InstructionSetArchitecture, + pub get_maximum_processor_index: GetMaximumProcessorIndex, + pub register_periodic_callback: RegisterPeriodicCallback, + pub register_exception_callback: RegisterExceptionCallback, + pub invalidate_instruction_cache: InvalidateInstructionCache, +} diff --git a/vendor/r-efi/src/protocols/debugport.rs b/vendor/r-efi/src/protocols/debugport.rs new file mode 100644 index 000000000..a335fd971 --- /dev/null +++ b/vendor/r-efi/src/protocols/debugport.rs @@ -0,0 +1,42 @@ +//! Debug Port Protocol +//! +//! It provides the communication link between the debug agent and the remote host. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xeba4e8d2, + 0x3858, + 0x41ec, + 0xa2, + 0x81, + &[0x26, 0x47, 0xba, 0x96, 0x60, 0xd0], +); + +pub type Reset = eficall! {fn( + *mut Protocol, +) -> *mut crate::base::Status}; + +pub type Write = eficall! {fn( + *mut Protocol, + u32, + *mut usize, + *mut core::ffi::c_void +) -> *mut crate::base::Status}; + +pub type Read = eficall! {fn( + *mut Protocol, + u32, + *mut usize, + *mut core::ffi::c_void +) -> *mut crate::base::Status}; + +pub type Poll = eficall! {fn( + *mut Protocol, +) -> *mut crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub reset: Reset, + pub write: Write, + pub read: Read, + pub poll: Poll, +} diff --git a/vendor/r-efi/src/protocols/decompress.rs b/vendor/r-efi/src/protocols/decompress.rs new file mode 100644 index 000000000..640369ad0 --- /dev/null +++ b/vendor/r-efi/src/protocols/decompress.rs @@ -0,0 +1,37 @@ +//! Decompress Protocol +//! +//! The decompress protocol provides a decompression service that allows a compressed source +//! buffer in memory to be decompressed into a destination buffer in memory. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xd8117cfe, + 0x94a6, + 0x11d4, + 0x9a, + 0x3a, + &[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d], +); + +pub type ProtocolGetInfo = eficall! {fn( + *mut Protocol, + *mut core::ffi::c_void, + u32, + *mut u32, + *mut u32, +) -> crate::base::Status}; + +pub type ProtocolDecompress = eficall! {fn( + *mut Protocol, + *mut core::ffi::c_void, + u32, + *mut core::ffi::c_void, + u32, + *mut core::ffi::c_void, + u32, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_info: ProtocolGetInfo, + pub decompress: ProtocolDecompress, +} diff --git a/vendor/r-efi/src/protocols/device_path.rs b/vendor/r-efi/src/protocols/device_path.rs new file mode 100644 index 000000000..98fcc094e --- /dev/null +++ b/vendor/r-efi/src/protocols/device_path.rs @@ -0,0 +1,66 @@ +//! Device Path Protocol +//! +//! The device path protocol defines how to obtain generic path/location information +//! concerning the phisycal or logical device. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x09576e91, + 0x6d3f, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +pub const TYPE_HARDWARE: u8 = 0x01; +pub const TYPE_ACPI: u8 = 0x02; +pub const TYPE_MESSAGING: u8 = 0x03; +pub const TYPE_MEDIA: u8 = 0x04; +pub const TYPE_BIOS: u8 = 0x05; +pub const TYPE_END: u8 = 0x7f; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Protocol { + pub r#type: u8, + pub sub_type: u8, + pub length: [u8; 2], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct End { + pub header: Protocol, +} + +impl End { + pub const SUBTYPE_INSTANCE: u8 = 0x01; + pub const SUBTYPE_ENTIRE: u8 = 0xff; +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Hardware { + pub header: Protocol, +} + +impl Hardware { + pub const SUBTYPE_PCI: u8 = 0x01; + pub const SUBTYPE_PCCARD: u8 = 0x02; + pub const SUBTYPE_MMAP: u8 = 0x03; + pub const SUBTYPE_VENDOR: u8 = 0x04; + pub const SUBTYPE_CONTROLLER: u8 = 0x05; + pub const SUBTYPE_BMC: u8 = 0x06; +} + +#[repr(C, packed)] +#[derive(Clone, Copy, Debug)] +pub struct HardDriveMedia { + pub header: Protocol, + pub partition_number: u32, + pub partition_start: u64, + pub partition_size: u64, + pub partition_signature: [u8; 16], + pub partition_format: u8, + pub signature_type: u8, +} diff --git a/vendor/r-efi/src/protocols/device_path_from_text.rs b/vendor/r-efi/src/protocols/device_path_from_text.rs new file mode 100644 index 000000000..b9191edd9 --- /dev/null +++ b/vendor/r-efi/src/protocols/device_path_from_text.rs @@ -0,0 +1,26 @@ +//! Device Path From Text Protocol +//! +//! Convert text to device paths and device nodes. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x5c99a21, + 0xc70f, + 0x4ad2, + 0x8a, + 0x5f, + &[0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e], +); + +pub type DevicePathFromTextNode = eficall! {fn( + *const crate::base::Char16, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type DevicePathFromTextPath = eficall! {fn( + *const crate::base::Char16, +) -> *mut crate::protocols::device_path::Protocol}; + +#[repr(C)] +pub struct Protocol { + pub convert_text_to_device_node: DevicePathFromTextNode, + pub convert_text_to_device_path: DevicePathFromTextPath, +} diff --git a/vendor/r-efi/src/protocols/device_path_to_text.rs b/vendor/r-efi/src/protocols/device_path_to_text.rs new file mode 100644 index 000000000..c0b98337e --- /dev/null +++ b/vendor/r-efi/src/protocols/device_path_to_text.rs @@ -0,0 +1,30 @@ +//! Device Path to Text Protocol +//! +//! Convert device nodes and paths to text. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x8b843e20, + 0x8132, + 0x4852, + 0x90, + 0xcc, + &[0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c], +); + +pub type DevicePathToTextNode = eficall! {fn( + *mut crate::protocols::device_path::Protocol, + crate::base::Boolean, + crate::base::Boolean, +) -> *mut crate::base::Char16}; + +pub type DevicePathToTextPath = eficall! {fn( + *mut crate::protocols::device_path::Protocol, + crate::base::Boolean, + crate::base::Boolean, +) -> *mut crate::base::Char16}; + +#[repr(C)] +pub struct Protocol { + pub convert_device_node_to_text: DevicePathToTextNode, + pub convert_device_path_to_text: DevicePathToTextPath, +} diff --git a/vendor/r-efi/src/protocols/device_path_utilities.rs b/vendor/r-efi/src/protocols/device_path_utilities.rs new file mode 100644 index 000000000..d34aea819 --- /dev/null +++ b/vendor/r-efi/src/protocols/device_path_utilities.rs @@ -0,0 +1,63 @@ +//! Device Path Utilities Protocol +//! +//! The device-path utilities protocol provides common utilities for creating and manipulating +//! device paths and device nodes. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x379be4e, + 0xd706, + 0x437d, + 0xb0, + 0x37, + &[0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4], +); + +pub type ProtocolGetDevicePathSize = eficall! {fn( + *const crate::protocols::device_path::Protocol, +) -> usize}; + +pub type ProtocolDuplicateDevicePath = eficall! {fn( + *const crate::protocols::device_path::Protocol, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type ProtocolAppendDevicePath = eficall! {fn( + *const crate::protocols::device_path::Protocol, + *const crate::protocols::device_path::Protocol, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type ProtocolAppendDeviceNode = eficall! {fn( + *const crate::protocols::device_path::Protocol, + *const crate::protocols::device_path::Protocol, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type ProtocolAppendDevicePathInstance = eficall! {fn( + *const crate::protocols::device_path::Protocol, + *const crate::protocols::device_path::Protocol, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type ProtocolGetNextDevicePathInstance = eficall! {fn( + *mut *mut crate::protocols::device_path::Protocol, + *mut usize, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type ProtocolIsDevicePathMultiInstance = eficall! {fn( + *const crate::protocols::device_path::Protocol, +) -> crate::base::Boolean}; + +pub type ProtocolCreateDeviceNode = eficall! {fn( + u8, + u8, + u16, +) -> *mut crate::protocols::device_path::Protocol}; + +#[repr(C)] +pub struct Protocol { + pub get_device_path_size: ProtocolGetDevicePathSize, + pub duplicate_device_path: ProtocolDuplicateDevicePath, + pub append_device_path: ProtocolAppendDevicePath, + pub append_device_node: ProtocolAppendDeviceNode, + pub append_device_path_instance: ProtocolAppendDevicePathInstance, + pub get_next_device_path_instance: ProtocolGetNextDevicePathInstance, + pub is_device_path_multi_instance: ProtocolIsDevicePathMultiInstance, + pub create_device_node: ProtocolCreateDeviceNode, +} diff --git a/vendor/r-efi/src/protocols/disk_io.rs b/vendor/r-efi/src/protocols/disk_io.rs new file mode 100644 index 000000000..dd3093f13 --- /dev/null +++ b/vendor/r-efi/src/protocols/disk_io.rs @@ -0,0 +1,40 @@ +//! Disk I/O Protocol +//! +//! Abstracts block accesses of the Block I/O protocol to a more general offset-length protocol. +//! Firmware is responsible for adding this protocol to any Block I/O interface that appears +//! in the system that does not already have a Disk I/O protocol. File systems and other disk +//! access code utilize the Disk I/O protocol. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xce345171, + 0xba0b, + 0x11d2, + 0x8e, + 0x4f, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +pub const REVISION: u64 = 0x0000000000010000u64; + +pub type ProtocolReadDisk = eficall! {fn( + *mut Protocol, + u32, + u64, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolWriteDisk = eficall! {fn( + *mut Protocol, + u32, + u64, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub read_disk: ProtocolReadDisk, + pub write_disk: ProtocolWriteDisk, +} diff --git a/vendor/r-efi/src/protocols/disk_io2.rs b/vendor/r-efi/src/protocols/disk_io2.rs new file mode 100644 index 000000000..777ed4b44 --- /dev/null +++ b/vendor/r-efi/src/protocols/disk_io2.rs @@ -0,0 +1,58 @@ +//! Disk I/O 2 Protocol +//! +//! Extends the Disk I/O protocol interface to enable non-blocking / +//! asynchronous byte-oriented disk operation. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x151c8eae, + 0x7f2c, + 0x472c, + 0x9e, + 0x54, + &[0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88], +); + +pub const REVISION: u64 = 0x0000000000020000u64; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Token { + event: crate::base::Event, + transaction_status: crate::base::Status, +} + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolReadDiskEx = eficall! {fn( + *mut Protocol, + u32, + u64, + *mut Token, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolWriteDiskEx = eficall! {fn( + *mut Protocol, + u32, + u64, + *mut Token, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolFlushDiskEx = eficall! {fn( + *mut Protocol, + *mut Token, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub cancel: ProtocolCancel, + pub read_disk_ex: ProtocolReadDiskEx, + pub write_disk_ex: ProtocolWriteDiskEx, + pub flush_disk_ex: ProtocolFlushDiskEx, +} diff --git a/vendor/r-efi/src/protocols/driver_binding.rs b/vendor/r-efi/src/protocols/driver_binding.rs new file mode 100644 index 000000000..7ba2ee328 --- /dev/null +++ b/vendor/r-efi/src/protocols/driver_binding.rs @@ -0,0 +1,42 @@ +//! Driver Binding Protocol +//! +//! Provides the services required to determine if a driver supports a given controller. If +//! a controller is supported, then it also provides routines to start and stop the controller. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x18a031ab, + 0xb443, + 0x4d1a, + 0xa5, + 0xc0, + &[0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71], +); + +pub type ProtocolSupported = eficall! {fn( + *mut Protocol, + crate::base::Handle, + *mut crate::protocols::device_path::Protocol, +) -> crate::base::Status}; + +pub type ProtocolStart = eficall! {fn( + *mut Protocol, + crate::base::Handle, + *mut crate::protocols::device_path::Protocol, +) -> crate::base::Status}; + +pub type ProtocolStop = eficall! {fn( + *mut Protocol, + crate::base::Handle, + usize, + *mut crate::base::Handle, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub supported: ProtocolSupported, + pub start: ProtocolStart, + pub stop: ProtocolStop, + pub version: u32, + pub image_handle: crate::base::Handle, + pub driver_binding_handle: crate::base::Handle, +} diff --git a/vendor/r-efi/src/protocols/driver_diagnostics2.rs b/vendor/r-efi/src/protocols/driver_diagnostics2.rs new file mode 100644 index 000000000..dff5bd446 --- /dev/null +++ b/vendor/r-efi/src/protocols/driver_diagnostics2.rs @@ -0,0 +1,38 @@ +//! Driver Diagnostics Protocol +//! +//! Defined in UEFI Specification, Section 11.4 +//! Used to perform diagnostics on a controller that a UEFI driver is managing. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x4d330321, + 0x025f, + 0x4aac, + 0x90, + 0xd8, + &[0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63], +); + +pub type Type = u32; + +pub const TYPE_STANDARD: Type = 0; +pub const TYPE_EXTENDED: Type = 1; +pub const TYPE_MANUFACTURING: Type = 2; +pub const TYPE_CANCEL: Type = 3; +pub const TYPE_MAXIMUM: Type = 4; + +pub type RunDiagnostics = eficall! {fn( + *mut Protocol, + crate::base::Handle, + crate::base::Handle, + Type, + *mut crate::base::Char8, + *mut *mut crate::base::Guid, + *mut usize, + *mut *mut crate::base::Char16, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub run_diagnostics: RunDiagnostics, + pub supported_languages: *mut crate::base::Char8, +} diff --git a/vendor/r-efi/src/protocols/file.rs b/vendor/r-efi/src/protocols/file.rs new file mode 100644 index 000000000..4a66ce294 --- /dev/null +++ b/vendor/r-efi/src/protocols/file.rs @@ -0,0 +1,183 @@ +//! File Protocol +//! +//! Provides an interface to interact with both files and directories. This protocol is typically +//! obtained via an EFI_SIMPLE_FILE_SYSTEM protocol or via another EFI_FILE_PROTOCOL. + +pub const REVISION: u64 = 0x0000_0000_0001_0000u64; +pub const REVISION2: u64 = 0x0000_0000_0002_0000u64; +pub const LATEST_REVISION: u64 = REVISION2; + +pub const MODE_READ: u64 = 0x0000000000000001u64; +pub const MODE_WRITE: u64 = 0x0000000000000002u64; +pub const MODE_CREATE: u64 = 0x8000000000000000u64; + +pub const READ_ONLY: u64 = 0x0000000000000001u64; +pub const HIDDEN: u64 = 0x0000000000000002u64; +pub const SYSTEM: u64 = 0x0000000000000004u64; +pub const RESERVED: u64 = 0x0000000000000008u64; +pub const DIRECTORY: u64 = 0x0000000000000010u64; +pub const ARCHIVE: u64 = 0x0000000000000020u64; +pub const VALID_ATTR: u64 = 0x0000000000000037u64; + +pub const INFO_ID: crate::base::Guid = crate::base::Guid::from_fields( + 0x09576e92, + 0x6d3f, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); +pub const SYSTEM_INFO_ID: crate::base::Guid = crate::base::Guid::from_fields( + 0x09576e93, + 0x6d3f, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); +pub const SYSTEM_VOLUME_LABEL_ID: crate::base::Guid = crate::base::Guid::from_fields( + 0xdb47d7d3, + 0xfe81, + 0x11d3, + 0x9a, + 0x35, + &[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IoToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub buffer_size: usize, + pub buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Info { + pub size: u64, + pub file_size: u64, + pub physical_size: u64, + pub create_time: crate::system::Time, + pub last_access_time: crate::system::Time, + pub modification_time: crate::system::Time, + pub attribute: u64, + pub file_name: [crate::base::Char16; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemInfo { + pub size: u64, + pub read_only: crate::base::Boolean, + pub volume_size: u64, + pub free_space: u64, + pub block_size: u32, + pub volume_label: [crate::base::Char16; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct SystemVolumeLabel { + pub volume_label: [crate::base::Char16; N], +} + +pub type ProtocolOpen = eficall! {fn( + *mut Protocol, + *mut *mut Protocol, + *mut crate::base::Char16, + u64, + u64, +) -> crate::base::Status}; + +pub type ProtocolClose = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolDelete = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolRead = eficall! {fn( + *mut Protocol, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolWrite = eficall! {fn( + *mut Protocol, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolGetPosition = eficall! {fn( + *mut Protocol, + *mut u64, +) -> crate::base::Status}; + +pub type ProtocolSetPosition = eficall! {fn( + *mut Protocol, + u64, +) -> crate::base::Status}; + +pub type ProtocolGetInfo = eficall! {fn( + *mut Protocol, + *mut crate::base::Guid, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolSetInfo = eficall! {fn( + *mut Protocol, + *mut crate::base::Guid, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolFlush = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolOpenEx = eficall! {fn( + *mut Protocol, + *mut *mut Protocol, + *mut crate::base::Char16, + u64, + u64, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolReadEx = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolWriteEx = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolFlushEx = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub open: ProtocolOpen, + pub close: ProtocolClose, + pub delete: ProtocolDelete, + pub read: ProtocolRead, + pub write: ProtocolWrite, + pub get_position: ProtocolGetPosition, + pub set_position: ProtocolSetPosition, + pub get_info: ProtocolGetInfo, + pub set_info: ProtocolSetInfo, + pub flush: ProtocolFlush, + pub open_ex: ProtocolOpenEx, + pub read_ex: ProtocolReadEx, + pub write_ex: ProtocolWriteEx, + pub flush_ex: ProtocolFlushEx, +} diff --git a/vendor/r-efi/src/protocols/graphics_output.rs b/vendor/r-efi/src/protocols/graphics_output.rs new file mode 100644 index 000000000..a6a4438b8 --- /dev/null +++ b/vendor/r-efi/src/protocols/graphics_output.rs @@ -0,0 +1,103 @@ +//! Graphics Output Protocol +//! +//! Provides means to configure graphics hardware and get access to +//! framebuffers. Replaces the old UGA interface from EFI with a +//! VGA-independent API. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x9042a9de, + 0x23dc, + 0x4a38, + 0x96, + 0xfb, + &[0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct PixelBitmask { + pub red_mask: u32, + pub green_mask: u32, + pub blue_mask: u32, + pub reserved_mask: u32, +} + +pub type GraphicsPixelFormat = u32; + +pub const PIXEL_RED_GREEN_BLUE_RESERVED_8_BIT_PER_COLOR: GraphicsPixelFormat = 0x00000000; +pub const PIXEL_BLUE_GREEN_RED_RESERVED_8_BIT_PER_COLOR: GraphicsPixelFormat = 0x00000001; +pub const PIXEL_BIT_MASK: GraphicsPixelFormat = 0x00000002; +pub const PIXEL_BLT_ONLY: GraphicsPixelFormat = 0x00000003; +pub const PIXEL_FORMAT_MAX: GraphicsPixelFormat = 0x00000004; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ModeInformation { + pub version: u32, + pub horizontal_resolution: u32, + pub vertical_resolution: u32, + pub pixel_format: GraphicsPixelFormat, + pub pixel_information: PixelBitmask, + pub pixels_per_scan_line: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Mode { + pub max_mode: u32, + pub mode: u32, + pub info: *mut ModeInformation, + pub size_of_info: usize, + pub frame_buffer_base: crate::base::PhysicalAddress, + pub frame_buffer_size: usize, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct BltPixel { + pub blue: u8, + pub green: u8, + pub red: u8, + pub reserved: u8, +} + +pub type BltOperation = u32; + +pub const BLT_VIDEO_FILL: BltOperation = 0x00000000; +pub const BLT_VIDEO_TO_BLT_BUFFER: BltOperation = 0x00000001; +pub const BLT_BUFFER_TO_VIDEO: BltOperation = 0x00000002; +pub const BLT_VIDEO_TO_VIDEO: BltOperation = 0x00000003; +pub const BLT_OPERATION_MAX: BltOperation = 0x00000004; + +pub type ProtocolQueryMode = eficall! {fn( + *mut Protocol, + u32, + *mut usize, + *mut *mut ModeInformation, +) -> crate::base::Status}; + +pub type ProtocolSetMode = eficall! {fn( + *mut Protocol, + u32, +) -> crate::base::Status}; + +pub type ProtocolBlt = eficall! {fn( + *mut Protocol, + *mut BltPixel, + BltOperation, + usize, + usize, + usize, + usize, + usize, + usize, + usize, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub query_mode: ProtocolQueryMode, + pub set_mode: ProtocolSetMode, + pub blt: ProtocolBlt, + pub mode: *mut Mode, +} diff --git a/vendor/r-efi/src/protocols/hii_database.rs b/vendor/r-efi/src/protocols/hii_database.rs new file mode 100644 index 000000000..579c43cf2 --- /dev/null +++ b/vendor/r-efi/src/protocols/hii_database.rs @@ -0,0 +1,299 @@ +//! Human Interface Infrastructure (HII) Protocol +//! +//! Database manager for HII-related data structures. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xef9fc172, + 0xa1b2, + 0x4693, + 0xb3, + 0x27, + &[0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42], +); + +pub const SET_KEYBOARD_LAYOUT_EVENT_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x14982a4f, + 0xb0ed, + 0x45b8, + 0xa8, + 0x11, + &[0x5a, 0x7a, 0x9b, 0xc2, 0x32, 0xdf], +); + +pub type ProtocolNewPackageList = eficall! {fn( + *const Protocol, + *const crate::hii::PackageListHeader, + crate::base::Handle, + *mut crate::hii::Handle, +) -> crate::base::Status}; + +pub type ProtocolRemovePackageList = eficall! {fn( + *const Protocol, + crate::hii::Handle, +) -> crate::base::Status}; + +pub type ProtocolUpdatePackageList = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *const crate::hii::PackageListHeader, +) -> crate::base::Status}; + +pub type ProtocolListPackageLists = eficall! {fn( + *const Protocol, + u8, + *const crate::base::Guid, + *mut usize, + *mut crate::hii::Handle, +) -> crate::base::Status}; + +pub type ProtocolExportPackageLists = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *mut usize, + *mut crate::hii::PackageListHeader, +) -> crate::base::Status}; + +pub type ProtocolRegisterPackageNotify = eficall! {fn( + *const Protocol, + u8, + *const crate::base::Guid, + Notify, + NotifyType, + *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type ProtocolUnregisterPackageNotify = eficall! {fn( + *const Protocol, + crate::base::Handle, +) -> crate::base::Status}; + +pub type ProtocolFindKeyboardLayouts = eficall! {fn( + *const Protocol, + *mut u16, + *mut crate::base::Guid, +) -> crate::base::Status}; + +pub type ProtocolGetKeyboardLayout = eficall! {fn( + *const Protocol, + *const crate::base::Guid, + *mut u16, + *mut KeyboardLayout, +) -> crate::base::Status}; + +pub type ProtocolSetKeyboardLayout = eficall! {fn( + *const Protocol, + *mut crate::base::Guid, +) -> crate::base::Status}; + +pub type ProtocolGetPackageListHandle = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *mut crate::base::Handle, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub new_package_list: ProtocolNewPackageList, + pub remove_package_list: ProtocolRemovePackageList, + pub update_package_list: ProtocolUpdatePackageList, + pub list_package_lists: ProtocolListPackageLists, + pub export_package_lists: ProtocolExportPackageLists, + pub register_package_notify: ProtocolRegisterPackageNotify, + pub unregister_package_notify: ProtocolUnregisterPackageNotify, + pub find_keyboard_layouts: ProtocolFindKeyboardLayouts, + pub get_keyboard_layout: ProtocolGetKeyboardLayout, + pub set_keyboard_layout: ProtocolSetKeyboardLayout, + pub get_package_list_handle: ProtocolGetPackageListHandle, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct KeyboardLayout { + pub layout_length: u16, + pub guid: crate::base::Guid, + pub layout_descriptor_string_offset: u32, + pub descriptor_count: u8, + pub descriptors: [KeyDescriptor; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct KeyDescriptor { + pub key: Key, + pub unicode: crate::base::Char16, + pub shifted_unicode: crate::base::Char16, + pub alt_gr_unicode: crate::base::Char16, + pub shifted_alt_gr_unicode: crate::base::Char16, + pub modifier: u16, + pub affected_attribute: u16, +} + +pub const AFFECTED_BY_STANDARD_SHIFT: u16 = 0x0001; +pub const AFFECTED_BY_CAPS_LOCK: u16 = 0x0002; +pub const AFFECTED_BY_NUM_LOCK: u16 = 0x0004; + +pub type Key = u32; + +pub const EFI_KEY_LCTRL: Key = 0x00000000; +pub const EFI_KEY_A0: Key = 0x00000001; +pub const EFI_KEY_LALT: Key = 0x00000002; +pub const EFI_KEY_SPACE_BAR: Key = 0x00000003; +pub const EFI_KEY_A2: Key = 0x00000004; +pub const EFI_KEY_A3: Key = 0x00000005; +pub const EFI_KEY_A4: Key = 0x00000006; +pub const EFI_KEY_RCTRL: Key = 0x00000007; +pub const EFI_KEY_LEFT_ARROW: Key = 0x00000008; +pub const EFI_KEY_DOWN_ARROW: Key = 0x00000009; +pub const EFI_KEY_RIGHT_ARROW: Key = 0x0000000a; +pub const EFI_KEY_ZERO: Key = 0x0000000b; +pub const EFI_KEY_PERIOD: Key = 0x0000000c; +pub const EFI_KEY_ENTER: Key = 0x0000000d; +pub const EFI_KEY_LSHIFT: Key = 0x0000000e; +pub const EFI_KEY_B0: Key = 0x0000000f; +pub const EFI_KEY_B1: Key = 0x00000010; +pub const EFI_KEY_B2: Key = 0x00000011; +pub const EFI_KEY_B3: Key = 0x00000012; +pub const EFI_KEY_B4: Key = 0x00000013; +pub const EFI_KEY_B5: Key = 0x00000014; +pub const EFI_KEY_B6: Key = 0x00000015; +pub const EFI_KEY_B7: Key = 0x00000016; +pub const EFI_KEY_B8: Key = 0x00000017; +pub const EFI_KEY_B9: Key = 0x00000018; +pub const EFI_KEY_B10: Key = 0x00000019; +pub const EFI_KEY_RSHIFT: Key = 0x0000001a; +pub const EFI_KEY_UP_ARROW: Key = 0x0000001b; +pub const EFI_KEY_ONE: Key = 0x0000001c; +pub const EFI_KEY_TWO: Key = 0x0000001d; +pub const EFI_KEY_THREE: Key = 0x0000001e; +pub const EFI_KEY_CAPS_LOCK: Key = 0x0000001f; +pub const EFI_KEY_C1: Key = 0x00000020; +pub const EFI_KEY_C2: Key = 0x00000021; +pub const EFI_KEY_C3: Key = 0x00000022; +pub const EFI_KEY_C4: Key = 0x00000023; +pub const EFI_KEY_C5: Key = 0x00000024; +pub const EFI_KEY_C6: Key = 0x00000025; +pub const EFI_KEY_C7: Key = 0x00000026; +pub const EFI_KEY_C8: Key = 0x00000027; +pub const EFI_KEY_C9: Key = 0x00000028; +pub const EFI_KEY_C10: Key = 0x00000029; +pub const EFI_KEY_C11: Key = 0x0000002a; +pub const EFI_KEY_C12: Key = 0x0000002b; +pub const EFI_KEY_FOUR: Key = 0x0000002c; +pub const EFI_KEY_FIVE: Key = 0x0000002d; +pub const EFI_KEY_SIX: Key = 0x0000002e; +pub const EFI_KEY_PLUS: Key = 0x0000002f; +pub const EFI_KEY_TAB: Key = 0x00000030; +pub const EFI_KEY_D1: Key = 0x00000031; +pub const EFI_KEY_D2: Key = 0x00000032; +pub const EFI_KEY_D3: Key = 0x00000033; +pub const EFI_KEY_D4: Key = 0x00000034; +pub const EFI_KEY_D5: Key = 0x00000035; +pub const EFI_KEY_D6: Key = 0x00000036; +pub const EFI_KEY_D7: Key = 0x00000037; +pub const EFI_KEY_D8: Key = 0x00000038; +pub const EFI_KEY_D9: Key = 0x00000039; +pub const EFI_KEY_D10: Key = 0x0000003a; +pub const EFI_KEY_D11: Key = 0x0000003b; +pub const EFI_KEY_D12: Key = 0x0000003c; +pub const EFI_KEY_D13: Key = 0x0000003d; +pub const EFI_KEY_DEL: Key = 0x0000003e; +pub const EFI_KEY_END: Key = 0x0000003f; +pub const EFI_KEY_PGDN: Key = 0x00000040; +pub const EFI_KEY_SEVEN: Key = 0x00000041; +pub const EFI_KEY_EIGHT: Key = 0x00000042; +pub const EFI_KEY_NINE: Key = 0x00000043; +pub const EFI_KEY_E0: Key = 0x00000044; +pub const EFI_KEY_E1: Key = 0x00000045; +pub const EFI_KEY_E2: Key = 0x00000046; +pub const EFI_KEY_E3: Key = 0x00000047; +pub const EFI_KEY_E4: Key = 0x00000048; +pub const EFI_KEY_E5: Key = 0x00000049; +pub const EFI_KEY_E6: Key = 0x0000004a; +pub const EFI_KEY_E7: Key = 0x0000004b; +pub const EFI_KEY_E8: Key = 0x0000004c; +pub const EFI_KEY_E9: Key = 0x0000004d; +pub const EFI_KEY_E10: Key = 0x0000004e; +pub const EFI_KEY_E11: Key = 0x0000004f; +pub const EFI_KEY_E12: Key = 0x00000050; +pub const EFI_KEY_BACK_SPACE: Key = 0x00000051; +pub const EFI_KEY_INS: Key = 0x00000052; +pub const EFI_KEY_HOME: Key = 0x00000053; +pub const EFI_KEY_PGUP: Key = 0x00000054; +pub const EFI_KEY_NLCK: Key = 0x00000055; +pub const EFI_KEY_SLASH: Key = 0x00000056; +pub const EFI_KEY_ASTERISK: Key = 0x00000057; +pub const EFI_KEY_MINUS: Key = 0x00000058; +pub const EFI_KEY_ESC: Key = 0x00000059; +pub const EFI_KEY_F1: Key = 0x0000005a; +pub const EFI_KEY_F2: Key = 0x0000005b; +pub const EFI_KEY_F3: Key = 0x0000005c; +pub const EFI_KEY_F4: Key = 0x0000005d; +pub const EFI_KEY_F5: Key = 0x0000005e; +pub const EFI_KEY_F6: Key = 0x0000005f; +pub const EFI_KEY_F7: Key = 0x00000060; +pub const EFI_KEY_F8: Key = 0x00000061; +pub const EFI_KEY_F9: Key = 0x00000062; +pub const EFI_KEY_F10: Key = 0x00000063; +pub const EFI_KEY_F11: Key = 0x00000064; +pub const EFI_KEY_F12: Key = 0x00000065; +pub const EFI_KEY_PRINT: Key = 0x00000066; +pub const EFI_KEY_SLCK: Key = 0x00000067; +pub const EFI_KEY_PAUSE: Key = 0x00000068; + +pub const NULL_MODIFIER: u16 = 0x0000; +pub const LEFT_CONTROL_MODIFIER: u16 = 0x0001; +pub const RIGHT_CONTROL_MODIFIER: u16 = 0x0002; +pub const LEFT_ALT_MODIFIER: u16 = 0x0003; +pub const RIGHT_ALT_MODIFIER: u16 = 0x0004; +pub const ALT_GR_MODIFIER: u16 = 0x0005; +pub const INSERT_MODIFIER: u16 = 0x0006; +pub const DELETE_MODIFIER: u16 = 0x0007; +pub const PAGE_DOWN_MODIFIER: u16 = 0x0008; +pub const PAGE_UP_MODIFIER: u16 = 0x0009; +pub const HOME_MODIFIER: u16 = 0x000A; +pub const END_MODIFIER: u16 = 0x000B; +pub const LEFT_SHIFT_MODIFIER: u16 = 0x000C; +pub const RIGHT_SHIFT_MODIFIER: u16 = 0x000D; +pub const CAPS_LOCK_MODIFIER: u16 = 0x000E; +pub const NUM_LOCK_MODIFIER: u16 = 0x000F; +pub const LEFT_ARROW_MODIFIER: u16 = 0x0010; +pub const RIGHT_ARROW_MODIFIER: u16 = 0x0011; +pub const DOWN_ARROW_MODIFIER: u16 = 0x0012; +pub const UP_ARROW_MODIFIER: u16 = 0x0013; +pub const NS_KEY_MODIFIER: u16 = 0x0014; +pub const NS_KEY_DEPENDENCY_MODIFIER: u16 = 0x0015; +pub const FUNCTION_KEY_ONE_MODIFIER: u16 = 0x0016; +pub const FUNCTION_KEY_TWO_MODIFIER: u16 = 0x0017; +pub const FUNCTION_KEY_THREE_MODIFIER: u16 = 0x0018; +pub const FUNCTION_KEY_FOUR_MODIFIER: u16 = 0x0019; +pub const FUNCTION_KEY_FIVE_MODIFIER: u16 = 0x001A; +pub const FUNCTION_KEY_SIX_MODIFIER: u16 = 0x001B; +pub const FUNCTION_KEY_SEVEN_MODIFIER: u16 = 0x001C; +pub const FUNCTION_KEY_EIGHT_MODIFIER: u16 = 0x001D; +pub const FUNCTION_KEY_NINE_MODIFIER: u16 = 0x001E; +pub const FUNCTION_KEY_TEN_MODIFIER: u16 = 0x001F; +pub const FUNCTION_KEY_ELEVEN_MODIFIER: u16 = 0x0020; +pub const FUNCTION_KEY_TWELVE_MODIFIER: u16 = 0x0021; +pub const PRINT_MODIFIER: u16 = 0x0022; +pub const SYS_REQUEST_MODIFIER: u16 = 0x0023; +pub const SCROLL_LOCK_MODIFIER: u16 = 0x0024; +pub const PAUSE_MODIFIER: u16 = 0x0025; +pub const BREAK_MODIFIER: u16 = 0x0026; +pub const LEFT_LOGO_MODIFIER: u16 = 0x0027; +pub const RIGHT_LOGO_MODIFIER: u16 = 0x0028; +pub const MENU_MODIFIER: u16 = 0x0029; + +pub type Notify = eficall! {fn( + u8, + *const crate::base::Guid, + *const crate::hii::PackageHeader, + crate::hii::Handle, + NotifyType, +) -> crate::base::Status}; + +pub type NotifyType = usize; + +pub const NOTIFY_NEW_PACK: NotifyType = 0x00000001; +pub const NOTIFY_REMOVE_PACK: NotifyType = 0x00000002; +pub const NOTIFY_EXPORT_PACK: NotifyType = 0x00000004; +pub const NOTIFY_ADD_PACK: NotifyType = 0x00000008; diff --git a/vendor/r-efi/src/protocols/hii_font.rs b/vendor/r-efi/src/protocols/hii_font.rs new file mode 100644 index 000000000..4ca7bf7b3 --- /dev/null +++ b/vendor/r-efi/src/protocols/hii_font.rs @@ -0,0 +1,87 @@ +//! HII Font Protocol + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xe9ca4775, + 0x8657, + 0x47fc, + 0x97, + 0xe7, + &[0x7e, 0xd6, 0x5a, 0x08, 0x43, 0x24], +); + +pub type ProtocolStringToImage = eficall! {fn( + *const Protocol, + OutFlags, + String, + *const super::hii_font_ex::DisplayInfo, + *mut *mut super::hii_font_ex::ImageOutput, + usize, + usize, + *mut *mut RowInfo, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolStringIdToImage = eficall! {fn( + *const Protocol, + OutFlags, + crate::hii::Handle, + crate::hii::StringId, + *const crate::base::Char8, + *const super::hii_font_ex::DisplayInfo, + *mut *mut super::hii_font_ex::ImageOutput, + usize, + usize, + *mut *mut RowInfo, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolGetGlyph = eficall! {fn( + *const Protocol, + crate::base::Char16, + *const super::hii_font_ex::DisplayInfo, + *mut *mut super::hii_font_ex::ImageOutput, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolGetFontInfo = eficall! {fn( + *const Protocol, + *mut Handle, + *const super::hii_font_ex::DisplayInfo, + *mut *mut super::hii_font_ex::DisplayInfo, + String, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub string_to_image: ProtocolStringToImage, + pub string_id_to_image: ProtocolStringIdToImage, + pub get_glyph: ProtocolGetGlyph, + pub get_font_info: ProtocolGetFontInfo, +} + +pub type OutFlags = u32; + +pub const OUT_FLAG_CLIP: OutFlags = 0x00000001; +pub const OUT_FLAG_WRAP: OutFlags = 0x00000002; +pub const OUT_FLAG_CLIP_CLEAN_Y: OutFlags = 0x00000004; +pub const OUT_FLAG_CLIP_CLEAN_X: OutFlags = 0x00000008; +pub const OUT_FLAG_TRANSPARENT: OutFlags = 0x00000010; +pub const IGNORE_IF_NO_GLYPH: OutFlags = 0x00000020; +pub const IGNORE_LINE_BREAK: OutFlags = 0x00000040; +pub const DIRECT_TO_SCREEN: OutFlags = 0x00000080; + +pub type String = *mut crate::base::Char16; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct RowInfo { + pub start_index: usize, + pub end_index: usize, + pub line_height: usize, + pub line_width: usize, + pub baseline_offset: usize, +} + +pub type Handle = *mut core::ffi::c_void; diff --git a/vendor/r-efi/src/protocols/hii_font_ex.rs b/vendor/r-efi/src/protocols/hii_font_ex.rs new file mode 100644 index 000000000..92466986f --- /dev/null +++ b/vendor/r-efi/src/protocols/hii_font_ex.rs @@ -0,0 +1,107 @@ +//! HII Font Ex Protocol + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x849e6875, + 0xdb35, + 0x4df8, + 0xb4, + 0x1e, + &[0xc8, 0xf3, 0x37, 0x18, 0x07, 0x3f], +); + +pub type ProtocolStringToImageEx = eficall! {fn( + *const Protocol, + super::hii_font::OutFlags, + super::hii_font::String, + *const DisplayInfo, + *mut *mut ImageOutput, + usize, + usize, + *mut *mut super::hii_font::RowInfo, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolStringIdToImageEx = eficall! {fn( + *const Protocol, + super::hii_font::OutFlags, + crate::hii::Handle, + crate::hii::StringId, + *const crate::base::Char8, + *const DisplayInfo, + *mut *mut ImageOutput, + usize, + usize, + *mut *mut super::hii_font::RowInfo, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolGetGlyphEx = eficall! {fn( + *const Protocol, + crate::base::Char16, + *const DisplayInfo, + *mut *mut ImageOutput, + usize, +) -> crate::base::Status}; + +pub type ProtocolGetFontInfoEx = eficall! {fn( + *const Protocol, + *mut super::hii_font::Handle, + *const DisplayInfo, + *mut *mut DisplayInfo, + super::hii_font::String, +) -> crate::base::Status}; + +pub type ProtocolGetGlyphInfo = eficall! {fn( + *const Protocol, + crate::base::Char16, + *const DisplayInfo, + *mut crate::hii::GlyphInfo, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub string_to_image_ex: ProtocolStringToImageEx, + pub string_id_to_image_ex: ProtocolStringIdToImageEx, + pub get_glyph_ex: ProtocolGetGlyphEx, + pub get_font_info_ex: ProtocolGetFontInfoEx, + pub get_glyph_info: ProtocolGetGlyphInfo, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct DisplayInfo { + pub foreground_color: super::graphics_output::BltPixel, + pub background_color: super::graphics_output::BltPixel, + pub font_info_mask: InfoMask, + pub font_info: super::hii_string::Info, +} + +pub type InfoMask = u32; + +pub const INFO_SYS_FONT: InfoMask = 0x00000001; +pub const INFO_SYS_SIZE: InfoMask = 0x00000002; +pub const INFO_SYS_STYLE: InfoMask = 0x00000004; +pub const INFO_SYS_FORE_COLOR: InfoMask = 0x00000010; +pub const INFO_SYS_BACK_COLOR: InfoMask = 0x00000020; +pub const INFO_RESIZE: InfoMask = 0x00001000; +pub const INFO_RESTYLE: InfoMask = 0x00002000; +pub const INFO_ANY_FONT: InfoMask = 0x00010000; +pub const INFO_ANY_SIZE: InfoMask = 0x00020000; +pub const INFO_ANY_STYLE: InfoMask = 0x00040000; + +#[repr(C)] +#[derive(Clone, Copy)] +pub union ImageOutputImage { + pub bitmap: *mut super::graphics_output::BltPixel, + pub screen: *mut super::graphics_output::Protocol, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ImageOutput { + pub width: u16, + pub height: u16, + pub image: ImageOutputImage, +} diff --git a/vendor/r-efi/src/protocols/hii_string.rs b/vendor/r-efi/src/protocols/hii_string.rs new file mode 100644 index 000000000..c7a1d6e33 --- /dev/null +++ b/vendor/r-efi/src/protocols/hii_string.rs @@ -0,0 +1,71 @@ +//! HII String Protocol + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xfd96974, + 0x23aa, + 0x4cdc, + 0xb9, + 0xcb, + &[0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a], +); + +pub type ProtocolNewString = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *mut crate::hii::StringId, + *const crate::base::Char8, + *const crate::base::Char16, + super::hii_font::String, + *const Info, +) -> crate::base::Status}; + +pub type ProtocolGetString = eficall! {fn( + *const Protocol, + *const crate::base::Char8, + crate::hii::Handle, + crate::hii::StringId, + super::hii_font::String, + *mut usize, + *mut *mut Info, +) -> crate::base::Status}; + +pub type ProtocolSetString = eficall! {fn( + *const Protocol, + crate::hii::Handle, + crate::hii::StringId, + *const crate::base::Char8, + super::hii_font::String, + *const Info, +) -> crate::base::Status}; + +pub type ProtocolGetLanguages = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *mut crate::base::Char8, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolGetSecondaryLanguages = eficall! {fn( + *const Protocol, + crate::hii::Handle, + *const crate::base::Char8, + *mut crate::base::Char8, + *mut usize, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub new_string: ProtocolNewString, + pub get_string: ProtocolGetString, + pub set_string: ProtocolSetString, + pub get_languages: ProtocolGetLanguages, + pub get_secondary_languages: ProtocolGetSecondaryLanguages, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Info { + pub font_style: crate::hii::FontStyle, + pub font_size: u16, + pub font_name: [crate::base::Char16; N], +} diff --git a/vendor/r-efi/src/protocols/ip4.rs b/vendor/r-efi/src/protocols/ip4.rs new file mode 100644 index 000000000..1a57b5c99 --- /dev/null +++ b/vendor/r-efi/src/protocols/ip4.rs @@ -0,0 +1,202 @@ +//! IPv4 Protocol +//! +//! It implements a simple packet-oriented interface that can be used by +//! drivers, daemons, and applications to transmit and receive network packets. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x41d94cd2, + 0x35b6, + 0x455a, + 0x82, + 0x58, + &[0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xc51711e7, + 0xb4bf, + 0x404a, + 0xbf, + 0xb8, + &[0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub default_protocol: u8, + pub accept_any_protocol: crate::base::Boolean, + pub accept_icmp_errors: crate::base::Boolean, + pub accept_broadcast: crate::base::Boolean, + pub accept_promiscuous: crate::base::Boolean, + pub use_default_address: crate::base::Boolean, + pub station_address: crate::base::Ipv4Address, + pub subnet_mask: crate::base::Ipv4Address, + pub type_of_service: u8, + pub time_to_live: u8, + pub do_not_fragment: crate::base::Boolean, + pub raw_data: crate::base::Boolean, + pub receive_timeout: u32, + pub transmit_timeout: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct RouteTable { + pub subnet_address: crate::base::Ipv4Address, + pub subnet_mask: crate::base::Ipv4Address, + pub gateway_address: crate::base::Ipv4Address, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IcmpType { + pub r#type: u8, + pub code: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ModeData { + pub is_started: crate::base::Boolean, + pub max_packet_size: u32, + pub config_data: ConfigData, + pub is_configured: crate::base::Boolean, + pub group_count: u32, + pub group_table: *mut crate::base::Ipv4Address, + pub route_count: u32, + pub route_table: *mut RouteTable, + pub icmp_type_count: u32, + pub icmp_type_list: *mut IcmpType, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub packet: CompletionTokenPacket, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CompletionTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ReceiveData { + pub time_stamp: crate::system::Time, + pub recycle_signal: crate::base::Event, + pub header_length: u32, + pub header: *mut Header, + pub options_length: u32, + pub options: *mut core::ffi::c_void, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TransmitData { + pub destination_address: crate::base::Ipv4Address, + pub override_data: *mut OverrideData, + pub options_length: u32, + pub options_buffer: *mut core::ffi::c_void, + pub total_data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Header { + pub header_length_and_version: u8, + pub type_of_service: u8, + pub total_length: u16, + pub identification: u16, + pub fragmentation: u16, + pub time_to_live: u8, + pub protocol: u8, + pub checksum: u16, + pub source_address: crate::base::Ipv4Address, + pub destination_address: crate::base::Ipv4Address, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct OverrideData { + pub source_address: crate::base::Ipv4Address, + pub gateway_address: crate::base::Ipv4Address, + pub protocol: u8, + pub type_of_service: u8, + pub time_to_live: u8, + pub do_not_fragment: crate::base::Boolean, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolGroups = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv4Address, +) -> crate::base::Status}; + +pub type ProtocolRoutes = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub groups: ProtocolGroups, + pub routes: ProtocolRoutes, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/ip6.rs b/vendor/r-efi/src/protocols/ip6.rs new file mode 100644 index 000000000..ad03e8f1f --- /dev/null +++ b/vendor/r-efi/src/protocols/ip6.rs @@ -0,0 +1,264 @@ +//! IPv6 Protocol +//! +//! It implements a simple packet-oriented interface that can be used by +//! drivers, daemons, and applications to transmit and receive network packets. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x2c8759d5, + 0x5c2d, + 0x66ef, + 0x92, + 0x5f, + &[0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xec835dd3, + 0xfe0f, + 0x617b, + 0xa6, + 0x21, + &[0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ModeData { + pub is_started: crate::base::Boolean, + pub max_packet_size: u32, + pub config_data: ConfigData, + pub is_configured: crate::base::Boolean, + pub address_count: u32, + pub address_list: *mut AddressInfo, + pub group_count: u32, + pub group_table: *mut crate::base::Ipv6Address, + pub route_count: u32, + pub route_table: *mut RouteTable, + pub neighbor_count: u32, + pub neighbor_cache: *mut NeighborCache, + pub prefix_count: u32, + pub prefix_table: *mut AddressInfo, + pub icmp_type_count: u32, + pub icmp_type_list: *mut IcmpType, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub default_protocol: u8, + pub accept_any_protocol: crate::base::Boolean, + pub accept_icmp_errors: crate::base::Boolean, + pub accept_promiscuous: crate::base::Boolean, + pub destination_address: crate::base::Ipv6Address, + pub station_address: crate::base::Ipv6Address, + pub traffic_class: u8, + pub hop_limit: u8, + pub flow_lable: u32, + pub receive_timeout: u32, + pub transmit_timeout: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct AddressInfo { + pub address: crate::base::Ipv6Address, + pub prefix_length: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct RouteTable { + pub gateway: crate::base::Ipv6Address, + pub destination: crate::base::Ipv6Address, + pub prefix_length: u8, +} + +pub type NeighborState = u32; + +pub const NEIGHBOR_IN_COMPLETE: NeighborState = 0x00000000; +pub const NEIGHBOR_REACHABLE: NeighborState = 0x00000001; +pub const NEIGHBOR_STATE: NeighborState = 0x00000002; +pub const NEIGHBOR_DELAY: NeighborState = 0x00000003; +pub const NEIGHBOR_PROBE: NeighborState = 0x00000004; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct NeighborCache { + pub neighbor: crate::base::Ipv6Address, + pub link_address: crate::base::MacAddress, + pub state: NeighborState, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct IcmpType { + pub r#type: u8, + pub code: u8, +} + +pub const ICMP_V6_DEST_UNREACHABLE: u8 = 0x01; +pub const ICMP_V6_PACKET_TOO_BIG: u8 = 0x02; +pub const ICMP_V6_TIME_EXCEEDED: u8 = 0x03; +pub const ICMP_V6_PARAMETER_PROBLEM: u8 = 0x04; + +pub const ICMP_V6_ECHO_REQUEST: u8 = 0x80; +pub const ICMP_V6_ECHO_REPLY: u8 = 0x81; +pub const ICMP_V6_LISTENER_QUERY: u8 = 0x82; +pub const ICMP_V6_LISTENER_REPORT: u8 = 0x83; +pub const ICMP_V6_LISTENER_DONE: u8 = 0x84; +pub const ICMP_V6_ROUTER_SOLICIT: u8 = 0x85; +pub const ICMP_V6_ROUTER_ADVERTISE: u8 = 0x86; +pub const ICMP_V6_NEIGHBOR_SOLICIT: u8 = 0x87; +pub const ICMP_V6_NEIGHBOR_ADVERTISE: u8 = 0x88; +pub const ICMP_V6_REDIRECT: u8 = 0x89; +pub const ICMP_V6_LISTENER_REPORT_2: u8 = 0x8f; + +pub const ICMP_V6_NO_ROUTE_TO_DEST: u8 = 0x00; +pub const ICMP_V6_COMM_PROHIBITED: u8 = 0x01; +pub const ICMP_V6_BEYOND_SCOPE: u8 = 0x02; +pub const ICMP_V6_ADDR_UNREACHABLE: u8 = 0x03; +pub const ICMP_V6_PORT_UNREACHABLE: u8 = 0x04; +pub const ICMP_V6_SOURCE_ADDR_FAILED: u8 = 0x05; +pub const ICMP_V6_ROUTE_REJECTED: u8 = 0x06; + +pub const ICMP_V6_TIMEOUT_HOP_LIMIT: u8 = 0x00; +pub const ICMP_V6_TIMEOUT_REASSEMBLE: u8 = 0x01; + +pub const ICMP_V6_ERRONEOUS_HEADER: u8 = 0x00; +pub const ICMP_V6_UNRECOGNIZE_NEXT_HDR: u8 = 0x01; +pub const ICMP_V6_UNRECOGNIZE_OPTION: u8 = 0x02; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub packet: CompletionTokenPacket, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CompletionTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ReceiveData { + pub time_stamp: crate::system::Time, + pub recycle_signal: crate::base::Event, + pub header_length: u32, + pub header: *mut Header, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Header { + pub traffic_class_h_version: u8, + pub flow_label_h_traffic_class_l: u8, + pub flow_label_l: u16, + pub payload_length: u16, + pub next_header: u8, + pub hop_limit: u8, + pub source_address: crate::base::Ipv6Address, + pub destination_address: crate::base::Ipv6Address, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TransmitData { + pub destination_address: *mut crate::base::Ipv6Address, + pub override_data: *mut OverrideData, + pub ext_hdrs_length: u32, + pub ext_hdrs: *mut core::ffi::c_void, + pub next_header: u8, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct OverrideData { + pub protocol: u8, + pub hop_limit: u8, + pub flow_label: u32, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolGroups = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv6Address, +) -> crate::base::Status}; + +pub type ProtocolRoutes = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv6Address, + u8, + *mut crate::base::Ipv6Address, +) -> crate::base::Status}; + +pub type ProtocolNeighbors = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv6Address, + *mut crate::base::MacAddress, + u32, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub groups: ProtocolGroups, + pub routes: ProtocolRoutes, + pub neighbors: ProtocolNeighbors, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/loaded_image.rs b/vendor/r-efi/src/protocols/loaded_image.rs new file mode 100644 index 000000000..5005d76a2 --- /dev/null +++ b/vendor/r-efi/src/protocols/loaded_image.rs @@ -0,0 +1,39 @@ +//! Loaded Image Protocol +//! +//! The loaded image protocol defines how to obtain information about a loaded image from an +//! image handle. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x5b1b31a1, + 0x9562, + 0x11d2, + 0x8e, + 0x3f, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +pub const REVISION: u32 = 0x00001000u32; + +pub type ProtocolUnload = eficall! {fn( + crate::base::Handle, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u32, + pub parent_handle: crate::base::Handle, + pub system_table: *mut crate::system::SystemTable, + + pub device_handle: crate::base::Handle, + pub file_path: *mut crate::protocols::device_path::Protocol, + pub reserved: *mut core::ffi::c_void, + + pub load_options_size: u32, + pub load_options: *mut core::ffi::c_void, + + pub image_base: *mut core::ffi::c_void, + pub image_size: u64, + pub image_code_type: crate::system::MemoryType, + pub image_data_type: crate::system::MemoryType, + pub unload: ProtocolUnload, +} diff --git a/vendor/r-efi/src/protocols/loaded_image_device_path.rs b/vendor/r-efi/src/protocols/loaded_image_device_path.rs new file mode 100644 index 000000000..55067317f --- /dev/null +++ b/vendor/r-efi/src/protocols/loaded_image_device_path.rs @@ -0,0 +1,13 @@ +//! Loaded Image Device Path Protocol +//! +//! The loaded image device path protocol provides the device path of a loaded image, using the +//! protocol structures of the device-path and loaded-image protocols. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xbc62157e, + 0x3e33, + 0x4fec, + 0x99, + 0x20, + &[0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf], +); diff --git a/vendor/r-efi/src/protocols/managed_network.rs b/vendor/r-efi/src/protocols/managed_network.rs new file mode 100644 index 000000000..12d516b4b --- /dev/null +++ b/vendor/r-efi/src/protocols/managed_network.rs @@ -0,0 +1,147 @@ +//! Managed Network Protocol +//! +//! It provides raw (unformatted) asynchronous network packet I/O services. +//! These services make it possible for multiple-event-driven drivers and +//! applications to access and use the system network interfaces at the same +//! time. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x7ab33a91, + 0xace5, + 0x4326, + 0xb5, + 0x72, + &[0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xf36ff770, + 0xa7e1, + 0x42cf, + 0x9e, + 0xd2, + &[0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub received_queue_timeout_value: u32, + pub transmit_queue_timeout_value: u32, + pub protocol_type_filter: u16, + pub enable_unicast_receive: crate::base::Boolean, + pub enable_multicast_receive: crate::base::Boolean, + pub enable_broadcast_receive: crate::base::Boolean, + pub enable_promiscuous_receive: crate::base::Boolean, + pub flush_queues_on_reset: crate::base::Boolean, + pub enable_receive_timestamps: crate::base::Boolean, + pub disable_background_polling: crate::base::Boolean, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub packet: CompletionTokenPacket, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CompletionTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ReceiveData { + pub timestamp: crate::system::Time, + pub recycle_event: crate::base::Event, + pub packet_length: u32, + pub header_length: u32, + pub address_length: u32, + pub data_length: u32, + pub broadcast_flag: crate::base::Boolean, + pub multicast_flag: crate::base::Boolean, + pub promiscuous_flag: crate::base::Boolean, + pub protocol_type: u16, + pub destination_address: *mut core::ffi::c_void, + pub source_address: *mut core::ffi::c_void, + pub media_header: *mut core::ffi::c_void, + pub packet_data: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TransmitData { + pub destination_address: *mut crate::base::MacAddress, + pub source_address: *mut crate::base::MacAddress, + pub protocol_type: u16, + pub data_length: u32, + pub header_length: u16, + pub fragment_count: u16, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolMcastIpToMac = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::IpAddress, + *mut crate::base::MacAddress, +) -> crate::base::Status}; + +pub type ProtocolGroups = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::MacAddress, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub mcast_ip_to_mac: ProtocolMcastIpToMac, + pub groups: ProtocolGroups, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/mp_services.rs b/vendor/r-efi/src/protocols/mp_services.rs new file mode 100644 index 000000000..6163b4c51 --- /dev/null +++ b/vendor/r-efi/src/protocols/mp_services.rs @@ -0,0 +1,121 @@ +//! Multi-Processor Services Protocol +//! +//! This Protocol is defined in the UEFI Platform Integration Specification, +//! Section 13.4. +//! +//! This provides a generalized way of performing the following tasks: +//! - Retrieving information of multi-processor environments. +//! - Dispatching user-provided function to APs. +//! - Maintain MP-related processor status. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x3fdda605, + 0xa76e, + 0x4f46, + 0xad, + 0x29, + &[0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08], +); + +pub const PROCESSOR_AS_BSP_BIT: u32 = 0x00000001; +pub const PROCESSOR_ENABLED_BIT: u32 = 0x00000002; +pub const PROCESSOR_HEALTH_STATUS_BIT: u32 = 0x00000004; + +pub const END_OF_CPU_LIST: usize = usize::MAX; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CpuPhysicalLocation { + pub package: u32, + pub core: u32, + pub thread: u32, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CpuPhysicalLocation2 { + pub package: u32, + pub module: u32, + pub tile: u32, + pub die: u32, + pub core: u32, + pub thread: u32, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union ExtendedProcessorInformation { + pub location2: CpuPhysicalLocation2, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ProcessorInformation { + pub processor_id: u64, + pub status_flag: u32, + pub location: CpuPhysicalLocation, + pub extended_information: ExtendedProcessorInformation, +} + +pub type ApProcedure = eficall! {fn(*mut core::ffi::c_void)}; + +pub type GetNumberOfProcessors = eficall! {fn( + *mut Protocol, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type GetProcessorInfo = eficall! {fn( + *mut Protocol, + usize, + *mut ProcessorInformation, +) -> crate::base::Status}; + +pub type StartupAllAps = eficall! {fn( + *mut Protocol, + ApProcedure, + crate::base::Boolean, + crate::base::Event, + usize, + *mut core::ffi::c_void, + *mut *mut usize, +) -> crate::base::Status}; + +pub type StartupThisAp = eficall! {fn( + *mut Protocol, + ApProcedure, + usize, + crate::base::Event, + usize, + *mut core::ffi::c_void, + *mut crate::base::Boolean, +) -> crate::base::Status}; + +pub type SwitchBsp = eficall! {fn( + *mut Protocol, + usize, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type EnableDisableAp = eficall! {fn( + *mut Protocol, + usize, + crate::base::Boolean, + *mut u32, +) -> crate::base::Status}; + +pub type WhoAmI = eficall! {fn( + *mut Protocol, + *mut usize, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_number_of_processors: GetNumberOfProcessors, + pub get_processor_info: GetProcessorInfo, + pub startup_all_aps: StartupAllAps, + pub startup_this_ap: StartupThisAp, + pub switch_bsp: SwitchBsp, + pub enable_disable_ap: EnableDisableAp, + pub who_am_i: WhoAmI, +} diff --git a/vendor/r-efi/src/protocols/rng.rs b/vendor/r-efi/src/protocols/rng.rs new file mode 100644 index 000000000..92eb01375 --- /dev/null +++ b/vendor/r-efi/src/protocols/rng.rs @@ -0,0 +1,83 @@ +//! Random Number Generator Protocol +//! +//! This protocol is used to provide random numbers for use in applications, or +//! entropy for seeding other random number generators. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x3152bca5, + 0xeade, + 0x433d, + 0x86, + 0x2e, + &[0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44], +); + +pub type Algorithm = crate::base::Guid; + +pub const ALGORITHM_SP800_90_HASH_256_GUID: Algorithm = crate::base::Guid::from_fields( + 0xa7af67cb, + 0x603b, + 0x4d42, + 0xba, + 0x21, + &[0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96], +); +pub const ALGORITHM_SP800_90_HMAC_256_GUID: Algorithm = crate::base::Guid::from_fields( + 0xc5149b43, + 0xae85, + 0x4f53, + 0x99, + 0x82, + &[0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7], +); +pub const ALGORITHM_SP800_90_CTR_256_GUID: Algorithm = crate::base::Guid::from_fields( + 0x44f0de6e, + 0x4d8c, + 0x4045, + 0xa8, + 0xc7, + &[0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e], +); +pub const ALGORITHM_X9_31_3DES_GUID: Algorithm = crate::base::Guid::from_fields( + 0x63c4785a, + 0xca34, + 0x4012, + 0xa3, + 0xc8, + &[0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46], +); +pub const ALGORITHM_X9_31_AES_GUID: Algorithm = crate::base::Guid::from_fields( + 0xacd03321, + 0x777e, + 0x4d3d, + 0xb1, + 0xc8, + &[0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9], +); +pub const ALGORITHM_RAW: Algorithm = crate::base::Guid::from_fields( + 0xe43176d7, + 0xb6e8, + 0x4827, + 0xb7, + 0x84, + &[0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61], +); + +pub type ProtocolGetInfo = eficall! {fn( + *mut Protocol, + *mut usize, + *mut Algorithm, +) -> crate::base::Status}; + +pub type ProtocolGetRng = eficall! {fn( + *mut Protocol, + *mut Algorithm, + usize, + *mut u8, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_info: ProtocolGetInfo, + pub get_rng: ProtocolGetRng, +} diff --git a/vendor/r-efi/src/protocols/service_binding.rs b/vendor/r-efi/src/protocols/service_binding.rs new file mode 100644 index 000000000..67c69f91f --- /dev/null +++ b/vendor/r-efi/src/protocols/service_binding.rs @@ -0,0 +1,20 @@ +//! Service Binding Protocol +//! +//! Provides services that are required to create and destroy child handles +//! that support a given set of protocols. + +pub type ProtocolCreateChild = eficall! {fn( + *mut Protocol, + *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type ProtocolDestroyChild = eficall! {fn( + *mut Protocol, + crate::base::Handle, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub create_child: ProtocolCreateChild, + pub destroy_child: ProtocolDestroyChild, +} diff --git a/vendor/r-efi/src/protocols/shell.rs b/vendor/r-efi/src/protocols/shell.rs new file mode 100644 index 000000000..01b6b2c68 --- /dev/null +++ b/vendor/r-efi/src/protocols/shell.rs @@ -0,0 +1,295 @@ +//! Shell Protocol +//! +//! Provides shell services to UEFI applications. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x6302d008, + 0x7f9b, + 0x4f30, + 0x87, + 0xac, + &[0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e], +); + +pub const MAJOR_VERSION: u32 = 0x00000002; +pub const MINOR_VERSION: u32 = 0x00000002; + +pub type FileHandle = *mut core::ffi::c_void; + +pub type DeviceNameFlags = u32; +pub const DEVICE_NAME_USE_COMPONENT_NAME: DeviceNameFlags = 0x00000001; +pub const DEVICE_NAME_USE_DEVICE_PATH: DeviceNameFlags = 0x00000002; + +#[repr(C)] +pub struct ListEntry { + pub flink: *mut ListEntry, + pub blink: *mut ListEntry, +} + +#[repr(C)] +pub struct FileInfo { + pub link: ListEntry, + pub status: crate::base::Status, + pub full_name: *mut crate::base::Char16, + pub file_name: *mut crate::base::Char16, + pub handle: FileHandle, + pub info: *mut crate::protocols::file::Info, +} + +pub type Execute = eficall! {fn( + *mut crate::base::Handle, + *mut crate::base::Char16, + *mut *mut crate::base::Char16, + *mut crate::base::Status, +) -> crate::base::Status}; + +pub type GetEnv = eficall! {fn( + *mut crate::base::Char16, +) -> *mut crate::base::Char16}; + +pub type SetEnv = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Char16, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type GetAlias = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Boolean, +) -> *mut crate::base::Char16}; + +pub type SetAlias = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Char16, + crate::base::Boolean, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type GetHelpText = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Char16, + *mut *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetDevicePathFromMap = eficall! {fn( + *mut crate::base::Char16, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type GetMapFromDevicePath = eficall! {fn( + *mut *mut crate::protocols::device_path::Protocol, +) -> *mut crate::base::Char16}; + +pub type GetDevicePathFromFilePath = eficall! {fn( + *mut crate::base::Char16, +) -> *mut crate::protocols::device_path::Protocol}; + +pub type GetFilePathFromDevicePath = eficall! {fn( + *mut crate::protocols::device_path::Protocol, +) -> *mut crate::base::Char16}; + +pub type SetMap = eficall! {fn( + *mut crate::protocols::device_path::Protocol, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetCurDir = eficall! {fn( + *mut crate::base::Char16, +) -> *mut crate::base::Char16}; + +pub type SetCurDir = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type OpenFileList = eficall! {fn( + *mut crate::base::Char16, + u64, + *mut *mut FileInfo, +) -> crate::base::Status}; + +pub type FreeFileList = eficall! {fn( + *mut *mut FileInfo, +) -> crate::base::Status}; + +pub type RemoveDupInFileList = eficall! {fn( + *mut *mut FileInfo, +) -> crate::base::Status}; + +pub type BatchIsActive = eficall! {fn() -> crate::base::Boolean}; + +pub type IsRootShell = eficall! {fn() -> crate::base::Boolean}; + +pub type EnablePageBreak = eficall! {fn()}; + +pub type DisablePageBreak = eficall! {fn()}; + +pub type GetPageBreak = eficall! {fn() -> crate::base::Boolean}; + +pub type GetDeviceName = eficall! {fn( + crate::base::Handle, + DeviceNameFlags, + *mut crate::base::Char8, + *mut *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetFileInfo = eficall! {fn( + FileHandle, +) -> *mut crate::protocols::file::Info}; + +pub type SetFileInfo = eficall! {fn( + FileHandle, + *mut crate::protocols::file::Info +) -> crate::base::Status}; + +pub type OpenFileByName = eficall! {fn( + *mut crate::base::Char16, + *mut FileHandle, + u64, +) -> crate::base::Status}; + +pub type CloseFile = eficall! {fn( + FileHandle, +) -> crate::base::Status}; + +pub type CreateFile = eficall! {fn( + *mut crate::base::Char16, + u64, + *mut FileHandle, +) -> crate::base::Status}; + +pub type ReadFile = eficall! {fn( + FileHandle, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type WriteFile = eficall! {fn( + FileHandle, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type DeleteFile = eficall! {fn( + FileHandle, +) -> crate::base::Status}; + +pub type DeleteFileByName = eficall! {fn( + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetFilePosition = eficall! {fn( + FileHandle, + *mut u64, +) -> crate::base::Status}; + +pub type SetFilePosition = eficall! {fn( + FileHandle, + u64, +) -> crate::base::Status}; + +pub type FlushFile = eficall! {fn( + FileHandle, +) -> crate::base::Status}; + +pub type FindFiles = eficall! {fn( + *mut crate::base::Char16, + *mut *mut FileInfo, +) -> crate::base::Status}; + +pub type FindFilesInDir = eficall! {fn( + FileHandle, + *mut *mut FileInfo, +) -> crate::base::Status}; + +pub type GetFileSize = eficall! {fn( + FileHandle, + *mut u64, +) -> crate::base::Status}; + +pub type OpenRoot = eficall! {fn( + *mut crate::protocols::device_path::Protocol, + *mut FileHandle, +) -> crate::base::Status}; + +pub type OpenRootByHandle = eficall! {fn( + crate::base::Handle, + *mut FileHandle, +) -> crate::base::Status}; + +pub type RegisterGuidName = eficall! {fn( + *mut crate::base::Guid, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetGuidName = eficall! {fn( + *mut crate::base::Guid, + *mut *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type GetGuidFromName = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Guid, +) -> crate::base::Status}; + +pub type GetEnvEx = eficall! {fn( + *mut crate::base::Char16, + *mut u32, +) -> *mut crate::base::Char16}; + +#[repr(C)] +pub struct Protocol { + pub execute: Execute, + pub get_env: GetEnv, + pub set_env: SetEnv, + pub get_alias: GetAlias, + pub set_alias: SetAlias, + pub get_help_text: GetHelpText, + pub get_device_path_from_map: GetDevicePathFromMap, + pub get_map_from_device_path: GetMapFromDevicePath, + pub get_device_path_from_file_path: GetDevicePathFromFilePath, + pub get_file_path_from_device_path: GetFilePathFromDevicePath, + pub set_map: SetMap, + + pub get_cur_dir: GetCurDir, + pub set_cur_dir: SetCurDir, + pub open_file_list: OpenFileList, + pub free_file_list: FreeFileList, + pub remove_dup_in_file_list: RemoveDupInFileList, + + pub batch_is_active: BatchIsActive, + pub is_root_shell: IsRootShell, + pub enable_page_break: EnablePageBreak, + pub disable_page_break: DisablePageBreak, + pub get_page_break: GetPageBreak, + pub get_device_name: GetDeviceName, + + pub get_file_info: GetFileInfo, + pub set_file_info: SetFileInfo, + pub open_file_by_name: OpenFileByName, + pub close_file: CloseFile, + pub create_file: CreateFile, + pub read_file: ReadFile, + pub write_file: WriteFile, + pub delete_file: DeleteFile, + pub delete_file_by_name: DeleteFileByName, + pub get_file_position: GetFilePosition, + pub set_file_position: SetFilePosition, + pub flush_file: FlushFile, + pub find_files: FindFiles, + pub find_files_in_dir: FindFilesInDir, + pub get_file_size: GetFileSize, + + pub open_root: OpenRoot, + pub open_root_by_handle: OpenRootByHandle, + + pub execution_break: crate::base::Event, + + pub major_version: u32, + pub minor_version: u32, + pub register_guid_name: RegisterGuidName, + pub get_guid_name: GetGuidName, + pub get_guid_from_name: GetGuidFromName, + + // Shell 2.1 + pub get_env_ex: GetEnvEx, +} diff --git a/vendor/r-efi/src/protocols/shell_dynamic_command.rs b/vendor/r-efi/src/protocols/shell_dynamic_command.rs new file mode 100644 index 000000000..a1d775915 --- /dev/null +++ b/vendor/r-efi/src/protocols/shell_dynamic_command.rs @@ -0,0 +1,33 @@ +//! Shell Dynamic Command Protocol +//! +//! Defined in UEFI Shell Specification, Section 2.4 + +use super::{shell, shell_parameters}; + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x3c7200e9, + 0x005f, + 0x4ea4, + 0x87, + 0xde, + &[0xa3, 0xdf, 0xac, 0x8a, 0x27, 0xc3], +); + +pub type CommandHandler = eficall! {fn( + *mut Protocol, + *mut crate::system::SystemTable, + *mut shell_parameters::Protocol, + *mut shell::Protocol, +) -> crate::base::Status}; + +pub type CommandGetHelp = eficall! {fn( + *mut Protocol, + *mut crate::base::Char8, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub command_name: *mut crate::base::Char16, + pub handler: CommandHandler, + pub get_help: CommandGetHelp, +} diff --git a/vendor/r-efi/src/protocols/shell_parameters.rs b/vendor/r-efi/src/protocols/shell_parameters.rs new file mode 100644 index 000000000..e779d0add --- /dev/null +++ b/vendor/r-efi/src/protocols/shell_parameters.rs @@ -0,0 +1,23 @@ +//! Shell Parameters Protocol +//! +//! Defined in the UEFI Shell Specification, Section 2.3. + +use super::shell; + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x752f3136, + 0x4e16, + 0x4fdc, + 0xa2, + 0x2a, + &[0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca], +); + +#[repr(C)] +pub struct Protocol { + pub argv: *mut *mut crate::base::Char16, + pub argc: usize, + pub std_in: shell::FileHandle, + pub std_out: shell::FileHandle, + pub std_err: shell::FileHandle, +} diff --git a/vendor/r-efi/src/protocols/simple_file_system.rs b/vendor/r-efi/src/protocols/simple_file_system.rs new file mode 100644 index 000000000..0f0947b9b --- /dev/null +++ b/vendor/r-efi/src/protocols/simple_file_system.rs @@ -0,0 +1,26 @@ +//! Simple File System Protocol +//! +//! Provides the `open_volume` function returning a file protocol representing the root directory +//! of a filesystem. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x964e5b22, + 0x6459, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +pub const REVISION: u64 = 0x0000000000010000u64; + +pub type ProtocolOpenVolume = eficall! {fn( + *mut Protocol, + *mut *mut crate::protocols::file::Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub open_volume: ProtocolOpenVolume, +} diff --git a/vendor/r-efi/src/protocols/simple_network.rs b/vendor/r-efi/src/protocols/simple_network.rs new file mode 100644 index 000000000..883ff31b4 --- /dev/null +++ b/vendor/r-efi/src/protocols/simple_network.rs @@ -0,0 +1,196 @@ +//! Simple Network Protocol +//! +//! The simple network protcol provides services to initialize a network interface, transmit +//! packets, receive packets, and close a network interface. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xa19832b9, + 0xac25, + 0x11d3, + 0x9a, + 0x2d, + &[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d], +); + +pub const REVISION: u64 = 0x0000000000010000u64; + +pub const MAX_MCAST_FILTER_CNT: usize = 16; + +pub const RECEIVE_UNICAST: u32 = 0x00000001u32; +pub const RECEIVE_MULTICAST: u32 = 0x00000002u32; +pub const RECEIVE_BROADCAST: u32 = 0x00000004u32; +pub const RECEIVE_PROMISCUOUS: u32 = 0x00000008u32; +pub const RECEIVE_PROMISCUOUS_MULTICAST: u32 = 0x00000010u32; + +pub const RECEIVE_INTERRUPT: u32 = 0x00000001u32; +pub const TRANSMIT_INTERRUPT: u32 = 0x00000002u32; +pub const COMMAND_INTERRUPT: u32 = 0x00000004u32; +pub const SOFTWARE_INTERRUPT: u32 = 0x000000008u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Mode { + pub state: u32, + pub hw_address_size: u32, + pub media_header_size: u32, + pub max_packet_size: u32, + pub nvram_size: u32, + pub nvram_access_size: u32, + pub receive_filter_mask: u32, + pub receive_filter_setting: u32, + pub max_mcast_filter_count: u32, + pub mcast_filter_count: u32, + pub mcast_filter: [crate::base::MacAddress; MAX_MCAST_FILTER_CNT], + pub current_address: crate::base::MacAddress, + pub broadcast_address: crate::base::MacAddress, + pub permanent_address: crate::base::MacAddress, + pub if_type: u8, + pub mac_address_changeable: crate::base::Boolean, + pub multiple_tx_supported: crate::base::Boolean, + pub media_present_supported: crate::base::Boolean, + pub media_present: crate::base::Boolean, +} + +pub type State = u32; + +pub const STOPPED: State = 0x00000000; +pub const STARTED: State = 0x00000001; +pub const INITIALIZED: State = 0x00000002; +pub const MAX_STATE: State = 0x00000003; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Statistics { + pub rx_total_frames: u64, + pub rx_good_frames: u64, + pub rx_undersize_frames: u64, + pub rx_oversize_frames: u64, + pub rx_dropped_frames: u64, + pub rx_unicast_frames: u64, + pub rx_broadcast_frames: u64, + pub rx_multicast_frames: u64, + pub rx_crc_error_frames: u64, + pub rx_total_bytes: u64, + pub tx_total_frames: u64, + pub tx_good_frames: u64, + pub tx_undersize_frames: u64, + pub tx_oversize_frames: u64, + pub tx_dropped_frames: u64, + pub tx_unicast_frames: u64, + pub tx_broadcast_frames: u64, + pub tx_multicast_frames: u64, + pub tx_crc_error_frames: u64, + pub tx_total_bytes: u64, + pub collisions: u64, + pub unsupported_protocol: u64, + pub rx_duplicated_frames: u64, + pub rx_decrypt_error_frames: u64, + pub tx_error_frames: u64, + pub tx_retry_frames: u64, +} + +pub type ProtocolStart = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolStop = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolInitialize = eficall! {fn( + *mut Protocol, + usize, + usize, +) -> crate::base::Status}; + +pub type ProtocolReset = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolShutdown = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolReceiveFilters = eficall! {fn( + *mut Protocol, + u32, + u32, + crate::base::Boolean, + usize, + *mut crate::base::MacAddress, +) -> crate::base::Status}; + +pub type ProtocolStationAddress = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::MacAddress, +) -> crate::base::Status}; + +pub type ProtocolStatistics = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut usize, + *mut Statistics, +) -> crate::base::Status}; + +pub type ProtocolMcastIpToMac = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::IpAddress, + *mut crate::base::MacAddress, +) -> crate::base::Status}; + +pub type ProtocolNvData = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + usize, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolGetStatus = eficall! {fn( + *mut Protocol, + *mut u32, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + usize, + usize, + *mut core::ffi::c_void, + *mut crate::base::MacAddress, + *mut crate::base::MacAddress, + *mut u16, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut usize, + *mut usize, + *mut core::ffi::c_void, + *mut crate::base::MacAddress, + *mut crate::base::MacAddress, + *mut u16, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub revision: u64, + pub start: ProtocolStart, + pub stop: ProtocolStop, + pub initialize: ProtocolInitialize, + pub reset: ProtocolReset, + pub shutdown: ProtocolShutdown, + pub receive_filters: ProtocolReceiveFilters, + pub station_address: ProtocolStationAddress, + pub statistics: ProtocolStatistics, + pub mcast_ip_to_mac: ProtocolMcastIpToMac, + pub nv_data: ProtocolNvData, + pub get_status: ProtocolGetStatus, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub wait_for_packet: crate::base::Event, + pub mode: *mut Mode, +} diff --git a/vendor/r-efi/src/protocols/simple_text_input.rs b/vendor/r-efi/src/protocols/simple_text_input.rs new file mode 100644 index 000000000..30f4104ef --- /dev/null +++ b/vendor/r-efi/src/protocols/simple_text_input.rs @@ -0,0 +1,38 @@ +//! Simple Text Input Protocol +//! +//! The simple-text-input protocol defines how to read basic key-strokes. It is limited to +//! non-modifiers and lacks any detailed reporting. It is mostly useful for debugging and admin +//! interaction. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x387477c1, + 0x69c7, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct InputKey { + pub scan_code: u16, + pub unicode_char: crate::base::Char16, +} + +pub type ProtocolReset = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolReadKeyStroke = eficall! {fn( + *mut Protocol, + *mut InputKey, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub reset: ProtocolReset, + pub read_key_stroke: ProtocolReadKeyStroke, + pub wait_for_key: crate::base::Event, +} diff --git a/vendor/r-efi/src/protocols/simple_text_input_ex.rs b/vendor/r-efi/src/protocols/simple_text_input_ex.rs new file mode 100644 index 000000000..f0baf8a97 --- /dev/null +++ b/vendor/r-efi/src/protocols/simple_text_input_ex.rs @@ -0,0 +1,85 @@ +//! Extended Simple Text Input Protocol +//! +//! The simple-text-input-ex protocol extends the simple-text-input protocol by allowing more +//! details reporting about modifiers, etc. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xdd9e7534, + 0x7762, + 0x4698, + 0x8c, + 0x14, + &[0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa], +); + +pub const SHIFT_STATE_VALID: u32 = 0x80000000u32; +pub const RIGHT_SHIFT_PRESSED: u32 = 0x00000001u32; +pub const LEFT_SHIFT_PRESSED: u32 = 0x00000002u32; +pub const RIGHT_CONTROL_PRESSED: u32 = 0x00000004u32; +pub const LEFT_CONTROL_PRESSED: u32 = 0x00000008u32; +pub const RIGHT_ALT_PRESSED: u32 = 0x00000010u32; +pub const LEFT_ALT_PRESSED: u32 = 0x00000020u32; +pub const RIGHT_LOGO_PRESSED: u32 = 0x00000040u32; +pub const LEFT_LOGO_PRESSED: u32 = 0x00000080u32; +pub const MENU_KEY_PRESSED: u32 = 0x00000100u32; +pub const SYS_REQ_PRESSED: u32 = 0x00000200u32; + +pub const TOGGLE_STATE_VALID: u8 = 0x80u8; +pub const KEY_STATE_EXPOSED: u8 = 0x40u8; +pub const SCROLL_LOCK_ACTIVE: u8 = 0x01u8; +pub const NUM_LOCK_ACTIVE: u8 = 0x02u8; +pub const CAPS_LOCK_ACTIVE: u8 = 0x04u8; + +pub type KeyToggleState = u8; +pub type KeyNotifyFunction = eficall! {fn(*mut KeyData) -> crate::base::Status}; + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct KeyState { + pub key_shift_state: u32, + pub key_toggle_state: KeyToggleState, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct KeyData { + pub key: crate::protocols::simple_text_input::InputKey, + pub key_state: KeyState, +} + +pub type ProtocolReset = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolReadKeyStrokeEx = eficall! {fn( + *mut Protocol, + *mut KeyData, +) -> crate::base::Status}; + +pub type ProtocolSetState = eficall! {fn( + *mut Protocol, + *mut KeyToggleState, +) -> crate::base::Status}; + +pub type ProtocolRegisterKeyNotify = eficall! {fn( + *mut Protocol, + *mut KeyData, + KeyNotifyFunction, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type ProtocolUnregisterKeyNotify = eficall! {fn( + *mut Protocol, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub reset: ProtocolReset, + pub read_key_stroke_ex: ProtocolReadKeyStrokeEx, + pub wait_for_key_ex: crate::base::Event, + pub set_state: ProtocolSetState, + pub register_key_notify: ProtocolRegisterKeyNotify, + pub unregister_key_notify: ProtocolUnregisterKeyNotify, +} diff --git a/vendor/r-efi/src/protocols/simple_text_output.rs b/vendor/r-efi/src/protocols/simple_text_output.rs new file mode 100644 index 000000000..d100736db --- /dev/null +++ b/vendor/r-efi/src/protocols/simple_text_output.rs @@ -0,0 +1,86 @@ +//! Simple Text Output Protocol +//! +//! The simple-text-output protocol provides a simple way to print text on screen. It is modeled +//! around the old VGA-consoles, but does not carry all the old cruft. It expects a rectangular +//! text array and allows you to move the cursor around to write Unicode symbols to screen. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x387477c2, + 0x69c7, + 0x11d2, + 0x8e, + 0x39, + &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Mode { + pub max_mode: i32, + pub mode: i32, + pub attribute: i32, + pub cursor_column: i32, + pub cursor_row: i32, + pub cursor_visible: crate::base::Boolean, +} + +pub type ProtocolReset = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type ProtocolOutputString = eficall! {fn( + *mut Protocol, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type ProtocolTestString = eficall! {fn( + *mut Protocol, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type ProtocolQueryMode = eficall! {fn( + *mut Protocol, + usize, + *mut usize, + *mut usize, +) -> crate::base::Status}; + +pub type ProtocolSetMode = eficall! {fn( + *mut Protocol, + usize, +) -> crate::base::Status}; + +pub type ProtocolSetAttribute = eficall! {fn( + *mut Protocol, + usize, +) -> crate::base::Status}; + +pub type ProtocolClearScreen = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +pub type ProtocolSetCursorPosition = eficall! {fn( + *mut Protocol, + usize, + usize, +) -> crate::base::Status}; + +pub type ProtocolEnableCursor = eficall! {fn( + *mut Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub reset: ProtocolReset, + pub output_string: ProtocolOutputString, + pub test_string: ProtocolTestString, + pub query_mode: ProtocolQueryMode, + pub set_mode: ProtocolSetMode, + pub set_attribute: ProtocolSetAttribute, + pub clear_screen: ProtocolClearScreen, + pub set_cursor_position: ProtocolSetCursorPosition, + pub enable_cursor: ProtocolEnableCursor, + pub mode: *mut Mode, +} diff --git a/vendor/r-efi/src/protocols/tcp4.rs b/vendor/r-efi/src/protocols/tcp4.rs new file mode 100644 index 000000000..051b1d8ef --- /dev/null +++ b/vendor/r-efi/src/protocols/tcp4.rs @@ -0,0 +1,224 @@ +//! Transmission Control Protocol version 4 +//! +//! It provides services to send and receive data streams. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x65530bc7, + 0xa359, + 0x410f, + 0xb0, + 0x10, + &[0x5a, 0xad, 0xc7, 0xec, 0x2b, 0x62], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x00720665, + 0x67eb, + 0x4a99, + 0xba, + 0xf7, + &[0xd3, 0xc3, 0x3a, 0x1c, 0x7c, 0xc9], +); + +pub type ConnectionState = u32; + +pub const STATE_CLOSED: ConnectionState = 0x00000000; +pub const STATE_LISTEN: ConnectionState = 0x00000001; +pub const STATE_SYN_SENT: ConnectionState = 0x00000002; +pub const STATE_SYN_RECEIVED: ConnectionState = 0x00000003; +pub const STATE_ESTABLISHED: ConnectionState = 0x00000004; +pub const STATE_FIN_WAIT1: ConnectionState = 0x00000005; +pub const STATE_FIN_WAIT2: ConnectionState = 0x00000006; +pub const STATE_CLOSING: ConnectionState = 0x00000007; +pub const STATE_TIME_WAIT: ConnectionState = 0x00000008; +pub const STATE_CLOSE_WAIT: ConnectionState = 0x00000009; +pub const STATE_LAST_ACK: ConnectionState = 0x0000000a; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub type_of_service: u8, + pub time_to_live: u8, + pub access_point: AccessPoint, + pub control_option: *mut r#Option, +} + +impl Default for ConfigData { + fn default() -> Self { + Self { + type_of_service: Default::default(), + time_to_live: Default::default(), + access_point: Default::default(), + control_option: core::ptr::null_mut(), + } + } +} + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct AccessPoint { + pub use_default_address: crate::base::Boolean, + pub station_address: crate::base::Ipv4Address, + pub subnet_mask: crate::base::Ipv4Address, + pub station_port: u16, + pub remote_address: crate::base::Ipv4Address, + pub remote_port: u16, + pub active_flag: crate::base::Boolean, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct r#Option { + pub receive_buffer_size: u32, + pub send_buffer_size: u32, + pub max_syn_back_log: u32, + pub connection_timeout: u32, + pub data_retries: u32, + pub fin_timeout: u32, + pub time_wait_timeout: u32, + pub keep_alive_probes: u32, + pub keep_alive_time: u32, + pub keep_alive_interval: u32, + pub enable_nagle: crate::base::Boolean, + pub enable_time_stamp: crate::base::Boolean, + pub enable_window_scaling: crate::base::Boolean, + pub enable_selective_ack: crate::base::Boolean, + pub enable_path_mtu_discovery: crate::base::Boolean, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConnectionToken { + pub completion_token: CompletionToken, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ListenToken { + pub completion_token: CompletionToken, + pub new_child_handle: crate::base::Handle, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IoToken { + pub completion_token: CompletionToken, + pub packet: IoTokenPacket, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IoTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ReceiveData { + pub urgent_flag: crate::base::Boolean, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TransmitData { + pub push: crate::base::Boolean, + pub urgent: crate::base::Boolean, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CloseToken { + pub completion_token: CompletionToken, + pub abort_on_close: crate::base::Boolean, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ConnectionState, + *mut ConfigData, + *mut crate::protocols::ip4::ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolRoutes = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, +) -> crate::base::Status}; + +pub type ProtocolConnect = eficall! {fn( + *mut Protocol, + *mut ConnectionToken, +) -> crate::base::Status}; + +pub type ProtocolAccept = eficall! {fn( + *mut Protocol, + *mut ListenToken, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolClose = eficall! {fn( + *mut Protocol, + *mut CloseToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub routes: ProtocolRoutes, + pub connect: ProtocolConnect, + pub accept: ProtocolAccept, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub close: ProtocolClose, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/tcp6.rs b/vendor/r-efi/src/protocols/tcp6.rs new file mode 100644 index 000000000..428b5c3eb --- /dev/null +++ b/vendor/r-efi/src/protocols/tcp6.rs @@ -0,0 +1,202 @@ +//! Transmission Control Protocol version 6 +//! +//! It provides services to send and receive data streams. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x46e44855, + 0xbd60, + 0x4ab7, + 0xab, + 0x0d, + &[0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xec20eb79, + 0x6c1a, + 0x4664, + 0x9a, + 0x0d, + &[0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct AccessPoint { + pub station_address: crate::base::Ipv6Address, + pub station_port: u16, + pub remote_address: crate::base::Ipv6Address, + pub remote_port: u16, + pub active_flag: crate::base::Boolean, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct r#Option { + pub receive_buffer_size: u32, + pub send_buffer_size: u32, + pub max_syn_back_log: u32, + pub connection_timeout: u32, + pub data_retries: u32, + pub fin_timeout: u32, + pub time_wait_timeout: u32, + pub keep_alive_probes: u32, + pub keep_alive_time: u32, + pub keep_alive_interval: u32, + pub enable_nagle: crate::base::Boolean, + pub enable_time_stamp: crate::base::Boolean, + pub enable_window_scaling: crate::base::Boolean, + pub enable_selective_ack: crate::base::Boolean, + pub enable_path_mtu_discovery: crate::base::Boolean, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub traffic_class: u8, + pub hop_limit: u8, + pub access_point: AccessPoint, + pub control_option: *mut r#Option, +} + +pub type ConnectionState = u32; + +pub const STATE_CLOSED: ConnectionState = 0x00000000; +pub const STATE_LISTEN: ConnectionState = 0x00000001; +pub const STATE_SYN_SENT: ConnectionState = 0x00000002; +pub const STATE_SYN_RECEIVED: ConnectionState = 0x00000003; +pub const STATE_ESTABLISHED: ConnectionState = 0x00000004; +pub const STATE_FIN_WAIT1: ConnectionState = 0x00000005; +pub const STATE_FIN_WAIT2: ConnectionState = 0x00000006; +pub const STATE_CLOSING: ConnectionState = 0x00000007; +pub const STATE_TIME_WAIT: ConnectionState = 0x00000008; +pub const STATE_CLOSE_WAIT: ConnectionState = 0x00000009; +pub const STATE_LAST_ACK: ConnectionState = 0x0000000a; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConnectionToken { + pub completion_token: CompletionToken, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ListenToken { + pub completion_token: CompletionToken, + pub new_child_handle: crate::base::Handle, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IoToken { + pub completion_token: CompletionToken, + pub packet: IoTokenPacket, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union IoTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ReceiveData { + pub urgent_flag: crate::base::Boolean, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TransmitData { + pub push: crate::base::Boolean, + pub urgent: crate::base::Boolean, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CloseToken { + pub completion_token: CompletionToken, + pub abort_on_close: crate::base::Boolean, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ConnectionState, + *mut ConfigData, + *mut crate::protocols::ip6::ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolConnect = eficall! {fn( + *mut Protocol, + *mut ConnectionToken, +) -> crate::base::Status}; + +pub type ProtocolAccept = eficall! {fn( + *mut Protocol, + *mut ListenToken, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut IoToken, +) -> crate::base::Status}; + +pub type ProtocolClose = eficall! {fn( + *mut Protocol, + *mut CloseToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub connect: ProtocolConnect, + pub accept: ProtocolAccept, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub close: ProtocolClose, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/timestamp.rs b/vendor/r-efi/src/protocols/timestamp.rs new file mode 100644 index 000000000..3e8f6b575 --- /dev/null +++ b/vendor/r-efi/src/protocols/timestamp.rs @@ -0,0 +1,32 @@ +//! EFI Timestamp Protocol +//! +//! The Timestamp protocol provides a platform independent interface for +//! retrieving a high resolution timestamp counter. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xafbfde41, + 0x2e6e, + 0x4262, + 0xba, + 0x65, + &[0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct Properties { + pub frequency: u64, + pub end_value: u64, +} + +pub type ProtocolGetTimestamp = eficall! {fn() -> u64}; + +pub type ProtocolGetProperties = eficall! {fn( + *mut Properties, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_timestamp: ProtocolGetTimestamp, + pub get_properties: ProtocolGetProperties, +} diff --git a/vendor/r-efi/src/protocols/udp4.rs b/vendor/r-efi/src/protocols/udp4.rs new file mode 100644 index 000000000..f374235ce --- /dev/null +++ b/vendor/r-efi/src/protocols/udp4.rs @@ -0,0 +1,151 @@ +//! User Datagram Protocol V4 +//! +//! It provides simple packet-oriented services to transmit and receive UDP packets. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x3ad9df29, + 0x4501, + 0x478d, + 0xb1, + 0xf8, + &[0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x83f01464, + 0x99bd, + 0x45e5, + 0xb3, + 0x83, + &[0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub accept_broadcast: crate::base::Boolean, + pub accept_promiscuous: crate::base::Boolean, + pub accept_any_port: crate::base::Boolean, + pub allow_duplicate_port: crate::base::Boolean, + pub type_of_service: u8, + pub time_to_live: u8, + pub do_not_fragment: crate::base::Boolean, + pub receive_timeout: u32, + pub transmit_timeout: u32, + pub use_default_address: crate::base::Boolean, + pub station_address: crate::base::Ipv4Address, + pub subnet_mask: crate::base::Ipv4Address, + pub station_port: u16, + pub remote_address: crate::base::Ipv4Address, + pub remote_port: u16, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SessionData { + pub source_address: crate::base::Ipv4Address, + pub source_port: u16, + pub destination_address: crate::base::Ipv4Address, + pub destination_port: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ReceiveData { + pub time_stamp: crate::system::Time, + pub recycle_signal: crate::base::Event, + pub udp_session: SessionData, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct TransmitData { + pub udp_session_data: *mut SessionData, + pub gateway_address: *mut crate::base::Ipv4Address, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CompletionTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub packet: CompletionTokenPacket, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ConfigData, + *mut crate::protocols::ip4::ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolGroups = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv4Address, +) -> crate::base::Status}; + +pub type ProtocolRoutes = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, + *mut crate::base::Ipv4Address, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub groups: ProtocolGroups, + pub routes: ProtocolRoutes, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/protocols/udp6.rs b/vendor/r-efi/src/protocols/udp6.rs new file mode 100644 index 000000000..796863be4 --- /dev/null +++ b/vendor/r-efi/src/protocols/udp6.rs @@ -0,0 +1,137 @@ +//! User Datagram Protocol V6 +//! +//! It provides simple packet-oriented services to transmit and receive UDP packets. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x4f948815, + 0xb4b9, + 0x43cb, + 0x8a, + 0x33, + &[0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55], +); + +pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x66ed4721, + 0x3c98, + 0x4d3e, + 0x81, + 0xe3, + &[0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigData { + pub accept_promiscuous: crate::base::Boolean, + pub accept_any_port: crate::base::Boolean, + pub allow_duplicate_port: crate::base::Boolean, + pub traffic_class: u8, + pub hop_limit: u8, + pub receive_timeout: u32, + pub transmit_timeout: u32, + pub station_address: crate::base::Ipv6Address, + pub station_port: u16, + pub remote_address: crate::base::Ipv6Address, + pub remote_port: u16, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SessionData { + pub source_address: crate::base::Ipv6Address, + pub source_port: u16, + pub destination_address: crate::base::Ipv6Address, + pub destination_port: u16, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct FragmentData { + pub fragment_length: u32, + pub fragment_buffer: *mut core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ReceiveData { + pub time_stamp: crate::system::Time, + pub recycle_signal: crate::base::Event, + pub udp_session: SessionData, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct TransmitData { + pub udp_session_data: *mut SessionData, + pub data_length: u32, + pub fragment_count: u32, + pub fragment_table: [FragmentData; N], +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CompletionTokenPacket { + pub rx_data: *mut ReceiveData, + pub tx_data: *mut TransmitData, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CompletionToken { + pub event: crate::base::Event, + pub status: crate::base::Status, + pub packet: CompletionTokenPacket, +} + +pub type ProtocolGetModeData = eficall! {fn( + *mut Protocol, + *mut ConfigData, + *mut crate::protocols::ip6::ModeData, + *mut crate::protocols::managed_network::ConfigData, + *mut crate::protocols::simple_network::Mode, +) -> crate::base::Status}; + +pub type ProtocolConfigure = eficall! {fn( + *mut Protocol, + *mut ConfigData, +) -> crate::base::Status}; + +pub type ProtocolGroups = eficall! {fn( + *mut Protocol, + crate::base::Boolean, + *mut crate::base::Ipv6Address, +) -> crate::base::Status}; + +pub type ProtocolTransmit = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolReceive = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolCancel = eficall! {fn( + *mut Protocol, + *mut CompletionToken, +) -> crate::base::Status}; + +pub type ProtocolPoll = eficall! {fn( + *mut Protocol, +) -> crate::base::Status}; + +#[repr(C)] +pub struct Protocol { + pub get_mode_data: ProtocolGetModeData, + pub configure: ProtocolConfigure, + pub groups: ProtocolGroups, + pub transmit: ProtocolTransmit, + pub receive: ProtocolReceive, + pub cancel: ProtocolCancel, + pub poll: ProtocolPoll, +} diff --git a/vendor/r-efi/src/system.rs b/vendor/r-efi/src/system.rs new file mode 100644 index 000000000..cac0163f9 --- /dev/null +++ b/vendor/r-efi/src/system.rs @@ -0,0 +1,933 @@ +//! UEFI System Integration +//! +//! This header defines the structures and types of the surrounding system of an UEFI application. +//! It contains the definitions of the system table, the runtime and boot services, as well as +//! common types. +//! +//! We do not document the behavior of each of these types and functions. They follow the UEFI +//! specification, which does a well-enough job of documenting each. This file just provides you +//! the rust definitions of each symbol and some limited hints on some pecularities. + +// +// Time Management +// +// UEFI time management is modeled around the EFI_TIME structure, which represents any arbitrary +// timestamp. The runtime and boot services provide helper functions to query and set the system +// time. +// + +pub const TIME_ADJUST_DAYLIGHT: u8 = 0x01u8; +pub const TIME_IN_DAYLIGHT: u8 = 0x02u8; + +pub const UNSPECIFIED_TIMEZONE: i16 = 0x07ffi16; + +// Cannot derive `Eq` etc. due to uninitialized `pad2` field. +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct Time { + pub year: u16, + pub month: u8, + pub day: u8, + pub hour: u8, + pub minute: u8, + pub second: u8, + pub pad1: u8, + pub nanosecond: u32, + pub timezone: i16, + pub daylight: u8, + pub pad2: u8, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TimeCapabilities { + pub resolution: u32, + pub accuracy: u32, + pub sets_to_zero: crate::base::Boolean, +} + +// +// UEFI Variables +// +// UEFI systems provide a way to store global variables. These can be persistent or volatile. The +// variable store must be provided by the platform, but persistent storage might not be available. +// + +pub const VARIABLE_NON_VOLATILE: u32 = 0x00000001u32; +pub const VARIABLE_BOOTSERVICE_ACCESS: u32 = 0x00000002u32; +pub const VARIABLE_RUNTIME_ACCESS: u32 = 0x00000004u32; +pub const VARIABLE_HARDWARE_ERROR_RECORD: u32 = 0x00000008u32; +pub const VARIABLE_AUTHENTICATED_WRITE_ACCESS: u32 = 0x00000010u32; +pub const VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS: u32 = 0x00000020u32; +pub const VARIABLE_APPEND_WRITE: u32 = 0x00000040u32; +pub const VARIABLE_ENHANCED_AUTHENTICATED_ACCESS: u32 = 0x00000080u32; + +pub const VARIABLE_AUTHENTICATION_3_CERT_ID_SHA256: u32 = 0x1u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct VariableAuthentication3CertId { + pub r#type: u8, + pub id_size: u32, + pub id: [u8; N], +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct VariableAuthentication { + pub monotonic_count: u64, + pub auth_info: [u8; N], // WIN_CERTIFICATE_UEFI_ID from PE/COFF +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct VariableAuthentication2 { + pub timestamp: Time, + pub auth_info: [u8; N], // WIN_CERTIFICATE_UEFI_ID from PE/COFF +} + +pub const VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE: u32 = 0x1u32; +pub const VARIABLE_AUTHENTICATION_3_NONCE_TYPE: u32 = 0x2u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct VariableAuthentication3 { + pub version: u8, + pub r#type: u8, + pub metadata_size: u32, + pub flags: u32, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct VariableAuthentication3Nonce { + pub nonce_size: u32, + pub nonce: [u8; N], +} + +pub const HARDWARE_ERROR_VARIABLE_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x414E6BDD, + 0xE47B, + 0x47cc, + 0xB2, + 0x44, + &[0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16], +); + +// +// Virtual Mappings +// +// UEFI runs in an 1-to-1 mapping from virtual to physical addresses. But once you exit boot +// services, you can apply any address mapping you want, as long as you inform UEFI about it (or, +// alternatively, stop using the UEFI runtime services). +// + +pub const OPTIONAL_POINTER: u32 = 0x00000001u32; + +// +// System Reset +// +// UEFI provides access to firmware functions to reset the system. This includes a wide variety of +// different possible resets. +// + +pub type ResetType = u32; + +pub const RESET_COLD: ResetType = 0x00000000; +pub const RESET_WARM: ResetType = 0x00000001; +pub const RESET_SHUTDOWN: ResetType = 0x00000002; +pub const RESET_PLATFORM_SPECIFIC: ResetType = 0x00000003; + +// +// Update Capsules +// +// The process of firmware updates is generalized in UEFI. There are small blobs called capsules +// that you can push into the firmware to be run either immediately or on next reboot. +// + +#[repr(C)] +#[derive(Clone, Copy)] +pub union CapsuleBlockDescriptorUnion { + pub data_block: crate::base::PhysicalAddress, + pub continuation_pointer: crate::base::PhysicalAddress, +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CapsuleBlockDescriptor { + pub length: u64, + pub data: CapsuleBlockDescriptorUnion, +} + +pub const CAPSULE_FLAGS_PERSIST_ACROSS_RESET: u32 = 0x00010000u32; +pub const CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE: u32 = 0x00020000u32; +pub const CAPSULE_FLAGS_INITIATE_RESET: u32 = 0x00040000u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CapsuleHeader { + pub capsule_guid: crate::base::Guid, + pub header_size: u32, + pub flags: u32, + pub capsule_image_size: u32, +} + +pub const OS_INDICATIONS_BOOT_TO_FW_UI: u64 = 0x0000000000000001u64; +pub const OS_INDICATIONS_TIMESTAMP_REVOCATION: u64 = 0x0000000000000002u64; +pub const OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED: u64 = 0x0000000000000004u64; +pub const OS_INDICATIONS_FMP_CAPSULE_SUPPORTED: u64 = 0x0000000000000008u64; +pub const OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED: u64 = 0x0000000000000010u64; +pub const OS_INDICATIONS_START_OS_RECOVERY: u64 = 0x0000000000000020u64; +pub const OS_INDICATIONS_START_PLATFORM_RECOVERY: u64 = 0x0000000000000040u64; + +pub const CAPSULE_REPORT_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x39b68c46, + 0xf7fb, + 0x441b, + 0xb6, + 0xec, + &[0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3], +); + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CapsuleResultVariableHeader { + pub variable_total_size: u32, + pub reserved: u32, + pub capsule_guid: crate::base::Guid, + pub capsule_processed: Time, + pub capsule_status: crate::base::Status, +} + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct CapsuleResultVariableFMP { + pub version: u16, + pub payload_index: u8, + pub update_image_index: u8, + pub update_image_type_id: crate::base::Guid, + pub capsule_file_name_and_target: [crate::base::Char16; N], +} + +// +// Tasks +// +// UEFI uses a simplified task model, and only ever runs on a single CPU. Usually, there is only +// one single task running on the system, which is the current execution. No interrupts are +// supported, other than timer interrupts. That is, all device management must be reliant on +// polling. +// +// You can, however, register callbacks to be run by the UEFI core. That is, either when execution +// is returned to the UEFI core, or when a timer interrupt fires, the scheduler will run the +// highest priority task next, interrupting the current task. You can use simple +// task-priority-levels (TPL) to adjust the priority of your callbacks and current task. +// + +pub const EVT_TIMER: u32 = 0x80000000u32; +pub const EVT_RUNTIME: u32 = 0x40000000u32; +pub const EVT_NOTIFY_WAIT: u32 = 0x00000100u32; +pub const EVT_NOTIFY_SIGNAL: u32 = 0x00000200u32; +pub const EVT_SIGNAL_EXIT_BOOT_SERVICES: u32 = 0x00000201u32; +pub const EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE: u32 = 0x60000202u32; + +pub type EventNotify = eficall! {fn(crate::base::Event, *mut core::ffi::c_void)}; + +pub const EVENT_GROUP_EXIT_BOOT_SERVICES: crate::base::Guid = crate::base::Guid::from_fields( + 0x27abf055, + 0xb1b8, + 0x4c26, + 0x80, + 0x48, + &[0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf], +); +pub const EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE: crate::base::Guid = crate::base::Guid::from_fields( + 0x13fa7698, + 0xc831, + 0x49c7, + 0x87, + 0xea, + &[0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96], +); +pub const EVENT_GROUP_MEMORY_MAP_CHANGE: crate::base::Guid = crate::base::Guid::from_fields( + 0x78bee926, + 0x692f, + 0x48fd, + 0x9e, + 0xdb, + &[0x1, 0x42, 0x2e, 0xf0, 0xd7, 0xab], +); +pub const EVENT_GROUP_READY_TO_BOOT: crate::base::Guid = crate::base::Guid::from_fields( + 0x7ce88fb3, + 0x4bd7, + 0x4679, + 0x87, + 0xa8, + &[0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b], +); +pub const EVENT_GROUP_RESET_SYSTEM: crate::base::Guid = crate::base::Guid::from_fields( + 0x62da6a56, + 0x13fb, + 0x485a, + 0xa8, + 0xda, + &[0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b], +); + +pub type TimerDelay = u32; + +pub const TIMER_CANCEL: TimerDelay = 0x00000000; +pub const TIMER_PERIODIC: TimerDelay = 0x00000001; +pub const TIMER_RELATIVE: TimerDelay = 0x00000002; + +pub const TPL_APPLICATION: crate::base::Tpl = 4; +pub const TPL_CALLBACK: crate::base::Tpl = 8; +pub const TPL_NOTIFY: crate::base::Tpl = 16; +pub const TPL_HIGH_LEVEL: crate::base::Tpl = 31; + +// +// Memory management +// +// The UEFI boot services provide you pool-allocation helpers to reserve memory. The region for +// each allocation can be selected by the caller, allowing to reserve memory that even survives +// beyond boot services. However, dynamic allocations can only performed via boot services, so no +// dynamic modifications can be done once you exit boot services. +// + +pub type AllocateType = u32; + +pub const ALLOCATE_ANY_PAGES: AllocateType = 0x00000000; +pub const ALLOCATE_MAX_ADDRESS: AllocateType = 0x00000001; +pub const ALLOCATE_ADDRESS: AllocateType = 0x00000002; + +pub type MemoryType = u32; + +pub const RESERVED_MEMORY_TYPE: MemoryType = 0x00000000; +pub const LOADER_CODE: MemoryType = 0x00000001; +pub const LOADER_DATA: MemoryType = 0x00000002; +pub const BOOT_SERVICES_CODE: MemoryType = 0x00000003; +pub const BOOT_SERVICES_DATA: MemoryType = 0x00000004; +pub const RUNTIME_SERVICES_CODE: MemoryType = 0x00000005; +pub const RUNTIME_SERVICES_DATA: MemoryType = 0x00000006; +pub const CONVENTIONAL_MEMORY: MemoryType = 0x00000007; +pub const UNUSABLE_MEMORY: MemoryType = 0x00000008; +pub const ACPI_RECLAIM_MEMORY: MemoryType = 0x00000009; +pub const ACPI_MEMORY_NVS: MemoryType = 0x0000000a; +pub const MEMORY_MAPPED_IO: MemoryType = 0x0000000b; +pub const MEMORY_MAPPED_IO_PORT_SPACE: MemoryType = 0x0000000c; +pub const PAL_CODE: MemoryType = 0x0000000d; +pub const PERSISTENT_MEMORY: MemoryType = 0x0000000e; + +pub const MEMORY_UC: u64 = 0x0000000000000001u64; +pub const MEMORY_WC: u64 = 0x0000000000000002u64; +pub const MEMORY_WT: u64 = 0x0000000000000004u64; +pub const MEMORY_WB: u64 = 0x0000000000000008u64; +pub const MEMORY_UCE: u64 = 0x0000000000000010u64; +pub const MEMORY_WP: u64 = 0x0000000000001000u64; +pub const MEMORY_RP: u64 = 0x0000000000002000u64; +pub const MEMORY_XP: u64 = 0x0000000000004000u64; +pub const MEMORY_NV: u64 = 0x0000000000008000u64; +pub const MEMORY_MORE_RELIABLE: u64 = 0x0000000000010000u64; +pub const MEMORY_RO: u64 = 0x0000000000020000u64; +pub const MEMORY_RUNTIME: u64 = 0x8000000000000000u64; + +pub const MEMORY_DESCRIPTOR_VERSION: u32 = 0x00000001u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct MemoryDescriptor { + pub r#type: u32, + pub physical_start: crate::base::PhysicalAddress, + pub virtual_start: crate::base::VirtualAddress, + pub number_of_pages: u64, + pub attribute: u64, +} + +// +// Protocol Management +// +// The UEFI driver model provides ways to have bus-drivers, device-drivers, and applications as +// separate, independent entities. They use protocols to communicate, and handles to refer to +// common state. Drivers and devices can be registered dynamically at runtime, and can support +// hotplugging. +// + +pub type InterfaceType = u32; + +pub const NATIVE_INTERFACE: InterfaceType = 0x00000000; + +pub type LocateSearchType = u32; + +pub const ALL_HANDLES: LocateSearchType = 0x00000000; +pub const BY_REGISTER_NOTIFY: LocateSearchType = 0x00000001; +pub const BY_PROTOCOL: LocateSearchType = 0x00000002; + +pub const OPEN_PROTOCOL_BY_HANDLE_PROTOCOL: u32 = 0x00000001u32; +pub const OPEN_PROTOCOL_GET_PROTOCOL: u32 = 0x00000002u32; +pub const OPEN_PROTOCOL_TEST_PROTOCOL: u32 = 0x00000004u32; +pub const OPEN_PROTOCOL_BY_CHILD_CONTROLLER: u32 = 0x00000008u32; +pub const OPEN_PROTOCOL_BY_DRIVER: u32 = 0x00000010u32; +pub const OPEN_PROTOCOL_EXCLUSIVE: u32 = 0x00000020u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct OpenProtocolInformationEntry { + pub agent_handle: crate::base::Handle, + pub controller_handle: crate::base::Handle, + pub attributes: u32, + pub open_count: u32, +} + +// +// Configuration Tables +// +// The system table contains an array of auxiliary tables, indexed by their GUID, called +// configuration tables. Each table uses the generic ConfigurationTable structure as header. +// + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct ConfigurationTable { + pub vendor_guid: crate::base::Guid, + pub vendor_table: *mut core::ffi::c_void, +} + +pub const PROPERTIES_TABLE_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0x880aaca3, + 0x4adc, + 0x4a04, + 0x90, + 0x79, + &[0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5], +); + +pub const PROPERTIES_TABLE_VERSION: u32 = 0x00010000u32; + +pub const PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA: u64 = 0x1u64; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct PropertiesTable { + pub version: u32, + pub length: u32, + pub memory_protection_attribute: u64, +} + +pub const MEMORY_ATTRIBUTES_TABLE_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xdcfa911d, + 0x26eb, + 0x469f, + 0xa2, + 0x20, + &[0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20], +); + +pub const MEMORY_ATTRIBUTES_TABLE_VERSION: u32 = 0x00000001u32; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct MemoryAttributesTable { + pub version: u32, + pub number_of_entries: u32, + pub descriptor_size: u32, + pub reserved: u32, + pub entry: [MemoryDescriptor; N], +} + +// +// Global Tables +// +// UEFI uses no global state, so all access to UEFI internal state is done through vtables you get +// passed to your entry-point. The global entry is the system-table, which encorporates several +// sub-tables, including the runtime and boot service tables, and configuration tables (including +// vendor extensions). +// + +pub const SPECIFICATION_REVISION: u32 = SYSTEM_TABLE_REVISION; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct TableHeader { + pub signature: u64, + pub revision: u32, + pub header_size: u32, + pub crc32: u32, + pub reserved: u32, +} + +pub const RUNTIME_SERVICES_SIGNATURE: u64 = 0x56524553544e5552u64; // "RUNTSERV" +pub const RUNTIME_SERVICES_REVISION: u32 = SPECIFICATION_REVISION; + +pub type RuntimeGetTime = eficall! {fn( + *mut Time, + *mut TimeCapabilities, +) -> crate::base::Status}; + +pub type RuntimeSetTime = eficall! {fn( + *mut Time, +) -> crate::base::Status}; + +pub type RuntimeGetWakeupTime = eficall! {fn( + *mut crate::base::Boolean, + *mut crate::base::Boolean, + *mut Time, +) -> crate::base::Status}; + +pub type RuntimeSetWakeupTime = eficall! {fn( + crate::base::Boolean, + *mut Time, +) -> crate::base::Status}; + +pub type RuntimeSetVirtualAddressMap = eficall! {fn( + usize, + usize, + u32, + *mut MemoryDescriptor, +) -> crate::base::Status}; + +pub type RuntimeConvertPointer = eficall! {fn( + usize, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type RuntimeGetVariable = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Guid, + *mut u32, + *mut usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type RuntimeGetNextVariableName = eficall! {fn( + *mut usize, + *mut crate::base::Char16, + *mut crate::base::Guid, +) -> crate::base::Status}; + +pub type RuntimeSetVariable = eficall! {fn( + *mut crate::base::Char16, + *mut crate::base::Guid, + u32, + usize, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type RuntimeGetNextHighMonoCount = eficall! {fn( + *mut u32, +) -> crate::base::Status}; + +pub type RuntimeResetSystem = eficall! {fn( + ResetType, + crate::base::Status, + usize, + *mut core::ffi::c_void, +)}; + +pub type RuntimeUpdateCapsule = eficall! {fn( + *mut *mut CapsuleHeader, + usize, + crate::base::PhysicalAddress, +) -> crate::base::Status}; + +pub type RuntimeQueryCapsuleCapabilities = eficall! {fn( + *mut *mut CapsuleHeader, + usize, + *mut u64, + *mut ResetType, +) -> crate::base::Status}; + +pub type RuntimeQueryVariableInfo = eficall! {fn( + u32, + *mut u64, + *mut u64, + *mut u64, +) -> crate::base::Status}; + +#[repr(C)] +pub struct RuntimeServices { + pub hdr: TableHeader, + + pub get_time: RuntimeGetTime, + pub set_time: RuntimeSetTime, + pub get_wakeup_time: RuntimeGetWakeupTime, + pub set_wakeup_time: RuntimeSetWakeupTime, + + pub set_virtual_address_map: RuntimeSetVirtualAddressMap, + pub convert_pointer: RuntimeConvertPointer, + + pub get_variable: RuntimeGetVariable, + pub get_next_variable_name: RuntimeGetNextVariableName, + pub set_variable: RuntimeSetVariable, + + pub get_next_high_mono_count: RuntimeGetNextHighMonoCount, + pub reset_system: RuntimeResetSystem, + + pub update_capsule: RuntimeUpdateCapsule, + pub query_capsule_capabilities: RuntimeQueryCapsuleCapabilities, + pub query_variable_info: RuntimeQueryVariableInfo, +} + +pub const BOOT_SERVICES_SIGNATURE: u64 = 0x56524553544f4f42u64; // "BOOTSERV" +pub const BOOT_SERVICES_REVISION: u32 = SPECIFICATION_REVISION; + +pub type BootRaiseTpl = eficall! {fn( + crate::base::Tpl, +) -> crate::base::Tpl}; + +pub type BootRestoreTpl = eficall! {fn( + crate::base::Tpl, +)}; + +pub type BootAllocatePages = eficall! {fn( + AllocateType, + MemoryType, + usize, + *mut crate::base::PhysicalAddress, +) -> crate::base::Status}; + +pub type BootFreePages = eficall! {fn( + crate::base::PhysicalAddress, + usize, +) -> crate::base::Status}; + +pub type BootGetMemoryMap = eficall! {fn( + *mut usize, + *mut MemoryDescriptor, + *mut usize, + *mut usize, + *mut u32, +) -> crate::base::Status}; + +pub type BootAllocatePool = eficall! {fn( + MemoryType, + usize, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootFreePool = eficall! {fn( + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootCreateEvent = eficall! {fn( + u32, + crate::base::Tpl, + Option, + *mut core::ffi::c_void, + *mut crate::base::Event, +) -> crate::base::Status}; + +pub type BootSetTimer = eficall! {fn( + crate::base::Event, + TimerDelay, + u64, +) -> crate::base::Status}; + +pub type BootWaitForEvent = eficall! {fn( + usize, + *mut crate::base::Event, + *mut usize, +) -> crate::base::Status}; + +pub type BootSignalEvent = eficall! {fn( + crate::base::Event, +) -> crate::base::Status}; + +pub type BootCloseEvent = eficall! {fn( + crate::base::Event, +) -> crate::base::Status}; + +pub type BootCheckEvent = eficall! {fn( + crate::base::Event, +) -> crate::base::Status}; + +pub type BootInstallProtocolInterface = eficall! {fn( + *mut crate::base::Handle, + *mut crate::base::Guid, + InterfaceType, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootReinstallProtocolInterface = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + *mut core::ffi::c_void, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootUninstallProtocolInterface = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootHandleProtocol = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootRegisterProtocolNotify = eficall! {fn( + *mut crate::base::Guid, + crate::base::Event, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootLocateHandle = eficall! {fn( + LocateSearchType, + *mut crate::base::Guid, + *mut core::ffi::c_void, + *mut usize, + *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type BootLocateDevicePath = eficall! {fn( + *mut crate::base::Guid, + *mut *mut crate::protocols::device_path::Protocol, + *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type BootInstallConfigurationTable = eficall! {fn( + *mut crate::base::Guid, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootLoadImage = eficall! {fn( + crate::base::Boolean, + crate::base::Handle, + *mut crate::protocols::device_path::Protocol, + *mut core::ffi::c_void, + usize, + *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type BootStartImage = eficall! {fn( + crate::base::Handle, + *mut usize, + *mut *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type BootExit = eficall! {fn( + crate::base::Handle, + crate::base::Status, + usize, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type BootUnloadImage = eficall! {fn( + crate::base::Handle, +) -> crate::base::Status}; + +pub type BootExitBootServices = eficall! {fn( + crate::base::Handle, + usize, +) -> crate::base::Status}; + +pub type BootGetNextMonotonicCount = eficall! {fn( + *mut u64, +) -> crate::base::Status}; + +pub type BootStall = eficall! {fn( + usize, +) -> crate::base::Status}; + +pub type BootSetWatchdogTimer = eficall! {fn( + usize, + u64, + usize, + *mut crate::base::Char16, +) -> crate::base::Status}; + +pub type BootConnectController = eficall! {fn( + crate::base::Handle, + *mut crate::base::Handle, + *mut crate::protocols::device_path::Protocol, + crate::base::Boolean, +) -> crate::base::Status}; + +pub type BootDisconnectController = eficall! {fn( + crate::base::Handle, + crate::base::Handle, + crate::base::Handle, +) -> crate::base::Status}; + +pub type BootOpenProtocol = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + *mut *mut core::ffi::c_void, + crate::base::Handle, + crate::base::Handle, + u32, +) -> crate::base::Status}; + +pub type BootCloseProtocol = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + crate::base::Handle, + crate::base::Handle, +) -> crate::base::Status}; + +pub type BootOpenProtocolInformation = eficall! {fn( + crate::base::Handle, + *mut crate::base::Guid, + *mut *mut OpenProtocolInformationEntry, + *mut usize, +) -> crate::base::Status}; + +pub type BootProtocolsPerHandle = eficall! {fn( + crate::base::Handle, + *mut *mut *mut crate::base::Guid, + *mut usize, +) -> crate::base::Status}; + +pub type BootLocateHandleBuffer = eficall! {fn( + LocateSearchType, + *mut crate::base::Guid, + *mut core::ffi::c_void, + *mut usize, + *mut *mut crate::base::Handle, +) -> crate::base::Status}; + +pub type BootLocateProtocol = eficall! {fn( + *mut crate::base::Guid, + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootInstallMultipleProtocolInterfaces = eficall! {fn( + *mut crate::base::Handle, + // XXX: Actual definition is variadic. See eficall!{} for details. + *mut core::ffi::c_void, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootUninstallMultipleProtocolInterfaces = eficall! {fn( + *mut crate::base::Handle, + // XXX: Actual definition is variadic. See eficall!{} for details. + *mut core::ffi::c_void, + *mut core::ffi::c_void, +) -> crate::base::Status}; + +pub type BootCalculateCrc32 = eficall! {fn( + *mut core::ffi::c_void, + usize, + *mut u32, +) -> crate::base::Status}; + +pub type BootCopyMem = eficall! {fn( + *mut core::ffi::c_void, + *mut core::ffi::c_void, + usize, +)}; + +pub type BootSetMem = eficall! {fn( + *mut core::ffi::c_void, + usize, + u8, +)}; + +pub type BootCreateEventEx = eficall! {fn( + u32, + crate::base::Tpl, + Option, + *const core::ffi::c_void, + *const crate::base::Guid, + *mut crate::base::Event, +) -> crate::base::Status}; + +#[repr(C)] +pub struct BootServices { + pub hdr: TableHeader, + + pub raise_tpl: BootRaiseTpl, + pub restore_tpl: BootRestoreTpl, + + pub allocate_pages: BootAllocatePages, + pub free_pages: BootFreePages, + pub get_memory_map: BootGetMemoryMap, + pub allocate_pool: BootAllocatePool, + pub free_pool: BootFreePool, + + pub create_event: BootCreateEvent, + pub set_timer: BootSetTimer, + pub wait_for_event: BootWaitForEvent, + pub signal_event: BootSignalEvent, + pub close_event: BootCloseEvent, + pub check_event: BootCheckEvent, + + pub install_protocol_interface: BootInstallProtocolInterface, + pub reinstall_protocol_interface: BootReinstallProtocolInterface, + pub uninstall_protocol_interface: BootUninstallProtocolInterface, + pub handle_protocol: BootHandleProtocol, + pub reserved: *mut core::ffi::c_void, + pub register_protocol_notify: BootRegisterProtocolNotify, + pub locate_handle: BootLocateHandle, + pub locate_device_path: BootLocateDevicePath, + + pub install_configuration_table: BootInstallConfigurationTable, + + pub load_image: BootLoadImage, + pub start_image: BootStartImage, + pub exit: BootExit, + pub unload_image: BootUnloadImage, + pub exit_boot_services: BootExitBootServices, + + pub get_next_monotonic_count: BootGetNextMonotonicCount, + pub stall: BootStall, + pub set_watchdog_timer: BootSetWatchdogTimer, + + // 1.1+ + pub connect_controller: BootConnectController, + pub disconnect_controller: BootDisconnectController, + + pub open_protocol: BootOpenProtocol, + pub close_protocol: BootCloseProtocol, + pub open_protocol_information: BootOpenProtocolInformation, + + pub protocols_per_handle: BootProtocolsPerHandle, + pub locate_handle_buffer: BootLocateHandleBuffer, + pub locate_protocol: BootLocateProtocol, + pub install_multiple_protocol_interfaces: BootInstallMultipleProtocolInterfaces, + pub uninstall_multiple_protocol_interfaces: BootUninstallMultipleProtocolInterfaces, + + pub calculate_crc32: BootCalculateCrc32, + + pub copy_mem: BootCopyMem, + pub set_mem: BootSetMem, + + // 2.0+ + pub create_event_ex: BootCreateEventEx, +} + +pub const SYSTEM_TABLE_REVISION_2_70: u32 = (2 << 16) | (70); +pub const SYSTEM_TABLE_REVISION_2_60: u32 = (2 << 16) | (60); +pub const SYSTEM_TABLE_REVISION_2_50: u32 = (2 << 16) | (50); +pub const SYSTEM_TABLE_REVISION_2_40: u32 = (2 << 16) | (40); +pub const SYSTEM_TABLE_REVISION_2_31: u32 = (2 << 16) | (31); +pub const SYSTEM_TABLE_REVISION_2_30: u32 = (2 << 16) | (30); +pub const SYSTEM_TABLE_REVISION_2_20: u32 = (2 << 16) | (20); +pub const SYSTEM_TABLE_REVISION_2_10: u32 = (2 << 16) | (10); +pub const SYSTEM_TABLE_REVISION_2_00: u32 = (2 << 16) | (0); +pub const SYSTEM_TABLE_REVISION_1_10: u32 = (1 << 16) | (10); +pub const SYSTEM_TABLE_REVISION_1_02: u32 = (1 << 16) | (2); + +pub const SYSTEM_TABLE_SIGNATURE: u64 = 0x5453595320494249u64; // "IBI SYST" +pub const SYSTEM_TABLE_REVISION: u32 = SYSTEM_TABLE_REVISION_2_70; + +#[repr(C)] +pub struct SystemTable { + pub hdr: TableHeader, + pub firmware_vendor: *mut crate::base::Char16, + pub firmware_revision: u32, + + pub console_in_handle: crate::base::Handle, + pub con_in: *mut crate::protocols::simple_text_input::Protocol, + pub console_out_handle: crate::base::Handle, + pub con_out: *mut crate::protocols::simple_text_output::Protocol, + pub standard_error_handle: crate::base::Handle, + pub std_err: *mut crate::protocols::simple_text_output::Protocol, + + pub runtime_services: *mut RuntimeServices, + pub boot_services: *mut BootServices, + + pub number_of_table_entries: usize, + pub configuration_table: *mut ConfigurationTable, +} diff --git a/vendor/r-efi/src/vendor.rs b/vendor/r-efi/src/vendor.rs new file mode 100644 index 000000000..d931b8fc3 --- /dev/null +++ b/vendor/r-efi/src/vendor.rs @@ -0,0 +1,10 @@ +//! UEFI Vendor Protocols +//! +//! Many vendor protocols are not part of the official specification. But we +//! still allow importing them here, so we have a central place to collect +//! them. Note that we separate them by vendor-name, which is not the best +//! name-space but should be acceptible. + +pub mod intel { + pub mod console_control; +} diff --git a/vendor/r-efi/src/vendor/intel/console_control.rs b/vendor/r-efi/src/vendor/intel/console_control.rs new file mode 100644 index 000000000..a6fbf1588 --- /dev/null +++ b/vendor/r-efi/src/vendor/intel/console_control.rs @@ -0,0 +1,37 @@ +//! Console Control Protocol +//! +//! The console-control protocols allows modifying the behavior of the default +//! console device. It is supported by TianoCore and widely adopted. + +pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( + 0xf42f7782, + 0x012e, + 0x4c12, + 0x99, + 0x56, + &[0x49, 0xf9, 0x43, 0x04, 0xf7, 0x21], +); + +pub type ScreenMode = u32; + +pub const SCREEN_TEXT: ScreenMode = 0x00000000; +pub const SCREEN_GRAPHICS: ScreenMode = 0x00000001; +pub const SCREEN_MAX_VALUE: ScreenMode = 0x00000002; + +#[repr(C)] +pub struct Protocol { + pub get_mode: eficall! {fn( + *mut Protocol, + *mut ScreenMode, + *mut crate::base::Boolean, + *mut crate::base::Boolean, + ) -> crate::base::Status}, + pub set_mode: eficall! {fn( + *mut Protocol, + ScreenMode, + ) -> crate::base::Status}, + pub lock_std_in: eficall! {fn( + *mut Protocol, + *mut crate::base::Char16, + ) -> crate::base::Status}, +} -- cgit v1.2.3