[Xen-devel,11/11] xen/arm: vpl011: Modify handle_tty_read in xenconsole to redirect user data to vpl011 IN ring buffer

Message ID 1487676368-22356-12-git-send-email-bhupinder.thakur@linaro.org
State New
Headers show
Series
  • pl011 emulation support in Xen
Related show

Commit Message

Bhupinder Thakur Feb. 21, 2017, 11:26 a.m.
Modification in handle_tty_read to write the user data to the vpl011 IN ring buffer.

Finally this needs to be modified to allow user input for both PV and vpl011 consoles.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
 tools/console/daemon/io.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Comments

Konrad Rzeszutek Wilk March 3, 2017, 9:17 p.m. | #1
On Tue, Feb 21, 2017 at 04:56:08PM +0530, Bhupinder Thakur wrote:
> Modification in handle_tty_read to write the user data to the vpl011 IN ring buffer.
> 
> Finally this needs to be modified to allow user input for both PV and vpl011 consoles.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
>  tools/console/daemon/io.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 4e531e7..a59b4c0 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -877,6 +877,9 @@ static int ring_free_bytes(struct domain *dom)
>  	struct xencons_interface *intf = dom->interface;
>  	XENCONS_RING_IDX cons, prod, space;
>  
> +	if ( dom->vpl011_initialized )
> +		intf = dom->vpl011_interface;
> +
>  	cons = intf->in_cons;
>  	prod = intf->in_prod;
>  	xen_mb();
> @@ -904,8 +907,9 @@ static void handle_tty_read(struct domain *dom)
>  	ssize_t len = 0;
>  	char msg[80];
>  	int i;
> -	struct xencons_interface *intf = dom->interface;
> +	struct xencons_interface *intf=dom->interface;

Please don't.

>  	XENCONS_RING_IDX prod;
> +	xenevtchn_port_or_error_t port=dom->local_port;

Please add spaces.

>  
>  	if (dom->is_dead)
>  		return;
> @@ -918,6 +922,16 @@ static void handle_tty_read(struct domain *dom)
>  		len = sizeof(msg);
>  
>  	len = read(dom->master_fd, msg, len);
> +
> +	/* select the interface based on whether vpl011 console is 
> +	* enabled or not

Please remove this comment. It is quite obvious from the code what
it does.

> +	*/
> +	if ( dom->vpl011_initialized )
> +	{
> +		intf = dom->vpl011_interface;
> +		port = dom->vpl011_local_port;
> +	}
> +
>  	/*
>  	 * Note: on Solaris, len == 0 means the slave closed, and this
>  	 * is no problem, but Linux can't handle this usefully, so we
> @@ -927,13 +941,14 @@ static void handle_tty_read(struct domain *dom)
>  		domain_handle_broken_tty(dom, domain_is_valid(dom->domid));
>  	} else if (domain_is_valid(dom->domid)) {
>  		prod = intf->in_prod;
> +

<cough> Please remove this.


>  		for (i = 0; i < len; i++) {
>  			intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
>  				msg[i];
>  		}
>  		xen_wmb();
>  		intf->in_prod = prod;
> -		xenevtchn_notify(dom->xce_handle, dom->local_port);
> +		xenevtchn_notify(dom->xce_handle, port);
>  	} else {
>  		domain_close_tty(dom);
>  		shutdown_domain(dom);
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel

Patch hide | download patch | download mbox

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 4e531e7..a59b4c0 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -877,6 +877,9 @@  static int ring_free_bytes(struct domain *dom)
 	struct xencons_interface *intf = dom->interface;
 	XENCONS_RING_IDX cons, prod, space;
 
+	if ( dom->vpl011_initialized )
+		intf = dom->vpl011_interface;
+
 	cons = intf->in_cons;
 	prod = intf->in_prod;
 	xen_mb();
@@ -904,8 +907,9 @@  static void handle_tty_read(struct domain *dom)
 	ssize_t len = 0;
 	char msg[80];
 	int i;
-	struct xencons_interface *intf = dom->interface;
+	struct xencons_interface *intf=dom->interface;
 	XENCONS_RING_IDX prod;
+	xenevtchn_port_or_error_t port=dom->local_port;
 
 	if (dom->is_dead)
 		return;
@@ -918,6 +922,16 @@  static void handle_tty_read(struct domain *dom)
 		len = sizeof(msg);
 
 	len = read(dom->master_fd, msg, len);
+
+	/* select the interface based on whether vpl011 console is 
+	* enabled or not
+	*/
+	if ( dom->vpl011_initialized )
+	{
+		intf = dom->vpl011_interface;
+		port = dom->vpl011_local_port;
+	}
+
 	/*
 	 * Note: on Solaris, len == 0 means the slave closed, and this
 	 * is no problem, but Linux can't handle this usefully, so we
@@ -927,13 +941,14 @@  static void handle_tty_read(struct domain *dom)
 		domain_handle_broken_tty(dom, domain_is_valid(dom->domid));
 	} else if (domain_is_valid(dom->domid)) {
 		prod = intf->in_prod;
+
 		for (i = 0; i < len; i++) {
 			intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
 				msg[i];
 		}
 		xen_wmb();
 		intf->in_prod = prod;
-		xenevtchn_notify(dom->xce_handle, dom->local_port);
+		xenevtchn_notify(dom->xce_handle, port);
 	} else {
 		domain_close_tty(dom);
 		shutdown_domain(dom);