1.1 --- a/stage2/irq.c Tue Feb 23 22:51:36 2016 +0100
1.2 +++ b/stage2/irq.c Tue Feb 23 23:22:30 2016 +0100
1.3 @@ -102,3 +102,30 @@
1.4 enter_user_mode();
1.5 plot_pattern();
1.6 }
1.7 +
1.8 +void tlb_handle()
1.9 +{
1.10 + u32 context, virtual, physical;
1.11 +
1.12 + /* Obtain the bad virtual address. */
1.13 +
1.14 + asm volatile(
1.15 + "mfc0 %0, $4\n" /* CP0_CONTEXT */
1.16 + : "=r" (context)
1.17 + );
1.18 +
1.19 + /* Obtain a virtual address region with 8KB resolution. */
1.20 +
1.21 + virtual = (context & 0x007ffff0) << 9;
1.22 +
1.23 + /* The appropriate physical address depends on the current task. */
1.24 +
1.25 + physical = virtual;
1.26 +
1.27 + /*
1.28 + Request a physical region mapping two 4KB pages.
1.29 + Pages employ C=3, dirty, valid, with the task number as the ASID.
1.30 + */
1.31 +
1.32 + map_page(virtual, physical, 4 * 1024, 0x1f, 0);
1.33 +}