xref: /illumos-gate/usr/src/uts/i86pc/sys/biosdisk.h (revision 721df51d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*721df51dSSeth Goldberg  * Common Development and Distribution License (the "License").
6*721df51dSSeth Goldberg  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*721df51dSSeth Goldberg  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_BIOSDISK_H
277c478bd9Sstevel@tonic-gate #define	_SYS_BIOSDISK_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef __cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate typedef union device_path {
367c478bd9Sstevel@tonic-gate 	struct {			/* ATA or ATAPI or SATA */
377c478bd9Sstevel@tonic-gate 		unsigned char 	chan;	/* 0 or 1 */
387c478bd9Sstevel@tonic-gate 		unsigned char 	lun;	/* for ATAPI only */
397c478bd9Sstevel@tonic-gate 	} ata;
407c478bd9Sstevel@tonic-gate 	struct {
417c478bd9Sstevel@tonic-gate 		unsigned short	target;
427c478bd9Sstevel@tonic-gate 		uint32_t	lun_lo;
437c478bd9Sstevel@tonic-gate 		uint32_t	lun_hi;
447c478bd9Sstevel@tonic-gate 	} scsi;
457c478bd9Sstevel@tonic-gate 	struct {
467c478bd9Sstevel@tonic-gate 		uint64_t	usb_serial_id;
477c478bd9Sstevel@tonic-gate 	} usb;
487c478bd9Sstevel@tonic-gate 	struct {
497c478bd9Sstevel@tonic-gate 		uint64_t	eui;
507c478bd9Sstevel@tonic-gate 	} s1394;
517c478bd9Sstevel@tonic-gate 	struct {
527c478bd9Sstevel@tonic-gate 		uint64_t	wwid;
537c478bd9Sstevel@tonic-gate 		uint64_t	lun;
547c478bd9Sstevel@tonic-gate 	} fibre;
557c478bd9Sstevel@tonic-gate 	struct {
567c478bd9Sstevel@tonic-gate 		uint64_t	id_tag;
577c478bd9Sstevel@tonic-gate 	} i2o;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 	struct {
607c478bd9Sstevel@tonic-gate 		uint32_t	raid_array_num;
617c478bd9Sstevel@tonic-gate 	} raid;
627c478bd9Sstevel@tonic-gate 	unsigned char pad[16];		/* total length */
637c478bd9Sstevel@tonic-gate } device_path_t;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate typedef union interface_path {
677c478bd9Sstevel@tonic-gate 		struct {
687c478bd9Sstevel@tonic-gate 			unsigned short 	baseport;
697c478bd9Sstevel@tonic-gate 		} isa;
707c478bd9Sstevel@tonic-gate 		struct {		/* PCI or PCIX */
717c478bd9Sstevel@tonic-gate 			unsigned char bus;
727c478bd9Sstevel@tonic-gate 			unsigned char device;
737c478bd9Sstevel@tonic-gate 			unsigned char function;
747c478bd9Sstevel@tonic-gate 			unsigned char channel;
757c478bd9Sstevel@tonic-gate 		} pci;
767c478bd9Sstevel@tonic-gate 		char 	pad[8];
777c478bd9Sstevel@tonic-gate } interface_path_t;
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * Structure for Int 13 function 48 (EDD 3.0)
817c478bd9Sstevel@tonic-gate  *
827c478bd9Sstevel@tonic-gate  * from T13/1484D Revision 2
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #pragma pack(1)
867c478bd9Sstevel@tonic-gate typedef struct int13_fn48_result {
877c478bd9Sstevel@tonic-gate 	unsigned short		buflen;
887c478bd9Sstevel@tonic-gate 	unsigned short		flags;
897c478bd9Sstevel@tonic-gate 	uint32_t		ncyl;
907c478bd9Sstevel@tonic-gate 	uint32_t		nhead;
917c478bd9Sstevel@tonic-gate 	uint32_t		spt;
927c478bd9Sstevel@tonic-gate 	uint32_t 		nsect_lo;
937c478bd9Sstevel@tonic-gate 	uint32_t		nsect_hi;
947c478bd9Sstevel@tonic-gate 	unsigned short		bps;
957c478bd9Sstevel@tonic-gate 	uint32_t		dpte;
967c478bd9Sstevel@tonic-gate 	unsigned short		magic;		/* BEDD if Path info there */
977c478bd9Sstevel@tonic-gate 	unsigned char		pathinfo_len;
987c478bd9Sstevel@tonic-gate 	unsigned char		res1;
997c478bd9Sstevel@tonic-gate 	unsigned short		res2;
1007c478bd9Sstevel@tonic-gate 	char			bustype[4];	/* offset 36 */
1017c478bd9Sstevel@tonic-gate 	char			interface_type[8];
1027c478bd9Sstevel@tonic-gate 	interface_path_t	interfacepath;
1037c478bd9Sstevel@tonic-gate 	device_path_t		devicepath;
1047c478bd9Sstevel@tonic-gate 	unsigned char		res3;
1057c478bd9Sstevel@tonic-gate 	unsigned char		checksum;	/* offset 73 */
1067c478bd9Sstevel@tonic-gate } fn48_t;
107*721df51dSSeth Goldberg 
108*721df51dSSeth Goldberg typedef struct int13_fn4b_result {
109*721df51dSSeth Goldberg 	uint8_t		pkt_size;	/* Packet size (== 0x13) */
110*721df51dSSeth Goldberg 
111*721df51dSSeth Goldberg 	uint8_t		boot_mtype;	/* Boot media type: see defines below */
112*721df51dSSeth Goldberg 
113*721df51dSSeth Goldberg 	uint8_t		drivenum;
114*721df51dSSeth Goldberg 	uint8_t		ctlr_idx;
115*721df51dSSeth Goldberg 	uint32_t	lba;
116*721df51dSSeth Goldberg 	uint16_t	dev_spec;
117*721df51dSSeth Goldberg 	uint16_t	buf_seg;
118*721df51dSSeth Goldberg 	uint16_t	load_seg;
119*721df51dSSeth Goldberg 	uint16_t	sect_cnt;
120*721df51dSSeth Goldberg 	uint8_t		cyl_0_7;	/* Bits 0-7 of the 9-bit cylinder cnt */
121*721df51dSSeth Goldberg 	/*
122*721df51dSSeth Goldberg 	 * Bits 0-5: Sector count
123*721df51dSSeth Goldberg 	 *	6-7: High 2 bits of the 9-bit cylinder count
124*721df51dSSeth Goldberg 	 */
125*721df51dSSeth Goldberg 	uint8_t		sec_0_5_and_cyl_8_9;
126*721df51dSSeth Goldberg 	uint8_t		head_cnt;
127*721df51dSSeth Goldberg } fn4b_t;
128*721df51dSSeth Goldberg 
1297c478bd9Sstevel@tonic-gate #pragma pack()
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate typedef struct biosdev_data {
1327c478bd9Sstevel@tonic-gate 	uchar_t			first_block_valid;
1337c478bd9Sstevel@tonic-gate 	uchar_t			first_block[512];
1347c478bd9Sstevel@tonic-gate 	uchar_t			edd_valid;
1357c478bd9Sstevel@tonic-gate 	fn48_t			fn48_dev_params;
1367c478bd9Sstevel@tonic-gate } biosdev_data_t;
1377c478bd9Sstevel@tonic-gate 
138*721df51dSSeth Goldberg /*
139*721df51dSSeth Goldberg  * Definitions for boot_mtype in fn4b_t
140*721df51dSSeth Goldberg  */
141*721df51dSSeth Goldberg #define	BOOT_MTYPE_MASK			0xF
142*721df51dSSeth Goldberg #define	BOOT_MTYPE(x)			((x) & BOOT_MTYPE_MASK)
143*721df51dSSeth Goldberg #define	BOOT_MTYPE_NO_EMUL		0
144*721df51dSSeth Goldberg #define	BOOT_MTYPE_1_2M_FLOPPY		1
145*721df51dSSeth Goldberg #define	BOOT_MTYPE_1_44M_FLOPPY		2
146*721df51dSSeth Goldberg #define	BOOT_MTYPE_2_88M_FLOPPY		3
147*721df51dSSeth Goldberg #define	BOOT_MTYPE_HARD_DISK		4
148*721df51dSSeth Goldberg #define	BOOT_MTYPE_INTF_MASK		0xC0
149*721df51dSSeth Goldberg #define	BOOT_MTYPE_INTF_ATAPI		0x40
150*721df51dSSeth Goldberg #define	BOOT_MTYPE_INTF_SCSI		0x80
151*721df51dSSeth Goldberg #define	BOOT_MTYPE_IS_ATAPI(x) \
152*721df51dSSeth Goldberg 	(((x) & BOOT_MTYPE_INTF_MASK) == BOOT_MTYPE_INTF_ATAPI)
153*721df51dSSeth Goldberg #define	BOOT_MTYPE_IS_SCSI(x) \
154*721df51dSSeth Goldberg 	(((x) & BOOT_MTYPE_INTF_MASK) == BOOT_MTYPE_INTF_SCSI)
155*721df51dSSeth Goldberg 
1567c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1577c478bd9Sstevel@tonic-gate }
1587c478bd9Sstevel@tonic-gate #endif
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #endif /* _SYS_BIOSDISK_H */
161