1.1 --- a/stage2/cpu.c Tue Feb 23 22:51:36 2016 +0100
1.2 +++ b/stage2/cpu.c Tue Feb 23 23:22:30 2016 +0100
1.3 @@ -233,23 +233,3 @@
1.4
1.5 map_page_index(virtual, physical, pagesize, flags & 0xfd, asid, index);
1.6 }
1.7 -
1.8 -void tlb_handle(void)
1.9 -{
1.10 - u32 context, virtual;
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 - /* Request a physical region mapping two 4KB pages. */
1.24 -
1.25 - map_page(virtual, virtual, 4 * 1024, 0x1f, 0);
1.26 -}
2.1 --- a/stage2/cpu.h Tue Feb 23 22:51:36 2016 +0100
2.2 +++ b/stage2/cpu.h Tue Feb 23 23:22:30 2016 +0100
2.3 @@ -12,6 +12,5 @@
2.4 void map_page(u32, u32, u32, u8, u8);
2.5 void map_page_index(u32, u32, u32, u8, u8, u32);
2.6 void unmap_page(u32, u32, u32, u8, u8);
2.7 -void tlb_handle(void);
2.8
2.9 #endif /* __CPU_H__ */
3.1 --- a/stage2/irq.c Tue Feb 23 22:51:36 2016 +0100
3.2 +++ b/stage2/irq.c Tue Feb 23 23:22:30 2016 +0100
3.3 @@ -102,3 +102,30 @@
3.4 enter_user_mode();
3.5 plot_pattern();
3.6 }
3.7 +
3.8 +void tlb_handle()
3.9 +{
3.10 + u32 context, virtual, physical;
3.11 +
3.12 + /* Obtain the bad virtual address. */
3.13 +
3.14 + asm volatile(
3.15 + "mfc0 %0, $4\n" /* CP0_CONTEXT */
3.16 + : "=r" (context)
3.17 + );
3.18 +
3.19 + /* Obtain a virtual address region with 8KB resolution. */
3.20 +
3.21 + virtual = (context & 0x007ffff0) << 9;
3.22 +
3.23 + /* The appropriate physical address depends on the current task. */
3.24 +
3.25 + physical = virtual;
3.26 +
3.27 + /*
3.28 + Request a physical region mapping two 4KB pages.
3.29 + Pages employ C=3, dirty, valid, with the task number as the ASID.
3.30 + */
3.31 +
3.32 + map_page(virtual, physical, 4 * 1024, 0x1f, 0);
3.33 +}
4.1 --- a/stage2/stage2.c Tue Feb 23 22:51:36 2016 +0100
4.2 +++ b/stage2/stage2.c Tue Feb 23 23:22:30 2016 +0100
4.3 @@ -2,7 +2,7 @@
4.4 * Ben NanoNote stage 2 payload test.
4.5 *
4.6 * Copyright (C) Wolfgang Spraul <wolfgang@sharism.cc>
4.7 - * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
4.8 + * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
4.9 *
4.10 * This program is free software: you can redistribute it and/or modify
4.11 * it under the terms of the GNU General Public License as published by
4.12 @@ -34,13 +34,19 @@
4.13 /* The actual work. */
4.14
4.15 started = is_started();
4.16 - if (!started) {
4.17 +
4.18 + if (!started)
4.19 + {
4.20 gpio_init2();
4.21 cpm_init();
4.22 rtc_init();
4.23 timer_init();
4.24 }
4.25 +
4.26 lcd_init();
4.27 irq_init();
4.28 +
4.29 start_task();
4.30 +
4.31 + while (1) asm volatile("wait");
4.32 }