1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * QEMU LoongArch CPU -- internal functions and types
5 * Copyright (c) 2021 Loongson Technology Corporation Limited
8 #ifndef LOONGARCH_INTERNALS_H
9 #define LOONGARCH_INTERNALS_H
11 #define FCMP_LT 0b0001 /* fp0 < fp1 */
12 #define FCMP_EQ 0b0010 /* fp0 = fp1 */
13 #define FCMP_UN 0b0100 /* unordered */
14 #define FCMP_GT 0b1000 /* fp0 > fp1 */
16 #define TARGET_PHYS_MASK MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS)
17 #define TARGET_VIRT_MASK MAKE_64BIT_MASK(0, TARGET_VIRT_ADDR_SPACE_BITS)
19 /* Global bit used for lddir/ldpte */
20 #define LOONGARCH_PAGE_HUGE_SHIFT 6
21 /* Global bit for huge page */
22 #define LOONGARCH_HGLOBAL_SHIFT 12
24 void loongarch_translate_init(void);
26 void loongarch_cpu_dump_state(CPUState
*cpu
, FILE *f
, int flags
);
28 void G_NORETURN
do_raise_exception(CPULoongArchState
*env
,
32 const char *loongarch_exception_name(int32_t exception
);
34 int ieee_ex_to_loongarch(int xcpt
);
35 void restore_fp_status(CPULoongArchState
*env
);
37 #ifndef CONFIG_USER_ONLY
38 extern const VMStateDescription vmstate_loongarch_cpu
;
40 void loongarch_cpu_set_irq(void *opaque
, int irq
, int level
);
42 void loongarch_constant_timer_cb(void *opaque
);
43 uint64_t cpu_loongarch_get_constant_timer_counter(LoongArchCPU
*cpu
);
44 uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU
*cpu
);
45 void cpu_loongarch_store_constant_timer_config(LoongArchCPU
*cpu
,
48 bool loongarch_cpu_tlb_fill(CPUState
*cs
, vaddr address
, int size
,
49 MMUAccessType access_type
, int mmu_idx
,
50 bool probe
, uintptr_t retaddr
);
52 hwaddr
loongarch_cpu_get_phys_page_debug(CPUState
*cpu
, vaddr addr
);
53 #endif /* !CONFIG_USER_ONLY */
55 uint64_t read_fcc(CPULoongArchState
*env
);
56 void write_fcc(CPULoongArchState
*env
, uint64_t val
);
58 int loongarch_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
);
59 int loongarch_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
);
60 void loongarch_cpu_register_gdb_regs_for_features(CPUState
*cs
);