这种方法是用三星提供的2450上面的一个简单的流驱动与GOOGLEMAN的方法是有点出入,不过他的方法经测试也是能够实现!
具体链接如下:
http://blog.csdn.net/gooogleman/archive/2008/08/04/2765650.aspx
这个链接我看到学到了一种测试方法!因为学习三星的内容并没有提供详细的方法写应用程序去测试流驱动。
先将方法整个流驱动和测试代码方法写出来:
一、流驱动部分
1.新建一个目录 %/WINCE500/PLATFORM/SMDK2450/Src/Drivers/driver_test(该目录是BSP 包驱动程序的存放位置)
2.修改:/WINCE500/PLATFORM/SMDK2450/Src/Drivers/dir 文件
DIRS=ceddk /
Display_2450 /
Display_2443 /
touch /
wavedev /
cs8900eboot /
iic /
camera /
PowerButton /
Usb /
Keybd /
Serial /
HSMMC /
CF_ATAPI /
SDBUS /
SDMEMORY /
SDHC /
POST /
hspi /
NLED /
driver_test/
3.用文本编辑器建立 4 个文本文件,文件名分别为 driver_test.cpp,driver_test.h,
driver_test.def和 source,makefile 目录下的文件如图 所示
4.编写def 文件
library driver_test
EXPORTS
STR_Init
STR_Open
STR_Close
STR_Deinit
STR_Powerup
STR_Powerdown
STR_IOControl
STR_Read
STR_Write
5.编写source 文件
SYNCHRONIZE_DRAIN=1
RELEASETYPE=PLATFORM
TARGETNAME=driver_test
DEFFILE=driver_test.def
TARGETTYPE=DYNLINK
DLLENTRY=_DllMainCRTStartup
TARGETLIBS= /
$(_COMMONSDKROOT)/lib/$(_CPUINDPATH)/coredll.lib /
SOURCELIBS=
INCLUDES=$(INCLUDES);$(_TARGETPLATROOT)/src/inc;
SOURCES= /
driver_test.cpp /
6.修改注册表
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/STR]
"Prefix"="STR"
"Dll"="driver_test.dll"
"Index"=dword:0;端口为0,写测试程序的时候记得哦,本人因为没注意到所以郁闷了一天下午
"Order"=dword:0
7.修改映象文件
driver_test.dll $(_FLATRELEASEDIR)/driver_test.dll NK SH
8、增加makefile文件内容
!if 0
Copyright (c) Microsoft Corporation. All rights reserved.
!endif
!if 0
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.
!endif
#
# DO NOT EDIT THIS FILE!!! Edit ./sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components
#
!INCLUDE $(_MAKEENVROOT)/makefile.def
9、driver_test.cpp代码
#include <windows.h>
#include <pm.h>
#include <bsp.h>
#include "driver_test.h"
#include <oal.h>
#include <s3c2450.h>
#include <s3c2450_intr.h>
#include <intr.h>
#include <bsp_cfg.h>
#include <ceddk.h>
#include <nkintr.h>
#define sizebf 256
int Tmp,Count;
TCHAR buffer[sizebf];
DWORD STR_Init(DWORD dwContext)
{
UINT32 sysIntr, irq;
ULONG value;
DWORD dwErr;
Tmp=0;
Count=0;
RETAILMSG(1,(TEXT("---――--driver test : STR_Init---------
/r/n")));
return 1;
}
DWORD STR_Deinit(DWORD dwContext)
{
RETAILMSG(1,(TEXT("-------driver test : STR_Deinit----------
/r/n")));
return 1;
}
DWORD STR_Open(DWORD dwData, DWORD dwAccess, DWORD dwShareMode)
{
RETAILMSG(1,(TEXT("---------driver test : STR_Open-----------
/r/n")));
Tmp++;
return Tmp;
}
DWORD STR_Close(DWORD dwContext)
{
RETAILMSG(1,(TEXT("---------driver test : STR_close-----------
/r/n")));
if(Count!=0)
Count--;
return 1;
}
DWORD STR_Read(DWORD hOpencontext,LPVOID pBuffer,DWORD Count)
{
RETAILMSG(1,(TEXT("---------driver test : STR_Read-----------
/r/n")));
uchar *pReadBuffer;
if((pBuffer==NULL)||(Count<=0))
{
RETAILMSG(1,(TEXT("-----driver test : STR_Read error-
----- /r/n")));
return 0;
}
pReadBuffer=(uchar *)MapPtrToProcess(pBuffer,GetCallerProcess
());
*pReadBuffer=Tmp;
wcsncpy((LPWSTR)pBuffer,buffer,Count);
RETAILMSG(1,(TEXT("Lanshuguang---STR_Read:---%s---
/r/n"),pBuffer));
return 1;
}
DWORD STR_Write(DWORD hOpencontext,LPVOID pBuffer,DWORD Count){
uchar *pWriteBuffer;
wcsncpy(buffer,(LPWSTR)pBuffer,Count);
if((pBuffer==NULL)||(Count<=0)){
RETAILMSG(1,(TEXT("----driver test : STR_Write error-
----- /r/n")));
return 0;
}
RETAILMSG(1,(TEXT("Lanshuguang---SSTR_Write:---%s---
/r/n"),pBuffer));
pWriteBuffer=(uchar *)MapPtrToProcess
(pBuffer,GetCallerProcess());
Tmp=*pWriteBuffer;
RETAILMSG(1,(TEXT("---driver test : STR_Writeaaa---%x-----
/r/n"),Tmp));
return 1;
}
BOOL
WINAPI
DllMain(
HANDLE hinstDll,
DWORD dwReason,
LPVOID lpReserved
)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
RETAILMSG(1,(TEXT("LanShuGuang-----driver test :
STR_attach----- /r/n /r/n /r/n")));
break;
case DLL_PROCESS_DETACH:
RETAILMSG(1,(TEXT("LanShuGuang-----driver test :
STR_detach------ /r/n")));
break;
}
return TRUE;
}
10、将driver_test文件夹编译,后sysgen,至此一个名为STR的流驱动就写好了
二、测试部分
请参考GOOGLEMAN的测试代码就行了
在dnw可以看到打印信息
---------driver test : STR_Open-----------
Lanshuguang---SSTR_Write:---This is a TEST of TTT Driver---
---driver test : STR_Writeaaa---54-----
---------driver test : STR_Read-----------
Lanshuguang---STR_Read:---This is a TEST of TTT Driver---
---------driver test : STR_close-----------