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 2007 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A#ifndef _SYS_ZAP_LEAF_H
1N/A#define _SYS_ZAP_LEAF_H
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#define ZAP_LEAF_MAGIC 0x2AB1EAF
1N/A
1N/A/* chunk size = 24 bytes */
1N/A#define ZAP_LEAF_CHUNKSIZE 24
1N/A
1N/A/*
1N/A * The amount of space within the chunk available for the array is:
1N/A * chunk size - space for type (1) - space for next pointer (2)
1N/A */
1N/A#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
1N/A
1N/Atypedef enum zap_chunk_type {
1N/A ZAP_CHUNK_FREE = 253,
1N/A ZAP_CHUNK_ENTRY = 252,
1N/A ZAP_CHUNK_ARRAY = 251,
1N/A ZAP_CHUNK_TYPE_MAX = 250
1N/A} zap_chunk_type_t;
1N/A
1N/A/*
1N/A * TAKE NOTE:
1N/A * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified.
1N/A */
1N/Atypedef struct zap_leaf_phys {
1N/A struct zap_leaf_header {
1N/A uint64_t lh_block_type; /* ZBT_LEAF */
1N/A uint64_t lh_pad1;
1N/A uint64_t lh_prefix; /* hash prefix of this leaf */
1N/A uint32_t lh_magic; /* ZAP_LEAF_MAGIC */
1N/A uint16_t lh_nfree; /* number free chunks */
1N/A uint16_t lh_nentries; /* number of entries */
1N/A uint16_t lh_prefix_len; /* num bits used to id this */
1N/A
1N/A/* above is accessable to zap, below is zap_leaf private */
1N/A
1N/A uint16_t lh_freelist; /* chunk head of free list */
1N/A uint8_t lh_pad2[12];
1N/A } l_hdr; /* 2 24-byte chunks */
1N/A
1N/A /*
1N/A * The header is followed by a hash table with
1N/A * ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is
1N/A * followed by an array of ZAP_LEAF_NUMCHUNKS(zap)
1N/A * zap_leaf_chunk structures. These structures are accessed
1N/A * with the ZAP_LEAF_CHUNK() macro.
1N/A */
1N/A
1N/A uint16_t l_hash[1];
1N/A} zap_leaf_phys_t;
1N/A
1N/Atypedef union zap_leaf_chunk {
1N/A struct zap_leaf_entry {
1N/A uint8_t le_type; /* always ZAP_CHUNK_ENTRY */
1N/A uint8_t le_int_size; /* size of ints */
1N/A uint16_t le_next; /* next entry in hash chain */
1N/A uint16_t le_name_chunk; /* first chunk of the name */
1N/A uint16_t le_name_length; /* bytes in name, incl null */
1N/A uint16_t le_value_chunk; /* first chunk of the value */
1N/A uint16_t le_value_length; /* value length in ints */
1N/A uint32_t le_cd; /* collision differentiator */
1N/A uint64_t le_hash; /* hash value of the name */
1N/A } l_entry;
1N/A struct zap_leaf_array {
1N/A uint8_t la_type; /* always ZAP_CHUNK_ARRAY */
1N/A uint8_t la_array[ZAP_LEAF_ARRAY_BYTES];
1N/A uint16_t la_next; /* next blk or CHAIN_END */
1N/A } l_array;
1N/A struct zap_leaf_free {
1N/A uint8_t lf_type; /* always ZAP_CHUNK_FREE */
1N/A uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES];
1N/A uint16_t lf_next; /* next in free list, or CHAIN_END */
1N/A } l_free;
1N/A} zap_leaf_chunk_t;
1N/A
1N/A#endif /* _SYS_ZAP_LEAF_H */