/*---------------------------------------------------------------------------*\
 *   
 *   Copyright (C) 2006 AVM GmbH <fritzbox_info@avm.de>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation version 2 of the License.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
\*---------------------------------------------------------------------------*/

#if !defined (_ahcirx_h_)
#define _ahcirx_h_

#include "ahcidef.h"

/*---------------------------------------------------------------------------*\
	Transfer Status
\*---------------------------------------------------------------------------*/

typedef enum {	
	AHCI_TS_NoError = 0,
	AHCI_TS_CrcError, 
	AHCI_TS_BitstuffError,
	AHCI_TS_0x3_reserved,
	AHCI_TS_Stall,
	AHCI_TS_Timeout,
	AHCI_TS_PidError,
	AHCI_TS_MissedEOP,
	AHCI_TS_PacketOverflow,
	AHCI_TS_TransferOverflow,
	AHCI_TS_DataUnderrun,
	AHCI_TS_RxMemoryOverflow,
	AHCI_TS_OtherErrors,
	AHCI_TS_EOF1Error,
	AHCI_TS_0xD_reserved,
	AHCI_TS_Canceled
} AHCI_TransferStatus;

/*---------------------------------------------------------------------------*\
	Transfer Status Word im Rx Memory
\*---------------------------------------------------------------------------*/
#define AHCI_TSW_tdPosition_SHIFT		0
#define AHCI_TSW_completed_SHIFT 		15
#define AHCI_TSW_byteCount_SHIFT		16
#define AHCI_TSW_toggleBit_SHIFT		27
#define AHCI_TSW_transferStatus_SHIFT	28

#define AHCI_TSW_tdPosition_MASK		0x00003FFF	// 14 Bits
#define AHCI_TSW_completed_FLAG			0x00008000	// 1 Bit
#define AHCI_TSW_byteCount_MASK			0x03FF0000	// 10 Bits
#define AHCI_TSW_toggleBit_FLAG			0x08000000	// 1 Bit
#define AHCI_TSW_transferStatus_MASK	0xF0000000	// 4 Bits

#define AHCI_TSW_tdPosition(v) 		(((v) & AHCI_TSW_tdPosition_MASK) >> AHCI_TSW_tdPosition_SHIFT)
#define AHCI_TSW_completed(v) 		(((v) & AHCI_TSW_completed_FLAG) != 0)
#define AHCI_TSW_byteCount(v) 		(((v) & AHCI_TSW_byteCount_MASK) >> AHCI_TSW_byteCount_SHIFT)
#define AHCI_TSW_toggleBit(v)		(((v) & AHCI_TSW_toggleBit_FLAG) != 0)
#define AHCI_TSW_transferStatus(v)	(((v) & AHCI_TSW_transferStatus_MASK) >> AHCI_TSW_transferStatus_SHIFT)

#endif //_ahcirx_h_
