From patchwork Fri Aug 31 22:09:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 10584503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E551A1709 for ; Fri, 31 Aug 2018 22:13:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2F932BFF9 for ; Fri, 31 Aug 2018 22:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C65192C029; Fri, 31 Aug 2018 22:13:04 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 38B632BFF9 for ; Fri, 31 Aug 2018 22:13:04 +0000 (UTC) Received: from localhost ([::1]:58658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvrf5-0007fa-Gy for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Aug 2018 18:13:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvrbr-0004ex-PP for qemu-devel@nongnu.org; Fri, 31 Aug 2018 18:09:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvrbp-0004sm-7m for qemu-devel@nongnu.org; Fri, 31 Aug 2018 18:09:43 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fvrbm-0004mb-QK; Fri, 31 Aug 2018 18:09:39 -0400 Received: by mail-pg1-x541.google.com with SMTP id r1-v6so6013674pgp.11; Fri, 31 Aug 2018 15:09:35 -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=HECvTG3GejFa6sz+CKKWy/jQ+RL2N8C5303UsdeGdog=; b=sA68YOl8VGfUR9TaJJ97poZ/p6f4/6xoFgdPPa+z1btWMz6PoJgbY3nubQkzUmqv5Z YI89b7PDtwTNk1mhXFpi/azMGIJ5A7+78KPXCSqxUuiUpzkELDxoft4+V8xUtiovhcjK GyDG5VBdVetQSbsFbwZJghcXm7MZ0eqgC57qY3nMwVSsJ7dnN/cQUrCforvluGIA5XNc JAFaWHQ2uyFefcsjRRog4aYV8I9WFPiG5qIpSdjpKhqyKu44qKSZCJUPdmY9lL1uH8C5 sA6PkKVPSTxHtVxWICy7mcM9bovhWJAFXaOo9ywnZUc/xxiNWsO3a8pL7bxU5A4XXOwx lf9Q== 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=HECvTG3GejFa6sz+CKKWy/jQ+RL2N8C5303UsdeGdog=; b=bfedXGFS/vwDEMiUpxTWqMkXOZqL41xlmjo6uJDRSET48BqBkPEFdYce72TdYck1l8 1fC9h9DwvXtJ/B8v9M7LV82ff6ZM2Uo+RVoJwIB1qRxs1htFeczNSpqJFPdZqFGARvXT 8QfHVddMcpdlBPQQKOYtFV59Vp7cydO7KkxdnExKqa/m432sQEbvPzBKZqnk/iX9EwAS El5hJsVv0XdDGwTtlBlG3Ko9VC7NjQtmj6rCXCkGESrkfUTY4cfm6BATkQejzXkfnRpU OZMDPLti3+DMW+MQwkUEz4p7ENOGPuPJNr/gOUOoxEOTsHdnSoK0pLKvij9z3s20BoYr b5sw== X-Gm-Message-State: APzg51BIi0lubTlN7PXS/bh8JuIG3uSuKFTaW0EVHkjsrAXM+xvQPEX7 Syd4HXFIIR0oz0c0kqUga7c= X-Google-Smtp-Source: ANB0VdYHqB37AdRv4mAx9PJ1RgGNnKs+1cD9kZz5U9Z9MHHYlC2DTyqlaityQCRCeiNrYzuDxl+t5Q== X-Received: by 2002:a63:2354:: with SMTP id u20-v6mr1602019pgm.122.1535753374402; Fri, 31 Aug 2018 15:09:34 -0700 (PDT) Received: from aurora.jms.id.au ([72.28.92.217]) by smtp.gmail.com with ESMTPSA id d12-v6sm16634207pfk.69.2018.08.31.15.09.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 15:09:33 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Fri, 31 Aug 2018 15:09:32 -0700 From: Joel Stanley To: Peter Maydell Date: Fri, 31 Aug 2018 15:09:20 -0700 Message-Id: <20180831220920.27113-4-joel@jms.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180831220920.27113-1-joel@jms.id.au> References: <20180831220920.27113-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::541 Subject: [Qemu-devel] [PATCH v6 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 v5: - move back to armv7m calls, as v4 of Stefan's patch removed the m_profile changes v6: - MICROBITMachineState -> MicrobitMachineState - Rework machine type init with PMM's suggestions --- hw/arm/Makefile.objs | 2 +- hw/arm/microbit.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 hw/arm/microbit.c diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index ae4e20373b9e..5f88062c666d 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -37,4 +37,4 @@ 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_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.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..e7d74116a504 --- /dev/null +++ b/hw/arm/microbit.c @@ -0,0 +1,67 @@ +/* + * 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 MACHINE_TYPE_NAME("microbit") + +#define MICROBIT_MACHINE(obj) \ + OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE) + +static void microbit_init(MachineState *machine) +{ + MicrobitMachineState *s = MICROBIT_MACHINE(machine); + MemoryRegion *system_memory = get_system_memory(); + Object *soc = OBJECT(&s->nrf51); + + sysbus_init_child_obj(OBJECT(machine), "nrf51", soc, sizeof(s->nrf51), + TYPE_NRF51_SOC); + object_property_set_link(soc, OBJECT(system_memory), "memory", + &error_fatal); + object_property_set_bool(soc, true, "realized", &error_fatal); + + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, + NRF51_SOC(soc)->flash_size); +} + +static void microbit_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + + mc->desc = "BBC micro:bit"; + mc->init = microbit_init; + mc->max_cpus = 1; +} + +static const TypeInfo microbit_info = { + .name = TYPE_MICROBIT_MACHINE, + .parent = TYPE_MACHINE, + .instance_size = sizeof(MicrobitMachineState), + .class_init = microbit_machine_class_init, +}; + +static void microbit_machine_init(void) +{ + type_register_static(µbit_info); +} + +type_init(microbit_machine_init);