1.1 --- a/stage2/irq.c Fri Feb 26 01:13:51 2016 +0100
1.2 +++ b/stage2/irq.c Fri Feb 26 20:01:03 2016 +0100
1.3 @@ -74,9 +74,9 @@
1.4
1.5 void irq_init()
1.6 {
1.7 + handle_error_level();
1.8 timer_init_irq();
1.9 init_interrupts();
1.10 - enable_interrupts();
1.11 }
1.12
1.13 void irq_handle()
1.14 @@ -106,51 +106,24 @@
1.15 }
1.16 }
1.17
1.18 -void tlb_handle()
1.19 -{
1.20 - u32 asid, virtual, physical, bottom, top;
1.21 -
1.22 - /* Obtain the bad virtual address. */
1.23 -
1.24 - asm volatile(
1.25 - "mfc0 %0, $10\n" /* CP0_ENTRYHI */
1.26 - "nop\n"
1.27 - : "=r" (virtual)
1.28 - );
1.29 -
1.30 - /* Obtain a virtual address region with 8KB resolution. */
1.31 -
1.32 - asid = virtual & 0xff;
1.33 - virtual = virtual & 0xffffe000;
1.34 -
1.35 - /* The appropriate physical address depends on the current task. */
1.36 -
1.37 - bottom = (stack_start - stack_size) & 0xffffe000;
1.38 - top = stack_start & 0xffffe000;
1.39 -
1.40 - if ((asid != 0) && (virtual >= bottom) && (virtual < top))
1.41 - physical = virtual + asid * stack_size;
1.42 - else
1.43 - physical = virtual;
1.44 -
1.45 - /*
1.46 - Request a physical region mapping two 4KB pages.
1.47 - Pages employ C=3, dirty, valid, with the task number as the ASID.
1.48 - */
1.49 -
1.50 - map_page_miss(physical, pagesize, 0x1e);
1.51 -}
1.52 -
1.53 void start_task(unsigned short task)
1.54 {
1.55 u32 args[] = {1, 0, (task - 1) * 120};
1.56 + u32 virtual, physical;
1.57
1.58 /*
1.59 Each task employs a stack at a multiple of the given start address in
1.60 physical memory, but at the same address in virtual memory.
1.61 */
1.62
1.63 - map_page(stack_start + stack_size * task - stack_size, stack_start + stack_size * task - stack_size, pagesize, 0x1e, 0);
1.64 + virtual = stack_start - pagesize * 2;
1.65 + physical = stack_start + stack_size * task - pagesize * 2;
1.66 +
1.67 + init_page_table(page_table_start, virtual, physical, pagesize, 0x1e, task);
1.68 +
1.69 + /* Map the page for initialisation. */
1.70 +
1.71 + map_page(physical, physical, pagesize, 0x1e, 0);
1.72
1.73 /*
1.74 Set the stack for the new task, initialising the global pointer and
1.75 @@ -190,7 +163,6 @@
1.76 {
1.77 current_task = task;
1.78 current_stack_pointer = stack_pointers[current_task];
1.79 - map_page(stack_start - stack_size, stack_start + stack_size * current_task - stack_size, pagesize, 0x1e, current_task);
1.80 set_task(current_task);
1.81
1.82 asm volatile(