Changeset 16 for trunk/kernel/kern
- Timestamp:
- May 10, 2017, 5:04:01 PM (8 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.c
r14 r16 25 25 #include <hal_types.h> 26 26 #include <hal_special.h> 27 #include <printk.h> 27 28 #include <boot_info.h> 28 29 #include <xlist.h> … … 47 48 else if( func_type == DEV_FUNC_ICU ) return "ICU"; 48 49 else if( func_type == DEV_FUNC_PIC ) return "PIC"; 49 else return " UNDEFINED";50 else return "undefined"; 50 51 } 51 52 -
trunk/kernel/kern/chdev.h
r14 r16 222 222 ****************************************************************************************** 223 223 * @ func_type : functionnal type. 224 * @ return a printablestring.224 * @ return pointer on string. 225 225 *****************************************************************************************/ 226 226 char * chdev_func_str( uint32_t func_type ); -
trunk/kernel/kern/core.h
r14 r16 148 148 149 149 /*************************************************************************************** 150 * This function andreset the usage statistics.150 * This function reset the usage statistics. 151 151 *************************************************************************************** 152 152 * @ core : pointer on core descriptor. -
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 } -
trunk/kernel/kern/printk.h
r5 r16 213 213 #endif 214 214 215 #if CONFIG_SYSCALL_DEBUG 216 #define syscall_dmsg(...) printk(__VA_ARGS__) 217 #else 218 #define syscall_dmsg(...) 219 #endif 220 215 221 #if CONFIG_THREAD_DEBUG 216 222 #define thread_dmsg(...) printk(__VA_ARGS__) -
trunk/kernel/kern/rpc.c
r14 r16 745 745 746 746 ///////////////////////////////////////////////////////////////////////////////////////// 747 // Marshaling functions attached to RPC_VMM_GET_ VSEG747 // Marshaling functions attached to RPC_VMM_GET_REF_VSEG 748 748 ///////////////////////////////////////////////////////////////////////////////////////// 749 749 … … 797 797 798 798 // set output argument to client RPC descriptor 799 vseg_xp = XPTR( local_cxy , vseg_ptr ); 799 if( vseg_ptr == NULL ) vseg_xp = XPTR_NULL; 800 else vseg_xp = XPTR( local_cxy , vseg_ptr ); 800 801 hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)vseg_xp ); 801 802 } -
trunk/kernel/kern/rpc.h
r14 r16 371 371 * on the vseg containing a given virtual address in a given process. 372 372 * The server cluster is supposed to be the reference cluster. 373 * It returns NULL if no vseg has been founded.373 * It returns XPTR_NULL if no vseg has been founded. 374 374 *********************************************************************************** 375 375 * @ cxy : server cluster identifier. 376 376 * @ process : [in] pointer on process descriptor in server cluster. 377 377 * @ vaddr : [in] virtual address to be searched. 378 * @ vseg : [out] address of buffer for vseg pointerin client cluster.378 * @ vseg_xp : [out] buffer for extended pointer on vseg in client cluster. 379 379 **********************************************************************************/ 380 380 void rpc_vmm_get_ref_vseg_client( cxy_t cxy, -
trunk/kernel/kern/signal.h
r5 r16 92 92 uid_t si_uid; /*! Real user ID of sending process */ 93 93 int si_status; /*! Exit value or signal */ 94 c lock_t si_utime; /*! User time consumed */95 c lock_t si_stime; /*! System time consumed */94 cycle_t si_utime; /*! User time consumed */ 95 cycle_t si_stime; /*! System time consumed */ 96 96 sigval_t si_value; /*! Signal value */ 97 97 int si_int; /*! POSIX.1b signal */ -
trunk/kernel/kern/thread.c
r14 r16 51 51 52 52 ////////////////////////////////////////////////////////////////////////////////////// 53 // global variables for display / must be consistant with enum in "thread.h" 54 ////////////////////////////////////////////////////////////////////////////////////// 55 56 const char* thread_type_name[THREAD_TYPES_NR] = 57 { 58 "USER", 59 "RPC" 60 "KERNEL", 61 "IDLE", 62 }; 63 64 ////////////////////////////////////////////////////////////////////////////////////// 65 // This static function returns a printable string for the thread type. 53 // This function returns a printable string for the thread type. 66 54 ////////////////////////////////////////////////////////////////////////////////////// 67 55 char * thread_type_str( uint32_t type ) 68 56 { 69 if ( type == THREAD_USER ) return " THREAD_USER";70 else if( type == THREAD_RPC ) return " THREAD_RPC";71 else if( type == THREAD_DEV ) return " THREAD_DEV";72 else if( type == THREAD_KERNEL ) return " THREAD_KERNEL";73 else if( type == THREAD_IDLE ) return " THREAD_IDLE";57 if ( type == THREAD_USER ) return "USER"; 58 else if( type == THREAD_RPC ) return "RPC"; 59 else if( type == THREAD_DEV ) return "DEV"; 60 else if( type == THREAD_KERNEL ) return "KERNEL"; 61 else if( type == THREAD_IDLE ) return "IDLE"; 74 62 else return "undefined"; 75 63 } … … 703 691 } // end thread_idle() 704 692 705 693 ///////////////////////////////////////////////// 694 void thread_user_time_update( thread_t * thread ) 695 { 696 // TODO 697 printk("\n[WARNING] function %s not implemented\n", __FUNCTION__ ); 698 } 699 700 /////////////////////////////////////////////////// 701 void thread_kernel_time_update( thread_t * thread ) 702 { 703 // TODO 704 printk("\n[WARNING] function %s not implemented\n", __FUNCTION__ ); 705 } 706 707 //////////////////////////////////////////////// 708 void thread_signals_handler( thread_t * thread ) 709 { 710 // TODO 711 printk("\n[WARNING] function %s not implemented\n", __FUNCTION__ ); 712 } 713 714 -
trunk/kernel/kern/thread.h
r14 r16 128 128 uint32_t tm_born; /*! date of the thread loading */ 129 129 uint32_t tm_dead; /*! date of the death */ 130 c lock_t tm_sleep; /*! TODO ??? [AG] */131 c lock_t tm_wait; /*! TODO ??? [AG] */132 c lock_t tm_usr; /*! user execution duration */133 c lock_t tm_sys; /*! system execution duration */130 cycle_t tm_sleep; /*! TODO ??? [AG] */ 131 cycle_t tm_wait; /*! TODO ??? [AG] */ 132 cycle_t tm_usr; /*! user execution duration */ 133 cycle_t tm_sys; /*! system execution duration */ 134 134 } 135 135 thread_info_t; … … 151 151 typedef struct thread_s 152 152 { 153 void * cpu_uzone; /*! used for exception/interrupt/syscall */ 154 void * cpu_context; /*! used for context switch */ 155 void * fpu_context; /*! used for dynamic FPU allocation */ 156 153 157 uint32_t trdid; /*! thread index (in THTBL) */ 154 158 thread_type_t type; /*! thread type */ … … 177 181 uint32_t signals; /*! bit vector of signals */ 178 182 179 error_t errno; /*! errno value of last system call*/183 error_t errno; /*! errno value set by last system call */ 180 184 181 185 bool_t fork_user; /*! user defined placement for next fork() */ … … 205 209 xlist_entry_t wait_list; /*! member of threads blocked on same cond */ 206 210 207 void * fpu_context; /*! pointer on FPU context */208 void * cpu_context; /*! pointer on CPU context */209 210 211 thread_info_t info; /*! embedded thread_info_t */ 211 212 … … 219 220 220 221 #define CURRENT_THREAD (hal_get_current_thread()) 222 223 /*************************************************************************************** 224 * This function returns a printable string for a thread type. 225 *************************************************************************************** 226 * @ type : thread type. 227 * returns pointer on string. 228 **************************************************************************************/ 229 char * thread_type_str( uint32_t type ); 221 230 222 231 /*************************************************************************************** … … 438 447 void thread_kill( thread_t * thread ); 439 448 449 /*************************************************************************************** 450 * This function updates the calling thread user_time counter, and reset the thread 451 * cycles counter. 452 * TODO This function is not implemented. 453 *************************************************************************************** 454 * @ thread : local pointer on target thread. 455 **************************************************************************************/ 456 void thread_user_time_update( thread_t * thread ); 457 458 /**************************************************************************************n 459 * This function updates the calling thread kernel_time counter, and reset the thread 460 * cycles counter. 461 * TODO This function is not implemented. 462 *************************************************************************************** 463 * @ thread : local pointer on target thread. 464 **************************************************************************************/ 465 void thread_kernel_time_update( thread_t * thread ); 466 467 /*************************************************************************************** 468 * This function handle all pending signals for the thread identified by the <thread> 469 * argument. It is called each time the core exit the kernel, after handling an 470 * interrupt, exception or syscall. 471 * TODO This function is not implemented. 472 *************************************************************************************** 473 * @ thread : local pointer on target thread. 474 **************************************************************************************/ 475 void thread_signals_handle( thread_t * thread ); 476 477 478 440 479 #endif /* _THREAD_H_ */
Note: See TracChangeset
for help on using the changeset viewer.