Chinaunix首页 | 论坛 | 博客
  • 博客访问: 335562
  • 博文数量: 97
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 636
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-12 22:41
文章分类

全部博文(97)

文章存档

2017年(8)

2015年(87)

2014年(2)

我的朋友

分类: 嵌入式

2015-04-15 21:19:46

本文介绍在A9上添加HIVE注册表,使其自动保存路径为MMCMemory


1、HIVE注册表的加载步骤
     a) NK.exe执行,启动Filesys.dll。Filesys.dll首先加载Boot Hive,此时Boot Hive位于NK.bin解压之后的文件中。然后,filesys.dll在启动device.dll后处于等待状态,等待device.dll将包含System Hive的文件系统的存储设备的驱动程序加载完毕,而这个文件系统的存储设备的驱动程序在Boot Hive中;
     b) Device.dll在上述驱动开始工作之后进入等待状态,然后filesys.dll被唤醒,加载并且安装System Hive,然后filesys.dll再次处于等待状态;
     c) NK.exe按照System Hive的信息开始执行初始化工作,包括加载驱动和启动一些应用程序。其中加载驱动一般由device.dll执行,而启动应用程序由filesys.dll执行,这时device.dll和filesys.dll都被唤醒
     d) 因为Boot Hive和System Hive可能都有重复的地方,所以可能重复加载了驱动或重复启动了应用程序。为此,windows CE允许在描述驱动程序的注册表信息中加入防止重复的标志


2、实践操作
    a) 添加Hive注册表所需要的组件如下:
 
    b) 添加全局变量
    SET PRJ_ENABLE_REGFLUSH_THREAD=1    ;该全局变量是自动保存注册表所需
    set PRJ_ENABLE_FSREGHIVE=1                 ;这个属于PRJ Environment Variables ,在MSDN上描述为:Controls whether the hive-based registry is enabled by default
相关msdn条词在:Windows Embedded Compact 7 > Reference > Environment Variables >
(ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.WindowsCompact.v70.en/WECP_Ref_EnvVar/html/d497612e-796d-4d1b-a836-729c43ca6170.htm)


    c)添加注册表
    从HIVE注册表加载步骤中可以得知,HIVE注册表的加载首先需要由device.dll 初始化设备驱动,然后由filesys.dll加载文件系统并读取出System.hv,再交由device.dll按照注册表加载驱动
    因此我们在注册表中需要的信息有:设备驱动相关注册表、文件系统相关注册表、BootVars相关注册表。 这里将所有的注册表和需要注意事项通过注释写出来
    
; HIVE BOOT SECTION
; BootVars
;
; We want start both storage and device manager. Flags value is combination of
;   0x0001  Start storage manager in boot phases 0 and 1 to load the boot
;           file system.
;   0x0002  Start device manager in boot phase 1 to load the boot file system.
;
[HKEY_LOCAL_MACHINE\Init\BootVars]
    "Flags"=dword:3
 ;   "SystemHive"="\\Documents and Settings\\system.hv"    这里需要删除,添加后USB同步无法使用,且一旦添加同步后,系统死机 ,分析原因:CE7默认路径不是这儿
 ;  "ProfileDir"="\\Documents and Settings"
 ;   "DefaultUser"="default"
 ;   "RegistryFlags"=dword:0 ;这里设置为0,设置为1的话系统起不来,不知为何,且网贴有介绍称设置为1会影响系统效率,因为每次读写均在flash中
; RegistryFlags: 0:Lazy Flush 1:auto save when modify 2:;Disable background registry flushing to improve performance.
; END HIVE BOOT SECTION




; HIVE BOOT SECTION
; SD Drivers 这里添加SD卡加载所需的驱动注册表
[HKEY_LOCAL_MACHINE\Drivers\Builtin\SDBusDriver]
   "Order"=dword:15
   "Dll"="SDBus.dll"
   "Prefix"="SDC"
   "ThreadPriority"=dword:64     ; default thread priority for dispatch thread
   "RequestListDepth"=dword:30   ; pre-allocated requests
   "IClass"=multi_sz:"{20FA98A8-B298-4b32-8D72-C716AEE2FA84}=%b","{6F40791D-300E-44E4-BC38-E0E63CA8375C}=%b"
   "BootPhase"=dword:1 ; change to 1
    "Flags"=dword:1000 ; 设置Flags信息,该注册表信息在系统阶段不会被加载
   
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\USDHC4]
    "Order"=dword:20    
"Dll"="usdhc.dll"
    "Prefix"="SHC"
    "Index"=dword:4
    ;"DisableDMA"=dword:1                                      ; Use this ;reg setting to disable both internal and external DMA
    "MaximumClockFrequency"=dword:3197500           ; 52 MHz max clock speed
    ;"WakeupSource"=dword:1                                  ; this will enable system wakeup when card is inserted or removed during suspend state    
;    "CardDetectOpt"=dword:0
    "Flags"=dword:1000

; MMC Drivers
; MMC Storage Class Driver 这一部分的驱动,在后续加载SD卡时还会被用到,因此不应该添加Flags = 1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDMemory]
    "Name"="SD Memory Card"
    "Folder"="SDMemory"
; "Flags"=dword:1000 
 ;"PartitionDriver"=""          ; removable storage cannot have partitions


[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDMemory\FATFS]
    "FormatFatVersion"=dword:10    ; standard sd cards require fat12 or fat16, and cannot use fat32
