Changeset 625 for trunk/hal/tsar_mips32/core/hal_kentry.S
- Timestamp:
- Apr 10, 2019, 10:09:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_kentry.S
r438 r625 4 4 * AUthors Ghassan Almaless (2007,2008,2009,2010,2011,2012) 5 5 * Mohamed Lamine Karaoui (2015) 6 * Alain Greiner (201 7)6 * Alain Greiner (2016,2017,2018,2019) 7 7 * 8 8 * Copyright (c) UPMC Sorbonne Universites … … 87 87 #------------------------------------------------------------------------------------ 88 88 # Kernel Entry point for Interrupt / Exception / Syscall 89 # The c2_dext and c2_iext CP2 registersmust have been previously set90 # to "local_cxy", because the kernel run with MMU desactivated.89 # The c2_dext CP2 register must have been previously set 90 # to "local_cxy", because the kernel run with data MMU desactivated. 91 91 #------------------------------------------------------------------------------------ 92 92 … … 96 96 andi $26, $26, 0x10 # test User Mode bit 97 97 beq $26, $0, kernel_mode # jump if core already in kernel 98 ori $27, $0, 0x 3 # $27 <= code forMMU OFF98 ori $27, $0, 0xB # $27 <= code data MMU OFF 99 99 100 100 #------------------------------------------------------------------------------------ … … 102 102 # to handle a syscall, an interrupt, or an user exception. 103 103 # - save current c2_mode in $26. 104 # - set MMU OFF.104 # - set data MMU OFF. 105 105 # - copy user stack pointer in $27 to be saved in uzone. 106 # - set kernel stack pointer in $29 == top_kernel_stack(this).106 # - set kernel stack pointer in $29 (kernel stack empty at firts entry). 107 107 108 108 user_mode: 109 109 110 110 mfc2 $26, $1 # $26 <= c2_mode 111 mtc2 $27, $1 # set MMU OFF111 mtc2 $27, $1 # set data MMU OFF 112 112 move $27, $29 # $27 <= user stack pointer 113 113 mfc0 $29, $4, 2 # get pointer on thread descriptor from c0_th … … 121 121 # after a syscall, to handle an interrupt, or to handle a non-fatal exception. 122 122 # - save current c2_mode in $26. 123 # - set MMU OFF.123 # - set data MMU OFF. 124 124 # - copy current kernel stack pointer in $27. 125 125 … … 127 127 128 128 mfc2 $26, $1 # $26 <= c2_mode 129 mtc2 $27, $1 # set MMU OFF129 mtc2 $27, $1 # set data MMU OFF 130 130 move $27, $29 # $27 <= current kernel stack pointer 131 131 … … 133 133 # This code is executed in both modes (user or kernel): 134 134 # The assumptions are: 135 # - c2_mode contains the MMU OFF value.135 # - c2_mode contains the data MMU OFF value. 136 136 # - $26 contains the previous c2_mode value. 137 137 # - $27 contains the previous sp value (can be usp or ksp). … … 139 139 # We execute the following actions: 140 140 # - decrement $29 to allocate an uzone in kernel stack 141 # - save relevantGPR, CP0 and CP2 registers to uzone.142 # - set the SR in kernel mode: IRQ disabled, clear exl.141 # - save GPR, CP0 and CP2 registers to uzone. 142 # - set the SR in kernel mode: IRQ disabled, clear EXL. 143 143 144 144 unified_mode: … … 195 195 sw $26, (UZ_MODE*4)($29) # save previous c2_mode (can be user or kernel) 196 196 197 mfc0 $3, $12 197 mfc0 $3, $12 # $3 <= c0_sr 198 198 srl $3, $3, 5 199 199 sll $3, $3, 5 # reset 5 LSB bits … … 216 216 nop 217 217 move $4, $2 218 jal putd 219 nop 220 la $4, msg_crlf 221 jal puts 222 nop 223 # display saved CR value 224 la $4, msg_cr 225 jal puts 226 nop 227 lw $4, (UZ_CR*4)($29) 218 228 jal putx 219 229 nop … … 286 296 287 297 #------------------------------------------------------------------------------------ 288 # This code handle the uzone pointers stack, and calls the relevant298 # This code handle the two-slots uzone pointers stack, and calls the relevant 289 299 # Interrupt / Exception / Syscall handler, depending on XCODE in CP0_CR. 290 300 # Both the hal_do_syscall() and the hal_do_exception() functions use … … 338 348 # - All registers saved in the uzone are restored, using the pointer on uzone, 339 349 # that is contained in $29. 340 # - The " uzone" field in thread descriptor, that has beeen modified at kernel entry341 # is restored from value contained in the uzone[UZ_SP] slot.350 # - The "current_uzone" pointer in thread descriptor, that has beeen modified at 351 # kernel entry is restored from value contained in the uzone[UZ_SP] slot. 342 352 # ----------------------------------------------------------------------------------- 343 353 … … 365 375 nop 366 376 move $4, $2 377 jal putd 378 nop 379 la $4, msg_crlf 380 jal puts 381 nop 382 # display saved CR value 383 la $4, msg_cr 384 jal puts 385 nop 386 lw $4, (UZ_CR*4)($29) 367 387 jal putx 368 388 nop … … 479 499 480 500 lw $26, (UZ_MODE*4)($27) 481 mtc2 $26, $1 # restore CP2_MODEfrom uzone501 mtc2 $26, $1 # restore c2_mode from uzone 482 502 483 503 # ----------------------------------------------------------------------------------- … … 494 514 .section .kdata 495 515 516 msg_cr: 517 .align 2 518 .asciiz "- UZ_CR = " 496 519 msg_sp: 497 520 .align 2
Note: See TracChangeset
for help on using the changeset viewer.