📄 tmhal.c
字号:
/*----------------------------------------------------------------------------
COPYRIGHT (c) 1995 by Philips Semiconductors
THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED AND COPIED IN
ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH A LICENSE AND WITH THE
INCLUSION OF THE THIS COPY RIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
OF THIS SOFTWARE MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
PERSON. THE OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.
THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT ANY PRIOR NOTICE
AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY Philips Semiconductor.
PHILIPS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE
ON PLATFORMS OTHER THAN THE ONE ON WHICH THIS SOFTWARE IS FURNISHED.
----------------------------------------------------------------------------*/
/*
HISTORY
#define TR Tilakraj Roy
960510 TR Created
961019 TR Moved the CTC 1.1 bug fix in IRQGen from IRQAck.
*/
/*----------------------------------------------------------------------------
SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
/* #define USE_NEWHAL */
#include "stdio.h"
#include "tmInterrupts.h"
/*----------------------------------------------------------------------------
DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
/* external includes */
#include "tmman.h"
/* common includes */
#include "tmhd.h"
#include "tmmmio.h"
#include "tmhal.h"
/* tm1 specific includes */
#include "ops/custom_defs.h"
#include "ops/custom_ops.h"
VOID halHostACKHandler ( VOID );
extern DWORD Host2TargetIntPtr;
extern DWORD Target2HostIntPtr;
STATUS halCreate( DWORD dwSDRAMBase, DWORD dwMMIOBase,
DWORD CPUVersion, PVOID *ppHAL )
{
PTMHAL_OBJECT this;
if ( ( this = (PTMHAL_OBJECT)malloc (
sizeof ( TMHAL_OBJECT) ) ) == NULL )
{
return TM_STATUS ( TMHAL_ERR_OBJALLOCFAIL );
}
this->Size = sizeof ( TMHAL_OBJECT );
this->MMIO.pVIC = (PTMHAL_MMIO_VIC)(dwMMIOBase + 0x100800);
this->MMIO.pTimers = (PTMHAL_MMIO_TIMERS)(dwMMIOBase + 0x100c00);
this->MMIO.pDebug = (PTMHAL_MMIO_DEBUG)(dwMMIOBase + 0x101000);
this->MMIO.pBIU = (PTMHAL_MMIO_BIU)(dwMMIOBase + 0x103004);
this->MMIO.pAudioIn = (PTMHAL_MMIO_AUDIO)(dwMMIOBase + 0x101c00);
this->MMIO.pAudioOut = (PTMHAL_MMIO_AUDIO)(dwMMIOBase + 0x102000);
this->MMIO.pCache = (PTMHAL_MMIO_CACHE)(dwMMIOBase + 0x100000);
tmParameterDWORDGet ( TMHD_PARAM_HAL, &this->pSharedData );
this->pSharedData->T2HInterruptReq = FALSE;
Target2HostIntPtr = &this->pSharedData->T2HInterruptReq;
Host2TargetIntPtr = &this->pSharedData->H2TInterruptReq;
this->MMIO.pBIU->dwBIUControl |= ( TMHAL_BIU_CONTROL_CR );
this->CPUVersion = CPUVersion;
this->InterruptsBusy = FALSE;
*ppHAL = this;
return TMOK;
}
VOID halDestroy ( PVOID pObject )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
this->Size = 0;
free ( this );
}
STATUS halIRQConnect( PVOID pObject, DWORD dwIRQ, BOOL fLevelTrigger,
BYTE bPriority, DWORD dwInterruptHandler )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
intInstanceSetup_t setup;
/* setup the main interrupt */
if (intOpen( intINT_28) != 0)
{
return TM_STATUS ( TMHAL_ERR_IRQALLOCFAIL );;
}
this->Instance = intINT_28; setup.enabled = True;
setup.handler = (intHandler_t)dwInterruptHandler;
setup.priority = bPriority;
setup.level_triggered = fLevelTrigger;
intInstanceSetup( this->Instance, &setup );
/*
if (intOpen( intINT_31) != 0)
{
return TM_STATUS ( TMHAL_ERR_IRQALLOCFAIL );;
}
setup.enabled = True;
setup.handler = (intHandler_t)halHostACKHandler;
setup.priority = bPriority;
setup.level_triggered = fLevelTrigger;
intInstanceSetup( intINT_31, &setup );
*/
}
VOID halIRQDisconnect( PVOID pObject, DWORD dwIRQ )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
intClose ( this->Instance );
}
VOID halIRQDisable( PVOID pObject, DWORD dwIRQ, PDWORD pSaved )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
intInstanceSetup_t Setup;
intGetInstanceSetup ( this->Instance, &Setup );
Setup.enabled = False;
intInstanceSetup ( this->Instance, &Setup );
}
VOID halIRQEnable( PVOID pObject, DWORD dwIRQ, PDWORD pSaved )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
intInstanceSetup_t Setup;
intGetInstanceSetup ( this->Instance, &Setup );
Setup.enabled = True;
intInstanceSetup ( this->Instance, &Setup );
}
VOID halIRQDisableAll( PVOID pvObject, PDWORD pdwPCSW )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pvObject;
*pdwPCSW = intCLEAR_IEN ( );
}
VOID halIRQRestoreAll ( PVOID pvObject, DWORD dwPCSW )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pvObject;
intRESTORE_IEN ( dwPCSW );
}
VOID halIRQDSPGen( PVOID pObject, DWORD dwIRQ )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
this->MMIO.pVIC->dwIPending = ( 1<< dwIRQ );
}
DWORD halRaiseIrql ( PVOID pObject, DWORD Irql )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
DWORD OldIrql;
intSetup_t Setup;
intGetSetup ( &Setup );
/* does the same as KeRaiseIrql */
OldIrql = Setup.priority;
Setup.priority = Irql;
intSetup ( & Setup );
return OldIrql;
}
VOID halLowerIrql ( PVOID pObject, DWORD Irql )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
intSetup_t Setup;
intGetSetup ( &Setup );
/* does the same as KeRaiseIrql */
Setup.priority = Irql;
intSetup ( & Setup );
}
VOID halBIUHostIRQGen( PVOID pObject )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
DWORD dwInterruptControl;
/*
set MMIO->dwInterruptControl:INT(3..0)
set MMIO->dwInterruptControl:IE(7..4)
DT( 0, ("[halBIUHostIRQGen]"));
*/
if ( ( TMSTD_GETTMTYPE(this->CPUVersion) == TMSTD_TYPE_TM1000 ) &&
( TMSTD_GETTMREV(this->CPUVersion) == 0 ) )
{
/******* Special case CTC1.1 BEGIN **************/
dwInterruptControl = this->MMIO.pBIU->dwInterruptControl;
dwInterruptControl |=
( ( 1 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) |
( 0x10 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) );
/* mark that the host is yet to process the int */
this->pSharedData->Ring0ISRActive = TRUE;
/* set the PCI interrupt */
this->MMIO.pBIU->dwInterruptControl = dwInterruptControl;
/* wait for the host isr to be invoked */
while( this->pSharedData->Ring0ISRActive == TRUE);
/* reset the interrupt */
/*
reset MMIO->dwInterruptControl:INT(3..0)
reset MMIO->dwInterruptControl:IE(7..4)
*/
dwInterruptControl = this->MMIO.pBIU->dwInterruptControl;
dwInterruptControl &=
( ~( 1 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) &
~( 0x10 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) );
this->MMIO.pBIU->dwInterruptControl = dwInterruptControl;
/******* Special case CTC1.1 END **************/
}
else /* TM1 or some bug fixed hardware */
{
while (1)
{
/* is the host in the process of accessing the INT_CTL */
if ( this->pSharedData->H2TInterruptReq == FALSE )
{
/* we want to access the INT_CTL */
this->pSharedData->T2HInterruptReq = TRUE;
/* check if we have done it at the right time */
if ( this->pSharedData->H2TInterruptReq == TRUE )
{
this->pSharedData->T2HInterruptReq = FALSE;
}
else
{
dwInterruptControl = this->MMIO.pBIU->dwInterruptControl;
dwInterruptControl |=
( ( 1 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) |
( 0x10 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) );
/* set the PCI interrupt */
this->MMIO.pBIU->dwInterruptControl = dwInterruptControl;
/* we are done so set the semaphore to its original value */
this->pSharedData->T2HInterruptReq = FALSE;
break;
}
}
}
/*
DWORD Saved = intClearIEN();
if ( this->InterruptsBusy != TRUE )
{
this->InterruptsBusy = TRUE;
dwInterruptControl = this->MMIO.pBIU->dwInterruptControl;
dwInterruptControl |=
( ( 1 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) |
( 0x10 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) );
this->MMIO.pBIU->dwInterruptControl = dwInterruptControl;
intRestoreIEN(Saved);
break;
}
intRestoreIEN(Saved);
*/
}
}
VOID halIRQDSPAck( PVOID pObject, DWORD dwIRQ )
{
PTMHAL_OBJECT this = (PTMHAL_OBJECT)pObject;
this->MMIO.pVIC->dwIClear = ( 1<< dwIRQ );
}
/*
VOID halHostACKHandler4Real ( VOID )
{
// #pragma TCS_handler
PTMHAL_OBJECT this = GetHalObject();
DWORD dwInterruptControl;
DT( 0, ("[halHostACKHandler]"));
dwInterruptControl = this->MMIO.pBIU->dwInterruptControl;
dwInterruptControl &=
( ~( 1 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) &
~( 0x10 << ( TMHD_HAL_PCIIRQNUMBER - 0x0a ) ) );
this->MMIO.pBIU->dwInterruptControl = dwInterruptControl;
this->InterruptsBusy = FALSE;
}
*/
VOID halHostACKHandler ( VOID ) { #pragma TCS_handler AppModel_suspend_scheduling(); AppModel_run_on_sstack( (Pointer)halHostACKHandler4Real, Null ); AppModel_resume_scheduling(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -