aboutsummaryrefslogtreecommitdiff
path: root/drivers/external_drivers/debug_tools/vtunedk/src/sys64.S
blob: 70abf6442b2e8e3eff246f1f3eaccb799b72785a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#     Copyright (C) 2002-2014 Intel Corporation.  All Rights Reserved.
# 
#     This file is part of SEP Development Kit
# 
#     SEP Development Kit is free software; you can redistribute it
#     and/or modify it under the terms of the GNU General Public License
#     version 2 as published by the Free Software Foundation.
# 
#     SEP Development Kit is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with SEP Development Kit; if not, write to the Free Software
#     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# 
#     As a special exception, you may use this file as part of a free software
#     library without restriction.  Specifically, if other files instantiate
#     templates or use macros or inline functions from this file, or you compile
#     this file and link it with other files to produce an executable, this
#     file does not by itself cause the resulting executable to be covered by
#     the GNU General Public License.  This exception does not however
#     invalidate any other reasons why the executable file might be covered by
#     the GNU General Public License.


#include <asm/dwarf2.h>
#include <asm/calling.h>
#include <asm/msr.h>

.text

#***********************************************************************
#
#    SYS_Get_IDT_Base
#            Get the IDT Desc address
#
#    Entry:  pointer to location to store idt Desc
#
#    Exit:  none 
#
# void SYS_Get_IDT_Base(U64 *pIdtDesc);
#
#***********************************************************************
        .global SYS_Get_IDT_Base
SYS_Get_IDT_Base:
        SIDT (%rdi)
        ret

#***********************************************************************
#
#    SYS_Get_GDT_Base
#            Get the GDT Desc address
#
#    Entry:  pointer to location to store gdt Desc
#
#    Exit:  none 
#
# void SYS_Get_GDT_Base(U64 *pGdtDesc);
#
#***********************************************************************
        .global SYS_Get_GDT_Base
SYS_Get_GDT_Base:
        SGDT (%rdi)
        ret

#***********************************************************************
#
#    SYS_Get_TSC
#            Get the current TSC
#
#    Entry:  pointer to location to store gdt Desc
#
#    Exit:  none 
#
# void SYS_Get_TSC(U64 *tsc);
#
#***********************************************************************
#        .global SYS_Get_TSC
#SYS_Get_TSC:
#        rdtsc
#        ret

#***********************************************************************
#
#    SYS_IO_Delay
#            Add a short delay to the instruction stream
#
#    Entry:  none
#
#    Exit:  none 
#
# void SYS_IO_Delay(void);
#
#***********************************************************************
        .global SYS_IO_Delay
SYS_IO_Delay:
         ret

# ----------------------------------------------------------------------------
# name:         SYS_PerfVec_Handler
#
# description:  ISR entry for local APIC PERF interrupt vector
#
# Input:        n/a
#
# Output:       n/a 
# ----------------------------------------------------------------------------

        .global SYS_Perfvec_Handler
SYS_Perfvec_Handler:
	CFI_STARTPROC
        pushq %rax          // fake an error code...
        cld                 // cause the kernel likes it this way...

        SAVE_ALL            // Save the world!

        movl  $MSR_GS_BASE,%ecx     // for the moment, do the safe swapgs check
        rdmsr
        xorl  %ebx,%ebx             // assume no swapgs (ebx == 0)
        testl %edx,%edx
        js    1f
        swapgs
        movl  $1,%ebx               // ebx == 1 means we did a swapgs
1:      movq %rsp,%rdi              // pt_regs is the first argument

        //
        // ebx is zero if no swap, one if swap
        // ebx is preserved in C calling convention...
        //
        // NOTE: the C code is responsible for ACK'ing the APIC!!!
        //
        call PMI_Interrupt_Handler

        //
        // Don't want an interrupt while we are doing the swapgs stuff
        //
        cli
        testl %ebx,%ebx
        jz 2f
        swapgs
2:      RESTORE_ALL
        popq    %rax
        iretq
        CFI_ENDPROC