Support sending information from the comboot module to the syslinux core
authorH. Peter Anvin <hpa@zytor.com>
Sat, 26 Aug 2006 00:16:49 +0000 (17:16 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 26 Aug 2006 00:16:49 +0000 (17:16 -0700)
as to what the graphics mode is set to.

comboot.doc
comboot.inc
conio.inc
extlinux.asm
font.inc
graphics.inc
layout.inc
ldlinux.asm
plaincon.inc [new file with mode: 0644]
rawcon.inc

index cb3488b..8b8cdad 100644 (file)
@@ -658,3 +658,63 @@ AX=0016h [3.10] Run kernel image
        doesn't exist, instead of returning to the command line.  (It
        may still return to the command line if the image is somehow
        corrupt, however.)
+
+
+AX=0017h [3.20] Report video mode change
+       Input:  AX      0017h
+               BX      Video mode flags
+                       Bit 0:  graphics mode
+                       Bit 1:  non-default mode
+                       Bit 2:  VESA mode
+                       Bit 3:  text functions not supported
+               CX      For graphics modes, pixel columns
+               DX      For graphics modes, pixel rows
+       Output: None
+
+       This function is used to report video mode changes to
+       SYSLINUX.  It does NOT actually change the video mode, but
+       rather, allows SYSLINUX to take appropriate action in response
+       to a video mode change.  Modes that cannot be exited either
+       with the conventional BIOS mode set command (INT 10h, AH=00h)
+       or the VESA VBE mode set command (INT 10h, AX=4F02h) should
+       not be used.
+
+       This function returns with a failure if BX contains any bits
+       which are undefined in the current version of SYSLINUX.
+
+       The following bits in BX are currently defined:
+       
+       Bit 0: graphics mode
+
+               Indicates that the mode is a graphics mode, as opposed
+               to a text mode.
+
+       Bit 1: non-standard mode
+
+               A non-standard mode is any mode except text mode and
+               graphics mode 0012h (VGA 640x480, 16 color.)
+
+       Bit 2: VESA mode
+
+               This mode is a VESA mode, and has to be exited with
+               the VESA VBE API (INT 10h, AX=4F02h) as opposed to the
+               conventional BIOS API (INT 10h, AH=00h).
+
+       Bit 3: Text functions not supported
+
+               This indicates that the BIOS text output functions
+               (INT 10h, AH=02h, 03h, 06h, 09h, 0Eh, 11h) don't work.
+               If this bit is set, SYSLINUX will reset the mode
+               before printing any characters on the screen.
+
+               This is common for VESA modes.
+
+
+AX=0018h [3.20]        Query custom font
+       Input:  AX      0018h
+       Output: AL      Height of custom font in scan lines, or zero
+               ES:BX   Pointer to custom font in memory
+
+       This call queries if a custom display font has been loaded via
+       the "font" configuration file command.  If no custom font has
+       been loaded, AL contains zero.
index 0ce82b2..5fda968 100644 (file)
@@ -1,6 +1,6 @@
 ;; -----------------------------------------------------------------------
 ;;
-;;   Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2006 H. Peter Anvin - All Rights Reserved
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
@@ -732,6 +732,45 @@ comapi_runkernel:
                mov word [CmdOptPtr],zero_string
                jmp kernel_good_saved
 
+;
+; INT 22h AX=0017h  Report video mode change
+;
+comapi_usingvga:
+               mov ax,P_BX
+               cmp ax,0Fh              ; Unknown flags = failure
+               ja .error
+               mov [UsingVGA],al
+               mov cx,P_CX
+               mov dx,P_DX
+               mov [GXPixCols],cx
+               mov [GXPixRows],dx
+               test al,08h
+               jnz .notext
+               call adjust_screen
+.notext:
+               clc
+               ret
+.error:
+               stc
+               ret
+
+;
+; INT 22h AX=0018h  Query custom font
+;
+comapi_userfont:
+               mov al,[UserFont]
+               and al,al
+               jz .done
+               mov al,[VGAFontSize]
+               mov P_ES,ds
+               mov P_BX,vgafontbuf
+
+.done:         ; CF=0 here
+               mov P_AL,al
+               ret
+               
+
+
                section .data
 
 %macro                 int21 2
@@ -777,6 +816,8 @@ int22_table:
                dw comapi_localboot     ; 0014 local boot
                dw comapi_features      ; 0015 feature flags
                dw comapi_runkernel     ; 0016 run kernel image
