設定CPU的Cache模式:MTRR
MSR(Model-Specific Register)內記錄關於CPU的特性,在MSR有段被稱為MTRR(Memory-Type Range Registers),用來記錄快取記憶體的模式。
快取模式
有5種快取模式。
| 編碼 | 簡寫 | 名稱 |
|---|---|---|
| 00h | UC | Uncacheable |
| 01h | WC | Write-Combining |
| 02h | Reserved | |
| 03h | Reserved | |
| 04h | WT | Writethrough |
| 05h | WP | Write-Protect |
| 06h | WB | Writeback |
IA32_MTRRCAP
IA32_MTRRCAP的位址在MSR[FEh],定義如下:
| 位元 | 標記 | 描述 |
|---|---|---|
| 63 ~ 11 | Reserved | |
| 10 | WC | Write-combining type is available |
| 9 | Reserved | |
| 8 | FIX | All fixed-size MTRRs are available |
| 7 ~ 0 | VCNT | Count of variable-size MTRRs supported |
IA32_MTRRdefType
IA32_MTRRdefType的位址在MSR[2FFh],定義如下:
| 位元 | 標記 | 描述 |
|---|---|---|
| 63 ~ 12 | Reserved | |
| 11 | E | MTRR enable |
| 10 | FE | Fixed range enable |
| 9 ~ 8 | Reserved | |
| 7 ~ 0 | Type | Default memory type |
IA32_MTRRphysBase 與 IA32_MTRRphysMask
MTRR的變數由IA32_MTRRphysBase與IA32_MTRRphysMask構成一組,第一組的IA32_MTRRphysBase與IA32_MTRRphysMask位址分別在MSR[200h]、MSR[201h],第二組的IA32_MTRRphysBase與IA32_MTRRphysMask位址分別在MSR[202h]、MSR[203h],……,以此類推,共有多少組可查詢IA32_MTRRCAP內的VCNT之值。
IA32_MTRRphysBase定義如下:
IA32_MTRRphysMask定義如下:
IA32_MTRRphysBase定義如下:
| 位元 | 標記 | 描述 |
|---|---|---|
| 63 ~ 52 | Reserved | |
| 51 ~ 12 | PhysBase | Range base address |
| 11 ~ 8 | Reserved | |
| 7 ~ 0 | Type | Range memory type |
| 位元 | 標記 | 描述 |
|---|---|---|
| 63 ~ 52 | Reserved | |
| 51 ~ 12 | PhysMask | Sets range mask |
| 11 | V | Valid |
| 10 ~ 0 | Reserved |
參考資料
更詳盡的內容可參考以下資料




留言
張貼留言