core: don't flush the serial port queue for a serial command
authorH. Peter Anvin <hpa@zytor.com>
Sun, 24 May 2009 02:20:01 +0000 (19:20 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 24 May 2009 02:20:01 +0000 (19:20 -0700)
Don't flush the serial port queue when encountering a "serial"
command.  We don't actually want to lose data due to a repeated
"serial", since it's quite likely it's exactly the same as before.

Do flush the queue on hardware cleanup, however.

Also fix some minor bugs, including a bunch of code in the .data
segment.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/parseconfig.inc
core/serirq.inc

index efa41d1..65d71c9 100644 (file)
@@ -224,7 +224,7 @@ pc_serial:  call getint
                ;
                ; Begin code to actually set up the serial port
                ;
-               call sirq_cleanup               ; Cleanup existing IRQ handler
+               call sirq_cleanup_nowipe        ; Cleanup existing IRQ handler
 
                lea dx,[di+3]                   ; DX -> LCR
                mov al,83h                      ; Enable DLAB
index 8b04728..579c42b 100644 (file)
@@ -91,6 +91,8 @@ SerialIRQPort dw 0                    ; Serial port w IRQ service
 SerialHead     dw 0                    ; Head of serial port rx buffer
 SerialTail     dw 0                    ; Tail of serial port rx buffer
 
+               section .text
+
 sirq_install:
                pushad
 
@@ -124,8 +126,7 @@ sirq_install:
                mov [SerialIRQPort],bx
 
                lea dx,[bx+5]           ; DX -> LCR
-               in al,dx
-               and al,7Fh              ; Clear DLAB (should already be...)
+               mov al,03h              ; Clear DLAB (should already be...)
                slow_out dx,al
 
                lea dx,[bx+1]           ; DX -> IER
@@ -135,7 +136,7 @@ sirq_install:
                popad
                ret
 
-sirq_cleanup:
+sirq_cleanup_nowipe:
                pushad
                push ds
                push es
@@ -148,8 +149,7 @@ sirq_cleanup:
                jz .done
 
                lea dx,[bx+5]           ; DX -> LCR
-               in al,dx
-               and al,7Fh              ; Clear DLAB (should already be...)
+               mov al,03h              ; Clear DLAB (should already be...)
                slow_out dx,al
 
                lea dx,[bx+1]           ; DX -> IER
@@ -165,19 +165,26 @@ sirq_cleanup:
                mov cx,8
                rep movsd
 
+.done:
+               pop es
+               pop ds
+               popad
+               ret
+
+sirq_cleanup:
+               call sirq_cleanup_nowipe
+               pushad
+               push es
                ; Just in case it might contain a password, erase the
                ; serial port receive buffer...
-               mov [SerialIRQPort],ax
-               mov [SerialHead],eax
-               mov cx,aux_seg + (aux.serial >> 4)
-               mov es,cx
+               mov ax,aux_seg + (aux.serial >> 4)
+               mov es,ax
+               xor eax,eax
+               mov [cs:SerialHead],eax
                mov cx,serial_buf_size >> 2
                xor di,di
                rep stosd
-
-.done:
                pop es
-               pop ds
                popad
                ret