+               dw comapi_usingvga      ; 0017 report video mode change
+               dw comapi_userfont      ; 0018 query custom font
 int22_count    equ ($-int22_table)/2
 
 APIKeyWait     db 0
index dae4097..8fd9d9d 100644 (file)
--- a/conio.inc
+++ b/conio.inc
@@ -73,7 +73,9 @@ print_msg_file:
                je msg_done_pop
                push si
                mov cl,[UsingVGA]
-               inc cl                          ; 01h = text mode, 02h = graphics
+               and cl,01h
+               inc cx                          ; CL <- 01h = text mode,
+                                               ;       02h = graphics mode
                 call [NextCharJump]            ; Do what shall be done
                pop si
                pop edx
index 123c4f6..7ddc278 100644 (file)
@@ -1314,25 +1314,6 @@ unmangle_name:   call strcpy
                ret
 
 ;
-; writechr:    Write a single character in AL to the console without
-;              mangling any registers; handle video pages correctly.
-;
-writechr:
-               call write_serial       ; write to serial port if needed
-               pushfd
-               test byte [cs:DisplayCon],01h
-               jz .nothing
-               pushad
-               mov ah,0Eh
-               mov bl,07h              ; attribute
-               mov bh,[cs:BIOS_page]   ; current page
-               int 10h
-               popad
-.nothing:
-               popfd
-               ret
-
-;
 ;
 ; kaboom2: once everything is loaded, replace the part of kaboom
 ;         starting with "kaboom.patch" with this part
@@ -1533,6 +1514,7 @@ getfssec:
 
 %include "getc.inc"            ; getc et al
 %include "conio.inc"           ; Console I/O
+%include "plaincon.inc"                ; writechr
 %include "writestr.inc"                ; String output
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
index 820459a..04080ba 100644 (file)
--- a/font.inc
+++ b/font.inc
@@ -1,6 +1,6 @@
 ;; -----------------------------------------------------------------------
 ;;
-;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2006 H. Peter Anvin - All Rights Reserved
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
@@ -60,6 +60,11 @@ loadfont:
 ;       Must be called with CS = DS = ES
 ;
 use_font:
+               test byte [UsingVGA], ~03h      ; Nonstandard mode?
+               jz .modeok
+               call vgaclearmode
+
+.modeok:
                test [UserFont], byte 1         ; Are we using a user-specified font?
                jz adjust_screen                ; If not, just do the normal stuff
 
@@ -67,20 +72,24 @@ use_font:
                mov bh,[VGAFontSize]
 
                xor bl,bl                       ; Needed by both INT 10h calls
-               cmp [UsingVGA], byte 1          ; Are we in graphics mode?
-               jne .text
 
+               test byte [UsingVGA], 01h       ; Are we in graphics mode?
+               jz .text
+               
 .graphics:
                xor cx,cx
                mov cl,bh                       ; CX = bytes/character
-               mov ax,480
+               mov ax,[GXPixRows]
                div cl                          ; Compute char rows per screen
                mov dl,al
-               dec al
+               dec ax
                mov [VidRows],al
                mov ax,1121h                    ; Set user character table
                int 10h
-               mov [VidCols], byte 79          ; Always 80 bytes/line
+               mov ax,[GXPixCols]
+               shr ax,3                        ; 8 pixels/character
+               dec ax
+               mov [VidCols],al
 .lf_ret:       ret                             ; No need to call adjust_screen
 
 .text:
@@ -126,3 +135,8 @@ vgafontbuf  resb 8192
                align 2, db 0
 VGAFontSize    dw 16                   ; Defaults to 16 byte font
 UserFont       db 0                    ; Using a user-specified font
+
+               section .bss
+               alignb 4
+GXPixCols      resw 1                  ; Graphics mode pixel columns
+GXPixRows      resw 1                  ; Graphics mode pixel rows
index 3910146..cfdcf6e 100644 (file)
@@ -238,6 +238,19 @@ packedpixel2vga:
 vgasetmode:
                push ds
                pop es
+               mov al,[UsingVGA]
+               cmp al,01h
+               je .success             ; Nothing to do...
+               test al,04h
+               jz .notvesa
+               ; We're in a VESA mode, which means VGA; use VESA call
+               ; to revert the mode, and then call the conventional
+               ; mode-setting for good measure...
+               mov ax,4F02h
+               mov bx,0012h
+               int 10h
+               jmp .setmode
+.notvesa:
                mov ax,1A00h            ; Get video card and monitor
                xor bx,bx
                int 10h
