- Timestamp:
- Aug 2, 2018, 11:47:13 AM (6 years ago)
- Location:
- trunk/hal
- Files:
-
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_atomic.h
r408 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 ////////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_context.h
r408 r457 43 43 * identified by the <thread> argument. The context is not initialised. 44 44 **************************************************************************************** 45 * @ thread : pointer on the thread descriptor. 45 46 * @ return 0 if success / return -1 if failure. 46 47 ***************************************************************************************/ … … 48 49 49 50 /**************************************************************************************** 50 * This function allocates memory for a CPU context, initialize it from scratch, 51 * and links it to the thread identified by the <thread> argument. 51 * This function initializes a CPU context from scratch. 52 52 **************************************************************************************** 53 53 * @ thread : pointer on the thread descriptor. 54 * @ return 0 if success / return -1 if failure.55 54 ***************************************************************************************/ 56 error_t hal_cpu_context_create( struct thread_s * thread );55 void hal_cpu_context_init( struct thread_s * thread ); 57 56 58 57 /**************************************************************************************** … … 71 70 72 71 /**************************************************************************************** 72 * This function is used to implement the exec() system call. 73 * 1) It initialize the relevant slots of the the calling thread CPU context. 74 * 2) It call the hal_do_cpu_restore() function to return to user mode and start 75 * execution of the new process. 76 **************************************************************************************** 77 * @ thread : pointer on the thread descriptor. 78 ***************************************************************************************/ 79 void hal_cpu_context_exec( struct thread_s * thread ); 80 81 /**************************************************************************************** 73 82 * This function display some slots of the CPU context. 74 * - For the MIPS32 :75 * . GPR : gp_28 , sp_29 , ra_3176 * . CP0 : c0_sr , c0_th , c0_epc77 * . CP2 : c2_ptpr , c2-mode78 * - For X86 TODO :79 83 **************************************************************************************** 80 84 * @ thread_xp : extended pointer on the thread descriptor. … … 103 107 ***************************************************************************************/ 104 108 error_t hal_fpu_context_alloc( struct thread_s * thread ); 109 110 /**************************************************************************************** 111 * This function initializes a FPU context from scratch. 112 **************************************************************************************** 113 * @ thread : pointer on the thread descriptor. 114 ***************************************************************************************/ 115 void hal_fpu_context_init( struct thread_s * thread ); 105 116 106 117 /**************************************************************************************** -
trunk/hal/generic/hal_exception.h
r455 r457 25 25 #define _HAL_EXCEPTION_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 ////////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_gpt.h
r432 r457 25 25 #define _GPT_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 ///////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_interrupt.h
r408 r457 25 25 #define _HAL_INTERRUPT_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 /////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_irqmask.h
r279 r457 26 26 #define _HAL_IRQMASK_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_shared_types.h> 29 29 30 30 -
trunk/hal/generic/hal_ppm.h
r409 r457 26 26 #define _HAL_PPM_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <boot_info.h> 30 30 -
trunk/hal/generic/hal_remote.h
r407 r457 26 26 #define _HAL_REMOTE_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 ////////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_special.h
r408 r457 25 25 #define _HAL_CPU_H_ 26 26 27 #include <hal_types.h> 27 #include <hal_shared_types.h> 28 #include <hal_kernel_types.h> 28 29 29 30 /**** Forward declarations ***/ -
trunk/hal/generic/hal_switch.h
r408 r457 28 28 29 29 /************************************************************************************* 30 * Th e hal_do_cpu_switch() function is an assembly level function, called by the31 * sched_yield() function,to make a CPU context switch.32 * The current thread CPU context is identified by the <ctx_ current> pointer.33 * The new thread CPU context is identified by the <ctx_ne xt> pointer.30 * This assembly level function is called by the sched_yield() function, 31 * to make a CPU context switch. 32 * The current thread CPU context is identified by the <ctx_old> pointer. 33 * The new thread CPU context is identified by the <ctx_new> pointer. 34 34 * The architecture specific hal_cpu_context_t structure used to store a CPU context 35 35 * is defined in the architecture specific hal_context.c file. … … 45 45 46 46 /************************************************************************************* 47 * The hal_do_cpu_save() function is an assembly level function, called by the 48 * hal_cpu_context_save() functio to save the calling CPU register values to a 49 * CPU context identified by the <ctx> pointer. 47 * This assembly level function is called by the hal_cpu_context_fork() function. 48 * It save the calling CPU register values to a CPU context identified by <ctx>. 50 49 * This function does NOT modify any register before saving values into context. 51 50 * The architecture specific hal_cpu_context_t structure used to store a CPU context … … 57 56 void hal_do_cpu_save( void * ctx ); 58 57 58 /************************************************************************************* 59 * This assembly level function, is called by the hal_cpu_context_exec() function. 60 * It restore the calling CPU register values from a CPU context identified by <ctx>. 61 * The architecture specific hal_cpu_context_t structure used to store a CPU context 62 * is defined in the architecture specific hal_context.c file. 63 * When the restore is completed, it simply jumps to the address contained in ra_31. 64 * In ALMOS-MKH, ra_31 must contain a pointer on the eret() function, and c0_epc 65 * must contain the new main thread entry point. 66 ************************************************************************************* 67 * @ ctx : local pointer on CPU context. 68 ************************************************************************************/ 69 void hal_do_cpu_restore( void * ctx ); 70 59 71 #endif /* _HAL_SWITCH_H_ */ -
trunk/hal/generic/hal_syscall.h
r408 r457 25 25 #define _HAL_KERNEL_SYSCALL_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 /////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_user.h
r445 r457 25 25 #define _HAL_USER_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_shared_types.h> 28 28 29 29 ////////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_uspace.h
r407 r457 25 25 #define _HAL_USPACE_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 ////////////////////////////////////////////////////////////////////////////////////////// -
trunk/hal/generic/hal_vmm.h
r411 r457 25 25 #define _HAL_PPM_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <boot_info.h> 29 29 -
trunk/hal/tsar_mips32/Makefile
r444 r457 72 72 $(HAL_ARCH)/drivers/%.h \ 73 73 $(KERNEL)/kernel_config.h \ 74 $(HAL_ARCH)/core/hal_ types.h74 $(HAL_ARCH)/core/hal_kernel_types.h 75 75 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 76 76 … … 80 80 $(HAL)/generic/%.h \ 81 81 $(KERNEL)/kernel_config.h \ 82 $(HAL_ARCH)/core/hal_ types.h82 $(HAL_ARCH)/core/hal_kernel_types.h 83 83 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 84 84 … … 86 86 $(HAL_ARCH)/core/hal_kentry.h \ 87 87 $(KERNEL)/kernel_config.h \ 88 $(HAL_ARCH)/core/hal_ types.h88 $(HAL_ARCH)/core/hal_kernel_types.h 89 89 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 90 90 -
trunk/hal/tsar_mips32/core/hal_atomic.c
r62 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 26 26 //////////////////////////////////// -
trunk/hal/tsar_mips32/core/hal_context.c
r432 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_switch.h> 26 26 #include <memcpy.h> … … 136 136 } // end hal_cpu_context_alloc() 137 137 138 ///////////////////////////////////////////////// //139 // The following context slots are initialised :138 ///////////////////////////////////////////////// 139 // The following context slots are initialised 140 140 // GPR : a0_04 / sp_29 / ra_31 141 141 // CP0 : c0_sr / c0_th / c0_epc 142 142 // CP2 : c2_ptpr / c2_mode 143 /////////////////////////////////////////////////// 144 error_t hal_cpu_context_create( thread_t * thread ) 145 { 146 // allocate memory for a CPU context 147 error_t error = hal_cpu_context_alloc( thread ); 148 149 if( error ) return error; 150 143 ///////////////////////////////////////////////// 144 void hal_cpu_context_init( thread_t * thread ) 145 { 151 146 hal_cpu_context_t * context = (hal_cpu_context_t *)thread->cpu_context; 147 148 assert( (context != NULL ), __FUNCTION__, "CPU context not allocated" ); 152 149 153 150 // initialisation depends on thread type … … 173 170 context->c2_mode = 0x3; 174 171 } 175 176 return 0; 177 178 } // end hal_cpu_context_create() 172 } // end hal_cpu_context_init() 179 173 180 174 //////////////////////////////////////////// … … 243 237 assert( (current == child_ptr) , __FUNCTION__ , "current = %x / child = %x\n"); 244 238 } 245 246 239 } // end hal_cpu_context_fork() 240 241 ////////////////////////////////////////////// 242 void hal_cpu_context_exec( thread_t * thread ) 243 { 244 // re_initialize CPU context 245 hal_cpu_context_init( thread ); 246 247 // restore CPU registers ... and jump 248 hal_do_cpu_restore( (hal_cpu_context_t *)thread->cpu_context ); 249 250 } // end hal_cpu_context_exec() 247 251 248 252 ///////////////////////////////////////////////// … … 312 316 313 317 } // end hal_fpu_context_alloc() 318 319 ////////////////////////////////////////////// 320 void hal_fpu_context_init( thread_t * thread ) 321 { 322 hal_fpu_context_t * context = thread->fpu_context; 323 324 assert( (context != NULL) , __FUNCTION__ , "fpu context not allocated" ); 325 326 memset( context , 0 , sizeof(hal_fpu_context_t) ); 327 } 314 328 315 329 ////////////////////////////////////////// -
trunk/hal/tsar_mips32/core/hal_drivers.c
r407 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <chdev.h> 24 24 #include <hal_drivers.h> -
trunk/hal/tsar_mips32/core/hal_exception.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_irqmask.h> 26 26 #include <hal_special.h> … … 134 134 core_t * core = this->core; 135 135 136 // enable FPU 136 // enable FPU (in core SR) 137 137 hal_fpu_enable(); 138 138 139 // save FPU contextin current owner thread if required139 // save FPU register values in current owner thread if required 140 140 if( core->fpu_owner != NULL ) 141 141 { 142 142 if( core->fpu_owner != this ) 143 143 { 144 // save the FPU registers to current owner thread context 144 145 hal_fpu_context_save( XPTR( local_cxy , core->fpu_owner ) ); 146 147 // restore FPU registers from requesting thread context 148 hal_fpu_context_restore( this->fpu_context ); 149 150 // attach the FPU to the requesting thread 151 core->fpu_owner = this; 145 152 } 146 153 } 147 148 // attach the FPU to the requesting thread 149 hal_fpu_context_restore( this->fpu_context ); 150 core->fpu_owner = this; 154 else 155 { 156 // restore FPU registers from requesting thread context 157 hal_fpu_context_restore( this->fpu_context ); 158 159 // attach the FPU to the requesting thread 160 core->fpu_owner = this; 161 } 151 162 152 163 return EXCP_NON_FATAL; … … 206 217 uint32_t cycle = (uint32_t)hal_get_cycles(); 207 218 if( DEBUG_HAL_EXCEPTIONS < cycle ) 208 printk("\n[DBG] %s : thread %x enter / is_ins %d / %s / vaddr %x / cycle %d\n",209 __FUNCTION__, this , is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle);219 printk("\n[DBG] %s : thread %x in process %x enter / is_ins %d / %s / vaddr %x / cycle %d\n", 220 __FUNCTION__, this->trdid, process->pid, is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle); 210 221 #endif 211 222 … … 235 246 cycle = (uint32_t)hal_get_cycles(); 236 247 if( DEBUG_HAL_EXCEPTIONS < cycle ) 237 printk("\n[DBG] %s : thread %x exit / page-fault handled for vaddr = %x\n",238 __FUNCTION__ , this, bad_vaddr );248 printk("\n[DBG] %s : thread %x in process %x exit / page-fault handled for vaddr = %x\n", 249 __FUNCTION__, this->trdid, process->pid, bad_vaddr ); 239 250 #endif 240 251 … … 275 286 cycle = (uint32_t)hal_get_cycles(); 276 287 if( DEBUG_HAL_EXCEPTIONS < cycle ) 277 printk("\n[DBG] %s : thread %x exit / copy-on-write handled for vaddr = %x\n",278 __FUNCTION__ , this, bad_vaddr );288 printk("\n[DBG] %s : thread %x in process %x exit / copy-on-write handled for vaddr = %x\n", 289 __FUNCTION__, this->trdid, process->pid, bad_vaddr ); 279 290 #endif 280 291 … … 300 311 { 301 312 assert( false , __FUNCTION__ , 302 "thread %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n", 303 this, local_cxy, this->core->lid, excPC, bad_vaddr, (uint32_t)hal_get_cycles() ); 313 "thread %x in process %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n", 314 this->trdid, this->process->pid, local_cxy, this->core->lid, 315 excPC, bad_vaddr, (uint32_t)hal_get_cycles() ); 304 316 305 317 return EXCP_KERNEL_PANIC; … … 398 410 uint32_t cycle = (uint32_t)hal_get_cycles(); 399 411 if( DEBUG_HAL_EXCEPTIONS < cycle ) 400 printk("\n[DBG] %s : thread %x enter / core[%x,%d] / pid %x/ epc %x / xcode %x / cycle %d\n",401 __FUNCTION__, this , local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );412 printk("\n[DBG] %s : thread %x in process %x enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 413 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle ); 402 414 #endif 403 415 … … 458 470 cycle = (uint32_t)hal_get_cycles(); 459 471 if( DEBUG_HAL_EXCEPTIONS < cycle ) 460 printk("\n[DBG] %s : thread %x exit / core[%x,%d] / pid %x/ epc %x / xcode %x / cycle %d\n",461 __FUNCTION__, this , local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );472 printk("\n[DBG] %s : thread %x in process %x exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 473 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle ); 462 474 #endif 463 475 -
trunk/hal/tsar_mips32/core/hal_gpt.c
r445 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_gpt.h> 26 26 #include <hal_special.h> -
trunk/hal/tsar_mips32/core/hal_interrupt.c
r435 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <kernel_config.h> -
trunk/hal/tsar_mips32/core/hal_irqmask.c
r285 r457 23 23 */ 24 24 25 #include <hal_types.h> 25 #include <hal_kernel_types.h> 26 #include <hal_shared_types.h> 26 27 27 28 ////////////////////////////////////////// -
trunk/hal/tsar_mips32/core/hal_ppm.c
r443 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_ppm.h> 27 27 #include <hal_special.h> -
trunk/hal/tsar_mips32/core/hal_remote.c
r313 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_irqmask.h> 27 27 -
trunk/hal/tsar_mips32/core/hal_special.c
r425 r457 23 23 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <core.h> -
trunk/hal/tsar_mips32/core/hal_switch.S
r408 r457 26 26 .global hal_do_cpu_switch 27 27 .global hal_do_cpu_save 28 .global hal_do_cpu_restore 28 29 29 30 .set noat … … 90 91 sw $27, 33*4($26) /* save c2_mode to slot 33 */ 91 92 93 sync 94 92 95 /* restore new thread context */ 93 96 … … 144 147 mtc2 $27, $1 /* restore c2_mode from slot 33 */ 145 148 mtc0 $26, $12 /* restore c0_sr from slot 34 */ 146 147 sync148 149 149 150 jr $31 /* return to caller */ … … 211 212 nop 212 213 214 #--------------------------------------------------------------------------------- 215 # The hal_do_cpu_restore()function makes the following assumption: 216 # - register $4 contains a pointer on the target thread context. 217 #--------------------------------------------------------------------------------- 218 hal_do_cpu_restore: 219 220 move $26, $4 /* $26 <= &context */ 221 222 lw $27, 0*4($26) 223 mtc0 $27, $14 /* restore C0_epc from slot 0 */ 224 225 lw $1, 1*4($26) 226 lw $2, 2*4($26) 227 lw $3, 3*4($26) 228 lw $4, 4*4($26) 229 lw $5, 5*4($26) 230 lw $6, 6*4($26) 231 lw $7, 7*4($26) 232 lw $8, 8*4($26) 233 lw $9, 9*4($26) 234 lw $10, 10*4($26) 235 lw $11, 11*4($26) 236 lw $12, 12*4($26) 237 lw $13, 13*4($26) 238 lw $14, 14*4($26) 239 lw $15, 15*4($26) 240 lw $16, 16*4($26) 241 lw $17, 17*4($26) 242 lw $18, 18*4($26) 243 lw $19, 19*4($26) 244 lw $20, 20*4($26) 245 lw $21, 21*4($26) 246 lw $22, 22*4($26) 247 lw $23, 23*4($26) 248 lw $24, 24*4($26) 249 lw $25, 25*4($26) 250 251 lw $27, 26*4($26) 252 mthi $27 /* restore hi from slot 26 */ 253 lw $27, 27*4($26) 254 mtlo $27 /* restore lo from slot 27 */ 255 256 lw $28, 28*4($26) 257 lw $29, 29*4($26) 258 lw $30, 30*4($26) 259 lw $31, 31*4($26) /* restore ra from slot 31 */ 260 261 lw $27, 32*4($26) 262 mtc2 $27, $0 /* restore c2_ptpr from slot 32 */ 263 264 lw $27, 35*4($26) 265 mtc0 $27, $4, 2 /* restore c0_th from slot 35 */ 266 267 lw $27, 33*4($26) 268 lw $26, 34*4($26) 269 270 mtc2 $27, $1 /* restore c2_mode from slot 33 */ 271 mtc0 $26, $12 /* restore c0_sr from slot 34 */ 272 273 jr $31 /* return to caller */ 274 nop 275 213 276 .set reorder 214 277 .set at -
trunk/hal/tsar_mips32/core/hal_syscall.c
r425 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_syscall.h> 26 26 #include <do_syscall.h> … … 48 48 enter_uzone = (uint32_t *)this->uzone_current; 49 49 50 //printk("\n@@@ enter %s : thread = %x / enter_uzone = %x / EPC = %x\n",51 //__FUNCTION__ , this , enter_uzone , enter_uzone[UZ_EPC] );52 53 50 // get syscall arguments from uzone 54 51 service_num = enter_uzone[UZ_V0]; … … 71 68 exit_uzone = (uint32_t *)this->uzone_current; 72 69 73 //printk("\n@@@ exit %s : thread = %x / exit_uzone = %x / EPC = %x\n",74 //__FUNCTION__ , this , exit_uzone , exit_uzone[UZ_EPC] );75 76 70 // set return value to uzone 77 71 exit_uzone[UZ_V0] = retval; -
trunk/hal/tsar_mips32/core/hal_uspace.c
r425 r457 25 25 #include <errno.h> 26 26 #include <vmm.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_uspace.h> 29 29 #include <hal_irqmask.h> -
trunk/hal/tsar_mips32/core/hal_vmm.c
r411 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_vmm.h> 27 27 #include <hal_gpt.h> -
trunk/hal/tsar_mips32/drivers/soclib_pic.c
r451 r457 137 137 #endif 138 138 139 // analyse status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI)139 // analyse status and handle up to 3 pending IRQs (one WTI, one HWI, one PTI) 140 140 141 141 if( wti_status ) // pending WTI … … 150 150 #if DEBUG_HAL_IRQS 151 151 if (DEBUG_HAL_IRQS < cycle ) 152 printk("\n[DBG] %s : core[%x,%d] received anIPI\n", __FUNCTION__ , local_cxy , core->lid );152 printk("\n[DBG] %s : core[%x,%d] handling IPI\n", __FUNCTION__ , local_cxy , core->lid ); 153 153 #endif 154 154 // acknowledge IRQ (this require an XCU read) … … 156 156 157 157 // check RPC FIFO, and activate or create a RPC thread 158 // condition is always true, but we must use the ack value 158 // condition is always true, but we use the ack value 159 // to avoid a GCC warning 159 160 if( ack + 1 ) rpc_check(); 160 161 } … … 182 183 #if DEBUG_HAL_IRQS 183 184 if (DEBUG_HAL_IRQS < cycle ) 184 printk("\n[DBG] %s : core[%x,%d] receivedexternal WTI %d\n",185 printk("\n[DBG] %s : core[%x,%d] handling external WTI %d\n", 185 186 __FUNCTION__ , local_cxy , core->lid , index ); 186 187 #endif … … 216 217 #if DEBUG_HAL_IRQS 217 218 if (DEBUG_HAL_IRQS < cycle ) 218 printk("\n[DBG] %s : core[%x,%d] receivedHWI %d\n",219 printk("\n[DBG] %s : core[%x,%d] handling HWI %d\n", 219 220 __FUNCTION__ , local_cxy , core->lid , index ); 220 221 #endif … … 232 233 #if DEBUG_HAL_IRQS 233 234 if (DEBUG_HAL_IRQS < cycle ) 234 printk("\n[DBG] %s : core[%x,%d] receivedPTI %d\n",235 printk("\n[DBG] %s : core[%x,%d] handling PTI %d\n", 235 236 __FUNCTION__ , core->lid , local_cxy , index ); 236 237 #endif … … 239 240 240 241 // execute all actions related to TICK event 241 // condition is always true, but we must use the ack value 242 // condition is always true, but we use the ack value 243 // to avoid a GCC warning 242 244 if( ack + 1 ) core_clock( core ); 243 245 } … … 515 517 { 516 518 // calling core local index 517 lid_t lid = CURRENT_ CORE->lid;519 lid_t lid = CURRENT_THREAD->core->lid; 518 520 519 521 // get XCU segment base … … 533 535 { 534 536 // calling core local index 535 lid_t lid = CURRENT_ CORE->lid;537 lid_t lid = CURRENT_THREAD->core->lid; 536 538 537 539 // get XCU segment base -
trunk/hal/tsar_mips32/drivers/soclib_tty.c
r451 r457 272 272 xptr_t parent_main_xp; // local pointer on parent process main thread 273 273 274 // get TXT chdev channel, direction and server thread274 // get TXT chdev channel, direction, server thread, and server core 275 275 channel = chdev->channel; 276 276 is_rx = chdev->is_rx; … … 455 455 thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_ISR ); 456 456 457 // send IPI to core running server thread 458 dev_pic_send_ipi( local_cxy , server_lid ); 457 // send IPI to core running server thread if required 458 if( server_lid != CURRENT_THREAD->core->lid ) 459 { 460 dev_pic_send_ipi( local_cxy , server_lid ); 461 } 459 462 } 460 463 else … … 501 504 thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_ISR ); 502 505 503 // send IPI to core running server thread 504 dev_pic_send_ipi( local_cxy , server_lid ); 506 // send IPI to core running server thread if required 507 if( server_lid != CURRENT_THREAD->core->lid ) 508 { 509 dev_pic_send_ipi( local_cxy , server_lid ); 510 } 505 511 506 512 } // end TX -
trunk/hal/tsar_mips32/drivers/soclib_tty.h
r436 r457 2 2 * soclib_tty.c - soclib tty driver definition. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 29 29 /**************************************************************************************** 30 30 * This driver supports the vci_tty_tsar component. 31 * It implements the generic TXT device API:31 * Regarding read/write request, it implements the generic TXT device API: 32 32 * - transfer one single character from TTY to command "buffer" if to_mem is non-zero. 33 33 * - transfer "count" characters from command "buffer" to TTY if "to_mem is zero. 34 * It handles asynchronous control characters (^C / ^Z), that are translated to signals 35 * transmited to the TXT owner process (foreground process). 34 36 ***************************************************************************************/ 35 37 … … 101 103 /**************************************************************************************** 102 104 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ, even if 103 * The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the 105 * there is two different channel devices for TX and RX transfers. 106 * 107 * As the <chdev> argument is a local pointer, this ISR is always executed by a core 108 * that is in the same cluster as the core running the DEV server thread. 109 * 110 * - The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the 104 111 * TTY_STATUS register, when the TTY_RX_IRQ_ENABLE is non zero, indicating that 105 112 * the TTY_READ buffer is full and can be read. 106 * 113 * - The TX_IRQ is activated as soon as the TTY_STATUS_TX_FULL bit is 0 in the 107 114 * TTY_STATUS register, when the TTY_TX_IRQ_ENABLE is non zero, indicating that 108 115 * the TTY_WRITE buffer is empty, and can be written. 109 * WARNING : In ALMOS-MKH, the RX_IRQ is always enabled to catch the control signals, 116 * 117 * The RX_IRQ is always enabled to catch the control characters (^Z / ^C), 110 118 * but the TX_IRQ is dynamically enabled by the TXT_WRITE command, and disabled when 111 119 * the command is completed. 112 120 * 113 * 1) The ISR first read the TTY_STATUS to get the current state of the TTY_READ and 114 * the TTY_WRITE buffers. 121 * For normal characters The ISR uses two private TTY_RX and TTY_TX software FIFOs 122 * (two FIFOs per channel) to communicates with the DEV server thread executing the 123 * soclib_tty_cmd() function. 124 125 * For an RX transfer, this ISR executes a while loop moving bytes until the source 126 * TTY_READ buffer is empty: 127 * 1) The ISR read one byte from the TTY_READ register and acknowledge the RX_IRQ. 128 * 2) if the byte is a ^Z character, it uses a multicast RPC to block all treads of 129 * the TXT owner process, and transfer TXT ownership to another process of the group. 130 * 3) if the byte is a ^C character, it removes the process from the TXT group, and send 131 * a multicast RPC to delete all threads of the TXT owner process. 132 * 4) if the byte is a normal character and the destination TTY_RX_FIFO is not full, 133 * it writes the byte to this FIFO, unblock the TXT_RX server thread, and send an IPI 134 * to this server thread (only if it is running on another core than the ISR). 135 * 5) It discards the byte if the TTY_RX_FIFO is full, with a warning message on TXT0. 115 136 * 116 * 2) It try to read the first command registered in the server thread queue associated 117 * to the TTY channel 118 * 119 * 2) The ISR handles the RX when the TTY_READ buffer is full : 120 * . it read the available character from the TTY_READ buffer, and this 121 * acknowledges the RX_IRQ. 122 * . if it is a control character ( ^C / ^D / ^Z ) it translate it to the proper 123 * signal and execute the relevant sigaction for the foreground process. 124 * . if it is a normal character, it try to get the first command registered in the 125 * server thread queue. If it is a TXT_READ, it returns this character to the 126 * command buffer in the client thread. 127 * 128 * 3) The ISR handles the TX when the TTY_WRITE buffer is empty and a TXT_WRITE 129 * . it try to get it copies the 130 * character to the command buffer, acknowledges the TTY_RX_IRQ, and unblock the 131 * associated server thread. 132 133 * . the control characters ^C / ^D / ^Z are directly handled by the ISR and 134 * translated to the foreground process. 135 136 * - the 137 the TXT_READ and TXT_WRITE commands. 138 * It gets the command arguments from the first client thread in the TXT chdev queue: 139 * - if TXT_READ, it transfers one byte from the TTY_READ_REG to the command buffer. 140 * It simply returns for retry if TTY_READ_REG is empty. 141 * - if TXT_WRITE, it tries to transfer several bytes from the command buffer to the 142 * TTY_WRITE_REG. If the TTY_WRITE_REG is full, it updates the "count" and "buffer" 143 * command arguments and returns for retry. 144 * When the I/O operation is completed, it sets the status field in the command, unblocks 145 * the server thread, and unblocks the client thread. 137 * For a TX transfer, this ISR executes a while loop moving bytes until the source 138 * TTY_TX_FIFO is empty: 139 * 1) if the destination TTY_WRITE register is not full, it moves the byte from the 140 * TTY_TX_FIFO to the TTY_WRITE register. 141 * 2) if the TTY_WRITE register is full, it polls (busy waiting) the TTY_STATUS register, 142 * until the TTY_WRITE register is empty. 143 * 3) when the source TTY_TX_FIFO is empty, this ISR disable the TTY_TX_IRQ, unblock 144 * the TXT_TX server thread, and send an IPI to this server thread (only if it is 145 * running on another core than the ISR). 146 146 **************************************************************************************** 147 147 * @ chdev : local pointer on TXT chdev descriptor. -
trunk/hal/x86_64/Makefile
r444 r457 72 72 drivers/%.h \ 73 73 $(KERNEL)/kernel_config.h \ 74 core/hal_ types.h74 core/hal_kernel_types.h 75 75 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 76 76 … … 80 80 $(HAL)/generic/%.h \ 81 81 $(KERNEL)/kernel_config.h \ 82 core/hal_ types.h82 core/hal_kernel_types.h 83 83 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 84 84 … … 88 88 core/hal_segmentation.h \ 89 89 $(KERNEL)/kernel_config.h \ 90 core/hal_ types.h90 core/hal_kernel_types.h 91 91 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 92 92 … … 96 96 core/hal_segmentation.h \ 97 97 $(KERNEL)/kernel_config.h \ 98 core/hal_ types.h98 core/hal_kernel_types.h 99 99 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 100 100 … … 107 107 core/hal_internal.h \ 108 108 $(KERNEL)/kernel_config.h \ 109 core/hal_ types.h109 core/hal_kernel_types.h 110 110 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 111 111 … … 114 114 core/hal_segmentation.h \ 115 115 $(KERNEL)/kernel_config.h \ 116 core/hal_ types.h116 core/hal_kernel_types.h 117 117 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 118 118 … … 121 121 core/hal_boot.h \ 122 122 $(KERNEL)/kernel_config.h \ 123 core/hal_ types.h123 core/hal_kernel_types.h 124 124 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 125 125 … … 127 127 core/hal_acpi.h \ 128 128 $(KERNEL)/kernel_config.h \ 129 core/hal_ types.h129 core/hal_kernel_types.h 130 130 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 131 131 … … 133 133 core/hal_apic.h \ 134 134 $(KERNEL)/kernel_config.h \ 135 core/hal_ types.h135 core/hal_kernel_types.h 136 136 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 137 137 138 138 $(HAL_ARCH)/build/core/x86_printf.o: core/x86_printf.c \ 139 139 $(KERNEL)/kernel_config.h \ 140 core/hal_ types.h140 core/hal_kernel_types.h 141 141 $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $< 142 142 -
trunk/hal/x86_64/core/hal_acpi.c
r348 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_boot.h> 24 24 #include <hal_acpi.h> -
trunk/hal/x86_64/core/hal_apic.c
r327 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_boot.h> 24 24 #include <hal_register.h> -
trunk/hal/x86_64/core/hal_atomic.c
r234 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_internal.h> 24 24 -
trunk/hal/x86_64/core/hal_context.c
r368 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <memcpy.h> 24 24 #include <thread.h> -
trunk/hal/x86_64/core/hal_drivers.c
r346 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <chdev.h> 24 24 #include <hal_drivers.h> -
trunk/hal/x86_64/core/hal_exception.c
r403 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_irqmask.h> 24 24 #include <hal_exception.h> -
trunk/hal/x86_64/core/hal_gpt.c
r408 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_boot.h> /* XXX */ 24 24 #include <hal_gpt.h> -
trunk/hal/x86_64/core/hal_init.c
r365 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_boot.h> 24 24 #include <hal_multiboot.h> -
trunk/hal/x86_64/core/hal_interrupt.c
r344 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <kernel_config.h> 24 24 #include <thread.h> -
trunk/hal/x86_64/core/hal_irqmask.c
r370 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_internal.h> 24 24 #include <hal_segmentation.h> -
trunk/hal/x86_64/core/hal_ppm.c
r407 r457 21 21 22 22 #include <kernel_config.h> 23 #include <hal_ types.h>23 #include <hal_kernel_types.h> 24 24 #include <hal_ppm.h> 25 25 #include <hal_special.h> -
trunk/hal/x86_64/core/hal_remote.c
r314 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_internal.h> 24 24 -
trunk/hal/x86_64/core/hal_special.c
r371 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_apic.h> 24 24 #include <hal_special.h> -
trunk/hal/x86_64/core/hal_syscall.c
r145 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_syscall.h> 26 26 #include <do_syscall.h> -
trunk/hal/x86_64/core/hal_types.h
r407 r457 1 1 /* 2 * hal_ types.h - common kernel types for x86_642 * hal_kernel_types.h - common kernel types for x86_64 3 3 * 4 4 * Author Alain Greiner (2016) -
trunk/hal/x86_64/core/hal_uspace.c
r407 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_irqmask.h> -
trunk/hal/x86_64/core/x86_printf.c
r242 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <hal_boot.h> 24 24 #include <hal_internal.h> -
trunk/hal/x86_64/drivers/ioc_ata.h
r215 r457 24 24 25 25 #include <chdev.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 28 28 void ioc_ata_init(chdev_t *chdev); -
trunk/hal/x86_64/drivers/pic_apic.c
r404 r457 20 20 */ 21 21 22 #include <hal_ types.h>22 #include <hal_kernel_types.h> 23 23 #include <chdev.h> 24 24 #include <pic_apic.h> -
trunk/hal/x86_64/drivers/pic_apic.h
r280 r457 23 23 #define _PIC_APIC_H_ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 27 27 void pic_apic_init(chdev_t *pic);
Note: See TracChangeset
for help on using the changeset viewer.