qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Chris Wulff" <crwulff@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Marek Vasut" <marex@denx.de>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Dr . David Alan Gilbert" <dave@treblig.org>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-ppc@nongnu.org, "Laurent Vivier" <laurent@vivier.eu>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH-for-9.1 17/21] target/xtensa: Prefix MMU API with 'xtensa_'
Date: Thu, 21 Mar 2024 16:48:33 +0100	[thread overview]
Message-ID: <20240321154838.95771-18-philmd@linaro.org> (raw)
In-Reply-To: <20240321154838.95771-1-philmd@linaro.org>

In order to extract the MMU API to a new "mmu.h" header,
prefix it with the target name.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/xtensa/cpu.h        |  4 ++--
 target/xtensa/cpu.c        |  2 +-
 target/xtensa/mmu_helper.c | 41 +++++++++++++++++++++-----------------
 target/xtensa/monitor.c    |  2 +-
 4 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 6b8d0636d2..b2cfc78e9d 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -692,8 +692,8 @@ static inline int xtensa_get_cring(const CPUXtensaState *env)
 int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access);
-void reset_mmu(CPUXtensaState *env);
-void dump_mmu(CPUXtensaState *env);
+void xtensa_reset_mmu(CPUXtensaState *env);
+void xtensa_dump_mmu(CPUXtensaState *env);
 
 static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env)
 {
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 875cf843c9..ae0c4aab24 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -130,7 +130,7 @@ static void xtensa_cpu_reset_hold(Object *obj)
     env->exclusive_addr = -1;
 
 #ifndef CONFIG_USER_ONLY
-    reset_mmu(env);
+    xtensa_reset_mmu(env);
     cs->halted = env->runstall;
 #endif
     set_no_signaling_nans(!dfpu, &env->fp_status);
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
index 47063b0a57..31ee3fa957 100644
--- a/target/xtensa/mmu_helper.c
+++ b/target/xtensa/mmu_helper.c
@@ -139,7 +139,8 @@ static uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env,
  * Get bit mask for the 'VPN without index' field.
  * See ISA, 4.6.5.6, data format for RxTLB0
  */
-static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way)
+static uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb,
+                                    uint32_t way)
 {
     if (way < 4) {
         bool is32 = (dtlb ?
@@ -168,9 +169,10 @@ static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way)
  * Split virtual address into VPN (with index) and entry index
  * for the given TLB way
  */
-static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v,
-                                     bool dtlb, uint32_t *vpn,
-                                     uint32_t wi, uint32_t *ei)
+static void xtensa_split_tlb_entry_spec_way(const CPUXtensaState *env,
+                                            uint32_t v,
+                                            bool dtlb, uint32_t *vpn,
+                                            uint32_t wi, uint32_t *ei)
 {
     bool varway56 = dtlb ?
         env->config->dtlb.varway56 :
@@ -224,13 +226,15 @@ static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v,
  * Split TLB address into TLB way, entry index and VPN (with index).
  * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format
  */
-static bool split_tlb_entry_spec(CPUXtensaState *env, uint32_t v, bool dtlb,
-                                 uint32_t *vpn, uint32_t *wi, uint32_t *ei)
+static bool xtensa_split_tlb_entry_spec(CPUXtensaState *env,
+                                        uint32_t v, bool dtlb,
+                                        uint32_t *vpn, uint32_t *wi,
+                                        uint32_t *ei)
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
         *wi = v & (dtlb ? 0xf : 0x7);
         if (*wi < (dtlb ? env->config->dtlb.nways : env->config->itlb.nways)) {
-            split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei);
+            xtensa_split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei);
             return true;
         } else {
             return false;
@@ -254,14 +258,14 @@ static xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb,
         env->itlb[wi] + ei;
 }
 
-static xtensa_tlb_entry *get_tlb_entry(CPUXtensaState *env,
+static xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env,
         uint32_t v, bool dtlb, uint32_t *pwi)
 {
     uint32_t vpn;
     uint32_t wi;
     uint32_t ei;
 
-    if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) {
+    if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) {
         if (pwi) {
             *pwi = wi;
         }
@@ -405,7 +409,7 @@ static void reset_tlb_region_way0(CPUXtensaState *env,
     }
 }
 
-void reset_mmu(CPUXtensaState *env)
+void xtensa_reset_mmu(CPUXtensaState *env)
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
         env->sregs[RASID] = 0x04030201;
@@ -470,7 +474,7 @@ static int xtensa_tlb_lookup(const CPUXtensaState *env,
     for (wi = 0; wi < tlb->nways; ++wi) {
         uint32_t vpn;
         uint32_t ei;
-        split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei);
+        xtensa_split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei);
         if (entry[wi][ei].vaddr == vpn && entry[wi][ei].asid) {
             unsigned ring = get_ring(env, entry[wi][ei].asid);
             if (ring < 4) {
@@ -493,10 +497,11 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb)
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
         uint32_t wi;
-        const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi);
+        const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi);
 
         if (entry) {
-            return (entry->vaddr & get_vpn_mask(env, dtlb, wi)) | entry->asid;
+            return (entry->vaddr & xtensa_get_vpn_mask(env, dtlb, wi))
+                   | entry->asid;
         } else {
             return 0;
         }
