📄 main.c
字号:
BOOL OEMIsFlashAddr (DWORD dwAddr)
{
return FALSE;
}
BOOL OEMStartEraseFlash (DWORD dwStartAddr, DWORD dwLength)
{
return FALSE;
}
void OEMContinueEraseFlash (void)
{
}
BOOL OEMFinishEraseFlash (void)
{
return FALSE;
}
//------------------------------------------------------------------------------
/* OEMEthGetFrame
*
* Check to see if a frame has been received, and if so copy to buffer. An optimization
* which may be performed in the Ethernet driver is to filter out all received broadcast
* packets except for ARPs. This is done in the SMC9000 driver.
*
* Return Value:
* Return TRUE if frame has been received, FALSE if not.
*/
//------------------------------------------------------------------------------
BOOL
OEMEthGetFrame(
BYTE *pData, // OUT - Receives frame data
UINT16 *pwLength) // IN - Length of Rx buffer
// OUT - Number of bytes received
{
return g_pEdbgDriver->pfnGetFrame (pData, pwLength);
}
//------------------------------------------------------------------------------
/* OEMEthSendFrame
*
* Send Ethernet frame.
*
* Return Value:
* TRUE if frame successfully sent, FALSE otherwise.
*/
//------------------------------------------------------------------------------
BOOL
OEMEthSendFrame(
BYTE *pData, // IN - Data buffer
DWORD dwLength) // IN - Length of buffer
{
int retries = 0;
// Let's be persistant here
while (retries++ < 4) {
if (!g_pEdbgDriver->pfnSendFrame (pData, dwLength))
return TRUE;
else
KITLOutputDebugString("!OEMEthSendFrame failure, retry %u\n",retries);
}
return FALSE;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
VOID SC_WriteDebugLED(WORD wIndex, DWORD dwPattern) {
return;
}
//
// rtc cmos functions, in oal_x86_rtc.lib
//
BOOL Bare_GetRealTime(LPSYSTEMTIME lpst);
//------------------------------------------------------------------------------
// OEMGetRealTime
//
// called by the kitl library to handle OEMEthGetSecs
//
//------------------------------------------------------------------------------
BOOL OEMGetRealTime(LPSYSTEMTIME lpst)
{
return Bare_GetRealTime(lpst);
}
//
// read a line from debug port, return FALSE if timeout
// (timeout value in seconds)
//
#define BACKSPACE 8
#define IPADDR_MAX 15 // strlen ("xxx.xxx.xxx.xxx") = 15
static char szbuf[IPADDR_MAX+1];
static BOOL ReadIPLine (char *pbuf, DWORD dwTimeout)
{
DWORD dwCurrSec = OEMEthGetSecs ();
char ch;
int nLen = 0;
while (OEMEthGetSecs () - dwCurrSec < dwTimeout) {
switch (ch = OEMReadDebugByte ()) {
case OEM_DEBUG_COM_ERROR:
case OEM_DEBUG_READ_NODATA:
// no data or error, keep reading
break;
case BACKSPACE:
nLen --;
OEMWriteDebugByte (ch);
break;
case '\r':
case '\n':
OEMWriteDebugByte ('\n');
pbuf[nLen] = 0;
return TRUE;
default:
if ((ch == '.' || (ch >= '0' && ch <= '9')) && (nLen < IPADDR_MAX)) {
pbuf[nLen ++] = ch;
OEMWriteDebugByte (ch);
}
}
}
return FALSE; // timeout
}
// ask user to select transport options
static BOOL AskUser (EDBG_ADDR *pMyAddr, DWORD *pdwSubnetMask)
{
KITLOutputDebugString ("Hit ENTER within 3 seconds to enter static IP address!");
szbuf[IPADDR_MAX] = 0; // for safe measure, make sure null termination
if (!ReadIPLine (szbuf, 3)) {
return FALSE;
}
KITLOutputDebugString ("Enter IP address, or CR for default (%s): ", inet_ntoa (pMyAddr->dwIP));
ReadIPLine (szbuf, INFINITE);
if (szbuf[0]) {
pMyAddr->dwIP = inet_addr (szbuf);
}
KITLOutputDebugString ("Enter Subnet Masks, or CR for default (%s): ", inet_ntoa (*pdwSubnetMask));
ReadIPLine (szbuf, INFINITE);
if (szbuf[0]) {
*pdwSubnetMask = inet_addr (szbuf);
}
KITLOutputDebugString ( "\r\nUsing IP Address %s, ", inet_ntoa (pMyAddr->dwIP));
KITLOutputDebugString ( "subnet mask %s\r\n", inet_ntoa (*pdwSubnetMask));
return TRUE;
}
// Dummmy
LPVOID NKCreateStaticMapping(DWORD dwPhysBase, DWORD dwSize)
{
return (LPVOID)dwPhysBase;
}
/*
@func void | OEMDownloadFileNotify | Receives/processed download file manifest.
@rdesc
@comm
@xref
*/
void OEMDownloadFileNotify(PDownloadManifest pInfo)
{
BYTE nCount;
if (!pInfo || !pInfo->dwNumRegions)
{
KITLOutputDebugString("WARNING: OEMDownloadFileNotify - invalid BIN region descriptor(s).\r\n");
return;
}
g_dwMinImageStart = pInfo->Region[0].dwRegionStart;
KITLOutputDebugString("\r\nDownload file information:\r\n");
KITLOutputDebugString("-----------------------------------------------------\r\n");
for (nCount = 0 ; nCount < pInfo->dwNumRegions ; nCount++)
{
EdbgOutputDebugString("[%d]: Address=0x%x Length=0x%x Name=%s\r\n", nCount,
pInfo->Region[nCount].dwRegionStart,
pInfo->Region[nCount].dwRegionLength,
pInfo->Region[nCount].szFileName);
if (pInfo->Region[nCount].dwRegionStart < g_dwMinImageStart)
{
g_dwMinImageStart = pInfo->Region[nCount].dwRegionStart;
if (g_dwMinImageStart == 0)
{
KITLOutputDebugString("WARNING: OEMDownloadFileNotify - bad start address for file (%s).\r\n", pInfo->Region[nCount].szFileName);
return;
}
}
}
KITLOutputDebugString("\r\n");
memcpy((LPBYTE)&g_BINRegionInfo, (LPBYTE)pInfo, sizeof(MultiBINInfo));
}
static PVOID GetKernelExtPointer(DWORD dwRegionStart, DWORD dwRegionLength)
{
DWORD dwCacheAddress = 0;
ROMHDR *pROMHeader;
DWORD dwNumModules = 0;
TOCentry *pTOC;
if (dwRegionStart == 0 || dwRegionLength == 0)
return(NULL);
if (*(LPDWORD) OEMMapMemAddr (dwRegionStart, dwRegionStart + ROM_SIGNATURE_OFFSET) != ROM_SIGNATURE)
return NULL;
// A pointer to the ROMHDR structure lives just past the ROM_SIGNATURE (which is a longword value). Note that
// this pointer is remapped since it might be a flash address (image destined for flash), but is actually cached
// in RAM.
//
dwCacheAddress = *(LPDWORD) OEMMapMemAddr (dwRegionStart, dwRegionStart + ROM_SIGNATURE_OFFSET + sizeof(ULONG));
pROMHeader = (ROMHDR *) OEMMapMemAddr (dwRegionStart, dwCacheAddress);
// Make sure sure are some modules in the table of contents.
//
if ((dwNumModules = pROMHeader->nummods) == 0)
return NULL;
// Locate the table of contents and search for the kernel executable and the TOC immediately follows the ROMHDR.
//
pTOC = (TOCentry *)(pROMHeader + 1);
while(dwNumModules--) {
LPBYTE pFileName = OEMMapMemAddr(dwRegionStart, (DWORD)pTOC->lpszFileName);
if (!strcmp((const char *)pFileName, "nk.exe")) {
return ((PVOID)(pROMHeader->pExtensions));
}
++pTOC;
}
return NULL;
}
ULONG
HalSetBusDataByOffset(
IN BUS_DATA_TYPE BusDataType,
IN ULONG BusNumber,
IN ULONG SlotNumber,
IN PVOID Buffer,
IN ULONG Offset,
IN ULONG Length
)
{
return (PCISetBusDataByOffset (BusNumber, SlotNumber, Buffer, Offset, Length));
}
BOOL INTERRUPTS_ENABLE (BOOL fEnable)
{
return FALSE;
}
// For USB kitl it need this to satisfy the debug build.
#ifdef DEBUG
DBGPARAM
dpCurSettings =
{
TEXT("RndisMini"),
{
//
// MDD's, DON"T TOUCH
//
TEXT("Init"),
TEXT("Rndis"),
TEXT("Host Miniport"),
TEXT("CE Miniport"),
TEXT("Mem"),
TEXT("PDD Call"),
TEXT("<unused>"),
TEXT("<unused>"),
//
// PDD can use these..
//
TEXT("PDD Interrupt"),
TEXT("PDD EP0"),
TEXT("PDD EP123"),
TEXT("PDD FIFO"),
TEXT("PDD"),
TEXT("<unused>"),
//
// Standard, DON'T TOUCH
//
TEXT("Warning"),
TEXT("Error")
},
0xc000
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -