1N/A/*
1N/A * GRUB -- GRand Unified Bootloader
1N/A * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
1N/A *
1N/A * This program is free software; you can redistribute it and/or modify
1N/A * it under the terms of the GNU General Public License as published by
1N/A * the Free Software Foundation; either version 2 of the License, or
1N/A * (at your option) any later version.
1N/A *
1N/A * This program is distributed in the hope that it will be useful,
1N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A * GNU General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU General Public License
1N/A * along with this program; if not, write to the Free Software
1N/A * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1N/A */
1N/A/*
1N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
1N/A */
1N/A
1N/A#ifndef _SYS_ZAP_IMPL_H
1N/A#define _SYS_ZAP_IMPL_H
1N/A
1N/A#define ZAP_MAGIC 0x2F52AB2ABULL
1N/A
1N/A#define MZAP_ENT_LEN 64
1N/A#define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2)
1N/A#define MZAP_MAX_BLKSHIFT SPA_128KBLOCKSHIFT
1N/A#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT)
1N/A
1N/Atypedef struct mzap_ent_phys {
1N/A uint64_t mze_value;
1N/A uint32_t mze_cd;
1N/A uint16_t mze_pad; /* in case we want to chain them someday */
1N/A char mze_name[MZAP_NAME_LEN];
1N/A} mzap_ent_phys_t;
1N/A
1N/Atypedef struct mzap_phys {
1N/A uint64_t mz_block_type; /* ZBT_MICRO */
1N/A uint64_t mz_salt;
1N/A uint64_t mz_pad[6];
1N/A mzap_ent_phys_t mz_chunk[1];
1N/A /* actually variable size depending on block size */
1N/A} mzap_phys_t;
1N/A
1N/A/*
1N/A * The (fat) zap is stored in one object. It is an array of
1N/A * 1<<FZAP_BLOCK_SHIFT byte blocks. The layout looks like one of:
1N/A *
1N/A * ptrtbl fits in first block:
1N/A * [zap_phys_t zap_ptrtbl_shift < 6] [zap_leaf_t] ...
1N/A *
1N/A * ptrtbl too big for first block:
1N/A * [zap_phys_t zap_ptrtbl_shift >= 6] [zap_leaf_t] [ptrtbl] ...
1N/A *
1N/A */
1N/A
1N/A#define ZBT_LEAF ((1ULL << 63) + 0)
1N/A#define ZBT_HEADER ((1ULL << 63) + 1)
1N/A#define ZBT_MICRO ((1ULL << 63) + 3)
1N/A/* any other values are ptrtbl blocks */
1N/A
1N/A/*
1N/A * the embedded pointer table takes up half a block:
1N/A * block size / entry size (2^3) / 2
1N/A */
1N/A#define ZAP_EMBEDDED_PTRTBL_SHIFT(zap) (FZAP_BLOCK_SHIFT(zap) - 3 - 1)
1N/A
1N/A/*
1N/A * The embedded pointer table starts half-way through the block. Since
1N/A * the pointer table itself is half the block, it starts at (64-bit)
1N/A * word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)).
1N/A */
1N/A#define ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) \
1N/A ((uint64_t *)(zap)->zap_f.zap_phys) \
1N/A [(idx) + (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap))]
1N/A
1N/A/*
1N/A * TAKE NOTE:
1N/A * If zap_phys_t is modified, zap_byteswap() must be modified.
1N/A */
1N/Atypedef struct zap_phys {
1N/A uint64_t zap_block_type; /* ZBT_HEADER */
1N/A uint64_t zap_magic; /* ZAP_MAGIC */
1N/A
1N/A struct zap_table_phys {
1N/A uint64_t zt_blk; /* starting block number */
1N/A uint64_t zt_numblks; /* number of blocks */
1N/A uint64_t zt_shift; /* bits to index it */
1N/A uint64_t zt_nextblk; /* next (larger) copy start block */
1N/A uint64_t zt_blks_copied; /* number source blocks copied */
1N/A } zap_ptrtbl;
1N/A
1N/A uint64_t zap_freeblk; /* the next free block */
1N/A uint64_t zap_num_leafs; /* number of leafs */
1N/A uint64_t zap_num_entries; /* number of entries */
1N/A uint64_t zap_salt; /* salt to stir into hash function */
1N/A uint64_t zap_normflags; /* flags for u8_textprep_str() */
1N/A uint64_t zap_flags; /* zap_flag_t */
1N/A /*
1N/A * This structure is followed by padding, and then the embedded
1N/A * pointer table. The embedded pointer table takes up second
1N/A * half of the block. It is accessed using the
1N/A * ZAP_EMBEDDED_PTRTBL_ENT() macro.
1N/A */
1N/A} zap_phys_t;
1N/A
1N/A#endif /* _SYS_ZAP_IMPL_H */