Author: Fu Linlin Source: NEW YORK Original title: "Two points Practice Builder Platform" increase the problem of large-capacity physical memory support and permanent storage registry is encountered in the custom kernel work often. This article will explain the relevant knowledge of these two aspects and guide readers to implement in PB. For large-capacity physical memory, it is very convenient to increase physical memory on the PC. After inserting a memory module, the desktop operating system can be supported. And it is not that simple in CE-based products. If the physical memory is greater than 64MB, do some work when the kernel is customized. Once the memory management unit (MMU) starts working, the CPU no longer directly accesses physical memory. For the CE kernel running on the X86 and ARM Series CPU, you must first establish a mapping relationship with the virtual memory address. This relationship is actually defined in a table named OemadDRessTable. This table has been mentioned in front of the article. CE provides two virtual address mapping methods, static mapping and dynamic mapping, respectively, belonging to a static mapping method. The static mapped virtual address space can only be accessed by kernel, while the dynamically mapped address space can be accessed by the user mode application. OEMADDRESSTABLE in file% _winceroot% / public / common / Oak / CSP / I486 / OAL / OEMINIT.ASM. The final code in this file:
; RAM 0x80000000 -> 0x00000000, Size 64MDD 800000H, 0, 04000000HDD 0, 0, 0 This code indicates that the virtual address 80000000 is mapped to the physical address 0, and the size is 64MB. Change 04000000h to the actual physical memory size and then save. Then click the PB menu "build" - "Open Build Release Directory", first use the CD command to enter the above directory in the command line, such as: CD% _winceroot% / public / common / Oak / CSP / I486 / OAL and type the following command :
The build -csysgen i486oal build command compiles the entire directory based on the content file content, and the sysGen batch copying the file I486OAL.LIB file compiled Build to the CE installation directory and kernel engineering directory. The BSP I installed is X86 based, so the corresponding directory is% _winceroot% / public / common / oak / lib / x86 / retail and% _ProjectRoot% / CESYSGEN / OAK / lib / x86 / retail two directories. After the last step is finished, then began to modify the config.bib file. In the previous article, the memory area is defined in the Config.bib file. The preset configuration in config.bi is not more than 64MB, so you have to add it yourself. According to the original IMGRAM64 configuration, the original IMGRAM64 is as follows:
64 MB of Ram (NOTE: AutoSize Will Adjust Boundary) IF Imgram64nk 80220000 009E0000 Ramimageram 80C00000 03000000 Ramumabuf 83C00000 00400000 ReservedEndIf If you want to support 128MB, change as follows:
IF IMGRAM16! IF IMGRAM32! IF IMGRAM64! NK 80220000 009E0000 Ramimageram 80C00000 070000000 Ramumabuf 87C00000 00400000 ReservedIndifendifeDifendif does not change the size of NK here, just modifying the size of the RAM. After config.bib definition, you can also change the size of the physical memory through a variable or function in the OAL layer, and the appropriate device may increase or decrease in memory. The help documentation of CE introduces several ways, here only come up with the CreateStaticMapping function. The CreateStaticMapping function is supplemented by the config.bib file, which is suitable for calling in the user mode application or driver, calling this function to map the physical memory block of the specified first address to the virtual address space, the function returns the virtual address. The virtual address ranges between C400 0000 to E000 0000, which is the address space of the kernel, and can only be accessed by kernel. Comparing the VirtualCopy function to dynamically map the physical memory block of the specified first address to the virtual address space, this virtual address space is generally the address space of the user process, because the VirtualCopy function is designed to be used for driver calls, which is often used Map a physical memory block to a different virtual address space. Achieve permanent saving registry data About registry has been introduced in front of the article, only how to implement permanent saving registry data. The registry type is divided into object-stored registry and Hive-based registry, only one of them can only be selected when customizing the kernel. In theory, both registry can implement permanent saving registry data, but different types affect CE startup sequence and start speed, which will also affect the amount of memory. I still tend to adopt Hive-based registry to achieve permanent saving registry data, which is also a development trend. Briefly describe before explaining If the CE uses a Hive-based registry, how to load the saved registry data at startup: 1, nk.exe execution, start FileSys.exe. 2, FileSys.exe Load Boot Hive, this point in the file behind Nk.bin decompresses it. 3, FileSys.exe launches Device.exe, then in the waiting state, wait for Device.exe to load the driver of the file system and storage device containing the system Hive. The driver of this file system and storage device exists in booting the Hive. 4. Device.exe loads the above-mentioned file system drivers and storage device drivers to start working. The device.exe then is waiting. 5, FILESYS.EXE is awakened, loaded and installed the system Hive. The FileSys.exe is then waiting. 6, nk.exe starts initialization work according to the information of the system Hive. These include loading drivers and launching some applications. The loading driver is generally performed by Device.exe, while the startup application is executed by FileSys.exe. At this time, Device.exe and FileSys.exe have been awakened. Because the boot Hive and system hive certainly have repetitive places, it may have been repeatedly loaded or repeatedly launched the application. To this end, CE allows the addition of a repetitive flag to be added to the registry information describing the driver, and the application can use event objects to prevent duplicate start, such as Device.exe. Here, how to set up Hive-based registry (if saving the system Hive is a FAT file system): 1. Add "Hive-Based Registry" in the PB, if it is a Geode platform, join the BSP_enable_fsreghive environment variable. 2, open Platform.Reg, find the following information:
; HIVE BOOT SECTION [HKEY_LOCAL_MACHINE / init / BootVars] "SYSTEMHIVE" = "Documents and Settings // system.hv" "PROFILEDIR" = "Documents and Settings" "Start DevMgr" = dword: 0IF BSP_ENABLE_FSREGHIVE "Start DevMgr" = dword: 1 Nendif; End Hive Boot Section "Systemhive" The value of the system Hive file. "START DEVMGR" is a Boolean value indicating whether to perform device manager device.exe, follow the CE help documentation, only want to store the system Hive in the object storage, so it is usually set. To 1. 3. If it is a multi-user, you can enter "DefaultUser" = ", specify the default username at the above registry location. If it is a single user system, it may not be set.
4. Ensure that the registry information of the registry information of the file system driver containing the system Hive is included in "; Hive Boot Section" and "; End Hive Boot Section" between these two The registry data between statements belongs to the boot Hive. If we store the system hive file system.hv on the hard disk and use the FAT file system. Then you have to move [HKEY_LOCAL_MACHINE / SYSTEM / STORAGEMANAGER / FATFS] and [HKEY_LOCAL_MACHINE / SYSTEM / StorageManager / Profiles / HDProfile] to "; Hive Boot Section".
5. Add the following signs in the registry information between all drivers between "; Hive Boot Section" and "End Hive Boot Section":
"Flags" = dword: 1000
This flag is a bit mask, which can be and other "flags" or operations already existing. Value 1000 indicates that this driver is only loaded, so Device.exe does not load the current driver twice.
6. In the registry information of the driver containing the storage device of the system Hive, add the following flag (assuming is a hard disk):
[HKEY_LOCAL_MACHINE / SYSTEM / STORAGEMANAGER / Profiles / HDProfile] "MountFlags" = DWORD: 2
This log indicates that this storage device contains a system Hive file.
Permanently stored registry data can be implemented in accordance with the kernel as described above. The execution action for saving registry data must be explained here:
Normally, CE can guarantee that important registry data can be brushed from memory to (Flush) permanent memory. But this does not fully guarantee that all data can be fully saved without being lost, so it is necessary to ensure that the RegflushKey function enforces the data in the memory to a permanent memory. The parameter of this function is only one, which is the registry branch. CE also adds an registry key (as shown below), which automatically calls the RegflushKey function whenever the function regLosekey is called.
[HKEY_LOCAL_MACHINE / INIT / BOOTVARS] "registryflags" = dword: 1
If the CE discovers the system Hive error during the startup process, it automatically deletes the file and creates a default system Hive file, if the following registry key appears, this means that this is. [Hkey_local_machine] "regpersisted" = DWORD: 1
This article is not allowed to reprint this article without the consent of this article. Contact the author Post: Fllsoft@sina.com or windowsce@tom.com