From patchwork Tue Dec 19 03:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Goel X-Patchwork-Id: 122339 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3622477qgn; Mon, 18 Dec 2017 19:20:25 -0800 (PST) X-Google-Smtp-Source: ACJfBotyZF1ZFArdXNNCjXfT2W/pEcDdbyGaVbgsNEUsnJNOJ4851Fs08u2h5snduMyFrkzmXmCt X-Received: by 10.107.167.77 with SMTP id q74mr2269110ioe.171.1513653625593; Mon, 18 Dec 2017 19:20:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513653625; cv=none; d=google.com; s=arc-20160816; b=obz1EwklBYk7cqN/faLebtMLTAsGBY8bVoHXZnRhTN70n9pRgy3Ri/llsmcDxv24xc dQU4LKYili4VjzZk9YmtSklj2O5xucu2vVKUtSTs48R4+4AvxHV1VOQHKXH15Bh1ow4c +xQLaR+jic1Ok//LdkG8qc5yabm6FqAKBbp2AoxQTbT8GR27WrMwVhj+btv9fSkJkGDf AL+ln8ypyQtPFjr9CGHVR2MeynioQ/wEIUV44vQlN0ZEKNsd/xIcqGecYlOGmeZoSv8s FWPFxjUZ5vr0pgJqcu+x1oFLaEX3X79PLUOaY/V23qeCJBX8ZZXwqF7is40Qyw+0emYT 2aXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-unsubscribe:list-id:precedence:subject:cc :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=b1ZKKMBFh4WUyFAulzZUSPvXmEihDJDz0WaaX++HwFQ=; b=fI5b8NsieUydyT/W/Xc4Lv3bnzgsD1LHYz2fUHWQDioe+4YbpqRemwz2Spq3dyBZNK chOL6Ck3Th3YHseR/f+H7V0jQT3TI3MXakQqT6CPTKrLMcZDpKkDt1lu4wuiGHeGZVyc y3zm+nOK1dQkqEa60Ks7JEMJuu7/b/7LCQ1aenbMIsehB35h7uvphSoN6E5+6oDatZUJ OFb0eC1U1bPbnKfdWWy5/e6QoEfIjnQEyQoqj4Isf6oScIooZBNyqoMhJXmLo7g85kp1 DXHIWdI4ytx/ocpwV0PMgSnOmt+MTY+ugyfTHv1az8/jGZ/pQvjiLT7W6rsFpvAmJYKo i2QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EPSlwQFT; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z8si9135040iob.152.2017.12.18.19.20.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 19:20:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EPSlwQFT; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR8Q6-00070Z-5V; Tue, 19 Dec 2017 03:18:18 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR8Q5-00070E-Jb for xen-devel@lists.xenproject.org; Tue, 19 Dec 2017 03:18:17 +0000 X-Inumbo-ID: 27bd68f8-e46b-11e7-b4a6-bc764e045a96 Received: from mail-pl0-f66.google.com (unknown [209.85.160.66]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 27bd68f8-e46b-11e7-b4a6-bc764e045a96; Tue, 19 Dec 2017 04:17:34 +0100 (CET) Received: by mail-pl0-f66.google.com with SMTP id b96so6149386pli.2 for ; Mon, 18 Dec 2017 19:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yOBD9+dBvAFxcr+ElCdoAfkZ3/2ird9Zs+SGgOniAdo=; b=EPSlwQFToYLxnT6TUm0wIhqk+syBhB6qiNk4QVhYRhQ6OFt3lO1MYU/mRXKfRqD0cP 8a4sZ4gI+aGNkbE0QJdeFmfi5DJ7O7QqaZyTTTrKTuk+9o/rrJJMuG6yxVSw7OWl4Khl L9KU9D/4ys7mtzdcl33vlwo9/7MQd+jH9/8sc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yOBD9+dBvAFxcr+ElCdoAfkZ3/2ird9Zs+SGgOniAdo=; b=MZ+cxuJkZsrbcfi0lkrg1YLxNEmtBjM2/A8sDErE8zOtpje/5gvZRDCVglKdN47DfS XuOPMuKwZziSPU4WarHZbK1BnjgSFh6KLQyCCvJwFwe+9vp3G7F/4h9KVJPaF1zU7s6k 3RRUEsQL36EvKSKBsWe8Revvh66nTaFBDFAALIr1hkWaqMj6jEHHH17REBZNpS8xKVWP Vmc8TEJDNsVJSbt8/iuPPcvJzcTA3RNrjZ8QRlYYUA9idbcGCmp5WeGkd996Pw1u8XXa vYkFF8HyWn1X5eVVaNS8z5hJxZYLFRuQMbNPQRoY718M6VIwCoWAdZYiLfIMryIFmsFc m8aw== X-Gm-Message-State: AKGB3mLBzQUf957nwMNZhTKTIOSuu4r4TBKOwc1TdTHQUjH5IuOHA3ZN ogOZkIaq67Zo8xtxeg4tIqyKwD9XUBCsnA== X-Received: by 10.159.230.16 with SMTP id u16mr1801500plq.41.1513653435514; Mon, 18 Dec 2017 19:17:15 -0800 (PST) Received: from sameer-ubuntu-book.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 84sm28289917pfp.180.2017.12.18.19.17.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 19:17:15 -0800 (PST) From: Sameer Goel To: xen-devel@lists.xenproject.org, julien.grall@arm.com, mjaggi@caviumnetworks.com Date: Mon, 18 Dec 2017 20:16:58 -0700 Message-Id: <20171219031703.23420-4-sameer.goel@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171219031703.23420-1-sameer.goel@linaro.org> References: <20171219031703.23420-1-sameer.goel@linaro.org> MIME-Version: 1.0 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, george.dunlap@eu.citrix.com, Andrew.Cooper3@citrix.com, andre.przywara@linaro.org, jbeulich@suse.com, Sameer Goel , Ian.Jackson@citrix.com, nd@arm.com, shankerd@codeaurora.org Subject: [Xen-devel] [RFC v4 3/8] xen/linux_compat: Add a Linux compat header X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For porting files directly from Linux it is useful to have a function mapping definitions from Linux to Xen. This file adds common API functions and other defines that are needed for porting arm SMMU drivers. Signed-off-by: Sameer Goel --- xen/include/xen/linux_compat.h | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 xen/include/xen/linux_compat.h diff --git a/xen/include/xen/linux_compat.h b/xen/include/xen/linux_compat.h new file mode 100644 index 0000000000..174d0390e5 --- /dev/null +++ b/xen/include/xen/linux_compat.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * include/xen/linux_compat.h + * + * Compatibility defines for porting code from Linux to Xen + * + * Copyright (c) 2017 Linaro Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#ifndef __XEN_LINUX_COMPAT_H__ +#define __XEN_LINUX_COMPAT_H__ + +#include + +typedef paddr_t phys_addr_t; +typedef paddr_t dma_addr_t; + +typedef unsigned int gfp_t; +#define GFP_KERNEL 0 +#define __GFP_ZERO 0 + +/* Alias to Xen device tree helpers */ +#define device_node dt_device_node +#define of_phandle_args dt_phandle_args +#define of_device_id dt_device_match +#define of_match_node dt_match_node +#define of_property_read_u32(np, pname, out) (!dt_property_read_u32(np, pname, out)) +#define of_property_read_bool dt_property_read_bool +#define of_parse_phandle_with_args dt_parse_phandle_with_args + +/* Helpers for IRQ functions */ +#define free_irq release_irq + +enum irqreturn { + IRQ_NONE = (0 << 0), + IRQ_HANDLED = (1 << 0), + IRQ_WAKE_THREAD = (2 << 0), +}; + +typedef enum irqreturn irqreturn_t; + +/* Device logger functions */ +#define dev_print(dev, lvl, fmt, ...) \ + printk(lvl fmt, ## __VA_ARGS__) + +#define dev_dbg(dev, fmt, ...) dev_print(dev, XENLOG_DEBUG, fmt, ## __VA_ARGS__) +#define dev_notice(dev, fmt, ...) dev_print(dev, XENLOG_INFO, fmt, ## __VA_ARGS__) +#define dev_warn(dev, fmt, ...) dev_print(dev, XENLOG_WARNING, fmt, ## __VA_ARGS__) +#define dev_err(dev, fmt, ...) dev_print(dev, XENLOG_ERR, fmt, ## __VA_ARGS__) +#define dev_info(dev, fmt, ...) dev_print(dev, XENLOG_INFO, fmt, ## __VA_ARGS__) + +#define dev_err_ratelimited(dev, fmt, ...) \ + dev_print(dev, XENLOG_ERR, fmt, ## __VA_ARGS__) + +#define dev_name(dev) dt_node_full_name(dev_to_dt(dev)) + +/* Alias to Xen allocation helpers */ +#define kfree xfree +#define kmalloc(size, flags) _xmalloc(size, sizeof(void *)) +#define kzalloc(size, flags) _xzalloc(size, sizeof(void *)) +#define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *)) +#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n) + +/* Alias to Xen time functions */ +#define ktime_t s_time_t +#define ktime_add_us(t,i) (NOW() + MICROSECS(i)) +#define ktime_compare(t,i) (NOW() > (i)) + +#endif /* __XEN_LINUX_COMPAT_H__ */