]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[console] Pass escape sequence context to ANSI escape sequence handlers
authorMichael Brown <mcb30@ipxe.org>
Mon, 25 Nov 2013 14:01:40 +0000 (14:01 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 27 Nov 2013 11:27:50 +0000 (11:27 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/firmware/pcbios/bios_console.c
src/core/ansiesc.c
src/include/ipxe/ansiesc.h
src/interface/efi/efi_console.c
src/net/tcp/syslogs.c
src/net/udp/syslog.c

index 79e437088f39bb696af0e14bc3ed13b84c07bd71..035831c87bff0356ff847bdf73c34349b1557cf9 100644 (file)
@@ -62,11 +62,13 @@ static unsigned int bios_attr = ATTR_DEFAULT;
 /**
  * Handle ANSI CUP (cursor position)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params[0]                Row (1 is top)
  * @v params[1]                Column (1 is left)
  */
-static void bios_handle_cup ( unsigned int count __unused, int params[] ) {
+static void bios_handle_cup ( struct ansiesc_context *ctx __unused,
+                             unsigned int count __unused, int params[] ) {
        int cx = ( params[1] - 1 );
        int cy = ( params[0] - 1 );
 
@@ -85,10 +87,12 @@ static void bios_handle_cup ( unsigned int count __unused, int params[] ) {
 /**
  * Handle ANSI ED (erase in page)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params[0]                Region to erase
  */
-static void bios_handle_ed ( unsigned int count __unused,
+static void bios_handle_ed ( struct ansiesc_context *ctx __unused,
+                            unsigned int count __unused,
                             int params[] __unused ) {
        /* We assume that we always clear the whole screen */
        assert ( params[0] == ANSIESC_ED_ALL );
@@ -103,10 +107,12 @@ static void bios_handle_ed ( unsigned int count __unused,
 /**
  * Handle ANSI SGR (set graphics rendition)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params           List of graphic rendition aspects
  */
-static void bios_handle_sgr ( unsigned int count, int params[] ) {
+static void bios_handle_sgr ( struct ansiesc_context *ctx __unused,
+                             unsigned int count, int params[] ) {
        static const uint8_t bios_attr_fcols[10] = {
                ATTR_FCOL_BLACK, ATTR_FCOL_RED, ATTR_FCOL_GREEN,
                ATTR_FCOL_YELLOW, ATTR_FCOL_BLUE, ATTR_FCOL_MAGENTA,
index 32e9d7c9f87743a3b9141a1d20046cbc1666371b..68e7061b323479d951f0e4defd3cefa789f39b89 100644 (file)
@@ -32,19 +32,20 @@ FILE_LICENCE ( GPL2_OR_LATER );
 /**
  * Call ANSI escape sequence handler
  *
- * @v handlers         List of escape sequence handlers
+ * @v ctx              ANSI escape sequence context
  * @v function         Control function identifier
  * @v count            Parameter count
  * @v params           Parameter list
  */
-static void ansiesc_call_handler ( struct ansiesc_handler *handlers,
+static void ansiesc_call_handler ( struct ansiesc_context *ctx,
                                   unsigned int function, int count,
                                   int params[] ) {
+       struct ansiesc_handler *handlers = ctx->handlers;
        struct ansiesc_handler *handler;
 
        for ( handler = handlers ; handler->function ; handler++ ) {
                if ( handler->function == function ) {
-                       handler->handle ( count, params );
+                       handler->handle ( ctx, count, params );
                        break;
                }
        }
@@ -67,6 +68,7 @@ static void ansiesc_call_handler ( struct ansiesc_handler *handlers,
  * sequences we are prepared to accept as valid.
  */
 int ansiesc_process ( struct ansiesc_context *ctx, int c ) {
+
        if ( ctx->count == 0 ) {
                if ( c == ESC ) {
                        /* First byte of CSI : begin escape sequence */
@@ -109,7 +111,7 @@ int ansiesc_process ( struct ansiesc_context *ctx, int c ) {
                        ctx->count = 0;
                        ctx->function <<= 8;
                        ctx->function |= c;
-                       ansiesc_call_handler ( ctx->handlers, ctx->function,
+                       ansiesc_call_handler ( ctx, ctx->function,
                                               count, ctx->params );
                }
                return -1;
index c00af258a8aa69cc5bf768de1277357927846a9f..1a5a9a1b7456ff5889bd0570ee74eed3e85f65cc 100644 (file)
@@ -28,6 +28,8 @@
 
 FILE_LICENCE ( GPL2_OR_LATER );
 
+struct ansiesc_context;
+
 /** A handler for an escape sequence */
 struct ansiesc_handler {
        /** The control function identifier
@@ -42,6 +44,7 @@ struct ansiesc_handler {
        unsigned int function;
        /** Handle escape sequence
         *
+        * @v ctx               ANSI escape context
         * @v count             Parameter count
         * @v params            Parameter list
         *
@@ -54,7 +57,8 @@ struct ansiesc_handler {
         * omitted".  Consequently, the parameter list will always
         * contain at least one item.
         */
-       void ( * handle ) ( unsigned int count, int params[] );
+       void ( * handle ) ( struct ansiesc_context *ctx, unsigned int count,
+                           int params[] );
 };
 
 /** Maximum number of parameters within a single escape sequence */
index d86d30c91e2d05f77c1da03d904db95aae5c06cb..af60d4f916ee978912e6424acfc347cf5a9ad3bf 100644 (file)
@@ -64,11 +64,13 @@ static unsigned int efi_attr = ATTR_DEFAULT;
 /**
  * Handle ANSI CUP (cursor position)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params[0]                Row (1 is top)
  * @v params[1]                Column (1 is left)
  */
-static void efi_handle_cup ( unsigned int count __unused, int params[] ) {
+static void efi_handle_cup ( struct ansiesc_context *ctx __unused,
+                            unsigned int count __unused, int params[] ) {
        EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
        int cx = ( params[1] - 1 );
        int cy = ( params[0] - 1 );
@@ -84,11 +86,13 @@ static void efi_handle_cup ( unsigned int count __unused, int params[] ) {
 /**
  * Handle ANSI ED (erase in page)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params[0]                Region to erase
  */
-static void efi_handle_ed ( unsigned int count __unused,
-                            int params[] __unused ) {
+static void efi_handle_ed ( struct ansiesc_context *ctx __unused,
+                           unsigned int count __unused,
+                           int params[] __unused ) {
        EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
 
        /* We assume that we always clear the whole screen */
@@ -100,10 +104,12 @@ static void efi_handle_ed ( unsigned int count __unused,
 /**
  * Handle ANSI SGR (set graphics rendition)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params           List of graphic rendition aspects
  */
-static void efi_handle_sgr ( unsigned int count, int params[] ) {
+static void efi_handle_sgr ( struct ansiesc_context *ctx __unused,
+                            unsigned int count, int params[] ) {
        EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
        static const uint8_t efi_attr_fcols[10] = {
                ATTR_FCOL_BLACK, ATTR_FCOL_RED, ATTR_FCOL_GREEN,
index dae6ba18b6171f825d4710707afb8514990e64d0..a4dc29753bab68bb5586af4d4313bf1d403d5185 100644 (file)
@@ -113,10 +113,12 @@ static unsigned int syslogs_severity = SYSLOG_DEFAULT_SEVERITY;
 /**
  * Handle ANSI set encrypted syslog priority (private sequence)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params           List of graphic rendition aspects
  */
-static void syslogs_handle_priority ( unsigned int count __unused,
+static void syslogs_handle_priority ( struct ansiesc_context *ctx __unused,
+                                     unsigned int count __unused,
                                      int params[] ) {
        if ( params[0] >= 0 ) {
                syslogs_severity = params[0];
index 00101008bcffd6b2ad95cb49041dcfc0852e92ec..4bfba51e57e6755c77c2d4977b3597e05ee708fc 100644 (file)
@@ -111,10 +111,12 @@ static unsigned int syslog_severity = SYSLOG_DEFAULT_SEVERITY;
 /**
  * Handle ANSI set syslog priority (private sequence)
  *
+ * @v ctx              ANSI escape sequence context
  * @v count            Parameter count
  * @v params           List of graphic rendition aspects
  */
-static void syslog_handle_priority ( unsigned int count __unused,
+static void syslog_handle_priority ( struct ansiesc_context *ctx __unused,
+                                    unsigned int count __unused,
                                     int params[] ) {
        if ( params[0] >= 0 ) {
                syslog_severity = params[0];