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

📄 args.c

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
//
// 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.
//
//------------------------------------------------------------------------------
//
//  Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
#include <bsp.h>

#ifdef PLAT_PMC
static WCHAR szDeviceMakeStr[] = DEVICE_MAKE_STR;
static WCHAR szDeviceModelStr[] = DEVICE_MODEL_STR;
static char  szDevicePrefix[] = BSP_DEVICE_PREFIX;
static UINT8 uuid[32]; // Should be plenty long
static PMC_UUID pmcUuid = { 0, uuid };
static BOOL fUuidInit = FALSE;

//
// OEMs are expected to create a unique value, at least 128-bits long, for each of their
// devices.  This value is returned to the DRM code and to MTP via the
// IOCTL_HAL_GET_DEVICEID kernel IOCTL call.
//
// In the implementation given below, some number of bits of ID bits are combined with
// guidMfg.  The ID bits are guaranteed by the Flash manufacturer
// to be unique.

// To ensure that the complete UUID is unique, OEMs must:
//  - initially choose a "unique" value for guidMfg.
//  - change guidMfg if they switch Flash manufacturers.
//
// To create a unique random number, simply:
//  - run the standard GUIDGEN tool (see MSDN)
//  - go to view 3 (static const struct view)
//  - copy/paste the GUID into guidMfg.
//
// {E207CA67-A630-4e6e-81B2-73DCD77DB64C}
static const GUID guidMfg = 
{ 0xe207ca67, 0xa630, 0x4e6e, { 0x81, 0xb2, 0x73, 0xdc, 0xd7, 0x7d, 0xb6, 0x4c } };

//------------------------------------------------------------------------------
//
//  Function:  InitializeUuid
//
//  This function gets a device-specific UUID. It currently follows a strange
//  approach defined in PMC V1.
//

static BOOL InitializeUuid(void)
{
#if 0 // TODO: We need to get this working!
    BYTE bPresetData[16];       // read from protection register in flash
    DWORD dwSize = sizeof(bPresetData);
    DWORD dwStatus;

    // Have we succeeded before?
    if (TRUE == fUuidInit)
    {
        return TRUE;
    }

    // read preset data
    FlashLock();
    dwStatus = FlashGetPresetData(bPresetData, &dwSize);
    FlashUnlock();

    // did we succeed?
    if(dwStatus != ERROR_SUCCESS)
    {
        return FALSE;
    }

    // Make sure we have room for the whole thing
    if (sizeof(guidMfg) + dwSize > sizeof(uuid))
    {
        return FALSE;
    }

    // copy the manufacturer GUID
    memcpy(uuid, &guidMfg, sizeof(guidMfg));

    // Copy the device-specific ID
    memcpy(&uuid[sizeof(guidMfg)], bPresetData, dwSize);

    pmcUuid.dwUuidLen = sizeof(guidMfg) + dwSize;
#endif

    fUuidInit = TRUE;
    return TRUE;
}

#else

//------------------------------------------------------------------------------
// Local Variables

// TODO:
// UUID could be based on IIM fuse values or memory chip ID.  For now we
// keep it simple and use the MAC.
static UUID gUUID = { ((BSP_ARGS_DEFAULT_MAC_BYTE3 << 24) |  // Data1
                       (BSP_ARGS_DEFAULT_MAC_BYTE2 << 16) |
                       (BSP_ARGS_DEFAULT_MAC_BYTE1 << 8) |
                       (BSP_ARGS_DEFAULT_MAC_BYTE0)),
                      ((BSP_ARGS_DEFAULT_MAC_BYTE5 << 8) |  // Data2
                       (BSP_ARGS_DEFAULT_MAC_BYTE4)),
                       0,                                   // Data 3
                       0, 0, 0, 0                           // Data 4
                    };

#endif // PLAT_PMC

//------------------------------------------------------------------------------
//
//  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 = (BSP_ARGS *)OALPAtoVA(IMAGE_SHARE_ARGS_RAM_START,FALSE);
    
    OALMSG(OAL_ARGS&&OAL_FUNC, (L"+OALArgsQuery(%d)\r\n", type));
    
    // Check if there is expected signature
    if (
        pArgs->header.signature  != OAL_ARGS_SIGNATURE ||
        pArgs->header.oalVersion != OAL_ARGS_VERSION   ||
        pArgs->header.bspVersion != BSP_ARGS_VERSION
        ) goto cleanUp;
    
    // Depending on required args
    switch (type) {
        
    case OAL_ARGS_QUERY_DEVID:
        pData = &pArgs->deviceId;
        break;
        
    case OAL_ARGS_QUERY_KITL:
        pArgs->kitl.flags |= (OAL_KITL_FLAGS_ENABLED | OAL_KITL_FLAGS_VMINI);
        
        // 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;
        }
        
        // Has the bootloader provided information about which NIC it was using?
        // If not, choose the CS8900A as the default.
        //
        if (pArgs->kitl.devLoc.LogicalLoc == 0)
        {
            pArgs->kitl.devLoc.IfcType     = Internal;
            pArgs->kitl.devLoc.BusNumber   = 0;
            pArgs->kitl.devLoc.PhysicalLoc = (PVOID)(BSP_BASE_REG_PA_CS8900A_IOBASE);
            pArgs->kitl.devLoc.LogicalLoc  = (DWORD)pArgs->kitl.devLoc.PhysicalLoc;
        }
        
        pData = &pArgs->kitl;
        break;
        
#ifdef PLAT_PMC
    case BSP_ARGS_QUERY_DEVPREFIX:
        pData = szDevicePrefix;
        break;
        
    case PMC_ARGS_QUERY_DEVMAKESTR:
        pData = szDeviceMakeStr;
        break;
        
    case PMC_ARGS_QUERY_DEVMODELSTR:
        pData = szDeviceModelStr;
        break;
        
    case PMC_ARGS_QUERY_PMCARGS:
        pData = &pArgs->pmc_args;
        break;
#endif

#ifdef PLAT_PMC
    case PMC_ARGS_QUERY_UUID:
        if (FALSE == InitializeUuid())
        {
            break;
        }
        pData = &pmcUuid;
        break;
#else
    // Check if this is a UUID request
    case OAL_ARGS_QUERY_UUID:
        // Return pointer to global UUID
        pData = &gUUID;
        break;
#endif

#if (defined(BSP_POCKETPC) || defined(BSP_SMARTPHONE) || defined(BSP_ULDR))
    case OAL_ARGS_QUERY_UPDATEMODE:
        pData = &pArgs->updateMode;
        break;
#endif
    }
    
cleanUp:
    OALMSG(OAL_ARGS&&OAL_FUNC, (L"-OALArgsQuery(pData = 0x%08x)\r\n", pData));
    return pData;
}


//------------------------------------------------------------------------------
//
//  Function:   OALBspArgsInit
//
//  This function reads the user switch setting on the ADS board and configures
//  parameters of the global BSP args structure.

⌨️ 快捷键说明

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