From patchwork Sun May 17 20:04:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48656 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 50F5521411 for ; Sun, 17 May 2015 20:07:34 +0000 (UTC) Received: by lagv1 with SMTP id v1sf4098899lag.1 for ; Sun, 17 May 2015 13:07:33 -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:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=oC5iCCGnirDR06ZSQbqF852uaQhnnaeGWgaxwXhlux8=; b=PNZEDIRr+xoqcpg8efBCEu2TcMX5G6c8xNPuuqO2LVc62knumAYFuWYii8GJ1GyE87 SMSs/WGrlKZ6vFdlj/DPhIG41ZioIkw2O4spnc2NVqp7H+ZgvLTyTPgpwL0/PlbSZU6o Y3MymuX0C27btx51BHdvVErU/u95WCw6Jm5lNZ8b8/UCWwOUXS8ELsuGTPSQCu4yvR2W IKzKuACID9ndSTBeht0mCefbSYcAfcAzxwu0oGtiA8pDRsJSbFm52q3agvYkthKjSlF1 21ltUgV0TxVG6a17yLRRP9Qh33K7n7HI0LTb1ngfbylmkRS+aHRgfa2EXe4prb8vKNZG C1Eg== X-Gm-Message-State: ALoCoQmmWM3VUk+jWX9VkxKVwt2V7VP/vBKrLduVCLAE73YN9RLO/JU3fwF4BCmMuAMkUjeaC8DW X-Received: by 10.152.8.17 with SMTP id n17mr15258867laa.0.1431893253261; Sun, 17 May 2015 13:07:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls694172laj.72.gmail; Sun, 17 May 2015 13:07:33 -0700 (PDT) X-Received: by 10.112.171.68 with SMTP id as4mr14839179lbc.64.1431893252987; Sun, 17 May 2015 13:07:32 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id sa9si5321441lbb.132.2015.05.17.13.07.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:07:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by laat2 with SMTP id t2so191075587laa.1 for ; Sun, 17 May 2015 13:07:32 -0700 (PDT) X-Received: by 10.112.13.6 with SMTP id d6mr14533045lbc.117.1431893252897; Sun, 17 May 2015 13:07:32 -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.112.108.230 with SMTP id hn6csp3508352lbb; Sun, 17 May 2015 13:07:32 -0700 (PDT) X-Received: by 10.52.135.50 with SMTP id pp18mr9201192vdb.73.1431893251438; Sun, 17 May 2015 13:07:31 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id hf2si5806412vdb.37.2015.05.17.13.07.30 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:07:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) 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 1Yu4pk-0003uw-1f; Sun, 17 May 2015 20:06:48 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4pi-0003rw-Gf for xen-devel@lists.xen.org; Sun, 17 May 2015 20:06:46 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id 69/46-02785-5D4F8555; Sun, 17 May 2015 20:06:45 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1431893203!17850925!1 X-Originating-IP: [209.85.192.171] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20871 invoked from network); 17 May 2015 20:06:44 -0000 Received: from mail-pd0-f171.google.com (HELO mail-pd0-f171.google.com) (209.85.192.171) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:06:44 -0000 Received: by pdbnk13 with SMTP id nk13so21912827pdb.1 for ; Sun, 17 May 2015 13:06:43 -0700 (PDT) X-Received: by 10.70.134.133 with SMTP id pk5mr38089525pdb.133.1431893203006; Sun, 17 May 2015 13:06:43 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.06.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:06:42 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:34:02 +0530 Message-Id: <1431893048-5214-36-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 35/41] arm : acpi add helper function to calculate crc32 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: parth.dixit@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.215.43 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: Add helper functions for calculating crc32. This is required for computing crc of efi table. These functions are copied from here http://mirrors.neusoft.edu.cn/rpi-kernel/lib/xz/xz_crc32.c Original author's are Lasse Collin and Igor Pavlov. Signed-off-by: Parth Dixit --- xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 36b072b..0ad70c1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1227,6 +1227,39 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, } #ifdef CONFIG_ACPI +static uint32_t xz_crc32_table[256]; + +static void xz_crc32_init(void) +{ + const uint32_t poly = 0xEDB88320; + + uint32_t i; + uint32_t j; + uint32_t r; + + for (i = 0; i < 256; ++i) { + r = i; + for (j = 0; j < 8; ++j) + r = (r >> 1) ^ (poly & ~((r & 1) - 1)); + + xz_crc32_table[i] = r; + } + + return; +} + +static uint32_t xz_crc32(uint8_t *buf, size_t size, uint32_t crc) +{ + crc = ~crc; + + while (size != 0) { + crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8); + --size; + } + + return ~crc; +} + static int create_xen_acpi_tables(struct kernel_info *kinfo, struct domain *d, struct membank tbl_add[]) {