Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / fs / zfs / zfs_fletcher.c
blob7d27b053dc7ab958940b31d9c6940d6ec804a84e
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
4 * Copyright 2007 Sun Microsystems, Inc.
6 * GRUB is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/err.h>
21 #include <grub/file.h>
22 #include <grub/mm.h>
23 #include <grub/misc.h>
24 #include <grub/disk.h>
25 #include <grub/dl.h>
26 #include <grub/types.h>
27 #include <grub/zfs/zfs.h>
28 #include <grub/zfs/zio.h>
29 #include <grub/zfs/dnode.h>
30 #include <grub/zfs/uberblock_impl.h>
31 #include <grub/zfs/vdev_impl.h>
32 #include <grub/zfs/zio_checksum.h>
33 #include <grub/zfs/zap_impl.h>
34 #include <grub/zfs/zap_leaf.h>
35 #include <grub/zfs/zfs_znode.h>
36 #include <grub/zfs/dmu.h>
37 #include <grub/zfs/dmu_objset.h>
38 #include <grub/zfs/dsl_dir.h>
39 #include <grub/zfs/dsl_dataset.h>
41 void
42 fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
43 zio_cksum_t *zcp)
45 const grub_uint64_t *ip = buf;
46 const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t));
47 grub_uint64_t a0, b0, a1, b1;
49 for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2)
51 a0 += grub_zfs_to_cpu64 (ip[0], endian);
52 a1 += grub_zfs_to_cpu64 (ip[1], endian);
53 b0 += a0;
54 b1 += a1;
57 zcp->zc_word[0] = grub_cpu_to_zfs64 (a0, endian);
58 zcp->zc_word[1] = grub_cpu_to_zfs64 (a1, endian);
59 zcp->zc_word[2] = grub_cpu_to_zfs64 (b0, endian);
60 zcp->zc_word[3] = grub_cpu_to_zfs64 (b1, endian);
63 void
64 fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
65 zio_cksum_t *zcp)
67 const grub_uint32_t *ip = buf;
68 const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t));
69 grub_uint64_t a, b, c, d;
71 for (a = b = c = d = 0; ip < ipend; ip++)
73 a += grub_zfs_to_cpu32 (ip[0], endian);;
74 b += a;
75 c += b;
76 d += c;
79 zcp->zc_word[0] = grub_cpu_to_zfs64 (a, endian);
80 zcp->zc_word[1] = grub_cpu_to_zfs64 (b, endian);
81 zcp->zc_word[2] = grub_cpu_to_zfs64 (c, endian);
82 zcp->zc_word[3] = grub_cpu_to_zfs64 (d, endian);