ia64/xen-unstable
changeset 942:220bd9f57bc2
bitkeeper revision 1.599 (3fb3783bCzU2OI0iS1r2i_GVLKRG0Q)
Fixes. Xen console buffer ring can be cleared at request.
Fixes. Xen console buffer ring can be cleared at request.
author | laudney@eclipse.(none) |
---|---|
date | Thu Nov 13 12:25:31 2003 +0000 (2003-11-13) |
parents | 151801bd4e5e |
children | 7ae6b4359a0d |
files | tools/internal/xi_read_console_ring.c xen/common/console.c xen/common/dom0_ops.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/xeno/console.h |
line diff
1.1 --- a/tools/internal/xi_read_console_ring.c Thu Nov 13 01:46:28 2003 +0000 1.2 +++ b/tools/internal/xi_read_console_ring.c Thu Nov 13 12:25:31 2003 +0000 1.3 @@ -4,10 +4,12 @@ 1.4 1.5 #include "dom0_defs.h" 1.6 1.7 -#define CONSOLE_RING_SIZE 16392 1.8 +#define CONSOLE_RING_SIZE 16392 1.9 +#define CONSOLE_RING_CLEAR 1 1.10 + 1.11 static char *argv0 = "read_console_ring"; 1.12 1.13 -static long read_console_ring(unsigned long str, unsigned count) 1.14 +static long read_console_ring(unsigned long str, unsigned count, unsigned int cmd) 1.15 { 1.16 int ret; 1.17 dom0_op_t op; 1.18 @@ -15,6 +17,7 @@ static long read_console_ring(unsigned l 1.19 op.cmd = DOM0_READCONSOLE; 1.20 op.u.readconsole.str = str; 1.21 op.u.readconsole.count = count; 1.22 + op.u.readconsole.cmd = cmd; 1.23 1.24 ret = do_dom0_op(&op); 1.25 if (ret > 0) { 1.26 @@ -26,22 +29,32 @@ static long read_console_ring(unsigned l 1.27 1.28 int main(int argc, char **argv) 1.29 { 1.30 - char str[CONSOLE_RING_SIZE]; 1.31 - 1.32 + char str[CONSOLE_RING_SIZE+1]; 1.33 + unsigned int cmd = 0; 1.34 + 1.35 if ( argv[0] != NULL ) 1.36 argv0 = argv[0]; 1.37 1.38 - if ( argc > 2) { 1.39 - fprintf(stderr, "Usage: %s [-r]\n", argv0); 1.40 + if ( argc > 2 || (argc == 2 && strcmp(argv[1], "-c")) ) { 1.41 + fprintf(stderr, "Usage: %s [-c]\n", argv0); 1.42 + return 1; 1.43 + } 1.44 + 1.45 + if ( argc == 2) { 1.46 + cmd |= CONSOLE_RING_CLEAR; 1.47 + } 1.48 + 1.49 + if ( mlock(str, CONSOLE_RING_SIZE+1) != 0) { 1.50 + PERROR("Could not lock memory for user space read console ring buffer"); 1.51 return 1; 1.52 } 1.53 1.54 - if ( read_console_ring((unsigned long)str, CONSOLE_RING_SIZE) < 0 ) { 1.55 + if ( read_console_ring((unsigned long)str, CONSOLE_RING_SIZE, cmd) < 0 ) { 1.56 printf("Read console ring error.\n"); 1.57 - printf("%s", str); 1.58 return 1; 1.59 } 1.60 1.61 printf("%s", str); 1.62 + 1.63 return 0; 1.64 }
2.1 --- a/xen/common/console.c Thu Nov 13 01:46:28 2003 +0000 2.2 +++ b/xen/common/console.c Thu Nov 13 12:25:31 2003 +0000 2.3 @@ -12,19 +12,18 @@ console_ring_t console_ring = { 2.4 .len = 0 2.5 }; 2.6 2.7 -void init_console_ring() 2.8 -{ 2.9 - console_ring.len = 0; 2.10 -} 2.11 - 2.12 -long read_console_ring(unsigned long str, unsigned int count) 2.13 +long read_console_ring(unsigned long str, unsigned int count, unsigned cmd) 2.14 { 2.15 unsigned int len; 2.16 2.17 - len = (console_ring.len < count)? console_ring.len : count; 2.18 + len = (console_ring.len < count) ? console_ring.len : count; 2.19 2.20 if ( copy_to_user((char *)str, console_ring.buf, len) ) 2.21 return -EFAULT; 2.22 2.23 + if ( cmd & CONSOLE_RING_CLEAR ) { 2.24 + console_ring.len = 0; 2.25 + } 2.26 + 2.27 return len; 2.28 }
3.1 --- a/xen/common/dom0_ops.c Thu Nov 13 01:46:28 2003 +0000 3.2 +++ b/xen/common/dom0_ops.c Thu Nov 13 12:25:31 2003 +0000 3.3 @@ -415,9 +415,10 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 3.4 3.5 case DOM0_READCONSOLE: 3.6 { 3.7 - extern long read_console_ring(unsigned long, unsigned int); 3.8 + extern long read_console_ring(unsigned long, unsigned int, unsigned int); 3.9 ret = read_console_ring(op.u.readconsole.str, 3.10 - op.u.readconsole.count); 3.11 + op.u.readconsole.count, 3.12 + op.u.readconsole.cmd); 3.13 } 3.14 break; 3.15
4.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h Thu Nov 13 01:46:28 2003 +0000 4.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h Thu Nov 13 12:25:31 2003 +0000 4.3 @@ -194,6 +194,7 @@ typedef struct dom0_readconsole_st 4.4 { 4.5 unsigned long str; 4.6 unsigned int count; 4.7 + unsigned int cmd; 4.8 } dom0_readconsole_t; 4.9 4.10 typedef struct dom0_op_st
5.1 --- a/xen/include/xeno/console.h Thu Nov 13 01:46:28 2003 +0000 5.2 +++ b/xen/include/xeno/console.h Thu Nov 13 12:25:31 2003 +0000 5.3 @@ -6,6 +6,9 @@ 5.4 * Copyright (c) 2003 James Scott, Intel Research Cambridge 5.5 */ 5.6 5.7 +#ifndef __CONSOLE_H__ 5.8 +#define __CONSOLE_H__ 5.9 + 5.10 /* 5.11 * Ownership of console --- currently hardwired to dom0. This is used to see 5.12 * who gets the PS/2 keyboard/mouse events 5.13 @@ -43,7 +46,8 @@ 5.14 5.15 extern int opt_console; 5.16 5.17 -#define CONSOLE_RING_SIZE 16392 5.18 +#define CONSOLE_RING_SIZE 16392 5.19 +#define CONSOLE_RING_CLEAR 1 5.20 5.21 typedef struct console_ring_st 5.22 { 5.23 @@ -53,5 +57,6 @@ typedef struct console_ring_st 5.24 5.25 extern console_ring_t console_ring; 5.26 5.27 -void init_console_ring(); 5.28 -long read_console_ring(unsigned long, unsigned int); 5.29 +long read_console_ring(unsigned long, unsigned int, unsigned int); 5.30 + 5.31 +#endif