📄 uuid.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: uuid.c
//
// This file This file implements the IOCTL_HAL_GET_UUID handler.
//
#include <windows.h>
#include <oal.h>
#include <omap730.h>
//------------------------------------------------------------------------------
//
// External: g_oalIoCtlVendorId
//
// This is vendor/manufacturer code used to generate device UUID. It should
// be defined in platform code.
//
extern const UINT8 g_oalIoCtlVendorId[6];
//------------------------------------------------------------------------------
//
// Function: OALIoCtlHalGetUUID
//
// Implements the IOCTL_HAL_GET_UUID handler.
//
BOOL OALIoCtlHalGetUUID(
UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer,
UINT32 outSize, UINT32 *pOutSize
) {
BOOL rc = FALSE;
OMAP730_CONFIG_REGS *pConfigRegs = OALPAtoUA(OMAP730_CONFIG_REGS_PA);
UINT32 id0, id1;
#if defined ( project_smartfon ) || defined ( project_wpc ) // Smartphone or PocketPC build
UCHAR uuid[sizeof(UUID)];
// Check parameters
if (pOutSize != NULL)
{
*pOutSize = sizeof(uuid);
}
if (pOutBuffer == NULL || outSize < sizeof(uuid)) {
NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
OALMSG(OAL_WARN, (L"WARN: OALIoCtlHalGetUUID: Buffer too small\r\n"));
goto cleanUp;
}
// Get die IDs
id0 = INREG32(&pConfigRegs->MPU_DIE_ID0);
id1 = INREG32(&pConfigRegs->MPU_DIE_ID1);
// Store unique device ID.
uuid[0] = (UINT8)( id0 >> 0 );
uuid[1] = (UINT8)( id0 >> 8 );
uuid[2] = (UINT8)( id0 >> 16 );
uuid[3] = (UINT8)( id0 >> 24 );
uuid[4] = (UINT8)( id1 >> 0 );
uuid[5] = (UINT8)( id1 >> 8 );
uuid[6] = (UINT8)( id1 >> 16 );
uuid[7] = (UINT8)( id1 >> 24 );
uuid[8] = uuid[7];
// Lower 4 bits of byte 7 of the Device ID in upper nibble,
// and 4 bit version in lower nibble.
uuid[7] <<= 4;
uuid[7] |= 1;
// Upper 4 bits of byte 7 of the Device ID in upper nibble,
// and 4 bit variant in lower nibble.
uuid[8] &= 0xf0;
uuid[8] |= 8;
// Not used, set to 0.
uuid[9] = 0;
// 48 bit HW MFG Product Line Number. We are going to use the MS
// assigned ID for TI for this.
uuid[10] = g_oalIoCtlVendorId[0];
uuid[11] = g_oalIoCtlVendorId[1];
uuid[12] = g_oalIoCtlVendorId[2];
uuid[13] = g_oalIoCtlVendorId[3];
uuid[14] = g_oalIoCtlVendorId[4];
uuid[15] = g_oalIoCtlVendorId[5];
// Copy UUID to output buffer
memcpy(pOutBuffer, &uuid[0], sizeof(uuid));
#else // Not Smartphone or PocketPC build
GUID GuidPattern = { 0xd2a826f9, 0x86be, 0x483a, {
0xba, 0x94, 0xde, 0x55, 0x4c, 0x55, 0xc, 0xe7
}};
VOID* pGuidPattern = &GuidPattern;
// Check parameters
if (pOutSize != NULL)
{
*pOutSize = sizeof(GuidPattern);
}
if (pOutBuffer == NULL || outSize < sizeof(GuidPattern)) {
NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
OALMSG(OAL_WARN, (L"WARN: OALIoCtlHalGetUUID: Buffer too small\r\n"));
goto cleanUp;
}
// Get die IDs
id0 = INREG32(&pConfigRegs->MPU_DIE_ID0);
id1 = INREG32(&pConfigRegs->MPU_DIE_ID1);
// Modify GUID with die IDs
((UINT32*)pGuidPattern)[0] ^= id0;
((UINT32*)pGuidPattern)[1] ^= id1;
// Copy GUID pattern to output buffer
memcpy(pOutBuffer, &GuidPattern, sizeof(GUID));
#endif // SP/PPC build check
// Done
rc = TRUE;
cleanUp:
return rc;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -