Commit | Line | Data |
---|---|---|
9ae09838 CM |
1 | /* |
2 | * Copyright 2013 Tilera Corporation. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation, version 2. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
11 | * NON INFRINGEMENT. See the GNU General Public License for | |
12 | * more details. | |
13 | */ | |
14 | ||
15 | /* | |
16 | * Pull in the hypervisor header so we declare all the ABI functions | |
17 | * with the underscore versions, then undef the names so that we can | |
18 | * provide our own wrapper versions. | |
19 | */ | |
20 | #define hv_init _hv_init | |
21 | #define hv_install_context _hv_install_context | |
22 | #define hv_sysconf _hv_sysconf | |
23 | #define hv_get_rtc _hv_get_rtc | |
24 | #define hv_set_rtc _hv_set_rtc | |
25 | #define hv_flush_asid _hv_flush_asid | |
26 | #define hv_flush_page _hv_flush_page | |
27 | #define hv_flush_pages _hv_flush_pages | |
28 | #define hv_restart _hv_restart | |
29 | #define hv_halt _hv_halt | |
30 | #define hv_power_off _hv_power_off | |
31 | #define hv_inquire_physical _hv_inquire_physical | |
32 | #define hv_inquire_memory_controller _hv_inquire_memory_controller | |
33 | #define hv_inquire_virtual _hv_inquire_virtual | |
34 | #define hv_inquire_asid _hv_inquire_asid | |
35 | #define hv_nanosleep _hv_nanosleep | |
36 | #define hv_console_read_if_ready _hv_console_read_if_ready | |
37 | #define hv_console_write _hv_console_write | |
38 | #define hv_downcall_dispatch _hv_downcall_dispatch | |
39 | #define hv_inquire_topology _hv_inquire_topology | |
40 | #define hv_fs_findfile _hv_fs_findfile | |
41 | #define hv_fs_fstat _hv_fs_fstat | |
42 | #define hv_fs_pread _hv_fs_pread | |
43 | #define hv_physaddr_read64 _hv_physaddr_read64 | |
44 | #define hv_physaddr_write64 _hv_physaddr_write64 | |
45 | #define hv_get_command_line _hv_get_command_line | |
46 | #define hv_set_caching _hv_set_caching | |
47 | #define hv_bzero_page _hv_bzero_page | |
48 | #define hv_register_message_state _hv_register_message_state | |
49 | #define hv_send_message _hv_send_message | |
50 | #define hv_receive_message _hv_receive_message | |
51 | #define hv_inquire_context _hv_inquire_context | |
52 | #define hv_start_all_tiles _hv_start_all_tiles | |
53 | #define hv_dev_open _hv_dev_open | |
54 | #define hv_dev_close _hv_dev_close | |
55 | #define hv_dev_pread _hv_dev_pread | |
56 | #define hv_dev_pwrite _hv_dev_pwrite | |
57 | #define hv_dev_poll _hv_dev_poll | |
58 | #define hv_dev_poll_cancel _hv_dev_poll_cancel | |
59 | #define hv_dev_preada _hv_dev_preada | |
60 | #define hv_dev_pwritea _hv_dev_pwritea | |
61 | #define hv_flush_remote _hv_flush_remote | |
62 | #define hv_console_putc _hv_console_putc | |
63 | #define hv_inquire_tiles _hv_inquire_tiles | |
64 | #define hv_confstr _hv_confstr | |
65 | #define hv_reexec _hv_reexec | |
66 | #define hv_set_command_line _hv_set_command_line | |
67 | #define hv_clear_intr _hv_clear_intr | |
68 | #define hv_enable_intr _hv_enable_intr | |
69 | #define hv_disable_intr _hv_disable_intr | |
70 | #define hv_raise_intr _hv_raise_intr | |
71 | #define hv_trigger_ipi _hv_trigger_ipi | |
72 | #define hv_store_mapping _hv_store_mapping | |
73 | #define hv_inquire_realpa _hv_inquire_realpa | |
74 | #define hv_flush_all _hv_flush_all | |
75 | #define hv_get_ipi_pte _hv_get_ipi_pte | |
76 | #define hv_set_pte_super_shift _hv_set_pte_super_shift | |
77 | #define hv_console_set_ipi _hv_console_set_ipi | |
e5701b74 | 78 | #define hv_send_nmi _hv_send_nmi |
9ae09838 CM |
79 | #include <hv/hypervisor.h> |
80 | #undef hv_init | |
81 | #undef hv_install_context | |
82 | #undef hv_sysconf | |
83 | #undef hv_get_rtc | |
84 | #undef hv_set_rtc | |
85 | #undef hv_flush_asid | |
86 | #undef hv_flush_page | |
87 | #undef hv_flush_pages | |
88 | #undef hv_restart | |
89 | #undef hv_halt | |
90 | #undef hv_power_off | |
91 | #undef hv_inquire_physical | |
92 | #undef hv_inquire_memory_controller | |
93 | #undef hv_inquire_virtual | |
94 | #undef hv_inquire_asid | |
95 | #undef hv_nanosleep | |
96 | #undef hv_console_read_if_ready | |
97 | #undef hv_console_write | |
98 | #undef hv_downcall_dispatch | |
99 | #undef hv_inquire_topology | |
100 | #undef hv_fs_findfile | |
101 | #undef hv_fs_fstat | |
102 | #undef hv_fs_pread | |
103 | #undef hv_physaddr_read64 | |
104 | #undef hv_physaddr_write64 | |
105 | #undef hv_get_command_line | |
106 | #undef hv_set_caching | |
107 | #undef hv_bzero_page | |
108 | #undef hv_register_message_state | |
109 | #undef hv_send_message | |
110 | #undef hv_receive_message | |
111 | #undef hv_inquire_context | |
112 | #undef hv_start_all_tiles | |
113 | #undef hv_dev_open | |
114 | #undef hv_dev_close | |
115 | #undef hv_dev_pread | |
116 | #undef hv_dev_pwrite | |
117 | #undef hv_dev_poll | |
118 | #undef hv_dev_poll_cancel | |
119 | #undef hv_dev_preada | |
120 | #undef hv_dev_pwritea | |
121 | #undef hv_flush_remote | |
122 | #undef hv_console_putc | |
123 | #undef hv_inquire_tiles | |
124 | #undef hv_confstr | |
125 | #undef hv_reexec | |
126 | #undef hv_set_command_line | |
127 | #undef hv_clear_intr | |
128 | #undef hv_enable_intr | |
129 | #undef hv_disable_intr | |
130 | #undef hv_raise_intr | |
131 | #undef hv_trigger_ipi | |
132 | #undef hv_store_mapping | |
133 | #undef hv_inquire_realpa | |
134 | #undef hv_flush_all | |
135 | #undef hv_get_ipi_pte | |
136 | #undef hv_set_pte_super_shift | |
137 | #undef hv_console_set_ipi | |
e5701b74 | 138 | #undef hv_send_nmi |
9ae09838 CM |
139 | |
140 | /* | |
141 | * Provide macros based on <linux/syscalls.h> to provide a wrapper | |
142 | * function that invokes the same function with an underscore prefix. | |
143 | * We can't use the existing __SC_xxx macros because we need to | |
144 | * support up to nine arguments rather than up to six, and also this | |
145 | * way the file stands alone from possible changes in the | |
146 | * implementation of <linux/syscalls.h>. | |
147 | */ | |
148 | #define HV_WRAP0(type, name) \ | |
149 | type name(void); \ | |
150 | type name(void) \ | |
151 | { \ | |
152 | return _##name(); \ | |
153 | } | |
154 | #define __HV_DECL1(t1, a1) t1 a1 | |
155 | #define __HV_DECL2(t2, a2, ...) t2 a2, __HV_DECL1(__VA_ARGS__) | |
156 | #define __HV_DECL3(t3, a3, ...) t3 a3, __HV_DECL2(__VA_ARGS__) | |
157 | #define __HV_DECL4(t4, a4, ...) t4 a4, __HV_DECL3(__VA_ARGS__) | |
158 | #define __HV_DECL5(t5, a5, ...) t5 a5, __HV_DECL4(__VA_ARGS__) | |
159 | #define __HV_DECL6(t6, a6, ...) t6 a6, __HV_DECL5(__VA_ARGS__) | |
160 | #define __HV_DECL7(t7, a7, ...) t7 a7, __HV_DECL6(__VA_ARGS__) | |
161 | #define __HV_DECL8(t8, a8, ...) t8 a8, __HV_DECL7(__VA_ARGS__) | |
162 | #define __HV_DECL9(t9, a9, ...) t9 a9, __HV_DECL8(__VA_ARGS__) | |
163 | #define __HV_PASS1(t1, a1) a1 | |
164 | #define __HV_PASS2(t2, a2, ...) a2, __HV_PASS1(__VA_ARGS__) | |
165 | #define __HV_PASS3(t3, a3, ...) a3, __HV_PASS2(__VA_ARGS__) | |
166 | #define __HV_PASS4(t4, a4, ...) a4, __HV_PASS3(__VA_ARGS__) | |
167 | #define __HV_PASS5(t5, a5, ...) a5, __HV_PASS4(__VA_ARGS__) | |
168 | #define __HV_PASS6(t6, a6, ...) a6, __HV_PASS5(__VA_ARGS__) | |
169 | #define __HV_PASS7(t7, a7, ...) a7, __HV_PASS6(__VA_ARGS__) | |
170 | #define __HV_PASS8(t8, a8, ...) a8, __HV_PASS7(__VA_ARGS__) | |
171 | #define __HV_PASS9(t9, a9, ...) a9, __HV_PASS8(__VA_ARGS__) | |
172 | #define HV_WRAPx(x, type, name, ...) \ | |
173 | type name(__HV_DECL##x(__VA_ARGS__)); \ | |
174 | type name(__HV_DECL##x(__VA_ARGS__)) \ | |
175 | { \ | |
176 | return _##name(__HV_PASS##x(__VA_ARGS__)); \ | |
177 | } | |
178 | #define HV_WRAP1(type, name, ...) HV_WRAPx(1, type, name, __VA_ARGS__) | |
179 | #define HV_WRAP2(type, name, ...) HV_WRAPx(2, type, name, __VA_ARGS__) | |
180 | #define HV_WRAP3(type, name, ...) HV_WRAPx(3, type, name, __VA_ARGS__) | |
181 | #define HV_WRAP4(type, name, ...) HV_WRAPx(4, type, name, __VA_ARGS__) | |
182 | #define HV_WRAP5(type, name, ...) HV_WRAPx(5, type, name, __VA_ARGS__) | |
183 | #define HV_WRAP6(type, name, ...) HV_WRAPx(6, type, name, __VA_ARGS__) | |
184 | #define HV_WRAP7(type, name, ...) HV_WRAPx(7, type, name, __VA_ARGS__) | |
185 | #define HV_WRAP8(type, name, ...) HV_WRAPx(8, type, name, __VA_ARGS__) | |
186 | #define HV_WRAP9(type, name, ...) HV_WRAPx(9, type, name, __VA_ARGS__) | |
187 | ||
188 | /* List all the hypervisor API functions. */ | |
189 | HV_WRAP4(void, hv_init, HV_VersionNumber, interface_version_number, | |
190 | int, chip_num, int, chip_rev_num, int, client_pl) | |
191 | HV_WRAP1(long, hv_sysconf, HV_SysconfQuery, query) | |
192 | HV_WRAP3(int, hv_confstr, HV_ConfstrQuery, query, HV_VirtAddr, buf, int, len) | |
193 | #if CHIP_HAS_IPI() | |
194 | HV_WRAP3(int, hv_get_ipi_pte, HV_Coord, tile, int, pl, HV_PTE*, pte) | |
195 | HV_WRAP3(int, hv_console_set_ipi, int, ipi, int, event, HV_Coord, coord); | |
196 | #else | |
197 | HV_WRAP1(void, hv_enable_intr, HV_IntrMask, enab_mask) | |
198 | HV_WRAP1(void, hv_disable_intr, HV_IntrMask, disab_mask) | |
199 | HV_WRAP1(void, hv_clear_intr, HV_IntrMask, clear_mask) | |
200 | HV_WRAP1(void, hv_raise_intr, HV_IntrMask, raise_mask) | |
201 | HV_WRAP2(HV_Errno, hv_trigger_ipi, HV_Coord, tile, int, interrupt) | |
202 | #endif /* !CHIP_HAS_IPI() */ | |
203 | HV_WRAP3(int, hv_store_mapping, HV_VirtAddr, va, unsigned int, len, | |
204 | HV_PhysAddr, pa) | |
205 | HV_WRAP2(HV_PhysAddr, hv_inquire_realpa, HV_PhysAddr, cpa, unsigned int, len) | |
206 | HV_WRAP0(HV_RTCTime, hv_get_rtc) | |
207 | HV_WRAP1(void, hv_set_rtc, HV_RTCTime, time) | |
208 | HV_WRAP4(int, hv_install_context, HV_PhysAddr, page_table, HV_PTE, access, | |
209 | HV_ASID, asid, __hv32, flags) | |
210 | HV_WRAP2(int, hv_set_pte_super_shift, int, level, int, log2_count) | |
211 | HV_WRAP0(HV_Context, hv_inquire_context) | |
212 | HV_WRAP1(int, hv_flush_asid, HV_ASID, asid) | |
213 | HV_WRAP2(int, hv_flush_page, HV_VirtAddr, address, HV_PageSize, page_size) | |
214 | HV_WRAP3(int, hv_flush_pages, HV_VirtAddr, start, HV_PageSize, page_size, | |
215 | unsigned long, size) | |
216 | HV_WRAP1(int, hv_flush_all, int, preserve_global) | |
217 | HV_WRAP2(void, hv_restart, HV_VirtAddr, cmd, HV_VirtAddr, args) | |
218 | HV_WRAP0(void, hv_halt) | |
219 | HV_WRAP0(void, hv_power_off) | |
220 | HV_WRAP1(int, hv_reexec, HV_PhysAddr, entry) | |
221 | HV_WRAP0(HV_Topology, hv_inquire_topology) | |
222 | HV_WRAP3(HV_Errno, hv_inquire_tiles, HV_InqTileSet, set, HV_VirtAddr, cpumask, | |
223 | int, length) | |
224 | HV_WRAP1(HV_PhysAddrRange, hv_inquire_physical, int, idx) | |
225 | HV_WRAP2(HV_MemoryControllerInfo, hv_inquire_memory_controller, HV_Coord, coord, | |
226 | int, controller) | |
227 | HV_WRAP1(HV_VirtAddrRange, hv_inquire_virtual, int, idx) | |
228 | HV_WRAP1(HV_ASIDRange, hv_inquire_asid, int, idx) | |
229 | HV_WRAP1(void, hv_nanosleep, int, nanosecs) | |
230 | HV_WRAP0(int, hv_console_read_if_ready) | |
231 | HV_WRAP1(void, hv_console_putc, int, byte) | |
232 | HV_WRAP2(int, hv_console_write, HV_VirtAddr, bytes, int, len) | |
233 | HV_WRAP0(void, hv_downcall_dispatch) | |
234 | HV_WRAP1(int, hv_fs_findfile, HV_VirtAddr, filename) | |
235 | HV_WRAP1(HV_FS_StatInfo, hv_fs_fstat, int, inode) | |
236 | HV_WRAP4(int, hv_fs_pread, int, inode, HV_VirtAddr, buf, | |
237 | int, length, int, offset) | |
238 | HV_WRAP2(unsigned long long, hv_physaddr_read64, HV_PhysAddr, addr, | |
239 | HV_PTE, access) | |
240 | HV_WRAP3(void, hv_physaddr_write64, HV_PhysAddr, addr, HV_PTE, access, | |
241 | unsigned long long, val) | |
242 | HV_WRAP2(int, hv_get_command_line, HV_VirtAddr, buf, int, length) | |
243 | HV_WRAP2(HV_Errno, hv_set_command_line, HV_VirtAddr, buf, int, length) | |
244 | HV_WRAP1(void, hv_set_caching, unsigned long, bitmask) | |
245 | HV_WRAP2(void, hv_bzero_page, HV_VirtAddr, va, unsigned int, size) | |
246 | HV_WRAP1(HV_Errno, hv_register_message_state, HV_MsgState*, msgstate) | |
247 | HV_WRAP4(int, hv_send_message, HV_Recipient *, recips, int, nrecip, | |
248 | HV_VirtAddr, buf, int, buflen) | |
249 | HV_WRAP3(HV_RcvMsgInfo, hv_receive_message, HV_MsgState, msgstate, | |
250 | HV_VirtAddr, buf, int, buflen) | |
251 | HV_WRAP0(void, hv_start_all_tiles) | |
252 | HV_WRAP2(int, hv_dev_open, HV_VirtAddr, name, __hv32, flags) | |
253 | HV_WRAP1(int, hv_dev_close, int, devhdl) | |
254 | HV_WRAP5(int, hv_dev_pread, int, devhdl, __hv32, flags, HV_VirtAddr, va, | |
255 | __hv32, len, __hv64, offset) | |
256 | HV_WRAP5(int, hv_dev_pwrite, int, devhdl, __hv32, flags, HV_VirtAddr, va, | |
257 | __hv32, len, __hv64, offset) | |
258 | HV_WRAP3(int, hv_dev_poll, int, devhdl, __hv32, events, HV_IntArg, intarg) | |
259 | HV_WRAP1(int, hv_dev_poll_cancel, int, devhdl) | |
260 | HV_WRAP6(int, hv_dev_preada, int, devhdl, __hv32, flags, __hv32, sgl_len, | |
261 | HV_SGL *, sglp, __hv64, offset, HV_IntArg, intarg) | |
262 | HV_WRAP6(int, hv_dev_pwritea, int, devhdl, __hv32, flags, __hv32, sgl_len, | |
263 | HV_SGL *, sglp, __hv64, offset, HV_IntArg, intarg) | |
264 | HV_WRAP9(int, hv_flush_remote, HV_PhysAddr, cache_pa, | |
265 | unsigned long, cache_control, unsigned long*, cache_cpumask, | |
266 | HV_VirtAddr, tlb_va, unsigned long, tlb_length, | |
267 | unsigned long, tlb_pgsize, unsigned long*, tlb_cpumask, | |
268 | HV_Remote_ASID*, asids, int, asidcount) | |
e5701b74 CM |
269 | HV_WRAP3(HV_NMI_Info, hv_send_nmi, HV_Coord, tile, unsigned long, info, |
270 | __hv64, flags) |