/*---------------------------------------------------------------------------*\
 *   
 *   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 
\*---------------------------------------------------------------------------*/

#include "ahcireg.h"

/*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/

PAHCI_REGISTER pAHCI_ListControlReg = 0;
PAHCI_REGISTER pAHCI_GlobalControlReg = 0;

PAHCI_REGISTER pAHCI_SofConfigReg = 0;
PAHCI_REGISTER pAHCI_MemoryConfigReg = 0;
PAHCI_REGISTER pAHCI_ResetConfigReg = 0;
PAHCI_REGISTER pAHCI_ResumeConfigReg = 0;

PAHCI_REGISTER pAHCI_InterruptStatusReg = 0;
PAHCI_REGISTER pAHCI_InterruptEnableReg = 0;
PAHCI_REGISTER pAHCI_InterruptConfigReg = 0;

PAHCI_REGISTER pAHCI_FrameNumberReg = 0;
PAHCI_REGISTER pAHCI_CurRxAddrReg = 0;

PAHCI_REGISTER pAHCI_RevisionIDReg = 0;

PAHCI_REGISTER pAHCI_HPStartPointerReg = 0;
PAHCI_REGISTER pAHCI_LPStartPointerReg = 0;

PAHCI_REGISTER pAHCI_PortControlRegs = 0;

/*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/
void AHCI_InitRegisterMapping (unsigned RegisterOffset) {
	struct AHCI_hw * pHW;

	assert (AHCI_BaseAddress != 0);
	//weniger sollte es wirklich nicht sein
	assert (RegisterOffset > (4*1024));
	
	pHW = (struct AHCI_hw *) (((char *) AHCI_BaseAddress) + RegisterOffset);
	
	//assert:kein Wraparound
	assert (pHW > (struct AHCI_hw *) AHCI_BaseAddress);

	pAHCI_ListControlReg =		&(pHW->ListControlReg);
	pAHCI_GlobalControlReg =	&(pHW->GlobalControlReg);
	
	pAHCI_SofConfigReg =		&(pHW->SofConfigReg);
	pAHCI_MemoryConfigReg =		&(pHW->MemoryConfigReg);
	pAHCI_ResetConfigReg =		&(pHW->ResetConfigReg);
	pAHCI_ResumeConfigReg =		&(pHW->ResumeConfigReg);

	pAHCI_InterruptStatusReg = 	&(pHW->InterruptStatusReg);
	pAHCI_InterruptEnableReg = 	&(pHW->InterruptEnableReg);
	pAHCI_InterruptConfigReg = 	&(pHW->InterruptConfigReg);

	pAHCI_FrameNumberReg =		&(pHW->FrameNumberReg);
	pAHCI_CurRxAddrReg =		&(pHW->CurRxAddrReg);

	pAHCI_RevisionIDReg =		&(pHW->RevisionIDReg);

	pAHCI_HPStartPointerReg =	&(pHW->HPStartPointerReg);
	pAHCI_LPStartPointerReg =	&(pHW->LPStartPointerReg);

	pAHCI_PortControlRegs = 	&(pHW->PortControlRegs[0]);
	
	PrintInfo ("ListControlReg = %x\n", *pAHCI_ListControlReg);
	PrintInfo ("GlobalControlReg = %x\n", *pAHCI_GlobalControlReg);
	
	PrintInfo ("SofConfigReg = %x\n", *pAHCI_SofConfigReg);
	PrintInfo ("MemoryConfigReg = %x\n", *pAHCI_MemoryConfigReg);
	PrintInfo ("ResetConfigReg = %x\n", *pAHCI_ResetConfigReg);
	PrintInfo ("ResumeConfigReg = %x\n", *pAHCI_ResumeConfigReg);

	PrintInfo ("InterruptStatusReg = %x\n", *pAHCI_InterruptStatusReg);
	PrintInfo ("InterruptEnableReg = %x\n", *pAHCI_InterruptEnableReg);
	PrintInfo ("InterruptConfigReg = %x\n", *pAHCI_InterruptConfigReg);

	PrintInfo ("FrameNumberReg = %x\n", *pAHCI_FrameNumberReg);
	PrintInfo ("CurRxAddrReg = %x\n", *pAHCI_CurRxAddrReg);

	PrintInfo ("RevisionIDReg = %x\n", *pAHCI_RevisionIDReg);

	PrintInfo ("HPStartPointerReg = %x\n", *pAHCI_HPStartPointerReg);
	PrintInfo ("LPStartPointerReg = %x\n", *pAHCI_LPStartPointerReg);

	PrintInfo ("PortControlRegs = %x\n", *pAHCI_PortControlRegs);
	
}

/*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/
