Skip to content

Commit

Permalink
hal/ia32: optimize cr0 restoration
Browse files Browse the repository at this point in the history
JIRA: RTOS-954
  • Loading branch information
badochov committed Nov 15, 2024
1 parent 7c9049d commit 765fd16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions hal/ia32/_exceptions.S
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,18 @@ exception_popContext:
popw %ds
/* FPU context */
testl $CR0_TS_BIT, FPU_CONTEXT_SIZE(%esp)
jz .exception_popFPU
movl %eax, FPU_CONTEXT_SIZE(%esp)
movl %cr0, %eax
jz .exception_popFPU
orl $CR0_TS_BIT, %eax
movl %eax, %cr0
addl $FPU_CONTEXT_SIZE, %esp
popl %eax
iret
.exception_popFPU:
andl $~CR0_TS_BIT, %eax
mov %eax, %cr0
clts
frstor (%esp)
addl $FPU_CONTEXT_SIZE, %esp
popl %eax
addl $FPU_CONTEXT_SIZE + 4, %esp
iret
.size exception_popContext, .-exception_popContext

Expand Down
8 changes: 3 additions & 5 deletions hal/ia32/_interrupts.S
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,18 @@ interrupts_popContext:
popw %ds
/* FPU context */
testl $CR0_TS_BIT, FPU_CONTEXT_SIZE(%esp)
jz .Linterrupts_popFPU
movl %eax, FPU_CONTEXT_SIZE(%esp)
movl %cr0, %eax
jz .Linterrupts_popFPU
orl $CR0_TS_BIT, %eax
movl %eax, %cr0
addl $FPU_CONTEXT_SIZE, %esp
popl %eax
iret
.Linterrupts_popFPU:
andl $~CR0_TS_BIT, %eax
mov %eax, %cr0
clts
frstor (%esp)
addl $FPU_CONTEXT_SIZE, %esp
popl %eax
addl $FPU_CONTEXT_SIZE + 4, %esp
iret
interrupts_popContextUnlocked:
cli
Expand Down

0 comments on commit 765fd16

Please sign in to comment.