xref: /openbmc/u-boot/include/zfs/vdev_impl.h (revision e11ef3d2)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  *  GRUB  --  GRand Unified Bootloader
4  *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
5  */
6 /*
7  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
8  * Use is subject to license terms.
9  */
10 
11 #ifndef _SYS_VDEV_IMPL_H
12 #define	_SYS_VDEV_IMPL_H
13 
14 #define	VDEV_SKIP_SIZE		(8 << 10)
15 #define	VDEV_BOOT_HEADER_SIZE	(8 << 10)
16 #define	VDEV_PHYS_SIZE		(112 << 10)
17 #define	VDEV_UBERBLOCK_RING	(128 << 10)
18 
19 /* ZFS boot block */
20 #define	VDEV_BOOT_MAGIC		0x2f5b007b10cULL
21 #define	VDEV_BOOT_VERSION	1		/* version number	*/
22 
23 typedef struct vdev_boot_header {
24 	uint64_t	vb_magic;		/* VDEV_BOOT_MAGIC	*/
25 	uint64_t	vb_version;		/* VDEV_BOOT_VERSION	*/
26 	uint64_t	vb_offset;		/* start offset	(bytes) */
27 	uint64_t	vb_size;		/* size (bytes)		*/
28 	char		vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof(uint64_t)];
29 } vdev_boot_header_t;
30 
31 typedef struct vdev_phys {
32 	char		vp_nvlist[VDEV_PHYS_SIZE - sizeof(zio_eck_t)];
33 	zio_eck_t	vp_zbt;
34 } vdev_phys_t;
35 
36 typedef struct vdev_label {
37 	char		vl_pad[VDEV_SKIP_SIZE];			/*   8K	*/
38 	vdev_boot_header_t vl_boot_header;			/*   8K	*/
39 	vdev_phys_t	vl_vdev_phys;				/* 112K	*/
40 	char		vl_uberblock[VDEV_UBERBLOCK_RING];	/* 128K	*/
41 } vdev_label_t;							/* 256K total */
42 
43 /*
44  * Size and offset of embedded boot loader region on each label.
45  * The total size of the first two labels plus the boot area is 4MB.
46  */
47 #define	VDEV_BOOT_OFFSET	(2 * sizeof(vdev_label_t))
48 #define	VDEV_BOOT_SIZE		(7ULL << 19)			/* 3.5M	*/
49 
50 /*
51  * Size of label regions at the start and end of each leaf device.
52  */
53 #define	VDEV_LABEL_START_SIZE	(2 * sizeof(vdev_label_t) + VDEV_BOOT_SIZE)
54 #define	VDEV_LABEL_END_SIZE	(2 * sizeof(vdev_label_t))
55 #define	VDEV_LABELS		4
56 
57 #endif	/* _SYS_VDEV_IMPL_H */
58