Author: arm-WinCE
In the wince system, how does the kernel use the memory and how does it know the memory size? The description in the config. bib file defines the starting address and size of Ram occupied by the wince kernel in the memory section of the config. bib file, for example:
Memory
NK 80001000 01e00000 ramimage
The bib file format has been introduced before. It is not repeated here. In config. bib defines a physical continuous memory. In oal, we can change the size of the continuous physical memory used by the kernel, you can also use functions to enumerate other available physical memory. Normally, these physical addresses are not sequential.
1. mainmemoryendaddress:
Used to change the size of the continuous physical memory used by the kernel defined in config. bib. During startup, the kernel sets this value to ulramend, where the value of ulramend is equal to config. the ram start address defined in bib + Ram size. The wince kernel uses mainmemoryendaddress to learn the available continuous physical memory size. This variable can be reset in the oeminit function to adjust the memory size.
2. bool oemgetextensiondram (lpdword lpmemstart, lpdword lpmemlen)
This function is used to enumerate a discontinuous physical memory from the wince kernel. When another physical memory exists, you can use this function to enumerate the starting address and size of the memory, so that the wince kernel can use this memory.
Lpmemstart: Memory start address
Lpmemlen: Memory size
If no additional memory exists, the function returns false directly.
3. pnkenumextensiondram
If the system has more than one non-consecutive physical memory, you need to implement the oemenumextensiondram function and assign it to the pnkenumextensiondram function pointer. It is generally implemented in oeminit as follows:
Pnkenumextensiondram = oemenumextensiondram;
Then we need to implement the oemenumextensiondram function. This function is relatively simple. For example, we will understand it as follows:
DWORD oemenumextensiondram (pmemory_section pmemsections, DWORD cmemsections)
{
DWORD dwextmem = 0;
Pmemsections [0]. dwflags = 0;
Pmemsections [0]. dwstart = (sdram_virtual_memory + sdram_main_block_size );
Pmemsections [0]. dwlen = sdram_main_block_size;
Pmemsections [1]. dwflags = 0;
Pmemsections [1]. dwstart = (sdram_virtual_memory + 2 * sdram_main_block_size );
Pmemsections [1]. dwlen = sdram_main_block_size;
Pmemsections [2]. dwflags = 0;
Pmemsections [2]. dwstart = (sdram_virtual_memory + 3 * sdram_main_block_size );
Pmemsections [2]. dwlen = sdram_main_block_size;
Dwextmem = 3;
Return dwextmem;
}
Pmemsections is a memory structure, as follows:
Typedef struct _ memory_section {
DWORD dwflags;// Reserved, must be set to 0
DWORD dwstart;// Memory start address
DWORD dwlen;// Memory size
} Memory_section, * pmemory_section;
In the above oemenumextensiondram function, three consecutive physical memories are enumerated and the number of enumerated memories is returned.
During the wince boot process, the system first checks whether pnkenumextensiondram is null. If it is not null, the system calls the function it points to and does not call oemgetextensiondram. If pnkenumextensiondram is null, The oemgetextensiondram function is called.