📄 ioctl.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: ioctl.c
//
// This file implements the OEM's IO Control (IOCTL) functions and declares
// global variables used by the IOCTL component.
//
#include <windows.h>
#include <oal.h>
#include <bsp.h>
#include <Pkfuncs.h>
#include <Storemgr.h>
//------------------------------------------------------------------------------
//
// Global: g_oalIoctlPlatformType/OEM
//
// Platform Type/OEM
//
#ifdef SMARTFON
LPCWSTR g_oalIoCtlPlatformType = L"SmartPhone\0";
#elif defined WPC
LPCWSTR g_oalIoCtlPlatformType = L"PocketPC\0SSDK\0";
#else
LPCWSTR g_oalIoCtlPlatformType = L"SMDK2440 Board";
#endif
LPCWSTR g_oalIoCtlPlatformOEM = L"Samsung Electronics";
//------------------------------------------------------------------------------
//
// Global: g_oalIoctlProcessorVendor/Name/Core
//
// Processor information
//
LPCWSTR g_oalIoCtlProcessorVendor = L"Smasung Electronics";
LPCWSTR g_oalIoCtlProcessorName = L"S3C2440A";
LPCWSTR g_oalIoCtlProcessorCore = L"ARM920T";
const UINT8 g_oalIoCtlVendorId[6] = { 0x00, 0x50, 0xBF, 0x43, 0x39, 0xBF };
//------------------------------------------------------------------------------
//
// Global: g_oalIoctlInstructionSet
//
// Processor instruction set identifier
//
INT32 g_oalIoCtlInstructionSet = 0;
extern UINT32 g_oalIoCtlClockSpeed;
BOOL OALIoCtlHalGetHiveCleanFlag(UINT32 code, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf, UINT32 nOutBufSize, UINT32 *lpBytesReturned )
{
volatile S3C2440X_IOPORT_REG *pOalPortRegs;
BOOL HiveCleanFlag = TRUE;
pOalPortRegs = OALPAtoVA(S3C2440X_BASE_REG_PA_IOPORT, FALSE);
if(INREG32(&pOalPortRegs->GPFDAT) & (1<<2))
HiveCleanFlag = FALSE;
RETAILMSG(1, (TEXT("<<<< OALIoCtlHalGetHiveCleanFlag .>>>>\n")));
if (!lpInBuf || (nInBufSize != sizeof(DWORD)) || !lpOutBuf || (nOutBufSize != sizeof(BOOL)))
{
NKSetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
} else
{
DWORD *pdwFlags = (DWORD*)lpInBuf;
BOOL *pfClean = (BOOL*)lpOutBuf;
if (*pdwFlags == HIVECLEANFLAG_SYSTEM) {
if(HiveCleanFlag){
RETAILMSG(1, (TEXT("OEM: Cleaning system hive\r\n")));
*pfClean = TRUE;
}
else{
RETAILMSG(1, (TEXT("OEM: No Cleaning system hive\r\n")));
*pfClean = FALSE;
}
} else if (*pdwFlags == HIVECLEANFLAG_USERS) {
if(HiveCleanFlag){
RETAILMSG(1, (TEXT("OEM: Cleaning user profiles\r\n")));
*pfClean = TRUE;
}
else{
RETAILMSG(1, (TEXT("OEM: NO Cleaning user profiles\r\n")));
*pfClean = FALSE;
}
}
}
return TRUE;
}
BOOL OALIoCtlHalQueryFormatPartition(UINT32 code, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf, UINT32 nOutBufSize, UINT32 *lpBytesReturned )
{
S3C2440X_IOPORT_REG *pOalPortRegs;
BOOL g_fFormatRootFS = TRUE;
BOOL g_fFormatBootableFS = TRUE;
STORAGECONTEXT* pContext = (STORAGECONTEXT*)lpInBuf;
pOalPortRegs = OALPAtoVA(S3C2440X_BASE_REG_PA_IOPORT, FALSE);
if(INREG32(&pOalPortRegs->GPFDAT) & (1<<2))
{
g_fFormatRootFS = FALSE;
g_fFormatBootableFS = FALSE;
}
RETAILMSG(1, (TEXT("<<<< OALIoCtlHalQueryFormatPartition .>>>>\n")));
// validate parameters
if (sizeof(STORAGECONTEXT) != nInBufSize || !lpInBuf ||
sizeof(BOOL) != nOutBufSize || !lpOutBuf) {
NKSetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
// by default, do not format any partitions
*(BOOL*)lpOutBuf = FALSE;
//
// format the root file system? (MountAsRoot=dword:1)
//
if (g_fFormatRootFS && (AFS_FLAG_ROOTFS & pContext->dwFlags)) {
*(BOOL*)lpOutBuf = TRUE;
RETAILMSG(1, (TEXT("format the root file system\n")));
}
//
// format the bootable file system? (MountAsBootable=dword:1)
//
if (g_fFormatBootableFS && (AFS_FLAG_BOOTABLE & pContext->dwFlags)) {
*(BOOL*)lpOutBuf = TRUE;
RETAILMSG(1, (TEXT("format the bootable file system\n")));
}
return TRUE;
}
BOOL OALIoCtlHalQueryDisplaySettings (UINT32 dwIoControlCode, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf, UINT32 nOutBufSize, UINT32* lpBytesReturned)
{
DWORD dwErr = 0;
RETAILMSG(0, (TEXT("In OALIoCtlHalQueryDisplaySettings^^^^^\r\n")));
if (lpBytesReturned) {
*lpBytesReturned = 0;
}
if (!lpOutBuf) {
dwErr = ERROR_INVALID_PARAMETER;
} else if (sizeof(DWORD)*3 > nOutBufSize) {
dwErr = ERROR_INSUFFICIENT_BUFFER;
} else {
// Check the boot arg structure for the default display settings.
__try {
((PDWORD)lpOutBuf)[0] = (DWORD)240;
((PDWORD)lpOutBuf)[1] = (DWORD)320;
((PDWORD)lpOutBuf)[2] = (DWORD)16;
if (lpBytesReturned) {
*lpBytesReturned = sizeof (DWORD) * 3;
}
} __except (EXCEPTION_EXECUTE_HANDLER) {
dwErr = ERROR_INVALID_PARAMETER;
}
}
if (dwErr) {
NKSetLastError (dwErr);
}
return !dwErr;
}
BOOL OALIoCtlHalProfile(UINT32 dwIoControlCode, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf, UINT32 nOutBufSize, UINT32* lpBytesReturned)
{
RETAILMSG(0, (TEXT("<<<< OALIoCtlHalProfile .>>>>\n")));
return(TRUE);
}
//------------------------------------------------------------------------------
//
// Global: g_oalIoCtlTable[]
//
// IOCTL handler table. This table includes the IOCTL code/handler pairs
// defined in the IOCTL configuration file. This global array is exported
// via oal_ioctl.h and is used by the OAL IOCTL component.
//
const OAL_IOCTL_HANDLER g_oalIoCtlTable[] = {
#include "ioctl_tab.h"
};
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -