1 | /* |
---|
2 | * GRUB -- GRand Unified Bootloader |
---|
3 | * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
---|
4 | * |
---|
5 | * GRUB is free software; you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU General Public License as published by |
---|
7 | * the Free Software Foundation; either version 3 of the License, or |
---|
8 | * (at your option) any later version. |
---|
9 | * |
---|
10 | * GRUB is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with GRUB. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | */ |
---|
18 | /* |
---|
19 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
---|
20 | * Use is subject to license terms. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _SYS_ZAP_LEAF_H |
---|
24 | #define _SYS_ZAP_LEAF_H |
---|
25 | |
---|
26 | #define ZAP_LEAF_MAGIC 0x2AB1EAF |
---|
27 | |
---|
28 | /* chunk size = 24 bytes */ |
---|
29 | #define ZAP_LEAF_CHUNKSIZE 24 |
---|
30 | |
---|
31 | /* |
---|
32 | * The amount of space within the chunk available for the array is: |
---|
33 | * chunk size - space for type (1) - space for next pointer (2) |
---|
34 | */ |
---|
35 | #define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3) |
---|
36 | |
---|
37 | typedef enum zap_chunk_type { |
---|
38 | ZAP_CHUNK_FREE = 253, |
---|
39 | ZAP_CHUNK_ENTRY = 252, |
---|
40 | ZAP_CHUNK_ARRAY = 251, |
---|
41 | ZAP_CHUNK_TYPE_MAX = 250 |
---|
42 | } zap_chunk_type_t; |
---|
43 | |
---|
44 | /* |
---|
45 | * TAKE NOTE: |
---|
46 | * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified. |
---|
47 | */ |
---|
48 | typedef struct zap_leaf_phys { |
---|
49 | struct zap_leaf_header { |
---|
50 | grub_uint64_t lh_block_type; /* ZBT_LEAF */ |
---|
51 | grub_uint64_t lh_pad1; |
---|
52 | grub_uint64_t lh_prefix; /* hash prefix of this leaf */ |
---|
53 | grub_uint32_t lh_magic; /* ZAP_LEAF_MAGIC */ |
---|
54 | grub_uint16_t lh_nfree; /* number free chunks */ |
---|
55 | grub_uint16_t lh_nentries; /* number of entries */ |
---|
56 | grub_uint16_t lh_prefix_len; /* num bits used to id this */ |
---|
57 | |
---|
58 | /* above is accessable to zap, below is zap_leaf private */ |
---|
59 | |
---|
60 | grub_uint16_t lh_freelist; /* chunk head of free list */ |
---|
61 | grub_uint8_t lh_pad2[12]; |
---|
62 | } l_hdr; /* 2 24-byte chunks */ |
---|
63 | |
---|
64 | /* |
---|
65 | * The header is followed by a hash table with |
---|
66 | * ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is |
---|
67 | * followed by an array of ZAP_LEAF_NUMCHUNKS(zap) |
---|
68 | * zap_leaf_chunk structures. These structures are accessed |
---|
69 | * with the ZAP_LEAF_CHUNK() macro. |
---|
70 | */ |
---|
71 | |
---|
72 | grub_uint16_t l_hash[0]; |
---|
73 | grub_properly_aligned_t l_entries[0]; |
---|
74 | } zap_leaf_phys_t; |
---|
75 | |
---|
76 | typedef union zap_leaf_chunk { |
---|
77 | struct zap_leaf_entry { |
---|
78 | grub_uint8_t le_type; /* always ZAP_CHUNK_ENTRY */ |
---|
79 | grub_uint8_t le_int_size; /* size of ints */ |
---|
80 | grub_uint16_t le_next; /* next entry in hash chain */ |
---|
81 | grub_uint16_t le_name_chunk; /* first chunk of the name */ |
---|
82 | grub_uint16_t le_name_length; /* bytes in name, incl null */ |
---|
83 | grub_uint16_t le_value_chunk; /* first chunk of the value */ |
---|
84 | grub_uint16_t le_value_length; /* value length in ints */ |
---|
85 | grub_uint32_t le_cd; /* collision differentiator */ |
---|
86 | grub_uint64_t le_hash; /* hash value of the name */ |
---|
87 | } l_entry; |
---|
88 | struct zap_leaf_array { |
---|
89 | grub_uint8_t la_type; /* always ZAP_CHUNK_ARRAY */ |
---|
90 | union |
---|
91 | { |
---|
92 | grub_uint8_t la_array[ZAP_LEAF_ARRAY_BYTES]; |
---|
93 | grub_uint64_t la_array64; |
---|
94 | } GRUB_PACKED; |
---|
95 | grub_uint16_t la_next; /* next blk or CHAIN_END */ |
---|
96 | } l_array; |
---|
97 | struct zap_leaf_free { |
---|
98 | grub_uint8_t lf_type; /* always ZAP_CHUNK_FREE */ |
---|
99 | grub_uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES]; |
---|
100 | grub_uint16_t lf_next; /* next in free list, or CHAIN_END */ |
---|
101 | } l_free; |
---|
102 | } zap_leaf_chunk_t; |
---|
103 | |
---|
104 | #endif /* _SYS_ZAP_LEAF_H */ |
---|