xref: /titanic_50/usr/src/uts/i86pc/sys/biosdisk.h (revision 8388e56e7eb0b29615534291f733a3c75562ac18)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_BIOSDISK_H
27 #define	_SYS_BIOSDISK_H
28 
29 #include <sys/types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef union device_path {
36 	struct {			/* ATA or ATAPI or SATA */
37 		unsigned char 	chan;	/* 0 or 1 */
38 		unsigned char 	lun;	/* for ATAPI only */
39 	} ata;
40 	struct {
41 		unsigned short	target;
42 		uint32_t	lun_lo;
43 		uint32_t	lun_hi;
44 	} scsi;
45 	struct {
46 		uint64_t	usb_serial_id;
47 	} usb;
48 	struct {
49 		uint64_t	eui;
50 	} s1394;
51 	struct {
52 		uint64_t	wwid;
53 		uint64_t	lun;
54 	} fibre;
55 	struct {
56 		uint64_t	id_tag;
57 	} i2o;
58 
59 	struct {
60 		uint32_t	raid_array_num;
61 	} raid;
62 	unsigned char pad[16];		/* total length */
63 } device_path_t;
64 
65 
66 typedef union interface_path {
67 		struct {
68 			unsigned short 	baseport;
69 		} isa;
70 		struct {		/* PCI or PCIX */
71 			unsigned char bus;
72 			unsigned char device;
73 			unsigned char function;
74 			unsigned char channel;
75 		} pci;
76 		char 	pad[8];
77 } interface_path_t;
78 
79 /*
80  * Structure for Int 13 function 48 (EDD 3.0)
81  *
82  * from T13/1484D Revision 2
83  */
84 
85 #pragma pack(1)
86 typedef struct int13_fn48_result {
87 	unsigned short		buflen;
88 	unsigned short		flags;
89 	uint32_t		ncyl;
90 	uint32_t		nhead;
91 	uint32_t		spt;
92 	uint32_t 		nsect_lo;
93 	uint32_t		nsect_hi;
94 	unsigned short		bps;
95 	uint32_t		dpte;
96 	unsigned short		magic;		/* BEDD if Path info there */
97 	unsigned char		pathinfo_len;
98 	unsigned char		res1;
99 	unsigned short		res2;
100 	char			bustype[4];	/* offset 36 */
101 	char			interface_type[8];
102 	interface_path_t	interfacepath;
103 	device_path_t		devicepath;
104 	unsigned char		res3;
105 	unsigned char		checksum;	/* offset 73 */
106 } fn48_t;
107 
108 typedef struct int13_fn4b_result {
109 	uint8_t		pkt_size;	/* Packet size (== 0x13) */
110 
111 	uint8_t		boot_mtype;	/* Boot media type: see defines below */
112 
113 	uint8_t		drivenum;
114 	uint8_t		ctlr_idx;
115 	uint32_t	lba;
116 	uint16_t	dev_spec;
117 	uint16_t	buf_seg;
118 	uint16_t	load_seg;
119 	uint16_t	sect_cnt;
120 	uint8_t		cyl_0_7;	/* Bits 0-7 of the 9-bit cylinder cnt */
121 	/*
122 	 * Bits 0-5: Sector count
123 	 *	6-7: High 2 bits of the 9-bit cylinder count
124 	 */
125 	uint8_t		sec_0_5_and_cyl_8_9;
126 	uint8_t		head_cnt;
127 } fn4b_t;
128 
129 #pragma pack()
130 
131 typedef struct biosdev_data {
132 	uchar_t			first_block_valid;
133 	uchar_t			first_block[512];
134 	uchar_t			edd_valid;
135 	fn48_t			fn48_dev_params;
136 } biosdev_data_t;
137 
138 /*
139  * Definitions for boot_mtype in fn4b_t
140  */
141 #define	BOOT_MTYPE_MASK			0xF
142 #define	BOOT_MTYPE(x)			((x) & BOOT_MTYPE_MASK)
143 #define	BOOT_MTYPE_NO_EMUL		0
144 #define	BOOT_MTYPE_1_2M_FLOPPY		1
145 #define	BOOT_MTYPE_1_44M_FLOPPY		2
146 #define	BOOT_MTYPE_2_88M_FLOPPY		3
147 #define	BOOT_MTYPE_HARD_DISK		4
148 #define	BOOT_MTYPE_INTF_MASK		0xC0
149 #define	BOOT_MTYPE_INTF_ATAPI		0x40
150 #define	BOOT_MTYPE_INTF_SCSI		0x80
151 #define	BOOT_MTYPE_IS_ATAPI(x) \
152 	(((x) & BOOT_MTYPE_INTF_MASK) == BOOT_MTYPE_INTF_ATAPI)
153 #define	BOOT_MTYPE_IS_SCSI(x) \
154 	(((x) & BOOT_MTYPE_INTF_MASK) == BOOT_MTYPE_INTF_SCSI)
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* _SYS_BIOSDISK_H */
161