All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <huth@tuxfamily.org>
To: qemu-devel@nongnu.org, "Michael Rolnik" <mrolnik@gmail.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Richard Henderson" <rth@twiddle.net>
Cc: Sarah Harris <S.E.Harris@kent.ac.uk>
Subject: [PATCH rc6 04/30] target/avr: CPU class: Add memory menagement support
Date: Sun,  5 Jul 2020 16:02:49 +0200	[thread overview]
Message-ID: <20200705140315.260514-5-huth@tuxfamily.org> (raw)
In-Reply-To: <20200705140315.260514-1-huth@tuxfamily.org>

From: Michael Rolnik <mrolnik@gmail.com>

This patch introduces three memory-management-related functions
that will become part of AVR CPU class object.

[AM: Split a larger AVR introduction patch into logical units]
Suggested-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Co-developed-by: Michael Rolnik <mrolnik@gmail.com>
Co-developed-by: Sarah Harris <S.E.Harris@kent.ac.uk>
Signed-off-by: Michael Rolnik <mrolnik@gmail.com>
Signed-off-by: Sarah Harris <S.E.Harris@kent.ac.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
 target/avr/cpu.c    |  3 +++
 target/avr/helper.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index 8305a3a85d..a1d5f3c1eb 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -203,6 +203,9 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data)
     cc->cpu_exec_interrupt = avr_cpu_exec_interrupt;
     cc->dump_state = avr_cpu_dump_state;
     cc->set_pc = avr_cpu_set_pc;
+    cc->memory_rw_debug = avr_cpu_memory_rw_debug;
+    cc->get_phys_page_debug = avr_cpu_get_phys_page_debug;
+    cc->tlb_fill = avr_cpu_tlb_fill;
     cc->disas_set_info = avr_cpu_disas_set_info;
     cc->tcg_initialize = avr_cpu_tcg_init;
     cc->synchronize_from_tb = avr_cpu_synchronize_from_tb;
diff --git a/target/avr/helper.c b/target/avr/helper.c
index 731a9ee27f..354def2a65 100644
--- a/target/avr/helper.c
+++ b/target/avr/helper.c
@@ -87,3 +87,53 @@ void avr_cpu_do_interrupt(CPUState *cs)
 
     cs->exception_index = -1;
 }
+
+int avr_cpu_memory_rw_debug(CPUState *cs, vaddr addr, uint8_t *buf,
+                                int len, bool is_write)
+{
+    return cpu_memory_rw_debug(cs, addr, buf, len, is_write);
+}
+
+hwaddr avr_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
+{
+    return addr; /* I assume 1:1 address correspondance */
+}
+
+bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
+                        MMUAccessType access_type, int mmu_idx,
+                        bool probe, uintptr_t retaddr)
+{
+    int prot = 0;
+    MemTxAttrs attrs = {};
+    uint32_t paddr;
+
+    address &= TARGET_PAGE_MASK;
+
+    if (mmu_idx == MMU_CODE_IDX) {
+        /* access to code in flash */
+        paddr = OFFSET_CODE + address;
+        prot = PAGE_READ | PAGE_EXEC;
+        if (paddr + TARGET_PAGE_SIZE > OFFSET_DATA) {
+            error_report("execution left flash memory");
+            exit(1);
+        }
+    } else if (address < NUMBER_OF_CPU_REGISTERS + NUMBER_OF_IO_REGISTERS) {
+        /*
+         * access to CPU registers, exit and rebuilt this TB to use full access
+         * incase it touches specially handled registers like SREG or SP
+         */
+        AVRCPU *cpu = AVR_CPU(cs);
+        CPUAVRState *env = &cpu->env;
+        env->fullacc = 1;
+        cpu_loop_exit_restore(cs, retaddr);
+    } else {
+        /* access to memory. nothing special */
+        paddr = OFFSET_DATA + address;
+        prot = PAGE_READ | PAGE_WRITE;
+    }
+
+    tlb_set_page_with_attrs(
+        cs, address, paddr, attrs, prot, mmu_idx, TARGET_PAGE_SIZE);
+
+    return true;
+}
-- 
2.26.2



  parent reply	other threads:[~2020-07-05 14:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-05 14:02 [PATCH rc6 00/30] target/avr merger Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 01/30] target/avr: Add basic parameters of the new platform Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 02/30] target/avr: Introduce basic CPU class object Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 03/30] target/avr: CPU class: Add interrupt handling support Thomas Huth
2020-07-05 14:02 ` Thomas Huth [this message]
2020-07-05 14:02 ` [PATCH rc6 05/30] target/avr: CPU class: Add migration support Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 06/30] target/avr: CPU class: Add GDB support Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 07/30] target/avr: Introduce enumeration AVRFeature Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 08/30] target/avr: Add defintions of AVR core types Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 09/30] target/avr: Add instruction helpers Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 10/30] target/avr: Add instruction translation - Register definitions Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 11/30] target/avr: Add instruction translation - Arithmetic and Logic Instructions Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 12/30] target/avr: Add instruction translation - Branch Instructions Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 13/30] target/avr: Add instruction translation - Data Transfer Instructions Thomas Huth
2020-07-05 14:02 ` [PATCH rc6 14/30] target/avr: Add instruction translation - Bit and Bit-test Instructions Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 15/30] target/avr: Add instruction translation - MCU Control Instructions Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 16/30] target/avr: Add instruction translation - CPU main translation function Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 17/30] target/avr: Initialize TCG register variables Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 18/30] target/avr: Add support for disassembling via option '-d in_asm' Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 19/30] hw/char: avr: Add limited support for USART peripheral Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 20/30] hw/timer: avr: Add limited support for 16-bit timer peripheral Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 21/30] hw/misc: avr: Add limited support for power reduction device Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 22/30] target/avr: Register AVR support with the rest of QEMU Thomas Huth
2020-07-06 14:56   ` Eric Blake
2020-07-06 16:36     ` Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 23/30] hw/avr: Add support for loading ELF/raw binaries Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 24/30] hw/avr: Add some ATmega microcontrollers Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 25/30] hw/avr: Add limited support for some Arduino boards Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 26/30] target/avr: Update build system Thomas Huth
2020-07-05 21:30   ` Philippe Mathieu-Daudé
2020-07-05 14:03 ` [PATCH rc6 27/30] tests/machine-none: Add AVR support Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 28/30] tests/boot-serial: Test some Arduino boards (AVR based) Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 29/30] tests/acceptance: Test the Arduino MEGA2560 board Thomas Huth
2020-07-05 14:03 ` [PATCH rc6 30/30] target/avr: Add section into QEMU documentation Thomas Huth
2020-07-05 14:29 ` [PATCH rc6 00/30] target/avr merger no-reply
2020-07-05 18:30   ` Thomas Huth
2020-07-05 18:42     ` Peter Maydell
2020-07-07 17:57 ` Philippe Mathieu-Daudé

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=20200705140315.260514-5-huth@tuxfamily.org \
    --to=huth@tuxfamily.org \
    --cc=S.E.Harris@kent.ac.uk \
    --cc=f4bug@amsat.org \
    --cc=mrolnik@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.