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 <asm/vreg.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 
33 struct vpl011 {
34     void *ring_buf;
35     struct page_info *ring_page;
36     uint32_t    uartfr;         /* Flag register */
37     uint32_t    uartcr;         /* Control register */
38     uint32_t    uartimsc;       /* Interrupt mask register*/
39     uint32_t    uarticr;        /* Interrupt clear register */
40     uint32_t    uartris;        /* Raw interrupt status register */
41     uint32_t    shadow_uartmis; /* shadow masked interrupt register */
42     spinlock_t  lock;
43     evtchn_port_t evtchn;
44 };
45 
46 struct vpl011_init_info {
47     domid_t console_domid;
48     gfn_t gfn;
49     evtchn_port_t evtchn;
50 };
51 
52 #ifdef CONFIG_SBSA_VUART_CONSOLE
53 int domain_vpl011_init(struct domain *d,
54                        struct vpl011_init_info *info);
55 void domain_vpl011_deinit(struct domain *d);
56 #else
domain_vpl011_init(struct domain * d,struct vpl011_init_info * info)57 static inline int domain_vpl011_init(struct domain *d,
58                                      struct vpl011_init_info *info)
59 {
60     return -ENOSYS;
61 }
62 
domain_vpl011_deinit(struct domain * d)63 static inline void domain_vpl011_deinit(struct domain *d) { }
64 #endif
65 #endif  /* _VPL011_H_ */
66 
67 /*
68  * Local variables:
69  * mode: C
70  * c-file-style: "BSD"
71  * c-basic-offset: 4
72  * indent-tabs-mode: nil
73  * End:
74  */
75