2022-06-06 15:42:52 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* QEMU LoongArch CPU -- internal functions and types
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LOONGARCH_INTERNALS_H
|
|
|
|
#define LOONGARCH_INTERNALS_H
|
|
|
|
|
2022-06-06 15:43:01 +03:00
|
|
|
#define FCMP_LT 0b0001 /* fp0 < fp1 */
|
|
|
|
#define FCMP_EQ 0b0010 /* fp0 = fp1 */
|
|
|
|
#define FCMP_UN 0b0100 /* unordered */
|
|
|
|
#define FCMP_GT 0b1000 /* fp0 > fp1 */
|
|
|
|
|
2022-06-06 15:43:12 +03:00
|
|
|
#define TARGET_PHYS_MASK MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS)
|
|
|
|
#define TARGET_VIRT_MASK MAKE_64BIT_MASK(0, TARGET_VIRT_ADDR_SPACE_BITS)
|
|
|
|
|
2022-06-06 15:42:52 +03:00
|
|
|
void loongarch_translate_init(void);
|
|
|
|
|
|
|
|
void loongarch_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
|
|
|
|
|
|
|
|
void G_NORETURN do_raise_exception(CPULoongArchState *env,
|
|
|
|
uint32_t exception,
|
|
|
|
uintptr_t pc);
|
|
|
|
|
|
|
|
const char *loongarch_exception_name(int32_t exception);
|
|
|
|
|
2024-01-05 10:57:59 +03:00
|
|
|
#ifdef CONFIG_TCG
|
2023-05-04 15:27:59 +03:00
|
|
|
int ieee_ex_to_loongarch(int xcpt);
|
2022-06-06 15:43:00 +03:00
|
|
|
void restore_fp_status(CPULoongArchState *env);
|
2024-01-05 10:57:59 +03:00
|
|
|
#endif
|
2022-06-06 15:43:00 +03:00
|
|
|
|
2022-06-24 06:10:47 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2024-01-25 09:14:01 +03:00
|
|
|
enum {
|
|
|
|
TLBRET_MATCH = 0,
|
|
|
|
TLBRET_BADADDR = 1,
|
|
|
|
TLBRET_NOMATCH = 2,
|
|
|
|
TLBRET_INVALID = 3,
|
|
|
|
TLBRET_DIRTY = 4,
|
|
|
|
TLBRET_RI = 5,
|
|
|
|
TLBRET_XI = 6,
|
|
|
|
TLBRET_PE = 7,
|
|
|
|
};
|
|
|
|
|
2022-06-06 15:43:10 +03:00
|
|
|
extern const VMStateDescription vmstate_loongarch_cpu;
|
|
|
|
|
2022-06-06 15:43:13 +03:00
|
|
|
void loongarch_cpu_set_irq(void *opaque, int irq, int level);
|
|
|
|
|
2022-06-06 15:43:14 +03:00
|
|
|
void loongarch_constant_timer_cb(void *opaque);
|
|
|
|
uint64_t cpu_loongarch_get_constant_timer_counter(LoongArchCPU *cpu);
|
|
|
|
uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU *cpu);
|
|
|
|
void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu,
|
|
|
|
uint64_t value);
|
2024-01-25 09:14:01 +03:00
|
|
|
bool loongarch_tlb_search(CPULoongArchState *env, target_ulong vaddr,
|
|
|
|
int *index);
|
|
|
|
int get_physical_address(CPULoongArchState *env, hwaddr *physical,
|
|
|
|
int *prot, target_ulong address,
|
|
|
|
MMUAccessType access_type, int mmu_idx);
|
|
|
|
hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
|
|
|
|
|
2024-01-05 10:57:59 +03:00
|
|
|
#ifdef CONFIG_TCG
|
2022-06-06 15:43:12 +03:00
|
|
|
bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
|
|
|
MMUAccessType access_type, int mmu_idx,
|
|
|
|
bool probe, uintptr_t retaddr);
|
2024-01-05 10:57:59 +03:00
|
|
|
#endif
|
2022-06-24 06:10:47 +03:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
2022-06-06 15:43:12 +03:00
|
|
|
|
2022-08-05 06:35:23 +03:00
|
|
|
uint64_t read_fcc(CPULoongArchState *env);
|
|
|
|
void write_fcc(CPULoongArchState *env, uint64_t val);
|
|
|
|
|
2022-06-06 15:43:31 +03:00
|
|
|
int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n);
|
|
|
|
int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n);
|
|
|
|
void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs);
|
|
|
|
|
2022-06-06 15:42:52 +03:00
|
|
|
#endif
|