xref: /onnv-gate/usr/src/cmd/boot/installgrub/installgrub.h (revision 12947:f5f96e09bf49)
1*12947SEnrico.Perla@Sun.COM /*
2*12947SEnrico.Perla@Sun.COM  * CDDL HEADER START
3*12947SEnrico.Perla@Sun.COM  *
4*12947SEnrico.Perla@Sun.COM  * The contents of this file are subject to the terms of the
5*12947SEnrico.Perla@Sun.COM  * Common Development and Distribution License (the "License").
6*12947SEnrico.Perla@Sun.COM  * You may not use this file except in compliance with the License.
7*12947SEnrico.Perla@Sun.COM  *
8*12947SEnrico.Perla@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12947SEnrico.Perla@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12947SEnrico.Perla@Sun.COM  * See the License for the specific language governing permissions
11*12947SEnrico.Perla@Sun.COM  * and limitations under the License.
12*12947SEnrico.Perla@Sun.COM  *
13*12947SEnrico.Perla@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12947SEnrico.Perla@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12947SEnrico.Perla@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12947SEnrico.Perla@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12947SEnrico.Perla@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12947SEnrico.Perla@Sun.COM  *
19*12947SEnrico.Perla@Sun.COM  * CDDL HEADER END
20*12947SEnrico.Perla@Sun.COM  */
21*12947SEnrico.Perla@Sun.COM /*
22*12947SEnrico.Perla@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*12947SEnrico.Perla@Sun.COM  */
24*12947SEnrico.Perla@Sun.COM 
25*12947SEnrico.Perla@Sun.COM #ifndef	_INSTALLGRUB_H
26*12947SEnrico.Perla@Sun.COM #define	_INSTALLGRUB_H
27*12947SEnrico.Perla@Sun.COM 
28*12947SEnrico.Perla@Sun.COM #ifdef	__cplusplus
29*12947SEnrico.Perla@Sun.COM extern "C" {
30*12947SEnrico.Perla@Sun.COM #endif
31*12947SEnrico.Perla@Sun.COM 
32*12947SEnrico.Perla@Sun.COM #include <sys/multiboot.h>
33*12947SEnrico.Perla@Sun.COM #include "./../common/bblk_einfo.h"
34*12947SEnrico.Perla@Sun.COM 
35*12947SEnrico.Perla@Sun.COM #define	SECTOR_SIZE	(512)
36*12947SEnrico.Perla@Sun.COM 
37*12947SEnrico.Perla@Sun.COM typedef struct _device_data {
38*12947SEnrico.Perla@Sun.COM 	char		*path;
39*12947SEnrico.Perla@Sun.COM 	char		*path_p0;
40*12947SEnrico.Perla@Sun.COM 	uint8_t		type;
41*12947SEnrico.Perla@Sun.COM 	int		part_fd;
42*12947SEnrico.Perla@Sun.COM 	int		disk_fd;
43*12947SEnrico.Perla@Sun.COM 	int		slice;
44*12947SEnrico.Perla@Sun.COM 	int		partition;
45*12947SEnrico.Perla@Sun.COM 	uint32_t	start_sector;
46*12947SEnrico.Perla@Sun.COM 	char		boot_sector[SECTOR_SIZE];
47*12947SEnrico.Perla@Sun.COM } ig_device_t;
48*12947SEnrico.Perla@Sun.COM 
49*12947SEnrico.Perla@Sun.COM typedef struct _stage2_data {
50*12947SEnrico.Perla@Sun.COM 	char			*buf;
51*12947SEnrico.Perla@Sun.COM 	char			*file;
52*12947SEnrico.Perla@Sun.COM 	char			*extra;
53*12947SEnrico.Perla@Sun.COM 	multiboot_header_t	*mboot;
54*12947SEnrico.Perla@Sun.COM 	uint32_t		mboot_off;
55*12947SEnrico.Perla@Sun.COM 	uint32_t		file_size;
56*12947SEnrico.Perla@Sun.COM 	uint32_t		buf_size;
57*12947SEnrico.Perla@Sun.COM 	uint32_t		first_sector;
58*12947SEnrico.Perla@Sun.COM 	uint32_t		pcfs_first_sectors[2];
59*12947SEnrico.Perla@Sun.COM } ig_stage2_t;
60*12947SEnrico.Perla@Sun.COM 
61*12947SEnrico.Perla@Sun.COM typedef struct _ig_data {
62*12947SEnrico.Perla@Sun.COM 	char		stage1_buf[SECTOR_SIZE];
63*12947SEnrico.Perla@Sun.COM 	ig_stage2_t	stage2;
64*12947SEnrico.Perla@Sun.COM 	ig_device_t	device;
65*12947SEnrico.Perla@Sun.COM } ig_data_t;
66*12947SEnrico.Perla@Sun.COM 
67*12947SEnrico.Perla@Sun.COM enum ig_devtype_t {
68*12947SEnrico.Perla@Sun.COM 	IG_DEV_X86BOOTPAR = 1,
69*12947SEnrico.Perla@Sun.COM 	IG_DEV_SOLVTOC
70*12947SEnrico.Perla@Sun.COM };
71*12947SEnrico.Perla@Sun.COM 
72*12947SEnrico.Perla@Sun.COM #define	is_bootpar(type)	(type == IG_DEV_X86BOOTPAR)
73*12947SEnrico.Perla@Sun.COM 
74*12947SEnrico.Perla@Sun.COM #define	STAGE2_MEMADDR		(0x8000)	/* loading addr of stage2 */
75*12947SEnrico.Perla@Sun.COM 
76*12947SEnrico.Perla@Sun.COM #define	STAGE1_BPB_OFFSET	(0x3)
77*12947SEnrico.Perla@Sun.COM #define	STAGE1_BPB_SIZE		(0x3B)
78*12947SEnrico.Perla@Sun.COM #define	STAGE1_BOOT_DRIVE	(0x40)
79*12947SEnrico.Perla@Sun.COM #define	STAGE1_FORCE_LBA	(0x41)
80*12947SEnrico.Perla@Sun.COM #define	STAGE1_STAGE2_ADDRESS	(0x42)
81*12947SEnrico.Perla@Sun.COM #define	STAGE1_STAGE2_SECTOR	(0x44)
82*12947SEnrico.Perla@Sun.COM #define	STAGE1_STAGE2_SEGMENT	(0x48)
83*12947SEnrico.Perla@Sun.COM 
84*12947SEnrico.Perla@Sun.COM #define	STAGE2_BLOCKLIST	(SECTOR_SIZE - 0x8)
85*12947SEnrico.Perla@Sun.COM #define	STAGE2_INSTALLPART	(SECTOR_SIZE + 0x8)
86*12947SEnrico.Perla@Sun.COM #define	STAGE2_FORCE_LBA	(SECTOR_SIZE + 0x11)
87*12947SEnrico.Perla@Sun.COM #define	STAGE2_BLKOFF		(50)	/* offset from start of fdisk part */
88*12947SEnrico.Perla@Sun.COM 
89*12947SEnrico.Perla@Sun.COM #ifdef	__cplusplus
90*12947SEnrico.Perla@Sun.COM }
91*12947SEnrico.Perla@Sun.COM #endif
92*12947SEnrico.Perla@Sun.COM 
93*12947SEnrico.Perla@Sun.COM #endif /* _INSTALLGRUB_H */
94