From patchwork Tue Sep 10 14:49:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19920 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 52552246A4 for ; Tue, 10 Sep 2013 14:49:50 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e13sf8873993vbg.4 for ; Tue, 10 Sep 2013 07:49:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=PCuYBbZPEc48vMmaFN5UUgtPxnyxRPd0/FpcI3y8q3c=; b=giATtigkHzlBBmPuK/uABAWm5kAfRE4+QKYvp8Yju847LamRXYyqs+N7CSKJuPdPRt Dbdi5mPVdYtfTMGJONpX0NJ1ZOUBuKbdleoQkk8DOOfpQDLrlhVoXq7F1f801Dhdk/EM KeE8dSDiv4Xt+EoCmTvdv8EY95/Of3KKJDuiUGwQTKs0wF/EQZKAoU9M+sQOnNhF8yqT W2IO/aMb7LePgxYRAtTcvoB3FQyF/DcmyTWvP8Fnc9GWmL6Gqr2l6Dcae0D5yQO2c1X3 nnWIVzFGLFcULHyEC4ouLzpUTTdRRCB64poh40z3kSjkgq+SxC16iAir0RGJHu68ACTZ Wc7g== X-Received: by 10.236.19.225 with SMTP id n61mr8400377yhn.8.1378824590132; Tue, 10 Sep 2013 07:49:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.231 with SMTP id ln7ls2240212qeb.57.gmail; Tue, 10 Sep 2013 07:49:49 -0700 (PDT) X-Received: by 10.58.19.233 with SMTP id i9mr182936vee.36.1378824589899; Tue, 10 Sep 2013 07:49:49 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id st7si3771685vdc.16.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ib11so5114803vcb.14 for ; Tue, 10 Sep 2013 07:49:49 -0700 (PDT) X-Gm-Message-State: ALoCoQnKx79qoW8ppveqCoGzSHAS6I6W3a2urIT2nRzvcsnG7L8AZdwy5k76tLAD3flolT/Oa/AE X-Received: by 10.220.174.200 with SMTP id u8mr23330814vcz.6.1378824589817; Tue, 10 Sep 2013 07:49:49 -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 u4csp4671vcz; Tue, 10 Sep 2013 07:49:49 -0700 (PDT) X-Received: by 10.14.210.8 with SMTP id t8mr39213054eeo.39.1378824588475; Tue, 10 Sep 2013 07:49:48 -0700 (PDT) Received: from mail-ee0-f43.google.com (mail-ee0-f43.google.com [74.125.83.43]) by mx.google.com with ESMTPS id z8si15289364eee.263.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:48 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.43 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.43; Received: by mail-ee0-f43.google.com with SMTP id e52so3888873eek.2 for ; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) X-Received: by 10.14.100.138 with SMTP id z10mr3258871eef.74.1378824585293; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id i1sm31911644eeg.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:44 -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 v3 17/27] xen/arm: Create a fake GIC node in dom0 device tree Date: Tue, 10 Sep 2013 15:49:05 +0100 Message-Id: <1378824555-16564-18-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378824555-16564-1-git-send-email-julien.grall@linaro.org> References: <1378824555-16564-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.220.169 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 0f4d10e..9865ca4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -418,6 +418,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) { @@ -507,6 +580,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; @@ -580,6 +654,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);