From patchwork Mon Jun 16 16:17:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 31995 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 33E7C20E7A for ; Mon, 16 Jun 2014 16:20:44 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id h18sf12106375igc.2 for ; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=IJ+Nx6GjcmHOzqfcuhVtGwT9hD5hosvW3nr0XQqPFC8=; b=Hlm5Yr9VQxXVTA/ukplt3mw3Mz64KGD+ObbOZyLWwU2+ChVN9jz/boAaqub79/b+yE rERmwLY3NuyFcOhimZ1ngqsPXb64AUMzZptkUQg8uYCqbchTzSDA0cRQVJvm3Up/OhEE ZVA2iVljZdvAzkqdtr1Q7P/nYs5af2a0+wvC7z065k0Zofjg982Ohqxahd4w8U+xJx0s vDtt03fdZEhOGc6zsjacTsr7iVkfeg0DRbI1U92FW+deT0ZBenvFeGIifK1qvhs1s90x fACOPgz2batk/8BEf2mvx9drn0WhPy+jYhYExJSs3Tfi8p+kSjB6WBB1Wb4/Eecrt/8R d/VQ== X-Gm-Message-State: ALoCoQkD2zx6DYKqbOBvZGDIPZn6aqk3GGdffTjeHLCN7P2hE9fkQ5164UXYREv/Pnw+yVskviow X-Received: by 10.182.119.194 with SMTP id kw2mr171986obb.27.1402935643684; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.100 with SMTP id f91ls477275qge.65.gmail; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-Received: by 10.58.132.41 with SMTP id or9mr16853683veb.5.1402935643586; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id x14si3856001vdi.87.2014.06.16.09.20.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Jun 2014 09:20:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id il7so5280390vcb.27 for ; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr1338632vca.45.1402935643467; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp146226vcb; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) X-Received: by 10.58.29.234 with SMTP id n10mr17062550veh.16.1402935643136; Mon, 16 Jun 2014 09:20:43 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id jq7si4291066vec.22.2014.06.16.09.20.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Jun 2014 09:20:43 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwZc5-0006lO-Sd; Mon, 16 Jun 2014 16:18:29 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwZc4-0006k9-3K for xen-devel@lists.xenproject.org; Mon, 16 Jun 2014 16:18:28 +0000 Received: from [85.158.139.211:20947] by server-3.bemta-5.messagelabs.com id 97/1A-01676-3D81F935; Mon, 16 Jun 2014 16:18:27 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1402935506!10230905!1 X-Originating-IP: [74.125.82.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8219 invoked from network); 16 Jun 2014 16:18:26 -0000 Received: from mail-we0-f176.google.com (HELO mail-we0-f176.google.com) (74.125.82.176) by server-8.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jun 2014 16:18:26 -0000 Received: by mail-we0-f176.google.com with SMTP id u56so5821734wes.21 for ; Mon, 16 Jun 2014 09:18:26 -0700 (PDT) X-Received: by 10.181.8.198 with SMTP id dm6mr28646783wid.30.1402935506122; Mon, 16 Jun 2014 09:18:26 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id l45sm34836161eep.25.2014.06.16.09.18.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jun 2014 09:18:25 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jun 2014 17:17:55 +0100 Message-Id: <1402935486-29136-9-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402935486-29136-1-git-send-email-julien.grall@linaro.org> References: <1402935486-29136-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [RFC 08/19] xen/dts: Provide an helper to get a DT node from a path provided by a guest X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@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.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Signed-off-by: Julien Grall --- xen/common/device_tree.c | 19 +++++++++++++++++++ xen/include/xen/device_tree.h | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 4736e0d..fd95307 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -661,6 +662,24 @@ struct dt_device_node *dt_find_node_by_path(const char *path) return np; } +int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, + struct dt_device_node **node) +{ + char *path; + int ret; + + ret = copy_string_from_guest(u_path, &path, u_plen, + DEVICE_TREE_MAX_PATHLEN); + if ( ret ) + return ret; + + *node = dt_find_node_by_path(path); + + xfree(path); + + return (*node == NULL) ? -ESRCH : 0; +} + struct dt_device_node *dt_find_node_by_alias(const char *alias) { const struct dt_alias_prop *app; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index e413447..bb33e54 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -20,6 +20,9 @@ #define DEVICE_TREE_MAX_DEPTH 16 +/* This limit is used by the hypercalls to restrict the size of the path */ +#define DEVICE_TREE_MAX_PATHLEN 1024 + #define NR_MEM_BANKS 8 #define MOD_XEN 0 @@ -484,6 +487,20 @@ struct dt_device_node *dt_find_node_by_alias(const char *alias); */ struct dt_device_node *dt_find_node_by_path(const char *path); + +/** + * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the + * path from the guest + * + * @u_path: Xen Guest handle to the buffer containing the path + * @u_plen: Length of the buffer + * @node: TODO + * + * Return 0 if succeed otherwise -errno + */ +int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, + struct dt_device_node **node); + /** * dt_get_parent - Get a node's parent if any * @node: Node to get parent