xref: /titanic_50/usr/src/cmd/boot/common/bblk_einfo.h (revision 7b07063d906859b2be1e88791f801b3c96e432f6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_BBLKEINFO_H
26 #define	_BBLKEINFO_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdint.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <md5.h>
36 
37 #define	BBLK_EINFO_VERSION	(1)
38 
39 #define	EINFO_MAGIC		"EXTINFO"
40 #define	EINFO_MAGIC_SIZE	(7)
41 
42 #pragma pack(1)
43 typedef struct _extended_info {
44 	char		magic[EINFO_MAGIC_SIZE];
45 	uint8_t		version;
46 	uint8_t		flags;
47 	uint32_t	str_off;
48 	uint16_t	str_size;
49 	uint8_t		hash_type;
50 	uint32_t	hash_off;
51 	uint16_t	hash_size;
52 	char		rsvd[32];
53 } bblk_einfo_t;
54 #pragma pack()
55 
56 enum bblk_hash_types_t {
57 	BBLK_NO_HASH = 0,
58 	BBLK_HASH_MD5,
59 	BBLK_HASH_TOT
60 };
61 
62 #define	EINFO_PRINT_HEADER	0x01
63 #define	EINFO_EASY_PARSE	0x02
64 
65 typedef struct _hashing_function {
66 	unsigned int	type;
67 	unsigned int	size;
68 	char		name[16];
69 	void 		(*compute_hash)(void *, const void *, unsigned int);
70 } bblk_hash_t;
71 
72 typedef struct _hashing_source {
73 	unsigned char	*src_buf;
74 	unsigned int	src_size;
75 } bblk_hs_t;
76 
77 #define	BBLK_DEFAULT_HASH	BBLK_HASH_MD5
78 
79 extern bblk_hash_t	bblk_no_hash;
80 extern bblk_hash_t	bblk_md5_hash;
81 extern bblk_hash_t	*bblk_hash_list[BBLK_HASH_TOT];
82 
83 void print_einfo(uint8_t, bblk_einfo_t *, unsigned long);
84 int prepare_and_write_einfo(unsigned char *, char *, bblk_hs_t *,
85     uint32_t, uint32_t *);
86 boolean_t einfo_should_update(bblk_einfo_t *, bblk_hs_t *, char *);
87 char *einfo_get_string(bblk_einfo_t *);
88 char *einfo_get_hash(bblk_einfo_t *);
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif /* _BBLKEINFO_H */
95