From 6566690ba105427912e2f1ad1f6e4cbc7422bd5c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 6 Aug 2014 15:10:58 +0100 Subject: [PATCH] [bios] Support displaying and hiding cursor Signed-off-by: Michael Brown --- src/arch/i386/firmware/pcbios/bios_console.c | 43 ++++++++++++++++++++ src/arch/i386/include/bios.h | 1 + 2 files changed, 44 insertions(+) diff --git a/src/arch/i386/firmware/pcbios/bios_console.c b/src/arch/i386/firmware/pcbios/bios_console.c index b2b7bf2d..bd73838b 100644 --- a/src/arch/i386/firmware/pcbios/bios_console.c +++ b/src/arch/i386/firmware/pcbios/bios_console.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include #include #include @@ -148,11 +149,53 @@ static void bios_handle_sgr ( struct ansiesc_context *ctx __unused, } } +/** + * Handle ANSI DECTCEM set (show cursor) + * + * @v ctx ANSI escape sequence context + * @v count Parameter count + * @v params List of graphic rendition aspects + */ +static void bios_handle_dectcem_set ( struct ansiesc_context *ctx __unused, + unsigned int count __unused, + int params[] __unused ) { + uint8_t height; + + /* Get character height */ + get_real ( height, BDA_SEG, BDA_CHAR_HEIGHT ); + + __asm__ __volatile__ ( REAL_CODE ( "sti\n\t" + "int $0x10\n\t" + "cli\n\t" ) + : : "a" ( 0x0100 ), + "c" ( ( ( height - 2 ) << 8 ) | + ( height - 1 ) ) ); +} + +/** + * Handle ANSI DECTCEM reset (hide cursor) + * + * @v ctx ANSI escape sequence context + * @v count Parameter count + * @v params List of graphic rendition aspects + */ +static void bios_handle_dectcem_reset ( struct ansiesc_context *ctx __unused, + unsigned int count __unused, + int params[] __unused ) { + + __asm__ __volatile__ ( REAL_CODE ( "sti\n\t" + "int $0x10\n\t" + "cli\n\t" ) + : : "a" ( 0x0100 ), "c" ( 0x2000 ) ); +} + /** BIOS console ANSI escape sequence handlers */ static struct ansiesc_handler bios_ansiesc_handlers[] = { { ANSIESC_CUP, bios_handle_cup }, { ANSIESC_ED, bios_handle_ed }, { ANSIESC_SGR, bios_handle_sgr }, + { ANSIESC_DECTCEM_SET, bios_handle_dectcem_set }, + { ANSIESC_DECTCEM_RESET, bios_handle_dectcem_reset }, { 0, NULL } }; diff --git a/src/arch/i386/include/bios.h b/src/arch/i386/include/bios.h index 3e6a845e..0754b116 100644 --- a/src/arch/i386/include/bios.h +++ b/src/arch/i386/include/bios.h @@ -9,5 +9,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define BDA_REBOOT 0x0072 #define BDA_REBOOT_WARM 0x1234 #define BDA_NUM_DRIVES 0x0075 +#define BDA_CHAR_HEIGHT 0x0085 #endif /* BIOS_H */