//! Pure submission boundary shared by native code and its host tests. pub const RO:u32=1<<5; pub const FLUSH:u32=1<<9; pub const VERSION_1:u32=1; pub const IOMMU:u32=2; #[derive(Clone,Copy,Debug,PartialEq,Eq)] pub struct Features { low:u32, high:u32, read_only:bool } impl Features { pub fn negotiate(read_only:bool,low:u32,high:u32)->Option{ if high&VERSION_1==0||high&IOMMU!=0||(low&RO!=0)!=read_only||(!read_only&&low&FLUSH==0){return None} Some(Self{low:if read_only{RO}else{FLUSH},high:VERSION_1,read_only}) } pub const fn low(self)->u32{self.low} pub const fn high(self)->u32{self.high} pub fn accepts(self,operation:u32,lba:u64,prior_requests:u16,capacity:u64)->bool{ if prior_requests>=16||capacity!=2048{return false} match operation{ 0=>matches!(lba,16|17|18|111|120|128..=131)&&lbamatches!(lba,18|120|128..=131)&&lba!self.read_only&&self.low&FLUSH!=0&&lba==0, _=>false, } } }