📄 kitl.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//------------------------------------------------------------------------------
//
// File: kitl.c
//
// Support routines for KITL.
//
// Note: this routines are stubbed out in the kern image.
//
//------------------------------------------------------------------------------
#include <bsp.h>
#include <ethdrv.h>
#include <kitl_cfg.h>
#include <devload.h>
//------------------------------------------------------------------------------
//
// Platform entry point for KITL. Called when KITLIoctl (IOCTL_KITL_STARTUP, ...) is called.
//
BOOL OEMKitlStartup (void)
{
BOOL rc = FALSE;
OAL_KITL_ARGS *pKITLArgs, KITLArgs;
CHAR *pszDeviceId;
// dpCurSettings.ulZoneMask = (UINT32) -1;
KITL_RETAILMSG(ZONE_KITL_OAL, ("+OEMKitlStartup\r\n"));
// Check and initialize the BSP Args area
//
OALArgsInit((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START);
// Look for bootargs left by the bootloader or left over from an earlier boot.
//
pKITLArgs = (OAL_KITL_ARGS*) OALArgsQuery(OAL_ARGS_QUERY_KITL);
pszDeviceId = (CHAR*) OALArgsQuery(OAL_ARGS_QUERY_DEVID);
// If no KITL arguments were found (typically provided by the bootloader), then select
// some default settings.
//
if (pKITLArgs == NULL)
{
memset(&KITLArgs, 0, sizeof(OAL_KITL_ARGS));
// By default, enable: KITL, DHCP, and VMINI...
KITLArgs.flags = (OAL_KITL_FLAGS_ENABLED | OAL_KITL_FLAGS_DHCP | OAL_KITL_FLAGS_VMINI);
// Use built-in DM9000 controller for KITL.
KITLArgs.devLoc.IfcType = Internal;
KITLArgs.devLoc.BusNumber = 0;
KITLArgs.devLoc.PhysicalLoc = (PVOID)(MAINSTONEII_BASE_REG_PA_DM9000_ETHERNET + 0x300);
KITLArgs.devLoc.LogicalLoc = (DWORD)KITLArgs.devLoc.PhysicalLoc;
pKITLArgs = &KITLArgs;
}
// pKITLArgs->flags |= OAL_KITL_FLAGS_POLL;
if (pszDeviceId == NULL)
{
KITL_RETAILMSG(ZONE_ERROR, ("ERROR: Unable to locate Device ID buffer\r\n"));
}
else if (pszDeviceId[0] == '\0')
{
// We don't yet have the Ethernet controller's MAC address (this is obtained
// in the initialization function. Store a base name for the device, and
// signal that it should be extended with the MAC address later.
//
strncpy(pszDeviceId, BSP_DEVICE_PREFIX, OAL_KITL_ID_SIZE);
pKITLArgs->flags |= OAL_KITL_FLAGS_EXTNAME;
}
// Finally call KITL library.
//
rc = OALKitlInit(pszDeviceId, pKITLArgs, g_kitlDevices);
KITL_RETAILMSG(ZONE_KITL_OAL, ("-OEMKitlStartup(rc = %d)\r\n", rc));
return(rc);
}
DWORD OEMKitlGetSecs (void)
{
SYSTEMTIME st;
DWORD dwRet;
static DWORD dwBias;
static DWORD dwLastTime;
OEMGetRealTime( &st );
dwRet = ((60UL * (60UL * (24UL * (31UL * st.wMonth + st.wDay) + st.wHour) + st.wMinute)) + st.wSecond);
dwBias = dwRet;
if (dwRet < dwLastTime) {
KITLOutputDebugString("! Time went backwards (or wrapped): cur: %u, last %u\n",
dwRet,dwLastTime);
}
dwLastTime = dwRet;
return (dwRet);
}
//------------------------------------------------------------------------------
//
// Function: OALGetTickCount
//
// This function is called by some KITL libraries to obtain relative time
// since device boot. It is mostly used to implement timeout in network
// protocol.
//
UINT32 OALGetTickCount()
{
return OEMKitlGetSecs () * 1000;
}
VOID OALStall(UINT32 microSec)
{
volatile PBULVERDE_OST_REG pOSTRegs = NULL;
pOSTRegs = (PBULVERDE_OST_REG)OALPAtoVA(BULVERDE_BASE_REG_PA_OST, FALSE);
XllpOstDelayMicroSeconds(pOSTRegs, microSec);
}
//------------------------------------------------------------------------------
//
// Function: OALKitlInitRegistry
//
// This function is called during the initialization process to allow the
// OAL to denote devices which are being used by the KITL connection
// and thus shouldn't be touched during the OS initialization process. The
// OAL provides this information via the registry.
//
VOID OALKitlInitRegistry()
{
OAL_KITL_ARGS *pKITLArgs;
HKEY Key;
DWORD Status;
DWORD Disposition;
// If we're using one of the PCCARD slots for the KITL connection, then we
// should disable the PCCARD driver (via the "no load" option in the registry)
// in order to avoid a conflict.
//
pKITLArgs = (OAL_KITL_ARGS*) OALArgsQuery(OAL_ARGS_QUERY_KITL);
if (pKITLArgs &&
((pKITLArgs->devLoc.PhysicalLoc == (PVOID)OALPAtoVA((BULVERDE_BASE_REG_PA_PCMCIA_S0_IO + 0x300), FALSE)) ||
(pKITLArgs->devLoc.PhysicalLoc == (PVOID)OALPAtoVA((BULVERDE_BASE_REG_PA_PCMCIA_S1_IO + 0x300), FALSE))))
{
// We're using the PCCARD controller for the KITL connection...
//
// *** Disable PCCARD slot 0 instance ***
//
Status = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Drivers\\BuiltIn\\PCC_MAINSTONEII0", 0, NULL, 0, 0, NULL, &Key, &Disposition);
if (Status == ERROR_SUCCESS)
{
Disposition = DEVFLAGS_NOLOAD;
// Set Flags value to indicate no loading of driver for this device
Status = NKRegSetValueEx(Key, DEVLOAD_FLAGS_VALNAME, 0, DEVLOAD_FLAGS_VALTYPE, (PBYTE)&Disposition, sizeof(Disposition));
}
// Close the registry key.
NKRegCloseKey(Key);
if (Status != ERROR_SUCCESS)
{
KITL_RETAILMSG(ZONE_ERROR, ("OALKitlInitRegistry: failed to set \"no load\" key for PCCARD slot 0.\r\n"));
goto CleanUp;
}
//
// *** Disable PCCARD slot 1 instance ***
//
Status = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Drivers\\BuiltIn\\PCC_MAINSTONEII1", 0, NULL, 0, 0, NULL, &Key, &Disposition);
if (Status == ERROR_SUCCESS)
{
Disposition = DEVFLAGS_NOLOAD;
// Set Flags value to indicate no loading of driver for this device
Status = NKRegSetValueEx(Key, DEVLOAD_FLAGS_VALNAME, 0, DEVLOAD_FLAGS_VALTYPE, (PBYTE)&Disposition, sizeof(Disposition));
}
// Close the registry key.
NKRegCloseKey(Key);
if (Status != ERROR_SUCCESS)
{
KITL_RETAILMSG(ZONE_ERROR, ("OALKitlInitRegistry: failed to set \"no load\" key for PCCARD slot 1.\r\n"));
goto CleanUp;
}
KITL_RETAILMSG(ZONE_INIT, ("INFO: PCCARD being used for KITL - disabling PCCARD driver...\r\n"));
}
CleanUp:
return;
}
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -