📄 system.c
字号:
/*DEBUGMSG(1|ZONE_INIT | ZONE_ERROR,
(TEXT("Error initializing interrupt\n\r")));*/
return INVALID_HANDLE_VALUE;
}
InterruptDone(pContext->SysIntr);
// Set up the dispatch thread and it's kill flag. Note that the thread
// fills in its own handle in pSerialHead.
hInterruptThread = NULL;
hInterruptThread = CreateThread(NULL,0, InterruptThread, pContext, 0,NULL);
return hInterruptThread;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_InitializeSystem(
PVOID pvContext
)
{
DWORD Lbrd1;
PCEUFNPDD_CONTEXT pContext = (PCEUFNPDD_CONTEXT)pvContext;
// Set up Base Addresses and Interrupt Number
FindHardware((PUCHAR *)&NetchipBaseAddress, &Plx9054ConfigAddress , &pContext->SysIntr, pContext->hKey);
// Set Bus Width
Lbrd1 = *(PDWORD)(Plx9054ConfigAddress + LBRD1);
*(PDWORD)(Plx9054ConfigAddress + LBRD1) =
Lbrd1 & ~(3 << MEMORY_SPACE_LOCAL_BUS_WIDTH) | W16_BIT;
NCPRINTF(VOLUME_MINIMUM, ("Set 16 bit address width\n"));
Rdk_ResetNetchip();
InitializeCriticalSection(&pContext->csInterrupt);
// Start Interrupt Thread
// Remember these handles for De-init later
pContext->hInterruptThread = StartInterruptThread(pContext);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
void *
NcMalloc(
size_t Size
)
{ // NetChip's version of malloc() using Windows system calls
// - Do free/malloc accounting
// - Use Windows LocalAlloc()
PVOID OsResult;
MallocRefCount++;
OsResult = LocalAlloc(LPTR, Size);
if (OsResult == NULL)
{
ASSERT(FALSE);
}
HISTO(VOLUME_MAXIMUM, "Aloc", MallocRefCount, (DWORD)OsResult, Size);
return OsResult;
}
///////////////////////////////////////////////////////////////////////////////
void
NcFree(
void **pBuf
)
{
// NetChip's 'friendly' version of free()
// - Note parameter difference: pointer to *pointer* to buffer (so pointer
// referencing memory can be set to NULL)
// - Conditionally free buffer: only free if buffer appears allocated (i.e. non-NULL)
// - After freeing, mark buffer pointer as free (i.e. NULL)
// - Do free/malloc accounting
// - Use Windows LocalFree()
if (*pBuf == NULL)
{ // Buffer is already freed
return;
}
HISTO(VOLUME_MAXIMUM, "Free", MallocRefCount, (DWORD)*pBuf, 0);
ASSERT(MallocRefCount);
MallocRefCount--;
LocalFree(*pBuf);
// Mark buffer pointer as free
*pBuf = NULL;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_SetupDma(
DWORD EpDataOffset, // Offset to an endpoint's EPDATA register
PUCHAR Buffer,
DWORD BufferSize,
BOOL IsTx,
BOOL DmaBurstEnable
)
{ // Stub function
DWORD temp1;
PUCHAR temp2;
BOOL temp3;
temp1 = EpDataOffset;
temp1 = BufferSize;
temp2 = Buffer;
temp3 = IsTx;
temp3 = DmaBurstEnable;
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_KickDma(
void
)
{ // Stub function
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_DmaStatus(
PBOOL DmaReady
)
{ // Stub function
PBOOL temp;
temp = DmaReady;
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_AbortDma(
void
)
{ // Stub function
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#else // #if _NC_CEPC
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#pragma message (_NC_MESSAGE"The following functions are not fully implemented.")
#pragma message (_NC_MESSAGE" - Complete as appropriate for target platform:")
// Compiling in target platform environment. (i.e. compiling in non-Windows
// and non-RDK environment):
// - In the Windows/RDK environment, several calls are fulfilled using Windows
// system calls and RDK driver calls. Your platform will certainly require
// different methods.
// Portability Stub Functions:
// - These empty 'stub' functions are to be implemented for your specific platform.
// - When _NC_RDK_AND_WINDOWS is FALSE, the PCI-RDK support functions for interrupts DMA,
// memory allocation, etc., are replaced with the following stub functions
///////////////////////////////////////////////////////////////////////////////
void *
NcMalloc(
size_t Size
)
{ // Allocate memory
// - This is a function stub. It must be completed as appropriate for target platform
// - Call malloc(), or equivalent
DBG_UNREFERENCED_PARAMETER(Size);
#pragma message (_NC_MESSAGE"NcMalloc()")
return NULL;
}
///////////////////////////////////////////////////////////////////////////////
void
NcFree(
void **pBuf
)
{ // Free memory (allocated by NcMalloc()) (stub function)
// - This is a function stub. It must be completed as appropriate for target platform
// - Call free(), or equivalent
// - Note: parameter is pointer to a *pointer* to memory!
DBG_UNREFERENCED_PARAMETER(pBuf);
#pragma message (_NC_MESSAGE"NcFree()")
}
///////////////////////////////////////////////////////////////////////////////
void
NcSleep(
UINT dwMilliseconds
)
{ // 'Sleep' for specified number of milliseconds
// - This is a function stub. It must be completed as appropriate for target platform
// - Call standard 'sleep()' or equivalent
DBG_UNREFERENCED_PARAMETER(dwMilliseconds);
#pragma message (_NC_MESSAGE"NcSleep()")
}
///////////////////////////////////////////////////////////////////////////////
void
System_ResetNetchip(
void
)
{ // Assert NET2272 reset pin
// - This is a function stub. Usually, all function stubs need to be
// completed for target platforms, however, resetting the NET2272
// may not be possible on all hardware designs
#pragma message (_NC_MESSAGE"System_ResetNetchip()")
}
///////////////////////////////////////////////////////////////////////////////
INTERRUPTCONTROL
System_InterruptController(
INTERRUPTCONTROL InterruptRequest
)
{ // Basic controls (enable, disable, status) for an interrupt controller
// connected to NetChip IRQ pin:
// - This is a function stub. Usually, all function stubs need to be
// completed for target platforms, however, carefully crafted code may
// not need this interrupt controller interface: If it can be guaranteed
// that all API calls are made from an interrupt context AND no API calls
// can be interrupted with other API calls, it should be safe to remove all
// references to this interrupt controller function.
#pragma message (_NC_MESSAGE"System_InterruptController()")
DBG_UNREFERENCED_PARAMETER(InterruptRequest);
return NCSYS_INTERRUPT_DISABLE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL
System_InitializeSystem(
PVOID pvContext
)
{ // Initialize non-NET2272 systems:
// - This is a function stub. It must be completed as appropriate for target platform
// - Program interrupt controller and DMA controller as applicable
#pragma message (_NC_MESSAGE"System_InitializeSystem()")
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////}
#endif // #if _NC_CEPC
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// End of file
///////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -