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/>.
21 #include <grub/file.h>
23 #include <grub/misc.h>
24 #include <grub/disk.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>
42 fletcher_2(const void *buf
, grub_uint64_t size
, grub_zfs_endian_t endian
,
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
);
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
);
64 fletcher_4 (const void *buf
, grub_uint64_t size
, grub_zfs_endian_t endian
,
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
);;
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
);