From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boYrB-0006xU-Jb for qemu-devel@nongnu.org; Mon, 26 Sep 2016 12:34:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boYr6-0007Lz-By for qemu-devel@nongnu.org; Mon, 26 Sep 2016 12:34:16 -0400 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]:34161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boYr6-0007Lm-6e for qemu-devel@nongnu.org; Mon, 26 Sep 2016 12:34:12 -0400 Received: by mail-io0-x243.google.com with SMTP id y139so11308221ioy.1 for ; Mon, 26 Sep 2016 09:34:12 -0700 (PDT) Sender: Richard Henderson References: From: Richard Henderson Message-ID: Date: Mon, 26 Sep 2016 09:34:09 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/18] target-riscv: Add initialization for translation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sagar Karandikar , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, kbastian@mail.uni-paderborn.de On 09/26/2016 03:56 AM, Sagar Karandikar wrote: > RISCVCPU *cpu_riscv_init(const char *cpu_model) > { > - return NULL; > + RISCVCPU *cpu; > + CPURISCVState *env; > + const riscv_def_t *def; > + > + def = cpu_riscv_find_by_name(cpu_model); > + if (!def) { > + return NULL; > + } > + cpu = RISCV_CPU(object_new(TYPE_RISCV_CPU)); > + env = &cpu->env; > + env->cpu_model = def; > + > + memset(env->csr, 0, 4096 * sizeof(target_ulong)); sizeof(env->csr)? And besides that, doesn't this more properly belong in a reset function, where that memset will already have been done? > + env->priv = PRV_M; > + > + /* set mcpuid from def */ > + env->csr[CSR_MISA] = def->init_misa_reg; > + object_property_set_bool(OBJECT(cpu), true, "realized", NULL); > + > + /* fpu flags: */ > + set_default_nan_mode(1, &env->fp_status);