From a7615704a4a4c76ef794c4758a60f6a539d603ce Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 18 Dec 2009 15:08:02 -0800 Subject: [PATCH] video: implement long-promised video functions; use them Implement long-since-promised video functions defined in . Use these functions in initvesa.c instead of open-coding the same functionality. Signed-off-by: H. Peter Anvin --- com32/include/syslinux/video.h | 2 +- com32/lib/Makefile | 5 +++- com32/lib/sys/vesa/initvesa.c | 19 +++++------- com32/lib/syslinux/video/fontquery.c | 54 +++++++++++++++++++++++++++++++++++ com32/lib/syslinux/video/forcetext.c | 42 +++++++++++++++++++++++++++ com32/lib/syslinux/video/reportmode.c | 45 +++++++++++++++++++++++++++++ 6 files changed, 153 insertions(+), 14 deletions(-) create mode 100644 com32/lib/syslinux/video/fontquery.c create mode 100644 com32/lib/syslinux/video/forcetext.c create mode 100644 com32/lib/syslinux/video/reportmode.c diff --git a/com32/include/syslinux/video.h b/com32/include/syslinux/video.h index 737c742..93df2a0 100644 --- a/com32/include/syslinux/video.h +++ b/com32/include/syslinux/video.h @@ -38,6 +38,6 @@ void syslinux_force_text_mode(void); int syslinux_report_video_mode(uint16_t flags, uint16_t xsize, uint16_t ysize); -int syslinux_font_query(void **font); +int syslinux_font_query(uint8_t **font); #endif /* _SYSLINUX_API_H */ diff --git a/com32/lib/Makefile b/com32/lib/Makefile index ad77bcd..ff5887b 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -110,7 +110,10 @@ LIBOBJS = \ syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \ \ syslinux/adv.o syslinux/advwrite.o syslinux/getadv.o \ - syslinux/setadv.o + syslinux/setadv.o \ + \ + syslinux/video/fontquery.o syslinux/video/forcetext.o \ + syslinux/video/reportmode.o BINDIR = /usr/bin LIBDIR = /usr/lib diff --git a/com32/lib/sys/vesa/initvesa.c b/com32/lib/sys/vesa/initvesa.c index 0221fcf..f1224a1 100644 --- a/com32/lib/sys/vesa/initvesa.c +++ b/com32/lib/sys/vesa/initvesa.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "vesa.h" #include "video.h" #include "fill.h" @@ -240,12 +241,10 @@ static int vesacon_set_mode(int x, int y) __vesacon_format_pixels = __vesacon_format_pixels_list[bestpxf]; /* Download the SYSLINUX- or BIOS-provided font */ - rm.eax.w[0] = 0x0018; /* Query custom font */ - __intcall(0x22, &rm, &rm); - if (!(rm.eflags.l & EFLAGS_CF) && rm.eax.b[0]) { - __vesacon_font_height = rm.eax.b[0]; - rom_font = MK_PTR(rm.es, rm.ebx.w[0]); - } else { + __vesacon_font_height = syslinux_font_query(&rom_font); + if (!__vesacon_font_height) { + /* Get BIOS 8x16 font */ + rm.eax.w[0] = 0x1130; /* Get Font Information */ rm.ebx.w[0] = 0x0600; /* Get 8x16 ROM font */ __intcall(0x10, &rm, &rm); @@ -270,17 +269,13 @@ static int vesacon_set_mode(int x, int y) __vesacon_init_copy_to_screen(); /* Tell syslinux we changed video mode */ - rm.eax.w[0] = 0x0017; /* Report video mode change */ /* In theory this should be: - rm.ebx.w[0] = (mi->mode_attr & 4) ? 0x0007 : 0x000f; + flags = (mi->mode_attr & 4) ? 0x0007 : 0x000f; However, that would assume all systems that claim to handle text output in VESA modes actually do that... */ - rm.ebx.w[0] = 0x000f; - rm.ecx.w[0] = mi->h_res; - rm.edx.w[0] = mi->v_res; - __intcall(0x22, &rm, NULL); + syslinux_report_video_mode(0x000f, mi->h_res, mi->v_res); __vesacon_pixel_format = bestpxf; diff --git a/com32/lib/syslinux/video/fontquery.c b/com32/lib/syslinux/video/fontquery.c new file mode 100644 index 0000000..dd5d86e --- /dev/null +++ b/com32/lib/syslinux/video/fontquery.c @@ -0,0 +1,54 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * syslinux/video/forcetext.c + */ + +#include +#include + +/* + * Returns height of font or zero if no custom font loaded + */ +int syslinux_font_query(uint8_t **font) +{ + static com32sys_t ireg; + com32sys_t oreg; + int height; + + ireg.eax.w[0] = 0x0018; + __intcall(0x22, &ireg, &oreg); + + height = !(oreg.eflags.l & EFLAGS_CF) ? oreg.eax.b[0] : 0; + if (height) + *font = MK_PTR(oreg.es, oreg.ebx.w[0]); + + return height; +} + diff --git a/com32/lib/syslinux/video/forcetext.c b/com32/lib/syslinux/video/forcetext.c new file mode 100644 index 0000000..136cb27 --- /dev/null +++ b/com32/lib/syslinux/video/forcetext.c @@ -0,0 +1,42 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * syslinux/video/forcetext.c + */ + +#include +#include + +void syslinux_force_text_mode(void) +{ + static com32sys_t ireg; + + ireg.eax.w[0] = 0x0005; + __intcall(0x22, &ireg, NULL); +} diff --git a/com32/lib/syslinux/video/reportmode.c b/com32/lib/syslinux/video/reportmode.c new file mode 100644 index 0000000..6e100f1 --- /dev/null +++ b/com32/lib/syslinux/video/reportmode.c @@ -0,0 +1,45 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * syslinux/video/reportmode.c + */ + +#include +#include + +int syslinux_report_video_mode(uint16_t flags, uint16_t xsize, uint16_t ysize) +{ + static com32sys_t ireg; + + ireg.eax.w[0] = 0x0017; + ireg.ebx.w[0] = flags; + ireg.ecx.w[0] = xsize; + ireg.edx.w[0] = ysize; + __intcall(0x22, &ireg, NULL); +} -- 2.7.4