All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Xiaojuan Yang <yangxiaojuan@loongson.cn>, qemu-devel@nongnu.org
Cc: mark.cave-ayland@ilande.co.uk, gaosong@loongson.cn
Subject: Re: [PATCH v1 26/43] target/loongarch: Add LoongArch IOCSR instruction
Date: Fri, 15 Apr 2022 19:26:27 -0700	[thread overview]
Message-ID: <7878fbf7-6352-fe32-1daa-272490fe8061@linaro.org> (raw)
In-Reply-To: <20220415094058.3584233-27-yangxiaojuan@loongson.cn>

On 4/15/22 02:40, Xiaojuan Yang wrote:
> +static bool trans_iocsrrd_b(DisasContext *ctx, arg_iocsrrd_b *a)
> +static bool trans_iocsrrd_h(DisasContext *ctx, arg_iocsrrd_h *a)
> +static bool trans_iocsrrd_w(DisasContext *ctx, arg_iocsrrd_w *a)
> +static bool trans_iocsrrd_d(DisasContext *ctx, arg_iocsrrd_d *a)

You have all of these split apart, then pass an integer to a common routine...

> +uint64_t helper_iocsr_read(CPULoongArchState *env, target_ulong r_addr,
> +                           uint32_t size)
> +{
> +    int cpuid = env_cpu(env)->cpu_index;
> +    CPUState  *cs = qemu_get_cpu(cpuid);
> +    env = cs->env_ptr;
> +    uint64_t ret = 0;
> +
> +    /*
> +     * Adjust the per core address such as 0x10xx(IPI)/0x18xx(EXTIOI)
> +     */
> +    if (((r_addr & 0xff00) == 0x1000) || ((r_addr & 0xff00) == 0x1800)) {
> +        r_addr = r_addr + ((target_ulong)(cpuid & 0x3) << 8);
> +    }
> +
> +    switch (size) {
> +    case 1:
> +        ret = address_space_ldub(&env->address_space_iocsr, r_addr,
> +                                 MEMTXATTRS_UNSPECIFIED, NULL);
> +        break;
> +    case 2:
> +        ret = address_space_lduw(&env->address_space_iocsr, r_addr,
> +                                 MEMTXATTRS_UNSPECIFIED, NULL);
> +        break;
> +    case 4:
> +        ret = address_space_ldl(&env->address_space_iocsr, r_addr,
> +                                MEMTXATTRS_UNSPECIFIED, NULL);
> +        break;
> +    case 8:
> +        ret = address_space_ldq(&env->address_space_iocsr, r_addr,
> +                                MEMTXATTRS_UNSPECIFIED, NULL);
> +        break;
> +    default:
> +        g_assert_not_reached();
> +    }

... then have to split them apart again.  It would be cleaner to have 4 helpers, one for 
each size.

I'm concerned about the address adjustment.  My thinking is that this should be handled by 
the address space (via a MemoryRegionOps entry).  I say this because there is nothing 
about this adjustment in "LoongArch Reference Manual", but rather in the "LoongArch 3A5000 
Registers Technical Reference Manual".  Which means that baking this cpu specific 
behaviour into the generic architecture is incorrect.


> +void helper_iocsr_write(CPULoongArchState *env, target_ulong w_addr,
> +                        target_ulong val, uint32_t size)
> +{
> +    int cpuid = env_cpu(env)->cpu_index;
> +    CPUState *cs = qemu_get_cpu(cpuid);
> +    int mask, i;
> +    env = cs->env_ptr;
> +
> +    /*
> +     * For IPI send, Mailbox send and ANY send, adjust the addr and
> +     * val accordingly. The IOCSR writes are turned to different
> +     * MMIO writes respectively
> +     */
> +    switch (w_addr) {
> +    case 0x1040: /* IPI send */

Likewise.


r~


  reply	other threads:[~2022-04-16  2:27 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15  9:40 [PATCH v1 00/43] Add LoongArch softmmu support Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 01/43] target/loongarch: Add README Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 02/43] target/loongarch: Add core definition Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 03/43] target/loongarch: Add main translation routines Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 04/43] target/loongarch: Add fixed point arithmetic instruction translation Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 05/43] target/loongarch: Add fixed point shift " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 06/43] target/loongarch: Add fixed point bit " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 07/43] target/loongarch: Add fixed point load/store " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 08/43] target/loongarch: Add fixed point atomic " Xiaojuan Yang
