1*4d3c95f5SJorgen Lundman /* 2*4d3c95f5SJorgen Lundman * GRUB -- GRand Unified Bootloader 3*4d3c95f5SJorgen Lundman * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. 4*4d3c95f5SJorgen Lundman * 5*4d3c95f5SJorgen Lundman * This program is free software; you can redistribute it and/or modify 6*4d3c95f5SJorgen Lundman * it under the terms of the GNU General Public License as published by 7*4d3c95f5SJorgen Lundman * the Free Software Foundation; either version 2 of the License, or 8*4d3c95f5SJorgen Lundman * (at your option) any later version. 9*4d3c95f5SJorgen Lundman * 10*4d3c95f5SJorgen Lundman * This program is distributed in the hope that it will be useful, 11*4d3c95f5SJorgen Lundman * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*4d3c95f5SJorgen Lundman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4d3c95f5SJorgen Lundman * GNU General Public License for more details. 14*4d3c95f5SJorgen Lundman * 15*4d3c95f5SJorgen Lundman * You should have received a copy of the GNU General Public License 16*4d3c95f5SJorgen Lundman * along with this program; if not, write to the Free Software 17*4d3c95f5SJorgen Lundman * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18*4d3c95f5SJorgen Lundman */ 19*4d3c95f5SJorgen Lundman /* 20*4d3c95f5SJorgen Lundman * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 21*4d3c95f5SJorgen Lundman * Use is subject to license terms. 22*4d3c95f5SJorgen Lundman */ 23*4d3c95f5SJorgen Lundman 24*4d3c95f5SJorgen Lundman #ifndef _SYS_VDEV_IMPL_H 25*4d3c95f5SJorgen Lundman #define _SYS_VDEV_IMPL_H 26*4d3c95f5SJorgen Lundman 27*4d3c95f5SJorgen Lundman #define VDEV_SKIP_SIZE (8 << 10) 28*4d3c95f5SJorgen Lundman #define VDEV_BOOT_HEADER_SIZE (8 << 10) 29*4d3c95f5SJorgen Lundman #define VDEV_PHYS_SIZE (112 << 10) 30*4d3c95f5SJorgen Lundman #define VDEV_UBERBLOCK_RING (128 << 10) 31*4d3c95f5SJorgen Lundman 32*4d3c95f5SJorgen Lundman /* ZFS boot block */ 33*4d3c95f5SJorgen Lundman #define VDEV_BOOT_MAGIC 0x2f5b007b10cULL 34*4d3c95f5SJorgen Lundman #define VDEV_BOOT_VERSION 1 /* version number */ 35*4d3c95f5SJorgen Lundman 36*4d3c95f5SJorgen Lundman typedef struct vdev_boot_header { 37*4d3c95f5SJorgen Lundman uint64_t vb_magic; /* VDEV_BOOT_MAGIC */ 38*4d3c95f5SJorgen Lundman uint64_t vb_version; /* VDEV_BOOT_VERSION */ 39*4d3c95f5SJorgen Lundman uint64_t vb_offset; /* start offset (bytes) */ 40*4d3c95f5SJorgen Lundman uint64_t vb_size; /* size (bytes) */ 41*4d3c95f5SJorgen Lundman char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof(uint64_t)]; 42*4d3c95f5SJorgen Lundman } vdev_boot_header_t; 43*4d3c95f5SJorgen Lundman 44*4d3c95f5SJorgen Lundman typedef struct vdev_phys { 45*4d3c95f5SJorgen Lundman char vp_nvlist[VDEV_PHYS_SIZE - sizeof(zio_eck_t)]; 46*4d3c95f5SJorgen Lundman zio_eck_t vp_zbt; 47*4d3c95f5SJorgen Lundman } vdev_phys_t; 48*4d3c95f5SJorgen Lundman 49*4d3c95f5SJorgen Lundman typedef struct vdev_label { 50*4d3c95f5SJorgen Lundman char vl_pad[VDEV_SKIP_SIZE]; /* 8K */ 51*4d3c95f5SJorgen Lundman vdev_boot_header_t vl_boot_header; /* 8K */ 52*4d3c95f5SJorgen Lundman vdev_phys_t vl_vdev_phys; /* 112K */ 53*4d3c95f5SJorgen Lundman char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */ 54*4d3c95f5SJorgen Lundman } vdev_label_t; /* 256K total */ 55*4d3c95f5SJorgen Lundman 56*4d3c95f5SJorgen Lundman /* 57*4d3c95f5SJorgen Lundman * Size and offset of embedded boot loader region on each label. 58*4d3c95f5SJorgen Lundman * The total size of the first two labels plus the boot area is 4MB. 59*4d3c95f5SJorgen Lundman */ 60*4d3c95f5SJorgen Lundman #define VDEV_BOOT_OFFSET (2 * sizeof(vdev_label_t)) 61*4d3c95f5SJorgen Lundman #define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */ 62*4d3c95f5SJorgen Lundman 63*4d3c95f5SJorgen Lundman /* 64*4d3c95f5SJorgen Lundman * Size of label regions at the start and end of each leaf device. 65*4d3c95f5SJorgen Lundman */ 66*4d3c95f5SJorgen Lundman #define VDEV_LABEL_START_SIZE (2 * sizeof(vdev_label_t) + VDEV_BOOT_SIZE) 67*4d3c95f5SJorgen Lundman #define VDEV_LABEL_END_SIZE (2 * sizeof(vdev_label_t)) 68*4d3c95f5SJorgen Lundman #define VDEV_LABELS 4 69*4d3c95f5SJorgen Lundman 70*4d3c95f5SJorgen Lundman #endif /* _SYS_VDEV_IMPL_H */ 71