1607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/*
2607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * linux/include/linux/edd.h
3607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *  Copyright (C) 2002, 2003, 2004 Dell Inc.
4607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *  by Matt Domsch <Matt_Domsch@dell.com>
5607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
6607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * structures and definitions for the int 13h, ax={41,48}h
7607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * BIOS Enhanced Disk Drive Services
8607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This is based on the T13 group document D1572 Revision 0 (August 14 2002)
9607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * available at http://www.t13.org/docs2002/d1572r0.pdf.  It is
10607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * very similar to D1484 Revision 3 http://www.t13.org/docs2002/d1484r3.pdf
11607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
12607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * In a nutshell, arch/{i386,x86_64}/boot/setup.S populates a scratch
13607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * table in the boot_params that contains a list of BIOS-enumerated
14607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * boot devices.
15607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * In arch/{i386,x86_64}/kernel/setup.c, this information is
16607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * transferred into the edd structure, and in drivers/firmware/edd.c, that
17607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * information is used to identify BIOS boot disk.  The code in setup.S
18607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * is very sensitive to the size of these structures.
19607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
20607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This program is free software; you can redistribute it and/or modify
21607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * it under the terms of the GNU General Public License v2.0 as published by
22607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * the Free Software Foundation
23607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
24607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This program is distributed in the hope that it will be useful,
25607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * but WITHOUT ANY WARRANTY; without even the implied warranty of
26607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * GNU General Public License for more details.
28607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
29607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
30607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#ifndef _UAPI_LINUX_EDD_H
31607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define _UAPI_LINUX_EDD_H
32607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
33607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#include <linux/types.h>
34607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
35607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDNR 0x1e9		/* addr of number of edd_info structs at EDDBUF
36607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells				   in boot_params - treat this as 1 byte  */
37607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDBUF	0xd00		/* addr of edd_info structs in boot_params */
38607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDMAXNR 6		/* number of edd_info structs starting at EDDBUF  */
39607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDEXTSIZE 8		/* change these if you muck with the structures */
40607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDPARMSIZE 74
41607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define CHECKEXTENSIONSPRESENT 0x41
42607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define GETDEVICEPARAMETERS 0x48
43607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define LEGACYGETDEVICEPARAMETERS 0x08
44607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDMAGIC1 0x55AA
45607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDDMAGIC2 0xAA55
46607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
47607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
48607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define READ_SECTORS 0x02         /* int13 AH=0x02 is READ_SECTORS command */
49607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_MBR_SIG_OFFSET 0x1B8  /* offset of signature in the MBR */
50607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_MBR_SIG_BUF    0x290  /* addr in boot params */
51607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_MBR_SIG_MAX 16        /* max number of signatures to store */
52607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_MBR_SIG_NR_BUF 0x1ea  /* addr of number of MBR signtaures at EDD_MBR_SIG_BUF
53607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells				     in boot_params - treat this as 1 byte  */
54607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
55607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#ifndef __ASSEMBLY__
56607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
57607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_EXT_FIXED_DISK_ACCESS           (1 << 0)
58607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_EXT_DEVICE_LOCKING_AND_EJECTING (1 << 1)
59607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT (1 << 2)
60607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_EXT_64BIT_EXTENSIONS            (1 << 3)
61607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
62607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT (1 << 0)
63607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_GEOMETRY_VALID                (1 << 1)
64607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_REMOVABLE                     (1 << 2)
65607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_WRITE_VERIFY                  (1 << 3)
66607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_MEDIA_CHANGE_NOTIFICATION     (1 << 4)
67607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_LOCKABLE                      (1 << 5)
68607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_NO_MEDIA_PRESENT              (1 << 6)
69607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define EDD_INFO_USE_INT13_FN50                (1 << 7)
70607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
71607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct edd_device_params {
72607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 length;
73607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 info_flags;
74607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 num_default_cylinders;
75607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 num_default_heads;
76607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 sectors_per_track;
77607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 number_of_sectors;
78607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 bytes_per_sector;
79607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 dpte_ptr;		/* 0xFFFFFFFF for our purposes */
80607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 key;		/* = 0xBEDD */
81607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 device_path_info_length;	/* = 44 */
82607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 reserved2;
83607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 reserved3;
84607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 host_bus_type[4];
85607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 interface_type[8];
86607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	union {
87607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
88607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 base_address;
89607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 reserved1;
90607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved2;
91607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) isa;
92607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
93607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 bus;
94607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 slot;
95607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 function;
96607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 channel;
97607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved;
98607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) pci;
99607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		/* pcix is same as pci */
100607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
101607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
102607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) ibnd;
103607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
104607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
105607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) xprs;
106607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
107607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
108607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) htpt;
109607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
110607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
111607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) unknown;
112607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	} interface_path;
113607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	union {
114607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
115607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 device;
116607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 reserved1;
117607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 reserved2;
118607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved3;
119607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved4;
120607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) ata;
121607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
122607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 device;
123607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 lun;
124607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 reserved1;
125607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 reserved2;
126607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved3;
127607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved4;
128607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) atapi;
129607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
130607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 id;
131607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 lun;
132607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 reserved1;
133607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved2;
134607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) scsi;
135607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
136607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 serial_number;
137607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
138607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) usb;
139607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
140607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 eui;
141607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
142607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) i1394;
143607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
144607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 wwid;
145607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 lun;
146607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) fibre;
147607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
148607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 identity_tag;
149607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved;
150607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) i2o;
151607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
152607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 array_number;
153607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved1;
154607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved2;
155607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) raid;
156607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
157607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 device;
158607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u8 reserved1;
159607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u16 reserved2;
160607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u32 reserved3;
161607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved4;
162607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) sata;
163607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		struct {
164607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved1;
165607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells			__u64 reserved2;
166607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells		} __attribute__ ((packed)) unknown;
167607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	} device_path;
168607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 reserved4;
169607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 checksum;
170607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells} __attribute__ ((packed));
171607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
172607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct edd_info {
173607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 device;
174607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 version;
175607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 interface_support;
176607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 legacy_max_cylinder;
177607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 legacy_max_head;
178607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 legacy_sectors_per_track;
179607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	struct edd_device_params params;
180607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells} __attribute__ ((packed));
181607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
182607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct edd {
183607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int mbr_signature[EDD_MBR_SIG_MAX];
184607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	struct edd_info edd_info[EDDMAXNR];
185607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned char mbr_signature_nr;
186607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned char edd_info_nr;
187607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
188607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
189607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#endif				/*!__ASSEMBLY__ */
190607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
191607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#endif /* _UAPI_LINUX_EDD_H */
192