Forráskód Böngészése

Update to latest version of bitflags crate.

Andrew Walbran 1 éve
szülő
commit
713ac2f890

+ 1 - 1
Cargo.toml

@@ -16,7 +16,7 @@ categories = ["hardware-support", "no-std"]
 
 [dependencies]
 log = "0.4"
-bitflags = "1.3"
+bitflags = "2.3.0"
 zerocopy = "0.6.1"
 
 [features]

+ 1 - 0
src/device/blk.rs

@@ -417,6 +417,7 @@ impl Default for BlkResp {
 pub const SECTOR_SIZE: usize = 512;
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct BlkFeature: u64 {
         /// Device supports request barriers. (legacy)
         const BARRIER       = 1 << 0;

+ 1 - 0
src/device/common.rs

@@ -3,6 +3,7 @@
 use bitflags::bitflags;
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     pub(crate) struct Feature: u64 {
         // device independent
         const NOTIFY_ON_EMPTY       = 1 << 24; // legacy

+ 1 - 0
src/device/console.rs

@@ -206,6 +206,7 @@ struct Config {
 }
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct Features: u64 {
         const SIZE                  = 1 << 0;
         const MULTIPORT             = 1 << 1;

+ 1 - 0
src/device/gpu.rs

@@ -313,6 +313,7 @@ struct Config {
 const EVENT_DISPLAY: u32 = 1 << 0;
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct Features: u64 {
         /// virgl 3D mode is supported.
         const VIRGL                 = 1 << 0;

+ 8 - 3
src/device/net.rs

@@ -262,6 +262,7 @@ impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> Drop for VirtIONet<H, T, QUE
 }
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct Features: u64 {
         /// Device handles packets with partial checksum.
         /// This "checksum offload" is a common feature on modern network cards.
@@ -323,6 +324,7 @@ bitflags! {
 }
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct Status: u16 {
         const LINK_UP = 1;
         const ANNOUNCE = 2;
@@ -330,6 +332,7 @@ bitflags! {
 }
 
 bitflags! {
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     struct InterruptStatus : u32 {
         const USED_RING_UPDATE = 1 << 0;
         const CONFIGURATION_CHANGE = 1 << 1;
@@ -364,10 +367,12 @@ pub struct VirtioNetHdr {
     // payload starts from here
 }
 
+#[derive(AsBytes, Copy, Clone, Debug, Default, Eq, FromBytes, PartialEq)]
+#[repr(transparent)]
+struct Flags(u8);
+
 bitflags! {
-    #[repr(transparent)]
-    #[derive(AsBytes, Default, FromBytes)]
-    struct Flags: u8 {
+    impl Flags: u8 {
         const NEEDS_CSUM = 1;
         const DATA_VALID = 2;
         const RSC_INFO   = 4;

+ 6 - 3
src/queue.rs

@@ -555,10 +555,13 @@ impl Descriptor {
     }
 }
 
+/// Descriptor flags
+#[derive(Copy, Clone, Debug, Default, Eq, FromBytes, PartialEq)]
+#[repr(transparent)]
+struct DescFlags(u16);
+
 bitflags! {
-    /// Descriptor flags
-    #[derive(FromBytes)]
-    struct DescFlags: u16 {
+    impl DescFlags: u16 {
         const NEXT = 1;
         const WRITE = 2;
         const INDIRECT = 4;

+ 1 - 1
src/transport/mod.rs

@@ -93,7 +93,7 @@ pub trait Transport {
 
 bitflags! {
     /// The device status field. Writing 0 into this field resets the device.
-    #[derive(Default)]
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     pub struct DeviceStatus: u32 {
         /// Indicates that the guest OS has found the device and recognized it
         /// as a valid virtio device.

+ 2 - 0
src/transport/pci/bus.rs

@@ -24,6 +24,7 @@ pub const PCI_CAP_ID_VNDR: u8 = 0x09;
 
 bitflags! {
     /// The status register in PCI configuration space.
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     pub struct Status: u16 {
         // Bits 0-2 are reserved.
         /// The state of the device's INTx# signal.
@@ -53,6 +54,7 @@ bitflags! {
 
 bitflags! {
     /// The command register in PCI configuration space.
+    #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
     pub struct Command: u16 {
         /// The device can respond to I/O Space accesses.
         const IO_SPACE = 1 << 0;