Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1i2cwi-0003oa-DY for mharc-qemu-riscv@gnu.org; Tue, 27 Aug 2019 10:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47110) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwZ-0003ah-7R for qemu-riscv@nongnu.org; Tue, 27 Aug 2019 10:59:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwU-0003t6-BT for qemu-riscv@nongnu.org; Tue, 27 Aug 2019 10:59:34 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwL-0003bU-CK; Tue, 27 Aug 2019 10:59:21 -0400 Received: by mail-pf1-x443.google.com with SMTP id o70so14292415pfg.5; Tue, 27 Aug 2019 07:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=uq+EV8N1IlJV9bRL7iLPiVLeUBJGzU4ZDSAZrtKNNVt4nD6Wh5w/CZ5/KOtzVRfsnQ qwYnxLuYyxaHhCrYDOq9zOqHhqH7Slmr3K1rBxtbK/9WugxZcyMqDs0vxMRkzEDhNrZY kHaER/02xdsoMg6GMFtSa/CWHZCZwm8HcFP4hvcMv6adkiYJrkLex2BKFd3MdygB0WUu uvIVavGFTKdrn5OOYvYpbJ71TwENKDYbq0YYf2TviOLHvpAbWELvmfvxTOQhIU4A1dn/ i28HVnrczu85nstJ/iOvKyzm6jiCWmfJ6faHZqvHhS1cPmy2bXJD04AC/1TaDR9T0CVE YcNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=HwkJrBkrb9xGtt6AbG8xnxKv8QlFBM53ORxWUv9EoXMpN6Cy8Vydy6jfsHAqFiMmp/ KWYEBU/YDwo3rlZBWYLyWrzu9AzJeXM/f72FKsprxZNikOw6jLfh3QXi5sSF8Xcrc23H LU3Bq4szXRTTTkupAc8UB6GKATssueqfadn1WizVJ0z9rl310MbUP0HtIxXjgBL/DAkj JjNGoezxQkYSZle1PfVVFvNBqqFv4Yghdad4H2U2g3rGRd1EfalfplpsuHv8xTCNqh3X qxHSZjmf26yiw0kYhWyfG9+MbDJ0NgM8RSA+DcdppKFRQe+BaYV9HpQMQ2gaxIPfOHwJ FTmA== X-Gm-Message-State: APjAAAWFUlVKqKrwF73ntxIkdTrLKQOHn2XlsRLCBzty1wTM0oGH9EQ5 Wt/qzDtwJsaxGr7pNzDx1Oc= X-Google-Smtp-Source: APXvYqwOylZlWtK6LxsNDbmSpUoQhUeW0iJgmOuiN1XMnDQgc3DjafD11YlT9v0LikmGxM9trpmmEQ== X-Received: by 2002:a62:ee0e:: with SMTP id e14mr10365737pfi.31.1566917941905; Tue, 27 Aug 2019 07:59:01 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.00 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:01 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:24 -0700 Message-Id: <1566917919-25381-16-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-riscv] [PATCH v6 15/30] riscv: hart: Add a "hartid-base" property to RISC-V hart array X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 14:59:40 -0000 At present each hart's hartid in a RISC-V hart array is assigned the same value of its index in the hart array. But for a system that has multiple hart arrays, this is not the case any more. Add a new "hartid-base" property so that hartid number can be assigned based on the property value. Signed-off-by: Bin Meng --- Changes in v6: - use s->hartid_base directly, instead of an extra variable Changes in v5: None Changes in v4: - new patch to add a "hartid-base" property to RISC-V hart array Changes in v3: None Changes in v2: None hw/riscv/riscv_hart.c | 7 ++++--- include/hw/riscv/riscv_hart.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index 9deef869..7cfc835 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -27,6 +27,7 @@ static Property riscv_harts_props[] = { DEFINE_PROP_UINT32("num-harts", RISCVHartArrayState, num_harts, 1), + DEFINE_PROP_UINT32("hartid-base", RISCVHartArrayState, hartid_base, 0), DEFINE_PROP_STRING("cpu-type", RISCVHartArrayState, cpu_type), DEFINE_PROP_END_OF_LIST(), }; @@ -37,7 +38,7 @@ static void riscv_harts_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } -static void riscv_hart_realize(RISCVHartArrayState *s, int idx, +static void riscv_hart_realize(RISCVHartArrayState *s, int idx, uint32_t hartid, char *cpu_type, Error **errp) { Error *err = NULL; @@ -45,7 +46,7 @@ static void riscv_hart_realize(RISCVHartArrayState *s, int idx, object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], sizeof(RISCVCPU), cpu_type, &error_abort, NULL); - s->harts[idx].env.mhartid = idx; + s->harts[idx].env.mhartid = hartid; qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]); object_property_set_bool(OBJECT(&s->harts[idx]), true, "realized", &err); @@ -63,7 +64,7 @@ static void riscv_harts_realize(DeviceState *dev, Error **errp) s->harts = g_new0(RISCVCPU, s->num_harts); for (n = 0; n < s->num_harts; n++) { - riscv_hart_realize(s, n, s->cpu_type, errp); + riscv_hart_realize(s, n, s->hartid_base + n, s->cpu_type, errp); } } diff --git a/include/hw/riscv/riscv_hart.h b/include/hw/riscv/riscv_hart.h index 0671d88..1984e30 100644 --- a/include/hw/riscv/riscv_hart.h +++ b/include/hw/riscv/riscv_hart.h @@ -32,6 +32,7 @@ typedef struct RISCVHartArrayState { /*< public >*/ uint32_t num_harts; + uint32_t hartid_base; char *cpu_type; RISCVCPU *harts; } RISCVHartArrayState; -- 2.7.4