KolibriOS kernel
mtrr.inc File Reference

Classes

struct  mtrr_range
 mtrr_reconfigure keeps a list of MEM_WB ranges. This structure describes one item in the list. More...
 

Functions

void init_pat_mtrr ()
 Initializes PAT (Page Attribute Table) and MTRRs. More...
 
void mtrr_begin_change ()
 
void mtrr_end_change ()
 
void mtrr_reconfigure ()
 Helper procedure for MTRR initialization. Takes MTRR configured by BIOS and tries to recongifure them in order to allow non-UC data at top of 4G memory. Example: if low part of physical memory is 3.5G = 0xE0000000 bytes wide, BIOS can configure two MTRRs so that the first MTRR describes [0, 4G) as WB and the second MTRR describes [3.5G, 4G) as UC; WB+UC=UC, so the resulting memory map would be as needed, but in this configuration our attempts to map LFB at (say) 0xE8000000 as WC would be ignored, WB+UC+WC is still UC. So we must keep top of 4G memory not covered by MTRRs, using three WB MTRRs [0,2G) + [2G,3G) + [3G,3.5G), this gives the same memory map, but allows to add further entries. See mtrrtest.asm for detailed input/output from real hardware+BIOS. More...
 
void set_mtrr (dword base, dword size, dword mem_type)
 Allocate&set one MTRR for given range. size must be power of 2 that divides base. More...
 
void mtrr_get_real_type ()
 Helper procedure for mtrr_validate. Calculates memory type for given address according to variable-range MTRRs. Assumes that MTRRs are enabled. in: ebx = 32-bit physical address out: eax = memory type for ebx. More...
 
void mtrr_validate ()
 If MTRRs are configured improperly, this is not obvious to the user; everything works, but the performance can be horrible. Try to detect this and let the user know that the low performance is caused by some problem and is not a global property of the system. Let's hope he would report it to developers... More...
 

Variables

dd num_variable_mtrrs
 number of variable-range MTRRs More...
 
dd _phys_reserved_mask
 
dd _first_range
 
dd _first_free_range
 
dd _num_used_mtrrs
 
dd _mtrrs_end
 
rq _mtrrs
 

Function Documentation

◆ init_pat_mtrr()

void init_pat_mtrr ( )

Initializes PAT (Page Attribute Table) and MTRRs.

Source
core/mtrr.inc:11

◆ mtrr_begin_change()

void mtrr_begin_change ( )

◆ mtrr_end_change()

void mtrr_end_change ( )

◆ mtrr_get_real_type()

void mtrr_get_real_type ( )

Helper procedure for mtrr_validate. Calculates memory type for given address according to variable-range MTRRs. Assumes that MTRRs are enabled. in: ebx = 32-bit physical address out: eax = memory type for ebx.

Source
core/mtrr.inc:815

◆ mtrr_reconfigure()

void mtrr_reconfigure ( )

Helper procedure for MTRR initialization. Takes MTRR configured by BIOS and tries to recongifure them in order to allow non-UC data at top of 4G memory. Example: if low part of physical memory is 3.5G = 0xE0000000 bytes wide, BIOS can configure two MTRRs so that the first MTRR describes [0, 4G) as WB and the second MTRR describes [3.5G, 4G) as UC; WB+UC=UC, so the resulting memory map would be as needed, but in this configuration our attempts to map LFB at (say) 0xE8000000 as WC would be ignored, WB+UC+WC is still UC. So we must keep top of 4G memory not covered by MTRRs, using three WB MTRRs [0,2G) + [2G,3G) + [3G,3.5G), this gives the same memory map, but allows to add further entries. See mtrrtest.asm for detailed input/output from real hardware+BIOS.

Source
core/mtrr.inc:130

◆ mtrr_validate()

void mtrr_validate ( )

If MTRRs are configured improperly, this is not obvious to the user; everything works, but the performance can be horrible. Try to detect this and let the user know that the low performance is caused by some problem and is not a global property of the system. Let's hope he would report it to developers...

Source
core/mtrr.inc:872

◆ set_mtrr()

void set_mtrr ( dword  base,
dword  size,
dword  mem_type 
)

Allocate&set one MTRR for given range. size must be power of 2 that divides base.

Source
core/mtrr.inc:763

Variable Documentation

◆ _first_free_range

dd _first_free_range
Initial value
?
Source
core/mtrr.inc:157

◆ _first_range

dd _first_range
Initial value
?
Source
core/mtrr.inc:156

◆ _mtrrs

rq _mtrrs
Initial value
MAX_USEFUL_MTRRS * 2
Source
core/mtrr.inc:160

◆ _mtrrs_end

dd _mtrrs_end
Initial value
?
Source
core/mtrr.inc:159

◆ _num_used_mtrrs

dd _num_used_mtrrs
Initial value
?
Source
core/mtrr.inc:158

◆ _phys_reserved_mask

dd _phys_reserved_mask
Initial value
?
Source
core/mtrr.inc:155

◆ num_variable_mtrrs

dd num_variable_mtrrs

number of variable-range MTRRs

Initial value
0
Source
core/mtrr.inc:114