从网上看到些介绍,贴在下面,最近没有太多时间来看相关的内容。
驱动开发入门之中断处理
驱动程序开发过程中对中断的处理是很重要的一部分,直接关系程序的运行结果与效率,所以需要对其给予足够的重视.
中断处理包含两个方面,与CE系统相关的部分及与硬件相关的部分.
CE系统特定的处理流程(与其它系统有所区别的,或者说这部分代码在其它系统上是无法运行的)一般为:
1.用CreateEvent创建一个自动事件(即不需要使用ResetEvent去重置事件.
2.用InterruptInitialize将些事件与硬件所需要的中断关联起来.
3.创建一个线程,在此线程中用WaitForSingleObject等待事件,当等到这个事件之后,开始相应的处理,完成之后调用InterruptDone去重新激活中断.
硬件相关部分,
一般的,OAL层的中断处理程序(OEMInterruptHandler),在监测到某个中断后,会将CPU相应的中断标志位清除,同时禁用该中断,以保证系统调度不会被该中断再次打断,而后返回一个中断号给系统,从而使系统开始调度其IST,驱动程序的IST被激活,完成相应的处理之后应该清除硬件级的中断标志,从而使硬件知道中断服务已经完成,而不再产生该中断。当然有些硬件,例如ATA/ATAPI不需要这个动作,这些设备在最后一个字节被读出/写入之后会将其DRQ标志清除,自然,只要还有一个字节没有被读出/写入,DRQ就一直存在。
注意:
5。0以后引入PQOAL的概念,在PQOAL格式的BSP中,有一个SYSINTR与IRQ的概念,SYSINTR是系统使用的中断,IRQ为硬件中断,即CPU使用的中断线,一般的BSP中,将其CPU的中断标志寄存器的各位一一对应,即,IRQ0对应于该寄存器的第0位,IRQ2为第2位。所以,做为驱动程序,必须知道它所驱动的硬件所使用的IRQ,即硬件中断线。然后调用KernelIoControl的IOCTL_HAL_REQUEST_SYSINTR功能得到一个SYSINTR,然后再进入上面描述的流程。这样,驱动程序 以后就只使用申请到的SYSINTR,而不关心其IRQ了。 OAL层会将IRQ与SYSINTR做相互转换。
Search This Blog
Jul 13, 2008
Jun 23, 2008
WINCE build option.
1.Sysgen to build image when you change the catalog.
2.Build and Sysgen. Build OS kernel and Sysgen, it tooks too much time
3.Build and Sysgen CurrentBSP. Build if you only change platform BSP code, the speed is fast.
When I change config.bib for memory map, with Build and Sysgen CurrentBSP, it does not generate correct image. I found config.bib in release directory is old on. I run "Copy file to release directory" and then run "Build and Sysgen CurrentBSP" and get correcty image.
If you only change one device driver, you can select the "Build project" and then run "Make runtime image", then you can fastest get image.
2.Build and Sysgen. Build OS kernel and Sysgen, it tooks too much time
3.Build and Sysgen CurrentBSP. Build if you only change platform BSP code, the speed is fast.
When I change config.bib for memory map, with Build and Sysgen CurrentBSP, it does not generate correct image. I found config.bib in release directory is old on. I run "Copy file to release directory" and then run "Build and Sysgen CurrentBSP" and get correcty image.
If you only change one device driver, you can select the "Build project" and then run "Make runtime image", then you can fastest get image.
Jun 16, 2008
PWM setting
SDK setting is too complex, re-organize it.
void backlight_test()
{
unsigned int i,temp;
(*(volatile unsigned int *) HW_PINCTRL_MUXSEL4_CLR_ADDR) = (3<<4); // GPIO config as PWM2
(*(volatile unsigned int *) HW_PWM_ACTIVE2_CLR_ADDR) = 0; // clear count of inactive and active
(*(volatile unsigned int *) HW_PWM_ACTIVE2_SET_ADDR) = 0x00210000; // set active and inactive count
(*(volatile unsigned int *) HW_PWM_PERIOD2_CLR_ADDR) = 0; // clear
(*(volatile unsigned int *) HW_PWM_PERIOD2_SET_ADDR) = 0x000B002F; // set MATT,CDIV,INACTIVE,ACTIVE,PERIOD
(*(volatile unsigned int *) HW_CLKCTRL_XTAL_CLR_ADDR) = 0x20000000; // Clear the gate
(*(volatile unsigned int *) HW_PWM_CTRL_CLR_ADDR) = 0x40000000; // Clear the clock gate
(*(volatile unsigned int *) HW_PWM_CTRL_SET_ADDR) = (1<<5); // PWM2_ANA_CTRL_ENABLE
(*(volatile unsigned int *) HW_LRADC_CTRL0_CLR_ADDR)= 0xC0000000; // LRADC RST and gate clear
(*(volatile unsigned int *) HW_LRADC_CTRL2_CLR_ADDR)= 0x00200000; // LRADC1 feedback control
temp = (*(volatile unsigned int *) HW_LRADC_CTRL2_ADDR) & 0x001F0000;
for(i=0;i<=100;i+=10)
{
(*(volatile unsigned int *) HW_LRADC_CTRL2_ADDR) = temp | ((0x1C*i/100) << 16);
(*(volatile unsigned int *) HW_PWM_CTRL_SET_ADDR) = 0x4; // Pwm2 enable
(*(volatile unsigned int *) HW_LRADC_CTRL2_SET_ADDR) = 0x00400000; // BL enable
}
}
void backlight_test()
{
unsigned int i,temp;
(*(volatile unsigned int *) HW_PINCTRL_MUXSEL4_CLR_ADDR) = (3<<4); // GPIO config as PWM2
(*(volatile unsigned int *) HW_PWM_ACTIVE2_CLR_ADDR) = 0; // clear count of inactive and active
(*(volatile unsigned int *) HW_PWM_ACTIVE2_SET_ADDR) = 0x00210000; // set active and inactive count
(*(volatile unsigned int *) HW_PWM_PERIOD2_CLR_ADDR) = 0; // clear
(*(volatile unsigned int *) HW_PWM_PERIOD2_SET_ADDR) = 0x000B002F; // set MATT,CDIV,INACTIVE,ACTIVE,PERIOD
(*(volatile unsigned int *) HW_CLKCTRL_XTAL_CLR_ADDR) = 0x20000000; // Clear the gate
(*(volatile unsigned int *) HW_PWM_CTRL_CLR_ADDR) = 0x40000000; // Clear the clock gate
(*(volatile unsigned int *) HW_PWM_CTRL_SET_ADDR) = (1<<5); // PWM2_ANA_CTRL_ENABLE
(*(volatile unsigned int *) HW_LRADC_CTRL0_CLR_ADDR)= 0xC0000000; // LRADC RST and gate clear
(*(volatile unsigned int *) HW_LRADC_CTRL2_CLR_ADDR)= 0x00200000; // LRADC1 feedback control
temp = (*(volatile unsigned int *) HW_LRADC_CTRL2_ADDR) & 0x001F0000;
for(i=0;i<=100;i+=10)
{
(*(volatile unsigned int *) HW_LRADC_CTRL2_ADDR) = temp | ((0x1C*i/100) << 16);
(*(volatile unsigned int *) HW_PWM_CTRL_SET_ADDR) = 0x4; // Pwm2 enable
(*(volatile unsigned int *) HW_LRADC_CTRL2_SET_ADDR) = 0x00400000; // BL enable
}
}
May 27, 2008
Dirver developing in wince
We can compile the driver project and then make run time image, it is fastest way when you developing your device driver. It takes few minutes.
May 20, 2008
HIVE
wanna to store touch panel cordinate data into REG, modify the FlashDSK.reg
; HIVE BOOT SECTION
[HKEY_LOCAL_MACHINE\init\BootVars]
"SYSTEMHIVE"="system.hv"
"PROFILEDIR"="Documents and Settings"
"Start DevMgr"=dword:1
"RegistryFlags"=dword:1
[HKEY_LOCAL_MACHINE\init\BootVars]
"DefaultUser"="default"
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\MSFlash]
"Profile"="MSFlash"
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"Order"=dword:0
"FriendlyName"="MSFLASH Driver"
"Dll"="smflash.dll"
"Prefix"="DSK"
[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\MSFlash]
"DriverPath"="Drivers\\BuiltIn\\MSFlash"
; LoadFlags 0x01 == load synchronously
"LoadFlags"=dword:1
"Order"=dword:0
"BootPhase"=dword:0
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\FlashDrv]
"Prefix"="DSK"
"Dll"="FLASH_STMP37XX.dll"
"Order"=dword:1
"Index"=dword:2
"Ioctl"=dword:4
"Profile"="FLASHDISK"
"FriendlyName"="MSFLASH Driver"
"MountFlags"=dword:0
"BootPhase"=dword:0
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"Flags"=dword:1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FLASHDISK]
"PartitionDriver"="mspart.dll"
"AutoMount"=dword:1
"AutoPart"=dword:1
"AutoFormat"=dword:1
"MountFlags"=dword:1
"Folder"="ResidentFlash"
"Name"="Microsoft Flash Disk"
"BootPhase"=dword:0
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FLASHDISK\FATFS]
;"MountFlags"=dword:0
"MountFlags"=dword:2 ; support hive-based registry
"AutoMount"=dword:1
"AutoPart"=dword:1
; @CESYSGEN ENDIF CE_MODULES_SDNPCID
; END HIVE BOOT SECTION
; HIVE BOOT SECTION
[HKEY_LOCAL_MACHINE\init\BootVars]
"SYSTEMHIVE"="system.hv"
"PROFILEDIR"="Documents and Settings"
"Start DevMgr"=dword:1
"RegistryFlags"=dword:1
[HKEY_LOCAL_MACHINE\init\BootVars]
"DefaultUser"="default"
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\MSFlash]
"Profile"="MSFlash"
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"Order"=dword:0
"FriendlyName"="MSFLASH Driver"
"Dll"="smflash.dll"
"Prefix"="DSK"
[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\MSFlash]
"DriverPath"="Drivers\\BuiltIn\\MSFlash"
; LoadFlags 0x01 == load synchronously
"LoadFlags"=dword:1
"Order"=dword:0
"BootPhase"=dword:0
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\FlashDrv]
"Prefix"="DSK"
"Dll"="FLASH_STMP37XX.dll"
"Order"=dword:1
"Index"=dword:2
"Ioctl"=dword:4
"Profile"="FLASHDISK"
"FriendlyName"="MSFLASH Driver"
"MountFlags"=dword:0
"BootPhase"=dword:0
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"Flags"=dword:1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FLASHDISK]
"PartitionDriver"="mspart.dll"
"AutoMount"=dword:1
"AutoPart"=dword:1
"AutoFormat"=dword:1
"MountFlags"=dword:1
"Folder"="ResidentFlash"
"Name"="Microsoft Flash Disk"
"BootPhase"=dword:0
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FLASHDISK\FATFS]
;"MountFlags"=dword:0
"MountFlags"=dword:2 ; support hive-based registry
"AutoMount"=dword:1
"AutoPart"=dword:1
; @CESYSGEN ENDIF CE_MODULES_SDNPCID
; END HIVE BOOT SECTION
May 19, 2008
wince run on 32MB mDDR platform
1.config.bib modified the macro definition from 64MB to 32MB
#define ROM_IMAGE_START 80100000
; #define ROM_IMAGE_SIZE 01100000
; #define RAM_IMAGE_START 81300000
; #define RAM_IMAGE_SIZE 02D00000
#define ROM_IMAGE_SIZE 01100000
#define RAM_IMAGE_START 81300000
#define RAM_IMAGE_SIZE 00D00000
2. Modify wince37xx_32MB.bd
constants {
LOAD_ADDR = 0x40100000;
ENTRY_ADDR = 0x40100000;
sdram_arg = 0x02010020; // 0x02010040
}
3. Modify SDRAM arg from 64MB to 32MB in elf2sb convert.
elftosb -V -z -f 37xx -p "\." -c wince37xx_32MB.bd -o bootmanager.sb -D sdram_arg=0x02010020
#define ROM_IMAGE_START 80100000
; #define ROM_IMAGE_SIZE 01100000
; #define RAM_IMAGE_START 81300000
; #define RAM_IMAGE_SIZE 02D00000
#define ROM_IMAGE_SIZE 01100000
#define RAM_IMAGE_START 81300000
#define RAM_IMAGE_SIZE 00D00000
2. Modify wince37xx_32MB.bd
constants {
LOAD_ADDR = 0x40100000;
ENTRY_ADDR = 0x40100000;
sdram_arg = 0x02010020; // 0x02010040
}
3. Modify SDRAM arg from 64MB to 32MB in elf2sb convert.
elftosb -V -z -f 37xx -p "\." -c wince37xx_32MB.bd -o bootmanager.sb -D sdram_arg=0x02010020
Apr 23, 2008
WINCE5.0
Now the license fees of wince is only 1$, and the cpu is powerful now. Moreover, it is fast way to use wince to design your product.
Subscribe to:
Posts (Atom)