📄 args.c
字号:
//
// Copyright (c) Special Computing. All rights reserved.
// 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>
extern const UINT8 g_oalIoCtlVendorId[6];
//------------------------------------------------------------------------------
//
// Function: OEMArgsQuery
//
// 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;
static UCHAR deviceId[OAL_KITL_ID_SIZE] = "";
static UCHAR uuid[sizeof(UUID)] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
OALMSG(OAL_ARGS&&OAL_FUNC, (L"+OALArgsQuery(%d)\r\n", type));
// Get pointer to expected boot args location
pArgs = OALPAtoCA(IMAGE_SHARE_ARGS_PA);
// 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_UPDATEMODE:
pData = &pArgs->updateMode;
break;
case OAL_ARGS_QUERY_KITL:
pData = &pArgs->kitl;
break;
case BSP_ARGS_QUERY:
pData = pArgs;
break;
case OAL_ARGS_QUERY_DEVID:
if (deviceId[0] == '\0') {
DWORD count, code;
INT32 j;
UCHAR d;
OMAP3_DEVICE_DIEID_REGS *pDevIdRegs = OALPAtoUA(OMAP3_DEVICE_DIEID_REGS_PA);
// Copy prefix
count = sizeof(BSP_DEVICE_PREFIX) - 1;
if (count > sizeof(deviceId)/2) count = sizeof(deviceId)/2;
memcpy(deviceId, BSP_DEVICE_PREFIX, count);
// Create unique part of name from SoC ID
code = INREG32(&pDevIdRegs->DIE_ID_0);
code ^= INREG32(&pDevIdRegs->DIE_ID_1);
code ^= INREG32(&pDevIdRegs->DIE_ID_2);
code ^= INREG32(&pDevIdRegs->DIE_ID_3);
// Convert it to hexa number
for (j = 28; j >= 0 && count < OAL_KITL_ID_SIZE - 1; j -= 4) {
d = (UCHAR)((code >> j) & 0xF);
deviceId[count++] = d < 10 ? '0' + d : 'A' + d - 10;
}
// End string
while (count < sizeof(deviceId)) deviceId[count++] = '\0';
}
pData = deviceId;
break;
case OAL_ARGS_QUERY_UUID:
if ((uuid[0] | uuid[1] | uuid[2] | uuid[3] | uuid[4] | uuid[5] | uuid[6] | uuid[7]) == 0x00) {
UINT32 id0, id1;
OMAP3_DEVICE_DIEID_REGS *pDevIdRegs = OALPAtoUA(OMAP3_DEVICE_DIEID_REGS_PA);
// 48 bit HW MFG Product Line Number. We are going to use the MS
// assigned ID for TI for this.
uuid[0] = g_oalIoCtlVendorId[0];
uuid[1] = g_oalIoCtlVendorId[1];
uuid[2] = g_oalIoCtlVendorId[2];
uuid[3] = g_oalIoCtlVendorId[3];
uuid[4] = g_oalIoCtlVendorId[4];
uuid[5] = g_oalIoCtlVendorId[5];
//The 16 bit Version/Variant Code
uuid[6] = (UINT8)1; // Version 1.8 format (48/16/64) from
uuid[7] = (UINT8)8; // Windows Mobile documentation
// Get die IDs
id0 = INREG32(&pDevIdRegs->DIE_ID_0) ^ INREG32(&pDevIdRegs->DIE_ID_1);
id1 = INREG32(&pDevIdRegs->DIE_ID_2) ^ INREG32(&pDevIdRegs->DIE_ID_3);
// Store unique device ID.
uuid[8] = (UINT8)( id0 >> 0 );
uuid[9] = (UINT8)( id0 >> 8 );
uuid[10] = (UINT8)( id0 >> 16 );
uuid[11] = (UINT8)( id0 >> 24 );
uuid[12] = (UINT8)( id1 >> 0 );
uuid[13] = (UINT8)( id1 >> 8 );
uuid[14] = (UINT8)( id1 >> 16 );
uuid[15] = (UINT8)( id1 >> 24 );
}
pData = uuid;
break;
}
cleanUp:
OALMSG(OAL_ARGS&&OAL_FUNC, (L"-OALArgsQuery(pData = 0x%08x)\r\n", pData));
return pData;
}
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -