📄 tmboard.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
960404 TR Created
961027 TR Moved all object creatin functionality from vxmain to here
*/
/*----------------------------------------------------------------------------
SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
#define WANTVXDWRAPS
#include <basedef.h>
#include <vmm.h>
#include <vxdwraps.h>
/*----------------------------------------------------------------------------
DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "vxstd.h"
#include "vxwin.h"
#include "vxdbg.h"
#include "verinfo.h"
#include "tmwincom.h"
#include "tmhd.h"
#include "tmshare.h"
#include "tmboard.h"
#include "tmbuffer.h"
#include "tmman32.h"
#pragma VxD_LOCKED_CODE_SEG
#pragma VxD_LOCKED_DATA_SEG
/*
boardParameterDWORDSet
set parameters for counterparts running on DSP
*/
STATUS boardParameterDWORDSet ( PVOID pBoard, DWORD ID, DWORD Value )
{
PTMBOARD_OBJECT this = (PTMBOARD_OBJECT)pBoard;
if ( ID > this->ParameterCount )
{
return TM_STATUS(TMBOARD_ERR_IDOUTOFRANGE);
}
this->pSharedData->Parameter[ID] = Value;
return TMOK;
}
/*
boardParameterDWORDGet
get parameters for counterparts running on DSP
*/
STATUS boardParameterDWORDGet ( PVOID pBoard, DWORD ID, PDWORD pValue )
{
PTMBOARD_OBJECT this = (PTMBOARD_OBJECT)pBoard;
if ( ID > this->ParameterCount )
{
return TM_STATUS(TMBOARD_ERR_IDOUTOFRANGE);
}
*pValue = this->pSharedData->Parameter[ID];
return TMOK;
}
STATUS boardGetCaps ( PVOID Object, PVOID pObjectCaps )
{
PTMBOARD_OBJECT this = (PTMBOARD_OBJECT)Object;
PTMMAN_DSP_CAPS pDSPCaps = (PTMMAN_DSP_CAPS)pObjectCaps;
pDSPCaps->dwCPUVersion = (DWORD)this->Config.bRevision;
pDSPCaps->dwHWVersion = this->Config.dwSubsystemID;
pDSPCaps->dwROMVersion = 0;
// these copy the structure in to a common structure.
pDSPCaps->SDRAM.dwPhysical = this->Config.dwSDRAMBase;
pDSPCaps->SDRAM.dwLinear = this->SDRAMLinear;
pDSPCaps->SDRAM.dwSize = this->Config.dwSDRAMLength;
pDSPCaps->MMIO.dwPhysical = this->Config.dwMMIOBase;
pDSPCaps->MMIO.dwLinear = this->MMIOLinear;
pDSPCaps->MMIO.dwSize = this->Config.dwMMIOLength;
pDSPCaps->User.dwPhysical = this->UserSharedDataPhys;
pDSPCaps->User.dwLinear = (DWORD)this->pUserSharedData;
pDSPCaps->User.dwSize =
((PINIT_OBJECT)pDriverObject->pInitObj)->dwUserBufferSize;
/*
*/
vxdStrCopy ( this->szPCIName , pDSPCaps->szPCIName);
pDSPCaps->DSPNumber = vxdGetDeviceNumber ( this );
return TMOK;
}
STATUS boardCreate ( PVOID pConfig, PVOID *ppBoard )
{
PTMBOARD_OBJECT this;
STATUS Status;
TMMAN_DSP_CAPS DSPCaps;
DWORD Idx;
if ( *ppBoard )
{
this = *ppBoard;
this->Flags = 0;
}
else
{
if ( ( this = vxdMalloc ( sizeof ( TMBOARD_OBJECT ) ) ) == NULL )
{
DP(0,"TM:boardCreate:Object:MALLOC:FAIL\n");
Status = TM_STATUS ( TMBOARD_ERR_OBJALLOCFAIL );
goto boardCreate_fail1;
}
FlagSet ( this->Flags, TMBOARD_FLAG_DYNAMICOBJ );
}
this->Size = sizeof ( TMBOARD_OBJECT );
this->Config = *(PTMPNP_CONFIG)pConfig;
this->SharedFlags = 0;
// read all the pci registers and save them for use after reset.
for ( Idx = 0 ; Idx < TMBOARD_MAX_PCI_REGISTERS ; Idx ++ )
{
pciReadConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
(WORD)Idx*4, &this->PCIRegisters[Idx] );
}
this->MMIOLinear = winMapPhysToLinear ( this->Config.dwMMIOBase,
this->Config.dwMMIOLength , 0);
if ( this->MMIOLinear == 0xffffffff )
{
DP(0,"TM:boardCreate:winMapPhysToLinear:MMIO:FAIL\n");
Status = TM_STATUS ( TMBOARD_ERR_MMIOMAPFAIL);
goto boardCreate_fail2;
}
/* TBD : change all this to use the TMMAN_MEMORY_BLOCK interfaces */
// map SDRAM.
this->SDRAMLinear = winMapPhysToLinear ( this->Config.dwSDRAMBase,
this->Config.dwSDRAMLength , 0);
if ( this->SDRAMLinear == 0xffffffff )
{
DP(0,"TM:boardCreate:winMapPhysToLinear:SDRAM:FAIL\n");
Status = (TM_STATUS ( TMBOARD_ERR_SDRAMMAPFAIL));
goto boardCreate_fail2;
}
/* create the other objects */
this->pHAL = NULL;
this->pIPC = NULL;
this->pChnlMgr = NULL;
this->pMsgMgr = NULL;
this->pTaskMgr = NULL;
this->pShMem = NULL;
this->pStrmMgr = NULL;
this->pDMAMgr = NULL;
if ( ( Status = shmemCreate (
((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTotalBufferSize,
this, &this->pShMem ) ) != TMOK )
goto boardCreate_fail2;
if ( ( Status = shmemAllocate ( this->pShMem, 0 ,
sizeof ( TMHD_BOARD_SHARED ), &this->pSharedData,
&this->SharedDataPhys ) ) != TMOK )
goto boardCreate_fail3;
this->ParameterCount = TMHD_PARAM_COUNT;
boardParameterDWORDSet ( this, TMHD_PARAM_BOARD, this->SharedDataPhys );
pnpPCINameGet ( this->Config.wVendorID, this->Config.wDeviceID,
this->Config.bBusNum, this->Config.bDevFuncNum,
this->szPCIName );
if ( ( Status = halCreate ( this->SDRAMLinear,
this->Config.dwSDRAMLength,
this->MMIOLinear, this, &this->pHAL ) ) != TMOK )
goto boardCreate_fail4;
halRegisterInit ( this->pHAL, this->Config.dwSDRAMBase,
(this->Config.dwSDRAMBase + this->Config.dwSDRAMLength),
this->Config.dwMMIOBase );
if ( ( Status = ipcCreate ( this, this->Config.bIRQ,
&this->pIPC ) ) != TMOK )
goto boardCreate_fail5;
if ( ( Status = chnlmCreate (
this,
( 0x20 * 2 ), /* should be same as specified in target\tmman.c */
&this->pChnlMgr ) ) != TMOK )
goto boardCreate_fail6;
if ( ( Status = msgmCreate ( this,
(0x20), /* should be same as specified in target\tmman.c */
&this->pMsgMgr ) ) != TMOK )
goto boardCreate_fail7;
if ( ( Status = taskmCreate ( this,
(0x10), /* should be same as specified in target\tmman.c */
&this->pTaskMgr ) ) != TMOK )
goto boardCreate_fail8;
if ( ( Status = buffermCreate ( this,
((PINIT_OBJECT)(pDriverObject->pInitObj))->dwBufferMaxCount,
&this->pBufferMgr ) ) != TMOK )
goto boardCreate_fail9;
if ( ( Status = shmemAllocate ( this->pShMem, 0 ,
sizeof ( TMHD_DBG_SHARED ), &this->pDBGSharedData,
&this->DBGSharedDataPhys ) ) != TMOK )
goto boardCreate_fail11;
this->pDBGSharedData->OptionBits = 0;
this->pDBGSharedData->Level = ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTargetDBGLevel;
boardParameterDWORDSet ( this, TMHD_PARAM_DBG, this->DBGSharedDataPhys );
DP(1,"vtmman:board:DBG:Linear[%x]:Physical[%x]\n",
this->pDBGSharedData, this->DBGSharedDataPhys );
/* allocate the shared user region - will be removed once streaming works */
if ( ( Status = shmemAllocate ( this->pShMem, 0 ,
((PINIT_OBJECT)(pDriverObject->pInitObj))->dwUserBufferSize,
&this->pUserSharedData,
&this->UserSharedDataPhys ) ) != TMOK )
goto boardCreate_fail12;
boardGetCaps ( this, &DSPCaps );
this->pSharedData->CPUVersion = DSPCaps.dwCPUVersion;
this->pSharedData->SDRAM = DSPCaps.SDRAM;
this->pSharedData->MMIO = DSPCaps.MMIO;
this->pSharedData->User = DSPCaps.User;
*ppBoard = this;
return TMOK;
/* SEH code */
boardCreate_fail12 :
shmemFree ( this->pShMem,this->pDBGSharedData );
boardCreate_fail11 :
/*
dmaDestroy ( this->pDMAMgr );
boardCreate_fail10 :
*/
buffermDestroy ( this->pBufferMgr );
boardCreate_fail9 :
taskmDestroy ( this->pTaskMgr );
boardCreate_fail8 :
msgmDestroy ( this->pMsgMgr );
boardCreate_fail7 :
chnlmDestroy ( this->pChnlMgr );
boardCreate_fail6 :
ipcDestroy ( this->pIPC );
boardCreate_fail5 :
halDestroy ( this->pHAL );
boardCreate_fail4 :
shmemFree ( this->pShMem, this->pSharedData );
boardCreate_fail3 :
shmemDestroy ( this->pShMem );
boardCreate_fail2 :
if ( FlagGet ( this->Flags, TMBOARD_FLAG_DYNAMICOBJ ) )
{
vxdFree ( this );
}
boardCreate_fail1 :
return Status ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -