Changeset 16 for trunk/kernel/kern/do_interrupt.c
- Timestamp:
- May 10, 2017, 5:04:01 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/do_interrupt.c
r5 r16 1 1 /* 2 * kern/do_interrupt.c - kernel unified interrupt entry-point2 * do_interrupt.c - architecture independant interrupt handler. 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Author Alain Greiner (2016) 6 5 * 7 * This file is part of ALMOS-kernel.6 * Copyright (c) UPMC Sorbonne Universites 8 7 * 9 * ALMOS-kernel is free software; you can redistribute it and/or modify it 8 * This file is part of ALMOS-MKH. 9 * 10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 22 23 23 #include < cpu.h>24 #include < task.h>24 #include <hal_types.h> 25 #include <kernel_config.h> 25 26 #include <thread.h> 26 #include <cpu-trace.h> 27 #include <chdev.h> 28 #include <system.h> 29 #include <signal.h> 27 #include <dev_icu.h> 30 28 31 #define irq_cpu_dmsg(c,...) \32 do{ \33 if(cpu_get_id() == (c)) \34 isr_dmsg(INFO, __VA_ARGS__); \35 }while(0)36 29 37 void do_interrupt(struct thread_s *this, uint_t irq_num) 30 //////////////////////////////////// 31 void do_interrupt( thread_t * this ) 38 32 { 39 register thread_state_t old_state; 40 struct irq_action_s *action; 41 struct cpu_s *cpu; 42 uint_t irq_state; 43 error_t ret; 33 // update user time 34 thread_user_time_update( this ); 44 35 45 cpu_trace_write(thread_current_cpu(this), do_interrupt); 36 // access ICU device to call the relevant ISR 37 dev_icu_irq_handler(); 38 39 // handle pending signals for interrupted thread 40 thread_signals_handle( this ); 46 41 47 cpu = thread_current_cpu(this); 48 49 cpu->irq_nr ++; 50 old_state = this->state; 51 52 if(old_state == S_USR) 53 { 54 this->state = S_KERNEL; 55 tm_usr_compute(this); 56 } 57 58 arch_cpu_get_irq_entry(cpu, irq_num, &action); 59 action->irq_handler(action); 60 61 cpu_yield(); 62 63 if(old_state != S_USR)//and not a kernel thread ? 64 return; 65 66 /* it is safe to migrate as we are going to user * 67 * space. */ 68 if(thread_migration_isActivated(this)) 69 { 70 thread_clear_cap_migrate(this); 71 cpu_enable_all_irq(&irq_state); 72 ret = thread_migrate(this,-1); 73 cpu_restore_irq(irq_state); 74 75 /* this pointer has expired */ 76 this = CURRENT_THREAD; 77 cpu_wbflush(); 78 79 if(ret == 0) 80 thread_migration_deactivate(this); 81 else 82 { 83 isr_dmsg(INFO, 84 "%s: cpu %d, migration failed for victim pid %d, tid %d, err %d\n", 85 __FUNCTION__, 86 cpu_get_id(), 87 this->task->pid, 88 this->info.order, 89 ret); 90 } 91 } 92 93 tm_sys_compute(this); 94 this->state = S_USR; 95 signal_notify(this); 42 // update kernel time 43 thread_kernel_time_update( this ); 96 44 }
Note: See TracChangeset
for help on using the changeset viewer.