From 07ae8ccd0fc4ab5a9766ebc1486ed81a1b4c5f41 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Tue, 15 Dec 2020 14:45:06 +0800 Subject: target/mips/addr: Add translation helpers for KSEG1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's useful for bootloader to do I/O operations. Signed-off-by: Jiaxun Yang Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Huacai Chen Message-Id: <20201215064507.30148-3-jiaxun.yang@flygoat.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/addr.c | 10 ++++++++++ target/mips/cpu.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'target') diff --git a/target/mips/addr.c b/target/mips/addr.c index 27a6036c45..86f1c129c9 100644 --- a/target/mips/addr.c +++ b/target/mips/addr.c @@ -40,6 +40,16 @@ uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr) return addr | 0x40000000ll; } +uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr) +{ + return addr & 0x1fffffffll; +} + +uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr) +{ + return (addr & 0x1fffffffll) | 0xffffffffa0000000ll; +} + bool mips_um_ksegs_enabled(void) { return mips_um_ksegs; diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 0086f95ea2..0c2d397e4a 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1312,6 +1312,8 @@ uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr); uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr); uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr); +uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr); +uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr); bool mips_um_ksegs_enabled(void); void mips_um_ksegs_enable(void); -- cgit v1.2.3