2021-12-08 02:51:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-09-13 17:55:17 +00:00
|
|
|
# Copyright 2022 The ChromiumOS Authors
|
2021-12-08 02:51:31 +00:00
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
2022-09-13 19:37:28 +00:00
|
|
|
|
2021-12-08 02:51:31 +00:00
|
|
|
# Regenerate virtio_sys bindgen bindings.
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
|
|
|
|
source tools/impl/bindgen-common.sh
|
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--allowlist-type='vhost_.*' \
|
|
|
|
--allowlist-var='VHOST_.*' \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/vhost.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
> virtio_sys/src/vhost.rs
|
|
|
|
|
2024-01-15 01:40:18 +00:00
|
|
|
VIRTIO_CONFIG_EXTRA="// Added by virtio_sys/bindgen.sh
|
|
|
|
pub const VIRTIO_CONFIG_S_SUSPEND: u32 = 16;
|
|
|
|
pub const VIRTIO_F_SUSPEND: u32 = 42;"
|
|
|
|
|
2022-04-11 21:35:56 +00:00
|
|
|
bindgen_generate \
|
2024-01-15 01:40:18 +00:00
|
|
|
--raw-line "${VIRTIO_CONFIG_EXTRA}" \
|
2022-04-11 21:35:56 +00:00
|
|
|
--allowlist-var='VIRTIO_.*' \
|
|
|
|
--allowlist-type='virtio_.*' \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_config.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
> virtio_sys/src/virtio_config.rs
|
|
|
|
|
2022-12-13 21:45:02 +00:00
|
|
|
VIRTIO_FS_EXTRA="// Added by virtio_sys/bindgen.sh
|
|
|
|
use data_model::Le32;
|
2023-02-08 23:16:15 +00:00
|
|
|
use zerocopy::AsBytes;
|
2023-09-20 19:11:35 +00:00
|
|
|
use zerocopy::FromBytes;
|
|
|
|
use zerocopy::FromZeroes;"
|
2022-12-13 21:45:02 +00:00
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--raw-line "${VIRTIO_FS_EXTRA}" \
|
|
|
|
--allowlist-var='VIRTIO_FS_.*' \
|
|
|
|
--allowlist-type='virtio_fs_.*' \
|
2023-09-20 19:11:35 +00:00
|
|
|
--with-derive-custom "virtio_fs_config=FromZeroes,FromBytes,AsBytes" \
|
2022-12-13 21:45:02 +00:00
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_fs.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
| replace_linux_endian_types \
|
|
|
|
> virtio_sys/src/virtio_fs.rs
|
|
|
|
|
2022-04-11 22:37:21 +00:00
|
|
|
VIRTIO_IDS_EXTRAS="
|
|
|
|
//! This file defines virtio device IDs. IDs with large values (counting down
|
|
|
|
//! from 63) are nonstandard and not defined by the virtio specification.
|
|
|
|
|
|
|
|
// Added by virtio_sys/bindgen.sh - do not edit the generated file.
|
2022-06-09 23:41:41 +00:00
|
|
|
// TODO(b/236144983): Fix this id when an official virtio-id is assigned to this device.
|
2023-09-22 01:00:44 +00:00
|
|
|
pub const VIRTIO_ID_PVCLOCK: u32 = 61;
|
2024-10-07 04:13:31 +00:00
|
|
|
// TODO: Remove this once the ID is included in the Linux headers.
|
|
|
|
pub const VIRTIO_ID_MEDIA: u32 = 49;
|
2022-04-11 22:37:21 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--raw-line "${VIRTIO_IDS_EXTRAS}" \
|
2022-09-13 22:17:56 +00:00
|
|
|
--allowlist-var='VIRTIO_ID_.*' \
|
2022-04-11 22:37:21 +00:00
|
|
|
--allowlist-type='virtio_.*' \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_ids.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
| rustfmt \
|
|
|
|
> virtio_sys/src/virtio_ids.rs
|
|
|
|
|
2023-02-08 23:16:15 +00:00
|
|
|
VIRTIO_NET_EXTRA="// Added by virtio_sys/bindgen.sh
|
|
|
|
use zerocopy::AsBytes;
|
2023-09-20 19:11:35 +00:00
|
|
|
use zerocopy::FromBytes;
|
|
|
|
use zerocopy::FromZeroes;"
|
2023-02-08 23:16:15 +00:00
|
|
|
|
2021-12-08 02:51:31 +00:00
|
|
|
bindgen_generate \
|
2022-04-27 04:09:54 +00:00
|
|
|
--raw-line "${VIRTIO_NET_EXTRA}" \
|
2021-12-08 02:51:31 +00:00
|
|
|
--allowlist-var='VIRTIO_NET_.*' \
|
|
|
|
--allowlist-type='virtio_net_.*' \
|
|
|
|
--blocklist-type='virtio_net_ctrl_mac' \
|
2023-09-20 19:11:35 +00:00
|
|
|
--with-derive-custom "virtio_net_hdr=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_net_hdr_mrg_rxbuf=FromZeroes,FromBytes,AsBytes" \
|
2021-12-08 02:51:31 +00:00
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_net.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
> virtio_sys/src/virtio_net.rs
|
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--allowlist-var='VRING_.*' \
|
|
|
|
--allowlist-var='VIRTIO_RING_.*' \
|
|
|
|
--allowlist-type='vring.*' \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_ring.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
> virtio_sys/src/virtio_ring.rs
|
2022-07-25 13:07:15 +00:00
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--allowlist-var='VIRTIO_.*' \
|
|
|
|
--allowlist-type='virtio_.*' \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_mmio.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
> virtio_sys/src/virtio_mmio.rs
|
2023-07-06 00:45:28 +00:00
|
|
|
|
|
|
|
VIRTIO_VSOCK_EXTRA="// Added by virtio_sys/bindgen.sh
|
|
|
|
use data_model::Le16;
|
|
|
|
use data_model::Le32;
|
|
|
|
use data_model::Le64;
|
|
|
|
use zerocopy::AsBytes;"
|
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--raw-line "${VIRTIO_VSOCK_EXTRA}" \
|
|
|
|
--allowlist-var='VIRTIO_VSOCK_.*' \
|
|
|
|
--allowlist-type='virtio_vsock_.*' \
|
|
|
|
--with-derive-custom "virtio_vsock_event=AsBytes" \
|
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_vsock.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
| replace_linux_endian_types \
|
|
|
|
> virtio_sys/src/virtio_vsock.rs
|
2023-09-06 08:27:21 +00:00
|
|
|
|
|
|
|
VIRTIO_SCSI_EXTRA="// Added by virtio_sys/bindgen.sh
|
|
|
|
use zerocopy::AsBytes;
|
2023-09-20 19:11:35 +00:00
|
|
|
use zerocopy::FromBytes;
|
|
|
|
use zerocopy::FromZeroes;"
|
2023-09-06 08:27:21 +00:00
|
|
|
|
|
|
|
bindgen_generate \
|
|
|
|
--raw-line "${VIRTIO_SCSI_EXTRA}" \
|
|
|
|
--allowlist-var='VIRTIO_SCSI_.*' \
|
|
|
|
--allowlist-type='virtio_scsi_.*' \
|
|
|
|
--blocklist-type='virtio_scsi_cmd_req_pi' \
|
2023-09-20 19:11:35 +00:00
|
|
|
--with-derive-custom "virtio_scsi_config=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_scsi_cmd_req=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_scsi_cmd_resp=FromZeroes,FromBytes,AsBytes" \
|
2023-10-20 07:56:55 +00:00
|
|
|
--with-derive-custom "virtio_scsi_ctrl_tmf_req=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_scsi_ctrl_an_req=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_scsi_ctrl_tmf_resp=FromZeroes,FromBytes,AsBytes" \
|
|
|
|
--with-derive-custom "virtio_scsi_ctrl_an_resp=FromZeroes,FromBytes,AsBytes" \
|
2023-09-06 08:27:21 +00:00
|
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/virtio_scsi.h" \
|
|
|
|
-- \
|
|
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
|
|
| replace_linux_int_types \
|
|
|
|
| replace_linux_endian_types \
|
|
|
|
> virtio_sys/src/virtio_scsi.rs
|