1 /******************************************************************************
2  * asm-x86/guest/shim.h
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms and conditions of the GNU General Public
6  * License, version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this program; If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Copyright (c) 2017 Citrix Systems Ltd.
17  */
18 
19 #ifndef __X86_PV_SHIM_H__
20 #define __X86_PV_SHIM_H__
21 
22 #include <xen/types.h>
23 
24 #if defined(CONFIG_PV_SHIM_EXCLUSIVE)
25 # define pv_shim 1
26 #elif defined(CONFIG_PV_SHIM)
27 extern bool pv_shim;
28 #else
29 # define pv_shim 0
30 #endif /* CONFIG_PV_SHIM{,_EXCLUSIVE} */
31 
32 #ifdef CONFIG_PV_SHIM
33 
34 void pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start,
35                        unsigned long va_start, unsigned long store_va,
36                        unsigned long console_va, unsigned long vphysmap,
37                        start_info_t *si);
38 int pv_shim_shutdown(uint8_t reason);
39 void pv_shim_inject_evtchn(unsigned int port);
40 long pv_shim_cpu_up(void *data);
41 long pv_shim_cpu_down(void *data);
42 void pv_shim_online_memory(unsigned int nr, unsigned int order);
43 void pv_shim_offline_memory(unsigned int nr, unsigned int order);
44 domid_t get_initial_domain_id(void);
45 uint64_t pv_shim_mem(uint64_t avail);
46 
47 #else
48 
pv_shim_setup_dom(struct domain * d,l4_pgentry_t * l4start,unsigned long va_start,unsigned long store_va,unsigned long console_va,unsigned long vphysmap,start_info_t * si)49 static inline void pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start,
50                                      unsigned long va_start,
51                                      unsigned long store_va,
52                                      unsigned long console_va,
53                                      unsigned long vphysmap,
54                                      start_info_t *si)
55 {
56     ASSERT_UNREACHABLE();
57 }
pv_shim_shutdown(uint8_t reason)58 static inline int pv_shim_shutdown(uint8_t reason)
59 {
60     ASSERT_UNREACHABLE();
61     return 0;
62 }
pv_shim_inject_evtchn(unsigned int port)63 static inline void pv_shim_inject_evtchn(unsigned int port)
64 {
65     ASSERT_UNREACHABLE();
66 }
pv_shim_cpu_up(void * data)67 static inline long pv_shim_cpu_up(void *data)
68 {
69     ASSERT_UNREACHABLE();
70     return 0;
71 }
pv_shim_cpu_down(void * data)72 static inline long pv_shim_cpu_down(void *data)
73 {
74     ASSERT_UNREACHABLE();
75     return 0;
76 }
pv_shim_online_memory(unsigned int nr,unsigned int order)77 static inline void pv_shim_online_memory(unsigned int nr, unsigned int order)
78 {
79     ASSERT_UNREACHABLE();
80 }
pv_shim_offline_memory(unsigned int nr,unsigned int order)81 static inline void pv_shim_offline_memory(unsigned int nr, unsigned int order)
82 {
83     ASSERT_UNREACHABLE();
84 }
get_initial_domain_id(void)85 static inline domid_t get_initial_domain_id(void)
86 {
87     return 0;
88 }
pv_shim_mem(uint64_t avail)89 static inline uint64_t pv_shim_mem(uint64_t avail)
90 {
91     ASSERT_UNREACHABLE();
92     return 0;
93 }
94 
95 #endif
96 
97 #endif /* __X86_PV_SHIM_H__ */
98 
99 /*
100  * Local variables:
101  * mode: C
102  * c-file-style: "BSD"
103  * c-basic-offset: 4
104  * tab-width: 4
105  * indent-tabs-mode: nil
106  * End:
107  */
108