xref: /openbmc/qemu/target/i386/tcg/seg_helper.h (revision a6caeee8)
1 /*
2  *  x86 segmentation related helpers macros
3  *
4  *  Copyright (c) 2003 Fabrice Bellard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SEG_HELPER_H
21 #define SEG_HELPER_H
22 
23 //#define DEBUG_PCALL
24 
25 #ifdef DEBUG_PCALL
26 # define LOG_PCALL(...) qemu_log_mask(CPU_LOG_PCALL, ## __VA_ARGS__)
27 # define LOG_PCALL_STATE(cpu)                                  \
28     log_cpu_state_mask(CPU_LOG_PCALL, (cpu), CPU_DUMP_CCOP)
29 #else
30 # define LOG_PCALL(...) do { } while (0)
31 # define LOG_PCALL_STATE(cpu) do { } while (0)
32 #endif
33 
34 /*
35  * TODO: Convert callers to compute cpu_mmu_index_kernel once
36  * and use *_mmuidx_ra directly.
37  */
38 #define cpu_ldub_kernel_ra(e, p, r) \
39     cpu_ldub_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
40 #define cpu_lduw_kernel_ra(e, p, r) \
41     cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
42 #define cpu_ldl_kernel_ra(e, p, r) \
43     cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
44 #define cpu_ldq_kernel_ra(e, p, r) \
45     cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
46 
47 #define cpu_stb_kernel_ra(e, p, v, r) \
48     cpu_stb_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
49 #define cpu_stw_kernel_ra(e, p, v, r) \
50     cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
51 #define cpu_stl_kernel_ra(e, p, v, r) \
52     cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
53 #define cpu_stq_kernel_ra(e, p, v, r) \
54     cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
55 
56 #define cpu_ldub_kernel(e, p)    cpu_ldub_kernel_ra(e, p, 0)
57 #define cpu_lduw_kernel(e, p)    cpu_lduw_kernel_ra(e, p, 0)
58 #define cpu_ldl_kernel(e, p)     cpu_ldl_kernel_ra(e, p, 0)
59 #define cpu_ldq_kernel(e, p)     cpu_ldq_kernel_ra(e, p, 0)
60 
61 #define cpu_stb_kernel(e, p, v)  cpu_stb_kernel_ra(e, p, v, 0)
62 #define cpu_stw_kernel(e, p, v)  cpu_stw_kernel_ra(e, p, v, 0)
63 #define cpu_stl_kernel(e, p, v)  cpu_stl_kernel_ra(e, p, v, 0)
64 #define cpu_stq_kernel(e, p, v)  cpu_stq_kernel_ra(e, p, v, 0)
65 
66 #endif /* SEG_HELPER_H */
67