ata_common.h revision fe072f421ec51952432306add7d50852ad1921b2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ATA_COMMON_H
#define _ATA_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#include "ghd.h"
#include "pciide.h"
#include "ata_cmd.h"
#include "ata_fsm.h"
#include "ata_debug.h"
/*
* device types
*/
#define ATA_DEV_NONE 0
#define ATA_DEV_DISK 1
#define ATA_DEV_ATAPI 2
/*
* Largest sector allowed in 28 bit mode
*/
#define MAX_28BIT_CAPACITY 0xfffffff
/*
* Largest sector count allowed for device firmware file in one command.
*/
#define MAX_FWFILE_SIZE_ONECMD 0xffff
/*
* ata-options property configuration bits
*/
#define ATA_OPTIONS_DMA 0x01
/* ad_flags (per-drive) */
#define AD_DISK 0x02
#define AD_MUTEX_INIT 0x04
#define AD_NO_CDB_INTR 0x20
#define AD_1SECTOR 0x40
#define AD_BLLBA48 0x400
/* max targets and luns */
#define ATA_MAXTARG 2
#define ATA_MAXLUN 16
/*
*/
/*
* Controller port address defaults
*/
#define ATA_BASE0 0x1f0
#define ATA_BASE1 0x170
/*
* port offsets from base address ioaddr1
*/
/*
* port offsets from base address ioaddr2
*/
/* Device control register */
/*
* ATA-6 spec
* In 48-bit addressing, reading the LBA location and count
* registers when the high-order bit is set reads the "previous
* content" (LBA bits 47:24, count bits 15:8) instead of the
* "most recent" values (LBA bits 23:0, count bits 7:0).
*/
/*
* Status bits from AT_STATUS register
*/
/*
* Status bits from AT_ERROR register
*/
/* ICRC error in ATA-4 and newer */
/*
* Drive selectors for AT_DRVHD register
*/
/*
* Feature register bits
*/
/*
* Set feature register definitions.
*/
/*
* common bits and options for set features (ATC_SET_FEAT)
*/
#define FC_WRITE_CACHE_ON 0x02
#define FC_WRITE_CACHE_OFF 0x82
/* Test which version of ATA is supported */
#define IS_ATA_VERSION_SUPPORTED(idp, n) \
/* Test if supported version >= ATA-n */
#define IS_ATA_VERSION_GE(idp, n) \
(idp->ai_majorversion != 0) && \
/* Test whether a device is a CD drive */
/* Test whether the device support write cache */
#define IS_WRITE_CACHE_SUPPORTED(x) \
/* macros from old common hba code */
/*
*
* per-controller soft-state data structure
*
*/
typedef struct ata_ctl {
int ac_max_transfer; /* max transfer in sectors */
/*
* port addresses associated with ioaddr1
*/
/*
* port addresses associated with ioaddr2
*/
/*
* handle and port addresss for PCI-IDE Bus Master controller
*/
/*
*/
/*
* data for managing ARQ on ATAPI devices
*/
/*
* Power Management
*/
int ac_pm_support;
int ac_pm_level;
} ata_ctl_t;
/* ac_flags (per-controller) */
#define AC_GHD_INIT 0x02
#define AC_ATAPI_INIT 0x04
#define AC_DISK_INIT 0x08
#define AC_ATTACHED 0x10
#define AC_SCSI_HBA_TRAN_ALLOC 0x1000
#define AC_SCSI_HBA_ATTACH 0x2000
#define AC_BMSTATREG_PIO_BROKEN 0x80000000
/*
* Bug 1256489:
*
* If AC_BSY_WAIT needs to be set for laptops that do
* drop after a resume.
*/
/* ac_timing_flags (per-controller) */
/* Identify drive data */
struct ata_id {
/* WORD */
/* OFFSET COMMENT */
};
/* Identify Drive: general config bits - word 0 */
#define ATA_ID_REM_DRV 0x80
#define ATA_ID_COMPACT_FLASH 0x848a
#define ATA_ID_CF_TO_ATA 0x040a
#define ATA_ID_INCMPT 0x0004
/* Identify Drive: common capability bits - word 49 */
#define ATAC_DMA_SUPPORT 0x0100
#define ATAC_LBA_SUPPORT 0x0200
#define ATAC_IORDY_DISABLE 0x0400
#define ATAC_IORDY_SUPPORT 0x0800
#define ATAC_STANDBYTIMER 0x2000
#define ATAC_ATA_TYPE_MASK 0x8001
#define ATAC_ATA_TYPE 0x0000
#define ATAC_ATAPI_TYPE_MASK 0xc000
#define ATAC_ATAPI_TYPE 0x8000
/* Identify Driver ai_validinfo (word 53) */
/* Identify Drive: ai_dworddma (word 63) */
/* Identify Drive: ai_advpiomode (word 64) */
/* Identify Drive: ai_majorversion (word 80) */
/* Identify Drive: ai_features85 (word 85) */
/* Identify Drive: ai_ultradma (word 88) */
/* per-drive data struct */
typedef struct ata_drv {
/* Used by atapi side only */
/* Used by disk side only */
struct scsi_device *ad_device;
struct scsi_inquiry ad_inquiry;
struct ctl_obj ad_ctl_obj;
/*
* Geometry note: The following three values are the geometry
* that the driver will use. They may differ from the
* on ata_fix_large_disk_geometry in ata_disk.c for more
* details.
*/
short ad_block_factor;
short ad_bytes_per_block;
/*
* Support for 48-bit LBA (ATA-6)
*/
/*
*/
} ata_drv_t;
/* values for ad_dma_cap */
#define ATA_DMA_ULTRAMODE 0x1
#define ATA_DMA_MWORDMODE 0x2
typedef struct ata_tgt {
int at_arq;
} ata_tgt_t;
/* values for ad_pciide_dma */
#define ATA_DMA_OFF 0x0
#define ATA_DMA_ON 0x1
#define ATA_DMA_UNINITIALIZED 0x2
/*
* (ata_pkt_t *) to (gcmd_t *)
*/
/*
* (gcmd_t *) to (ata_pkt_t *)
*/
/*
* (gtgt_t *) to (ata_ctl_t *)
*/
/*
* (gtgt_t *) to (ata_tgt_t *)
*/
/*
* (gtgt_t *) to (ata_drv_t *)
*/
/*
* (gcmd_t *) to (ata_tgt_t *)
*/
/*
* (gcmd_t *) to (ata_drv_t *)
*/
/*
* (ata_pkt_t *) to (ata_drv_t *)
*/
/*
* (struct hba_tran *) to (ata_ctl_t *)
*/
/*
* ata common packet structure
*/
typedef struct ata_pkt {
int ap_sg_cnt; /* number of entries in S/G list */
/* command, starting sector number, sector count */
/* saved status and error registers for error case */
/* Used by disk side */
char ap_cdb; /* disk command */
char ap_scb; /* status after disk cmd */
/* Used by atapi side */
} ata_pkt_t;
/*
* defines for ap_flags
*/
#define AP_ARQ_OKAY 0x2000
#define AP_ARQ_ERROR 0x4000
/*
* public function prototypes
*/
/*
* PCIIDE DMA (Bus Mastering) functions and data in ata_dma.c
*/
extern ddi_dma_attr_t ata_pciide_dma_attr;
extern int ata_dma_disabled;
int single_segment, int seg_index);
#ifdef __cplusplus
}
#endif
#endif /* _ATA_COMMON_H */