linux/include/uapi/linux/hdreg.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _LINUX_HDREG_H
#define _LINUX_HDREG_H

#include <linux/types.h>

/*
 * Command Header sizes for IOCTL commands
 */

#define HDIO_DRIVE_CMD_HDR_SIZE
#define HDIO_DRIVE_HOB_HDR_SIZE
#define HDIO_DRIVE_TASK_HDR_SIZE

#define IDE_DRIVE_TASK_NO_DATA
#ifndef __KERNEL__
#define IDE_DRIVE_TASK_INVALID
#define IDE_DRIVE_TASK_SET_XFER
#define IDE_DRIVE_TASK_IN
#define IDE_DRIVE_TASK_OUT
#endif
#define IDE_DRIVE_TASK_RAW_WRITE

/*
 * Define standard taskfile in/out register
 */
#define IDE_TASKFILE_STD_IN_FLAGS
#define IDE_HOB_STD_IN_FLAGS
#ifndef __KERNEL__
#define IDE_TASKFILE_STD_OUT_FLAGS
#define IDE_HOB_STD_OUT_FLAGS

typedef unsigned char task_ioreg_t;
typedef unsigned long sata_ioreg_t;
#endif

ide_reg_valid_t;

ide_task_request_t;

ide_ioctl_request_t;

struct hd_drive_cmd_hdr {};

#ifndef __KERNEL__
typedef struct hd_drive_task_hdr {
	__u8 data;
	__u8 feature;
	__u8 sector_count;
	__u8 sector_number;
	__u8 low_cylinder;
	__u8 high_cylinder;
	__u8 device_head;
	__u8 command;
} task_struct_t;

typedef struct hd_drive_hob_hdr {
	__u8 data;
	__u8 feature;
	__u8 sector_count;
	__u8 sector_number;
	__u8 low_cylinder;
	__u8 high_cylinder;
	__u8 device_head;
	__u8 control;
} hob_struct_t;
#endif

#define TASKFILE_NO_DATA

#define TASKFILE_IN
#define TASKFILE_MULTI_IN

#define TASKFILE_OUT
#define TASKFILE_MULTI_OUT
#define TASKFILE_IN_OUT

#define TASKFILE_IN_DMA
#define TASKFILE_OUT_DMA
#define TASKFILE_IN_DMAQ
#define TASKFILE_OUT_DMAQ

#ifndef __KERNEL__
#define TASKFILE_P_IN
#define TASKFILE_P_OUT
#define TASKFILE_P_IN_DMA
#define TASKFILE_P_OUT_DMA
#define TASKFILE_P_IN_DMAQ
#define TASKFILE_P_OUT_DMAQ
#define TASKFILE_48
#define TASKFILE_INVALID
#endif

#ifndef __KERNEL__
/* ATA/ATAPI Commands pre T13 Spec */
#define WIN_NOP
/*
 *	0x01->0x02 Reserved
 */
#define CFA_REQ_EXT_ERROR_CODE
/*
 *	0x04->0x07 Reserved
 */
#define WIN_SRST
#define WIN_DEVICE_RESET
/*
 *	0x09->0x0F Reserved
 */
#define WIN_RECAL
#define WIN_RESTORE
/*
 *	0x10->0x1F Reserved
 */
#define WIN_READ
#define WIN_READ_ONCE
#define WIN_READ_LONG
#define WIN_READ_LONG_ONCE
#define WIN_READ_EXT
#define WIN_READDMA_EXT
#define WIN_READDMA_QUEUED_EXT
#define WIN_READ_NATIVE_MAX_EXT
/*
 *	0x28
 */
#define WIN_MULTREAD_EXT
/*
 *	0x2A->0x2F Reserved
 */
#define WIN_WRITE
#define WIN_WRITE_ONCE
#define WIN_WRITE_LONG
#define WIN_WRITE_LONG_ONCE
#define WIN_WRITE_EXT
#define WIN_WRITEDMA_EXT
#define WIN_WRITEDMA_QUEUED_EXT
#define WIN_SET_MAX_EXT
#define CFA_WRITE_SECT_WO_ERASE
#define WIN_MULTWRITE_EXT
/*
 *	0x3A->0x3B Reserved
 */
#define WIN_WRITE_VERIFY
/*
 *	0x3D->0x3F Reserved
 */
#define WIN_VERIFY
#define WIN_VERIFY_ONCE
#define WIN_VERIFY_EXT
/*
 *	0x43->0x4F Reserved
 */
#define WIN_FORMAT
/*
 *	0x51->0x5F Reserved
 */
#define WIN_INIT
/*
 *	0x61->0x5F Reserved
 */
