From patchwork Fri Sep 13 12:49:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 20042 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 761BF28E9E for ; Fri, 13 Sep 2013 12:50:01 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf1172277qcx.0 for ; Fri, 13 Sep 2013 05:50:01 -0700 (PDT) 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=jkvR71c8Q0uA64j9btzNiloUpR72Gn6bv2dNzytysf4=; b=Et2YMK755zZmV2EpcvRp1JzSGbOCwRzthyeIyhf8BRcsJwcM4PurvcLuqMn/3L7CKr oDiDGZxqfE0YqynnYlxlgQUoi7bH702tnY+05GgwXVztE9O6O6tkWU3T4mQ0Wumlj6My 9jpfKyyPAWGn6injqbimfnnFt/ZVeaqZZdrCj6k1uhWvMPk8EfcIZxJx3+25olpoe50z AeX97DxEDS6skRe5MgQ9vz502IJa6IInDcT41kKK+tl7iaIiggN7pK4blPstb2jtzoCD +nufMwOx+uAMVUEyEhAVG+/fohCkxaHHCZunErFi14q2PfQy0jP5cuH46iZ05A+naoQg hoXQ== X-Gm-Message-State: ALoCoQljNzQmNquLOhJyn6zPkWFTiLXasd8wFMPc7+cluTn2ZTsgQWsvREDqcZegIkZKMfFundS2 X-Received: by 10.236.2.5 with SMTP id 5mr4920932yhe.23.1379076601080; Fri, 13 Sep 2013 05:50:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls1168215qeo.28.gmail; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) X-Received: by 10.58.152.3 with SMTP id uu3mr11823763veb.16.1379076600860; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by mx.google.com with ESMTPS id vr9si3066595vcb.126.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:50:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.48; Received: by mail-vb0-f48.google.com with SMTP id w16so858085vbf.21 for ; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) X-Received: by 10.52.74.100 with SMTP id s4mr543406vdv.35.1379076600761; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) 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.220.174.196 with SMTP id u4csp78786vcz; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) X-Received: by 10.14.0.3 with SMTP id 3mr2459864eea.62.1379076599445; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com [209.85.215.172]) by mx.google.com with ESMTPS id u46si3778889eeg.136.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.172 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.172; Received: by mail-ea0-f172.google.com with SMTP id r16so557766ead.17 for ; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) X-Received: by 10.15.98.9 with SMTP id bi9mr2744032eeb.67.1379076598919; Fri, 13 Sep 2013 05:49:58 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id p5sm14678420eeg.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, andre.przywara@linaro.org, Julien Grall Subject: [PATCH v4 17/27] xen/arm: Create a fake GIC node in dom0 device tree Date: Fri, 13 Sep 2013 13:49:24 +0100 Message-Id: <1379076574-28316-18-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> References: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Recreate the GIC node and remove hypervisor specific ranges (vgic and hypervisor controls). Signed-off-by: Julien Grall --- Changes in v3: - Use DT_MATCH_GIC --- xen/arch/arm/domain_build.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 036155e..87382d5 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -439,6 +439,79 @@ static int make_cpus_node(const struct domain *d, void *fdt, return res; } +static int make_gic_node(const struct domain *d, void *fdt, + const struct dt_device_node *parent) +{ + const struct dt_device_node *gic = dt_interrupt_controller; + const void *compatible = NULL; + u32 len; + __be32 *new_cells, *tmp; + int res = 0; + + DPRINT("Create gic node\n"); + + compatible = dt_get_property(gic, "compatible", &len); + if ( !compatible ) + { + dprintk(XENLOG_ERR, "Can't find compatible property for the gic node\n"); + return -FDT_ERR_XEN(ENOENT); + } + + res = fdt_begin_node(fdt, "interrupt-controller"); + if ( res ) + return res; + + res = fdt_property(fdt, "compatible", compatible, len); + if ( res ) + return res; + + res = fdt_property_cell(fdt, "#interrupt-cells", 3); + if ( res ) + return res; + + res = fdt_property(fdt, "interrupt-controller", NULL, 0); + + if ( res ) + return res; + + len = dt_cells_to_size(dt_n_addr_cells(parent) + dt_n_size_cells(parent)); + len *= 2; + new_cells = xzalloc_bytes(dt_cells_to_size(len)); + if ( new_cells == NULL ) + return -FDT_ERR_XEN(ENOMEM); + + tmp = new_cells; + DPRINT(" Set Distributor Base 0x%"PRIpaddr"-0x%"PRIpaddr"\n", + d->arch.vgic.dbase, d->arch.vgic.dbase + PAGE_SIZE - 1); + dt_set_range(&tmp, parent, d->arch.vgic.dbase, PAGE_SIZE); + + DPRINT(" Set Cpu Base 0x%"PRIpaddr" size = 0x%"PRIpaddr"\n", + d->arch.vgic.cbase, d->arch.vgic.cbase + (PAGE_SIZE * 2) - 1); + dt_set_range(&tmp, parent, d->arch.vgic.cbase, PAGE_SIZE * 2); + + res = fdt_property(fdt, "reg", new_cells, len); + xfree(new_cells); + + if ( res ) + return res; + + /* + * The value of the property "phandle" in the property "interrupts" + * to know on which interrupt controller the interrupt is wired. + */ + if ( gic->phandle ) + { + DPRINT(" Set phandle = 0x%x\n", gic->phandle); + res = fdt_property_cell(fdt, "phandle", gic->phandle); + if ( res ) + return res; + } + + res = fdt_end_node(fdt); + + return res; +} + /* Map the device in the domain */ static int map_device(struct domain *d, const struct dt_device_node *dev) { @@ -528,6 +601,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, DT_MATCH_COMPATIBLE("xen,multiboot-module"), DT_MATCH_COMPATIBLE("arm,psci"), DT_MATCH_PATH("/cpus"), + DT_MATCH_GIC, { /* sentinel */ }, }; const struct dt_device_node *child; @@ -601,6 +675,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, res = make_cpus_node(d, kinfo->fdt, np); if ( res ) return res; + + res = make_gic_node(d, kinfo->fdt, np); + if ( res ) + return res; } res = fdt_end_node(kinfo->fdt);