summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/arch/i386/firmware/pcbios/bios_console.c12
-rw-r--r--src/core/ansiesc.c10
-rw-r--r--src/include/ipxe/ansiesc.h6
-rw-r--r--src/interface/efi/efi_console.c14
-rw-r--r--src/net/tcp/syslogs.c4
-rw-r--r--src/net/udp/syslog.c4
6 files changed, 36 insertions, 14 deletions
diff --git a/src/arch/i386/firmware/pcbios/bios_console.c b/src/arch/i386/firmware/pcbios/bios_console.c
index 79e437088..035831c87 100644
--- a/src/arch/i386/firmware/pcbios/bios_console.c
+++ b/src/arch/i386/firmware/pcbios/bios_console.c
@@ -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,
diff --git a/src/core/ansiesc.c b/src/core/ansiesc.c
index 32e9d7c9f..68e7061b3 100644
--- a/src/core/ansiesc.c
+++ b/src/core/ansiesc.c
@@ -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;
diff --git a/src/include/ipxe/ansiesc.h b/src/include/ipxe/ansiesc.h
index c00af258a..1a5a9a1b7 100644
--- a/src/include/ipxe/ansiesc.h
+++ b/src/include/ipxe/ansiesc.h
@@ -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 */
diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c
index d86d30c91..af60d4f91 100644
--- a/src/interface/efi/efi_console.c
+++ b/src/interface/efi/efi_console.c
@@ -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,
diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c
index dae6ba18b..a4dc29753 100644
--- a/src/net/tcp/syslogs.c
+++ b/src/net/tcp/syslogs.c
@@ -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];
diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c
index 00101008b..4bfba51e5 100644
--- a/src/net/udp/syslog.c
+++ b/src/net/udp/syslog.c
@@ -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];