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 18, 2024
1 parent 7d65b73 commit 709b931
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 @@ -98,20 +98,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 @@ -114,20 +114,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:
popl %esp
Expand Down

0 comments on commit 709b931

Please sign in to comment.