pcata.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_PCATA_H
#define _SYS_PCATA_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define FALSE 0
#define TRUE 1
#if defined(DEBUG)
#define ATA_DEBUG 1
#endif /* defined(DEBUG) */
/*
* port offsets from base address ioaddr1
*/
/*
* port offsets from base address ioaddr2
*/
/*
* Device control register
*/
/*
* Status bits from AT_STATUS register
*/
/*
* Status bits from AT_ERROR register
*/
/*
* Drive selectors for AT_DRVHD register
*/
/*
* ATA commands.
*/
/*
* ata device type
*/
#define ATA_DEV_NONE 0
#define ATA_DEV_DISK 1
/*
* write into config. opt. reg to configure level interrupt and
* I/O mapped addressing.
*/
#define LEVEL_MODE_IO_MAP 0x41
/*
*/
/* enabled if bit is CLEARED!!! */
/* enabled if bit is SET!!! */
/*
* direction bits
* for ac_direction
*/
#define AT_NO_DATA 0 /* No data transfer */
/*
* status bits for ab_ctl_status
*/
#define ATA_ONLINE 0
#define ATA_OFFLINE 1
#define ATA_PRESENT 2
#define B_PASSTHRU 0x1000000
/*
* timeout and timing parameters
*
*/
/* for non attached driver or when instance is unknown */
/* for attached driver or when instance is known */
/* for non attached driver or when instance is unknown */
/* for attached driver or when instance is known */
struct ata_cmpkt {
int cp_bytexfer; /* bytes xfer in this operation */
char ac_cdb; /* target driver command */
char ac_scb; /* controller status aft cmd */
int ac_bytes_per_block; /* blk mode factor per xfer */
int cp_resid; /* data bytes not transferred */
int cp_reason; /* error status */
int cp_flags;
void *cp_passthru;
char ac_direction; /* AT_IN - read AT_OUT - write */
int cp_retry;
/*
* task file registers setting
*/
/* sec count in ac_pkt */
#ifdef NOT_USED
#endif
/*
* error status
*/
};
/* structure of 'Read Parameters' command */
struct atarpbuf {
/* WORD */
/* OFFSET COMMENT */
};
/* direct coupled disk driver command */
/* driver error code */
#define DERR_SUCCESS 0 /* success */
/* reason code for completion status */
#define CPS_SUCCESS 0 /* command completes with no err */
/* flags definitions */
/* debug definitions */
#ifdef ATA_DEBUG
#define DENT 0x0001
#define DPKT 0x0002
#define DIO 0x0004
#define DDAT 0x0008
#define DPCM 0x0010
#define DINT 0x0040
#define DINIT 0x0080
#define DOPEN 0x0100
#endif /* ATA_DEBUG */
/*
* misc definition
*/
#define DDI_XSUSPEND 1
#define DDI_XRESUME 2
#define CFLAG_ERROR 1
#define CFLAG_FREE 2
#define CTL_SEND_FAILURE 1
#define CTL_SEND_SUCCESS 0
#define RETRY_CNT 10
#define PCATA_GO_RETRY 1
#define PCATA_WAIT_CNT 100
#define PCIDE_OUTB(a, b, c) csx_Put8(a, b, c);\
drv_usecwait(5);
/*
* also UNIT seems to be incompatible with PCATA_SETMINOR
* also in sysmacros.h O_MAXMIN seems to be 0xff which means << 10 is bad
*/
#define MAX_SLICES 16
#define PCATA_NAME "pcata"
#if defined(_SUNOS_VTOC_16)
#define VTOC_OFFSET 1
#elif defined(_SUNOS_VTOC_8)
#define VTOC_OFFSET 0
#else
#endif
#define USLICE_WHOLE 2
typedef struct {
int fdiskpresent; /* fdisk present */
int uidx; /* UNIX partition number */
} dsk_label_t;
/*
* linked list of drives on this controller
*/
typedef struct ata_unit {
int au_cyl; /* cylinders */
int au_acyl; /* alternate cylinders */
int au_hd;
int au_sec;
int au_blksz;
short au_block_factor;
short au_bytes_per_block;
} ata_unit_t;
/*
* pcata_cftable_t and pcata_cftable_params_t structures are used
* to store values from the CISTPL_CFTABLE_ENTRY tuples.
*/
typedef struct pcata_cftable_params_t {
int ranges; /* number of IO range */
typedef struct pcata_cftable_t {
pcata_cftable_params_t p; /* parameters */
struct pcata_cftable_t *prev;
struct pcata_cftable_t *next;
typedef struct pcata_cis_vars_t {
/* misc card requirements */
typedef struct pcata_biotimeout {
#define ATA_MAXDRIVE 8
/*
* soft state structure
*/
typedef struct ata_soft {
int flags; /* misc state info */
int sn; /* socket number */
int checkmedia_flag;
int ejected_media_flag;
int instance; /* instantiation of ourselves */
int chr_open; /* open in character mode */
int blk_open; /* open in block mode */
/*
* wait for cv_broadcast of condvar_mediastate
* in pcata_check_media
*/
int intr_pending; /* an interrupt is pending */
int softint_pending;
int write_in_progress;
void *ab_lkarg;
/*
* Even though we can only have 2 targets, we need 8 slots
* for the generic code
*/
/*
* port addresses associated with ioaddr1
*/
/*
* port addresses associated with ioaddr2
*/
/* until unit structure is alloc */
/* unit structure is alloc */
/* unit structure is alloc */
int ab_max_transfer;
} ata_soft_t;
/*
* flags in ata_soft.flags field
*/
/*
* flags in card_state field
*/
/*
* UNTIMEOUT() macro to make sure we're not trying untimeout a bogus timeout
*/
if (utt) { \
utt = 0; \
} \
}
/*
* global variables
*/
/*
* linkage to soft state structures by instance (see ddi_get_soft_state)
*/
extern void *pcata_soft;
extern char *pcata_name;
extern int pcata_debug;
extern struct cb_ops pcata_cb_ops;
/*
* pcata.c
*/
char *pcata_CS_etext(int ret);
void **result);
/*
* pcide.c
*/
int _init(void);
int _fini(void);
void pcata_byte_swap(char *buf, int n);
/*
* pcdisk.c
*/
int *rval_p);
/*
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PCATA_H */