#define WIN_SEEK

#define CFA_TRANSLATE_SECTOR
#define WIN_DIAGNOSE
#define WIN_SPECIFY
#define WIN_DOWNLOAD_MICROCODE
#define WIN_STANDBYNOW2
#define WIN_STANDBY2
#define WIN_SETIDLE2
#define WIN_CHECKPOWERMODE2
#define WIN_SLEEPNOW2
/*
 *	0x9A VENDOR
 */
#define WIN_PACKETCMD
#define WIN_PIDENTIFY
#define WIN_QUEUED_SERVICE
#define WIN_SMART
#define CFA_ERASE_SECTORS
#define WIN_MULTREAD
#define WIN_MULTWRITE
#define WIN_SETMULT
#define WIN_READDMA_QUEUED
#define WIN_READDMA
#define WIN_READDMA_ONCE
#define WIN_WRITEDMA
#define WIN_WRITEDMA_ONCE
#define WIN_WRITEDMA_QUEUED
#define CFA_WRITE_MULTI_WO_ERASE
#define WIN_GETMEDIASTATUS
#define WIN_ACKMEDIACHANGE
#define WIN_POSTBOOT
#define WIN_PREBOOT
#define WIN_DOORLOCK
#define WIN_DOORUNLOCK
#define WIN_STANDBYNOW1
#define WIN_IDLEIMMEDIATE
#define WIN_STANDBY
#define WIN_SETIDLE1
#define WIN_READ_BUFFER
#define WIN_CHECKPOWERMODE1
#define WIN_SLEEPNOW1
#define WIN_FLUSH_CACHE
#define WIN_WRITE_BUFFER
#define WIN_WRITE_SAME
	/* SET_FEATURES 0x22 or 0xDD */
#define WIN_FLUSH_CACHE_EXT
#define WIN_IDENTIFY
#define WIN_MEDIAEJECT
#define WIN_IDENTIFY_DMA
#define WIN_SETFEATURES
#define EXABYTE_ENABLE_NEST
#define WIN_SECURITY_SET_PASS
#define WIN_SECURITY_UNLOCK
#define WIN_SECURITY_ERASE_PREPARE
#define WIN_SECURITY_ERASE_UNIT
#define WIN_SECURITY_FREEZE_LOCK
#define WIN_SECURITY_DISABLE
#define WIN_READ_NATIVE_MAX
#define WIN_SET_MAX
#define DISABLE_SEAGATE

/* WIN_SMART sub-commands */

#define SMART_READ_VALUES
#define SMART_READ_THRESHOLDS
#define SMART_AUTOSAVE
#define SMART_SAVE
#define SMART_IMMEDIATE_OFFLINE
#define SMART_READ_LOG_SECTOR
#define SMART_WRITE_LOG_SECTOR
#define SMART_WRITE_THRESHOLDS
#define SMART_ENABLE
#define SMART_DISABLE
#define SMART_STATUS
#define SMART_AUTO_OFFLINE

/* Password used in TF4 & TF5 executing SMART commands */

#define SMART_LCYL_PASS
#define SMART_HCYL_PASS

/* WIN_SETFEATURES sub-commands */
#define SETFEATURES_EN_8BIT
#define SETFEATURES_EN_WCACHE
#define SETFEATURES_DIS_DEFECT
#define SETFEATURES_EN_APM
#define SETFEATURES_EN_SAME_R
#define SETFEATURES_DIS_MSN
#define SETFEATURES_DIS_RETRY
#define SETFEATURES_EN_AAM
#define SETFEATURES_RW_LONG
#define SETFEATURES_SET_CACHE
#define SETFEATURES_DIS_RLA
#define SETFEATURES_EN_RI
#define SETFEATURES_EN_SI
#define SETFEATURES_DIS_RPOD
#define SETFEATURES_DIS_ECC
#define SETFEATURES_DIS_8BIT
#define SETFEATURES_DIS_WCACHE
#define SETFEATURES_EN_DEFECT
#define SETFEATURES_DIS_APM
#define SETFEATURES_EN_ECC
#define SETFEATURES_EN_MSN
#define SETFEATURES_EN_RETRY
#define SETFEATURES_EN_RLA
#define SETFEATURES_PREFETCH
#define SETFEATURES_EN_REST
#define SETFEATURES_4B_RW_LONG
#define SETFEATURES_DIS_AAM
#define SETFEATURES_EN_RPOD
#define SETFEATURES_DIS_RI
#define SETFEATURES_EN_SAME_M
#define SETFEATURES_DIS_SI

/* WIN_SECURITY sub-commands */