@@ -247,6 +260,7 @@ vgasetmode:
 ;              mov bx,TextColorReg
 ;              mov dx,1009h            ; Read color registers
 ;              int 10h
+.setmode:
                mov ax,0012h            ; Set mode = 640x480 VGA 16 colors
                int 10h
                mov dx,linear_color
@@ -254,9 +268,13 @@ vgasetmode:
                int 10h
                mov [UsingVGA], byte 1
 
+               ; Set GXPixCols and GXPixRows
+               mov dword [GXPixCols],640+(480 << 16)
+
                call use_font           ; Set graphics font/data
                mov byte [ScrollAttribute], 00h
 
+.success:
                xor ax,ax               ; Set ZF
 .error:
                ret
@@ -273,8 +291,15 @@ vgaclearmode:
                mov ax,cs
                mov ds,ax
                mov es,ax
-               cmp [UsingVGA], byte 1
-               jne .done
+               mov al,[UsingVGA]
+               and al,al               ; Already in text mode?
+               jz .done
+               test al,04h
+               jz .notvesa
+               mov ax,4F02h            ; VESA return to normal video mode
+               mov bx,0003h
+               int 10h
+.notvesa:
                mov ax,0003h            ; Return to normal video mode
                int 10h
 ;              mov dx,TextColorReg     ; Restore color registers
@@ -316,6 +341,9 @@ vgacursorcommon:
                section .data
                ; Map colors to consecutive DAC registers
 linear_color   db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0
+
+               ; See comboot.doc, INT 22h AX=0017h for the semantics
+               ; of this byte.
 UsingVGA       db 0
 
                section .latebss
index 2736b32..d688a6e 100644 (file)
@@ -26,7 +26,7 @@ TEXT_START    equ 7C00h
 ; The secondary BSS section, above the text; we really wish we could
 ; just make it follow .bcopy32 or hang off the end,
 ; but it doesn't seem to work that way.
-LATEBSS_START  equ 0B000h
+LATEBSS_START  equ 0B400h
 
 ; Reserve memory for the stack.  This causes checkov to abort the
 ; compile if we violate this space.
index c79088a..b5a9ebf 100644 (file)
@@ -1043,25 +1043,6 @@ searchdir:
                ret
 
 ;
-; writechr:    Write a single character in AL to the console without
-;              mangling any registers; handle video pages correctly.
-;
-writechr:
-               call write_serial       ; write to serial port if needed
-               pushfd
-               test byte [cs:DisplayCon], 01h
-               jz .nothing
-               pushad
-               mov ah,0Eh
-               mov bl,07h              ; attribute
-               mov bh,[cs:BIOS_page]   ; current page
-               int 10h
-               popad
-.nothing:
-               popfd
-               ret
-
-;
 ;
 ; kaboom2: once everything is loaded, replace the part of kaboom
 ;         starting with "kaboom.patch" with this part
@@ -1425,6 +1406,7 @@ getfatsector:
 
 %include "getc.inc"            ; getc et al
 %include "conio.inc"           ; Console I/O
+%include "plaincon.inc"                ; writechr
 %include "writestr.inc"                ; String output
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
diff --git a/plaincon.inc b/plaincon.inc
new file mode 100644 (file)
index 0000000..59b2cbb
--- /dev/null
@@ -0,0 +1,24 @@
+;
+; writechr:    Write a single character in AL to the console without
+;              mangling any registers; handle video pages correctly.
+;
+               section .text
+
+writechr:
+               call write_serial       ; write to serial port if needed
+               pushfd
+               test byte [cs:UsingVGA], 08h
+               jz .videook
+               call vgaclearmode
+.videook:
+               test byte [cs:DisplayCon], 01h
+               jz .nothing
+               pushad
+               mov ah,0Eh
+               mov bl,07h              ; attribute
+               mov bh,[cs:BIOS_page]   ; current page
+               int 10h
+               popad
+.nothing:
+               popfd
+               ret
index 34bb60b..10d7a76 100644 (file)
@@ -11,6 +11,10 @@ writechr:
                push ds
                push cs
                pop ds
+               test byte [UsingVGA], 08h
+               jz .videook
+               call vgaclearmode
+.videook:
                call write_serial       ; write to serial port if needed
                pushfd
                test byte [DisplayCon],01h      ; Write to screen?