1.1 --- a/stage2/irq.c Thu Feb 25 23:21:19 2016 +0100
1.2 +++ b/stage2/irq.c Fri Feb 26 00:23:58 2016 +0100
1.3 @@ -43,6 +43,13 @@
1.4 }
1.5 }
1.6
1.7 +/* Task management. */
1.8 +
1.9 +const u32 stack_start = 0x00080000;
1.10 +const u32 stack_size = 0x00002000;
1.11 +const u32 pagesize = 4 * 1024;
1.12 +const u32 framesize = 120; /* see the handlers */
1.13 +
1.14 /* Tasks. */
1.15
1.16 void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y)
1.17 @@ -101,7 +108,7 @@
1.18
1.19 void tlb_handle()
1.20 {
1.21 - u32 asid, virtual, physical;
1.22 + u32 asid, virtual, physical, bottom, top;
1.23
1.24 /* Obtain the bad virtual address. */
1.25
1.26 @@ -116,14 +123,20 @@
1.27 asid = virtual & 0xff;
1.28 virtual = virtual & 0xffffe000;
1.29
1.30 - /* The appropriate physical address should depend on the current task. */
1.31 + /* The appropriate physical address depends on the current task. */
1.32 +
1.33 + bottom = (stack_start - stack_size) & 0xffffe000;
1.34 + top = stack_start & 0xffffe000;
1.35
1.36 - physical = virtual;
1.37 + if ((asid != 0) && (virtual >= bottom) && (virtual < top))
1.38 + physical = virtual + asid * stack_size;
1.39 + else
1.40 + physical = virtual;
1.41
1.42 /*
1.43 Request a physical region mapping two 4KB pages.
1.44 Pages employ C=3, dirty, valid, with the task number as the ASID.
1.45 */
1.46
1.47 - map_page(virtual, physical, 4 * 1024, 0x1e, asid);
1.48 + map_page(virtual, physical, pagesize, 0x1e, asid);
1.49 }