Make an attempt at detecting nonexistent serial port hardware.
authorhpa <hpa>
Wed, 21 Nov 2001 20:48:04 +0000 (20:48 +0000)
committerhpa <hpa>
Wed, 21 Nov 2001 20:48:04 +0000 (20:48 +0000)
isolinux.asm
ldlinux.asm
pxelinux.asm
syslinux.doc

index fdf54de..2abd748 100644 (file)
@@ -1222,8 +1222,9 @@ pc_serial:        call getint                     ; "serial" command
                cmp di,3
                ja .port_is_io                  ; If port > 3 then port is I/O addr
                shl di,1
-               mov di,[di+serial_base]
-.port_is_io:   mov [SerialPort],di
+               mov di,[di+serial_base]         ; Get the I/O port from the BIOS
+.port_is_io:
+               mov [SerialPort],di
                lea dx,[di+3]                   ; DX -> LCR
                mov al,83h                      ; Enable DLAB
                call slow_out
@@ -1236,6 +1237,9 @@ pc_serial:        call getint                     ; "serial" command
                mov al,03h                      ; Disable DLAB
                add dx,byte 2                   ; DX -> LCR
                call slow_out
+               in al,dx                        ; Read back LCR (detect missing hw)
+               cmp al,03h                      ; If nothing here we'll read 00 or FF
+               jne .serial_port_bad            ; Assume serial port busted
                sub dx,byte 2                   ; DX -> IER
                xor al,al                       ; IRQ disable
                call slow_out
@@ -1253,6 +1257,10 @@ pc_serial:       call getint                     ; "serial" command
 
                jmp short parse_config_3
 
+.serial_port_bad:
+               mov [SerialPort], word 0
+               jmp short parse_config_3
+
 pc_fkey:       sub ah,'1'
                jnb pc_fkey1
                mov ah,9                        ; F10
index 65b9330..f9552f9 100644 (file)
@@ -1320,8 +1320,9 @@ pc_serial:        call getint                     ; "serial" command
                cmp di,3
                ja .port_is_io                  ; If port > 3 then port is I/O addr
                shl di,1
-               mov di,[di+serial_base]
-.port_is_io:   mov [SerialPort],di
+               mov di,[di+serial_base]         ; Get the I/O port from the BIOS
+.port_is_io:
+               mov [SerialPort],di
                lea dx,[di+3]                   ; DX -> LCR
                mov al,83h                      ; Enable DLAB
                call slow_out
@@ -1334,6 +1335,9 @@ pc_serial:        call getint                     ; "serial" command
                mov al,03h                      ; Disable DLAB
                add dx,byte 2                   ; DX -> LCR
                call slow_out
+               in al,dx                        ; Read back LCR (detect missing hw)
+               cmp al,03h                      ; If nothing here we'll read 00 or FF
+               jne .serial_port_bad            ; Assume serial port busted
                sub dx,byte 2                   ; DX -> IER
                xor al,al                       ; IRQ disable
                call slow_out
@@ -1351,6 +1355,10 @@ pc_serial:       call getint                     ; "serial" command
 
                jmp short parse_config_3
 
+.serial_port_bad:
+               mov [SerialPort], word 0
+               jmp short parse_config_3
+
 pc_fkey:       sub ah,'1'
                jnb pc_fkey1
                mov ah,9                        ; F10
index 5a6976d..85faf63 100644 (file)
@@ -1037,8 +1037,9 @@ pc_serial:        call getint                     ; "serial" command
                cmp di,3
                ja .port_is_io                  ; If port > 3 then port is I/O addr
                shl di,1
-               mov di,[di+serial_base]
-.port_is_io:   mov [SerialPort],di
+               mov di,[di+serial_base]         ; Get the I/O port from the BIOS
+.port_is_io:
+               mov [SerialPort],di
                lea dx,[di+3]                   ; DX -> LCR
                mov al,83h                      ; Enable DLAB
                call slow_out
@@ -1051,6 +1052,9 @@ pc_serial:        call getint                     ; "serial" command
                mov al,03h                      ; Disable DLAB
                add dx,byte 2                   ; DX -> LCR
                call slow_out
+               in al,dx                        ; Read back LCR (detect missing hw)
+               cmp al,03h                      ; If nothing here we'll read 00 or FF
+               jne .serial_port_bad            ; Assume serial port busted
                sub dx,byte 2                   ; DX -> IER
                xor al,al                       ; IRQ disable
                call slow_out
@@ -1068,6 +1072,10 @@ pc_serial:       call getint                     ; "serial" command
 
                jmp short parse_config_3
 
+.serial_port_bad:
+               mov [SerialPort], word 0
+               jmp short parse_config_3
+
 pc_fkey:       sub ah,'1'
                jnb pc_fkey1
                mov ah,9                        ; F10
index 3a06485..71cbbe4 100644 (file)
@@ -234,6 +234,10 @@ SERIAL port [[baudrate] flowcontrol]
        For the SERIAL directive to be guaranteed to work properly, it
        should be the first directive in the configuration file.
 
+       NOTE: "port" values from 0 to 3 means the first four serial
+       ports detected by the BIOS.  They may or may not correspond to
+       the legacy port values 0x3F8, 0x2F8, 0x3E8, 0x2E8.
+
 FONT filename
        Load a font in .psf format before displaying any output
        (except the copyright line, which is output as ldlinux.sys