From patchwork Wed May 10 14:24:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9719957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B22C60236 for ; Wed, 10 May 2017 14:29:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 296F728236 for ; Wed, 10 May 2017 14:29:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E5D9285FF; Wed, 10 May 2017 14:29:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF30E28236 for ; Wed, 10 May 2017 14:29:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SaK-0002da-6y; Wed, 10 May 2017 14:27:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SaI-0002cx-6C for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:27:22 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 55/B4-01992-94323195; Wed, 10 May 2017 14:27:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRuso+uhLBx pcGaqosX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHpXFLB0nbGiq9rN7E0MP5O72Lk4hASmMko seDqbSYQh0VgHrPE6UXvmUEcCYF+VolVra2sXYwcQE6cxIybjBBmpcSf1UVdjJxAzVoSR0/NZ oUY1MQkcX75fBaQGjYBE4lZHRIgNSICShL3Vk1mArGZBUIl/j1rYwexhQW8JGYef84MYrMIqE osaHsGZvMKeEvsvvGKBcSWEJCTuHmuEyzOKeAjMffsJmaIvd4SrWuvMk9gFFjAyLCKUaM4tag stUjXyFgvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwrOoZGBh3MO5o9zvEKMnB pCTKq7tLKFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO9/ReFIIcGi1PTUirTMHGCAw6QlOHiUR Hhfg6R5iwsSc4sz0yFSpxiNOa60fnzPxPFo5Y/3TEIsefl5qVLivJdBSgVASjNK8+AGwSLvEq OslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3kMgU3gy80rg9r0COoUJ6JRABgGQU0oSEVJSDYz B1t2XOU5aslXyvCrepxenO30Z96Mrpjbf5NY2XLYp9/y5Zc6iVdOecBX8+PPdM+a3gcuOiYc1 31vpBzE/eJb3Z+3piRM/Tlt0WM/P8KLisn8u9W6mAjZ+PxjT3ednCln+WF2tvMfFtiXo2s16z 5yCLEmpbVI3stJK//AtWSctVx53S7KyT1iJpTgj0VCLuag4EQDCptuYtwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-206.messagelabs.com!1494426438!76704588!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48705 invoked from network); 10 May 2017 14:27:19 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-2.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:27:19 -0000 Received: by mail-pg0-f44.google.com with SMTP id u187so17524123pgb.0 for ; Wed, 10 May 2017 07:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1IO6DEQu96gAePQhYkdc0S1f2dANsW4ynSxGOtqdkE0=; b=jGodQhhJI+Mf00nAN+aL7XWUh1o2Ou71uVywM3pZwO+igN0ZLfI5J0QFni2KPVg/NO wPGN3XBf4aELAmJ+OyY+Y912hh+ktLNfnQXm7gap/ggbmDsJmxLNwg57glLHP/lbsEud kT7Q7Cqb1mp3QyYnGeW/zUdn7DoVeUEvec52Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1IO6DEQu96gAePQhYkdc0S1f2dANsW4ynSxGOtqdkE0=; b=H3zMPYl/8neh9fFUlmeNLWgtCVB4LvQyo7lYIFJ7e0Z9V57i7hJTUfEJEAurMwtC8g tpt6JM8EtqM8RVLrJY/sRx9y/t6EU4m/CQsUL+wKvCV00ArqT4Vvo6qcLTXE8d5O+U+u U5kWQh7d7ww4R9N0zkurCoCfM4JPhxZOsi8TznKAf93/JdOzYbK1w7qoxZRQsboVmqa1 a6dB8Jtm7PGoBkJBqpaJ2wo9/2nH6DW1szVVsZJdmuBsBCEP+XOrquNVbvlmYaim0VmB aIwaCmMXp+nDxatrwysEH1vangtEIJMilBXhdrDzOOKX2/MDiN2Z5uY+pA1xyRvvRfnJ mJTA== X-Gm-Message-State: AODbwcCJwQqk6N6uhWdi4mM36vWqxK7hSOS6yKiSLi09HytXuOrRbICj JnkHF/UNQ+ZFkQVV X-Received: by 10.84.138.193 with SMTP id 59mr8666743plp.184.1494426437314; Wed, 10 May 2017 07:27:17 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([61.0.91.57]) by smtp.gmail.com with ESMTPSA id k79sm6432320pfj.6.2017.05.10.07.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:27:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 19:54:53 +0530 Message-Id: <1494426293-32481-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494426293-32481-1-git-send-email-bhupinder.thakur@linaro.org> References: <1494426293-32481-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 03/12 v3] xen/arm: vpl011: Add pl011 uart emulation in Xen X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add emulation code to emulate read/write access to pl011 registers and pl011 interrupts: - Emulate DR read/write by reading and writing from/to the IN and OUT ring buffers and raising an event to the backend when there is data in the OUT ring buffer and injecting an interrupt to the guest when there is data in the IN ring buffer - Other registers are related to interrupt management and essentially control when interrupts are delivered to the guest The SBSA compliant pl011 uart is covered in Appendix B of https://static.docs.arm.com/den0029/a/Server_Base_System_Architecture_v3_1_ARM_DEN_0029A.pdf Signed-off-by: Bhupinder Thakur --- Changes since v2: - Use generic vreg_reg* for read/write of registers emulating pl011. - Use generic ring buffer functions defined using DEFINE_XEN_FLEX_RING. - Renamed the SPI injection function to vpl011_update_spi() to reflect level triggered nature of pl011 interrupts. - The pl011 register access address should always be the base address of the corresponding register as per section B of the SBSA document. For this reason, the register range address access is not allowed. Changes since v1: - Removed the optimiztion related to sendiing events to xenconsole - Use local variables as ring buffer indices while using the ring buffer xen/arch/arm/Kconfig | 5 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 350 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 94 +++++++++++ xen/include/public/arch-arm.h | 8 + 7 files changed, 466 insertions(+) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index d46b98c..c1a0e7f 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -50,6 +50,11 @@ config HAS_ITS prompt "GICv3 ITS MSI controller support" if EXPERT = "y" depends on HAS_GICV3 +config VPL011_CONSOLE + bool "Emulated pl011 console support" + default y + ---help--- + Allows a guest to use pl011 UART as a console endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 49e1fb2..15efc13 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -52,6 +52,7 @@ obj-y += vm_event.o obj-y += vtimer.o obj-y += vpsci.o obj-y += vuart.o +obj-$(CONFIG_VPL011_CONSOLE) += vpl011.o #obj-bin-y += ....o diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c new file mode 100644 index 0000000..2f71148 --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,350 @@ +/* + * arch/arm/vpl011.c + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static bool vpl011_reg32_check_access(int size) +{ + return (size == DABT_DOUBLE_WORD)? false : true; +} + +static void vpl011_update_spi(struct domain *d) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + if ( vpl011->uartris & vpl011->uartimsc ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); +} + +static void vpl011_read_data(struct domain *d, uint8_t *data) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + + /* + * Initialize the data so that even if there is no data in ring buffer + * 0 is returned. + */ + *data = 0; + + VPL011_LOCK(d, flags); + + /* + * It is expected that there will be data in the ring buffer when this + * function is called since the guest is expected to read the data register + * only if the TXFE flag is not set. + * If the guest still does read when TXFE bit is set then 0 will be returned. + */ + if ( !VPL011_IN_RING_EMPTY(intf) ) + { + XENCONS_RING_IDX in_cons = intf->in_cons; + *data = intf->in[VPL011_RING_IDX_MASK(in_cons, intf->in)]; + smp_mb(); + intf->in_cons = in_cons + 1; + } + + if ( VPL011_IN_RING_EMPTY(intf) ) + { + vpl011->uartfr |= RXFE; + vpl011->uartris &= ~RXI; + } + vpl011->uartfr &= ~RXFF; + VPL011_UNLOCK(d, flags); + + notify_via_xen_event_channel(d, vpl011->evtchn); +} + +static void vpl011_write_data(struct domain *d, uint8_t data) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + + VPL011_LOCK(d, flags); + + /* + * It is expected that the ring is not full when this function is called + * as the guest is expected to write to the data register only when the + * TXFF flag is not set. + * In case the guest does write even when the TXFF flag is set then the + * data will be silently dropped. + */ + if ( !VPL011_OUT_RING_FULL(intf) ) + { + XENCONS_RING_IDX out_prod = intf->out_prod; + intf->out[VPL011_RING_IDX_MASK(out_prod, intf->out)] = data; + smp_wmb(); + intf->out_prod = out_prod + 1; + } + + if ( VPL011_OUT_RING_FULL(intf) ) + { + vpl011->uartfr |= TXFF; + vpl011->uartris &= ~TXI; + } + + vpl011->uartfr |= BUSY; + + vpl011->uartfr &= ~TXFE; + + VPL011_UNLOCK(d, flags); + + notify_via_xen_event_channel(d, vpl011->evtchn); +} + +static int vpl011_mmio_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv) +{ + uint8_t ch; + struct hsr_dabt dabt = info->dabt; + int vpl011_reg = (int)(info->gpa - GUEST_PL011_BASE); + struct vpl011_s *vpl011 = &v->domain->arch.vpl011; + + if ( !vpl011_reg32_check_access(dabt.size) ) goto bad_width; + + switch ( vpl011_reg ) + { + case DR: + vpl011_read_data(v->domain, &ch); + *r = ch; + break; + + case RSR: + /* It always returns 0 as there are no physical errors. */ + *r = 0; + break; + + case FR: + *r = vreg_reg32_extract(vpl011->uartfr, info); + break; + + case RIS: + *r = vreg_reg32_extract(vpl011->uartris, info); + break; + + case MIS: + *r = vreg_reg32_extract(vpl011->uartris + & vpl011->uartimsc, info); + break; + + case IMSC: + *r = vreg_reg32_extract(vpl011->uartimsc, info); + break; + + case ICR: + /* Only write is valid. */ + return 0; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled read r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad read width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static int vpl011_mmio_write(struct vcpu *v, mmio_info_t *info, register_t r, void *priv) +{ + uint8_t ch = ((struct uartdr_reg *)&r)->data; + struct hsr_dabt dabt = info->dabt; + int vpl011_reg = (int)(info->gpa - GUEST_PL011_BASE); + struct vpl011_s *vpl011 = &v->domain->arch.vpl011; + + if ( !vpl011_reg32_check_access(dabt.size) ) goto bad_width; + + switch ( vpl011_reg ) + { + case DR: + vpl011_write_data(v->domain, ch); + break; + + case RSR: /* Nothing to clear. */ + break; + + case FR: + case RIS: + case MIS: + goto write_ignore; + + case IMSC: + vreg_reg32_update(&vpl011->uartimsc, r, info); + vpl011_update_spi(v->domain); + break; + + case ICR: + vreg_reg32_clearbits(&vpl011->uartris, r, info); + vpl011_update_spi(v->domain); + break; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + +write_ignore: + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad write width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static const struct mmio_handler_ops vpl011_mmio_handler = { + .read = vpl011_mmio_read, + .write = vpl011_mmio_write, +}; + +int vpl011_map_guest_page(struct domain *d, xen_pfn_t gfn) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + /* Map the guest PFN to Xen address space. */ + return prepare_ring_for_helper(d, + gfn, + &vpl011->ring_page, + &vpl011->ring_buf); +} + +static void vpl011_data_avail(struct domain *d) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + RING_IDX in_ring_depth, out_ring_depth; + + VPL011_LOCK(d, flags); + + in_ring_depth = vpl011_queued(intf->in_prod, intf->in_cons, sizeof(intf->in)); + out_ring_depth = vpl011_queued(intf->out_prod, intf->out_cons, sizeof(intf->out)); + + /* Update the uart rx state if the buffer is not empty. */ + if ( in_ring_depth != 0 ) + { + vpl011->uartfr &= ~RXFE; + if ( in_ring_depth == VPL011_RING_MAX_DEPTH(intf, in) ) + vpl011->uartfr |= RXFF; + vpl011->uartris |= RXI; + } + + /* Update the uart tx state if the buffer is not full. */ + if ( out_ring_depth != VPL011_RING_MAX_DEPTH(intf, out) ) + { + vpl011->uartfr &= ~TXFF; + vpl011->uartris |= TXI; + if ( out_ring_depth == 0 ) + { + vpl011->uartfr &= ~BUSY; + vpl011->uartfr |= TXFE; + } + } + + VPL011_UNLOCK(d, flags); + + vpl011_update_spi(d); +} + + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) +{ + int rc; + struct vpl011_s *vpl011 = &d->arch.vpl011; + + rc = vpl011_map_guest_page(d, gfn); + if ( rc < 0 ) + goto out; + + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + { + rc = -EINVAL; + goto out1; + } + + register_mmio_handler(d, &vpl011_mmio_handler, + GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + spin_lock_init(&vpl011->lock); + + rc = alloc_unbound_xen_event_channel(d, 0, console_domid, + vpl011_notification); + if (rc < 0) + goto out2; + + vpl011->evtchn = *evtchn = rc; + + vpl011->initialized = true; + + return 0; + +out2: + xfree(d->arch.vmmio.handlers); +out1: + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); +out: + return rc; +} + +void domain_vpl011_deinit(struct domain *d) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + if ( vpl011->initialized ) + { + free_xen_event_channel(d, vpl011->evtchn); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + } + vpl011->initialized = false; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 6de8082..54611e0 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -11,6 +11,7 @@ #include #include #include +#include struct hvm_domain { @@ -133,6 +134,11 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_VPL011_CONSOLE + struct vpl011_s vpl011; +#endif + } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h index 123f477..57e9ec7 100644 --- a/xen/include/asm-arm/pl011-uart.h +++ b/xen/include/asm-arm/pl011-uart.h @@ -49,6 +49,8 @@ /* FR bits */ #define TXFE (1<<7) /* TX FIFO empty */ #define RXFE (1<<4) /* RX FIFO empty */ +#define TXFF (1<<5) /* TX FIFO full */ +#define RXFF (1<<6) /* RX FIFO full */ #define BUSY (1<<3) /* Transmit is not complete */ /* LCR_H bits */ diff --git a/xen/include/asm-arm/vpl011.h b/xen/include/asm-arm/vpl011.h new file mode 100644 index 0000000..df7e6b7 --- /dev/null +++ b/xen/include/asm-arm/vpl011.h @@ -0,0 +1,94 @@ +/* + * include/xen/vpl011.h + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#ifndef _VPL011_H_ + +#define _VPL011_H_ + +#include +#include + +DEFINE_XEN_FLEX_RING(vpl011); + +/* helper macros */ +#define VPL011_RING_IDX_MASK(idx, ring) (vpl011_mask(idx, sizeof(ring))) + +#define VPL011_RING_DEPTH(intf,dir) (vpl011_queued((intf)->dir ## _prod, \ + (intf)->dir ## _cons, \ + sizeof((intf)->dir))) + +#define VPL011_RING_MAX_DEPTH(intf,dir) (sizeof((intf)->dir)) + +#define VPL011_IN_RING_EMPTY(intf) (VPL011_RING_DEPTH(intf, in) == 0) + +#define VPL011_OUT_RING_EMPTY(intf) (VPL011_RING_DEPTH(intf, out) == 0) + +#define VPL011_IN_RING_FULL(intf) (VPL011_RING_DEPTH(intf, in) == VPL011_RING_MAX_DEPTH(intf, in)) + +#define VPL011_OUT_RING_FULL(intf) (VPL011_RING_DEPTH(intf, out) == VPL011_RING_MAX_DEPTH(intf,out)) + +#define VPL011_LOCK(d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, flags) +#define VPL011_UNLOCK(d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lock, flags) + +struct uartdr_reg { + uint8_t data; + uint8_t error_status:4; + uint8_t reserved1:4; + uint16_t reserved2; + uint32_t reserved3; +}; + +struct vpl011_s { + void *ring_buf; + struct page_info *ring_page; + uint32_t uartfr; /* Flag register */ + uint32_t uartcr; /* Control register */ + uint32_t uartimsc; /* Interrupt mask register*/ + uint32_t uarticr; /* Interrupt clear register */ + uint32_t uartris; /* Raw interrupt status register */ + uint32_t uartmis; /* Masked interrupt register */ + spinlock_t lock; + evtchn_port_t evtchn; + bool initialized; /* Flag which tells whether vpl011 is initialized */ +}; + +#ifdef CONFIG_VPL011_CONSOLE +int domain_vpl011_init(struct domain *d, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn); +void domain_vpl011_deinit(struct domain *d); +#else +int domain_vpl011_init(struct domain *d, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) { return -ENOSYS; } + +static inline void domain_vpl011_deinit(struct domain *d) { } +#endif + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..5f91207 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -322,6 +322,8 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + + uint32_t console_domid; }; #endif /* __XEN__ || __XEN_TOOLS__ */ @@ -410,6 +412,10 @@ typedef uint64_t xen_callback_t; #define GUEST_ACPI_BASE 0x20000000ULL #define GUEST_ACPI_SIZE 0x02000000ULL +/* PL011 mappings */ +#define GUEST_PL011_BASE 0x22000000ULL +#define GUEST_PL011_SIZE 0x00001000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. @@ -444,6 +450,8 @@ typedef uint64_t xen_callback_t; #define GUEST_TIMER_PHYS_NS_PPI 30 #define GUEST_EVTCHN_PPI 31 +#define GUEST_VPL011_SPI 32 + /* PSCI functions */ #define PSCI_cpu_suspend 0 #define PSCI_cpu_off 1