Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fallen/milkymist-mmu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 582617f830bd
Choose a base ref
...
head repository: fallen/milkymist-mmu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2b79691a1126
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Oct 12, 2012

  1. Copy the full SHA
    def1b91 View commit details
  2. Copy the full SHA
    2b79691 View commit details
Showing with 23 additions and 15 deletions.
  1. +2 −1 cores/lm32/rtl/lm32_dcache.v
  2. +2 −1 cores/lm32/rtl/lm32_icache.v
  3. +7 −7 software/libbase/mmu.c
  4. +12 −6 software/libhal/mmu.c
3 changes: 2 additions & 1 deletion cores/lm32/rtl/lm32_dcache.v
Original file line number Diff line number Diff line change
@@ -799,7 +799,8 @@ begin
`LM32_TLB_CTRL_INVALIDATE_ENTRY:
begin
dtlb_flushing <= 1;
dtlb_flush_set <= dtlb_update_vaddr_csr_reg[`LM32_DTLB_IDX_RNG];
// dtlb_flush_set <= dtlb_update_vaddr_csr_reg[`LM32_DTLB_IDX_RNG];
dtlb_flush_set <= csr_write_data[`LM32_DTLB_IDX_RNG];
dtlb_updating <= 0;
dtlb_state <= `LM32_TLB_STATE_CHECK;
end
3 changes: 2 additions & 1 deletion cores/lm32/rtl/lm32_icache.v
Original file line number Diff line number Diff line change
@@ -888,7 +888,8 @@ begin
$display("it's an INVALIDATE ENTRY at %t", $time);
`endif
itlb_flushing <= 1;
itlb_flush_set <= itlb_update_vaddr_csr_reg[`LM32_ITLB_IDX_RNG];
// itlb_flush_set <= itlb_update_vaddr_csr_reg[`LM32_ITLB_IDX_RNG];
itlb_flush_set <= csr_write_data[`LM32_ITLB_IDX_RNG];
itlb_updating <= 0;
itlb_state <= `LM32_TLB_STATE_CHECK;
end
14 changes: 7 additions & 7 deletions software/libbase/mmu.c
Original file line number Diff line number Diff line change
@@ -47,18 +47,18 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
{
puts("Already mapped, updating metadata !");
mappings[i].metadata |= metadata;
// if (mappings[i].metadata & ITLB_MAPPING)
// mmu_itlb_map(vaddr, paddr);
if (mappings[i].metadata & ITLB_MAPPING)
mmu_itlb_map(vaddr, paddr);
if (mappings[i].metadata & DTLB_MAPPING)
mmu_dtlb_map(vaddr, paddr);
return 1;
} else if ((vaddr == mappings[i].vaddr) && (paddr != mappings[i].paddr) && (mappings[i].metadata & MAPPING_IS_VALID))
{
puts("Vaddr already mapped to another Paddr (0x%08X), overwritting...\n", mappings[i].paddr);
printf("Vaddr already mapped to another Paddr (0x%08X), overwritting...\n", mappings[i].paddr);
mappings[i].paddr = paddr;
mappings[i].metadata = (metadata | MAPPING_IS_VALID);
// if (mappings[i].metadata & ITLB_MAPPING)
// mmu_itlb_map(vaddr, paddr);
if (mappings[i].metadata & ITLB_MAPPING)
mmu_itlb_map(vaddr, paddr);
if (mappings[i].metadata & DTLB_MAPPING)
mmu_dtlb_map(vaddr, paddr);
return 1;
@@ -75,8 +75,8 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
mappings[empty_slot].paddr = paddr;
mappings[empty_slot].metadata = (metadata | MAPPING_IS_VALID);

// if (metadata & ITLB_MAPPING)
// mmu_itlb_map(vaddr, paddr);
if (metadata & ITLB_MAPPING)
mmu_itlb_map(vaddr, paddr);

if (metadata & DTLB_MAPPING)
mmu_dtlb_map(vaddr, paddr);
18 changes: 12 additions & 6 deletions software/libhal/mmu.c
Original file line number Diff line number Diff line change
@@ -56,27 +56,33 @@ inline void mmu_itlb_map(unsigned int vpfn, unsigned int pfn)

inline void mmu_dtlb_invalidate_line(unsigned int vaddr)
{
asm volatile ("ori %0, %0, 0x21\n\t"
"wcsr tlbvaddr, %0" :: "r"(vaddr) : );
vaddr |= 0x21;
asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
}

inline void mmu_itlb_invalidate_line(unsigned int vaddr)
{
asm volatile ("ori %0, %0, 0x20\n\t"
"wcsr tlbvaddr, %0" :: "r"(vaddr) : );
vaddr |= 0x20;
asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
}

inline void mmu_dtlb_invalidate(void)
{
register unsigned int cmd = DTLB_CTRL_FLUSH_CMD;
// register unsigned int cmd = DTLB_CTRL_FLUSH_CMD;
// asm volatile("wcsr tlbctrl, %0" :: "r"(cmd) : );
asm volatile("xor r11, r11, r11\n\t"
"ori r11, r11, 0x3\n\t"
"wcsr tlbvaddr, r11" ::: "r11");

}

inline void mmu_itlb_invalidate(void)
{
register unsigned int cmd = ITLB_CTRL_FLUSH_CMD;
// register unsigned int cmd = ITLB_CTRL_FLUSH_CMD;
// asm volatile("wcsr tlbctrl, %0" :: "r"(cmd) : );
asm volatile("xor r11, r11, r11\n\t"
"ori r11, r11, 0x2\n\t"
"wcsr tlbvaddr, r11" ::: "r11");

}