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