2022-04-15 22:46   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 09/43] target/loongarch: Add fixed point extra " Xiaojuan Yang
2022-04-15 22:56   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 10/43] target/loongarch: Add floating point arithmetic " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 11/43] target/loongarch: Add floating point comparison " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 12/43] target/loongarch: Add floating point conversion " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 13/43] target/loongarch: Add floating point move " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 14/43] target/loongarch: Add floating point load/store " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 15/43] target/loongarch: Add branch " Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 16/43] target/loongarch: Add disassembler Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 17/43] target/loongarch: Add target build suport Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 18/43] target/loongarch: Add system emulation introduction Xiaojuan Yang
2022-04-15 23:25   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 19/43] target/loongarch: Add CSRs definition Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 20/43] target/loongarch: Add basic vmstate description of CPU Xiaojuan Yang
2022-04-15 23:29   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 21/43] target/loongarch: Implement qmp_query_cpu_definitions() Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 22/43] target/loongarch: Add MMU support for LoongArch CPU Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 23/43] target/loongarch: Add LoongArch interrupt and exception handle Xiaojuan Yang
2022-04-16  0:13   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 24/43] target/loongarch: Add constant timer support Xiaojuan Yang
2022-04-16  0:17   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction Xiaojuan Yang
2022-04-16  1:04   ` Richard Henderson
2022-04-18 12:38     ` yangxiaojuan
2022-04-18 14:34       ` Richard Henderson
2022-04-19  7:33     ` yangxiaojuan
2022-04-19 17:05       ` Richard Henderson
2022-04-21  9:15         ` yangxiaojuan
2022-04-21 15:59           ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 26/43] target/loongarch: Add LoongArch IOCSR instruction Xiaojuan Yang
2022-04-16  2:26   ` Richard Henderson [this message]
2022-04-15  9:40 ` [PATCH v1 27/43] target/loongarch: Add TLB instruction support Xiaojuan Yang
2022-04-16  3:38   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 28/43] target/loongarch: Add other core instructions support Xiaojuan Yang
2022-04-16  3:49   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 29/43] target/loongarch: Add timer related " Xiaojuan Yang
2022-04-17 18:48   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 30/43] target/loongarch: Add gdb support Xiaojuan Yang
2022-04-17 19:02   ` Richard Henderson
2022-04-17 19:08   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 31/43] hw/loongarch: Add support loongson3 virt machine type Xiaojuan Yang
2022-04-17 22:28   ` Richard Henderson
2022-04-17 22:55   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 32/43] hw/loongarch: Add LoongArch ipi interrupt support(IPI) Xiaojuan Yang
2022-04-18  0:24   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 33/43] hw/intc: Add LoongArch ls7a interrupt controller support(PCH-PIC) Xiaojuan Yang
2022-04-18  3:15   ` Richard Henderson
2022-04-18  9:14     ` yangxiaojuan
2022-04-18 14:39       ` Richard Henderson
2022-04-19  7:27         ` yangxiaojuan
2022-04-19 17:14           ` Richard Henderson
2022-04-21  3:10             ` yangxiaojuan
2022-04-15  9:40 ` [PATCH v1 34/43] hw/intc: Add LoongArch ls7a msi interrupt controller support(PCH-MSI) Xiaojuan Yang
2022-04-18  3:39   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 35/43] hw/intc: Add LoongArch extioi interrupt controller(EIOINTC) Xiaojuan Yang
2022-04-18  3:48   ` Richard Henderson
2022-04-18  8:57     ` Mark Cave-Ayland
2022-04-19  1:50       ` yangxiaojuan
2022-04-19 11:10         ` Mark Cave-Ayland
2022-04-15  9:40 ` [PATCH v1 36/43] hw/loongarch: Add irq hierarchy for the system Xiaojuan Yang
2022-04-18 14:44   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 37/43] Enable common virtio pci support for LoongArch Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 38/43] hw/loongarch: Add some devices support for 3A5000 Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 39/43] hw/loongarch: Add LoongArch ls7a rtc device support Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 40/43] hw/loongarch: Add LoongArch boot code and load elf function Xiaojuan Yang
2022-04-18 15:11   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 41/43] hw/loongarch: Add LoongArch ls7a acpi device support Xiaojuan Yang
2022-04-15  9:40 ` [PATCH v1 42/43] tests/tcg/loongarch64: Add hello/memory test in loongarch64 system Xiaojuan Yang
2022-04-18 15:25   ` Richard Henderson
2022-04-15  9:40 ` [PATCH v1 43/43] target/loongarch: 'make check-tcg' support Xiaojuan Yang

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=7878fbf7-6352-fe32-1daa-272490fe8061@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=gaosong@loongson.cn \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=yangxiaojuan@loongson.cn \
    /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.