]> git.ipfire.org Git - thirdparty/u-boot.git/blame - fs/zfs/zfs_fletcher.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / fs / zfs / zfs_fletcher.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
4d3c95f5
JL
2/*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
4d3c95f5
JL
5 */
6/*
7 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
8 * Use is subject to license terms.
9 */
10
d678a59d 11#include <common.h>
4d3c95f5
JL
12#include <malloc.h>
13#include <linux/stat.h>
14#include <linux/time.h>
15#include <linux/ctype.h>
16#include <asm/byteorder.h>
17#include "zfs_common.h"
18
19#include <zfs/zfs.h>
20#include <zfs/zio.h>
21#include <zfs/dnode.h>
22#include <zfs/uberblock_impl.h>
23#include <zfs/vdev_impl.h>
24#include <zfs/zio_checksum.h>
25#include <zfs/zap_impl.h>
26#include <zfs/zap_leaf.h>
27#include <zfs/zfs_znode.h>
28#include <zfs/dmu.h>
29#include <zfs/dmu_objset.h>
30#include <zfs/dsl_dir.h>
31#include <zfs/dsl_dataset.h>
32
33void
34fletcher_2_endian(const void *buf, uint64_t size,
35 zfs_endian_t endian,
36 zio_cksum_t *zcp)
37{
38 const uint64_t *ip = buf;
39 const uint64_t *ipend = ip + (size / sizeof(uint64_t));
40 uint64_t a0, b0, a1, b1;
41
42 for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
43 a0 += zfs_to_cpu64(ip[0], endian);
44 a1 += zfs_to_cpu64(ip[1], endian);
45 b0 += a0;
46 b1 += a1;
47 }
48
49 zcp->zc_word[0] = cpu_to_zfs64(a0, endian);
50 zcp->zc_word[1] = cpu_to_zfs64(a1, endian);
51 zcp->zc_word[2] = cpu_to_zfs64(b0, endian);
52 zcp->zc_word[3] = cpu_to_zfs64(b1, endian);
53}
54
55void
56fletcher_4_endian(const void *buf, uint64_t size, zfs_endian_t endian,
57 zio_cksum_t *zcp)
58{
59 const uint32_t *ip = buf;
60 const uint32_t *ipend = ip + (size / sizeof(uint32_t));
61 uint64_t a, b, c, d;
62
63 for (a = b = c = d = 0; ip < ipend; ip++) {
64 a += zfs_to_cpu32(ip[0], endian);
65 b += a;
66 c += b;
67 d += c;
68 }
69
70 zcp->zc_word[0] = cpu_to_zfs64(a, endian);
71 zcp->zc_word[1] = cpu_to_zfs64(b, endian);
72 zcp->zc_word[2] = cpu_to_zfs64(c, endian);
73 zcp->zc_word[3] = cpu_to_zfs64(d, endian);
74}