From patchwork Tue Dec 9 10:29:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 42035 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EE97F25E75 for ; Tue, 9 Dec 2014 10:30:19 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf510200wib.2 for ; Tue, 09 Dec 2014 02:30:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=G7cRV24B/oczKuF7W4WXktH5fjgQOqR+CivzsdyvPiQ=; b=h3Eww6Zw1WTphwgXQRk04VSCJJAjun/0+FhDRQ43DCceef5kOsr8N/URHNWjiREQlm xgiTMk9F1+gZmlmmWLNfdyDJi13TqnFCd/NBSKw2mJgh+SqkHdLFlGMyLTHmkkk/PzhI GqeD8eKH22Y+V/I5+YHQL3MN+g6s9+h+gyl17p+6VwZga+hrZO6is/y0kMzI2Fwub46F abDDtW8qdYnl+wVnQpwGqYcvzEDxN2HS2Gzuho6suNhAjhRNid4B/reTF6Id6K47cTq0 gWBhgT7hxuyRoUX4EkOXpxlhKdvFu1l1PyAI9IHIGL0AORl6caPMrOtqE9EN6WEnJ9fk 4I+Q== X-Gm-Message-State: ALoCoQlfj6Csp0k6+8I4PAldiijmzoc+O+GgcegDvmhM7znI654O/qfSAf5SPkwn+uXz7zbQ1bIy X-Received: by 10.112.188.199 with SMTP id gc7mr7074639lbc.6.1418121019209; Tue, 09 Dec 2014 02:30:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.170 with SMTP id p10ls22140lal.35.gmail; Tue, 09 Dec 2014 02:30:19 -0800 (PST) X-Received: by 10.112.73.102 with SMTP id k6mr21189211lbv.75.1418121018995; Tue, 09 Dec 2014 02:30:18 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id u18si860402lal.73.2014.12.09.02.30.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 02:30:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id n15so241925lbi.2 for ; Tue, 09 Dec 2014 02:30:18 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr21203791lbk.46.1418121018890; Tue, 09 Dec 2014 02:30:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp733384lbc; Tue, 9 Dec 2014 02:30:17 -0800 (PST) X-Received: by 10.180.9.111 with SMTP id y15mr30238152wia.33.1418121017240; Tue, 09 Dec 2014 02:30:17 -0800 (PST) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com. [209.85.212.170]) by mx.google.com with ESMTPS id vk1si1419098wjc.12.2014.12.09.02.30.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 02:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.170 as permitted sender) client-ip=209.85.212.170; Received: by mail-wi0-f170.google.com with SMTP id bs8so9640199wib.1 for ; Tue, 09 Dec 2014 02:30:17 -0800 (PST) X-Received: by 10.180.80.34 with SMTP id o2mr3119228wix.53.1418121017021; Tue, 09 Dec 2014 02:30:17 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id w4sm1129273wjw.39.2014.12.09.02.30.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 02:30:16 -0800 (PST) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, kim.phillips@freescale.com, marc.zyngier@arm.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com, zhaoshenglong@huawei.com, ard.biesheuvel@linaro.org, agraf@suse.de, peter.maydell@linaro.org, pbonzini@redhat.com, afaerber@suse.de Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, Bharat.Bhushan@freescale.com, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, alex.williamson@redhat.com Subject: [PATCH v6 2/3] hw/arm/boot: arm_load_kernel implemented as a machine init done notifier Date: Tue, 9 Dec 2014 10:29:58 +0000 Message-Id: <1418120999-12631-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1418120999-12631-1-git-send-email-eric.auger@linaro.org> References: <1418120999-12631-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Device tree nodes for the platform bus and its children dynamic sysbus devices are added in a machine init done notifier. To load the dtb once, after those latter nodes are built and before ROM freeze, the actual arm_load_kernel existing code is moved into a notifier notify function, arm_load_kernel_notify. arm_load_kernel now only registers the corresponding notifier. Machine files that do not support platform bus stay unchanged. Machine files willing to support dynamic sysbus devices must call arm_load_kernel before sysbus-fdt arm_register_platform_bus_fdt_creator to make sure dynamic sysbus device nodes are integrated in the dtb. Signed-off-by: Eric Auger --- v6: creation of this patch file --- hw/arm/boot.c | 14 +++++++++++++- include/hw/arm/arm.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 0014c34..9d8aaa0 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -476,7 +476,7 @@ static void do_cpu_reset(void *opaque) } } -void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) +static void arm_load_kernel_notify(Notifier *notifier, void *data) { CPUState *cs; int kernel_size; @@ -487,6 +487,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) hwaddr entry, kernel_load_offset; int big_endian; static const ARMInsnFixup *primary_loader; + ArmLoadKernelNotifier *n = + container_of(notifier, ArmLoadKernelNotifier, notifier); + ARMCPU *cpu = n->cpu; + struct arm_boot_info *info = + container_of(n, struct arm_boot_info, load_kernel_notifier); /* CPU objects (unlike devices) are not automatically reset on system * reset, so we must always register a handler to do so. If we're @@ -665,3 +670,10 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) ARM_CPU(cs)->env.boot_info = info; } } + +void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) +{ + info->load_kernel_notifier.cpu = cpu; + info->load_kernel_notifier.notifier.notify = arm_load_kernel_notify; + qemu_add_machine_init_done_notifier(&info->load_kernel_notifier.notifier); +} diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h index cefc9e6..88cf80b 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -19,6 +19,16 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int flash_size, int sram_size, const char *kernel_filename, const char *cpu_model); +/* + * struct used as a parameter of the arm_load_kernel machine init + * done notifier + */ +typedef struct { + ARMCPU *cpu; /* handle to the first cpu object */ + Notifier notifier; /* actual notifier */ +} ArmLoadKernelNotifier; + + /* arm_boot.c */ struct arm_boot_info { uint64_t ram_size; @@ -61,12 +71,30 @@ struct arm_boot_info { * the user it should implement this hook. */ void (*modify_dtb)(const struct arm_boot_info *info, void *fdt); + /* machine init done notifier executing arm_load_dtb */ + ArmLoadKernelNotifier load_kernel_notifier; /* Used internally by arm_boot.c */ int is_linux; hwaddr initrd_start; hwaddr initrd_size; hwaddr entry; }; + +/** + * arm_load_kernel - Loads memory with everything needed to boot + * + * @cpu: handle to the first CPU object + * @info: handle to the boot info struct + * Registers a machine init done notifier that copies to memory + * everything needed to boot, depending on machine and user options: + * kernel image, boot loaders, initrd, dtb. Also registers the CPU + * reset handler. + * + * In case the machine file supports the platform bus device and its + * dynamically instantiable sysbus devices, this function must be called + * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the + * machine init done notifiers are called in registration reverse order. + */ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); /* Multiplication factor to convert from system clock ticks to qemu timer