The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
preempt_callback.S
1 /**
2  * @file arch/x86/preempt_callback.S
3  *
4  * @brief Userspace callback for preĆ«mptive Time Warp
5  *
6  * This callback is used to transfer back control from kernel space to
7  * platform space when an APIC interrupt is received.
8  *
9  * @copyright
10  * Copyright (C) 2008-2019 HPDCS Group
11  * https://hpdcs.github.io
12  *
13  * This file is part of ROOT-Sim (ROme OpTimistic Simulator).
14  *
15  * ROOT-Sim is free software; you can redistribute it and/or modify it under the
16  * terms of the GNU General Public License as published by the Free Software
17  * Foundation; only version 3 of the License applies.
18  *
19  * ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY
20  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21  * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License along with
24  * ROOT-Sim; if not, write to the Free Software Foundation, Inc.,
25  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26  * @author Alessandro Pellegrini
27  *
28  * @date March, 2015
29  */
30 
31 .file "preempt_callback.S"
32 .extern preempt
33 .extern return_from_kernel
34 
35 #ifdef HAVE_PREEMPTION
36 
37 #include <arch/asm_defines.h>
38 
39 .text
40 .globl preempt_callback
41 .type preempt_callback, @function
42 
43 preempt_callback:
44  push %rbp
45  push %rax
46 
47  lahf
48  seto %al
49  pushq %rax
50 
51  push %rbx
52  push %rcx
53  push %rdx
54  push %rdi
55  push %rsi
56 
57  push %r8
58  push %r9
59  push %r10
60  push %r11
61  push %r12
62  push %r13
63  push %r14
64  push %r15
65 
66  subq $16, %rsp
67  movsd %xmm0, (%rsp)
68  subq $16, %rsp
69  movsd %xmm1, (%rsp)
70 
71  call preempt
72 
73  movsd (%rsp), %xmm1
74  addq $16, %rsp
75  movsd (%rsp), %xmm0
76  addq $16, %rsp
77 
78  pop %r15
79  pop %r14
80  pop %r13
81  pop %r12
82  pop %r11
83  pop %r10
84  pop %r9
85  pop %r8
86 
87  pop %rsi
88  pop %rdi
89  pop %rdx
90  pop %rcx
91  pop %rbx
92 
93  pop %rax
94  addb $0x7f, %al
95  sahf
96 
97  pop %rax
98  pop %rbp
99  retq
100 
101 .size preempt_callback, .-preempt_callback
102 
103 #endif /* HAVE_PREEMPT */