diff options
author | Jeongik Cha <jeongik@google.com> | 2023-09-27 08:11:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-09-27 08:11:50 +0000 |
commit | c604d607a4a150a1c70db5afe88612b9b814c77b (patch) | |
tree | bf6963760953be1f66b5a30a57d469781b95f3bb | |
parent | 8006e211b2579aa72bae626ed639d8edcbc7a025 (diff) | |
parent | 1676fc7c3cf66abbaf6a3ca7d9fb5e240b287fd9 (diff) | |
download | virtio-bindings-c604d607a4a150a1c70db5afe88612b9b814c77b.tar.gz |
Import virtio-bindings am: 1676fc7c3c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/virtio-bindings/+/2752019
Change-Id: Ieb1d9fd86af88e0229f172e7bf1d0196226b17d1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 6 | ||||
-rw-r--r-- | Android.bp | 13 | ||||
-rw-r--r-- | CHANGELOG.md | 33 | ||||
-rw-r--r-- | CONTRIBUTING.md | 50 | ||||
-rw-r--r-- | Cargo.toml | 27 | ||||
-rw-r--r-- | Cargo.toml.orig | 18 | ||||
-rw-r--r-- | LICENSE | 235 | ||||
-rw-r--r-- | LICENSE-APACHE | 202 | ||||
-rw-r--r-- | LICENSE-BSD-3-Clause | 27 | ||||
-rw-r--r-- | METADATA | 19 | ||||
-rw-r--r-- | MODULE_LICENSE_APACHE2 | 0 | ||||
-rw-r--r-- | MODULE_LICENSE_BSD | 0 | ||||
-rw-r--r-- | OWNERS | 1 | ||||
-rw-r--r-- | README.md | 17 | ||||
-rw-r--r-- | src/lib.rs | 20 | ||||
-rw-r--r-- | src/virtio_blk.rs | 857 | ||||
-rw-r--r-- | src/virtio_config.rs | 20 | ||||
-rw-r--r-- | src/virtio_gpu.rs | 2466 | ||||
-rw-r--r-- | src/virtio_mmio.rs | 36 | ||||
-rw-r--r-- | src/virtio_net/generated.rs | 1095 | ||||
-rw-r--r-- | src/virtio_net/mod.rs | 72 | ||||
-rw-r--r-- | src/virtio_ring.rs | 448 | ||||
-rw-r--r-- | src/virtio_scsi.rs | 711 |
23 files changed, 6373 insertions, 0 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json new file mode 100644 index 0000000..d648267 --- /dev/null +++ b/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "854e098e4871f2ea487b1853bc21f02d6c1e8057" + }, + "path_in_vcs": "crates/virtio-bindings" +}
\ No newline at end of file diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..03a89fc --- /dev/null +++ b/Android.bp @@ -0,0 +1,13 @@ +// This file is generated by cargo2android.py --run. +// Do not modify this file as changes will be overridden on upgrade. + + + +rust_library_host { + name: "libvirtio_bindings", + crate_name: "virtio_bindings", + cargo_env_compat: true, + cargo_pkg_version: "0.2.1", + srcs: ["src/lib.rs"], + edition: "2021", +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8693370 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# v0.2.1 + +- Regenerate bindings with Linux 6.3. +- Added bindings for virtio_scsi.h +- Updated vm-memory from 0.10.0 to 0.12.0. + +# v0.2.0 + +## Added + +- Add bindings for virtio_config.h, virtio_gpu.h, and virtio_mmio.h + +## Changed + +- Regenerate bindings with Glibc 2.36, Linux 6.1, and bindgen 0.63.0 +- The `virtio-v4_14_0` and `virtio-v5_0_0` crate features are now no-ops + — the latest version of the bindings is now always used. +- The bindings modules no longer accidentally re-export constants from + Glibc or other kernel headers. As a result of this, it is no longer + possible to reference constants from virtio_config.h through + e.g. the `virtio_net` module, only through the `virtio_config` + module. + +# v0.1.0 + +This is the first `virtio-bindings` crate release. + +This crate provides Rust FFI bindings to the +[Virtual I/O Device (VIRTIO)](https://docs.oasis-open.org/virtio/virtio/v1.1/virtio-v1.1.html) +Linux kernel API. With this first release, the bindings are for the Linux kernel +versions 4.14 and 5.0. + +The bindings are generated using [bindgen](https://crates.io/crates/bindgen). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2dabef0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Contributing to virtio-bindings + +## Dependencies + +### Bindgen +The bindings are currently generated using +[bindgen](https://rust-lang.github.io/rust-bindgen/) version 0.63.0: +```bash +cargo install bindgen-cli --vers 0.63.0 +``` + +### Linux Kernel +Generating bindings depends on the Linux kernel, so you need to have the +repository on your machine: + +```bash +git clone https://github.com/torvalds/linux.git +``` + +## Example for updating to a new kernel version + +For this example we assume that you have both linux and virtio-bindings +repositories in your root. + +```bash +# linux is the repository that you cloned at the previous step. +cd linux +# Step 1: Checkout the version you want to generate the bindings for. +git checkout v5.0 + +# Step 2: Generate the bindings from the kernel headers. We need to +# generate a file for each one of the virtio headers we're interested on. +# For the moment, we're generating "virtio_blk", "virtio_gpu", "virtio_mmio", +# "virtio_net", "virtio_ring" and "virtio_scsi". Feel free to add additional header files if +# you need them for your project. +make headers_install INSTALL_HDR_PATH=v5_0_headers +cd v5_0_headers +for i in virtio_blk virtio_config virtio_gpu virtio_mmio virtio_net virtio_ring virtio_scsi ; do \ + bindgen include/linux/$i.h -o $i.rs \ + --allowlist-file include/linux/$i.h \ + --with-derive-default \ + --with-derive-partialeq \ + -- -Iinclude +done +cd ~ + +# Step 6: Copy the generated files to the new version module. +cp linux/v5_0_headers/*.rs vm-virtio/crates/virtio-bindings/src +mv vm-virtio/crates/virtio-bindings/src/virtio_net.rs vm-virtio/crates/virtio-bindings/src/virtio_net/generated.rs +``` diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e1e3ce7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,27 @@ +# 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 = "2021" +name = "virtio-bindings" +version = "0.2.1" +authors = ["Sergio Lopez <slp@redhat.com>"] +description = "Rust FFI bindings to virtio generated using bindgen." +readme = "README.md" +keywords = ["virtio"] +license = "BSD-3-Clause OR Apache-2.0" +repository = "https://github.com/rust-vmm/vm-virtio" + +[dependencies] + +[features] +virtio-v4_14_0 = [] +virtio-v5_0_0 = [] diff --git a/Cargo.toml.orig b/Cargo.toml.orig new file mode 100644 index 0000000..5fe4f03 --- /dev/null +++ b/Cargo.toml.orig @@ -0,0 +1,18 @@ +[package] +name = "virtio-bindings" +version = "0.2.1" +authors = ["Sergio Lopez <slp@redhat.com>"] +description = "Rust FFI bindings to virtio generated using bindgen." +repository = "https://github.com/rust-vmm/vm-virtio" +readme = "README.md" +edition = "2021" +keywords = ["virtio"] +license = "BSD-3-Clause OR Apache-2.0" + +[features] +# Kernel version features are deprecated and no longer have any effect, +# as the kernel headers are backwards compatible. +virtio-v4_14_0 = [] +virtio-v5_0_0 = [] + +[dependencies] @@ -0,0 +1,235 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + +--- + +// Copyright 2017 The Chromium OS Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--- + diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/LICENSE-BSD-3-Clause b/LICENSE-BSD-3-Clause new file mode 100644 index 0000000..8bafca3 --- /dev/null +++ b/LICENSE-BSD-3-Clause @@ -0,0 +1,27 @@ +// Copyright 2017 The Chromium OS Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..0fdac7d --- /dev/null +++ b/METADATA @@ -0,0 +1,19 @@ +name: "virtio-bindings" +description: "Rust FFI bindings to virtio generated using bindgen." +third_party { + identifier { + type: "crates.io" + value: "https://crates.io/crates/virtio-bindings" + } + identifier { + type: "Archive" + value: "https://static.crates.io/crates/virtio-bindings/virtio-bindings-0.2.1.crate" + } + version: "0.2.1" + license_type: NOTICE + last_upgrade_date { + year: 2023 + month: 8 + day: 23 + } +} diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_APACHE2 diff --git a/MODULE_LICENSE_BSD b/MODULE_LICENSE_BSD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_BSD @@ -0,0 +1 @@ +include platform/prebuilts/rust:master:/OWNERS diff --git a/README.md b/README.md new file mode 100644 index 0000000..994aec3 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# virtio-bindings +Rust FFI bindings to virtio generated using [bindgen](https://crates.io/crates/bindgen). + +## Usage +Add this to your `Cargo.toml`: +```toml +virtio-bindings = "0.2" +``` +You can then import the bindings where you need them. As an example, to grab the +bindings for virtio-blk, you can do: +```rust +use virtio_bindings::bindings::virtio_blk::*; +``` + +## Development + +To update the bindings, follow the steps in the [Contributing Document](CONTRIBUTING.md). diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8040e4e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,20 @@ +// Copyright 2019 Red Hat, Inc. All Rights Reserved. +// SPDX-License-Identifier: (BSD-3-Clause OR Apache-2.0) + +#![allow(clippy::all)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(clippy::undocumented_unsafe_blocks)] + +pub mod virtio_blk; +pub mod virtio_config; +pub mod virtio_gpu; +pub mod virtio_mmio; +pub mod virtio_net; +pub mod virtio_ring; +pub mod virtio_scsi; + +pub mod bindings { + pub use super::{virtio_blk, virtio_config, virtio_mmio, virtio_net, virtio_ring, virtio_scsi}; +} diff --git a/src/virtio_blk.rs b/src/virtio_blk.rs new file mode 100644 index 0000000..a2e5fb2 --- /dev/null +++ b/src/virtio_blk.rs @@ -0,0 +1,857 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); +impl<T> __IncompleteArrayField<T> { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const VIRTIO_BLK_F_SIZE_MAX: u32 = 1; +pub const VIRTIO_BLK_F_SEG_MAX: u32 = 2; +pub const VIRTIO_BLK_F_GEOMETRY: u32 = 4; +pub const VIRTIO_BLK_F_RO: u32 = 5; +pub const VIRTIO_BLK_F_BLK_SIZE: u32 = 6; +pub const VIRTIO_BLK_F_TOPOLOGY: u32 = 10; +pub const VIRTIO_BLK_F_MQ: u32 = 12; +pub const VIRTIO_BLK_F_DISCARD: u32 = 13; +pub const VIRTIO_BLK_F_WRITE_ZEROES: u32 = 14; +pub const VIRTIO_BLK_F_SECURE_ERASE: u32 = 16; +pub const VIRTIO_BLK_F_ZONED: u32 = 17; +pub const VIRTIO_BLK_F_BARRIER: u32 = 0; +pub const VIRTIO_BLK_F_SCSI: u32 = 7; +pub const VIRTIO_BLK_F_FLUSH: u32 = 9; +pub const VIRTIO_BLK_F_CONFIG_WCE: u32 = 11; +pub const VIRTIO_BLK_F_WCE: u32 = 9; +pub const VIRTIO_BLK_ID_BYTES: u32 = 20; +pub const VIRTIO_BLK_T_IN: u32 = 0; +pub const VIRTIO_BLK_T_OUT: u32 = 1; +pub const VIRTIO_BLK_T_SCSI_CMD: u32 = 2; +pub const VIRTIO_BLK_T_FLUSH: u32 = 4; +pub const VIRTIO_BLK_T_GET_ID: u32 = 8; +pub const VIRTIO_BLK_T_DISCARD: u32 = 11; +pub const VIRTIO_BLK_T_WRITE_ZEROES: u32 = 13; +pub const VIRTIO_BLK_T_SECURE_ERASE: u32 = 14; +pub const VIRTIO_BLK_T_ZONE_APPEND: u32 = 15; +pub const VIRTIO_BLK_T_ZONE_REPORT: u32 = 16; +pub const VIRTIO_BLK_T_ZONE_OPEN: u32 = 18; +pub const VIRTIO_BLK_T_ZONE_CLOSE: u32 = 20; +pub const VIRTIO_BLK_T_ZONE_FINISH: u32 = 22; +pub const VIRTIO_BLK_T_ZONE_RESET: u32 = 24; +pub const VIRTIO_BLK_T_ZONE_RESET_ALL: u32 = 26; +pub const VIRTIO_BLK_T_BARRIER: u32 = 2147483648; +pub const VIRTIO_BLK_Z_NONE: u32 = 0; +pub const VIRTIO_BLK_Z_HM: u32 = 1; +pub const VIRTIO_BLK_Z_HA: u32 = 2; +pub const VIRTIO_BLK_ZT_CONV: u32 = 1; +pub const VIRTIO_BLK_ZT_SWR: u32 = 2; +pub const VIRTIO_BLK_ZT_SWP: u32 = 3; +pub const VIRTIO_BLK_ZS_NOT_WP: u32 = 0; +pub const VIRTIO_BLK_ZS_EMPTY: u32 = 1; +pub const VIRTIO_BLK_ZS_IOPEN: u32 = 2; +pub const VIRTIO_BLK_ZS_EOPEN: u32 = 3; +pub const VIRTIO_BLK_ZS_CLOSED: u32 = 4; +pub const VIRTIO_BLK_ZS_RDONLY: u32 = 13; +pub const VIRTIO_BLK_ZS_FULL: u32 = 14; +pub const VIRTIO_BLK_ZS_OFFLINE: u32 = 15; +pub const VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP: u32 = 1; +pub const VIRTIO_BLK_S_OK: u32 = 0; +pub const VIRTIO_BLK_S_IOERR: u32 = 1; +pub const VIRTIO_BLK_S_UNSUPP: u32 = 2; +pub const VIRTIO_BLK_S_ZONE_INVALID_CMD: u32 = 3; +pub const VIRTIO_BLK_S_ZONE_UNALIGNED_WP: u32 = 4; +pub const VIRTIO_BLK_S_ZONE_OPEN_RESOURCE: u32 = 5; +pub const VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE: u32 = 6; +pub type __u8 = ::std::os::raw::c_uchar; +pub type __u16 = ::std::os::raw::c_ushort; +pub type __u32 = ::std::os::raw::c_uint; +pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __le32 = __u32; +pub type __le64 = __u64; +pub type __virtio16 = __u16; +pub type __virtio32 = __u32; +pub type __virtio64 = __u64; +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_blk_config { + pub capacity: __virtio64, + pub size_max: __virtio32, + pub seg_max: __virtio32, + pub geometry: virtio_blk_config_virtio_blk_geometry, + pub blk_size: __virtio32, + pub physical_block_exp: __u8, + pub alignment_offset: __u8, + pub min_io_size: __virtio16, + pub opt_io_size: __virtio32, + pub wce: __u8, + pub unused: __u8, + pub num_queues: __virtio16, + pub max_discard_sectors: __virtio32, + pub max_discard_seg: __virtio32, + pub discard_sector_alignment: __virtio32, + pub max_write_zeroes_sectors: __virtio32, + pub max_write_zeroes_seg: __virtio32, + pub write_zeroes_may_unmap: __u8, + pub unused1: [__u8; 3usize], + pub max_secure_erase_sectors: __virtio32, + pub max_secure_erase_seg: __virtio32, + pub secure_erase_sector_alignment: __virtio32, + pub zoned: virtio_blk_config_virtio_blk_zoned_characteristics, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_blk_config_virtio_blk_geometry { + pub cylinders: __virtio16, + pub heads: __u8, + pub sectors: __u8, +} +#[test] +fn bindgen_test_layout_virtio_blk_config_virtio_blk_geometry() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_config_virtio_blk_geometry> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_config_virtio_blk_geometry>(), + 4usize, + concat!( + "Size of: ", + stringify!(virtio_blk_config_virtio_blk_geometry) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_config_virtio_blk_geometry>(), + 2usize, + concat!( + "Alignment of ", + stringify!(virtio_blk_config_virtio_blk_geometry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cylinders) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_geometry), + "::", + stringify!(cylinders) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).heads) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_geometry), + "::", + stringify!(heads) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sectors) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_geometry), + "::", + stringify!(sectors) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_blk_config_virtio_blk_zoned_characteristics { + pub zone_sectors: __virtio32, + pub max_open_zones: __virtio32, + pub max_active_zones: __virtio32, + pub max_append_sectors: __virtio32, + pub write_granularity: __virtio32, + pub model: __u8, + pub unused2: [__u8; 3usize], +} +#[test] +fn bindgen_test_layout_virtio_blk_config_virtio_blk_zoned_characteristics() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_config_virtio_blk_zoned_characteristics> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_config_virtio_blk_zoned_characteristics>(), + 24usize, + concat!( + "Size of: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_config_virtio_blk_zoned_characteristics>(), + 4usize, + concat!( + "Alignment of ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zone_sectors) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(zone_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_open_zones) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(max_open_zones) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_active_zones) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(max_active_zones) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_append_sectors) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(max_append_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).write_granularity) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(write_granularity) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).model) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(model) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).unused2) as usize - ptr as usize }, + 21usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config_virtio_blk_zoned_characteristics), + "::", + stringify!(unused2) + ) + ); +} +#[test] +fn bindgen_test_layout_virtio_blk_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_config> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_config>(), + 96usize, + concat!("Size of: ", stringify!(virtio_blk_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_config>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_blk_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capacity) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(capacity) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size_max) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(size_max) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seg_max) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(seg_max) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).geometry) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(geometry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).blk_size) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(blk_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).physical_block_exp) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(physical_block_exp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).alignment_offset) as usize - ptr as usize }, + 25usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(alignment_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).min_io_size) as usize - ptr as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(min_io_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).opt_io_size) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(opt_io_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).wce) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(wce) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).unused) as usize - ptr as usize }, + 33usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(unused) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_queues) as usize - ptr as usize }, + 34usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(num_queues) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_discard_sectors) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_discard_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_discard_seg) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_discard_seg) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).discard_sector_alignment) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(discard_sector_alignment) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_write_zeroes_sectors) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_write_zeroes_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_write_zeroes_seg) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_write_zeroes_seg) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).write_zeroes_may_unmap) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(write_zeroes_may_unmap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).unused1) as usize - ptr as usize }, + 57usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(unused1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_secure_erase_sectors) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_secure_erase_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_secure_erase_seg) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(max_secure_erase_seg) + ) + ); + assert_eq!( + unsafe { + ::std::ptr::addr_of!((*ptr).secure_erase_sector_alignment) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(secure_erase_sector_alignment) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zoned) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_config), + "::", + stringify!(zoned) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_blk_outhdr { + pub type_: __virtio32, + pub ioprio: __virtio32, + pub sector: __virtio64, +} +#[test] +fn bindgen_test_layout_virtio_blk_outhdr() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_outhdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_outhdr>(), + 16usize, + concat!("Size of: ", stringify!(virtio_blk_outhdr)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_outhdr>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_blk_outhdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_outhdr), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ioprio) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_outhdr), + "::", + stringify!(ioprio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sector) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_outhdr), + "::", + stringify!(sector) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct virtio_blk_zone_descriptor { + pub z_cap: __virtio64, + pub z_start: __virtio64, + pub z_wp: __virtio64, + pub z_type: __u8, + pub z_state: __u8, + pub reserved: [__u8; 38usize], +} +#[test] +fn bindgen_test_layout_virtio_blk_zone_descriptor() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_zone_descriptor> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_zone_descriptor>(), + 64usize, + concat!("Size of: ", stringify!(virtio_blk_zone_descriptor)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_zone_descriptor>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_blk_zone_descriptor)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z_cap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(z_cap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z_start) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(z_start) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z_wp) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(z_wp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z_type) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(z_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z_state) as usize - ptr as usize }, + 25usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(z_state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_descriptor), + "::", + stringify!(reserved) + ) + ); +} +impl Default for virtio_blk_zone_descriptor { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug)] +pub struct virtio_blk_zone_report { + pub nr_zones: __virtio64, + pub reserved: [__u8; 56usize], + pub zones: __IncompleteArrayField<virtio_blk_zone_descriptor>, +} +#[test] +fn bindgen_test_layout_virtio_blk_zone_report() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_zone_report> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_zone_report>(), + 64usize, + concat!("Size of: ", stringify!(virtio_blk_zone_report)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_zone_report>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_blk_zone_report)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr_zones) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_report), + "::", + stringify!(nr_zones) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_report), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zones) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_zone_report), + "::", + stringify!(zones) + ) + ); +} +impl Default for virtio_blk_zone_report { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_blk_discard_write_zeroes { + pub sector: __le64, + pub num_sectors: __le32, + pub flags: __le32, +} +#[test] +fn bindgen_test_layout_virtio_blk_discard_write_zeroes() { + const UNINIT: ::std::mem::MaybeUninit<virtio_blk_discard_write_zeroes> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_blk_discard_write_zeroes>(), + 16usize, + concat!("Size of: ", stringify!(virtio_blk_discard_write_zeroes)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_blk_discard_write_zeroes>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_blk_discard_write_zeroes)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sector) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_discard_write_zeroes), + "::", + stringify!(sector) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_sectors) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_discard_write_zeroes), + "::", + stringify!(num_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_blk_discard_write_zeroes), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_inhdr { + pub errors: __virtio32, + pub data_len: __virtio32, + pub sense_len: __virtio32, + pub residual: __virtio32, +} +#[test] +fn bindgen_test_layout_virtio_scsi_inhdr() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_inhdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_inhdr>(), + 16usize, + concat!("Size of: ", stringify!(virtio_scsi_inhdr)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_inhdr>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_scsi_inhdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).errors) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_inhdr), + "::", + stringify!(errors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data_len) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_inhdr), + "::", + stringify!(data_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sense_len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_inhdr), + "::", + stringify!(sense_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).residual) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_inhdr), + "::", + stringify!(residual) + ) + ); +} diff --git a/src/virtio_config.rs b/src/virtio_config.rs new file mode 100644 index 0000000..5ef84b1 --- /dev/null +++ b/src/virtio_config.rs @@ -0,0 +1,20 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +pub const VIRTIO_CONFIG_S_ACKNOWLEDGE: u32 = 1; +pub const VIRTIO_CONFIG_S_DRIVER: u32 = 2; +pub const VIRTIO_CONFIG_S_DRIVER_OK: u32 = 4; +pub const VIRTIO_CONFIG_S_FEATURES_OK: u32 = 8; +pub const VIRTIO_CONFIG_S_NEEDS_RESET: u32 = 64; +pub const VIRTIO_CONFIG_S_FAILED: u32 = 128; +pub const VIRTIO_TRANSPORT_F_START: u32 = 28; +pub const VIRTIO_TRANSPORT_F_END: u32 = 41; +pub const VIRTIO_F_NOTIFY_ON_EMPTY: u32 = 24; +pub const VIRTIO_F_ANY_LAYOUT: u32 = 27; +pub const VIRTIO_F_VERSION_1: u32 = 32; +pub const VIRTIO_F_ACCESS_PLATFORM: u32 = 33; +pub const VIRTIO_F_IOMMU_PLATFORM: u32 = 33; +pub const VIRTIO_F_RING_PACKED: u32 = 34; +pub const VIRTIO_F_IN_ORDER: u32 = 35; +pub const VIRTIO_F_ORDER_PLATFORM: u32 = 36; +pub const VIRTIO_F_SR_IOV: u32 = 37; +pub const VIRTIO_F_RING_RESET: u32 = 40; diff --git a/src/virtio_gpu.rs b/src/virtio_gpu.rs new file mode 100644 index 0000000..ba83c90 --- /dev/null +++ b/src/virtio_gpu.rs @@ -0,0 +1,2466 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); +impl<T> __IncompleteArrayField<T> { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const VIRTIO_GPU_F_VIRGL: u32 = 0; +pub const VIRTIO_GPU_F_EDID: u32 = 1; +pub const VIRTIO_GPU_F_RESOURCE_UUID: u32 = 2; +pub const VIRTIO_GPU_F_RESOURCE_BLOB: u32 = 3; +pub const VIRTIO_GPU_F_CONTEXT_INIT: u32 = 4; +pub const VIRTIO_GPU_FLAG_FENCE: u32 = 1; +pub const VIRTIO_GPU_FLAG_INFO_RING_IDX: u32 = 2; +pub const VIRTIO_GPU_MAX_SCANOUTS: u32 = 16; +pub const VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP: u32 = 1; +pub const VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK: u32 = 255; +pub const VIRTIO_GPU_CAPSET_VIRGL: u32 = 1; +pub const VIRTIO_GPU_CAPSET_VIRGL2: u32 = 2; +pub const VIRTIO_GPU_EVENT_DISPLAY: u32 = 1; +pub const VIRTIO_GPU_BLOB_MEM_GUEST: u32 = 1; +pub const VIRTIO_GPU_BLOB_MEM_HOST3D: u32 = 2; +pub const VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST: u32 = 3; +pub const VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE: u32 = 1; +pub const VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE: u32 = 2; +pub const VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE: u32 = 4; +pub const VIRTIO_GPU_MAP_CACHE_MASK: u32 = 15; +pub const VIRTIO_GPU_MAP_CACHE_NONE: u32 = 0; +pub const VIRTIO_GPU_MAP_CACHE_CACHED: u32 = 1; +pub const VIRTIO_GPU_MAP_CACHE_UNCACHED: u32 = 2; +pub const VIRTIO_GPU_MAP_CACHE_WC: u32 = 3; +pub type __u8 = ::std::os::raw::c_uchar; +pub type __u32 = ::std::os::raw::c_uint; +pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __le32 = __u32; +pub type __le64 = __u64; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_UNDEFINED: virtio_gpu_ctrl_type = 0; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_GET_DISPLAY_INFO: virtio_gpu_ctrl_type = 256; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_CREATE_2D: virtio_gpu_ctrl_type = 257; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_UNREF: virtio_gpu_ctrl_type = 258; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_SET_SCANOUT: virtio_gpu_ctrl_type = 259; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_FLUSH: virtio_gpu_ctrl_type = 260; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D: virtio_gpu_ctrl_type = 261; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING: virtio_gpu_ctrl_type = 262; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING: virtio_gpu_ctrl_type = 263; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_GET_CAPSET_INFO: virtio_gpu_ctrl_type = 264; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_GET_CAPSET: virtio_gpu_ctrl_type = 265; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_GET_EDID: virtio_gpu_ctrl_type = 266; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID: virtio_gpu_ctrl_type = 267; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB: virtio_gpu_ctrl_type = 268; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_SET_SCANOUT_BLOB: virtio_gpu_ctrl_type = 269; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_CTX_CREATE: virtio_gpu_ctrl_type = 512; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_CTX_DESTROY: virtio_gpu_ctrl_type = 513; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE: virtio_gpu_ctrl_type = 514; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE: virtio_gpu_ctrl_type = 515; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_CREATE_3D: virtio_gpu_ctrl_type = 516; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D: virtio_gpu_ctrl_type = 517; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D: virtio_gpu_ctrl_type = 518; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_SUBMIT_3D: virtio_gpu_ctrl_type = 519; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB: virtio_gpu_ctrl_type = 520; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB: virtio_gpu_ctrl_type = 521; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_UPDATE_CURSOR: virtio_gpu_ctrl_type = 768; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_CMD_MOVE_CURSOR: virtio_gpu_ctrl_type = 769; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_NODATA: virtio_gpu_ctrl_type = 4352; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_DISPLAY_INFO: virtio_gpu_ctrl_type = 4353; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_CAPSET_INFO: virtio_gpu_ctrl_type = 4354; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_CAPSET: virtio_gpu_ctrl_type = 4355; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_EDID: virtio_gpu_ctrl_type = 4356; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_RESOURCE_UUID: virtio_gpu_ctrl_type = 4357; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_OK_MAP_INFO: virtio_gpu_ctrl_type = 4358; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_UNSPEC: virtio_gpu_ctrl_type = 4608; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY: virtio_gpu_ctrl_type = 4609; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID: virtio_gpu_ctrl_type = 4610; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID: virtio_gpu_ctrl_type = 4611; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_INVALID_CONTEXT_ID: virtio_gpu_ctrl_type = 4612; +pub const virtio_gpu_ctrl_type_VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER: virtio_gpu_ctrl_type = 4613; +pub type virtio_gpu_ctrl_type = ::std::os::raw::c_uint; +pub const virtio_gpu_shm_id_VIRTIO_GPU_SHM_ID_UNDEFINED: virtio_gpu_shm_id = 0; +pub const virtio_gpu_shm_id_VIRTIO_GPU_SHM_ID_HOST_VISIBLE: virtio_gpu_shm_id = 1; +pub type virtio_gpu_shm_id = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_ctrl_hdr { + pub type_: __le32, + pub flags: __le32, + pub fence_id: __le64, + pub ctx_id: __le32, + pub ring_idx: __u8, + pub padding: [__u8; 3usize], +} +#[test] +fn bindgen_test_layout_virtio_gpu_ctrl_hdr() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_ctrl_hdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_ctrl_hdr>(), + 24usize, + concat!("Size of: ", stringify!(virtio_gpu_ctrl_hdr)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_ctrl_hdr>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_ctrl_hdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fence_id) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(fence_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ctx_id) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(ctx_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ring_idx) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(ring_idx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 21usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctrl_hdr), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_cursor_pos { + pub scanout_id: __le32, + pub x: __le32, + pub y: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_cursor_pos() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_cursor_pos> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_cursor_pos>(), + 16usize, + concat!("Size of: ", stringify!(virtio_gpu_cursor_pos)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_cursor_pos>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_gpu_cursor_pos)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scanout_id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cursor_pos), + "::", + stringify!(scanout_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cursor_pos), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cursor_pos), + "::", + stringify!(y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cursor_pos), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_update_cursor { + pub hdr: virtio_gpu_ctrl_hdr, + pub pos: virtio_gpu_cursor_pos, + pub resource_id: __le32, + pub hot_x: __le32, + pub hot_y: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_update_cursor() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_update_cursor> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_update_cursor>(), + 56usize, + concat!("Size of: ", stringify!(virtio_gpu_update_cursor)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_update_cursor>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_update_cursor)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pos) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(pos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hot_x) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(hot_x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hot_y) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(hot_y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_update_cursor), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_rect { + pub x: __le32, + pub y: __le32, + pub width: __le32, + pub height: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_rect() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_rect> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_rect>(), + 16usize, + concat!("Size of: ", stringify!(virtio_gpu_rect)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_rect>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_gpu_rect)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_rect), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_rect), + "::", + stringify!(y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_rect), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_rect), + "::", + stringify!(height) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_unref { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_unref() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_unref> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_unref>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_unref)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_unref>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_unref)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unref), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unref), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unref), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_create_2d { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub format: __le32, + pub width: __le32, + pub height: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_create_2d() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_create_2d> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_create_2d>(), + 40usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_create_2d)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_create_2d>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_create_2d)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_2d), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_2d), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_2d), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_2d), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_2d), + "::", + stringify!(height) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_set_scanout { + pub hdr: virtio_gpu_ctrl_hdr, + pub r: virtio_gpu_rect, + pub scanout_id: __le32, + pub resource_id: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_set_scanout() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_set_scanout> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_set_scanout>(), + 48usize, + concat!("Size of: ", stringify!(virtio_gpu_set_scanout)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_set_scanout>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_set_scanout)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scanout_id) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout), + "::", + stringify!(scanout_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout), + "::", + stringify!(resource_id) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_flush { + pub hdr: virtio_gpu_ctrl_hdr, + pub r: virtio_gpu_rect, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_flush() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_flush> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_flush>(), + 48usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_flush)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_flush>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_flush)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_flush), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_flush), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_flush), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_flush), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_transfer_to_host_2d { + pub hdr: virtio_gpu_ctrl_hdr, + pub r: virtio_gpu_rect, + pub offset: __le64, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_transfer_to_host_2d() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_transfer_to_host_2d> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_transfer_to_host_2d>(), + 56usize, + concat!("Size of: ", stringify!(virtio_gpu_transfer_to_host_2d)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_transfer_to_host_2d>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_transfer_to_host_2d)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_to_host_2d), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_to_host_2d), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_to_host_2d), + "::", + stringify!(offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_to_host_2d), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_to_host_2d), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_mem_entry { + pub addr: __le64, + pub length: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_mem_entry() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_mem_entry> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_mem_entry>(), + 16usize, + concat!("Size of: ", stringify!(virtio_gpu_mem_entry)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_mem_entry>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_mem_entry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_mem_entry), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_mem_entry), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_mem_entry), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_attach_backing { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub nr_entries: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_attach_backing() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_attach_backing> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_attach_backing>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_attach_backing)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_attach_backing>(), + 8usize, + concat!( + "Alignment of ", + stringify!(virtio_gpu_resource_attach_backing) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_attach_backing), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_attach_backing), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr_entries) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_attach_backing), + "::", + stringify!(nr_entries) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_detach_backing { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_detach_backing() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_detach_backing> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_detach_backing>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_detach_backing)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_detach_backing>(), + 8usize, + concat!( + "Alignment of ", + stringify!(virtio_gpu_resource_detach_backing) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_detach_backing), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_detach_backing), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_detach_backing), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_display_info { + pub hdr: virtio_gpu_ctrl_hdr, + pub pmodes: [virtio_gpu_resp_display_info_virtio_gpu_display_one; 16usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_display_info_virtio_gpu_display_one { + pub r: virtio_gpu_rect, + pub enabled: __le32, + pub flags: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_display_info_virtio_gpu_display_one() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_display_info_virtio_gpu_display_one> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_display_info_virtio_gpu_display_one>(), + 24usize, + concat!( + "Size of: ", + stringify!(virtio_gpu_resp_display_info_virtio_gpu_display_one) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_display_info_virtio_gpu_display_one>(), + 4usize, + concat!( + "Alignment of ", + stringify!(virtio_gpu_resp_display_info_virtio_gpu_display_one) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_display_info_virtio_gpu_display_one), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).enabled) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_display_info_virtio_gpu_display_one), + "::", + stringify!(enabled) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_display_info_virtio_gpu_display_one), + "::", + stringify!(flags) + ) + ); +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_display_info() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_display_info> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_display_info>(), + 408usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_display_info)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_display_info>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_display_info)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_display_info), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pmodes) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_display_info), + "::", + stringify!(pmodes) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_box { + pub x: __le32, + pub y: __le32, + pub z: __le32, + pub w: __le32, + pub h: __le32, + pub d: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_box() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_box> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_box>(), + 24usize, + concat!("Size of: ", stringify!(virtio_gpu_box)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_box>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_gpu_box)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(z) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).w) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(w) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).h) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(h) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_box), + "::", + stringify!(d) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_transfer_host_3d { + pub hdr: virtio_gpu_ctrl_hdr, + pub box_: virtio_gpu_box, + pub offset: __le64, + pub resource_id: __le32, + pub level: __le32, + pub stride: __le32, + pub layer_stride: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_transfer_host_3d() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_transfer_host_3d> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_transfer_host_3d>(), + 72usize, + concat!("Size of: ", stringify!(virtio_gpu_transfer_host_3d)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_transfer_host_3d>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_transfer_host_3d)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).box_) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(box_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(level) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).stride) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(stride) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).layer_stride) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_transfer_host_3d), + "::", + stringify!(layer_stride) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_create_3d { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub target: __le32, + pub format: __le32, + pub bind: __le32, + pub width: __le32, + pub height: __le32, + pub depth: __le32, + pub array_size: __le32, + pub last_level: __le32, + pub nr_samples: __le32, + pub flags: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_create_3d() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_create_3d> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_create_3d>(), + 72usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_create_3d)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_create_3d>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_create_3d)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).target) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(target) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bind) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(bind) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).depth) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(depth) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).array_size) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(array_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last_level) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(last_level) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr_samples) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(nr_samples) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_3d), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct virtio_gpu_ctx_create { + pub hdr: virtio_gpu_ctrl_hdr, + pub nlen: __le32, + pub context_init: __le32, + pub debug_name: [::std::os::raw::c_char; 64usize], +} +#[test] +fn bindgen_test_layout_virtio_gpu_ctx_create() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_ctx_create> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_ctx_create>(), + 96usize, + concat!("Size of: ", stringify!(virtio_gpu_ctx_create)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_ctx_create>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_ctx_create)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_create), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nlen) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_create), + "::", + stringify!(nlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).context_init) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_create), + "::", + stringify!(context_init) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).debug_name) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_create), + "::", + stringify!(debug_name) + ) + ); +} +impl Default for virtio_gpu_ctx_create { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_ctx_destroy { + pub hdr: virtio_gpu_ctrl_hdr, +} +#[test] +fn bindgen_test_layout_virtio_gpu_ctx_destroy() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_ctx_destroy> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_ctx_destroy>(), + 24usize, + concat!("Size of: ", stringify!(virtio_gpu_ctx_destroy)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_ctx_destroy>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_ctx_destroy)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_destroy), + "::", + stringify!(hdr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_ctx_resource { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_ctx_resource() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_ctx_resource> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_ctx_resource>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_ctx_resource)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_ctx_resource>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_ctx_resource)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_resource), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_resource), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_ctx_resource), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_cmd_submit { + pub hdr: virtio_gpu_ctrl_hdr, + pub size: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_cmd_submit() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_cmd_submit> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_cmd_submit>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_cmd_submit)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_cmd_submit>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_cmd_submit)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_submit), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_submit), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_submit), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_get_capset_info { + pub hdr: virtio_gpu_ctrl_hdr, + pub capset_index: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_get_capset_info() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_get_capset_info> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_get_capset_info>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_get_capset_info)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_get_capset_info>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_get_capset_info)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset_info), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_index) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset_info), + "::", + stringify!(capset_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset_info), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_capset_info { + pub hdr: virtio_gpu_ctrl_hdr, + pub capset_id: __le32, + pub capset_max_version: __le32, + pub capset_max_size: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_capset_info() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_capset_info> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_capset_info>(), + 40usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_capset_info)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_capset_info>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_capset_info)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset_info), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset_info), + "::", + stringify!(capset_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_max_version) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset_info), + "::", + stringify!(capset_max_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_max_size) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset_info), + "::", + stringify!(capset_max_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset_info), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_get_capset { + pub hdr: virtio_gpu_ctrl_hdr, + pub capset_id: __le32, + pub capset_version: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_get_capset() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_get_capset> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_get_capset>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_get_capset)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_get_capset>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_get_capset)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset), + "::", + stringify!(capset_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_version) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_get_capset), + "::", + stringify!(capset_version) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct virtio_gpu_resp_capset { + pub hdr: virtio_gpu_ctrl_hdr, + pub capset_data: __IncompleteArrayField<__u8>, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_capset() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_capset> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_capset>(), + 24usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_capset)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_capset>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_capset)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).capset_data) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_capset), + "::", + stringify!(capset_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_cmd_get_edid { + pub hdr: virtio_gpu_ctrl_hdr, + pub scanout: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_cmd_get_edid() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_cmd_get_edid> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_cmd_get_edid>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_cmd_get_edid)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_cmd_get_edid>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_cmd_get_edid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_get_edid), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scanout) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_get_edid), + "::", + stringify!(scanout) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_cmd_get_edid), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_edid { + pub hdr: virtio_gpu_ctrl_hdr, + pub size: __le32, + pub padding: __le32, + pub edid: [__u8; 1024usize], +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_edid() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_edid> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_edid>(), + 1056usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_edid)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_edid>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_edid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_edid), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_edid), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_edid), + "::", + stringify!(padding) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).edid) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_edid), + "::", + stringify!(edid) + ) + ); +} +impl Default for virtio_gpu_resp_edid { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_config { + pub events_read: __le32, + pub events_clear: __le32, + pub num_scanouts: __le32, + pub num_capsets: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_config> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_config>(), + 16usize, + concat!("Size of: ", stringify!(virtio_gpu_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_config>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_gpu_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).events_read) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_config), + "::", + stringify!(events_read) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).events_clear) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_config), + "::", + stringify!(events_clear) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_scanouts) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_config), + "::", + stringify!(num_scanouts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_capsets) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_config), + "::", + stringify!(num_capsets) + ) + ); +} +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM: virtio_gpu_formats = 1; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM: virtio_gpu_formats = 2; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM: virtio_gpu_formats = 3; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM: virtio_gpu_formats = 4; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM: virtio_gpu_formats = 67; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM: virtio_gpu_formats = 68; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM: virtio_gpu_formats = 121; +pub const virtio_gpu_formats_VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM: virtio_gpu_formats = 134; +pub type virtio_gpu_formats = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_assign_uuid { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_assign_uuid() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_assign_uuid> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_assign_uuid>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_assign_uuid)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_assign_uuid>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_assign_uuid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_assign_uuid), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_assign_uuid), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_assign_uuid), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_resource_uuid { + pub hdr: virtio_gpu_ctrl_hdr, + pub uuid: [__u8; 16usize], +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_resource_uuid() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_resource_uuid> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_resource_uuid>(), + 40usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_resource_uuid)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_resource_uuid>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_resource_uuid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_resource_uuid), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).uuid) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_resource_uuid), + "::", + stringify!(uuid) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_create_blob { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub blob_mem: __le32, + pub blob_flags: __le32, + pub nr_entries: __le32, + pub blob_id: __le64, + pub size: __le64, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_create_blob() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_create_blob> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_create_blob>(), + 56usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_create_blob)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_create_blob>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_create_blob)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).blob_mem) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(blob_mem) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).blob_flags) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(blob_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr_entries) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(nr_entries) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).blob_id) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(blob_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_create_blob), + "::", + stringify!(size) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_set_scanout_blob { + pub hdr: virtio_gpu_ctrl_hdr, + pub r: virtio_gpu_rect, + pub scanout_id: __le32, + pub resource_id: __le32, + pub width: __le32, + pub height: __le32, + pub format: __le32, + pub padding: __le32, + pub strides: [__le32; 4usize], + pub offsets: [__le32; 4usize], +} +#[test] +fn bindgen_test_layout_virtio_gpu_set_scanout_blob() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_set_scanout_blob> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_set_scanout_blob>(), + 96usize, + concat!("Size of: ", stringify!(virtio_gpu_set_scanout_blob)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_set_scanout_blob>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_set_scanout_blob)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scanout_id) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(scanout_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(padding) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).strides) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(strides) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offsets) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_set_scanout_blob), + "::", + stringify!(offsets) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_map_blob { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, + pub offset: __le64, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_map_blob() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_map_blob> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_map_blob>(), + 40usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_map_blob)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_map_blob>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_map_blob)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_map_blob), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_map_blob), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_map_blob), + "::", + stringify!(padding) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_map_blob), + "::", + stringify!(offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resp_map_info { + pub hdr: virtio_gpu_ctrl_hdr, + pub map_info: __u32, + pub padding: __u32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resp_map_info() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resp_map_info> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resp_map_info>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resp_map_info)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resp_map_info>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resp_map_info)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_map_info), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).map_info) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_map_info), + "::", + stringify!(map_info) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resp_map_info), + "::", + stringify!(padding) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_gpu_resource_unmap_blob { + pub hdr: virtio_gpu_ctrl_hdr, + pub resource_id: __le32, + pub padding: __le32, +} +#[test] +fn bindgen_test_layout_virtio_gpu_resource_unmap_blob() { + const UNINIT: ::std::mem::MaybeUninit<virtio_gpu_resource_unmap_blob> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_gpu_resource_unmap_blob>(), + 32usize, + concat!("Size of: ", stringify!(virtio_gpu_resource_unmap_blob)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_gpu_resource_unmap_blob>(), + 8usize, + concat!("Alignment of ", stringify!(virtio_gpu_resource_unmap_blob)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unmap_blob), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resource_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unmap_blob), + "::", + stringify!(resource_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_gpu_resource_unmap_blob), + "::", + stringify!(padding) + ) + ); +} diff --git a/src/virtio_mmio.rs b/src/virtio_mmio.rs new file mode 100644 index 0000000..2f936cd --- /dev/null +++ b/src/virtio_mmio.rs @@ -0,0 +1,36 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +pub const VIRTIO_MMIO_MAGIC_VALUE: u32 = 0; +pub const VIRTIO_MMIO_VERSION: u32 = 4; +pub const VIRTIO_MMIO_DEVICE_ID: u32 = 8; +pub const VIRTIO_MMIO_VENDOR_ID: u32 = 12; +pub const VIRTIO_MMIO_DEVICE_FEATURES: u32 = 16; +pub const VIRTIO_MMIO_DEVICE_FEATURES_SEL: u32 = 20; +pub const VIRTIO_MMIO_DRIVER_FEATURES: u32 = 32; +pub const VIRTIO_MMIO_DRIVER_FEATURES_SEL: u32 = 36; +pub const VIRTIO_MMIO_GUEST_PAGE_SIZE: u32 = 40; +pub const VIRTIO_MMIO_QUEUE_SEL: u32 = 48; +pub const VIRTIO_MMIO_QUEUE_NUM_MAX: u32 = 52; +pub const VIRTIO_MMIO_QUEUE_NUM: u32 = 56; +pub const VIRTIO_MMIO_QUEUE_ALIGN: u32 = 60; +pub const VIRTIO_MMIO_QUEUE_PFN: u32 = 64; +pub const VIRTIO_MMIO_QUEUE_READY: u32 = 68; +pub const VIRTIO_MMIO_QUEUE_NOTIFY: u32 = 80; +pub const VIRTIO_MMIO_INTERRUPT_STATUS: u32 = 96; +pub const VIRTIO_MMIO_INTERRUPT_ACK: u32 = 100; +pub const VIRTIO_MMIO_STATUS: u32 = 112; +pub const VIRTIO_MMIO_QUEUE_DESC_LOW: u32 = 128; +pub const VIRTIO_MMIO_QUEUE_DESC_HIGH: u32 = 132; +pub const VIRTIO_MMIO_QUEUE_AVAIL_LOW: u32 = 144; +pub const VIRTIO_MMIO_QUEUE_AVAIL_HIGH: u32 = 148; +pub const VIRTIO_MMIO_QUEUE_USED_LOW: u32 = 160; +pub const VIRTIO_MMIO_QUEUE_USED_HIGH: u32 = 164; +pub const VIRTIO_MMIO_SHM_SEL: u32 = 172; +pub const VIRTIO_MMIO_SHM_LEN_LOW: u32 = 176; +pub const VIRTIO_MMIO_SHM_LEN_HIGH: u32 = 180; +pub const VIRTIO_MMIO_SHM_BASE_LOW: u32 = 184; +pub const VIRTIO_MMIO_SHM_BASE_HIGH: u32 = 188; +pub const VIRTIO_MMIO_CONFIG_GENERATION: u32 = 252; +pub const VIRTIO_MMIO_CONFIG: u32 = 256; +pub const VIRTIO_MMIO_INT_VRING: u32 = 1; +pub const VIRTIO_MMIO_INT_CONFIG: u32 = 2; diff --git a/src/virtio_net/generated.rs b/src/virtio_net/generated.rs new file mode 100644 index 0000000..326dbe5 --- /dev/null +++ b/src/virtio_net/generated.rs @@ -0,0 +1,1095 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); +impl<T> __IncompleteArrayField<T> { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const VIRTIO_NET_F_CSUM: u32 = 0; +pub const VIRTIO_NET_F_GUEST_CSUM: u32 = 1; +pub const VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: u32 = 2; +pub const VIRTIO_NET_F_MTU: u32 = 3; +pub const VIRTIO_NET_F_MAC: u32 = 5; +pub const VIRTIO_NET_F_GUEST_TSO4: u32 = 7; +pub const VIRTIO_NET_F_GUEST_TSO6: u32 = 8; +pub const VIRTIO_NET_F_GUEST_ECN: u32 = 9; +pub const VIRTIO_NET_F_GUEST_UFO: u32 = 10; +pub const VIRTIO_NET_F_HOST_TSO4: u32 = 11; +pub const VIRTIO_NET_F_HOST_TSO6: u32 = 12; +pub const VIRTIO_NET_F_HOST_ECN: u32 = 13; +pub const VIRTIO_NET_F_HOST_UFO: u32 = 14; +pub const VIRTIO_NET_F_MRG_RXBUF: u32 = 15; +pub const VIRTIO_NET_F_STATUS: u32 = 16; +pub const VIRTIO_NET_F_CTRL_VQ: u32 = 17; +pub const VIRTIO_NET_F_CTRL_RX: u32 = 18; +pub const VIRTIO_NET_F_CTRL_VLAN: u32 = 19; +pub const VIRTIO_NET_F_CTRL_RX_EXTRA: u32 = 20; +pub const VIRTIO_NET_F_GUEST_ANNOUNCE: u32 = 21; +pub const VIRTIO_NET_F_MQ: u32 = 22; +pub const VIRTIO_NET_F_CTRL_MAC_ADDR: u32 = 23; +pub const VIRTIO_NET_F_NOTF_COAL: u32 = 53; +pub const VIRTIO_NET_F_GUEST_USO4: u32 = 54; +pub const VIRTIO_NET_F_GUEST_USO6: u32 = 55; +pub const VIRTIO_NET_F_HOST_USO: u32 = 56; +pub const VIRTIO_NET_F_HASH_REPORT: u32 = 57; +pub const VIRTIO_NET_F_RSS: u32 = 60; +pub const VIRTIO_NET_F_RSC_EXT: u32 = 61; +pub const VIRTIO_NET_F_STANDBY: u32 = 62; +pub const VIRTIO_NET_F_SPEED_DUPLEX: u32 = 63; +pub const VIRTIO_NET_F_GSO: u32 = 6; +pub const VIRTIO_NET_S_LINK_UP: u32 = 1; +pub const VIRTIO_NET_S_ANNOUNCE: u32 = 2; +pub const VIRTIO_NET_RSS_HASH_TYPE_IPv4: u32 = 1; +pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv4: u32 = 2; +pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv4: u32 = 4; +pub const VIRTIO_NET_RSS_HASH_TYPE_IPv6: u32 = 8; +pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv6: u32 = 16; +pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv6: u32 = 32; +pub const VIRTIO_NET_RSS_HASH_TYPE_IP_EX: u32 = 64; +pub const VIRTIO_NET_RSS_HASH_TYPE_TCP_EX: u32 = 128; +pub const VIRTIO_NET_RSS_HASH_TYPE_UDP_EX: u32 = 256; +pub const VIRTIO_NET_HDR_F_NEEDS_CSUM: u32 = 1; +pub const VIRTIO_NET_HDR_F_DATA_VALID: u32 = 2; +pub const VIRTIO_NET_HDR_F_RSC_INFO: u32 = 4; +pub const VIRTIO_NET_HDR_GSO_NONE: u32 = 0; +pub const VIRTIO_NET_HDR_GSO_TCPV4: u32 = 1; +pub const VIRTIO_NET_HDR_GSO_UDP: u32 = 3; +pub const VIRTIO_NET_HDR_GSO_TCPV6: u32 = 4; +pub const VIRTIO_NET_HDR_GSO_UDP_L4: u32 = 5; +pub const VIRTIO_NET_HDR_GSO_ECN: u32 = 128; +pub const VIRTIO_NET_HASH_REPORT_NONE: u32 = 0; +pub const VIRTIO_NET_HASH_REPORT_IPv4: u32 = 1; +pub const VIRTIO_NET_HASH_REPORT_TCPv4: u32 = 2; +pub const VIRTIO_NET_HASH_REPORT_UDPv4: u32 = 3; +pub const VIRTIO_NET_HASH_REPORT_IPv6: u32 = 4; +pub const VIRTIO_NET_HASH_REPORT_TCPv6: u32 = 5; +pub const VIRTIO_NET_HASH_REPORT_UDPv6: u32 = 6; +pub const VIRTIO_NET_HASH_REPORT_IPv6_EX: u32 = 7; +pub const VIRTIO_NET_HASH_REPORT_TCPv6_EX: u32 = 8; +pub const VIRTIO_NET_HASH_REPORT_UDPv6_EX: u32 = 9; +pub const VIRTIO_NET_OK: u32 = 0; +pub const VIRTIO_NET_ERR: u32 = 1; +pub const VIRTIO_NET_CTRL_RX: u32 = 0; +pub const VIRTIO_NET_CTRL_RX_PROMISC: u32 = 0; +pub const VIRTIO_NET_CTRL_RX_ALLMULTI: u32 = 1; +pub const VIRTIO_NET_CTRL_RX_ALLUNI: u32 = 2; +pub const VIRTIO_NET_CTRL_RX_NOMULTI: u32 = 3; +pub const VIRTIO_NET_CTRL_RX_NOUNI: u32 = 4; +pub const VIRTIO_NET_CTRL_RX_NOBCAST: u32 = 5; +pub const VIRTIO_NET_CTRL_MAC: u32 = 1; +pub const VIRTIO_NET_CTRL_MAC_TABLE_SET: u32 = 0; +pub const VIRTIO_NET_CTRL_MAC_ADDR_SET: u32 = 1; +pub const VIRTIO_NET_CTRL_VLAN: u32 = 2; +pub const VIRTIO_NET_CTRL_VLAN_ADD: u32 = 0; +pub const VIRTIO_NET_CTRL_VLAN_DEL: u32 = 1; +pub const VIRTIO_NET_CTRL_ANNOUNCE: u32 = 3; +pub const VIRTIO_NET_CTRL_ANNOUNCE_ACK: u32 = 0; +pub const VIRTIO_NET_CTRL_MQ: u32 = 4; +pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: u32 = 0; +pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN: u32 = 1; +pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX: u32 = 32768; +pub const VIRTIO_NET_CTRL_MQ_RSS_CONFIG: u32 = 1; +pub const VIRTIO_NET_CTRL_MQ_HASH_CONFIG: u32 = 2; +pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS: u32 = 5; +pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET: u32 = 0; +pub const VIRTIO_NET_CTRL_NOTF_COAL: u32 = 6; +pub const VIRTIO_NET_CTRL_NOTF_COAL_TX_SET: u32 = 0; +pub const VIRTIO_NET_CTRL_NOTF_COAL_RX_SET: u32 = 1; +pub type __u8 = ::std::os::raw::c_uchar; +pub type __u16 = ::std::os::raw::c_ushort; +pub type __u32 = ::std::os::raw::c_uint; +pub type __le16 = __u16; +pub type __le32 = __u32; +pub type __virtio16 = __u16; +pub type __virtio32 = __u32; +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_config { + pub mac: [__u8; 6usize], + pub status: __virtio16, + pub max_virtqueue_pairs: __virtio16, + pub mtu: __virtio16, + pub speed: __le32, + pub duplex: __u8, + pub rss_max_key_size: __u8, + pub rss_max_indirection_table_length: __le16, + pub supported_hash_types: __le32, +} +#[test] +fn bindgen_test_layout_virtio_net_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_config> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_config>(), + 24usize, + concat!("Size of: ", stringify!(virtio_net_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_config>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_net_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mac) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(mac) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(status) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_virtqueue_pairs) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(max_virtqueue_pairs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mtu) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(mtu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).speed) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(speed) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).duplex) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(duplex) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rss_max_key_size) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(rss_max_key_size) + ) + ); + assert_eq!( + unsafe { + ::std::ptr::addr_of!((*ptr).rss_max_indirection_table_length) as usize - ptr as usize + }, + 18usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(rss_max_indirection_table_length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).supported_hash_types) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_config), + "::", + stringify!(supported_hash_types) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct virtio_net_hdr_v1 { + pub flags: __u8, + pub gso_type: __u8, + pub hdr_len: __virtio16, + pub gso_size: __virtio16, + pub __bindgen_anon_1: virtio_net_hdr_v1__bindgen_ty_1, + pub num_buffers: __virtio16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union virtio_net_hdr_v1__bindgen_ty_1 { + pub __bindgen_anon_1: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1, + pub csum: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2, + pub rsc: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1 { + pub csum_start: __virtio16, + pub csum_offset: __virtio16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csum_start) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(csum_start) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csum_offset) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(csum_offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2 { + pub start: __virtio16, + pub offset: __virtio16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Size of: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2>(), + 2usize, + concat!( + "Alignment of ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).start) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(start) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3 { + pub segments: __le16, + pub dup_acks: __le16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3>(), + 4usize, + concat!( + "Size of: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3) + ) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3>(), + 2usize, + concat!( + "Alignment of ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).segments) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(segments) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dup_acks) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(dup_acks) + ) + ); +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1__bindgen_ty_1> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(virtio_net_hdr_v1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(virtio_net_hdr_v1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csum) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1), + "::", + stringify!(csum) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rsc) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1__bindgen_ty_1), + "::", + stringify!(rsc) + ) + ); +} +impl Default for virtio_net_hdr_v1__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1>(), + 12usize, + concat!("Size of: ", stringify!(virtio_net_hdr_v1)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1>(), + 2usize, + concat!("Alignment of ", stringify!(virtio_net_hdr_v1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gso_type) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1), + "::", + stringify!(gso_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr_len) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1), + "::", + stringify!(hdr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gso_size) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1), + "::", + stringify!(gso_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_buffers) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1), + "::", + stringify!(num_buffers) + ) + ); +} +impl Default for virtio_net_hdr_v1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct virtio_net_hdr_v1_hash { + pub hdr: virtio_net_hdr_v1, + pub hash_value: __le32, + pub hash_report: __le16, + pub padding: __le16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_v1_hash() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_v1_hash> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_v1_hash>(), + 20usize, + concat!("Size of: ", stringify!(virtio_net_hdr_v1_hash)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_v1_hash>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_net_hdr_v1_hash)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1_hash), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_value) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1_hash), + "::", + stringify!(hash_value) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_report) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1_hash), + "::", + stringify!(hash_report) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_v1_hash), + "::", + stringify!(padding) + ) + ); +} +impl Default for virtio_net_hdr_v1_hash { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_hdr { + pub flags: __u8, + pub gso_type: __u8, + pub hdr_len: __virtio16, + pub gso_size: __virtio16, + pub csum_start: __virtio16, + pub csum_offset: __virtio16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr>(), + 10usize, + concat!("Size of: ", stringify!(virtio_net_hdr)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr>(), + 2usize, + concat!("Alignment of ", stringify!(virtio_net_hdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gso_type) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(gso_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr_len) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(hdr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gso_size) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(gso_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csum_start) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(csum_start) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csum_offset) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr), + "::", + stringify!(csum_offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_hdr_mrg_rxbuf { + pub hdr: virtio_net_hdr, + pub num_buffers: __virtio16, +} +#[test] +fn bindgen_test_layout_virtio_net_hdr_mrg_rxbuf() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hdr_mrg_rxbuf> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hdr_mrg_rxbuf>(), + 12usize, + concat!("Size of: ", stringify!(virtio_net_hdr_mrg_rxbuf)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hdr_mrg_rxbuf>(), + 2usize, + concat!("Alignment of ", stringify!(virtio_net_hdr_mrg_rxbuf)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_mrg_rxbuf), + "::", + stringify!(hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_buffers) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hdr_mrg_rxbuf), + "::", + stringify!(num_buffers) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_ctrl_hdr { + pub class: __u8, + pub cmd: __u8, +} +#[test] +fn bindgen_test_layout_virtio_net_ctrl_hdr() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_ctrl_hdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_ctrl_hdr>(), + 2usize, + concat!("Size of: ", stringify!(virtio_net_ctrl_hdr)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_ctrl_hdr>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_net_ctrl_hdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).class) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_hdr), + "::", + stringify!(class) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmd) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_hdr), + "::", + stringify!(cmd) + ) + ); +} +pub type virtio_net_ctrl_ack = __u8; +#[repr(C, packed)] +pub struct virtio_net_ctrl_mac { + pub entries: __virtio32, + pub macs: __IncompleteArrayField<[__u8; 6usize]>, +} +#[test] +fn bindgen_test_layout_virtio_net_ctrl_mac() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_ctrl_mac> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_ctrl_mac>(), + 4usize, + concat!("Size of: ", stringify!(virtio_net_ctrl_mac)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_ctrl_mac>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_net_ctrl_mac)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_mac), + "::", + stringify!(entries) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).macs) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_mac), + "::", + stringify!(macs) + ) + ); +} +impl Default for virtio_net_ctrl_mac { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_ctrl_mq { + pub virtqueue_pairs: __virtio16, +} +#[test] +fn bindgen_test_layout_virtio_net_ctrl_mq() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_ctrl_mq> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_ctrl_mq>(), + 2usize, + concat!("Size of: ", stringify!(virtio_net_ctrl_mq)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_ctrl_mq>(), + 2usize, + concat!("Alignment of ", stringify!(virtio_net_ctrl_mq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).virtqueue_pairs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_mq), + "::", + stringify!(virtqueue_pairs) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct virtio_net_rss_config { + pub hash_types: __le32, + pub indirection_table_mask: __le16, + pub unclassified_queue: __le16, + pub indirection_table: [__le16; 1usize], + pub max_tx_vq: __le16, + pub hash_key_length: __u8, + pub hash_key_data: __IncompleteArrayField<__u8>, +} +#[test] +fn bindgen_test_layout_virtio_net_rss_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_rss_config> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_rss_config>(), + 16usize, + concat!("Size of: ", stringify!(virtio_net_rss_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_rss_config>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_net_rss_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_types) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(hash_types) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).indirection_table_mask) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(indirection_table_mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).unclassified_queue) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(unclassified_queue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).indirection_table) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(indirection_table) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_tx_vq) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(max_tx_vq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_key_length) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(hash_key_length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_key_data) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_rss_config), + "::", + stringify!(hash_key_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct virtio_net_hash_config { + pub hash_types: __le32, + pub reserved: [__le16; 4usize], + pub hash_key_length: __u8, + pub hash_key_data: __IncompleteArrayField<__u8>, +} +#[test] +fn bindgen_test_layout_virtio_net_hash_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_hash_config> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_hash_config>(), + 16usize, + concat!("Size of: ", stringify!(virtio_net_hash_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_hash_config>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_net_hash_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_types) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hash_config), + "::", + stringify!(hash_types) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hash_config), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_key_length) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hash_config), + "::", + stringify!(hash_key_length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash_key_data) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_hash_config), + "::", + stringify!(hash_key_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_ctrl_coal_tx { + pub tx_max_packets: __le32, + pub tx_usecs: __le32, +} +#[test] +fn bindgen_test_layout_virtio_net_ctrl_coal_tx() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_ctrl_coal_tx> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_ctrl_coal_tx>(), + 8usize, + concat!("Size of: ", stringify!(virtio_net_ctrl_coal_tx)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_ctrl_coal_tx>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_net_ctrl_coal_tx)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tx_max_packets) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_coal_tx), + "::", + stringify!(tx_max_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tx_usecs) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_coal_tx), + "::", + stringify!(tx_usecs) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_net_ctrl_coal_rx { + pub rx_max_packets: __le32, + pub rx_usecs: __le32, +} +#[test] +fn bindgen_test_layout_virtio_net_ctrl_coal_rx() { + const UNINIT: ::std::mem::MaybeUninit<virtio_net_ctrl_coal_rx> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_net_ctrl_coal_rx>(), + 8usize, + concat!("Size of: ", stringify!(virtio_net_ctrl_coal_rx)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_net_ctrl_coal_rx>(), + 4usize, + concat!("Alignment of ", stringify!(virtio_net_ctrl_coal_rx)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_max_packets) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_coal_rx), + "::", + stringify!(rx_max_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_usecs) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_net_ctrl_coal_rx), + "::", + stringify!(rx_usecs) + ) + ); +} diff --git a/src/virtio_net/mod.rs b/src/virtio_net/mod.rs new file mode 100644 index 0000000..7685e4e --- /dev/null +++ b/src/virtio_net/mod.rs @@ -0,0 +1,72 @@ +// Copyright 2022 Unikie +// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0 + +mod generated; +pub use generated::*; + +use std::fmt::{Debug, Formatter, Result}; +use std::mem::{size_of, transmute}; + +impl Debug for virtio_net_hdr_v1 { + fn fmt(&self, f: &mut Formatter) -> Result { + // SAFETY: As of Linux v6.0, all union fields have compatible types. + // This means that it is safe to convert any variant into any other, + // as they all have the same size, alignment, and permitted values. + // https://doc.rust-lang.org/reference/items/unions.html#reading-and-writing-union-fields + let csum = unsafe { self.__bindgen_anon_1.csum }; + + // We forgo determining the correct name of the fields in the + // union due to the complexity that would involve. + f.debug_struct("virtio_net_hdr_v1") + .field("flags", &self.flags) + .field("gso_type", &self.gso_type) + .field("hdr_len", &self.hdr_len) + .field("gso_size", &self.gso_size) + .field("csum_start", &csum.start) + .field("csum_offset", &csum.offset) + .field("num_buffers", &self.num_buffers) + .finish() + } +} + +impl PartialEq<Self> for virtio_net_hdr_v1 { + fn eq<'a>(&'a self, other: &'a Self) -> bool { + // SAFETY: The values will be valid byte arrays, and the lifetimes match the + // original types. + unsafe { + let ptr1 = transmute::<&'a Self, &'a [u8; size_of::<Self>()]>(&self); + let ptr2 = transmute::<&'a Self, &'a [u8; size_of::<Self>()]>(&other); + ptr1 == ptr2 + } + } +} + +#[test] +fn virtio_net_hdr_v1_default_debug() { + assert_eq!(format!("{:?}", virtio_net_hdr_v1::default()), "virtio_net_hdr_v1 { flags: 0, gso_type: 0, hdr_len: 0, gso_size: 0, csum_start: 0, csum_offset: 0, num_buffers: 0 }"); +} + +#[test] +fn virtio_net_hdr_v1_hex_debug() { + let expected = "virtio_net_hdr_v1 { + flags: 0x0, + gso_type: 0x0, + hdr_len: 0x0, + gso_size: 0x0, + csum_start: 0x0, + csum_offset: 0x0, + num_buffers: 0x0, +}"; + assert_eq!(format!("{:#x?}", virtio_net_hdr_v1::default()), expected); +} + +#[test] +fn virtio_net_hdr_v1_partial_eq() { + let hdr1 = virtio_net_hdr_v1::default(); + let hdr2 = virtio_net_hdr_v1 { + flags: 1, + ..Default::default() + }; + assert_eq!(hdr1, hdr1); + assert_ne!(hdr1, hdr2); +} diff --git a/src/virtio_ring.rs b/src/virtio_ring.rs new file mode 100644 index 0000000..9512aaa --- /dev/null +++ b/src/virtio_ring.rs @@ -0,0 +1,448 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); +impl<T> __IncompleteArrayField<T> { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const VRING_DESC_F_NEXT: u32 = 1; +pub const VRING_DESC_F_WRITE: u32 = 2; +pub const VRING_DESC_F_INDIRECT: u32 = 4; +pub const VRING_PACKED_DESC_F_AVAIL: u32 = 7; +pub const VRING_PACKED_DESC_F_USED: u32 = 15; +pub const VRING_USED_F_NO_NOTIFY: u32 = 1; +pub const VRING_AVAIL_F_NO_INTERRUPT: u32 = 1; +pub const VRING_PACKED_EVENT_FLAG_ENABLE: u32 = 0; +pub const VRING_PACKED_EVENT_FLAG_DISABLE: u32 = 1; +pub const VRING_PACKED_EVENT_FLAG_DESC: u32 = 2; +pub const VRING_PACKED_EVENT_F_WRAP_CTR: u32 = 15; +pub const VIRTIO_RING_F_INDIRECT_DESC: u32 = 28; +pub const VIRTIO_RING_F_EVENT_IDX: u32 = 29; +pub const VRING_AVAIL_ALIGN_SIZE: u32 = 2; +pub const VRING_USED_ALIGN_SIZE: u32 = 4; +pub const VRING_DESC_ALIGN_SIZE: u32 = 16; +pub type __u16 = ::std::os::raw::c_ushort; +pub type __u32 = ::std::os::raw::c_uint; +pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __le16 = __u16; +pub type __le32 = __u32; +pub type __le64 = __u64; +pub type __virtio16 = __u16; +pub type __virtio32 = __u32; +pub type __virtio64 = __u64; +#[doc = " struct vring_desc - Virtio ring descriptors,\n 16 bytes long. These can chain together via @next.\n\n @addr: buffer address (guest-physical)\n @len: buffer length\n @flags: descriptor flags\n @next: index of the next descriptor in the chain,\n if the VRING_DESC_F_NEXT flag is set. We chain unused\n descriptors via this, too."] +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct vring_desc { + pub addr: __virtio64, + pub len: __virtio32, + pub flags: __virtio16, + pub next: __virtio16, +} +#[test] +fn bindgen_test_layout_vring_desc() { + const UNINIT: ::std::mem::MaybeUninit<vring_desc> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_desc>(), + 16usize, + concat!("Size of: ", stringify!(vring_desc)) + ); + assert_eq!( + ::std::mem::align_of::<vring_desc>(), + 8usize, + concat!("Alignment of ", stringify!(vring_desc)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_desc), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(vring_desc), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(vring_desc), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(vring_desc), + "::", + stringify!(next) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct vring_avail { + pub flags: __virtio16, + pub idx: __virtio16, + pub ring: __IncompleteArrayField<__virtio16>, +} +#[test] +fn bindgen_test_layout_vring_avail() { + const UNINIT: ::std::mem::MaybeUninit<vring_avail> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_avail>(), + 4usize, + concat!("Size of: ", stringify!(vring_avail)) + ); + assert_eq!( + ::std::mem::align_of::<vring_avail>(), + 2usize, + concat!("Alignment of ", stringify!(vring_avail)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_avail), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).idx) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(vring_avail), + "::", + stringify!(idx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ring) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(vring_avail), + "::", + stringify!(ring) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct vring_used_elem { + pub id: __virtio32, + pub len: __virtio32, +} +#[test] +fn bindgen_test_layout_vring_used_elem() { + const UNINIT: ::std::mem::MaybeUninit<vring_used_elem> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_used_elem>(), + 8usize, + concat!("Size of: ", stringify!(vring_used_elem)) + ); + assert_eq!( + ::std::mem::align_of::<vring_used_elem>(), + 4usize, + concat!("Alignment of ", stringify!(vring_used_elem)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_used_elem), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(vring_used_elem), + "::", + stringify!(len) + ) + ); +} +pub type vring_used_elem_t = vring_used_elem; +#[repr(C)] +#[derive(Debug, Default)] +pub struct vring_used { + pub flags: __virtio16, + pub idx: __virtio16, + pub ring: __IncompleteArrayField<vring_used_elem_t>, +} +#[test] +fn bindgen_test_layout_vring_used() { + const UNINIT: ::std::mem::MaybeUninit<vring_used> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_used>(), + 4usize, + concat!("Size of: ", stringify!(vring_used)) + ); + assert_eq!( + ::std::mem::align_of::<vring_used>(), + 4usize, + concat!("Alignment of ", stringify!(vring_used)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_used), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).idx) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(vring_used), + "::", + stringify!(idx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ring) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(vring_used), + "::", + stringify!(ring) + ) + ); +} +#[doc = " struct vring_desc - Virtio ring descriptors,\n 16 bytes long. These can chain together via @next.\n\n @addr: buffer address (guest-physical)\n @len: buffer length\n @flags: descriptor flags\n @next: index of the next descriptor in the chain,\n if the VRING_DESC_F_NEXT flag is set. We chain unused\n descriptors via this, too."] +pub type vring_desc_t = vring_desc; +pub type vring_avail_t = vring_avail; +pub type vring_used_t = vring_used; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct vring { + pub num: ::std::os::raw::c_uint, + pub desc: *mut vring_desc_t, + pub avail: *mut vring_avail_t, + pub used: *mut vring_used_t, +} +#[test] +fn bindgen_test_layout_vring() { + const UNINIT: ::std::mem::MaybeUninit<vring> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring>(), + 32usize, + concat!("Size of: ", stringify!(vring)) + ); + assert_eq!( + ::std::mem::align_of::<vring>(), + 8usize, + concat!("Alignment of ", stringify!(vring)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring), + "::", + stringify!(num) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).desc) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(vring), + "::", + stringify!(desc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).avail) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(vring), + "::", + stringify!(avail) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).used) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(vring), + "::", + stringify!(used) + ) + ); +} +impl Default for vring { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct vring_packed_desc_event { + pub off_wrap: __le16, + pub flags: __le16, +} +#[test] +fn bindgen_test_layout_vring_packed_desc_event() { + const UNINIT: ::std::mem::MaybeUninit<vring_packed_desc_event> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_packed_desc_event>(), + 4usize, + concat!("Size of: ", stringify!(vring_packed_desc_event)) + ); + assert_eq!( + ::std::mem::align_of::<vring_packed_desc_event>(), + 2usize, + concat!("Alignment of ", stringify!(vring_packed_desc_event)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).off_wrap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc_event), + "::", + stringify!(off_wrap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc_event), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct vring_packed_desc { + pub addr: __le64, + pub len: __le32, + pub id: __le16, + pub flags: __le16, +} +#[test] +fn bindgen_test_layout_vring_packed_desc() { + const UNINIT: ::std::mem::MaybeUninit<vring_packed_desc> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<vring_packed_desc>(), + 16usize, + concat!("Size of: ", stringify!(vring_packed_desc)) + ); + assert_eq!( + ::std::mem::align_of::<vring_packed_desc>(), + 8usize, + concat!("Alignment of ", stringify!(vring_packed_desc)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(vring_packed_desc), + "::", + stringify!(flags) + ) + ); +} diff --git a/src/virtio_scsi.rs b/src/virtio_scsi.rs new file mode 100644 index 0000000..caa48ca --- /dev/null +++ b/src/virtio_scsi.rs @@ -0,0 +1,711 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +pub const VIRTIO_SCSI_CDB_DEFAULT_SIZE: u32 = 32; +pub const VIRTIO_SCSI_SENSE_DEFAULT_SIZE: u32 = 96; +pub const VIRTIO_SCSI_CDB_SIZE: u32 = 32; +pub const VIRTIO_SCSI_SENSE_SIZE: u32 = 96; +pub const VIRTIO_SCSI_F_INOUT: u32 = 0; +pub const VIRTIO_SCSI_F_HOTPLUG: u32 = 1; +pub const VIRTIO_SCSI_F_CHANGE: u32 = 2; +pub const VIRTIO_SCSI_F_T10_PI: u32 = 3; +pub const VIRTIO_SCSI_S_OK: u32 = 0; +pub const VIRTIO_SCSI_S_OVERRUN: u32 = 1; +pub const VIRTIO_SCSI_S_ABORTED: u32 = 2; +pub const VIRTIO_SCSI_S_BAD_TARGET: u32 = 3; +pub const VIRTIO_SCSI_S_RESET: u32 = 4; +pub const VIRTIO_SCSI_S_BUSY: u32 = 5; +pub const VIRTIO_SCSI_S_TRANSPORT_FAILURE: u32 = 6; +pub const VIRTIO_SCSI_S_TARGET_FAILURE: u32 = 7; +pub const VIRTIO_SCSI_S_NEXUS_FAILURE: u32 = 8; +pub const VIRTIO_SCSI_S_FAILURE: u32 = 9; +pub const VIRTIO_SCSI_S_FUNCTION_SUCCEEDED: u32 = 10; +pub const VIRTIO_SCSI_S_FUNCTION_REJECTED: u32 = 11; +pub const VIRTIO_SCSI_S_INCORRECT_LUN: u32 = 12; +pub const VIRTIO_SCSI_T_TMF: u32 = 0; +pub const VIRTIO_SCSI_T_AN_QUERY: u32 = 1; +pub const VIRTIO_SCSI_T_AN_SUBSCRIBE: u32 = 2; +pub const VIRTIO_SCSI_T_TMF_ABORT_TASK: u32 = 0; +pub const VIRTIO_SCSI_T_TMF_ABORT_TASK_SET: u32 = 1; +pub const VIRTIO_SCSI_T_TMF_CLEAR_ACA: u32 = 2; +pub const VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET: u32 = 3; +pub const VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: u32 = 4; +pub const VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET: u32 = 5; +pub const VIRTIO_SCSI_T_TMF_QUERY_TASK: u32 = 6; +pub const VIRTIO_SCSI_T_TMF_QUERY_TASK_SET: u32 = 7; +pub const VIRTIO_SCSI_T_EVENTS_MISSED: u32 = 2147483648; +pub const VIRTIO_SCSI_T_NO_EVENT: u32 = 0; +pub const VIRTIO_SCSI_T_TRANSPORT_RESET: u32 = 1; +pub const VIRTIO_SCSI_T_ASYNC_NOTIFY: u32 = 2; +pub const VIRTIO_SCSI_T_PARAM_CHANGE: u32 = 3; +pub const VIRTIO_SCSI_EVT_RESET_HARD: u32 = 0; +pub const VIRTIO_SCSI_EVT_RESET_RESCAN: u32 = 1; +pub const VIRTIO_SCSI_EVT_RESET_REMOVED: u32 = 2; +pub const VIRTIO_SCSI_S_SIMPLE: u32 = 0; +pub const VIRTIO_SCSI_S_ORDERED: u32 = 1; +pub const VIRTIO_SCSI_S_HEAD: u32 = 2; +pub const VIRTIO_SCSI_S_ACA: u32 = 3; +pub type __u8 = ::std::os::raw::c_uchar; +pub type __u16 = ::std::os::raw::c_ushort; +pub type __u32 = ::std::os::raw::c_uint; +pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __virtio16 = __u16; +pub type __virtio32 = __u32; +pub type __virtio64 = __u64; +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_cmd_req { + pub lun: [__u8; 8usize], + pub tag: __virtio64, + pub task_attr: __u8, + pub prio: __u8, + pub crn: __u8, + pub cdb: [__u8; 32usize], +} +#[test] +fn bindgen_test_layout_virtio_scsi_cmd_req() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_cmd_req> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_cmd_req>(), + 51usize, + concat!("Size of: ", stringify!(virtio_scsi_cmd_req)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_cmd_req>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_cmd_req)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(tag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).task_attr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(task_attr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prio) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(prio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).crn) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(crn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cdb) as usize - ptr as usize }, + 19usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req), + "::", + stringify!(cdb) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_cmd_req_pi { + pub lun: [__u8; 8usize], + pub tag: __virtio64, + pub task_attr: __u8, + pub prio: __u8, + pub crn: __u8, + pub pi_bytesout: __virtio32, + pub pi_bytesin: __virtio32, + pub cdb: [__u8; 32usize], +} +#[test] +fn bindgen_test_layout_virtio_scsi_cmd_req_pi() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_cmd_req_pi> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_cmd_req_pi>(), + 59usize, + concat!("Size of: ", stringify!(virtio_scsi_cmd_req_pi)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_cmd_req_pi>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_cmd_req_pi)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(tag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).task_attr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(task_attr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prio) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(prio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).crn) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(crn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pi_bytesout) as usize - ptr as usize }, + 19usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(pi_bytesout) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pi_bytesin) as usize - ptr as usize }, + 23usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(pi_bytesin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cdb) as usize - ptr as usize }, + 27usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_req_pi), + "::", + stringify!(cdb) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct virtio_scsi_cmd_resp { + pub sense_len: __virtio32, + pub resid: __virtio32, + pub status_qualifier: __virtio16, + pub status: __u8, + pub response: __u8, + pub sense: [__u8; 96usize], +} +#[test] +fn bindgen_test_layout_virtio_scsi_cmd_resp() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_cmd_resp> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_cmd_resp>(), + 108usize, + concat!("Size of: ", stringify!(virtio_scsi_cmd_resp)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_cmd_resp>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_cmd_resp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sense_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(sense_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(resid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status_qualifier) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(status_qualifier) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(status) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).response) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(response) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sense) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_cmd_resp), + "::", + stringify!(sense) + ) + ); +} +impl Default for virtio_scsi_cmd_resp { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_ctrl_tmf_req { + pub type_: __virtio32, + pub subtype: __virtio32, + pub lun: [__u8; 8usize], + pub tag: __virtio64, +} +#[test] +fn bindgen_test_layout_virtio_scsi_ctrl_tmf_req() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_ctrl_tmf_req> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_ctrl_tmf_req>(), + 24usize, + concat!("Size of: ", stringify!(virtio_scsi_ctrl_tmf_req)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_ctrl_tmf_req>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_ctrl_tmf_req)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_tmf_req), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).subtype) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_tmf_req), + "::", + stringify!(subtype) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_tmf_req), + "::", + stringify!(lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_tmf_req), + "::", + stringify!(tag) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_ctrl_tmf_resp { + pub response: __u8, +} +#[test] +fn bindgen_test_layout_virtio_scsi_ctrl_tmf_resp() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_ctrl_tmf_resp> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_ctrl_tmf_resp>(), + 1usize, + concat!("Size of: ", stringify!(virtio_scsi_ctrl_tmf_resp)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_ctrl_tmf_resp>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_ctrl_tmf_resp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).response) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_tmf_resp), + "::", + stringify!(response) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_ctrl_an_req { + pub type_: __virtio32, + pub lun: [__u8; 8usize], + pub event_requested: __virtio32, +} +#[test] +fn bindgen_test_layout_virtio_scsi_ctrl_an_req() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_ctrl_an_req> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_ctrl_an_req>(), + 16usize, + concat!("Size of: ", stringify!(virtio_scsi_ctrl_an_req)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_ctrl_an_req>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_ctrl_an_req)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_an_req), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_an_req), + "::", + stringify!(lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).event_requested) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_an_req), + "::", + stringify!(event_requested) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_ctrl_an_resp { + pub event_actual: __virtio32, + pub response: __u8, +} +#[test] +fn bindgen_test_layout_virtio_scsi_ctrl_an_resp() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_ctrl_an_resp> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_ctrl_an_resp>(), + 5usize, + concat!("Size of: ", stringify!(virtio_scsi_ctrl_an_resp)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_ctrl_an_resp>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_ctrl_an_resp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).event_actual) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_an_resp), + "::", + stringify!(event_actual) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).response) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_ctrl_an_resp), + "::", + stringify!(response) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_event { + pub event: __virtio32, + pub lun: [__u8; 8usize], + pub reason: __virtio32, +} +#[test] +fn bindgen_test_layout_virtio_scsi_event() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_event> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_event>(), + 16usize, + concat!("Size of: ", stringify!(virtio_scsi_event)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_event>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_event)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).event) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_event), + "::", + stringify!(event) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_event), + "::", + stringify!(lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_event), + "::", + stringify!(reason) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct virtio_scsi_config { + pub num_queues: __virtio32, + pub seg_max: __virtio32, + pub max_sectors: __virtio32, + pub cmd_per_lun: __virtio32, + pub event_info_size: __virtio32, + pub sense_size: __virtio32, + pub cdb_size: __virtio32, + pub max_channel: __virtio16, + pub max_target: __virtio16, + pub max_lun: __virtio32, +} +#[test] +fn bindgen_test_layout_virtio_scsi_config() { + const UNINIT: ::std::mem::MaybeUninit<virtio_scsi_config> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<virtio_scsi_config>(), + 36usize, + concat!("Size of: ", stringify!(virtio_scsi_config)) + ); + assert_eq!( + ::std::mem::align_of::<virtio_scsi_config>(), + 1usize, + concat!("Alignment of ", stringify!(virtio_scsi_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_queues) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(num_queues) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seg_max) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(seg_max) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_sectors) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(max_sectors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmd_per_lun) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(cmd_per_lun) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).event_info_size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(event_info_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sense_size) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(sense_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cdb_size) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(cdb_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_channel) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(max_channel) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_target) as usize - ptr as usize }, + 30usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(max_target) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_lun) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(virtio_scsi_config), + "::", + stringify!(max_lun) + ) + ); +} |