1 /* 2 * Interrupt handling. 3 * 4 * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifdef CONFIG_CPU_JZ4730_MINIPC 21 #include "minipc.h" 22 #else 23 #include "nanonote.h" 24 #endif 25 26 #include "board-specific.h" 27 #include "board.h" 28 #include "lcd.h" 29 #include "jzlcd.h" 30 #include "cpu.h" 31 #include "irq.h" 32 33 extern vidinfo_t panel_info; 34 35 void next_pixel(unsigned short *x, unsigned short *y) 36 { 37 (*x)++; 38 if (*x >= panel_info.vl_col) { 39 *x = 0; 40 (*y)++; 41 if (*y >= panel_info.vl_row) 42 *y = 0; 43 } 44 } 45 46 /* Tasks. */ 47 48 void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y) 49 { 50 while (1) { 51 if (pixel_type) 52 test_pixel(x, y); 53 else 54 clear_pixel(x, y); 55 next_pixel(&x, &y); 56 udelay(100); 57 } 58 } 59 60 /* Initialisation and handling. */ 61 62 void irq_init() 63 { 64 timer_init_irq(); 65 handle_error_level(); 66 init_interrupts(); 67 enable_interrupts(); 68 } 69 70 void irq_handle() 71 { 72 unsigned short i; 73 74 /* Check interrupt identity. */ 75 76 if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { 77 78 /* Update the pixel type. */ 79 80 /* pixel_type = __gpio_get_pin(GPIO_POWER); */ 81 82 /* Clear interrupt status. */ 83 84 __intc_ack_irq(TIMER_CHAN_IRQ); 85 __tcu_clear_full_match_flag(TIMER_CHAN); 86 87 /* Handle other interrupts, anyway. */ 88 89 } else { 90 for (i = 0; i < 32; i++) { 91 if (REG_INTC_IPR & (1 << i)) 92 __intc_ack_irq(i); 93 } 94 } 95 } 96 97 void start_task() 98 { 99 enter_user_mode(); 100 plot_pattern(1, 0, 0); 101 } 102 103 void tlb_handle() 104 { 105 u32 context, virtual, physical; 106 107 /* Obtain the bad virtual address. */ 108 109 asm volatile( 110 "mfc0 %0, $4\n" /* CP0_CONTEXT */ 111 : "=r" (context) 112 ); 113 114 /* Obtain a virtual address region with 8KB resolution. */ 115 116 virtual = (context & 0x007ffff0) << 9; 117 118 /* The appropriate physical address depends on the current task. */ 119 120 physical = virtual; 121 122 /* 123 Request a physical region mapping two 4KB pages. 124 Pages employ C=3, dirty, valid, with the task number as the ASID. 125 */ 126 127 map_page(virtual, physical, 4 * 1024, 0x1f, 0); 128 }