; "Flags"=dword:1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDHCMemory]
    "Name"="SD Memory Card"
    "Folder"="SDHCMemory"
    ;"PartitionDriver"=""          ; removable storage cannot have partitions
; "Flags"=dword:1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDHCMemory\FATFS]
    "FormatFatVersion"=dword:20    ; high capacity SD cards need to use fat32 and cannot use fat16
; "Flags"=dword:1000


[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MMC]
    "Name"="MMC Card"
    "Folder"="MMCMemory"
    "FormatTfat"=dword:1 
    "MountAsBootable"=dword:1
    "MountPermanent"=dword:0
; "Flags"=dword:1000
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MMC\FATFS]
   "FormatTfat"=dword:1
   "AutoMount"=dword:1
   "AutoPart"=dword:1
   "AutoFormat"=dword:1
   "DisableAutoFormat"=dword:0
    "FormatTfat"=dword:1 
    "MountAsBootable"=dword:1
    "MountPermanent"=dword:0
; "Flags"=dword:1000   
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MMC\EXFAT]
   "FormatTfat"=dword:1
   "AutoMount"=dword:1
   "AutoPart"=dword:1
   "AutoFormat"=dword:1
   "DisableAutoFormat"=dword:0
; "Flags"=dword:1000
; SD Memory Storage class driver
[HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Class\SDMemory_Class]
   "Dll"="SDMemory.dll"
   "Prefix"="DSK"
   "BlockTransferSize"=dword:40  ; send no more than 64 blocks of data per bus transfer
   ;"SingleBlockWrites"=dword:1  ; alternatively force the driver to use single block access
   ;"IdleTimeout"=dword:7D0      ; 2000 milliseconds
   ;"IdlePowerState"=dword:2     ; 0 == D0, 1 == D1, etc.
   ;"DisablePowerManagement"=""  ; if value present, then disable (remove value to enable)
; "Flags"=dword:1000
   "Profile"="SDMemory"
   "IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}",
                     "{8DD679CE-8AB4-43c8-A14A-EA4963FAA715}"


; SDHC Memory Storage class driver
[HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Class\SDMemory_Class\High_Capacity]
   "Dll"="SDMemory.dll"
   "Prefix"="DSK"
   "BlockTransferSize"=dword:40  ; send no more than 64 blocks of data per bus transfer
   ;"SingleBlockWrites"=dword:1  ; alternatively force the driver to use single block access
   ;"IdleTimeout"=dword:7D0      ; 2000 milliseconds
   ;"IdlePowerState"=dword:2     ; 0 == D0, 1 == D1, etc.
   ;"DisablePowerManagement"=""  ; if value present, then disable (remove value to enable)
; "Flags"=dword:1000
   "Profile"="SDHCMemory"
   "IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}",
                     "{8DD679CE-8AB4-43c8-A14A-EA4963FAA715}"


; MMC Storage Class Driver
[HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Class\MMC_Class]
   "Dll"="SDMemory.dll"
   "Prefix"="DSK"
   "BlockTransferSize"=dword:40  ; send no more than 64 blocks of data per bus transfer
   ;"SingleBlockWrites"=dword:1  ; alternatively force the driver to use single block access
   ;"IdleTimeout"=dword:7D0      ; milliseconds
   ;"IdlePowerState"=dword:2     ; 0 == D0, 1 == D1, etc.
   ;"DisablePowerManagement"=""  ; if value present, then disable (remove value to enable)
; "Flags"=dword:1000
   "Profile"="MMC"
   "IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}",
                     "{8DD679CE-8AB4-43c8-A14A-EA4963FAA715}"


[HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Class\MMC_Class\High_Capacity]
   "Dll"="SDMemory.dll"
   "Prefix"="DSK"
   "BlockTransferSize"=dword:40  ; send no more than 64 blocks of data per bus transfer
   ;"SingleBlockWrites"=dword:1  ; alternatively force the driver to use single block access
   ;"IdleTimeout"=dword:7D0      ; milliseconds
   ;"IdlePowerState"=dword:2     ; 0 == D0, 1 == D1, etc.
   ;"DisablePowerManagement"=""  ; if value present, then disable (remove value to enable)
; "Flags"=dword:1000
   "Profile"="MMC"
   "IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}",
                     "{8DD679CE-8AB4-43c8-A14A-EA4963FAA715}"




; END HIVE BOOT SECTION


;*********************************************************************************************************
;
; 注册表自动保存注意事项: 
;
; 下面每间隔1秒(FlushPeriod的值)就会检查注册表是否有改变, 有则保存注册表,
;
; 使能时, 必须设置环境变量: SET  PRJ_ENABLE_REGFLUSH_THREAD=1
;
; 同时, 还要"RegistryFlags"=dword:1改成dword:0,不用每次注册表修改就自动去flush注册表。
;
;*********************************************************************************************************


IF PRJ_ENABLE_REGFLUSH_THREAD
[HKEY_LOCAL_MACHINE\System\ObjectStore\RegFlush]
; To monitor the flushing from an external process add "ActivityName" registry value.
; The activity name is a global named event that filesystem will signal on Registry Activity.
;   "ActivityName"=""
; Create an thread in filesys to perform flushing
    "SpawnThread"=dword:1
; Make the thread IDLE priority
    "FlushPriority256"=dword:FF
; ActivityThreshold specifies the # of reg activity before we force a flush
    "ActivityThreshold"=dword:100
; Timeout period for a flush (flush occurs if there have been some changes during this period)
    "FlushPeriod"=dword:3E8
ENDIF
   


阅读(1397) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~