#define SECURITY_SET_PASSWORD
#define SECURITY_UNLOCK
#define SECURITY_ERASE_PREPARE
#define SECURITY_ERASE_UNIT
#define SECURITY_FREEZE_LOCK
#define SECURITY_DISABLE_PASSWORD
#endif /* __KERNEL__ */

struct hd_geometry {};

/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
#define HDIO_GETGEO
#define HDIO_GET_UNMASKINTR
#define HDIO_GET_MULTCOUNT
#define HDIO_GET_QDMA

#define HDIO_SET_XFER

#define HDIO_OBSOLETE_IDENTITY
#define HDIO_GET_KEEPSETTINGS
#define HDIO_GET_32BIT
#define HDIO_GET_NOWERR
#define HDIO_GET_DMA
#define HDIO_GET_NICE
#define HDIO_GET_IDENTITY
#define HDIO_GET_WCACHE
#define HDIO_GET_ACOUSTIC
#define HDIO_GET_ADDRESS

#define HDIO_GET_BUSSTATE
#define HDIO_TRISTATE_HWIF
#define HDIO_DRIVE_RESET
#define HDIO_DRIVE_TASKFILE
#define HDIO_DRIVE_TASK
#define HDIO_DRIVE_CMD
#define HDIO_DRIVE_CMD_AEB

/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
#define HDIO_SET_MULTCOUNT
#define HDIO_SET_UNMASKINTR
#define HDIO_SET_KEEPSETTINGS
#define HDIO_SET_32BIT
#define HDIO_SET_NOWERR
#define HDIO_SET_DMA
#define HDIO_SET_PIO_MODE
#ifndef __KERNEL__
#define HDIO_SCAN_HWIF
#define HDIO_UNREGISTER_HWIF
#endif
#define HDIO_SET_NICE
#define HDIO_SET_WCACHE
#define HDIO_SET_ACOUSTIC
#define HDIO_SET_BUSSTATE
#define HDIO_SET_QDMA
#define HDIO_SET_ADDRESS

/* bus states */
enum {};

/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */
/* 0x330 is reserved - used to be HDIO_GETGEO_BIG */
/* 0x331 is reserved - used to be HDIO_GETGEO_BIG_RAW */
/* 0x338 is reserved - used to be HDIO_SET_IDE_SCSI */
/* 0x339 is reserved - used to be HDIO_SET_SCSI_IDE */

#define __NEW_HD_DRIVE_ID

#ifndef __KERNEL__
/*
 * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec.
 *
 * If you change something here, please remember to update fix_driveid() in
 * ide/probe.c.
 */
