From nobody Wed Nov 5 16:36:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496947984955587.1070494770325; Thu, 8 Jun 2017 11:53:04 -0700 (PDT) Received: from localhost ([::1]:51047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ2YI-0007dg-Eo for importer@patchew.org; Thu, 08 Jun 2017 14:53:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ2VU-0005h3-Cw for qemu-devel@nongnu.org; Thu, 08 Jun 2017 14:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJ2VP-0001JP-W2 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 14:50:08 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dJ2VP-0001JD-MP for qemu-devel@nongnu.org; Thu, 08 Jun 2017 14:50:03 -0400 Received: by mail-wm0-x242.google.com with SMTP id 70so8660955wme.1 for ; Thu, 08 Jun 2017 11:50:03 -0700 (PDT) Received: from a0999b0126e1.ant.amazon.com ([2.53.26.197]) by smtp.gmail.com with ESMTPSA id z32sm2914198edb.8.2017.06.08.11.50.00 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Jun 2017 11:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i0jsV9lStRRjqNPJ+mnB0gHc87mPoX0MzVV/aWoPgcM=; b=SI39J4PD43lNfijRHJgsA6yD5RBJ6UqvKwH3uz6ORZXAQMK4js6sqDn6FGy5pJnyuy aLlb4fM4vKCgEoMIKQRf4yRonGgKthZpKjQ076EUnVplBFEkKYRLXIOCEOVNyZJlVjYs Sw2PBA10fusUMQyzuHFGU5IwTk5oo/sGl7uos3/o9fT919ZTm+ITXiuecpBXgQeuUaZ5 PeJEKrNWPUObpQywKG+XHqdeVX1o4xqQSZoD5EAq8boTYasEMfoor1pU6Zxg3mngXhhx oPng01YfFwAgw9LHgn/u6JAe6UzGxGO87r5RRtFNmshslYANymEBs29Jh4xet7NXGn9K Mzzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i0jsV9lStRRjqNPJ+mnB0gHc87mPoX0MzVV/aWoPgcM=; b=UzqBQiKEMltdrlv0C9h3G+HfmVAEFgFGwFzTrRF5w4ELzPDBQuqh0QakrNnBRhWBbT h0bF7+L/P69iz95A324BXjSv+cOTUyC2ntSyu5P0tMzhwMhR7h816DprZw4PxjIAeLvH zGPXciswDHjCcWsFhPzJ6gxZgL4wo41hbsdUNh44u00vWxXAKgz1M4Q1aifW0i5RyMSI OzfRV/fx7/sty22YSXF3KUNS1dVas7jxJlOHP2gK2tSWUTCvg0A31BghPAR4dDN+0IwO /lPuWebONerzAukacsh56Nn+V7u3ITyK0hjh6zZJkiAMph1mMwcjROGcvMth73dD6dLx l+wA== X-Gm-Message-State: AODbwcAXbrvwNiRUvWrWXeoJkRsr6qx/tqCpqogaN/eQX7XbgkmP8X41 LukFyyRcvV7GLkcgxLk= X-Received: by 10.80.143.227 with SMTP id y90mr30653257edy.131.1496947802362; Thu, 08 Jun 2017 11:50:02 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Thu, 8 Jun 2017 21:49:38 +0300 Message-Id: <20170608184944.19406-4-mrolnik@gmail.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170608184944.19406-1-mrolnik@gmail.com> References: <20170608184944.19406-1-mrolnik@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH RFC v19 03/13] target-avr: adding a sample AVR 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: Richard Henderson , Michael Rolnik , anichang@protonmail.ch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michael Rolnik Message-Id: <1471522070-77598-4-git-send-email-mrolnik@gmail.com> Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + hw/avr/Makefile.objs | 21 ++++++++++ hw/avr/sample.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 130 insertions(+) create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c diff --git a/MAINTAINERS b/MAINTAINERS index dc37be323e..313b42642a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -129,6 +129,7 @@ AVR M: Michael Rolnik S: Maintained F: target-avr/ +F: hw/avr/ =20 CRIS M: Edgar E. Iglesias diff --git a/hw/avr/Makefile.objs b/hw/avr/Makefile.objs new file mode 100644 index 0000000000..8f537c9870 --- /dev/null +++ b/hw/avr/Makefile.objs @@ -0,0 +1,21 @@ +# +# QEMU AVR 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 +=3D sample.o diff --git a/hw/avr/sample.c b/hw/avr/sample.c new file mode 100644 index 0000000000..7b03130680 --- /dev/null +++ b/hw/avr/sample.c @@ -0,0 +1,108 @@ +/* + * QEMU AVR 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 + * + */ + +/* + * NOTE: + * This is not a real AVR board !!! This is an example !!! + * + * This example can be used to build a real AVR board. + * + * This example board loads provided binary file into flash memory and + * executes it from 0x00000000 address in the code memory space. + * + * Currently used for AVR CPU validation + * + */ + +#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 VIRT_BASE_FLASH 0x00000000 +#define VIRT_BASE_ISRAM 0x00000100 +#define VIRT_BASE_EXMEM 0x00001100 +#define VIRT_BASE_EEPROM 0x00000000 + +#define SIZE_FLASH 0x00020000 +#define SIZE_ISRAM 0x00001000 +#define SIZE_EXMEM 0x00010000 +#define SIZE_EEPROM 0x00001000 +#define SIZE_IOREG SIZE_REGS + +#define PHYS_BASE_FLASH (PHYS_BASE_CODE) + +#define PHYS_BASE_ISRAM (PHYS_BASE_DATA) +#define PHYS_BASE_EXMEM (PHYS_BASE_ISRAM + SIZE_ISRAM) +#define PHYS_BASE_EEPROM (PHYS_BASE_EXMEM + SIZE_EXMEM) + +#define PHYS_BASE_IOREG (PHYS_BASE_REGS + 0x20) + +static void sample_init(MachineState *machine) +{ + MemoryRegion *address_space_mem; + MemoryRegion *ram; + MemoryRegion *flash; + unsigned ram_size =3D SIZE_ISRAM + SIZE_EXMEM; + AVRCPU *cpu_avr ATTRIBUTE_UNUSED; + const char *firmware =3D NULL; + const char *filename; + + address_space_mem =3D get_system_memory(); + ram =3D g_new(MemoryRegion, 1); + flash =3D g_new(MemoryRegion, 1); + + cpu_avr =3D cpu_avr_init("avr5"); + + memory_region_allocate_system_memory(ram, NULL, "avr.ram", ram_size); + memory_region_add_subregion(address_space_mem, PHYS_BASE_ISRAM, ram); + + memory_region_init_rom(flash, NULL, "avr.flash", SIZE_FLASH, &error_fa= tal); + memory_region_add_subregion(address_space_mem, PHYS_BASE_FLASH, flash); + vmstate_register_ram_global(flash); + + if (machine->firmware) { + firmware =3D machine->firmware; + } + + filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware); + if (filename) { + load_image_targphys(filename, PHYS_BASE_FLASH, SIZE_FLASH); + } +} + +static void sample_machine_init(MachineClass *mc) +{ + mc->desc =3D "AVR sample/example board"; + mc->init =3D sample_init; + mc->is_default =3D 1; +} + +DEFINE_MACHINE("sample", sample_machine_init) --=20 2.11.0 (Apple Git-81)