From patchwork Thu Jul 26 02:36:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 142916 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1509950ljj; Wed, 25 Jul 2018 19:39:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfET+knq055fivSkM8jxR2WBIvKOXq1/nw5TfQW2lQVotcw1MjuvK3kQ5j2kfVM84TKSaOI X-Received: by 2002:a37:210a:: with SMTP id h10-v6mr70334qkh.263.1532572781722; Wed, 25 Jul 2018 19:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532572781; cv=none; d=google.com; s=arc-20160816; b=OFFvj7K/ThjtnR+CX0fWqnXvCOplZ4CJmwagFbPZFKfMWppLSl7j5a7A2xg7S+9XnP +Y6ohcNR9vD59i/gvcureR+e5Jsj221UsngHTee2nNFmUDmhVe8CJ9GYTh3AwqVjamBD BBuuIgrYeGfEUC5+Kcc+N5YX9ZADXLSwV6JwTIdsSpxzDbvNk0h+kJu7Y9vddhRDsv2U l5lwOb1b6H/DaDP4KBAf1jaUndh9MkakTdeEKAOBpTsswGer8GyM3esleHOa3I6T8HFM 3IuVZch0coybquJCrRRR+iHudCmIFbsCux3YXQWUpPrW8tys9eAbNXp54ytR6jW2FC+H pRPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=uVpIy0tbum8TS+4LeuR9ToTnLJtiAlEi8k9IZIn1ZjE=; b=buMlDcDtTYpBGmE5cDzeVO/rP7MG2ez035ZrhGQWnr4EtzY8hY/vcUa8UVYFwTRnCW q7P/VZ5AsNz+ordaymIUv0ap0yN1WJWawlmql/Ihh61zqy6N6UqpIx612ipNqNeexOA4 YbEnbwWBxVL2IcXtxE9rwZF8cSSsWWdX30/XT0NnjKJodhCdQL393d5mh2TuZqlxO101 +7fIxdIk68iUqRAxy115tMX9KSRTlAKFXwdbFC5K6wwkbyUZWGosPbVdZ0FqmMSKZ1bs 2jVSwHQrnNd+zEOwtFXudBCIOBihcwChx38CzkcOaHz0z4qxtU/lyiqFBblX3w4kEEWR GiSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e+rSrOSo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q12-v6si98390qtn.388.2018.07.25.19.39.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Jul 2018 19:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e+rSrOSo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:57710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiWBp-0007Lx-70 for patch@linaro.org; Wed, 25 Jul 2018 22:39:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiW9l-0005oi-Bn for qemu-devel@nongnu.org; Wed, 25 Jul 2018 22:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fiW9i-0003LY-Ci for qemu-devel@nongnu.org; Wed, 25 Jul 2018 22:37:33 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fiW9i-0003LO-6X; Wed, 25 Jul 2018 22:37:30 -0400 Received: by mail-pf1-x444.google.com with SMTP id q7-v6so74013pff.2; Wed, 25 Jul 2018 19:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uVpIy0tbum8TS+4LeuR9ToTnLJtiAlEi8k9IZIn1ZjE=; b=e+rSrOSoOddjat6fksfoZiVEkrkWwBPaaUree7BLNDWo8/KygHjyAm6VOLcP9xIJdz xlMjhWArb5TyFaxqLc0iY1FWHAy2H9x6IZKiS13rTE2cyyi938PsCp1pJ72MZJ9DAfR3 udB8IM3fLB/F58lCtZsLH4PfiG4Mle89x0JKtIk6qqMVaFgZyiRX/3BHLI1Ee3QFNdDk yE3C/0SpvEKNfhVDLnjh5Jy4zQn13XoGHrQ9cCrW4R7N0vWH6Pig7zmvKYAj8ePhXS+G vqbYu/jjs/fDHJnQefAPGhfI2JPDQZ8N5ilOiftBslt+WHJ8U/Uo+OEkTNxGMZsjXGf8 FkIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uVpIy0tbum8TS+4LeuR9ToTnLJtiAlEi8k9IZIn1ZjE=; b=qiLsmNfYyKpGRVHOjKzx7lNmPcueMDR1flP+4PsJpOsPKz1M5BuF5E0oENwivyJLWV j6v86v5CzUjKhrwjdDRRevmkukFcViNQvw4mtOEkiKTLpIzyy0Cf8ZUWydoFpWnu2Wl3 oGXVHtcGbnm5PwPGC+3I9PPywCfS2XAYYEcxGqVFTZUQi0RBD2b8YT4J0YnKHxmvTRE3 Z94C9n/D4dj/LFGmNSqXZ6tj+PKwZZSoBSDrOoPa4i1COFhRajXlGKFjwji1qiYWDMoP OnIs+0IY+lBQDtwuO80kY04QufzfMQCK2VSI1XqlG3OZ+zkXqTkIALWBzZGQp9Bmgmxo w6Ew== X-Gm-Message-State: AOUpUlHRSAjLi2udZs8VvsFFgKtBP9tnbLEEmTQ7d74hDG/EQnquNc+p /pjDe8kmdXeIN30p+R1BCn4= X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr127694pfc.256.1532572649147; Wed, 25 Jul 2018 19:37:29 -0700 (PDT) Received: from aurora.jms.id.au ([45.124.203.18]) by smtp.gmail.com with ESMTPSA id x87-v6sm106681pfa.143.2018.07.25.19.37.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 19:37:28 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Thu, 26 Jul 2018 12:07:21 +0930 From: Joel Stanley To: Peter Maydell Date: Thu, 26 Jul 2018 12:06:45 +0930 Message-Id: <20180726023645.13927-4-joel@jms.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180726023645.13927-1-joel@jms.id.au> References: <20180726023645.13927-1-joel@jms.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v3 3/3] arm: Add BBC micro:bit machine 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: Stefan Hajnoczi , =?utf-8?q?Steffen_G=C3=B6rtz?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Jim Mussared , Julia Suvorova Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds the base for a machine model of the BBC micro:bit: https://en.wikipedia.org/wiki/Micro_Bit This is a system with a nRF51 SoC containing the main processor, with various peripherals on board. Reviewed-by: Stefan Hajnoczi Signed-off-by: Joel Stanley --- v2: - Instead of setting kernel filename property, load the image directly - Add link to hardware overview website v3: - Rebase microbit on m0 changes - Remove hard-coded flash size and retrieve from the soc - Add Stefan's reviewed-by --- hw/arm/Makefile.objs | 2 +- hw/arm/microbit.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 hw/arm/microbit.c -- 2.17.1 diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index e31875ec69bc..2798a257921d 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -36,4 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o -obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o +obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o microbit.o diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c new file mode 100644 index 000000000000..ecf64e883f4f --- /dev/null +++ b/hw/arm/microbit.c @@ -0,0 +1,54 @@ +/* + * BBC micro:bit machine + * http://tech.microbit.org/hardware/ + * + * Copyright 2018 Joel Stanley + * + * This code is licensed under the GPL version 2 or later. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/boards.h" +#include "hw/arm/arm.h" +#include "exec/address-spaces.h" + +#include "hw/arm/nrf51_soc.h" + +typedef struct { + MachineState parent; + + NRF51State nrf51; +} MICROBITMachineState; + +#define TYPE_MICROBIT_MACHINE "microbit" + +#define MICROBIT_MACHINE(obj) \ + OBJECT_CHECK(MICROBITMachineState, obj, TYPE_MICROBIT_MACHINE) + +static void microbit_init(MachineState *machine) +{ + MICROBITMachineState *s = g_new(MICROBITMachineState, 1); + MemoryRegion *system_memory = get_system_memory(); + Object *soc; + + object_initialize(&s->nrf51, sizeof(s->nrf51), TYPE_NRF51_SOC); + soc = OBJECT(&s->nrf51); + object_property_add_child(OBJECT(machine), "nrf51", soc, &error_fatal); + object_property_set_link(soc, OBJECT(system_memory), + "memory", &error_abort); + + object_property_set_bool(soc, true, "realized", &error_abort); + + arm_m_profile_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, + NRF51_SOC(soc)->flash_size); +} + +static void microbit_machine_init(MachineClass *mc) +{ + mc->desc = "BBC micro:bit"; + mc->init = microbit_init; + mc->max_cpus = 1; +} +DEFINE_MACHINE("microbit", microbit_machine_init);