struct hd_driveid {
	unsigned short	config;		/* lots of obsolete bit flags */
	unsigned short	cyls;		/* Obsolete, "physical" cyls */
	unsigned short	reserved2;	/* reserved (word 2) */
	unsigned short	heads;		/* Obsolete, "physical" heads */
	unsigned short	track_bytes;	/* unformatted bytes per track */
	unsigned short	sector_bytes;	/* unformatted bytes per sector */
	unsigned short	sectors;	/* Obsolete, "physical" sectors per track */
	unsigned short	vendor0;	/* vendor unique */
	unsigned short	vendor1;	/* vendor unique */
	unsigned short	vendor2;	/* Retired vendor unique */
	unsigned char	serial_no[20];	/* 0 = not_specified */
	unsigned short	buf_type;	/* Retired */
	unsigned short	buf_size;	/* Retired, 512 byte increments
					 * 0 = not_specified
					 */
	unsigned short	ecc_bytes;	/* for r/w long cmds; 0 = not_specified */
	unsigned char	fw_rev[8];	/* 0 = not_specified */
	unsigned char	model[40];	/* 0 = not_specified */
	unsigned char	max_multsect;	/* 0=not_implemented */
	unsigned char	vendor3;	/* vendor unique */
	unsigned short	dword_io;	/* 0=not_implemented; 1=implemented */
	unsigned char	vendor4;	/* vendor unique */
	unsigned char	capability;	/* (upper byte of word 49)
					 *  3:	IORDYsup
					 *  2:	IORDYsw
					 *  1:	LBA
					 *  0:	DMA
					 */
	unsigned short	reserved50;	/* reserved (word 50) */
	unsigned char	vendor5;	/* Obsolete, vendor unique */
	unsigned char	tPIO;		/* Obsolete, 0=slow, 1=medium, 2=fast */
	unsigned char	vendor6;	/* Obsolete, vendor unique */
	unsigned char	tDMA;		/* Obsolete, 0=slow, 1=medium, 2=fast */
	unsigned short	field_valid;	/* (word 53)
					 *  2:	ultra_ok	word  88
					 *  1:	eide_ok		words 64-70
					 *  0:	cur_ok		words 54-58
					 */
	unsigned short	cur_cyls;	/* Obsolete, logical cylinders */
	unsigned short	cur_heads;	/* Obsolete, l heads */
	unsigned short	cur_sectors;	/* Obsolete, l sectors per track */
	unsigned short	cur_capacity0;	/* Obsolete, l total sectors on drive */
	unsigned short	cur_capacity1;	/* Obsolete, (2 words, misaligned int)     */
	unsigned char	multsect;	/* current multiple sector count */
	unsigned char	multsect_valid;	/* when (bit0==1) multsect is ok */
	unsigned int	lba_capacity;	/* Obsolete, total number of sectors */
	unsigned short	dma_1word;	/* Obsolete, single-word dma info */
	unsigned short	dma_mword;	/* multiple-word dma info */
	unsigned short  eide_pio_modes; /* bits 0:mode3 1:mode4 */
	unsigned short  eide_dma_min;	/* min mword dma cycle time (ns) */
	unsigned short  eide_dma_time;	/* recommended mword dma cycle time (ns) */
	unsigned short  eide_pio;       /* min cycle time (ns), no IORDY  */
	unsigned short  eide_pio_iordy; /* min cycle time (ns), with IORDY */
	unsigned short	words69_70[2];	/* reserved words 69-70
					 * future command overlap and queuing
					 */
	unsigned short	words71_74[4];	/* reserved words 71-74
					 * for IDENTIFY PACKET DEVICE command
					 */
	unsigned short  queue_depth;	/* (word 75)
					 * 15:5	reserved
					 *  4:0	Maximum queue depth -1
					 */
	unsigned short  words76_79[4];	/* reserved words 76-79 */
	unsigned short  major_rev_num;	/* (word 80) */
	unsigned short  minor_rev_num;	/* (word 81) */
	unsigned short  command_set_1;	/* (word 82) supported
					 * 15:	Obsolete
					 * 14:	NOP command
					 * 13:	READ_BUFFER
					 * 12:	WRITE_BUFFER
					 * 11:	Obsolete
					 * 10:	Host Protected Area
					 *  9:	DEVICE Reset
					 *  8:	SERVICE Interrupt
					 *  7:	Release Interrupt
					 *  6:	look-ahead
					 *  5:	write cache
					 *  4:	PACKET Command
					 *  3:	Power Management Feature Set
					 *  2:	Removable Feature Set
					 *  1:	Security Feature Set
					 *  0:	SMART Feature Set
					 */
	unsigned short  command_set_2;	/* (word 83)
					 * 15:	Shall be ZERO
					 * 14:	Shall be ONE
					 * 13:	FLUSH CACHE EXT
					 * 12:	FLUSH CACHE
					 * 11:	Device Configuration Overlay
					 * 10:	48-bit Address Feature Set
					 *  9:	Automatic Acoustic Management
					 *  8:	SET MAX security
					 *  7:	reserved 1407DT PARTIES
					 *  6:	SetF sub-command Power-Up
					 *  5:	Power-Up in Standby Feature Set
					 *  4:	Removable Media Notification
					 *  3:	APM Feature Set
					 *  2:	CFA Feature Set
					 *  1:	READ/WRITE DMA QUEUED
					 *  0:	Download MicroCode
					 */
	unsigned short  cfsse;		/* (word 84)
					 * cmd set-feature supported extensions
					 * 15:	Shall be ZERO
					 * 14:	Shall be ONE
					 * 13:6	reserved
					 *  5:	General Purpose Logging
					 *  4:	Streaming Feature Set
					 *  3:	Media Card Pass Through
					 *  2:	Media Serial Number Valid
					 *  1:	SMART selt-test supported
					 *  0:	SMART error logging
					 */
	unsigned short  cfs_enable_1;	/* (word 85)
					 * command set-feature enabled
					 * 15:	Obsolete
					 * 14:	NOP command
					 * 13:	READ_BUFFER
					 * 12:	WRITE_BUFFER
					 * 11:	Obsolete
					 * 10:	Host Protected Area
					 *  9:	DEVICE Reset
					 *  8:	SERVICE Interrupt
					 *  7:	Release Interrupt
					 *  6:	look-ahead
					 *  5:	write cache
					 *  4:	PACKET Command
					 *  3:	Power Management Feature Set
					 *  2:	Removable Feature Set
					 *  1:	Security Feature Set
					 *  0:	SMART Feature Set
					 */
	unsigned short  cfs_enable_2;	/* (word 86)
					 * command set-feature enabled
					 * 15:	Shall be ZERO
					 * 14:	Shall be ONE
					 * 13:	FLUSH CACHE EXT
					 * 12:	FLUSH CACHE
					 * 11:	Device Configuration Overlay
					 * 10:	48-bit Address Feature Set
					 *  9:	Automatic Acoustic Management
					 *  8:	SET MAX security
					 *  7:	reserved 1407DT PARTIES
					 *  6:	SetF sub-command Power-Up
					 *  5:	Power-Up in Standby Feature Set
					 *  4:	Removable Media Notification
					 *  3:	APM Feature Set
					 *  2:	CFA Feature Set
					 *  1:	READ/WRITE DMA QUEUED
					 *  0:	Download MicroCode
					 */
	unsigned short  csf_default;	/* (word 87)
					 * command set-feature default
					 * 15:	Shall be ZERO
					 * 14:	Shall be ONE
					 * 13:6	reserved
					 *  5:	General Purpose Logging enabled
					 *  4:	Valid CONFIGURE STREAM executed
					 *  3:	Media Card Pass Through enabled
					 *  2:	Media Serial Number Valid
					 *  1:	SMART selt-test supported
					 *  0:	SMART error logging
					 */
	unsigned short  dma_ultra;	/* (word 88) */
	unsigned short	trseuc;		/* time required for security erase */
	unsigned short	trsEuc;		/* time required for enhanced erase */
	unsigned short	CurAPMvalues;	/* current APM values */
	unsigned short	mprc;		/* master password revision code */
	unsigned short	hw_config;	/* hardware config (word 93)
					 * 15:	Shall be ZERO
					 * 14:	Shall be ONE
					 * 13:
					 * 12:
					 * 11:
					 * 10:
					 *  9:
					 *  8:
					 *  7:
					 *  6:
					 *  5:
					 *  4:
					 *  3:
					 *  2:
					 *  1:
					 *  0:	Shall be ONE
					 */
	unsigned short	acoustic;	/* (word 94)
					 * 15:8	Vendor's recommended value
					 *  7:0	current value
					 */
	unsigned short	msrqs;		/* min stream request size */
	unsigned short	sxfert;		/* stream transfer time */
	unsigned short	sal;		/* stream access latency */
	unsigned int	spg;		/* stream performance granularity */
	unsigned long long lba_capacity_2;/* 48-bit total number of sectors */
	unsigned short	words104_125[22];/* reserved words 104-125 */
	unsigned short	last_lun;	/* (word 126) */
	unsigned short	word127;	/* (word 127) Feature Set
					 * Removable Media Notification
					 * 15:2	reserved
					 *  1:0	00 = not supported
					 *	01 = supported
					 *	10 = reserved
					 *	11 = reserved
					 */
	unsigned short	dlf;		/* (word 128)
					 * device lock function
					 * 15:9	reserved
					 *  8	security level 1:max 0:high
					 *  7:6	reserved
					 *  5	enhanced erase
					 *  4	expire
					 *  3	frozen
					 *  2	locked
					 *  1	en/disabled
					 *  0	capability
					 */
	unsigned short  csfo;		/*  (word 129)
					 * current set features options
					 * 15:4	reserved
					 *  3:	auto reassign
					 *  2:	reverting
					 *  1:	read-look-ahead
					 *  0:	write cache
					 */
	unsigned short	words130_155[26];/* reserved vendor words 130-155 */
	unsigned short	word156;	/* reserved vendor word 156 */
	unsigned short	words157_159[3];/* reserved vendor words 157-159 */
	unsigned short	cfa_power;	/* (word 160) CFA Power Mode
					 * 15 word 160 supported
					 * 14 reserved
					 * 13
					 * 12
					 * 11:0
					 */
	unsigned short	words161_175[15];/* Reserved for CFA */
	unsigned short	words176_205[30];/* Current Media Serial Number */
	unsigned short	words206_254[49];/* reserved words 206-254 */
	unsigned short	integrity_word;	/* (word 255)
					 * 15:8 Checksum
					 *  7:0 Signature
					 */
};
#endif /* __KERNEL__ */

/*
 * IDE "nice" flags. These are used on a per drive basis to determine
 * when to be nice and give more bandwidth to the other devices which
 * share the same IDE bus.
 */
#define IDE_NICE_DSC_OVERLAP
#define IDE_NICE_ATAPI_OVERLAP
#define IDE_NICE_1
#ifndef __KERNEL__
#define IDE_NICE_0
#define IDE_NICE_2
#endif

#endif	/* _LINUX_HDREG_H */