1ca68245eSMichael Lotz/*
293c0a5d7SAxel Dörfler * Copyright 2010-2015, Axel D��rfler, axeld@pinc-software.de.
3ca68245eSMichael Lotz * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
4ca68245eSMichael Lotz * Distributed under the terms of the MIT License.
5ca68245eSMichael Lotz */
6ca68245eSMichael Lotz#ifndef ATA_INFOBLOCK_H
7ca68245eSMichael Lotz#define ATA_INFOBLOCK_H
8ca68245eSMichael Lotz
90b46a85eSAxel Dörfler
10ca68245eSMichael Lotz#include <lendian_bitfield.h>
11ca68245eSMichael Lotz
120b46a85eSAxel Dörfler
13ca68245eSMichael Lotz#define ATA_WORD_0_ATA_DEVICE		0
14ca68245eSMichael Lotz#define ATA_WORD_0_ATAPI_DEVICE		2
15ca68245eSMichael Lotz#define ATA_WORD_0_CFA_MAGIC		0x848a
16ca68245eSMichael Lotz
17ca68245eSMichael Lotz
18ca68245eSMichael Lotztypedef struct ata_device_infoblock {
19ca68245eSMichael Lotz	union {
20ca68245eSMichael Lotz		struct {
2193c0a5d7SAxel Dörfler			B_LBITFIELD16_8(
22ca68245eSMichael Lotz				word_0_bit_0_reserved			: 1,
23ca68245eSMichael Lotz				word_0_bit_1_retired			: 1,
24ca68245eSMichael Lotz				response_incomplete				: 1,
25ca68245eSMichael Lotz				word_0_bit_3_5_retired			: 3,
26ca68245eSMichael Lotz				word_0_bit_6_obsolete			: 1,
27ca68245eSMichael Lotz				removable_media_device			: 1,
28ca68245eSMichael Lotz				word_0_bit_8_14_retired			: 7,
29ca68245eSMichael Lotz				ata_device						: 1		// 0 means ATA
30ca68245eSMichael Lotz			);
31ca68245eSMichael Lotz		} ata;
32ca68245eSMichael Lotz		struct {
3393c0a5d7SAxel Dörfler			B_LBITFIELD16_8(
34ca68245eSMichael Lotz				packet_length					: 2,	// 0 = 12, 1 = 16 bytes
35ca68245eSMichael Lotz				response_incomplete				: 1,
36ca68245eSMichael Lotz				word_0_bit_3_4_reserved			: 2,
37ca68245eSMichael Lotz				data_request_delay				: 2,	// 0 = 3ms, 2 = 50us
38ca68245eSMichael Lotz				removable_media_device			: 1,
39ca68245eSMichael Lotz				command_packet_set				: 5,
40ca68245eSMichael Lotz				word_0_bit_13_reserved			: 1,
41ca68245eSMichael Lotz				atapi_device					: 2		// 2 means ATAPI
42ca68245eSMichael Lotz			);
43ca68245eSMichael Lotz		} atapi;
44ca68245eSMichael Lotz		uint16 raw;
45ca68245eSMichael Lotz	} word_0;
46ca68245eSMichael Lotz
47ca68245eSMichael Lotz	uint16	word_1_obsolete;
48ca68245eSMichael Lotz	uint16	specific_configuration;
49ca68245eSMichael Lotz	uint16	word_3_obsolete;
50ca68245eSMichael Lotz	uint16	word_4_5_retired[2];
51ca68245eSMichael Lotz	uint16	word_6_obsolete;
52ca68245eSMichael Lotz	uint16	word_7_8_reserved_compact_flash_assoc[2];
53ca68245eSMichael Lotz	uint16	word_9_retired;
54ca68245eSMichael Lotz	char	serial_number[20];
55ca68245eSMichael Lotz	uint16	word_20_21_retired[2];
56ca68245eSMichael Lotz	uint16	word_22_obsolete;
57ca68245eSMichael Lotz	char	firmware_revision[8];
58ca68245eSMichael Lotz	char	model_number[40];
59ca68245eSMichael Lotz
6093c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
61ca68245eSMichael Lotz		max_sectors_per_interrupt				: 8,
62ca68245eSMichael Lotz		word_47_bit_8_15_80h					: 8		// should be 0x80
63ca68245eSMichael Lotz	);
64ca68245eSMichael Lotz
65ca68245eSMichael Lotz	uint16	word_48_reserved;
66ca68245eSMichael Lotz
6793c0a5d7SAxel Dörfler	B_LBITFIELD16_9(
68ca68245eSMichael Lotz		word_49_bit_0_7_retired					: 8,
69ca68245eSMichael Lotz		dma_supported							: 1,
70ca68245eSMichael Lotz		lba_supported							: 1,
71ca68245eSMichael Lotz		io_ready_disable						: 1,
72ca68245eSMichael Lotz		io_ready_supported						: 1,
73ca68245eSMichael Lotz		word_19_bit_12_obsolete					: 1,
74ca68245eSMichael Lotz		standby_timer_standard					: 1,
75ca68245eSMichael Lotz		atapi_command_queuing_supported			: 1,
76ca68245eSMichael Lotz		atapi_interleaved_dma_supported			: 1
77ca68245eSMichael Lotz	);
78ca68245eSMichael Lotz
7993c0a5d7SAxel Dörfler	B_LBITFIELD16_5(
80ca68245eSMichael Lotz		standby_timer_value_min					: 1,
81ca68245eSMichael Lotz		word_50_bit_1_obsolete					: 1,
82ca68245eSMichael Lotz		word_50_bit_2_13_reserved				: 12,
83ca68245eSMichael Lotz		word_50_bit_14_one						: 1,
84ca68245eSMichael Lotz		word_50_bit_15_zero						: 1
85ca68245eSMichael Lotz	);
86ca68245eSMichael Lotz
87ca68245eSMichael Lotz	uint16	word_51_52_obsolete[2];
88ca68245eSMichael Lotz
8993c0a5d7SAxel Dörfler	B_LBITFIELD16_4(
90ca68245eSMichael Lotz		word_53_bit_0_obsolete					: 1,
91ca68245eSMichael Lotz		word_64_70_valid						: 1,
92ca68245eSMichael Lotz		word_88_valid							: 1,
93ca68245eSMichael Lotz		word_53_bit_3_15						: 13
94ca68245eSMichael Lotz	);
95ca68245eSMichael Lotz
96ca68245eSMichael Lotz	uint16	word_54_58_obsolete[5];
97ca68245eSMichael Lotz
9893c0a5d7SAxel Dörfler	B_LBITFIELD16_3(
99ca68245eSMichael Lotz		current_sectors_per_interrupt			: 8,
100ca68245eSMichael Lotz		multiple_sector_setting_valid			: 1,
101ca68245eSMichael Lotz		word_59_bit_9_15_reserved				: 7
102ca68245eSMichael Lotz	);
103ca68245eSMichael Lotz
104ca68245eSMichael Lotz	uint32	lba_sector_count;
105ca68245eSMichael Lotz	uint16	word_62_obsolete;
106ca68245eSMichael Lotz
10793c0a5d7SAxel Dörfler	B_LBITFIELD16_8(
108ca68245eSMichael Lotz		multiword_dma_0_supported				: 1,
109ca68245eSMichael Lotz		multiword_dma_1_supported				: 1,
110ca68245eSMichael Lotz		multiword_dma_2_supported				: 1,
111ca68245eSMichael Lotz		word_63_bit_3_7_resereved				: 5,
112ca68245eSMichael Lotz		multiword_dma_0_selected				: 1,
113ca68245eSMichael Lotz		multiword_dma_1_selected				: 1,
114ca68245eSMichael Lotz		multiword_dma_2_selected				: 1,
115ca68245eSMichael Lotz		word_63_bit_11_15_reserved				: 5
116ca68245eSMichael Lotz	);
117ca68245eSMichael Lotz
11893c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
119ca68245eSMichael Lotz		pio_modes_supported						: 8,
120ca68245eSMichael Lotz		word_64_bit_8_15_reserved				: 8
121ca68245eSMichael Lotz	);
122ca68245eSMichael Lotz
123ca68245eSMichael Lotz	uint16	min_multiword_dma_cycle_time;
124ca68245eSMichael Lotz	uint16	recommended_multiword_dma_cycle_time;
125ca68245eSMichael Lotz	uint16	min_pio_cycle_time;
126ca68245eSMichael Lotz	uint16	min_pio_cycle_time_io_ready;
12793c0a5d7SAxel Dörfler	B_LBITFIELD16_12(
128efc3172fSAxel Dörfler		word_69_bit_0_4_reserved				: 5,
129efc3172fSAxel Dörfler		supports_read_zero_after_trim			: 1,
130efc3172fSAxel Dörfler		supports_ata28_commands					: 1,
131efc3172fSAxel Dörfler		word_69_bit_7_reserved					: 1,
132efc3172fSAxel Dörfler		supports_download_microcode_dma			: 1,
133efc3172fSAxel Dörfler		supports_set_max_password_unlock_dma	: 1,
134efc3172fSAxel Dörfler		supports_write_buffer_dma				: 1,
135efc3172fSAxel Dörfler		supports_read_buffer_dma				: 1,
136efc3172fSAxel Dörfler		supports_device_configuration_identify_dma		: 1,
137efc3172fSAxel Dörfler		supports_long_physical_sector_error_reporting	: 1,
138efc3172fSAxel Dörfler		supports_deterministic_read_after_trim	: 1,
139efc3172fSAxel Dörfler		supports_cfast_specification			: 1
140efc3172fSAxel Dörfler	);
141efc3172fSAxel Dörfler	uint16	word_70_reserved;
142ca68245eSMichael Lotz	uint16	atapi_packet_received_to_bus_release_time_ns;
143ca68245eSMichael Lotz	uint16	atapi_service_command_to_busy_clear_time_ns;
144ca68245eSMichael Lotz	uint16	word_71_74_reserved[2];
145ca68245eSMichael Lotz
14693c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
147ca68245eSMichael Lotz		max_queue_depth_minus_one				: 5,
148ca68245eSMichael Lotz		word_75_bit_5_15_reserved				: 11
149ca68245eSMichael Lotz	);
150ca68245eSMichael Lotz
151ca68245eSMichael Lotz	uint16	word_76_79_reserved[4];
152ca68245eSMichael Lotz
15393c0a5d7SAxel Dörfler	B_LBITFIELD16_14(
154ca68245eSMichael Lotz		word_80_bit_0_reserved					: 1,
155efc3172fSAxel Dörfler		word_80_bit_1_3_obsolete				: 3,
156ca68245eSMichael Lotz		supports_ata_atapi_4					: 1,
157ca68245eSMichael Lotz		supports_ata_atapi_5					: 1,
158ca68245eSMichael Lotz		supports_ata_atapi_6					: 1,
159ca68245eSMichael Lotz		supports_ata_atapi_7					: 1,
160ca68245eSMichael Lotz		supports_ata_atapi_8					: 1,
161ca68245eSMichael Lotz		supports_ata_atapi_9					: 1,
162ca68245eSMichael Lotz		supports_ata_atapi_10					: 1,
163ca68245eSMichael Lotz		supports_ata_atapi_11					: 1,
164ca68245eSMichael Lotz		supports_ata_atapi_12					: 1,
165ca68245eSMichael Lotz		supports_ata_atapi_13					: 1,
166ca68245eSMichael Lotz		supports_ata_atapi_14					: 1,
167ca68245eSMichael Lotz		word_80_bit_15_reserved					: 1
168ca68245eSMichael Lotz	);
169ca68245eSMichael Lotz
170ca68245eSMichael Lotz	uint16	minor_version;
171ca68245eSMichael Lotz
17293c0a5d7SAxel Dörfler	B_LBITFIELD16_16(
173ca68245eSMichael Lotz		smart_supported							: 1,
174ca68245eSMichael Lotz		security_mode_supported					: 1,
175ca68245eSMichael Lotz		removable_media_supported				: 1,
176ca68245eSMichael Lotz		mandatory_power_management_supported	: 1,
177ca68245eSMichael Lotz		packet_supported						: 1,
178ca68245eSMichael Lotz		write_cache_supported					: 1,
179ca68245eSMichael Lotz		look_ahead_supported					: 1,
180ca68245eSMichael Lotz		release_interrupt_supported				: 1,
181ca68245eSMichael Lotz		service_interrupt_supported				: 1,
182ca68245eSMichael Lotz		device_reset_supported					: 1,
183ca68245eSMichael Lotz		host_protected_area_supported			: 1,
184ca68245eSMichael Lotz		word_82_bit_11_obsolete					: 1,
185ca68245eSMichael Lotz		write_buffer_command_supported			: 1,
186ca68245eSMichael Lotz		read_buffer_command_supported			: 1,
187ca68245eSMichael Lotz		nop_supported							: 1,
188ca68245eSMichael Lotz		word_82_bit_15_obsolete					: 1
189ca68245eSMichael Lotz	);
190ca68245eSMichael Lotz
19193c0a5d7SAxel Dörfler	B_LBITFIELD16_16(
192ca68245eSMichael Lotz		download_microcode_supported			: 1,
193ca68245eSMichael Lotz		read_write_dma_queued_supported			: 1,
194ca68245eSMichael Lotz		compact_flash_assoc_supported			: 1,
195ca68245eSMichael Lotz		advanced_power_management_supported		: 1,
196ca68245eSMichael Lotz		removable_media_status_supported		: 1,
197ca68245eSMichael Lotz		power_up_in_standby_supported			: 1,
198ca68245eSMichael Lotz		set_features_required_for_spinup		: 1,
199ca68245eSMichael Lotz		word_83_bit_7_reserved					: 1,
200ca68245eSMichael Lotz		set_max_security_extension_supported	: 1,
201ca68245eSMichael Lotz		automatic_acoustic_management_supported	: 1,
202ca68245eSMichael Lotz		lba48_supported							: 1,
203ca68245eSMichael Lotz		device_configuration_overlay_supported	: 1,
204ca68245eSMichael Lotz		mandatory_flush_cache_supported			: 1,
205ca68245eSMichael Lotz		flush_cache_ext_supported				: 1,
206ca68245eSMichael Lotz		word_83_bit_14_one						: 1,
207ca68245eSMichael Lotz		word_83_bit_15_zero						: 1
208ca68245eSMichael Lotz	);
209ca68245eSMichael Lotz
21093c0a5d7SAxel Dörfler	B_LBITFIELD16_9(
211ca68245eSMichael Lotz		smart_error_logging_supported			: 1,
212ca68245eSMichael Lotz		smart_self_test_supported				: 1,
213ca68245eSMichael Lotz		media_serial_number_supported			: 1,
214ca68245eSMichael Lotz		media_card_pass_through_supported		: 1,
215ca68245eSMichael Lotz		word_84_bit_4_reserved					: 1,
216ca68245eSMichael Lotz		general_purpose_logging_supported		: 1,
217ca68245eSMichael Lotz		word_84_bit_6_13_reserved				: 8,
218ca68245eSMichael Lotz		word_84_bit_14_one						: 1,
219ca68245eSMichael Lotz		word_84_bit_15_zero						: 1
220ca68245eSMichael Lotz	);
221ca68245eSMichael Lotz
22293c0a5d7SAxel Dörfler	B_LBITFIELD16_16(
223ca68245eSMichael Lotz		smart_enabled							: 1,
224ca68245eSMichael Lotz		security_mode_enabled					: 1,
225ca68245eSMichael Lotz		removable_media_enabled					: 1,
226ca68245eSMichael Lotz		mandatory_power_management_enabled		: 1,
227ca68245eSMichael Lotz		packet_enabled							: 1,
228ca68245eSMichael Lotz		write_cache_enabled						: 1,
229ca68245eSMichael Lotz		look_ahead_enabled						: 1,
230ca68245eSMichael Lotz		release_interrupt_enabled				: 1,
231ca68245eSMichael Lotz		service_interrupt_enabled				: 1,
232ca68245eSMichael Lotz		device_reset_enabled					: 1,
233ca68245eSMichael Lotz		host_protected_area_enabled				: 1,
234ca68245eSMichael Lotz		word_85_bit_11_obsolete					: 1,
235ca68245eSMichael Lotz		write_buffer_command_enabled			: 1,
236ca68245eSMichael Lotz		read_buffer_command_enabled				: 1,
237ca68245eSMichael Lotz		nop_enabled								: 1,
238ca68245eSMichael Lotz		word_85_bit_15_obsolete					: 1
239ca68245eSMichael Lotz	);
240ca68245eSMichael Lotz
24193c0a5d7SAxel Dörfler	B_LBITFIELD16_15(
242ca68245eSMichael Lotz		download_microcode_supported_2			: 1,
243ca68245eSMichael Lotz		read_write_dma_queued_supported_2		: 1,
244ca68245eSMichael Lotz		compact_flash_assoc_enabled				: 1,
245ca68245eSMichael Lotz		advanced_power_management_enabled		: 1,
246ca68245eSMichael Lotz		removable_media_status_enabled			: 1,
247ca68245eSMichael Lotz		power_up_in_standby_enabled				: 1,
248ca68245eSMichael Lotz		set_features_required_for_spinup_2		: 1,
249ca68245eSMichael Lotz		word_86_bit_7_reserved					: 1,
250ca68245eSMichael Lotz		set_max_security_extension_enabled		: 1,
251ca68245eSMichael Lotz		automatic_acoustic_management_enabled	: 1,
252ca68245eSMichael Lotz		lba48_supported_2						: 1,
253ca68245eSMichael Lotz		device_configuration_overlay_supported_2: 1,
254ca68245eSMichael Lotz		mandatory_flush_cache_supported_2		: 1,
255ca68245eSMichael Lotz		flush_cache_ext_supported_2				: 1,
256ca68245eSMichael Lotz		word_86_bit_14_15_reserved				: 2
257ca68245eSMichael Lotz	);
258ca68245eSMichael Lotz
25993c0a5d7SAxel Dörfler	B_LBITFIELD16_9(
260ca68245eSMichael Lotz		smart_error_logging_supported_2			: 1,
261ca68245eSMichael Lotz		smart_self_test_supported_2				: 1,
262ca68245eSMichael Lotz		media_serial_number_valid				: 1,
263ca68245eSMichael Lotz		media_card_pass_through_enabled			: 1,
264ca68245eSMichael Lotz		word_87_bit_4_reserved					: 1,
265ca68245eSMichael Lotz		general_purpose_logging_supported_2		: 1,
266ca68245eSMichael Lotz		word_87_bit_6_13_reserved				: 8,
267ca68245eSMichael Lotz		word_87_bit_14_one						: 1,
268ca68245eSMichael Lotz		word_87_bit_15_zero						: 1
269ca68245eSMichael Lotz	);
270ca68245eSMichael Lotz
27193c0a5d7SAxel Dörfler	B_LBITFIELD16_16(
272ca68245eSMichael Lotz		ultra_dma_0_supported					: 1,
273ca68245eSMichael Lotz		ultra_dma_1_supported					: 1,
274ca68245eSMichael Lotz		ultra_dma_2_supported					: 1,
275ca68245eSMichael Lotz		ultra_dma_3_supported					: 1,
276ca68245eSMichael Lotz		ultra_dma_4_supported					: 1,
277ca68245eSMichael Lotz		ultra_dma_5_supported					: 1,
278ca68245eSMichael Lotz		ultra_dma_6_supported					: 1,
279ca68245eSMichael Lotz		word_88_bit_7_reserved					: 1,
280ca68245eSMichael Lotz		ultra_dma_0_selected					: 1,
281ca68245eSMichael Lotz		ultra_dma_1_selected					: 1,
282ca68245eSMichael Lotz		ultra_dma_2_selected					: 1,
283ca68245eSMichael Lotz		ultra_dma_3_selected					: 1,
284ca68245eSMichael Lotz		ultra_dma_4_selected					: 1,
285ca68245eSMichael Lotz		ultra_dma_5_selected					: 1,
286ca68245eSMichael Lotz		ultra_dma_6_selected					: 1,
287ca68245eSMichael Lotz		word_88_bit_15_reserved					: 1
288ca68245eSMichael Lotz	);
289ca68245eSMichael Lotz
290ca68245eSMichael Lotz	uint16	security_erase_unit_duration;
291ca68245eSMichael Lotz	uint16	enhanced_security_erase_duration;
292ca68245eSMichael Lotz	uint16	current_advanced_power_management_value;
293ca68245eSMichael Lotz	uint16	master_password_revision_code;
294ca68245eSMichael Lotz
29593c0a5d7SAxel Dörfler	B_LBITFIELD16_5(
296ca68245eSMichael Lotz		device_0_hardware_reset_result			: 8,
297ca68245eSMichael Lotz		device_1_hardware_reset_result			: 5,
298ca68245eSMichael Lotz		cable_id_detected						: 1,
299ca68245eSMichael Lotz		word_93_bit_14_one						: 1,
300ca68245eSMichael Lotz		word_93_bit_15_zero						: 1
301ca68245eSMichael Lotz	);
302ca68245eSMichael Lotz
30393c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
304ca68245eSMichael Lotz		current_acoustic_management_value		: 8,
305ca68245eSMichael Lotz		recommended_acoustic_management_value	: 8
306ca68245eSMichael Lotz	);
307ca68245eSMichael Lotz
308ca68245eSMichael Lotz	uint16	word_95_99_reserved[5];
309ca68245eSMichael Lotz	uint64	lba48_sector_count;
310efc3172fSAxel Dörfler	uint16	word_104_reserved;
311efc3172fSAxel Dörfler	uint16	max_data_set_management_lba_range_blocks;
3120b46a85eSAxel Dörfler
31393c0a5d7SAxel Dörfler	B_LBITFIELD16_6(
3140b46a85eSAxel Dörfler		logical_sectors_per_physical_sector		: 4,	// 2^x exponent
3150b46a85eSAxel Dörfler		word_106_bit_4_11_reserved				: 8,
3160b46a85eSAxel Dörfler		logical_sector_not_512_bytes			: 1,
3170b46a85eSAxel Dörfler		multiple_logical_per_physical_sectors	: 1,
3180b46a85eSAxel Dörfler		word_106_bit_14_one						: 1,
3190b46a85eSAxel Dörfler		word_106_bit_15_zero					: 1
3200b46a85eSAxel Dörfler	);
3210b46a85eSAxel Dörfler
3220b46a85eSAxel Dörfler	uint16	word_107_116_reserved[10];
3230b46a85eSAxel Dörfler
3240b46a85eSAxel Dörfler	uint32	logical_sector_size;						// in words, see 106
3250b46a85eSAxel Dörfler
3260b46a85eSAxel Dörfler	uint16	word_119_126_reserved[8];
327ca68245eSMichael Lotz
32893c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
329ca68245eSMichael Lotz		removable_media_status_supported_2		: 2,	// 1 = supported
330ca68245eSMichael Lotz		word_127_bit_2_15_reserved				: 14
331ca68245eSMichael Lotz	);
332ca68245eSMichael Lotz
33393c0a5d7SAxel Dörfler	B_LBITFIELD16_9(
334ca68245eSMichael Lotz		security_supported						: 1,
335ca68245eSMichael Lotz		security_enabled						: 1,
336ca68245eSMichael Lotz		security_locked							: 1,
337ca68245eSMichael Lotz		security_frozen							: 1,
338ca68245eSMichael Lotz		security_count_expired					: 1,
339ca68245eSMichael Lotz		ehnaced_security_erase_supported		: 1,
340ca68245eSMichael Lotz		word_128_bit_6_7_reserved				: 2,
341ca68245eSMichael Lotz		security_level							: 1,	// 0 = high, 1 = max
342ca68245eSMichael Lotz		word_128_bit_9_15						: 7
343ca68245eSMichael Lotz	);
344ca68245eSMichael Lotz
345ca68245eSMichael Lotz	uint16	word_129_159_vendor_specific[31];
346ca68245eSMichael Lotz
34793c0a5d7SAxel Dörfler	B_LBITFIELD16_5(
348ca68245eSMichael Lotz		cfa_max_current_milli_ampers			: 12,
349ca68245eSMichael Lotz		cfa_power_mode_1_disabled				: 1,
350ca68245eSMichael Lotz		cfa_power_mode_1_required				: 1,
351ca68245eSMichael Lotz		word_160_bit_14_reserved				: 1,
352ca68245eSMichael Lotz		word_160_supported						: 1
353ca68245eSMichael Lotz	);
354ca68245eSMichael Lotz
355efc757f9SAdrien Destugues - PulkoMandy	uint16	word_161_167_reserved_compact_flash_assoc[7];
35693c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
357efc757f9SAdrien Destugues - PulkoMandy		device_nominal_form_factor				: 4,
358efc757f9SAdrien Destugues - PulkoMandy		word_168_bits_4_15_reserved				: 12
359efc757f9SAdrien Destugues - PulkoMandy	);
36093c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
361efc757f9SAdrien Destugues - PulkoMandy		data_set_management_support				: 1,
362efc757f9SAdrien Destugues - PulkoMandy		word_169_bits_1_15_reserved				: 15
363efc757f9SAdrien Destugues - PulkoMandy	);
364efc757f9SAdrien Destugues - PulkoMandy	uint16	additional_product_identifier[4];
365efc757f9SAdrien Destugues - PulkoMandy	uint16	word_174_175_reserved[2];
366ca68245eSMichael Lotz	uint16	current_media_serial_number[30];
3670b46a85eSAxel Dörfler	uint16	word_206_208_reserved[3];
3680b46a85eSAxel Dörfler
36993c0a5d7SAxel Dörfler	B_LBITFIELD16_3(
3700b46a85eSAxel Dörfler		logical_sector_offset					: 14,
3710b46a85eSAxel Dörfler		word_209_bit_14_one						: 1,
3720b46a85eSAxel Dörfler		word_209_bit_15_zero					: 1
3730b46a85eSAxel Dörfler	);
3740b46a85eSAxel Dörfler
3750b46a85eSAxel Dörfler	uint16	word_210_254_reserved[45];
376ca68245eSMichael Lotz
37793c0a5d7SAxel Dörfler	B_LBITFIELD16_2(
378ca68245eSMichael Lotz		signature								: 8,
379ca68245eSMichael Lotz		checksum								: 8
380ca68245eSMichael Lotz	);
3815ec5667dSAxel Dörfler
3825ec5667dSAxel Dörfler	uint64 SectorCount(bool& use48Bits, bool force)
3835ec5667dSAxel Dörfler	{
3845ec5667dSAxel Dörfler		if (lba48_supported && lba48_sector_count >= lba_sector_count) {
3855ec5667dSAxel Dörfler			use48Bits = true;
3865ec5667dSAxel Dörfler			return lba48_sector_count;
3875ec5667dSAxel Dörfler		}
3885ec5667dSAxel Dörfler
3895ec5667dSAxel Dörfler		use48Bits = force ? lba48_supported : false;
3905ec5667dSAxel Dörfler		return lba_sector_count;
3915ec5667dSAxel Dörfler	}
3925ec5667dSAxel Dörfler
3935ec5667dSAxel Dörfler	uint32 PhysicalSectorSize()
3945ec5667dSAxel Dörfler	{
3955ec5667dSAxel Dörfler		uint32 blockSize = 512;
3965ec5667dSAxel Dörfler		if (word_106_bit_14_one && !word_106_bit_15_zero) {
3975ec5667dSAxel Dörfler			// contains a valid block size configuration
3985ec5667dSAxel Dörfler			if (logical_sector_not_512_bytes)
3995ec5667dSAxel Dörfler				blockSize = logical_sector_size * 2;
4005ec5667dSAxel Dörfler
4015ec5667dSAxel Dörfler			if (multiple_logical_per_physical_sectors)
4025ec5667dSAxel Dörfler				return blockSize << logical_sectors_per_physical_sector;
4035ec5667dSAxel Dörfler		}
4045ec5667dSAxel Dörfler		return blockSize;
4055ec5667dSAxel Dörfler	}
4065ec5667dSAxel Dörfler
4075ec5667dSAxel Dörfler	uint32 SectorSize()
4085ec5667dSAxel Dörfler	{
4095ec5667dSAxel Dörfler		if (word_106_bit_14_one && !word_106_bit_15_zero) {
4105ec5667dSAxel Dörfler			// contains a valid block size configuration
4115ec5667dSAxel Dörfler			if (logical_sector_not_512_bytes)
4125ec5667dSAxel Dörfler				return logical_sector_size * 2;
4135ec5667dSAxel Dörfler		}
4145ec5667dSAxel Dörfler		return 512;
4155ec5667dSAxel Dörfler	}
4165ec5667dSAxel Dörfler
4175ec5667dSAxel Dörfler	uint32 BlockOffset()
4185ec5667dSAxel Dörfler	{
4195ec5667dSAxel Dörfler		if (word_209_bit_14_one && !word_209_bit_15_zero) {
4205ec5667dSAxel Dörfler			// contains a valid logical block offset configuration
4215ec5667dSAxel Dörfler			return logical_sector_offset;
4225ec5667dSAxel Dörfler		}
4235ec5667dSAxel Dörfler		return 0;
4245ec5667dSAxel Dörfler	}
425ca68245eSMichael Lotz} _PACKED ata_device_infoblock;
426ca68245eSMichael Lotz
4275ec5667dSAxel Dörfler
428ca68245eSMichael Lotz#endif // ATA_INFOBLOCK_H
429