Removed unused files
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11325 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,197 +0,0 @@
|
|||||||
// ****************************************************************************
|
|
||||||
//
|
|
||||||
// CEchoGals_WDM.cpp
|
|
||||||
//
|
|
||||||
// Implementation file for the CEchoGals driver class.
|
|
||||||
// Set editor tabs to 3 for your viewing pleasure.
|
|
||||||
//
|
|
||||||
// Copyright Echo Digital Audio Corporation (c) 1998 - 2002
|
|
||||||
// All rights reserved
|
|
||||||
// www.echoaudio.com
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal with the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
// the following conditions:
|
|
||||||
//
|
|
||||||
// - Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers.
|
|
||||||
//
|
|
||||||
// - Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// - Neither the name of Echo Digital Audio, nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this Software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
// SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// ****************************************************************************
|
|
||||||
|
|
||||||
#include "CEchoGals.h"
|
|
||||||
|
|
||||||
#pragma optimize("",off)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make new daffy ducks for all channels
|
|
||||||
//
|
|
||||||
ECHOSTATUS CEchoGals::MakeDaffyDuck(WORD wPipeIndex)
|
|
||||||
{
|
|
||||||
ECHOSTATUS Status = ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
//---------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Allocate the main daffy duck for this channel
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
m_pDaffyDucks[wPipeIndex] = new CDaffyDuck( m_pOsSupport,
|
|
||||||
GetDspCommObject(),
|
|
||||||
wPipeIndex );
|
|
||||||
if (NULL == m_pDaffyDucks[wPipeIndex])
|
|
||||||
{
|
|
||||||
return ECHOSTATUS_NO_MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check the daffy duck
|
|
||||||
//
|
|
||||||
Status = m_pDaffyDucks[wPipeIndex]->InitCheck();
|
|
||||||
if (ECHOSTATUS_OK != Status)
|
|
||||||
{
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Put the daffy duck in the comm page
|
|
||||||
//
|
|
||||||
GetDspCommObject()->
|
|
||||||
SetAudioDuckListPhys( wPipeIndex,
|
|
||||||
m_pDaffyDucks[wPipeIndex]->GetPhysStartAddr() );
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
|
|
||||||
} // MakeDaffyDuck
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Kill the daffy duck for a pipe
|
|
||||||
//
|
|
||||||
void CEchoGals::KillDaffyDuck(WORD wPipeIndex)
|
|
||||||
{
|
|
||||||
if (NULL != m_pDaffyDucks[wPipeIndex])
|
|
||||||
{
|
|
||||||
delete m_pDaffyDucks[wPipeIndex];
|
|
||||||
m_pDaffyDucks[wPipeIndex] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // KillDaffyDuck
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the daffy duck for a given pipe index
|
|
||||||
//
|
|
||||||
CDaffyDuck *CEchoGals::GetDaffyDuck(WORD wPipeIndex)
|
|
||||||
{
|
|
||||||
if (wPipeIndex >= GetNumPipes())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return m_pDaffyDucks[wPipeIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update the 64 bit DMA counter for this channel, allowing
|
|
||||||
// for DSP position counter wraparound.
|
|
||||||
//
|
|
||||||
void CEchoGals::UpdateDmaPos( WORD wPipeIndex )
|
|
||||||
{
|
|
||||||
DWORD dwDspPos;
|
|
||||||
DWORD dwDelta;
|
|
||||||
|
|
||||||
dwDspPos = GetDspCommObject()->GetAudioPosition( wPipeIndex );
|
|
||||||
dwDelta = dwDspPos - m_dwLastDspPos[ wPipeIndex ];
|
|
||||||
|
|
||||||
m_ullDmaPos[ wPipeIndex ] += dwDelta;
|
|
||||||
m_dwLastDspPos[ wPipeIndex ] = dwDspPos;
|
|
||||||
|
|
||||||
} // UpdateDmaPos
|
|
||||||
|
|
||||||
|
|
||||||
void CEchoGals::ResetDmaPos(WORD wCh)
|
|
||||||
{
|
|
||||||
m_ullDmaPos[ wCh ] = 0;
|
|
||||||
m_dwLastDspPos[ wCh ] = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// There may still be mappings in the daffy duck; if so,
|
|
||||||
// tell them to reset their DMA positions starting at zero
|
|
||||||
//
|
|
||||||
if (NULL != m_pDaffyDucks[wCh])
|
|
||||||
m_pDaffyDucks[wCh]->ResetStartPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SIMPHONICS_EXTENSIONS
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CEchoGals::SetMixerUberGain
|
|
||||||
|
|
||||||
Set an array of gains to simultaneously set all monitor, virtual output,
|
|
||||||
and output bus gains, as per the SimPhonics specifications.
|
|
||||||
|
|
||||||
The structure of the array is as follows:
|
|
||||||
|
|
||||||
|
|
||||||
Monitor gains
|
|
||||||
|
|
||||||
0 I0->O0 I1->O0 ... I15->O0
|
|
||||||
16 I0->O1 I1->O1 ... I15->O1
|
|
||||||
...
|
|
||||||
240 I0->O15 I1->O15 ... I15->O15
|
|
||||||
|
|
||||||
|
|
||||||
Virtual output gains
|
|
||||||
|
|
||||||
256 V0->O0 V1->O0 ... V15->O0
|
|
||||||
272 V0->O1 V1->O1 ... V15->O1
|
|
||||||
...
|
|
||||||
498 V0->O15 V1->O15 ... V15->O15
|
|
||||||
|
|
||||||
|
|
||||||
Master output bus gains
|
|
||||||
|
|
||||||
512 B0 B1 ... B15
|
|
||||||
|
|
||||||
|
|
||||||
Values are signed bytes, ranging from +6 to -128 dB.
|
|
||||||
|
|
||||||
Right now, this is hard-coded for Layla24v - 16 inputs,
|
|
||||||
16 output busses, 16 virtual outputs.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#define LAYLA24V_CHANNELS 16
|
|
||||||
|
|
||||||
ECHOSTATUS CEchoGals::SetLayla24vUberGain(LAYLA24V_UBER_GAIN *pLug)
|
|
||||||
{
|
|
||||||
if (GetDspCommObject())
|
|
||||||
GetDspCommObject()->SetLayla24vUberGain(pLug);
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // SetLayla24vMixerUberGain
|
|
||||||
|
|
||||||
#endif // SIMPHONICS_EXTENSIONS
|
|
||||||
@@ -1,430 +0,0 @@
|
|||||||
// ****************************************************************************
|
|
||||||
//
|
|
||||||
// OsSupportWDM.cpp
|
|
||||||
//
|
|
||||||
// Implementation file for WDM support services to the CEchoGals
|
|
||||||
// generic driver class.
|
|
||||||
//
|
|
||||||
// This will need to be rewritten for each new target OS.
|
|
||||||
//
|
|
||||||
// Set editor tabs to 3 for your viewing pleasure.
|
|
||||||
//
|
|
||||||
// Copyright Echo Digital Audio Corporation (c) 1998 - 2002
|
|
||||||
// All rights reserved
|
|
||||||
// www.echoaudio.com
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal with the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
// the following conditions:
|
|
||||||
//
|
|
||||||
// - Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers.
|
|
||||||
//
|
|
||||||
// - Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// - Neither the name of Echo Digital Audio, nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this Software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
// SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// ****************************************************************************
|
|
||||||
|
|
||||||
#include "CEchoGals.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <portcls.h>
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
|
|
||||||
Byte swapping for supporting big endian machines; obviously, this isn't
|
|
||||||
needed since this is OsSupportWDM. This is just here as an example
|
|
||||||
for those who wish to develop for big endian machines.
|
|
||||||
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef BIG_ENDIAN_HOST
|
|
||||||
|
|
||||||
#pragma warning( disable : 4035 )
|
|
||||||
|
|
||||||
WORD SwapBytesShort
|
|
||||||
(
|
|
||||||
WORD wIn
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_asm mov AX, wIn
|
|
||||||
_asm bswap EAX
|
|
||||||
_asm shr EAX,16
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD SwapBytesLong
|
|
||||||
(
|
|
||||||
DWORD dwIn
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_asm mov EAX, dwIn
|
|
||||||
_asm bswap EAX
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WORD SwapBytes
|
|
||||||
(
|
|
||||||
WORD wIn // 16 bit quantity to swap
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return( SwapBytesShort( wIn ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD SwapBytes
|
|
||||||
(
|
|
||||||
DWORD dwIn // 32 bit quantity to swap
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return( SwapBytesLong( dwIn ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BIG_ENDIAN_HOST
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
|
|
||||||
Memory management - not part of COsSupport
|
|
||||||
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Init the memory tracking counter; right now, this just uses a simple
|
|
||||||
// scheme that tracks the number of allocations
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
DWORD gdwAllocNonPagedCount = 0;
|
|
||||||
|
|
||||||
void OsAllocateInit()
|
|
||||||
{
|
|
||||||
gdwAllocNonPagedCount = 0;
|
|
||||||
} // OsAllocateInit
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// OsAllocateNonPaged is used to allocate a block of memory that will always
|
|
||||||
// be resident; that is, this particular block of memory won't be swapped
|
|
||||||
// out as virtual memory and can always be accessed at interrupt time.
|
|
||||||
//
|
|
||||||
// gdwAllocNonPagedCount tracks the number of times this has been
|
|
||||||
// successfully called.
|
|
||||||
//
|
|
||||||
// This is primarily used for overloading the new operator for the various
|
|
||||||
// generic classes.
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
ECHOSTATUS OsAllocateNonPaged
|
|
||||||
(
|
|
||||||
DWORD dwByteCt, // Block size in bytes
|
|
||||||
PPVOID ppMemAddr // Where to return memory ptr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ASSERT( DISPATCH_LEVEL >= KeGetCurrentIrql() );
|
|
||||||
*ppMemAddr = ExAllocatePoolWithTag( NonPagedPool, dwByteCt, ECHO_POOL_TAG );
|
|
||||||
|
|
||||||
if ( NULL == *ppMemAddr )
|
|
||||||
{
|
|
||||||
ECHO_DEBUGPRINTF( ("OsAllocateNonPaged : Failed on %d bytes\n",
|
|
||||||
dwByteCt) );
|
|
||||||
ECHO_DEBUGBREAK();
|
|
||||||
return ECHOSTATUS_NO_MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlZeroMemory( *ppMemAddr, dwByteCt );
|
|
||||||
|
|
||||||
gdwAllocNonPagedCount++;
|
|
||||||
ECHO_DEBUGPRINTF(("gdwAllocNonPagedCount %d\n",gdwAllocNonPagedCount));
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS OsAllocateNonPaged
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// OsFreeNonPaged is used to free memory allocated by OsAllocateNonPaged.
|
|
||||||
//
|
|
||||||
// gdwAllocNonPagedCount tracks the number of times this has been
|
|
||||||
// successfully called.
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
ECHOSTATUS OsFreeNonPaged
|
|
||||||
(
|
|
||||||
PVOID pMemAddr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ASSERT( DISPATCH_LEVEL >= KeGetCurrentIrql() );
|
|
||||||
|
|
||||||
ExFreePool( pMemAddr );
|
|
||||||
|
|
||||||
gdwAllocNonPagedCount--;
|
|
||||||
ECHO_DEBUGPRINTF(("gdwAllocNonPagedCount %d\n",gdwAllocNonPagedCount));
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS OsFreeNonPaged
|
|
||||||
|
|
||||||
|
|
||||||
//***********************************************************************
|
|
||||||
|
|
||||||
//
|
|
||||||
// This class is uniquely defined for each OS. It provides
|
|
||||||
// information that other components may require.
|
|
||||||
//
|
|
||||||
// For example, in Windows NT it contains a device object used by various
|
|
||||||
// memory management methods.
|
|
||||||
//
|
|
||||||
// An instance of this class must be constructed and initialized prior to
|
|
||||||
// constructing the CEchoGals derived object. The CEchoGals and
|
|
||||||
// CDspCommObject classes must have access to it during their respective
|
|
||||||
// construction times.
|
|
||||||
//
|
|
||||||
//***********************************************************************
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Construction/destruction
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
COsSupport::COsSupport
|
|
||||||
(
|
|
||||||
DWORD dwDeviceId // PCI bus subsystem ID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
KeQuerySystemTime( (PLARGE_INTEGER) &m_ullStartTime );
|
|
||||||
// All system time calls relative to this
|
|
||||||
|
|
||||||
m_dwDeviceId = dwDeviceId;
|
|
||||||
|
|
||||||
} // COsSupport::COsSupport()
|
|
||||||
|
|
||||||
|
|
||||||
COsSupport::~COsSupport()
|
|
||||||
{
|
|
||||||
} // COsSupport::~COsSupport()
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Timer methods
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Return the system time in microseconds.
|
|
||||||
// Return error status if the OS doesn't support this function.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ECHOSTATUS COsSupport::OsGetSystemTime
|
|
||||||
(
|
|
||||||
PULONGLONG pullTime // Where to return system time
|
|
||||||
)
|
|
||||||
{
|
|
||||||
KeQuerySystemTime( (PLARGE_INTEGER) pullTime );
|
|
||||||
*pullTime /= 10;
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS COsSupport::OsGetSystemTime
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Stall execution for dwTime microseconds.
|
|
||||||
// Return error status if the OS doesn't support this
|
|
||||||
// function.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ECHOSTATUS COsSupport::OsSnooze
|
|
||||||
(
|
|
||||||
DWORD dwTime // Duration in micro seconds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER Interval;
|
|
||||||
|
|
||||||
if ( KeGetCurrentIrql() < DISPATCH_LEVEL )
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Use negative number to express relative time.
|
|
||||||
// Convert micro seconds into 100 nano second units
|
|
||||||
//
|
|
||||||
Interval.QuadPart = -( (LONGLONG) dwTime * 10 );
|
|
||||||
KeDelayExecutionThread( KernelMode, FALSE, &Interval );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// This is very nasty, but we have no choice
|
|
||||||
//
|
|
||||||
KeStallExecutionProcessor( dwTime );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS COsSupport::OsSnooze
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// More memory management
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Allocate locked, non-pageable, physically contiguous memory pages
|
|
||||||
// in the drivers address space. Used to allocate memory for the DSP
|
|
||||||
// communications area.
|
|
||||||
//
|
|
||||||
// Currently, none of the generic code ever sets dwPageCt to higher than
|
|
||||||
// one. On the platforms we've developed for so far, a page is 4096
|
|
||||||
// bytes and is aligned on a 4096 byte boundary. None of the structures
|
|
||||||
// allocated by OsPageAllocate are more than 4096 bytes; memory
|
|
||||||
// allocated by this routine should be at least aligned on a 32 byte
|
|
||||||
// boundary and be physically contiguous.
|
|
||||||
//
|
|
||||||
// Note that this code is not 64 bit ready, since it's only using
|
|
||||||
// the low 32 bits of the physical address.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ECHOSTATUS COsSupport::OsPageAllocate
|
|
||||||
(
|
|
||||||
DWORD dwPageCt, // How many pages to allocate
|
|
||||||
PPVOID ppPageAddr, // Where to return the memory ptr
|
|
||||||
PPHYS_ADDR pPhysicalPageAddr // Where to return the physical PCI address
|
|
||||||
)
|
|
||||||
{
|
|
||||||
PHYSICAL_ADDRESS LogicalAddress;
|
|
||||||
|
|
||||||
ASSERT( DISPATCH_LEVEL >= KeGetCurrentIrql() );
|
|
||||||
|
|
||||||
*ppPageAddr = ExAllocatePoolWithTag(NonPagedPool,
|
|
||||||
PAGE_SIZE * dwPageCt,
|
|
||||||
'OHCE');
|
|
||||||
if (NULL != *ppPageAddr)
|
|
||||||
{
|
|
||||||
PHYSICAL_ADDRESS PhysTemp;
|
|
||||||
|
|
||||||
PhysTemp = MmGetPhysicalAddress(*ppPageAddr);
|
|
||||||
*pPhysicalPageAddr = PhysTemp.LowPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlZeroMemory( *ppPageAddr, dwPageCt * PAGE_SIZE );
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS COsSupport::OsPageAllocate
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Unlock and free non-pageable, physically contiguous memory pages in
|
|
||||||
// the drivers address space; the inverse of OsPageAllocate
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ECHOSTATUS COsSupport::OsPageFree
|
|
||||||
(
|
|
||||||
DWORD dwPageCt, // How many pages to free
|
|
||||||
PVOID pPageAddr, // Virtual memory ptr
|
|
||||||
PHYS_ADDR PhysicalPageAddr // Physical PCI addr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
PHYSICAL_ADDRESS LogicalAddress;
|
|
||||||
|
|
||||||
ASSERT( DISPATCH_LEVEL >= KeGetCurrentIrql() );
|
|
||||||
|
|
||||||
if (NULL == pPageAddr)
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
ExFreePool(pPageAddr);
|
|
||||||
|
|
||||||
return ECHOSTATUS_OK;
|
|
||||||
|
|
||||||
} // ECHOSTATUS COsSupport::OsPageFree
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Display an error message w/title; currently not supported under WDM.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void COsSupport::EchoErrorMsg
|
|
||||||
(
|
|
||||||
PCHAR pszMsg,
|
|
||||||
PCHAR pszTitle
|
|
||||||
)
|
|
||||||
{
|
|
||||||
} // void COsSupport::EchoErrorMsg( PCHAR )
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Overload new & delete so memory for this object is allocated from
|
|
||||||
// non-paged memory.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PVOID COsSupport::operator new( size_t Size )
|
|
||||||
{
|
|
||||||
PVOID pMemory;
|
|
||||||
ECHOSTATUS Status;
|
|
||||||
|
|
||||||
Status = OsAllocateNonPaged(Size,&pMemory);
|
|
||||||
|
|
||||||
if ( (ECHOSTATUS_OK != Status) || (NULL == pMemory ))
|
|
||||||
{
|
|
||||||
ECHO_DEBUGPRINTF(("COsSupport::operator new - memory allocation failed\n"));
|
|
||||||
|
|
||||||
pMemory = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset( pMemory, 0, Size );
|
|
||||||
}
|
|
||||||
|
|
||||||
return pMemory;
|
|
||||||
|
|
||||||
} // PVOID COsSupport::operator new( size_t Size )
|
|
||||||
|
|
||||||
|
|
||||||
VOID COsSupport::operator delete( PVOID pVoid )
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( ECHOSTATUS_OK != OsFreeNonPaged( pVoid ) )
|
|
||||||
{
|
|
||||||
ECHO_DEBUGPRINTF(("COsSupport::operator delete "
|
|
||||||
"memory free failed\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // VOID COsSupport::operator delete( PVOID pVoid )
|
|
||||||
|
|
||||||
@@ -1,289 +0,0 @@
|
|||||||
// ****************************************************************************
|
|
||||||
//
|
|
||||||
// OsSupportWDM.H
|
|
||||||
//
|
|
||||||
// Include file for WDM Support Services to the CEchoGals
|
|
||||||
// generic driver class
|
|
||||||
//
|
|
||||||
// Set editor tabs to 3 for your viewing pleasure.
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright Echo Digital Audio Corporation (c) 1998 - 2002
|
|
||||||
// All rights reserved
|
|
||||||
// www.echoaudio.com
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal with the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
// the following conditions:
|
|
||||||
//
|
|
||||||
// - Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers.
|
|
||||||
//
|
|
||||||
// - Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimers in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// - Neither the name of Echo Digital Audio, nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this Software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
// SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// ****************************************************************************
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma optimize("",off)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Prevent problems with multiple includes
|
|
||||||
#ifndef _ECHOOSSUPPORTWDM_
|
|
||||||
#define _ECHOOSSUPPORTWDM_
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <wdm.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include <portcls.h>
|
|
||||||
|
|
||||||
// hack - I have to do this- this prototype only
|
|
||||||
// shows up in ntddk.h, but wdm.h prevents ntddk.h
|
|
||||||
// from compiling... mattg
|
|
||||||
NTKERNELAPI
|
|
||||||
PHYSICAL_ADDRESS
|
|
||||||
MmGetPhysicalAddress (
|
|
||||||
IN PVOID BaseAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
// WDM debug printf macro
|
|
||||||
//#define ECHO_DEBUGPRINTF( strings ) DbgPrint##strings
|
|
||||||
#define ECHO_DEBUGPRINTF( strings )
|
|
||||||
//#define ECHO_DEBUGBREAK()
|
|
||||||
#define ECHO_DEBUGBREAK() _asm int 3;
|
|
||||||
#define ECHO_DEBUG
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define ECHO_DEBUGPRINTF( strings )
|
|
||||||
#define ECHO_DEBUGBREAK()
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// Specify OS specific types
|
|
||||||
//
|
|
||||||
typedef void ** PPVOID;
|
|
||||||
typedef signed char INT8;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Return Status Values
|
|
||||||
//
|
|
||||||
typedef unsigned long ECHOSTATUS;
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Define generic byte swapping functions
|
|
||||||
//
|
|
||||||
#ifdef BIG_ENDIAN_HOST
|
|
||||||
WORD SwapBytes( WORD dwIn );
|
|
||||||
DWORD SwapBytes( DWORD dwIn );
|
|
||||||
#define SWAP(x) SwapBytes( x )
|
|
||||||
#else
|
|
||||||
#define SWAP(x) x
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// Define what a physical address is on this OS
|
|
||||||
//
|
|
||||||
typedef unsigned long PHYS_ADDR; // Define physical addr type
|
|
||||||
typedef unsigned long * PPHYS_ADDR; // Define physical addr pointer type
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global Memory Management Functions
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// This tag is used to mark all memory allocated by EchoGals.
|
|
||||||
// Due to the way PoolMon displays things, we spell Echo backwards
|
|
||||||
// so it displays correctly.
|
|
||||||
//
|
|
||||||
#define ECHO_POOL_TAG 'OHCE'
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// OsAllocateInit - Set up memory tracking. Call this once - not
|
|
||||||
// once per PCI card, just one time.
|
|
||||||
//
|
|
||||||
void OsAllocateInit();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Allocate locked, non-pageable block of memory. Does not have to be
|
|
||||||
// physically contiguous. Primarily used to implement the overloaded
|
|
||||||
// new operator for classes that must remain memory resident.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsAllocateNonPaged
|
|
||||||
(
|
|
||||||
DWORD dwByteCt,
|
|
||||||
PPVOID ppMemAddr
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Unlock and free, non-pageable block of memory.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsFreeNonPaged
|
|
||||||
(
|
|
||||||
PVOID pMemAddr
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Copy memory
|
|
||||||
//
|
|
||||||
#define OsCopyMemory(pDest,pSrc,dwBytes) RtlCopyMemory(pDest,pSrc,dwBytes)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Set memory to zero
|
|
||||||
//
|
|
||||||
#define OsZeroMemory(pDest,dwBytes) RtlZeroMemory(pDest,dwBytes)
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// This class is uniquely defined for each OS. It provides
|
|
||||||
// information that other components may require.
|
|
||||||
// For example, in Windows NT it contains a device object used by various
|
|
||||||
// memory management methods.
|
|
||||||
// Since static variables are used in place of globals, an instance must
|
|
||||||
// be constructed and initialized by the OS Interface object prior to
|
|
||||||
// constructing the CEchoGals derived object. The CEchoGals and
|
|
||||||
// CDspCommObject classes must have access to it during their respective
|
|
||||||
// construction times.
|
|
||||||
//
|
|
||||||
class COsSupport
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// Construction/destruction
|
|
||||||
//
|
|
||||||
COsSupport
|
|
||||||
(
|
|
||||||
DWORD dwDeviceId // PCI bus device id
|
|
||||||
);
|
|
||||||
|
|
||||||
~COsSupport();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Timer Methods
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Return the system time in microseconds.
|
|
||||||
// Return error status if the OS doesn't support this function.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsGetSystemTime
|
|
||||||
(
|
|
||||||
PULONGLONG pullTime
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Stall execution for dwTime microseconds.
|
|
||||||
// Return error status if the OS doesn't support this function.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsSnooze
|
|
||||||
(
|
|
||||||
DWORD dwTime
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Memory Management Methods
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Allocate locked, non-pageable, physically contiguous memory pages
|
|
||||||
// in the drivers address space. Used to allocate memory for the DSP
|
|
||||||
// communications area and Ducks.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsPageAllocate
|
|
||||||
(
|
|
||||||
DWORD dwPageCt, // How many pages to allocate
|
|
||||||
PPVOID ppPageAddr, // Where to return the memory ptr
|
|
||||||
PPHYS_ADDR pPhysicalPageAddr // Where to return the physical PCI addr
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Unlock and free non-pageable, physically contiguous memory pages
|
|
||||||
// in the drivers address space.
|
|
||||||
// Used to free memory for the DSP communications area and Ducks.
|
|
||||||
//
|
|
||||||
ECHOSTATUS OsPageFree
|
|
||||||
(
|
|
||||||
DWORD dwPageCt, // How many pages to free
|
|
||||||
PVOID pPageAddr, // Virtual memory ptr
|
|
||||||
PHYS_ADDR PhysicalPageAddr // Physical PCI addr
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add additional methods here
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Display and/or log an error message w/title
|
|
||||||
//
|
|
||||||
void EchoErrorMsg
|
|
||||||
(
|
|
||||||
PCHAR pszMsg,
|
|
||||||
PCHAR pszTitle
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Return PCI card device ID
|
|
||||||
//
|
|
||||||
DWORD GetDeviceId()
|
|
||||||
{ return( m_dwDeviceId ); }
|
|
||||||
|
|
||||||
//
|
|
||||||
// Overload new & delete so memory for this object is allocated
|
|
||||||
// from non-paged memory.
|
|
||||||
//
|
|
||||||
PVOID operator new( size_t Size );
|
|
||||||
VOID operator delete( PVOID pVoid );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
private:
|
|
||||||
DWORD m_dwDeviceId; // PCI Device ID
|
|
||||||
|
|
||||||
//
|
|
||||||
// Define data here.
|
|
||||||
//
|
|
||||||
|
|
||||||
KIRQL m_IrqlCurrent; // Old IRQ level
|
|
||||||
ULONGLONG m_ullStartTime; // All system time relative to this time
|
|
||||||
class CPtrQueue * m_pPtrQue; // Store read only ptrs so they
|
|
||||||
// can be unmapped
|
|
||||||
|
|
||||||
}; // class COsSupport
|
|
||||||
|
|
||||||
typedef COsSupport * PCOsSupport;
|
|
||||||
|
|
||||||
#endif // _ECHOOSSUPPORTWDM_
|
|
||||||
Reference in New Issue
Block a user