From ee89890b4008c40bd7d6ea5ddb1016b47fee7bbf Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 23 May 2009 19:20:01 -0700 Subject: [PATCH] core: don't flush the serial port queue for a serial command 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 --- core/parseconfig.inc | 2 +- core/serirq.inc | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/core/parseconfig.inc b/core/parseconfig.inc index efa41d1..65d71c9 100644 --- a/core/parseconfig.inc +++ b/core/parseconfig.inc @@ -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 diff --git a/core/serirq.inc b/core/serirq.inc index 8b04728..579c42b 100644 --- a/core/serirq.inc +++ b/core/serirq.inc @@ -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 -- 2.7.4