⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kitl.c

📁 Intel DBPXA27X评估板OAL层代码.
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  File:  kitl.c
//
//  Support routines for KITL. 
//
//  Note: this routines are stubbed out in the kern image.
//
//------------------------------------------------------------------------------

#include <bsp.h>
#include <kitl_cfg.h>
#include <devload.h>

//------------------------------------------------------------------------------

BOOL OALKitlStart()
{
    BOOL rc = FALSE;
    OAL_KITL_ARGS *pKITLArgs, KITLArgs;
    CHAR *pszDeviceId;

//OALLogSetZones((UINT32)0x8100000F);
//KITLSetDebug(0xFFFFFFFF);

    OALMSG(OAL_KITL&&OAL_FUNC, (L"+OALKitlStart\r\n"));

    // 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 LAN91C111 controller for KITL.
        KITLArgs.devLoc.IfcType     = Internal;
        KITLArgs.devLoc.BusNumber   = 0;
        KITLArgs.devLoc.PhysicalLoc = (PVOID)(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET + 0x300);
        KITLArgs.devLoc.LogicalLoc  = (DWORD)KITLArgs.devLoc.PhysicalLoc;

        pKITLArgs = &KITLArgs;
    }
//temp
/*
        memset(&KITLArgs, 0, sizeof(OAL_KITL_ARGS));
        KITLArgs.flags = (OAL_KITL_FLAGS_ENABLED);
        KITLArgs.devLoc.IfcType     = Internal;
        KITLArgs.devLoc.BusNumber   = 0;
        KITLArgs.devLoc.PhysicalLoc = (PVOID)(BULVERDE_BASE_REG_PA_UDC);
        KITLArgs.devLoc.LogicalLoc  = (DWORD)KITLArgs.devLoc.PhysicalLoc;

        pKITLArgs = &KITLArgs;
*/
//
    if (pszDeviceId == NULL)
    {
        OALMSG(OAL_ERROR, (L"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);

    OALMSG(OAL_KITL&&OAL_FUNC, (L"-OALKitlStart(rc = %d)\r\n", rc));
    return(rc);
}


DWORD OEMEthGetSecs (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 OEMEthGetSecs () * 1000;
}


//------------------------------------------------------------------------------
//
//  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)
        {
            OALMSGS(OAL_ERROR, (L"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)
        {
            OALMSGS(OAL_ERROR, (L"OALKitlInitRegistry: failed to set \"no load\" key for PCCARD slot 1.\r\n"));
            goto CleanUp;
        }

        OALMSGS(TRUE, (L"INFO: PCCARD being used for KITL - disabling PCCARD driver...\r\n"));
    }

CleanUp:

    return;
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -