From: H. Peter Anvin Date: Mon, 14 Jul 2008 19:44:21 +0000 (-0700) Subject: keymap, font: use readc, so we can handle indeterminate file sizes X-Git-Tag: syslinux-3.71-pre10^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2bc8563baff2b7364f3aa49803319c5b5f77348;p=platform%2Fupstream%2Fsyslinux.git keymap, font: use readc, so we can handle indeterminate file sizes The keymap and font commands still assumed that we knew the file size, which is no longer true. Fix that by instead using "readc" and checking the CF. --- diff --git a/core/conio.inc b/core/conio.inc index 6513f31..aa3fd0e 100644 --- a/core/conio.inc +++ b/core/conio.inc @@ -20,24 +20,30 @@ ;; ; -; loadkeys: Load a LILO-style keymap; SI and EAX set by searchdir +; loadkeys: Load a LILO-style keymap; file is open on the top of the +; getc stack. ; section .text loadkeys: - cmp eax,256 ; Should be 256 bytes exactly - jne loadkeys_ret - - mov bx,trackbuf - mov cx,1 ; 1 cluster should be >= 256 bytes - call getfssec + mov cx,256 + mov di,trackbuf + call readc + jc .done ; EOF already? + ; Make sure we are at EOF now... + call getc + jnc .done ; We should be at EOF now! + + ; It was okay, we can now move it into the KbdMap mov si,trackbuf mov di,KbdMap mov cx,256 >> 2 rep movsd -loadkeys_ret: ret +.done: + call close + ret ; ; get_msg_file: Load a text file and write its contents to the screen, diff --git a/core/font.inc b/core/font.inc index be9a365..a553f04 100644 --- a/core/font.inc +++ b/core/font.inc @@ -20,41 +20,49 @@ ; ; loadfont: Load a .psf font file and install it onto the VGA console -; (if we're not on a VGA screen then ignore.) It is called with -; SI and EAX set by routine searchdir +; (if we're not on a VGA screen then ignore.) +; The font is on top of the getc stack. ; +loadfont.err: jmp close ; Tailcall the close routine + loadfont: - ; XXX: This can be 8K+4 bytes and the trackbuf is only - ; guaranteed to be 8K in size... - mov bx,trackbuf - mov cx,[BufSafe] - call getfssec + mov di,trackbuf + mov cx,4 + call readc ; Read header + jc .err mov ax,[trackbuf] ; Magic number cmp ax,0436h - jne lf_ret + jne .err mov al,[trackbuf+2] ; File mode cmp al,5 ; Font modes 0-5 supported - ja lf_ret + ja .err - mov bh,byte [trackbuf+3] ; Height of font + xor bx,bx + mov bh,[trackbuf+3] ; Height of font cmp bh,2 ; VGA minimum - jb lf_ret + jb .err cmp bh,32 ; VGA maximum - ja lf_ret + ja .err + + ; Load the actual font + mov di,trackbuf + mov cx,bx ; Bytes = font height * 256 + call readc + jc .err + + call close ; Copy to font buffer - mov si,trackbuf+4 ; Start of font data + mov si,trackbuf ; Start of font data mov [VGAFontSize],bh mov di,vgafontbuf - mov cx,(32*256) >> 2 ; Maximum size - rep movsd + mov cx,bx + rep movsb mov [UserFont], byte 1 ; Set font flag - ; Fall through to use_font - ; ; use_font: ; This routine activates whatever font happens to be in the @@ -92,7 +100,7 @@ use_font: shr ax,3 ; 8 pixels/character dec ax mov [VidCols],al -.lf_ret: ret ; No need to call adjust_screen + ret ; No need to call adjust_screen .text: mov cx,256 @@ -104,8 +112,6 @@ use_font: mov ax,1103h ; Select page 0 int 10h -lf_ret equ use_font.lf_ret - ; ; adjust_screen: Set the internal variables associated with the screen size. ; This is a subroutine in case we're loading a custom font. diff --git a/core/keywords.inc b/core/keywords.inc index 65b657c..973d15b 100644 --- a/core/keywords.inc +++ b/core/keywords.inc @@ -52,9 +52,9 @@ keywd_table: keyword initrd, pc_filename, InitRD keyword default, pc_default keyword display, pc_opencmd, get_msg_file - keyword font, pc_filecmd, loadfont + keyword font, pc_opencmd, loadfont keyword implicit, pc_setint16, AllowImplicit - keyword kbdmap, pc_filecmd, loadkeys + keyword kbdmap, pc_opencmd, loadkeys keyword kernel, pc_kernel, VK_KERNEL keyword linux, pc_kernel, VK_LINUX keyword boot, pc_kernel, VK_BOOT