From patchwork Thu Sep 8 22:32:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rolnik X-Patchwork-Id: 9322285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B070560752 for ; Thu, 8 Sep 2016 23:03:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9034A29A34 for ; Thu, 8 Sep 2016 23:03:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84FE729A36; Thu, 8 Sep 2016 23:03:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E637629A34 for ; Thu, 8 Sep 2016 23:03:47 +0000 (UTC) Received: from localhost ([::1]:54585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi8ME-0004OU-Q8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Sep 2016 19:03:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sh-0003Yg-Vj for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:33:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi7sg-0000qN-Ih for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:33:15 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sg-0000q9-97 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:33:14 -0400 Received: by mail-wm0-x242.google.com with SMTP id a6so201714wmc.2 for ; Thu, 08 Sep 2016 15:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=od/e3OJHp8R6q/zjrxDqJtulk+hkDG8sVKOpwOGe9EM=; b=ZD0m+1lBPZdl6fIWse8zmcayFFsfgSGNytlSFV+HpMNII12vnsWXDBPBibe2Mfdq+R 8Fl+W86ZFvNQNWRlSwxoGpJgBnW5hsjS4D08NLA0aFvvCS31xOhi3gh3OL6HtcxSCpbI MpxlY28y8J1/8hIDi4XPP+GwISXTtXdDir1bpISrAkMOejvxEARXyKJlZnr4NpX/Mpqz fOkaU4G8cMLqX8BouREuZgfG/elyGJmb2ZX9UIZcyQhBGP1n8wcxuaYFjfpu3Z68LcWL PmPQ8sluazIvRQOeCjoCaPZMPSrj4uu4ktQCEyppOUDaVMkr6MxBt07hBOdJA2YVZpkx lHNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=od/e3OJHp8R6q/zjrxDqJtulk+hkDG8sVKOpwOGe9EM=; b=VlqEkKpdtvbmBKISTYUD6KuESshCK6LQd8MsrCkmVflHCAEBlgHLSmFz/Y+ANAAEw/ Q01Y9jWyCN7O1/Rw2UZQyx2vYrANx+W0MbF3NUwIlWZykSDScS18cbN4oUQW3xOdaJRN H7wspGYwZ/tf8tbq6QUFSp3dgIU8NAAdxoP0zTcW5cTu7HOBkLlHD6a/SaGiT/F96has J7lgDwHrqeIZSQRYIxzoDktn+C4p7rGnkPuFqDB88HhPG5YfHdl2aneh73NTS7j0a678 Hd4pZIc10q1dNcyBorMmNA/C1ObWWefGPSJGPX6rPqx9hfgx406JdC0B0hFGWPS00skt TAPw== X-Gm-Message-State: AE9vXwM4NzfQMa5cyxBrlrRYZTnD+6kXebiaf+BacU8DNlW8Lsy2eJ7DKMhCSJ3AuteVow== X-Received: by 10.194.157.226 with SMTP id wp2mr237195wjb.48.1473373993631; Thu, 08 Sep 2016 15:33:13 -0700 (PDT) Received: from a0999b0126e1.ant.amazon.com ([94.230.86.12]) by smtp.gmail.com with ESMTPSA id d8sm276298wmi.0.2016.09.08.15.33.12 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Sep 2016 15:33:12 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Fri, 9 Sep 2016 01:32:10 +0300 Message-Id: <1473373930-31547-30-git-send-email-mrolnik@gmail.com> X-Mailer: git-send-email 2.4.9 (Apple Git-60) In-Reply-To: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> References: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH RFC v1 29/29] target-arc: sample board X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Rolnik Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Michael Rolnik --- MAINTAINERS | 1 + hw/arc/Makefile.objs | 21 ++++++++++++++ hw/arc/sample.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 hw/arc/Makefile.objs create mode 100644 hw/arc/sample.c diff --git a/MAINTAINERS b/MAINTAINERS index 0500cf5..6d7ce0b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -103,6 +103,7 @@ ARC M: Michael Rolnik S: Maintained F: target-arc/ +F: hw/arc ARM M: Peter Maydell diff --git a/hw/arc/Makefile.objs b/hw/arc/Makefile.objs new file mode 100644 index 0000000..5ac5cb7 --- /dev/null +++ b/hw/arc/Makefile.objs @@ -0,0 +1,21 @@ +# +# QEMU ARC CPU +# +# Copyright (c) 2016 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# +# + +obj-y += sample.o diff --git a/hw/arc/sample.c b/hw/arc/sample.c new file mode 100644 index 0000000..e8620af --- /dev/null +++ b/hw/arc/sample.c @@ -0,0 +1,80 @@ +/* + * QEMU ARC CPU + * + * Copyright (c) 2016 Michael Rolnik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "cpu.h" +#include "hw/hw.h" +#include "sysemu/sysemu.h" +#include "sysemu/qtest.h" +#include "ui/console.h" +#include "hw/boards.h" +#include "hw/devices.h" +#include "hw/loader.h" +#include "qemu/error-report.h" +#include "exec/address-spaces.h" +#include "include/hw/sysbus.h" + +#define SIZE_RAM 0x00020000 + +static void sample_init(MachineState *machine) +{ + MemoryRegion *mem; + MemoryRegion *ram; + + ARCCPU *cpu_arc ATTRIBUTE_UNUSED; + + mem = g_new(MemoryRegion, 1); + ram = g_new(MemoryRegion, 1); + + cpu_arc = cpu_arc_init("any"); + + memory_region_allocate_system_memory(mem, NULL, "arc.mem", SIZE_RAM); + + memory_region_init_ram(ram, NULL, "ram", SIZE_RAM, &error_fatal); + memory_region_add_subregion(get_system_memory(), PHYS_BASE_RAM, ram); + vmstate_register_ram_global(ram); + + char const *firmware = NULL; + char const *filename; + + if (machine->firmware) { + firmware = machine->firmware; + } + + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware); + if (!filename) { + error_report("Could not find flash image file '%s'", firmware); + exit(1); + } + + load_image_targphys(filename, PHYS_BASE_RAM + 0x100, SIZE_RAM); +} + +static void sample_machine_init(MachineClass *mc) +{ + mc->desc = "ARC sample/example board"; + mc->init = sample_init; + mc->is_default = 1; +} + +DEFINE_MACHINE("sample", sample_machine_init) +