diff mbox series

[v2,6/8] target/mips/addr: Add translation helpers for KSEG1

Message ID 20201215064507.30148-3-jiaxun.yang@flygoat.com (mailing list archive)
State New, archived
Headers show
Series MIPS Bootloader helper | expand

Commit Message

Jiaxun Yang Dec. 15, 2020, 6:45 a.m. UTC
It's useful for bootloader to do IO opreations.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 target/mips/addr.c | 10 ++++++++++
 target/mips/cpu.h  |  2 ++
 2 files changed, 12 insertions(+)

Comments

Philippe Mathieu-Daudé Jan. 1, 2021, 8:42 p.m. UTC | #1
On 12/15/20 7:45 AM, Jiaxun Yang wrote:
> It's useful for bootloader to do IO opreations.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  target/mips/addr.c | 10 ++++++++++
>  target/mips/cpu.h  |  2 ++
>  2 files changed, 12 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Philippe Mathieu-Daudé Jan. 1, 2021, 11:16 p.m. UTC | #2
On 1/1/21 9:42 PM, Philippe Mathieu-Daudé wrote:
> On 12/15/20 7:45 AM, Jiaxun Yang wrote:
>> It's useful for bootloader to do IO opreations.
>>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>>  target/mips/addr.c | 10 ++++++++++
>>  target/mips/cpu.h  |  2 ++
>>  2 files changed, 12 insertions(+)
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Huacai Chen Jan. 3, 2021, 1:46 a.m. UTC | #3
Reviewed-by: Huacai Chen <chenhuacai@kernel.org>

On Sat, Jan 2, 2021 at 7:17 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 1/1/21 9:42 PM, Philippe Mathieu-Daudé wrote:
> > On 12/15/20 7:45 AM, Jiaxun Yang wrote:
> >> It's useful for bootloader to do IO opreations.
> >>
> >> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> >> ---
> >>  target/mips/addr.c | 10 ++++++++++
> >>  target/mips/cpu.h  |  2 ++
> >>  2 files changed, 12 insertions(+)
> >
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
diff mbox series

Patch

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 3ac21d0e9c..0bb1218a57 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1303,6 +1303,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);