af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems/*
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * CDDL HEADER START
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems *
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * The contents of this file are subject to the terms of the
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * Common Development and Distribution License (the "License").
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * You may not use this file except in compliance with the License.
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems *
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * or http://www.opensolaris.org/os/licensing.
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * See the License for the specific language governing permissions
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * and limitations under the License.
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems *
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * When distributing Covered Code, include this CDDL HEADER in each
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * If applicable, add the following below this CDDL HEADER, with the
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * fields enclosed by brackets "[]" replaced with your own identifying
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * information: Portions Copyright [yyyy] [name of copyright owner]
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems *
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * CDDL HEADER END
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems */
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems/*
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
9890706ed36aa6bfca8ad283fbe4dac12ecd692bHans Rosenfeld * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems */
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#ifndef _INSTALLGRUB_H
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define _INSTALLGRUB_H
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#ifdef __cplusplus
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystemsextern "C" {
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#endif
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#include <sys/multiboot.h>
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#include "./../common/bblk_einfo.h"
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define SECTOR_SIZE (512)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystemstypedef struct _device_data {
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char *path;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char *path_p0;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint8_t type;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems int part_fd;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems int disk_fd;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems int slice;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems int partition;
9890706ed36aa6bfca8ad283fbe4dac12ecd692bHans Rosenfeld uint64_t start_sector;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char boot_sector[SECTOR_SIZE];
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems} ig_device_t;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystemstypedef struct _stage2_data {
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char *buf;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char *file;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char *extra;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems multiboot_header_t *mboot;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint32_t mboot_off;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint32_t file_size;
14d44f2248cc2a54490db7f7caa4da5968f90837Hans Rosenfeld uint32_t extra_size;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint32_t buf_size;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint32_t first_sector;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems uint32_t pcfs_first_sectors[2];
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems} ig_stage2_t;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystemstypedef struct _ig_data {
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems char stage1_buf[SECTOR_SIZE];
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems ig_stage2_t stage2;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems ig_device_t device;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems} ig_data_t;
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystemsenum ig_devtype_t {
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems IG_DEV_X86BOOTPAR = 1,
1a902ef8628b0dffd6df5442354ab59bb8530962Hans Rosenfeld IG_DEV_SOLVTOC,
1a902ef8628b0dffd6df5442354ab59bb8530962Hans Rosenfeld IG_DEV_EFI
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems};
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define is_bootpar(type) (type == IG_DEV_X86BOOTPAR)
1a902ef8628b0dffd6df5442354ab59bb8530962Hans Rosenfeld#define is_efi(type) (type == IG_DEV_EFI)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE2_MEMADDR (0x8000) /* loading addr of stage2 */
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_BPB_OFFSET (0x3)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_BPB_SIZE (0x3B)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_BOOT_DRIVE (0x40)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_FORCE_LBA (0x41)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_STAGE2_ADDRESS (0x42)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_STAGE2_SECTOR (0x44)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE1_STAGE2_SEGMENT (0x48)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE2_BLOCKLIST (SECTOR_SIZE - 0x8)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE2_INSTALLPART (SECTOR_SIZE + 0x8)
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#define STAGE2_FORCE_LBA (SECTOR_SIZE + 0x11)
1a902ef8628b0dffd6df5442354ab59bb8530962Hans Rosenfeld#define STAGE2_BLKOFF(type) \
1a902ef8628b0dffd6df5442354ab59bb8530962Hans Rosenfeld (is_efi(type) ? 1024 : 50) /* offset from start of part */
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld/*
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld * Maximum size of stage2 on EFI-labeled disks. Must not be larger than
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld * VDEV_BOOT_SIZE, defined in usr/src/uts/common/fs/zfs/sys/vdev_impl.h
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld */
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld#define STAGE2_MAXSIZE (1ULL << 19)
9348d232b12debc31fa8e694c517ad8ecfd54bdaHans Rosenfeld
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#ifdef __cplusplus
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems}
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#endif
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems
af28f636873b7156cfd73ceffa927658cca33fd0Enrico Perla - Sun Microsystems#endif /* _INSTALLGRUB_H */