diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-07-14 12:44:21 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-07-14 12:50:24 -0700 |
commit | b2bc8563baff2b7364f3aa49803319c5b5f77348 (patch) | |
tree | e65ef1621b9f62e7c017c175f9f463dbdc092266 | |
parent | 37173ab394082a5102d04f78ca1b920a9f34b265 (diff) | |
download | syslinux-b2bc8563baff2b7364f3aa49803319c5b5f77348.tar.gz syslinux-b2bc8563baff2b7364f3aa49803319c5b5f77348.tar.xz syslinux-b2bc8563baff2b7364f3aa49803319c5b5f77348.zip |
keymap, font: use readc, so we can handle indeterminate file sizessyslinux-3.71-pre10
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.
-rw-r--r-- | core/conio.inc | 22 | ||||
-rw-r--r-- | core/font.inc | 46 | ||||
-rw-r--r-- | core/keywords.inc | 4 |
3 files changed, 42 insertions, 30 deletions
diff --git a/core/conio.inc b/core/conio.inc index 6513f316..aa3fd0ef 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 be9a365c..a553f042 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 65b657c1..973d15b6 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 |