xref: /illumos-gate/usr/src/cmd/boot/installgrub/installgrub.h (revision af28f636873b7156cfd73ceffa927658cca33fd0)
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	_INSTALLGRUB_H
26*af28f636SEnrico Perla - Sun Microsystems #define	_INSTALLGRUB_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 <sys/multiboot.h>
33*af28f636SEnrico Perla - Sun Microsystems #include "./../common/bblk_einfo.h"
34*af28f636SEnrico Perla - Sun Microsystems 
35*af28f636SEnrico Perla - Sun Microsystems #define	SECTOR_SIZE	(512)
36*af28f636SEnrico Perla - Sun Microsystems 
37*af28f636SEnrico Perla - Sun Microsystems typedef struct _device_data {
38*af28f636SEnrico Perla - Sun Microsystems 	char		*path;
39*af28f636SEnrico Perla - Sun Microsystems 	char		*path_p0;
40*af28f636SEnrico Perla - Sun Microsystems 	uint8_t		type;
41*af28f636SEnrico Perla - Sun Microsystems 	int		part_fd;
42*af28f636SEnrico Perla - Sun Microsystems 	int		disk_fd;
43*af28f636SEnrico Perla - Sun Microsystems 	int		slice;
44*af28f636SEnrico Perla - Sun Microsystems 	int		partition;
45*af28f636SEnrico Perla - Sun Microsystems 	uint32_t	start_sector;
46*af28f636SEnrico Perla - Sun Microsystems 	char		boot_sector[SECTOR_SIZE];
47*af28f636SEnrico Perla - Sun Microsystems } ig_device_t;
48*af28f636SEnrico Perla - Sun Microsystems 
49*af28f636SEnrico Perla - Sun Microsystems typedef struct _stage2_data {
50*af28f636SEnrico Perla - Sun Microsystems 	char			*buf;
51*af28f636SEnrico Perla - Sun Microsystems 	char			*file;
52*af28f636SEnrico Perla - Sun Microsystems 	char			*extra;
53*af28f636SEnrico Perla - Sun Microsystems 	multiboot_header_t	*mboot;
54*af28f636SEnrico Perla - Sun Microsystems 	uint32_t		mboot_off;
55*af28f636SEnrico Perla - Sun Microsystems 	uint32_t		file_size;
56*af28f636SEnrico Perla - Sun Microsystems 	uint32_t		buf_size;
57*af28f636SEnrico Perla - Sun Microsystems 	uint32_t		first_sector;
58*af28f636SEnrico Perla - Sun Microsystems 	uint32_t		pcfs_first_sectors[2];
59*af28f636SEnrico Perla - Sun Microsystems } ig_stage2_t;
60*af28f636SEnrico Perla - Sun Microsystems 
61*af28f636SEnrico Perla - Sun Microsystems typedef struct _ig_data {
62*af28f636SEnrico Perla - Sun Microsystems 	char		stage1_buf[SECTOR_SIZE];
63*af28f636SEnrico Perla - Sun Microsystems 	ig_stage2_t	stage2;
64*af28f636SEnrico Perla - Sun Microsystems 	ig_device_t	device;
65*af28f636SEnrico Perla - Sun Microsystems } ig_data_t;
66*af28f636SEnrico Perla - Sun Microsystems 
67*af28f636SEnrico Perla - Sun Microsystems enum ig_devtype_t {
68*af28f636SEnrico Perla - Sun Microsystems 	IG_DEV_X86BOOTPAR = 1,
69*af28f636SEnrico Perla - Sun Microsystems 	IG_DEV_SOLVTOC
70*af28f636SEnrico Perla - Sun Microsystems };
71*af28f636SEnrico Perla - Sun Microsystems 
72*af28f636SEnrico Perla - Sun Microsystems #define	is_bootpar(type)	(type == IG_DEV_X86BOOTPAR)
73*af28f636SEnrico Perla - Sun Microsystems 
74*af28f636SEnrico Perla - Sun Microsystems #define	STAGE2_MEMADDR		(0x8000)	/* loading addr of stage2 */
75*af28f636SEnrico Perla - Sun Microsystems 
76*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_BPB_OFFSET	(0x3)
77*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_BPB_SIZE		(0x3B)
78*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_BOOT_DRIVE	(0x40)
79*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_FORCE_LBA	(0x41)
80*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_STAGE2_ADDRESS	(0x42)
81*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_STAGE2_SECTOR	(0x44)
82*af28f636SEnrico Perla - Sun Microsystems #define	STAGE1_STAGE2_SEGMENT	(0x48)
83*af28f636SEnrico Perla - Sun Microsystems 
84*af28f636SEnrico Perla - Sun Microsystems #define	STAGE2_BLOCKLIST	(SECTOR_SIZE - 0x8)
85*af28f636SEnrico Perla - Sun Microsystems #define	STAGE2_INSTALLPART	(SECTOR_SIZE + 0x8)
86*af28f636SEnrico Perla - Sun Microsystems #define	STAGE2_FORCE_LBA	(SECTOR_SIZE + 0x11)
87*af28f636SEnrico Perla - Sun Microsystems #define	STAGE2_BLKOFF		(50)	/* offset from start of fdisk part */
88*af28f636SEnrico Perla - Sun Microsystems 
89*af28f636SEnrico Perla - Sun Microsystems #ifdef	__cplusplus
90*af28f636SEnrico Perla - Sun Microsystems }
91*af28f636SEnrico Perla - Sun Microsystems #endif
92*af28f636SEnrico Perla - Sun Microsystems 
93*af28f636SEnrico Perla - Sun Microsystems #endif /* _INSTALLGRUB_H */
94