1 /*
2 * include/xen/vpl011.h
3 *
4 * Virtual PL011 UART
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef _VPL011_H_
20 #define _VPL011_H_
21
22 #include <public/domctl.h>
23 #include <public/io/ring.h>
24 #include <public/io/console.h>
25 #include <xen/mm.h>
26
27 /* helper macros */
28 #define VPL011_LOCK(d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, flags)
29 #define VPL011_UNLOCK(d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lock, flags)
30
31 #define SBSA_UART_FIFO_SIZE 32
32 /* Same size as VUART_BUF_SIZE, used in vuart.c */
33 #define SBSA_UART_OUT_BUF_SIZE 128
34 struct vpl011_xen_backend {
35 char in[SBSA_UART_FIFO_SIZE];
36 char out[SBSA_UART_OUT_BUF_SIZE];
37 XENCONS_RING_IDX in_cons, in_prod;
38 XENCONS_RING_IDX out_prod;
39 };
40
41 struct vpl011 {
42 bool backend_in_domain;
43 union {
44 struct {
45 void *ring_buf;
46 struct page_info *ring_page;
47 } dom;
48 struct vpl011_xen_backend *xen;
49 } backend;
50 uint32_t uartfr; /* Flag register */
51 uint32_t uartcr; /* Control register */
52 uint32_t uartimsc; /* Interrupt mask register*/
53 uint32_t uarticr; /* Interrupt clear register */
54 uint32_t uartris; /* Raw interrupt status register */
55 uint32_t shadow_uartmis; /* shadow masked interrupt register */
56 spinlock_t lock;
57 evtchn_port_t evtchn;
58 };
59
60 struct vpl011_init_info {
61 domid_t console_domid;
62 gfn_t gfn;
63 evtchn_port_t evtchn;
64 };
65
66 #ifdef CONFIG_SBSA_VUART_CONSOLE
67 int domain_vpl011_init(struct domain *d,
68 struct vpl011_init_info *info);
69 void domain_vpl011_deinit(struct domain *d);
70 void vpl011_rx_char_xen(struct domain *d, char c);
71 #else
domain_vpl011_init(struct domain * d,struct vpl011_init_info * info)72 static inline int domain_vpl011_init(struct domain *d,
73 struct vpl011_init_info *info)
74 {
75 return -ENOSYS;
76 }
77
domain_vpl011_deinit(struct domain * d)78 static inline void domain_vpl011_deinit(struct domain *d) { }
79 #endif
80 #endif /* _VPL011_H_ */
81
82 /*
83 * Local variables:
84 * mode: C
85 * c-file-style: "BSD"
86 * c-basic-offset: 4
87 * indent-tabs-mode: nil
88 * End:
89 */
90