1.在project下建立自己的driver folder,ex: ARIEL
並修改dirs檔案,加入自己driver的名字
!if 0
Copyright (c) Microsoft Corporation. All rights reserved.
!endif
!...
DIRS=\
drvlib \
KEYBD \
up \
wolfson \
# @CESYSGEN IF CE_MODULES_BATTDRVR
battdrvr \
# @CESYSGEN ENDIF CE_MODULES_BATTDRVR
# @CESYSGEN IF CE_MODULES_WAVEAPI
wavedev \
# @CESYSGEN ENDIF CE_MODULES_WAVEAPI
# @CESYSGEN IF CE_MODULES_POINTER
...
# @CESYSGEN ENDIF CE_MODULES_NLEDDRVR
# @CESYSGEN ENDIF CE_MODULES_DEVICE
nvscdrv \
Display \
sdmmc \
Backlight \
otgdrv \
gsmdrvr \
sc16c652 \
tffs632 \
SerialCSR \
BARCODE \
ARIEL \
接著在driver folder內需建立.c、.def、source和makefile ,ex:ariel.c、ariel.def
(.def、source需修改,可以複製其他driver的來做,makefile亦可複製其他driver來用)
2.修改source檔
!if 0
File: sources
Copyright (c) 2003 BSQUARE Corporation. All rights reserved.
!endif
RELEASETYPE=PLATFORM
TARGETNAME=ARIEL
TARGETTYPE=DYNLINK
DLLENTRY=DllEntry
TARGETLIBS= \
$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib \
$(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\ceddk.lib \
DEFFILE= ariel.def
SOURCES= ariel.c
3.修改.def檔
;
; 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.
;
LIBRARY ARIEL
EXPORTS //基本export的function
ARI_Init
ARI_Deinit
ARI_Open
ARI_Close
ARI_Read
ARI_Write
ARI_Seek
ARI_IOControl
ARI_PowerUp
ARI_PowerDown
//ariel.c
#include
#include
#include "ariel.h"
//-------------------------------------------------------------------------
//
//DLL initialization entry point
//
BOOL
DllEntry(
HINSTANCE hinstDll, /*@parm Instance pointer. */
DWORD dwReason, /*@parm Reason routine is called. */
LPVOID lpReserved /*@parm system parameter. */
)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DEBUGREGISTER(hinstDll);
}
if (dwReason == DLL_PROCESS_DETACH)
{
}
//RETAILMSG( 1, (TEXT("DllEntry:Ariel:enter\r\n")));
return TRUE;
}
//===========================================================================
//---------------------------------------------------------------------------
//
//Driver initialization function
//
PHW_INDEP_INFO
ARI_Init(
PVOID pContext
)
{
PHW_INDEP_INFO pARIInfo;
RETAILMSG( 1, (TEXT("******ARI_Init:Ariel:enter******\r\n")));
//Allocate a drive instance structure
pARIInfo = (PHW_INDEP_INFO)LocalAlloc( LPTR, sizeof(HW_INDEP_INFO) );
if (!pARIInfo)
{
return NULL;
}
return (pARIInfo);
}
//=============================================================================
//-----------------------------------------------------------------------------
//
//Driver de-initialization function
//
BOOL ARI_Deinit(
DWORD hDeviceContext
)
{
RETAILMSG( 1, (TEXT("ARI_Deinit:Ariel:enter\r\n")));
return TRUE;
}
//=============================================================================
//-----------------------------------------------------------------------------
//
//Called when driver opened
//
DWORD ARI_Open(
DWORD hDeviceContext,
DWORD AccessCode,
DWORD ShareMode
)
{
RETAILMSG( 1, (TEXT("ARI_Open:Ariel:enter\r\n")));
return TRUE;
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when driver closed
//
BOOL ARI_Close(
DWORD hOpenContext
)
{
RETAILMSG( 1, (TEXT("ARI_Close:Ariel:enter\r\n")));
return TRUE;
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when driver read
//
DWORD ARI_Read(
DWORD hOpenContext,
LPVOID pBuffer,
DWORD Count
)
{
RETAILMSG( 1, (TEXT("ARI_Read:Ariel:enter\r\n")));
return Count;
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when driver written
//
DWORD ARI_Write(
DWORD hOpenContext,
LPVOID pBuffer,
DWORD Count
)
{
RETAILMSG( 1, (TEXT("ARI_Write:Ariel:enter\r\n")));
return Count;
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when SeetFilePtr called
//
DWORD ARI_Seek(
DWORD hOpenContext,
long Amount,
WORD Type
)
{
RETAILMSG( 1, (TEXT("ARI_Seek:Ariel:enter\r\n")));
return 0;
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when DeviceIOControl called
//
BOOL ARI_IOControl(
PHW_INDEP_INFO pOTGInfo,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut
)
{
RETAILMSG( 1, (TEXT("ARI_IOControl:Ariel:enter dwCode=%d dwLenIn=%d dwLenOut=%d\r\n"),dwCode,dwLenIn,dwLenOut));
{
int i=0;
RETAILMSG( 1, (TEXT("pBufIn= \r\n")));
for(i=0;i
DWORD hDeviceContext
)
{
RETAILMSG( 1, (TEXT("ARI_PowerDown:Ariel:enter\r\n")));
}
//==============================================================================
//------------------------------------------------------------------------------
//
//Called when resumes
//
void ARI_PowerUp(
DWORD hDeviceContext
)
{
RETAILMSG( 1, (TEXT("ARI_PowerUp:Ariel:enter\r\n")));
}
//==============================================================================
4.修改platform.bib檔
加入
ariel.dll $(_FLATRELEASEDIR)\ariel.dll NK SH
5.修改platform.reg
加入
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\ARI]
"Prefix"="ARI"
"Dll"="ariel.dll"
"Order"=dword:0
"Index"=dword:0
ps.因為只有在 platform\...\files 下有修改,如果platform builder沒有build過的話,就需手動複製貼在 PBWorkspaces\...\RelDir\...Release中的platform.reg內