E1000NetworkAdapter.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/MACAddress.h>
  7. #include <Kernel/Bus/PCI/API.h>
  8. #include <Kernel/Bus/PCI/IDs.h>
  9. #include <Kernel/Debug.h>
  10. #include <Kernel/Net/Intel/E1000NetworkAdapter.h>
  11. #include <Kernel/Net/NetworkingManagement.h>
  12. #include <Kernel/Sections.h>
  13. namespace Kernel {
  14. #define REG_CTRL 0x0000
  15. #define REG_STATUS 0x0008
  16. #define REG_EEPROM 0x0014
  17. #define REG_CTRL_EXT 0x0018
  18. #define REG_INTERRUPT_CAUSE_READ 0x00C0
  19. #define REG_INTERRUPT_RATE 0x00C4
  20. #define REG_INTERRUPT_MASK_SET 0x00D0
  21. #define REG_INTERRUPT_MASK_CLEAR 0x00D8
  22. #define REG_RCTRL 0x0100
  23. #define REG_RXDESCLO 0x2800
  24. #define REG_RXDESCHI 0x2804
  25. #define REG_RXDESCLEN 0x2808
  26. #define REG_RXDESCHEAD 0x2810
  27. #define REG_RXDESCTAIL 0x2818
  28. #define REG_TCTRL 0x0400
  29. #define REG_TXDESCLO 0x3800
  30. #define REG_TXDESCHI 0x3804
  31. #define REG_TXDESCLEN 0x3808
  32. #define REG_TXDESCHEAD 0x3810
  33. #define REG_TXDESCTAIL 0x3818
  34. #define REG_RDTR 0x2820 // RX Delay Timer Register
  35. #define REG_RXDCTL 0x3828 // RX Descriptor Control
  36. #define REG_RADV 0x282C // RX Int. Absolute Delay Timer
  37. #define REG_RSRPD 0x2C00 // RX Small Packet Detect Interrupt
  38. #define REG_TIPG 0x0410 // Transmit Inter Packet Gap
  39. #define ECTRL_SLU 0x40 // set link up
  40. #define RCTL_EN (1 << 1) // Receiver Enable
  41. #define RCTL_SBP (1 << 2) // Store Bad Packets
  42. #define RCTL_UPE (1 << 3) // Unicast Promiscuous Enabled
  43. #define RCTL_MPE (1 << 4) // Multicast Promiscuous Enabled
  44. #define RCTL_LPE (1 << 5) // Long Packet Reception Enable
  45. #define RCTL_LBM_NONE (0 << 6) // No Loopback
  46. #define RCTL_LBM_PHY (3 << 6) // PHY or external SerDesc loopback
  47. #define RTCL_RDMTS_HALF (0 << 8) // Free Buffer Threshold is 1/2 of RDLEN
  48. #define RTCL_RDMTS_QUARTER (1 << 8) // Free Buffer Threshold is 1/4 of RDLEN
  49. #define RTCL_RDMTS_EIGHTH (2 << 8) // Free Buffer Threshold is 1/8 of RDLEN
  50. #define RCTL_MO_36 (0 << 12) // Multicast Offset - bits 47:36
  51. #define RCTL_MO_35 (1 << 12) // Multicast Offset - bits 46:35
  52. #define RCTL_MO_34 (2 << 12) // Multicast Offset - bits 45:34
  53. #define RCTL_MO_32 (3 << 12) // Multicast Offset - bits 43:32
  54. #define RCTL_BAM (1 << 15) // Broadcast Accept Mode
  55. #define RCTL_VFE (1 << 18) // VLAN Filter Enable
  56. #define RCTL_CFIEN (1 << 19) // Canonical Form Indicator Enable
  57. #define RCTL_CFI (1 << 20) // Canonical Form Indicator Bit Value
  58. #define RCTL_DPF (1 << 22) // Discard Pause Frames
  59. #define RCTL_PMCF (1 << 23) // Pass MAC Control Frames
  60. #define RCTL_SECRC (1 << 26) // Strip Ethernet CRC
  61. // Buffer Sizes
  62. #define RCTL_BSIZE_256 (3 << 16)
  63. #define RCTL_BSIZE_512 (2 << 16)
  64. #define RCTL_BSIZE_1024 (1 << 16)
  65. #define RCTL_BSIZE_2048 (0 << 16)
  66. #define RCTL_BSIZE_4096 ((3 << 16) | (1 << 25))
  67. #define RCTL_BSIZE_8192 ((2 << 16) | (1 << 25))
  68. #define RCTL_BSIZE_16384 ((1 << 16) | (1 << 25))
  69. // Transmit Command
  70. #define CMD_EOP (1 << 0) // End of Packet
  71. #define CMD_IFCS (1 << 1) // Insert FCS
  72. #define CMD_IC (1 << 2) // Insert Checksum
  73. #define CMD_RS (1 << 3) // Report Status
  74. #define CMD_RPS (1 << 4) // Report Packet Sent
  75. #define CMD_VLE (1 << 6) // VLAN Packet Enable
  76. #define CMD_IDE (1 << 7) // Interrupt Delay Enable
  77. // TCTL Register
  78. #define TCTL_EN (1 << 1) // Transmit Enable
  79. #define TCTL_PSP (1 << 3) // Pad Short Packets
  80. #define TCTL_CT_SHIFT 4 // Collision Threshold
  81. #define TCTL_COLD_SHIFT 12 // Collision Distance
  82. #define TCTL_SWXOFF (1 << 22) // Software XOFF Transmission
  83. #define TCTL_RTLC (1 << 24) // Re-transmit on Late Collision
  84. #define TSTA_DD (1 << 0) // Descriptor Done
  85. #define TSTA_EC (1 << 1) // Excess Collisions
  86. #define TSTA_LC (1 << 2) // Late Collision
  87. #define LSTA_TU (1 << 3) // Transmit Underrun
  88. // STATUS Register
  89. #define STATUS_FD 0x01
  90. #define STATUS_LU 0x02
  91. #define STATUS_TXOFF 0x08
  92. #define STATUS_SPEED 0xC0
  93. #define STATUS_SPEED_10MB 0x00
  94. #define STATUS_SPEED_100MB 0x40
  95. #define STATUS_SPEED_1000MB1 0x80
  96. #define STATUS_SPEED_1000MB2 0xC0
  97. // Interrupt Masks
  98. #define INTERRUPT_TXDW (1 << 0)
  99. #define INTERRUPT_TXQE (1 << 1)
  100. #define INTERRUPT_LSC (1 << 2)
  101. #define INTERRUPT_RXSEQ (1 << 3)
  102. #define INTERRUPT_RXDMT0 (1 << 4)
  103. #define INTERRUPT_RXO (1 << 6)
  104. #define INTERRUPT_RXT0 (1 << 7)
  105. #define INTERRUPT_MDAC (1 << 9)
  106. #define INTERRUPT_RXCFG (1 << 10)
  107. #define INTERRUPT_PHYINT (1 << 12)
  108. #define INTERRUPT_TXD_LOW (1 << 15)
  109. #define INTERRUPT_SRPD (1 << 16)
  110. // https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf Section 5.2
  111. UNMAP_AFTER_INIT static bool is_valid_device_id(u16 device_id)
  112. {
  113. // FIXME: It would be nice to distinguish which particular device it is.
  114. // Especially since it's needed to determine which registers we can access.
  115. // The reason I haven't done it now is because there's some IDs with multiple devices
  116. // and some devices with multiple IDs.
  117. switch (device_id) {
  118. case 0x1019: // 82547EI-A0, 82547EI-A1, 82547EI-B0, 82547GI-B0
  119. case 0x101A: // 82547EI-B0
  120. case 0x1010: // 82546EB-A1
  121. case 0x1012: // 82546EB-A1
  122. case 0x101D: // 82546EB-A1
  123. case 0x1079: // 82546GB-B0
  124. case 0x107A: // 82546GB-B0
  125. case 0x107B: // 82546GB-B0
  126. case 0x100F: // 82545EM-A
  127. case 0x1011: // 82545EM-A
  128. case 0x1026: // 82545GM-B
  129. case 0x1027: // 82545GM-B
  130. case 0x1028: // 82545GM-B
  131. case 0x1107: // 82544EI-A4
  132. case 0x1112: // 82544GC-A4
  133. case 0x1013: // 82541EI-A0, 82541EI-B0
  134. case 0x1018: // 82541EI-B0
  135. case 0x1076: // 82541GI-B1, 82541PI-C0
  136. case 0x1077: // 82541GI-B1
  137. case 0x1078: // 82541ER-C0
  138. case 0x1017: // 82540EP-A
  139. case 0x1016: // 82540EP-A
  140. case 0x100E: // 82540EM-A
  141. case 0x1015: // 82540EM-A
  142. return true;
  143. default:
  144. return false;
  145. }
  146. }
  147. UNMAP_AFTER_INIT LockRefPtr<E1000NetworkAdapter> E1000NetworkAdapter::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
  148. {
  149. if (pci_device_identifier.hardware_id().vendor_id != PCI::VendorID::Intel)
  150. return {};
  151. if (!is_valid_device_id(pci_device_identifier.hardware_id().device_id))
  152. return {};
  153. u8 irq = pci_device_identifier.interrupt_line().value();
  154. // FIXME: Better propagate errors here
  155. auto interface_name_or_error = NetworkingManagement::generate_interface_name_from_pci_address(pci_device_identifier);
  156. if (interface_name_or_error.is_error())
  157. return {};
  158. auto registers_io_window = IOWindow::create_for_pci_device_bar(pci_device_identifier, PCI::HeaderType0BaseRegister::BAR0).release_value_but_fixme_should_propagate_errors();
  159. auto adapter = adopt_lock_ref_if_nonnull(new (nothrow) E1000NetworkAdapter(pci_device_identifier.address(), irq, move(registers_io_window), interface_name_or_error.release_value()));
  160. if (!adapter)
  161. return {};
  162. if (adapter->initialize())
  163. return adapter;
  164. return {};
  165. }
  166. UNMAP_AFTER_INIT void E1000NetworkAdapter::setup_link()
  167. {
  168. u32 flags = in32(REG_CTRL);
  169. out32(REG_CTRL, flags | ECTRL_SLU);
  170. }
  171. UNMAP_AFTER_INIT void E1000NetworkAdapter::setup_interrupts()
  172. {
  173. out32(REG_INTERRUPT_RATE, 6000); // Interrupt rate of 1.536 milliseconds
  174. out32(REG_INTERRUPT_MASK_SET, INTERRUPT_LSC | INTERRUPT_RXT0 | INTERRUPT_RXO);
  175. in32(REG_INTERRUPT_CAUSE_READ);
  176. enable_irq();
  177. }
  178. UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize()
  179. {
  180. dmesgln("E1000: Found @ {}", pci_address());
  181. enable_bus_mastering(pci_address());
  182. dmesgln("E1000: IO base: {}", m_registers_io_window);
  183. dmesgln("E1000: Interrupt line: {}", interrupt_number());
  184. detect_eeprom();
  185. dmesgln("E1000: Has EEPROM? {}", m_has_eeprom);
  186. read_mac_address();
  187. auto const& mac = mac_address();
  188. dmesgln("E1000: MAC address: {}", mac.to_string());
  189. initialize_rx_descriptors();
  190. initialize_tx_descriptors();
  191. setup_link();
  192. setup_interrupts();
  193. m_link_up = ((in32(REG_STATUS) & STATUS_LU) != 0);
  194. return true;
  195. }
  196. UNMAP_AFTER_INIT E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq, NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<KString> interface_name)
  197. : NetworkAdapter(move(interface_name))
  198. , PCI::Device(address)
  199. , IRQHandler(irq)
  200. , m_registers_io_window(move(registers_io_window))
  201. , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 RX Descriptors"sv, Memory::Region::Access::ReadWrite).release_value())
  202. , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 TX Descriptors"sv, Memory::Region::Access::ReadWrite).release_value())
  203. {
  204. }
  205. UNMAP_AFTER_INIT E1000NetworkAdapter::~E1000NetworkAdapter() = default;
  206. bool E1000NetworkAdapter::handle_irq(RegisterState const&)
  207. {
  208. u32 status = in32(REG_INTERRUPT_CAUSE_READ);
  209. m_entropy_source.add_random_event(status);
  210. if (status == 0)
  211. return false;
  212. if (status & INTERRUPT_LSC) {
  213. u32 flags = in32(REG_CTRL);
  214. out32(REG_CTRL, flags | ECTRL_SLU);
  215. m_link_up = ((in32(REG_STATUS) & STATUS_LU) != 0);
  216. }
  217. if (status & INTERRUPT_RXDMT0) {
  218. // Threshold OK?
  219. }
  220. if (status & INTERRUPT_RXO) {
  221. dbgln_if(E1000_DEBUG, "E1000: RX buffer overrun");
  222. }
  223. if (status & INTERRUPT_RXT0) {
  224. receive();
  225. }
  226. m_wait_queue.wake_all();
  227. out32(REG_INTERRUPT_CAUSE_READ, 0xffffffff);
  228. return true;
  229. }
  230. UNMAP_AFTER_INIT void E1000NetworkAdapter::detect_eeprom()
  231. {
  232. out32(REG_EEPROM, 0x1);
  233. for (int i = 0; i < 999; ++i) {
  234. u32 data = in32(REG_EEPROM);
  235. if (data & 0x10) {
  236. m_has_eeprom = true;
  237. return;
  238. }
  239. }
  240. m_has_eeprom = false;
  241. }
  242. UNMAP_AFTER_INIT u32 E1000NetworkAdapter::read_eeprom(u8 address)
  243. {
  244. u16 data = 0;
  245. u32 tmp = 0;
  246. if (m_has_eeprom) {
  247. out32(REG_EEPROM, ((u32)address << 8) | 1);
  248. while (!((tmp = in32(REG_EEPROM)) & (1 << 4)))
  249. ;
  250. } else {
  251. out32(REG_EEPROM, ((u32)address << 2) | 1);
  252. while (!((tmp = in32(REG_EEPROM)) & (1 << 1)))
  253. ;
  254. }
  255. data = (tmp >> 16) & 0xffff;
  256. return data;
  257. }
  258. UNMAP_AFTER_INIT void E1000NetworkAdapter::read_mac_address()
  259. {
  260. if (m_has_eeprom) {
  261. MACAddress mac {};
  262. u32 tmp = read_eeprom(0);
  263. mac[0] = tmp & 0xff;
  264. mac[1] = tmp >> 8;
  265. tmp = read_eeprom(1);
  266. mac[2] = tmp & 0xff;
  267. mac[3] = tmp >> 8;
  268. tmp = read_eeprom(2);
  269. mac[4] = tmp & 0xff;
  270. mac[5] = tmp >> 8;
  271. set_mac_address(mac);
  272. } else {
  273. VERIFY_NOT_REACHED();
  274. }
  275. }
  276. UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_rx_descriptors()
  277. {
  278. auto* rx_descriptors = (e1000_tx_desc*)m_rx_descriptors_region->vaddr().as_ptr();
  279. constexpr auto rx_buffer_size = 8192;
  280. constexpr auto rx_buffer_page_count = rx_buffer_size / PAGE_SIZE;
  281. m_rx_buffer_region = MM.allocate_contiguous_kernel_region(rx_buffer_size * number_of_rx_descriptors, "E1000 RX buffers"sv, Memory::Region::Access::ReadWrite).release_value();
  282. for (size_t i = 0; i < number_of_rx_descriptors; ++i) {
  283. auto& descriptor = rx_descriptors[i];
  284. m_rx_buffers[i] = m_rx_buffer_region->vaddr().as_ptr() + rx_buffer_size * i;
  285. descriptor.addr = m_rx_buffer_region->physical_page(rx_buffer_page_count * i)->paddr().get();
  286. descriptor.status = 0;
  287. }
  288. out32(REG_RXDESCLO, m_rx_descriptors_region->physical_page(0)->paddr().get());
  289. out32(REG_RXDESCHI, 0);
  290. out32(REG_RXDESCLEN, number_of_rx_descriptors * sizeof(e1000_rx_desc));
  291. out32(REG_RXDESCHEAD, 0);
  292. out32(REG_RXDESCTAIL, number_of_rx_descriptors - 1);
  293. out32(REG_RCTRL, RCTL_EN | RCTL_SBP | RCTL_UPE | RCTL_MPE | RCTL_LBM_NONE | RTCL_RDMTS_HALF | RCTL_BAM | RCTL_SECRC | RCTL_BSIZE_8192);
  294. }
  295. UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_tx_descriptors()
  296. {
  297. auto* tx_descriptors = (e1000_tx_desc*)m_tx_descriptors_region->vaddr().as_ptr();
  298. constexpr auto tx_buffer_size = 8192;
  299. constexpr auto tx_buffer_page_count = tx_buffer_size / PAGE_SIZE;
  300. m_tx_buffer_region = MM.allocate_contiguous_kernel_region(tx_buffer_size * number_of_tx_descriptors, "E1000 TX buffers"sv, Memory::Region::Access::ReadWrite).release_value();
  301. for (size_t i = 0; i < number_of_tx_descriptors; ++i) {
  302. auto& descriptor = tx_descriptors[i];
  303. m_tx_buffers[i] = m_tx_buffer_region->vaddr().as_ptr() + tx_buffer_size * i;
  304. descriptor.addr = m_tx_buffer_region->physical_page(tx_buffer_page_count * i)->paddr().get();
  305. descriptor.cmd = 0;
  306. }
  307. out32(REG_TXDESCLO, m_tx_descriptors_region->physical_page(0)->paddr().get());
  308. out32(REG_TXDESCHI, 0);
  309. out32(REG_TXDESCLEN, number_of_tx_descriptors * sizeof(e1000_tx_desc));
  310. out32(REG_TXDESCHEAD, 0);
  311. out32(REG_TXDESCTAIL, 0);
  312. out32(REG_TCTRL, in32(REG_TCTRL) | TCTL_EN | TCTL_PSP);
  313. out32(REG_TIPG, 0x0060200A);
  314. }
  315. void E1000NetworkAdapter::out8(u16 address, u8 data)
  316. {
  317. dbgln_if(E1000_DEBUG, "E1000: OUT8 {:#02x} @ {:#04x}", data, address);
  318. m_registers_io_window->write8(address, data);
  319. }
  320. void E1000NetworkAdapter::out16(u16 address, u16 data)
  321. {
  322. dbgln_if(E1000_DEBUG, "E1000: OUT16 {:#04x} @ {:#04x}", data, address);
  323. m_registers_io_window->write16(address, data);
  324. }
  325. void E1000NetworkAdapter::out32(u16 address, u32 data)
  326. {
  327. dbgln_if(E1000_DEBUG, "E1000: OUT32 {:#08x} @ {:#04x}", data, address);
  328. m_registers_io_window->write32(address, data);
  329. }
  330. u8 E1000NetworkAdapter::in8(u16 address)
  331. {
  332. dbgln_if(E1000_DEBUG, "E1000: IN8 @ {:#04x}", address);
  333. return m_registers_io_window->read8(address);
  334. }
  335. u16 E1000NetworkAdapter::in16(u16 address)
  336. {
  337. dbgln_if(E1000_DEBUG, "E1000: IN16 @ {:#04x}", address);
  338. return m_registers_io_window->read16(address);
  339. }
  340. u32 E1000NetworkAdapter::in32(u16 address)
  341. {
  342. dbgln_if(E1000_DEBUG, "E1000: IN32 @ {:#04x}", address);
  343. return m_registers_io_window->read32(address);
  344. }
  345. void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
  346. {
  347. disable_irq();
  348. size_t tx_current = in32(REG_TXDESCTAIL) % number_of_tx_descriptors;
  349. dbgln_if(E1000_DEBUG, "E1000: Sending packet ({} bytes)", payload.size());
  350. auto* tx_descriptors = (e1000_tx_desc*)m_tx_descriptors_region->vaddr().as_ptr();
  351. auto& descriptor = tx_descriptors[tx_current];
  352. VERIFY(payload.size() <= 8192);
  353. auto* vptr = (void*)m_tx_buffers[tx_current];
  354. memcpy(vptr, payload.data(), payload.size());
  355. descriptor.length = payload.size();
  356. descriptor.status = 0;
  357. descriptor.cmd = CMD_EOP | CMD_IFCS | CMD_RS;
  358. dbgln_if(E1000_DEBUG, "E1000: Using tx descriptor {} (head is at {})", tx_current, in32(REG_TXDESCHEAD));
  359. tx_current = (tx_current + 1) % number_of_tx_descriptors;
  360. cli();
  361. enable_irq();
  362. out32(REG_TXDESCTAIL, tx_current);
  363. for (;;) {
  364. if (descriptor.status) {
  365. sti();
  366. break;
  367. }
  368. m_wait_queue.wait_forever("E1000NetworkAdapter"sv);
  369. }
  370. dbgln_if(E1000_DEBUG, "E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);
  371. }
  372. void E1000NetworkAdapter::receive()
  373. {
  374. auto* rx_descriptors = (e1000_tx_desc*)m_rx_descriptors_region->vaddr().as_ptr();
  375. u32 rx_current;
  376. for (;;) {
  377. rx_current = in32(REG_RXDESCTAIL) % number_of_rx_descriptors;
  378. rx_current = (rx_current + 1) % number_of_rx_descriptors;
  379. if (!(rx_descriptors[rx_current].status & 1))
  380. break;
  381. auto* buffer = m_rx_buffers[rx_current];
  382. u16 length = rx_descriptors[rx_current].length;
  383. VERIFY(length <= 8192);
  384. dbgln_if(E1000_DEBUG, "E1000: Received 1 packet @ {:p} ({} bytes)", buffer, length);
  385. did_receive({ buffer, length });
  386. rx_descriptors[rx_current].status = 0;
  387. out32(REG_RXDESCTAIL, rx_current);
  388. }
  389. }
  390. i32 E1000NetworkAdapter::link_speed()
  391. {
  392. if (!link_up())
  393. return NetworkAdapter::LINKSPEED_INVALID;
  394. u32 speed = in32(REG_STATUS) & STATUS_SPEED;
  395. switch (speed) {
  396. case STATUS_SPEED_10MB:
  397. return 10;
  398. case STATUS_SPEED_100MB:
  399. return 100;
  400. case STATUS_SPEED_1000MB1:
  401. case STATUS_SPEED_1000MB2:
  402. return 1000;
  403. default:
  404. return NetworkAdapter::LINKSPEED_INVALID;
  405. }
  406. }
  407. bool E1000NetworkAdapter::link_full_duplex()
  408. {
  409. u32 status = in32(REG_STATUS);
  410. return !!(status & STATUS_FD);
  411. }
  412. }