1b1b8ab3lling/*
2b1b8ab3lling *  GRUB  --  GRand Unified Bootloader
3b1b8ab3lling *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
4b1b8ab3lling *
5b1b8ab3lling *  This program is free software; you can redistribute it and/or modify
6b1b8ab3lling *  it under the terms of the GNU General Public License as published by
7b1b8ab3lling *  the Free Software Foundation; either version 2 of the License, or
8b1b8ab3lling *  (at your option) any later version.
9b1b8ab3lling *
10b1b8ab3lling *  This program is distributed in the hope that it will be useful,
11b1b8ab3lling *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12b1b8ab3lling *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13b1b8ab3lling *  GNU General Public License for more details.
14b1b8ab3lling *
15b1b8ab3lling *  You should have received a copy of the GNU General Public License
16b1b8ab3lling *  along with this program; if not, write to the Free Software
17b1b8ab3lling *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18b1b8ab3lling */
19b1b8ab3lling/*
206e1f5caNeil Perrin * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
21b1b8ab3lling * Use is subject to license terms.
22b1b8ab3lling */
23a6f561bSašo Kiselkov/*
24a6f561bSašo Kiselkov * Copyright 2013 by Saso Kiselkov. All rights reserved.
25a6f561bSašo Kiselkov */
26b1b8ab3lling
27b1b8ab3lling#ifndef _ZIO_H
28b1b8ab3lling#define	_ZIO_H
29b1b8ab3lling
306e1f5caNeil Perrin#define	ZEC_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
31b1b8ab3lling
326e1f5caNeil Perrintypedef struct zio_eck {
336e1f5caNeil Perrin	uint64_t	zec_magic;	/* for validation, endianness	*/
346e1f5caNeil Perrin	zio_cksum_t	zec_cksum;	/* 256-bit checksum		*/
356e1f5caNeil Perrin} zio_eck_t;
36b1b8ab3lling
37b1b8ab3lling/*
38b1b8ab3lling * Gang block headers are self-checksumming and contain an array
39b1b8ab3lling * of block pointers.
40b1b8ab3lling */
41b1b8ab3lling#define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
42b1b8ab3lling#define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
436e1f5caNeil Perrin	sizeof (zio_eck_t)) / sizeof (blkptr_t))
44b1b8ab3lling#define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
456e1f5caNeil Perrin	sizeof (zio_eck_t) - \
46b1b8ab3lling	(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
47b1b8ab3lling	sizeof (uint64_t))
48b1b8ab3lling
49b1b8ab3lling#define	ZIO_GET_IOSIZE(zio)	\
50b1b8ab3lling	(BP_IS_GANG((zio)->io_bp) ? \
51b1b8ab3lling	SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
52b1b8ab3lling
53b1b8ab3llingtypedef struct zio_gbh {
54b1b8ab3lling	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
55b1b8ab3lling	uint64_t		zg_filler[SPA_GBH_FILLER];
566e1f5caNeil Perrin	zio_eck_t		zg_tail;
57b1b8ab3lling} zio_gbh_phys_t;
58b1b8ab3lling
59b1b8ab3llingenum zio_checksum {
60b1b8ab3lling	ZIO_CHECKSUM_INHERIT = 0,
61b1b8ab3lling	ZIO_CHECKSUM_ON,
62b1b8ab3lling	ZIO_CHECKSUM_OFF,
63b1b8ab3lling	ZIO_CHECKSUM_LABEL,
64b1b8ab3lling	ZIO_CHECKSUM_GANG_HEADER,
65b1b8ab3lling	ZIO_CHECKSUM_ZILOG,
66b1b8ab3lling	ZIO_CHECKSUM_FLETCHER_2,
67b1b8ab3lling	ZIO_CHECKSUM_FLETCHER_4,
68b1b8ab3lling	ZIO_CHECKSUM_SHA256,
696e1f5caNeil Perrin	ZIO_CHECKSUM_ZILOG2,
7045818eeMatthew Ahrens	ZIO_CHECKSUM_NOPARITY,
7145818eeMatthew Ahrens	ZIO_CHECKSUM_SHA512,
7245818eeMatthew Ahrens	ZIO_CHECKSUM_SKEIN,
7345818eeMatthew Ahrens	ZIO_CHECKSUM_EDONR,
74b1b8ab3lling	ZIO_CHECKSUM_FUNCTIONS
75b1b8ab3lling};
76b1b8ab3lling
77b1b8ab3llingenum zio_compress {
78b1b8ab3lling	ZIO_COMPRESS_INHERIT = 0,
79b1b8ab3lling	ZIO_COMPRESS_ON,
80b1b8ab3lling	ZIO_COMPRESS_OFF,
81b1b8ab3lling	ZIO_COMPRESS_LZJB,
82b1b8ab3lling	ZIO_COMPRESS_EMPTY,
83a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_1,
84a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_2,
85a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_3,
86a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_4,
87a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_5,
88a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_6,
89a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_7,
90a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_8,
91a6f561bSašo Kiselkov	ZIO_COMPRESS_GZIP_9,
92a6f561bSašo Kiselkov	ZIO_COMPRESS_ZLE,
93a6f561bSašo Kiselkov	ZIO_COMPRESS_LZ4,
94b1b8ab3lling	ZIO_COMPRESS_FUNCTIONS
95b1b8ab3lling};
96b1b8ab3lling
97b1b8ab3lling#endif	/* _ZIO_H */
98