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

📄 args.c

📁 WinCE5.0BSP for Renesas SH7770
💻 C
字号:
//
//  Copyright(C) Renesas Technology Corp. 2005. All rights reserved.
//
//  NK Kernel for ITS-DS7
//
//  FILE      : args.c
//  CREATED   : 2005.08.10
//  MODIFIED  : 2005.11.14
//  AUTHOR    : Renesas Technology Corp.
//  HARDWARE  : RENESAS ITS-DS7
//  HISTORY   : 
//              2005.08.10
//              - Created release code.
//                (based on SMDK2410/MAINSTONEII for WCE5.0)
//              2005.11.14
//              - Modified CreateName().

//
// 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.
//
//------------------------------------------------------------------------------
//
#include <bsp.h>
#include "its_ds7.h"
#include "drv_glob.h"

#define pDriverGlobals  ((PDRIVER_GLOBALS) DRIVER_GLOBALS_PHYSICAL_MEMORY_START)

BSP_ARGS g_BSP_ARGS;

// Must define this locally instead of using the OALKitlCreateName so that we
// do not break non-kitl images
VOID CreateName(CHAR *pPrefix, UINT16 mac[3], CHAR *pBuffer);

//------------------------------------------------------------------------------
//
//  Function:  OALArgsQuery
//
//  This function is called from other OAL modules to return boot arguments.
//  Boot arguments are typically placed in fixed memory location and they are
//  filled by boot loader. In case that boot arguments can't be located
//  the function should return NULL. The OAL module then must use default
//  values.
//
VOID* OALArgsQuery(UINT32 type)
{
    VOID *pData = NULL;
    BSP_ARGS *pArgs = &g_BSP_ARGS;

    OALMSG(OAL_ARGS&&OAL_FUNC, (L"+OALArgsQuery(%d)\r\n", type));

    // Depending on required args
    switch (type) {

    case OAL_ARGS_QUERY_DEVID:
		if ( !pDriverGlobals->eth.PlatformAddr.wMAC[0] &&
			 !pDriverGlobals->eth.PlatformAddr.wMAC[1] &&
			 !pDriverGlobals->eth.PlatformAddr.wMAC[2] ){
				break;
		}
		memset(pArgs->deviceId, 0, sizeof(pArgs->deviceId));
        CreateName(BSP_DEVICE_PREFIX,
                   (USHORT *)pDriverGlobals->eth.PlatformAddr.wMAC,
                   pArgs->deviceId);
        pData = pArgs->deviceId;
        break;

    case OAL_ARGS_QUERY_KITL:
        memset(&pArgs->kitl, 0, sizeof(OAL_KITL_ARGS));

        pArgs->kitl.flags = (OAL_KITL_FLAGS_ENABLED);
		if(pDriverGlobals->eth.KitlTransport & KTS_PASSIVE_MODE)
			pArgs->kitl.flags |= OAL_KITL_FLAGS_PASSIVE;

        // Use built-in LAN91C111 controller for KITL.
        pArgs->kitl.devLoc.IfcType     = Internal;
        pArgs->kitl.devLoc.BusNumber   = 0;
        pArgs->kitl.devLoc.PhysicalLoc = (PVOID)(PF_ETHER_BASE);
        pArgs->kitl.devLoc.LogicalLoc  = (DWORD)pArgs->kitl.devLoc.PhysicalLoc;

        pArgs->kitl.ipAddress       = pDriverGlobals->eth.PlatformAddr.dwIP;
        pArgs->kitl.mac [0] = pDriverGlobals->eth.PlatformAddr.wMAC [0];
        pArgs->kitl.mac [1] = pDriverGlobals->eth.PlatformAddr.wMAC [1];
        pArgs->kitl.mac [2] = pDriverGlobals->eth.PlatformAddr.wMAC [2];
        pArgs->kitl.ipMask = pDriverGlobals->eth.SubnetMask;

        // Has the bootloader provided a non-zero IP address and subnet mask?
        // If not, use DHCP to obtain this information.
        //
        if ((pArgs->kitl.ipAddress == 0) || (pArgs->kitl.ipMask == 0))
        {
            pArgs->kitl.flags |= OAL_KITL_FLAGS_DHCP;
        }

#ifdef IMGSHAREETH
		pArgs->kitl.flags |= OAL_KITL_FLAGS_VMINI;
#endif

		//Use polling (no interrupt)
//		pArgs->kitl.flags |= OAL_KITL_FLAGS_POLL;

        pData = &pArgs->kitl;
        break;
	}

    OALMSG(OAL_ARGS&&OAL_FUNC, (L"-OALArgsQuery(pData = 0x%08x)\r\n", pData));
    return pData;
}

//------------------------------------------------------------------------------
//
//  Function:  CreateName
//
//  This function create device name from prefix and mac address (usually last
//  two bytes of MAC address used for download).
//
VOID CreateName(CHAR *pPrefix, UINT16 mac[3], CHAR *pBuffer)
{
    strcpy (pBuffer, pPrefix);
    _itoa(ntohs(mac[2]), pBuffer + strlen(pPrefix) , 10);

    OALMSG(OAL_ARGS&&OAL_FUNC, (L"-CreateName(pData = %s)\r\n", pBuffer));
}

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

⌨️ 快捷键说明

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