as to what the graphics mode is set to.
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.
;; -----------------------------------------------------------------------
;;
-;; 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
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
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
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
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
%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
;; -----------------------------------------------------------------------
;;
-;; 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
; 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
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:
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
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
; 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
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
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
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
; 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.
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
%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
--- /dev/null
+;
+; 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
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?