forked from M-Labs/zynq-rs
1
0
Fork 0

CPU options for better performance

L2 cache options and prefetch options
This commit is contained in:
pca006132 2020-09-04 16:38:48 +08:00
parent 08fd1391c5
commit 02c67051e8
3 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,13 @@ pub fn enable_l2_cache() {
// disable L2 cache // disable L2 cache
regs.reg1_control.modify(|_, w| w.l2_enable(false)); regs.reg1_control.modify(|_, w| w.l2_enable(false));
regs.reg15_prefetch_ctrl.modify(|_, w|
w.instr_prefetch_en(true)
.data_prefetch_en(true)
.double_linefill_en(true)
.incr_double_linefill_en(true)
.pref_drop_en(true)
);
regs.reg1_aux_control.modify(|_, w| { regs.reg1_aux_control.modify(|_, w| {
w.early_bresp_en(true) w.early_bresp_en(true)
.instr_prefetch_en(true) .instr_prefetch_en(true)
@ -190,6 +197,8 @@ struct RegisterBlock {
/// memory if the line is marked as valid and dirty. The lines are marked as not valid. /// memory if the line is marked as valid and dirty. The lines are marked as not valid.
/// Completes as a background task with the way, or ways, locked, preventing allocation. /// Completes as a background task with the way, or ways, locked, preventing allocation.
pub reg7_clean_inv_way: RW<u32>, pub reg7_clean_inv_way: RW<u32>,
unused9: [u32; 0x1D8],
pub reg15_prefetch_ctrl: Reg15PrefetechCtrl,
} }
register_at!(RegisterBlock, 0xF8F02000, new); register_at!(RegisterBlock, 0xF8F02000, new);
@ -311,3 +320,9 @@ register_bits!(reg7_clean_inv_index, way, u8, 28, 30);
register_bits!(reg7_clean_inv_index, index, u8, 5, 11); register_bits!(reg7_clean_inv_index, index, u8, 5, 11);
register_bit!(reg7_clean_inv_index, c, 0); register_bit!(reg7_clean_inv_index, c, 0);
register!(reg15_prefetch_ctrl, Reg15PrefetechCtrl, RW, u32);
register_bit!(reg15_prefetch_ctrl, double_linefill_en, 30);
register_bit!(reg15_prefetch_ctrl, instr_prefetch_en, 29);
register_bit!(reg15_prefetch_ctrl, data_prefetch_en, 28);
register_bit!(reg15_prefetch_ctrl, pref_drop_en, 24);
register_bit!(reg15_prefetch_ctrl, incr_double_linefill_en, 23);

View File

@ -156,6 +156,8 @@ register_bit!(actlr, excl, 7);
register_bit!(actlr, smp, 6); register_bit!(actlr, smp, 6);
register_bit!(actlr, write_full_line_of_zeros, 3); register_bit!(actlr, write_full_line_of_zeros, 3);
register_bit!(actlr, l1_prefetch_enable, 2); register_bit!(actlr, l1_prefetch_enable, 2);
// L2 cache prefetch hint, in UG585 section 3.4.8
register_bit!(actlr, l2_prefetch_enable, 1);
// Cache/TLB maintenance broadcast // Cache/TLB maintenance broadcast
register_bit!(actlr, fw, 0); register_bit!(actlr, fw, 0);
@ -173,6 +175,10 @@ impl ACTLR {
pub fn enable_smp(&mut self) { pub fn enable_smp(&mut self) {
self.modify(|_, w| w.smp(true).fw(true)); self.modify(|_, w| w.smp(true).fw(true));
} }
pub fn enable_prefetch(&mut self) {
self.modify(|_, w| w.l1_prefetch_enable(true).l2_prefetch_enable(true))
}
} }
/// Domain Access Control Register /// Domain Access Control Register

View File

@ -53,6 +53,7 @@ unsafe fn boot_core0() -> ! {
mmu::with_mmu(mmu_table, || { mmu::with_mmu(mmu_table, || {
mpcore.scu_control.start(); mpcore.scu_control.start();
ACTLR.enable_smp(); ACTLR.enable_smp();
ACTLR.enable_prefetch();
// TODO: Barriers reqd when core1 is not yet starting? // TODO: Barriers reqd when core1 is not yet starting?
asm::dmb(); asm::dmb();
asm::dsb(); asm::dsb();
@ -74,6 +75,7 @@ unsafe fn boot_core1() -> ! {
let mmu_table = mmu::L1Table::get(); let mmu_table = mmu::L1Table::get();
mmu::with_mmu(mmu_table, || { mmu::with_mmu(mmu_table, || {
ACTLR.enable_smp(); ACTLR.enable_smp();
ACTLR.enable_prefetch();
// TODO: Barriers reqd when core1 is not yet starting? // TODO: Barriers reqd when core1 is not yet starting?
asm::dmb(); asm::dmb();
asm::dsb(); asm::dsb();