Changeset 418 for trunk/hal/tsar_mips32/core
- Timestamp:
- Jan 8, 2018, 2:25:39 PM (7 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_kentry.S
r408 r418 99 99 100 100 #------------------------------------------------------------------------------------ 101 # This code is executed when the core is in user mode: 101 # This code is executed when the core is in user mode, 102 # to handle a syscall, an interrupt, or an user exception. 102 103 # - save current c2_mode in $26. 103 104 # - set MMU OFF. 104 # - save user stack pointer in $27.105 # - set kernel stack pointer in $29 .105 # - copy user stack pointer in $27 to be saved in uzone. 106 # - set kernel stack pointer in $29 == top_kernel_stack(this). 106 107 107 108 user_mode: … … 117 118 118 119 #------------------------------------------------------------------------------------ 119 # This code is executed when the core is already in kernel mode: 120 # This code is executed when the core is already in kernel mode, 121 # after a syscall, to handle an interrupt. 120 122 # - save current c2_mode in $26. 121 123 # - set MMU OFF. 122 # - savecurrent kernel stack pointer in $27.124 # - copy current kernel stack pointer in $27. 123 125 124 126 kernel_mode: … … 134 136 # - $26 contains the previous c2_mode value. 135 137 # - $27 contains the previous sp value (can be usp or ksp). 136 # - $29 contains the kernel stack pointer.138 # - $29 contains the curren kernel stack pointer. 137 139 # We execute the following actions: 138 # - allocate an uzone in kernel stack, decrementing $29.140 # - decrement $29 to allocate an uzone in kernel stack 139 141 # - save relevant GPR, CP0 and CP2 registers to uzone. 140 142 # - set the SR in kernel mode: IRQ disabled, clear exl. … … 198 200 mtc0 $3, $12 # set new c0_sr 199 201 200 #if CONFIG_KENTRY_DEBUG 202 #----------------------- 203 #if CONFIG_KENTRY_DEBUG 201 204 202 205 # display "enter" message … … 207 210 jal putx 208 211 nop 212 la $4, msg_cycle 213 jal puts 214 nop 215 jal hal_time_stamp 216 nop 217 move $4, $2 218 jal putx 219 nop 209 220 la $4, msg_crlf 210 221 jal puts … … 270 281 jal puts 271 282 nop 272 283 273 284 #endif 285 #----- 274 286 275 287 #------------------------------------------------------------------------------------ 276 # This code update the uzone field in thread descriptor, 277 # and call the relevant Interrupt / Exception / Syscall handler, 288 # This code calls the relevant Interrupt / Exception / Syscall handler, 278 289 # depending on XCODE in CP0_CR. 279 # assumption: $29 contains the kernel stack pointer, that is the uzone base. 290 # In case of syscall or exception, it set the "uzone" pointer in thread descriptor, 291 # that is used by the hal_do_syscall() & hal_do_exception() functions. 292 # WARNING: This "uzone" pointer is NOT modified in case of interrupt, 293 # because syscalls can be interrupted, and we want preserve this pointer. 280 294 281 295 mfc0 $17, $13 # $17 <= CR 282 296 andi $17, $17, 0x3F # $17 <= XCODE 283 284 mfc0 $4, $4, 2 # $4 <= pointer on thread desc285 sw $29, 8($4) # update uzone pointer in thread desc286 287 297 ori $8, $0, 0x20 288 298 beq $8, $17, cause_sys # go to syscall handler … … 292 302 293 303 cause_excp: 304 mfc0 $4, $4, 2 # get pointer on thread desc 305 sw $29, 8($4) # update uzone pointer in thread desc 294 306 jal hal_do_exception # call exception handler 295 307 nop … … 298 310 299 311 cause_sys: 312 mfc0 $4, $4, 2 # get pointer on thread desc 313 sw $29, 8($4) # update uzone pointer in thread desc 300 314 jal hal_do_syscall # call syscall handler 301 315 nop … … 309 323 # ----------------------------------------------------------------------------------- 310 324 # Kernel exit 311 # The pointer on uzone is supposed to be contained in $29 325 # - All registers saved in the uzone are restored, using the pointer on uzone, 326 # that is contained in $29. 327 # - The "uzone" field in thread descriptor, that has beeen modified at kernel entry 328 # is restored from value contained in the uzone[UZ_SP] slot. 312 329 # ----------------------------------------------------------------------------------- 330 313 331 kentry_exit: 314 332 333 #---------------------- 315 334 #if CONFIG_KENTRY_DEBUG 316 335 … … 322 341 jal putx 323 342 nop 343 la $4, msg_cycle 344 jal puts 345 nop 346 jal hal_time_stamp 347 nop 348 move $4, $2 349 jal putx 350 nop 324 351 la $4, msg_crlf 325 352 jal puts … … 387 414 388 415 #endif 416 #----- 389 417 390 418 # restore registers from uzone … … 475 503 .align 2 476 504 .asciiz "\nexit kernel : &uzone = " 477 505 msg_cycle: 506 .align 2 507 .asciiz " / cycle = " 508 -
trunk/hal/tsar_mips32/core/hal_syscall.c
r416 r418 29 29 #include <hal_kentry.h> 30 30 31 // @@@ 32 // __attribute__((section(".kdata"))) uint32_t * enter_uzone; 33 // __attribute__((section(".kdata"))) uint32_t * exit_uzone; 34 // @@@ 31 35 32 36 ///////////////////// … … 69 73 exit_uzone = (uint32_t *)this->uzone; 70 74 75 // printk("\n@@@ %s exit : enter_uzone = %x / exit_uzone = %x\n", 76 // __FUNCTION__ , enter_uzone , exit_uzone ); 77 71 78 // set syscall return value to uzone 72 79 exit_uzone[UZ_V0] = retval; … … 75 82 exit_uzone[UZ_EPC] += 4; 76 83 84 hal_fence(); 77 85 }
Note: See TracChangeset
for help on using the changeset viewer.