@@ -507,7 +512,7 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb)
 
 uint32_t HELPER(rtlb1)(CPUXtensaState *env, uint32_t v, uint32_t dtlb)
 {
-    const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, NULL);
+    const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, NULL);
 
     if (entry) {
         return entry->paddr | entry->attr;
@@ -520,7 +525,7 @@ void HELPER(itlb)(CPUXtensaState *env, uint32_t v, uint32_t dtlb)
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
         uint32_t wi;
-        xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi);
+        xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi);
         if (entry && entry->variable && entry->asid) {
             tlb_flush_page(env_cpu(env), entry->vaddr);
             entry->asid = 0;
@@ -559,7 +564,7 @@ void HELPER(wtlb)(CPUXtensaState *env, uint32_t p, uint32_t v, uint32_t dtlb)
     uint32_t vpn;
     uint32_t wi;
     uint32_t ei;
-    if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) {
+    if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) {
         xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, p);
     }
 }
@@ -818,7 +823,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb,
         may_lookup_pt && get_pte(env, vaddr, &pte)) {
         ring = (pte >> 4) & 0x3;
         wi = 0;
-        split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei);
+        xtensa_split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei);
 
         if (update_tlb) {
             wi = ++env->autorefill_idx & 0x3;
@@ -1192,7 +1197,7 @@ static void dump_mpu(CPUXtensaState *env,
     }
 }
 
-void dump_mmu(CPUXtensaState *env)
+void xtensa_dump_mmu(CPUXtensaState *env)
 {
     if (xtensa_option_bits_enabled(env->config,
                 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |
diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c
index fbf60d5553..ce1b791a5c 100644
--- a/target/xtensa/monitor.c
+++ b/target/xtensa/monitor.c
@@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "No CPU available\n");
         return;
     }
-    dump_mmu(env1);
+    xtensa_dump_mmu(env1);
 }
-- 
2.41.0



  parent reply	other threads:[~2024-03-21 15:52 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 15:48 [PATCH-for-9.1 00/21] target/monitor: Cleanup around hmp_info_tlb() Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.0? 01/21] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
2024-03-21 17:05   ` Richard Henderson
2024-04-23 13:54     ` Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 02/21] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h Philippe Mathieu-Daudé
2024-03-21 21:17   ` Richard Henderson
2024-03-21 15:48 ` [PATCH-for-9.1 03/21] target/i386: Move APIC related code to cpu-apic.c Philippe Mathieu-Daudé
2024-03-21 21:43   ` Richard Henderson
2024-04-24  8:26   ` Zhao Liu
2024-04-24 12:05     ` Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 04/21] target/i386: Extract x86_dump_mmu() from hmp_info_tlb() Philippe Mathieu-Daudé
2024-03-21 21:46   ` Richard Henderson
2024-03-21 15:48 ` [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor Philippe Mathieu-Daudé
2024-03-21 21:49   ` Richard Henderson
2024-03-24 23:43   ` Dr. David Alan Gilbert
2024-03-25  0:38     ` BALATON Zoltan
2024-03-28 21:59       ` Dr. David Alan Gilbert
2024-03-28 22:29         ` BALATON Zoltan
2024-04-24  7:35   ` Markus Armbruster
2024-04-24  9:19     ` BALATON Zoltan
2024-04-24  9:22       ` BALATON Zoltan
2024-03-21 15:48 ` [PATCH-for-9.1 06/21] target/m68k: Have dump_ttr() take a @description argument Philippe Mathieu-Daudé
2024-03-21 21:49   ` Richard Henderson
2024-03-21 15:48 ` [PATCH-for-9.1 07/21] target/m68k: Move MMU monitor commands from helper.c to monitor.c Philippe Mathieu-Daudé
2024-03-21 21:50   ` Richard Henderson
2024-03-21 15:48 ` [PATCH-for-9.1 08/21] target/microblaze: Prefix MMU API with 'mb_' Philippe Mathieu-Daudé
2024-03-23 13:13   ` Edgar E. Iglesias
2024-03-21 15:48 ` [PATCH-for-9.1 09/21] target/mips: Prefix MMU API with 'mips_' Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 10/21] target/nios2: Prefix MMU API with 'nios2_' Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 11/21] target/nios2: Move monitor commands to monitor.c Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 12/21] target/nios2: Replace qemu_printf() by monitor_printf() in monitor Philippe Mathieu-Daudé
2024-04-24  7:38   ` Markus Armbruster
2024-03-21 15:48 ` [PATCH-for-9.1 13/21] target/ppc: " Philippe Mathieu-Daudé
2024-04-24  7:39   ` Markus Armbruster
2024-03-21 15:48 ` [PATCH-for-9.1 14/21] target/sh4: Extract sh4_dump_mmu() from hmp_info_tlb() Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.0? 15/21] target/sparc: Fix string format errors when DEBUG_MMU is defined Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 16/21] target/sparc: Replace qemu_printf() by monitor_printf() in monitor Philippe Mathieu-Daudé
2024-04-24  7:44   ` Markus Armbruster
2024-04-24 12:08     ` Philippe Mathieu-Daudé
2024-03-21 15:48 ` Philippe Mathieu-Daudé [this message]
2024-03-21 15:48 ` [PATCH-for-9.1 18/21] target/xtensa: Extract MMU API to new mmu.c/mmu.h files Philippe Mathieu-Daudé
2024-03-23 19:23   ` Max Filippov
2024-03-21 15:48 ` [PATCH-for-9.1 19/21] target/xtensa: Simplify dump_mpu() and dump_tlb() Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 20/21] target/xtensa: Move monitor commands to monitor.c Philippe Mathieu-Daudé
2024-03-21 15:48 ` [PATCH-for-9.1 21/21] target/xtensa: Replace qemu_printf() by monitor_printf() in monitor Philippe Mathieu-Daudé
2024-04-24  7:45   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240321154838.95771-18-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=atar4qemu@gmail.com \
    --cc=crwulff@gmail.com \
    --cc=danielhb413@gmail.com \
    --cc=dave@treblig.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=laurent@vivier.eu \
    --cc=marex@denx.de \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).