1#![allow(unused_imports)]
4#![allow(dead_code)]
5
6use super::prelude::*;
7use cfg_if::cfg_if;
8
9cfg_if! {
10 if #[cfg(net_dev = "dummy")] {
11 use axdriver_net::{EthernetAddress, NetBuf, NetBufBox, NetBufPool, NetBufPtr};
12
13 pub struct DummyNetDev;
14 pub struct DummyNetDrvier;
15 register_net_driver!(DummyNetDriver, DummyNetDev);
16
17 impl BaseDriverOps for DummyNetDev {
18 fn device_type(&self) -> DeviceType { DeviceType::Net }
19 fn device_name(&self) -> &str { "dummy-net" }
20 }
21
22 impl NetDriverOps for DummyNetDev {
23 fn mac_address(&self) -> EthernetAddress { unreachable!() }
24 fn can_transmit(&self) -> bool { false }
25 fn can_receive(&self) -> bool { false }
26 fn rx_queue_size(&self) -> usize { 0 }
27 fn tx_queue_size(&self) -> usize { 0 }
28 fn recycle_rx_buffer(&mut self, _: NetBufPtr) -> DevResult { Err(DevError::Unsupported) }
29 fn recycle_tx_buffers(&mut self) -> DevResult { Err(DevError::Unsupported) }
30 fn transmit(&mut self, _: NetBufPtr) -> DevResult { Err(DevError::Unsupported) }
31 fn receive(&mut self) -> DevResult<NetBufPtr> { Err(DevError::Unsupported) }
32 fn alloc_tx_buffer(&mut self, _: usize) -> DevResult<NetBufPtr> { Err(DevError::Unsupported) }
33 }
34 }
35}
36
37cfg_if! {
38 if #[cfg(block_dev = "dummy")] {
39 pub struct DummyBlockDev;
40 pub struct DummyBlockDriver;
41 register_block_driver!(DummyBlockDriver, DummyBlockDev);
42
43 impl BaseDriverOps for DummyBlockDev {
44 fn device_type(&self) -> DeviceType {
45 DeviceType::Block
46 }
47 fn device_name(&self) -> &str {
48 "dummy-block"
49 }
50 }
51
52 impl BlockDriverOps for DummyBlockDev {
53 fn num_blocks(&self) -> u64 {
54 0
55 }
56 fn block_size(&self) -> usize {
57 0
58 }
59 fn read_block(&mut self, _: u64, _: &mut [u8]) -> DevResult {
60 Err(DevError::Unsupported)
61 }
62 fn write_block(&mut self, _: u64, _: &[u8]) -> DevResult {
63 Err(DevError::Unsupported)
64 }
65 fn flush(&mut self) -> DevResult {
66 Err(DevError::Unsupported)
67 }
68 }
69 }
70}
71
72cfg_if! {
73 if #[cfg(display_dev = "dummy")] {
74 pub struct DummyDisplayDev;
75 pub struct DummyDisplayDriver;
76 register_display_driver!(DummyDisplayDriver, DummyDisplayDev);
77
78 impl BaseDriverOps for DummyDisplayDev {
79 fn device_type(&self) -> DeviceType {
80 DeviceType::Display
81 }
82 fn device_name(&self) -> &str {
83 "dummy-display"
84 }
85 }
86
87 impl DisplayDriverOps for DummyDisplayDev {
88 fn info(&self) -> axdriver_display::DisplayInfo {
89 unreachable!()
90 }
91 fn fb(&self) -> axdriver_display::FrameBuffer {
92 unreachable!()
93 }
94 fn need_flush(&self) -> bool {
95 false
96 }
97 fn flush(&mut self) -> DevResult {
98 Err(DevError::Unsupported)
99 }
100 }
101 }
102}