Intel Webcam 253668-032US User Manual

Page of 806
Vol. 3   11-43
MEMORY CACHE CONTROL
automatically aligns the base address and size to 4-KByte boundaries. Pseudocode 
for the MemTypeGet() function is given in Example 11-4.
Example 11-4.  MemTypeGet() Pseudocode
#define MIXED_TYPES -1     /* 0 < MIXED_TYPES || MIXED_TYPES > 256 */
IF CPU_FEATURES.MTRR /* processor supports MTRRs */
THEN
Align BASE and SIZE to 4-KByte boundary;
IF (BASE + SIZE) wrap 4-GByte address space 
THEN return INVALID;
FI;
IF MTRRdefType.E = 0
THEN return UC;
FI;
FirstType 
¨
 Get4KMemType (BASE);
/* Obtains memory type for first 4-KByte range. */
/* See Get4KMemType (4KByteRange) in Example 11-5. */
FOR each additional 4-KByte range specified in SIZE
NextType 
¨
 Get4KMemType (4KByteRange);
IF NextType 
¼
 FirstType
THEN return MixedTypes;
FI;
ROF; 
return FirstType;
ELSE return UNSUPPORTED;
FI;
If the processor does not support MTRRs, the function returns UNSUPPORTED. If the 
MTRRs are not enabled, then the UC memory type is returned. If more than one 
memory type corresponds to the specified range, a status of MIXED_TYPES is 
returned. Otherwise, the memory type defined for the range (UC, WC, WT, WB, or 
WP) is returned.
The pseudocode for the Get4KMemType() function in Example 11-5 obtains the 
memory type for a single 4-KByte range at a given physical address. The sample 
code determines whether an PHY_ADDRESS falls within a fixed range by comparing 
the address with the known fixed ranges: 0 to 7FFFFH (64-KByte regions), 80000H to 
BFFFFH (16-KByte regions), and C0000H to FFFFFH (4-KByte regions). If an address 
falls within one of these ranges, the appropriate bits within one of its MTRRs deter-
mine the memory type.