|
22 | 22 |
|
23 | 23 | use bitflags::bitflags; |
24 | 24 | use core::fmt; |
25 | | -use x86_64::instructions::port::Port; |
| 25 | +use x86_64::instructions::port::{Port, PortReadOnly, PortWriteOnly}; |
26 | 26 |
|
27 | 27 | macro_rules! wait_for { |
28 | 28 | ($cond:expr) => { |
@@ -56,43 +56,26 @@ bitflags! { |
56 | 56 | /// An interface to a serial port that allows sending out individual bytes. |
57 | 57 | pub struct SerialPort { |
58 | 58 | data: Port<u8>, |
59 | | - int_en: Port<u8>, |
60 | | - fifo_ctrl: Port<u8>, |
61 | | - line_ctrl: Port<u8>, |
62 | | - modem_ctrl: Port<u8>, |
63 | | - line_sts: Port<u8>, |
| 59 | + int_en: PortWriteOnly<u8>, |
| 60 | + fifo_ctrl: PortWriteOnly<u8>, |
| 61 | + line_ctrl: PortWriteOnly<u8>, |
| 62 | + modem_ctrl: PortWriteOnly<u8>, |
| 63 | + line_sts: PortReadOnly<u8>, |
64 | 64 | } |
65 | 65 |
|
66 | 66 | impl SerialPort { |
67 | 67 | /// Creates a new serial port interface on the given I/O port. |
68 | 68 | /// |
69 | 69 | /// This function is unsafe because the caller must ensure that the given base address |
70 | 70 | /// really points to a serial port device. |
71 | | - #[cfg(feature = "nightly")] |
72 | 71 | pub const unsafe fn new(base: u16) -> SerialPort { |
73 | 72 | SerialPort { |
74 | 73 | data: Port::new(base), |
75 | | - int_en: Port::new(base + 1), |
76 | | - fifo_ctrl: Port::new(base + 2), |
77 | | - line_ctrl: Port::new(base + 3), |
78 | | - modem_ctrl: Port::new(base + 4), |
79 | | - line_sts: Port::new(base + 5), |
80 | | - } |
81 | | - } |
82 | | - |
83 | | - /// Creates a new serial port interface on the given I/O port. |
84 | | - /// |
85 | | - /// This function is unsafe because the caller must ensure that the given base address |
86 | | - /// really points to a serial port device. |
87 | | - #[cfg(not(feature = "nightly"))] |
88 | | - pub unsafe fn new(base: u16) -> SerialPort { |
89 | | - SerialPort { |
90 | | - data: Port::new(base), |
91 | | - int_en: Port::new(base + 1), |
92 | | - fifo_ctrl: Port::new(base + 2), |
93 | | - line_ctrl: Port::new(base + 3), |
94 | | - modem_ctrl: Port::new(base + 4), |
95 | | - line_sts: Port::new(base + 5), |
| 74 | + int_en: PortWriteOnly::new(base + 1), |
| 75 | + fifo_ctrl: PortWriteOnly::new(base + 2), |
| 76 | + line_ctrl: PortWriteOnly::new(base + 3), |
| 77 | + modem_ctrl: PortWriteOnly::new(base + 4), |
| 78 | + line_sts: PortReadOnly::new(base + 5), |
96 | 79 | } |
97 | 80 | } |
98 | 81 |
|
|
0 commit comments