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

📄 args.c

📁 Windows CE 6.0 针对PXA270的开发板的BSP参考代码
💻 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.
//

#include <bsp.h>

// Pointing to the BSP shared Args area. Must be initialized by calling OALArgsInit().
BSP_ARGS *g_pBSPArgs;

// Filled in by EBOOT
UINT16 g_UniqueDeviceID[4];

//------------------------------------------------------------------------------
// Called with physical address in IPL
// Called with virtual address in EBOOT
//
VOID OALArgsInit(BSP_ARGS* pArgs)
{
    g_pBSPArgs = pArgs;

    // Check the BSP Args area
    //
    if (pArgs->header.signature  != OAL_ARGS_SIGNATURE ||
        pArgs->header.oalVersion != OAL_ARGS_VERSION   ||
        pArgs->header.bspVersion != BSP_ARGS_VERSION)
    {
      // Zero out the current contents of the structure
      memset(pArgs, 0, sizeof(BSP_ARGS));

      // Setup header
      pArgs->header.signature = OAL_ARGS_SIGNATURE;
      pArgs->header.oalVersion = OAL_ARGS_VERSION;
      pArgs->header.bspVersion = BSP_ARGS_VERSION;

      // Default serial debug port
      pArgs->dbgSerPhysAddr = BULVERDE_BASE_REG_PA_BTUART;
 
      // Use One-Time-Programmable NOR 64-bit part ID in UUID
      // OEMs: Don't forget to request a Manufacturer ID!
      // First 48-bits: Test ID for Reference Platforms
      pArgs->uuid[0] = (UCHAR)0x00;
      pArgs->uuid[1] = (UCHAR)0x30;
      pArgs->uuid[2] = (UCHAR)0xBD;
      pArgs->uuid[3] = (UCHAR)0x2D;
      pArgs->uuid[4] = (UCHAR)0x73;
      pArgs->uuid[5] = (UCHAR)0x32;
      // Next 16-bits: Version/variant
      pArgs->uuid[6] = (UCHAR)1;  //Version 1.8 format (48/16/64) from
      pArgs->uuid[7] = (UCHAR)8;  // Windows Mobile documentation
      // Last 64-bits: Unique ID
      pArgs->uuid[8] = (UCHAR) ((g_UniqueDeviceID[0] >> 0) & 0xFF);
      pArgs->uuid[9] = (UCHAR) ((g_UniqueDeviceID[0] >> 8) & 0xFF);
      pArgs->uuid[10] = (UCHAR) ((g_UniqueDeviceID[1] >> 0) & 0xFF);
      pArgs->uuid[11] = (UCHAR) ((g_UniqueDeviceID[1] >> 8) & 0xFF);
      pArgs->uuid[12] = (UCHAR) ((g_UniqueDeviceID[2] >> 0) & 0xFF);
      pArgs->uuid[13] = (UCHAR) ((g_UniqueDeviceID[2] >> 8) & 0xFF);
      pArgs->uuid[14] = (UCHAR) ((g_UniqueDeviceID[3] >> 0) & 0xFF);
      pArgs->uuid[15] = (UCHAR) ((g_UniqueDeviceID[3] >> 8) & 0xFF);
    }

    return;
}


//------------------------------------------------------------------------------
//
//  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_pBSPArgs;

    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_UUID:
        // BSP device specific UUID is read from NOR flash by EBOOT. It is then copied
        // into pArgs->uuid by OALArgsInit. Sanity check the unique part of the UUID
        // and if EBOOT returned all 0's, do not return UUID, as it is not guaranteed unique.
        if( pArgs->uuid[8] || pArgs->uuid[9] || pArgs->uuid[10] || pArgs->uuid[11] ||
             pArgs->uuid[12] || pArgs->uuid[13] || pArgs->uuid[14] || pArgs->uuid[15] )
        {
            pData = &pArgs->uuid;
        }
        else 
        {
            pData = NULL;
        }
        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 LAN91C111 as the default.
        //
        if (pArgs->kitl.devLoc.LogicalLoc == 0)
        {
            pArgs->kitl.devLoc.IfcType     = Internal;
            pArgs->kitl.devLoc.BusNumber   = 0;
            pArgs->kitl.devLoc.PhysicalLoc = (PVOID)(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET + 0x300);
            pArgs->kitl.devLoc.LogicalLoc  = (DWORD)pArgs->kitl.devLoc.PhysicalLoc;
        }

        pData = &pArgs->kitl;
        break;

    case BSP_ARGS_QUERY_DBGSERIAL:
        if ((pArgs->dbgSerPhysAddr != BULVERDE_BASE_REG_PA_BTUART) && (pArgs->dbgSerPhysAddr != BULVERDE_BASE_REG_PA_FFUART))
        {
            pArgs->dbgSerPhysAddr = BULVERDE_BASE_REG_PA_BTUART;
        }
        pData = &pArgs->dbgSerPhysAddr;
        break;

    case BSP_ARGS_QUERY_HIVECLEAN:
        pData = &pArgs->bHiveCleanFlag;
        break;

    case BSP_ARGS_QUERY_CLEANBOOT:
        pData = &pArgs->bCleanBootFlag;
        break;

    case BSP_ARGS_QUERY_FORMATPART:
        pData = &pArgs->bFormatPartFlag;
        break;

    case BSP_ARGS_QUERY_SIGNEDSTATE:
        pData = &pArgs->ImageSignedState;
        break;

    default:
        break;
    }

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

⌨️ 快捷键说明

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