Changeset 425 for trunk/hal/tsar_mips32/core/hal_kentry.S
- Timestamp:
- Jan 29, 2018, 5:57:57 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_kentry.S
r418 r425 119 119 #------------------------------------------------------------------------------------ 120 120 # This code is executed when the core is already in kernel mode, 121 # after a syscall, to handle an interrupt .121 # after a syscall, to handle an interrupt, or to handle a non-fatal exception. 122 122 # - save current c2_mode in $26. 123 123 # - set MMU OFF. … … 286 286 287 287 #------------------------------------------------------------------------------------ 288 # This code calls the relevant Interrupt / Exception / Syscall handler, 289 # depending on XCODE in CP0_CR. 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. 294 288 # This code handle the uzone pointers stack, and calls the relevant 289 # Interrupt / Exception / Syscall handler, depending on XCODE in CP0_CR. 290 # Both the hal_do_syscall() and the hal_do_exception() functions use 291 # the values saved in the "uzone", but a syscall can be interrupted 292 # by an interrupt, or by a non-fatal exception. Therefore, we need 293 # to handle a two-slots "stack of uzones", implemented in the kernel stack, 294 # using the two "current_uzone" and "previous_uzone" pointers in thread descriptor. 295 # - at kernel_entry, we copy the "current_uzone" pointer to the "previous_uzone" 296 # slot, and copy the "$29" stack pointer to the "current_uzone" slot. 297 # - at kernel_exit, we simply restore the "previous_uzone" value to the 298 # "current_uzone" slot. 299 # For a syscall, the hal_do_syscall() function increment the uzone[EPC] 300 # slot and set the return value in the uzone[V0] slot before returning. 301 302 # update "current_uzone" and "previous_uzone" pointers 303 mfc0 $4, $4, 2 # $4 <= pointer on thread desc 304 lw $5, 8($4) # $5 <= current uzone pointer trom thread 305 sw $29, 8($4) # current uzone pointer <= $29 306 sw $5, 12($4) # previous uzone pointer <= current 307 308 # analyse XCODE to call relevant handler 295 309 mfc0 $17, $13 # $17 <= CR 296 andi $17, $17, 0x3F# $17 <= XCODE310 andi $17, $17, 0x3F # $17 <= XCODE 297 311 ori $8, $0, 0x20 298 312 beq $8, $17, cause_sys # go to syscall handler … … 302 316 303 317 cause_excp: 304 mfc0 $4, $4, 2 # get pointer on thread desc 305 sw $29, 8($4) # update uzone pointer in thread desc 318 306 319 jal hal_do_exception # call exception handler 307 320 nop … … 310 323 311 324 cause_sys: 312 mfc0 $4, $4, 2 # get pointer on thread desc 313 sw $29, 8($4) # update uzone pointer in thread desc 325 314 326 jal hal_do_syscall # call syscall handler 315 327 nop … … 318 330 319 331 cause_int: 332 320 333 jal hal_do_interrupt # call interrupt handler 321 334 nop … … 330 343 331 344 kentry_exit: 345 346 # restore "current_uzone" pointer 347 mfc0 $4, $4, 2 # $4 <= pointer on thread desc 348 lw $5, 12($4) # $5 <= previous uzone pointer from thread 349 sw $5, 8($4) # current uzone pointer <= previous 332 350 333 351 #----------------------
Note: See TracChangeset
for help on using the changeset viewer.