1004e86ffSlogin use alloc::vec::Vec; 2004e86ffSlogin use core::{intrinsics::size_of, ptr}; 3004e86ffSlogin 4004e86ffSlogin use core::sync::atomic::compiler_fence; 5004e86ffSlogin 6004e86ffSlogin use crate::mm::phys_2_virt; 7004e86ffSlogin 8004e86ffSlogin /// 文件说明: 实现了 AHCI 中的控制器 HBA 的相关行为 9004e86ffSlogin 10004e86ffSlogin /// 根据 AHCI 写出 HBA 的 Command 11004e86ffSlogin pub const ATA_CMD_READ_DMA_EXT: u8 = 0x25; // 读操作,并且退出 12004e86ffSlogin pub const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; // 写操作,并且退出 13004e86ffSlogin #[allow(dead_code)] 14004e86ffSlogin pub const ATA_CMD_IDENTIFY: u8 = 0xEC; 15004e86ffSlogin #[allow(dead_code)] 16004e86ffSlogin pub const ATA_CMD_IDENTIFY_PACKET: u8 = 0xA1; 17004e86ffSlogin #[allow(dead_code)] 18004e86ffSlogin pub const ATA_CMD_PACKET: u8 = 0xA0; 19004e86ffSlogin pub const ATA_DEV_BUSY: u8 = 0x80; 20004e86ffSlogin pub const ATA_DEV_DRQ: u8 = 0x08; 21004e86ffSlogin 22004e86ffSlogin pub const HBA_PORT_CMD_CR: u32 = 1 << 15; 23004e86ffSlogin pub const HBA_PORT_CMD_FR: u32 = 1 << 14; 24004e86ffSlogin pub const HBA_PORT_CMD_FRE: u32 = 1 << 4; 25004e86ffSlogin pub const HBA_PORT_CMD_ST: u32 = 1; 26004e86ffSlogin #[allow(dead_code)] 27004e86ffSlogin pub const HBA_PORT_IS_ERR: u32 = 1 << 30 | 1 << 29 | 1 << 28 | 1 << 27; 28004e86ffSlogin pub const HBA_SSTS_PRESENT: u32 = 0x3; 29004e86ffSlogin pub const HBA_SIG_ATA: u32 = 0x00000101; 30004e86ffSlogin pub const HBA_SIG_ATAPI: u32 = 0xEB140101; 31004e86ffSlogin pub const HBA_SIG_PM: u32 = 0x96690101; 32004e86ffSlogin pub const HBA_SIG_SEMB: u32 = 0xC33C0101; 33004e86ffSlogin 34004e86ffSlogin /// 接入 Port 的 不同设备类型 35004e86ffSlogin #[derive(Debug)] 36004e86ffSlogin pub enum HbaPortType { 37004e86ffSlogin None, 38004e86ffSlogin Unknown(u32), 39004e86ffSlogin SATA, 40004e86ffSlogin SATAPI, 41004e86ffSlogin PM, 42004e86ffSlogin SEMB, 43004e86ffSlogin } 44004e86ffSlogin 45004e86ffSlogin /// 声明了 HBA 的所有属性 46004e86ffSlogin #[repr(packed)] 47004e86ffSlogin pub struct HbaPort { 48004e86ffSlogin pub clb: u64, // 0x00, command list base address, 1K-byte aligned 49004e86ffSlogin pub fb: u64, // 0x08, FIS base address, 256-byte aligned 50004e86ffSlogin pub is: u32, // 0x10, interrupt status 51004e86ffSlogin pub ie: u32, // 0x14, interrupt enable 52004e86ffSlogin pub cmd: u32, // 0x18, command and status 53004e86ffSlogin pub _rsv0: u32, // 0x1C, Reserved 54004e86ffSlogin pub tfd: u32, // 0x20, task file data 55004e86ffSlogin pub sig: u32, // 0x24, signature 56004e86ffSlogin pub ssts: u32, // 0x28, SATA status (SCR0:SStatus) 57004e86ffSlogin pub sctl: u32, // 0x2C, SATA control (SCR2:SControl) 58004e86ffSlogin pub serr: u32, // 0x30, SATA error (SCR1:SError) 59004e86ffSlogin pub sact: u32, // 0x34, SATA active (SCR3:SActive) 60004e86ffSlogin pub ci: u32, // 0x38, command issue 61004e86ffSlogin pub sntf: u32, // 0x3C, SATA notification (SCR4:SNotification) 62004e86ffSlogin pub fbs: u32, // 0x40, FIS-based switch control 63004e86ffSlogin pub _rsv1: [u32; 11], // 0x44 ~ 0x6F, Reserved 64004e86ffSlogin pub vendor: [u32; 4], // 0x70 ~ 0x7F, vendor specific 65004e86ffSlogin } 66004e86ffSlogin 67004e86ffSlogin /// 全称 HBA Memory Register,是HBA的寄存器在内存中的映射 68004e86ffSlogin #[repr(packed)] 69004e86ffSlogin pub struct HbaMem { 70004e86ffSlogin pub cap: u32, // 0x00, Host capability 71004e86ffSlogin pub ghc: u32, // 0x04, Global host control 72004e86ffSlogin pub is: u32, // 0x08, Interrupt status 73004e86ffSlogin pub pi: u32, // 0x0C, Port implemented 74004e86ffSlogin pub vs: u32, // 0x10, Version 75004e86ffSlogin pub ccc_ctl: u32, // 0x14, Command completion coalescing control 76004e86ffSlogin pub ccc_pts: u32, // 0x18, Command completion coalescing ports 77004e86ffSlogin pub em_loc: u32, // 0x1C, Enclosure management location 78004e86ffSlogin pub em_ctl: u32, // 0x20, Enclosure management control 79004e86ffSlogin pub cap2: u32, // 0x24, Host capabilities extended 80004e86ffSlogin pub bohc: u32, // 0x28, BIOS/OS handoff control and status 81004e86ffSlogin pub _rsv: [u8; 116], // 0x2C - 0x9F, Reserved 82004e86ffSlogin pub vendor: [u8; 96], // 0xA0 - 0xFF, Vendor specific registers 83004e86ffSlogin pub ports: [HbaPort; 32], // 0x100 - 0x10FF, Port control registers 84004e86ffSlogin } 85004e86ffSlogin 86004e86ffSlogin /// HBA Command Table 里面的 PRDT 项 87004e86ffSlogin /// 作用: 记录了内存中读/写数据的位置,以及长度。你可以把他类比成一个指针? 88004e86ffSlogin #[repr(packed)] 89004e86ffSlogin pub struct HbaPrdtEntry { 90004e86ffSlogin pub dba: u64, // Data base address 91004e86ffSlogin _rsv0: u32, // Reserved 92004e86ffSlogin pub dbc: u32, // Byte count, 4M max, interrupt = 1 93004e86ffSlogin } 94004e86ffSlogin 95004e86ffSlogin /// HAB Command Table 96004e86ffSlogin /// 每个 Port 一个 Table,主机和设备的交互都靠这个数据结构 97004e86ffSlogin #[repr(packed)] 98004e86ffSlogin pub struct HbaCmdTable { 99004e86ffSlogin // 0x00 100004e86ffSlogin pub cfis: [u8; 64], // Command FIS 101004e86ffSlogin // 0x40 102004e86ffSlogin pub acmd: [u8; 16], // ATAPI command, 12 or 16 bytes 103004e86ffSlogin // 0x50 104004e86ffSlogin _rsv: [u8; 48], // Reserved 105004e86ffSlogin // 0x80 106*7ae679ddSLoGin pub prdt_entry: [HbaPrdtEntry; 8], // Physical region descriptor table entries, 0 ~ 65535, 需要注意不要越界 这里设置8的原因是,目前CmdTable只预留了8个PRDT项的空间 107004e86ffSlogin } 108004e86ffSlogin 109004e86ffSlogin /// HBA Command Header 110004e86ffSlogin /// 作用: 你可以把他类比成 Command Table 的指针。 111004e86ffSlogin /// 猜测: 这里多了一层 Header,而不是直接在 HbaMem 结构体指向 CmdTable,可能是为了兼容和可移植性? 112004e86ffSlogin #[repr(packed)] 113004e86ffSlogin pub struct HbaCmdHeader { 114004e86ffSlogin // DW0 115004e86ffSlogin pub cfl: u8, 116004e86ffSlogin // Command FIS length in DWORDS: 5(len in [2, 16]), atapi: 1, write - host to device: 1, prefetchable: 1 117004e86ffSlogin pub _pm: u8, // Reset - 0x80, bist: 0x40, clear busy on ok: 0x20, port multiplier 118004e86ffSlogin pub prdtl: u16, // Physical region descriptor table length in entries 119004e86ffSlogin // DW1 120004e86ffSlogin pub _prdbc: u32, // Physical region descriptor byte count transferred 121004e86ffSlogin // DW2, 3 122004e86ffSlogin pub ctba: u64, // Command table descriptor base address 123004e86ffSlogin // DW4 - 7 124004e86ffSlogin pub _rsv1: [u32; 4], // Reserved 125004e86ffSlogin } 126004e86ffSlogin 127004e86ffSlogin /// Port 的函数实现 128004e86ffSlogin impl HbaPort { 129004e86ffSlogin /// 获取设备类型 130004e86ffSlogin pub fn check_type(&mut self) -> HbaPortType { 131004e86ffSlogin if volatile_read!(self.ssts) & HBA_SSTS_PRESENT > 0 { 132004e86ffSlogin let sig = volatile_read!(self.sig); 133004e86ffSlogin match sig { 134004e86ffSlogin HBA_SIG_ATA => HbaPortType::SATA, 135004e86ffSlogin HBA_SIG_ATAPI => HbaPortType::SATAPI, 136004e86ffSlogin HBA_SIG_PM => HbaPortType::PM, 137004e86ffSlogin HBA_SIG_SEMB => HbaPortType::SEMB, 138004e86ffSlogin _ => HbaPortType::Unknown(sig), 139004e86ffSlogin } 140004e86ffSlogin } else { 141004e86ffSlogin HbaPortType::None 142004e86ffSlogin } 143004e86ffSlogin } 144004e86ffSlogin 145004e86ffSlogin /// 启动该端口的命令引擎 146004e86ffSlogin pub fn start(&mut self) { 147004e86ffSlogin while volatile_read!(self.cmd) & HBA_PORT_CMD_CR > 0 { 148004e86ffSlogin core::hint::spin_loop(); 149004e86ffSlogin } 150004e86ffSlogin let val: u32 = volatile_read!(self.cmd) | HBA_PORT_CMD_FRE | HBA_PORT_CMD_ST; 151004e86ffSlogin volatile_write!(self.cmd, val); 152004e86ffSlogin } 153004e86ffSlogin 154004e86ffSlogin /// 关闭该端口的命令引擎 155004e86ffSlogin pub fn stop(&mut self) { 156004e86ffSlogin #[allow(unused_unsafe)] 157004e86ffSlogin { 158004e86ffSlogin volatile_write!( 159004e86ffSlogin self.cmd, 160004e86ffSlogin (u32::MAX ^ HBA_PORT_CMD_ST) & volatile_read!(self.cmd) 161004e86ffSlogin ); 162004e86ffSlogin } 163004e86ffSlogin 164004e86ffSlogin while volatile_read!(self.cmd) & (HBA_PORT_CMD_FR | HBA_PORT_CMD_CR) 165004e86ffSlogin == (HBA_PORT_CMD_FR | HBA_PORT_CMD_CR) 166004e86ffSlogin { 167004e86ffSlogin core::hint::spin_loop(); 168004e86ffSlogin } 169004e86ffSlogin 170004e86ffSlogin #[allow(unused_unsafe)] 171004e86ffSlogin { 172004e86ffSlogin volatile_write!( 173004e86ffSlogin self.cmd, 174004e86ffSlogin (u32::MAX ^ HBA_PORT_CMD_FRE) & volatile_read!(self.cmd) 175004e86ffSlogin ); 176004e86ffSlogin } 177004e86ffSlogin } 178004e86ffSlogin 179004e86ffSlogin /// @return: 返回一个空闲 cmd table 的 id; 如果没有,则返回 Option::None 180004e86ffSlogin pub fn find_cmdslot(&self) -> Option<u32> { 181004e86ffSlogin let slots = volatile_read!(self.sact) | volatile_read!(self.ci); 182004e86ffSlogin for i in 0..32 { 183004e86ffSlogin if slots & 1 << i == 0 { 184004e86ffSlogin return Some(i); 185004e86ffSlogin } 186004e86ffSlogin } 187004e86ffSlogin return None; 188004e86ffSlogin } 189004e86ffSlogin 190004e86ffSlogin /// 初始化, 把 CmdList 等变量的地址赋值到 HbaPort 上 - 这些空间由操作系统分配且固定 191004e86ffSlogin /// 等价于原C版本的 port_rebase 函数 192004e86ffSlogin pub fn init(&mut self, clb: u64, fb: u64, ctbas: &Vec<u64>) { 193004e86ffSlogin self.stop(); // 先暂停端口 194004e86ffSlogin 195004e86ffSlogin // 赋值 command list base address 196004e86ffSlogin // Command list offset: 1K*portno 197004e86ffSlogin // Command list entry size = 32 198004e86ffSlogin // Command list entry maxim count = 32 199004e86ffSlogin // Command list maxim size = 32*32 = 1K per port 200004e86ffSlogin volatile_write!(self.clb, clb); 201004e86ffSlogin 202004e86ffSlogin unsafe { 203004e86ffSlogin compiler_fence(core::sync::atomic::Ordering::SeqCst); 204004e86ffSlogin ptr::write_bytes(phys_2_virt(clb as usize) as *mut u64, 0, 1024); 205004e86ffSlogin } 206004e86ffSlogin 207004e86ffSlogin // 赋值 fis base address 208004e86ffSlogin // FIS offset: 32K+256*portno 209004e86ffSlogin // FIS entry size = 256 bytes per port 210004e86ffSlogin volatile_write!(self.fb, fb); 211004e86ffSlogin unsafe { 212004e86ffSlogin compiler_fence(core::sync::atomic::Ordering::SeqCst); 213004e86ffSlogin ptr::write_bytes(phys_2_virt(fb as usize) as *mut u64, 0, 256); 214004e86ffSlogin } 215004e86ffSlogin 216004e86ffSlogin // 赋值 command table base address 217004e86ffSlogin // Command table offset: 40K + 8K*portno 218004e86ffSlogin // Command table size = 256*32 = 8K per port 219004e86ffSlogin let mut cmdheaders = phys_2_virt(clb as usize) as *mut u64 as *mut HbaCmdHeader; 220004e86ffSlogin for i in 0..32 as usize { 221*7ae679ddSLoGin volatile_write!((*cmdheaders).prdtl, 0); // 一开始没有询问,prdtl = 0(预留了8个PRDT项的空间) 222004e86ffSlogin volatile_write!((*cmdheaders).ctba, ctbas[i]); 223004e86ffSlogin // 这里限制了 prdtl <= 8, 所以一共用了256bytes,如果需要修改,可以修改这里 224004e86ffSlogin compiler_fence(core::sync::atomic::Ordering::SeqCst); 225004e86ffSlogin unsafe { 226004e86ffSlogin ptr::write_bytes(phys_2_virt(ctbas[i] as usize) as *mut u64, 0, 256); 227004e86ffSlogin } 228004e86ffSlogin cmdheaders = (cmdheaders as usize + size_of::<HbaCmdHeader>()) as *mut HbaCmdHeader; 229004e86ffSlogin } 230004e86ffSlogin 231004e86ffSlogin #[allow(unused_unsafe)] 232004e86ffSlogin { 233004e86ffSlogin // 启动中断 234004e86ffSlogin volatile_write!(self.ie, 0 /*TODO: Enable interrupts: 0b10111*/); 235004e86ffSlogin 236004e86ffSlogin // 错误码 237004e86ffSlogin volatile_write!(self.serr, volatile_read!(self.serr)); 238004e86ffSlogin 239004e86ffSlogin // Disable power management 240004e86ffSlogin volatile_write!(self.sctl, volatile_read!(self.sctl) | 7 << 8); 241004e86ffSlogin 242004e86ffSlogin // Power on and spin up device 243004e86ffSlogin volatile_write!(self.cmd, volatile_read!(self.cmd) | 1 << 2 | 1 << 1); 244004e86ffSlogin } 245004e86ffSlogin self.start(); // 重新开启端口 246004e86ffSlogin } 247004e86ffSlogin } 248004e86ffSlogin 249004e86ffSlogin #[repr(u8)] 250004e86ffSlogin #[allow(dead_code)] 251004e86ffSlogin pub enum FisType { 252004e86ffSlogin /// Register FIS - host to device 253004e86ffSlogin RegH2D = 0x27, 254004e86ffSlogin /// Register FIS - device to host 255004e86ffSlogin RegD2H = 0x34, 256004e86ffSlogin /// DMA activate FIS - device to host 257004e86ffSlogin DmaAct = 0x39, 258004e86ffSlogin /// DMA setup FIS - bidirectional 259004e86ffSlogin DmaSetup = 0x41, 260004e86ffSlogin /// Data FIS - bidirectional 261004e86ffSlogin Data = 0x46, 262004e86ffSlogin /// BIST activate FIS - bidirectional 263004e86ffSlogin Bist = 0x58, 264004e86ffSlogin /// PIO setup FIS - device to host 265004e86ffSlogin PioSetup = 0x5F, 266004e86ffSlogin /// Set device bits FIS - device to host 267004e86ffSlogin DevBits = 0xA1, 268004e86ffSlogin } 269004e86ffSlogin 270004e86ffSlogin #[repr(packed)] 271004e86ffSlogin pub struct FisRegH2D { 272004e86ffSlogin // DWORD 0 273004e86ffSlogin pub fis_type: u8, // FIS_TYPE_REG_H2D 274004e86ffSlogin 275004e86ffSlogin pub pm: u8, // Port multiplier, 1: Command, 0: Control 276004e86ffSlogin // uint8_t pmport : 4; // Port multiplier 低4位 277004e86ffSlogin // uint8_t rsv0 : 3; // Reserved 278004e86ffSlogin // uint8_t c : 1; // 1: Command, 0: Control 279004e86ffSlogin pub command: u8, // Command register 280004e86ffSlogin pub featurel: u8, // Feature register, 7:0 281004e86ffSlogin 282004e86ffSlogin // DWORD 1 283004e86ffSlogin pub lba0: u8, // LBA low register, 7:0 284004e86ffSlogin pub lba1: u8, // LBA mid register, 15:8 285004e86ffSlogin pub lba2: u8, // LBA high register, 23:16 286004e86ffSlogin pub device: u8, // Device register 287004e86ffSlogin 288004e86ffSlogin // DWORD 2 289004e86ffSlogin pub lba3: u8, // LBA register, 31:24 290004e86ffSlogin pub lba4: u8, // LBA register, 39:32 291004e86ffSlogin pub lba5: u8, // LBA register, 47:40 292004e86ffSlogin pub featureh: u8, // Feature register, 15:8 293004e86ffSlogin 294004e86ffSlogin // DWORD 3 295004e86ffSlogin pub countl: u8, // Count register, 7:0 296004e86ffSlogin pub counth: u8, // Count register, 15:8 297004e86ffSlogin pub icc: u8, // Isochronous command completion 298004e86ffSlogin pub control: u8, // Control register 299004e86ffSlogin 300004e86ffSlogin // DWORD 4 301004e86ffSlogin pub rsv1: [u8; 4], // Reserved 302004e86ffSlogin } 303004e86ffSlogin 304004e86ffSlogin #[repr(packed)] 305004e86ffSlogin #[allow(dead_code)] 306004e86ffSlogin pub struct FisRegD2H { 307004e86ffSlogin // DWORD 0 308004e86ffSlogin pub fis_type: u8, // FIS_TYPE_REG_D2H 309004e86ffSlogin 310004e86ffSlogin pub pm: u8, // Port multiplier, Interrupt bit: 2 311004e86ffSlogin 312004e86ffSlogin pub status: u8, // Status register 313004e86ffSlogin pub error: u8, // Error register 314004e86ffSlogin 315004e86ffSlogin // DWORD 1 316004e86ffSlogin pub lba0: u8, // LBA low register, 7:0 317004e86ffSlogin pub lba1: u8, // LBA mid register, 15:8 318004e86ffSlogin pub lba2: u8, // LBA high register, 23:16 319004e86ffSlogin pub device: u8, // Device register 320004e86ffSlogin 321004e86ffSlogin // DWORD 2 322004e86ffSlogin pub lba3: u8, // LBA register, 31:24 323004e86ffSlogin pub lba4: u8, // LBA register, 39:32 324004e86ffSlogin pub lba5: u8, // LBA register, 47:40 325004e86ffSlogin pub rsv2: u8, // Reserved 326004e86ffSlogin 327004e86ffSlogin // DWORD 3 328004e86ffSlogin pub countl: u8, // Count register, 7:0 329004e86ffSlogin pub counth: u8, // Count register, 15:8 330004e86ffSlogin pub rsv3: [u8; 2], // Reserved 331004e86ffSlogin 332004e86ffSlogin // DWORD 4 333004e86ffSlogin pub rsv4: [u8; 4], // Reserved 334004e86ffSlogin } 335004e86ffSlogin 336004e86ffSlogin #[repr(packed)] 337004e86ffSlogin #[allow(dead_code)] 338004e86ffSlogin pub struct FisData { 339004e86ffSlogin // DWORD 0 340004e86ffSlogin pub fis_type: u8, // FIS_TYPE_DATA 341004e86ffSlogin 342004e86ffSlogin pub pm: u8, // Port multiplier 343004e86ffSlogin 344004e86ffSlogin pub rsv1: [u8; 2], // Reserved 345004e86ffSlogin 346004e86ffSlogin // DWORD 1 ~ N 347004e86ffSlogin pub data: [u8; 252], // Payload 348004e86ffSlogin } 349004e86ffSlogin 350004e86ffSlogin #[repr(packed)] 351004e86ffSlogin #[allow(dead_code)] 352004e86ffSlogin pub struct FisPioSetup { 353004e86ffSlogin // DWORD 0 354004e86ffSlogin pub fis_type: u8, // FIS_TYPE_PIO_SETUP 355004e86ffSlogin 356004e86ffSlogin pub pm: u8, // Port multiplier, direction: 4 - device to host, interrupt: 2 357004e86ffSlogin 358004e86ffSlogin pub status: u8, // Status register 359004e86ffSlogin pub error: u8, // Error register 360004e86ffSlogin 361004e86ffSlogin // DWORD 1 362004e86ffSlogin pub lba0: u8, // LBA low register, 7:0 363004e86ffSlogin pub lba1: u8, // LBA mid register, 15:8 364004e86ffSlogin pub lba2: u8, // LBA high register, 23:16 365004e86ffSlogin pub device: u8, // Device register 366004e86ffSlogin 367004e86ffSlogin // DWORD 2 368004e86ffSlogin pub lba3: u8, // LBA register, 31:24 369004e86ffSlogin pub lba4: u8, // LBA register, 39:32 370004e86ffSlogin pub lba5: u8, // LBA register, 47:40 371004e86ffSlogin pub rsv2: u8, // Reserved 372004e86ffSlogin 373004e86ffSlogin // DWORD 3 374004e86ffSlogin pub countl: u8, // Count register, 7:0 375004e86ffSlogin pub counth: u8, // Count register, 15:8 376004e86ffSlogin pub rsv3: u8, // Reserved 377004e86ffSlogin pub e_status: u8, // New value of status register 378004e86ffSlogin 379004e86ffSlogin // DWORD 4 380004e86ffSlogin pub tc: u16, // Transfer count 381004e86ffSlogin pub rsv4: [u8; 2], // Reserved 382004e86ffSlogin } 383004e86ffSlogin 384004e86ffSlogin #[repr(packed)] 385004e86ffSlogin #[allow(dead_code)] 386004e86ffSlogin pub struct FisDmaSetup { 387004e86ffSlogin // DWORD 0 388004e86ffSlogin pub fis_type: u8, // FIS_TYPE_DMA_SETUP 389004e86ffSlogin 390004e86ffSlogin pub pm: u8, // Port multiplier, direction: 4 - device to host, interrupt: 2, auto-activate: 1 391004e86ffSlogin 392004e86ffSlogin pub rsv1: [u8; 2], // Reserved 393004e86ffSlogin 394004e86ffSlogin // DWORD 1&2 395004e86ffSlogin pub dma_buffer_id: u64, /* DMA Buffer Identifier. Used to Identify DMA buffer in host memory. SATA Spec says host specific and not in Spec. Trying AHCI spec might work. */ 396004e86ffSlogin 397004e86ffSlogin // DWORD 3 398004e86ffSlogin pub rsv3: u32, // More reserved 399004e86ffSlogin 400004e86ffSlogin // DWORD 4 401004e86ffSlogin pub dma_buffer_offset: u32, // Byte offset into buffer. First 2 bits must be 0 402004e86ffSlogin 403004e86ffSlogin // DWORD 5 404004e86ffSlogin pub transfer_count: u32, // Number of bytes to transfer. Bit 0 must be 0 405004e86ffSlogin 406004e86ffSlogin // DWORD 6 407004e86ffSlogin pub rsv6: u32, // Reserved 408004e86ffSlogin } 409