11use crate :: error:: Result ;
2- use crate :: logger;
32use crate :: physdev:: com:: * ;
43use crate :: vcpu;
54use crate :: virtdev:: {
65 DeviceEvent , DeviceEventResponse , DeviceRegion , EmulatedDevice , Event , Port ,
76} ;
8- use alloc:: string:: String ;
97use alloc:: sync:: Arc ;
108use alloc:: vec:: Vec ;
119use core:: convert:: TryInto ;
1210use spin:: RwLock ;
1311
1412pub struct Uart8250 {
15- id : u64 ,
1613 base_port : Port ,
17- is_newline : bool ,
1814 divisor : u16 ,
1915 receive_buffer : Option < u8 > ,
2016 interrupt_enable_register : IerFlags ,
@@ -27,12 +23,10 @@ pub struct Uart8250 {
2723}
2824
2925impl Uart8250 {
30- pub fn new ( vmid : u64 , base_port : Port ) -> Arc < RwLock < Self > > {
26+ pub fn new ( base_port : Port ) -> Arc < RwLock < Self > > {
3127 Arc :: new ( RwLock :: new ( Self {
32- id : vmid,
3328 base_port : base_port,
3429 divisor : 0 ,
35- is_newline : true ,
3630 receive_buffer : None ,
3731 interrupt_identification_register : 0x01 ,
3832 interrupt_enable_register : IerFlags :: empty ( ) ,
@@ -123,19 +117,9 @@ impl EmulatedDevice for Uart8250 {
123117 if self . divisor_latch_bit_set ( ) {
124118 self . divisor &= 0xff00 | val as u16 ;
125119 } else {
126- if self . is_newline {
127- logger:: write_console ( & format ! (
128- "GUEST{}: " ,
129- self . id
130- ) ) ;
131- }
132-
133- let buff = & [ val] ;
134- let s = String :: from_utf8_lossy ( buff) ;
135- logger:: write_console ( & s) ;
136-
137- self . is_newline = val == 10 ;
138-
120+ event. responses . push (
121+ DeviceEventResponse :: GuestUartTransmitted ( val) ,
122+ ) ;
139123 if self
140124 . interrupt_enable_register
141125 . contains ( IerFlags :: THR_EMPTY_INTERRUPT )
0 commit comments