msrs.py revision 5409
12SN/A# Copyright (c) 2008 The Regents of The University of Michigan
21762SN/A# All rights reserved.
32SN/A#
42SN/A# Redistribution and use in source and binary forms, with or without
52SN/A# modification, are permitted provided that the following conditions are
62SN/A# met: redistributions of source code must retain the above copyright
72SN/A# notice, this list of conditions and the following disclaimer;
82SN/A# redistributions in binary form must reproduce the above copyright
92SN/A# notice, this list of conditions and the following disclaimer in the
102SN/A# documentation and/or other materials provided with the distribution;
112SN/A# neither the name of the copyright holders nor the names of its
122SN/A# contributors may be used to endorse or promote products derived from
132SN/A# this software without specific prior written permission.
142SN/A#
152SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262SN/A#
272665Ssaidi@eecs.umich.edu# Authors: Gabe Black
282665Ssaidi@eecs.umich.edu
292SN/A# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
302SN/A# All rights reserved.
312439SN/A#
32146SN/A# Redistribution and use of this software in source and binary forms,
33146SN/A# with or without modification, are permitted provided that the
34146SN/A# following conditions are met:
35146SN/A#
36146SN/A# The software must be used only for Non-Commercial Use which means any
37146SN/A# use which is NOT directed to receiving any direct monetary
381717SN/A# compensation for, or commercial advantage from such use.  Illustrative
39146SN/A# examples of non-commercial use are academic research, personal study,
401717SN/A# teaching, education and corporate research & development.
41146SN/A# Illustrative examples of commercial use are distributing products for
421977SN/A# commercial advantage and providing services using the software for
432623SN/A# commercial advantage.
442683Sktlim@umich.edu#
451717SN/A# If you wish to use this software or functionality therein that may be
46146SN/A# covered by patents for commercial use, please contact:
472683Sktlim@umich.edu#     Director of Intellectual Property Licensing
481917SN/A#     Office of Strategy and Technology
492592SN/A#     Hewlett-Packard Company
502683Sktlim@umich.edu#     1501 Page Mill Road
512036SN/A#     Palo Alto, California  94304
52146SN/A#
5356SN/A# Redistributions of source code must retain the above copyright notice,
5456SN/A# this list of conditions and the following disclaimer.  Redistributions
5556SN/A# in binary form must reproduce the above copyright notice, this list of
56695SN/A# conditions and the following disclaimer in the documentation and/or
572901Ssaidi@eecs.umich.edu# other materials provided with the distribution.  Neither the name of
582SN/A# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
591858SN/A# contributors may be used to endorse or promote products derived from
6056SN/A# this software without specific prior written permission.  No right of
612171SN/A# sublicense is granted herewith.  Derivatives of the software and
622170SN/A# output created using the software may be prepared, but only for
632170SN/A# Non-Commercial Uses.  Derivatives of the software may be shared with
64146SN/A# others provided: (i) the others agree to abide by the list of
652462SN/A# conditions herein which includes the Non-Commercial Use restrictions;
66146SN/A# and (ii) such Derivatives of the software include the above copyright
672SN/A# notice to acknowledge the contribution from this software where
682SN/A# applicable, this list of conditions and the disclaimer below.
692449SN/A#
701355SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
712623SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
722683Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73224SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
741858SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
752683Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
762420SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
772683Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
782520SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
792420SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
802SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
812683Sktlim@umich.edu#
822672Sktlim@umich.edu# Authors: Gabe Black
832683Sktlim@umich.edu
842SN/Amicrocode = '''
852SN/Adef macroop RDMSR
86334SN/A{
87140SN/A    limm t1, "IntAddrPrefixMSR >> 3"
88334SN/A    ld t2, intseg, [8, t1, rcx], dataSize=8, addressSize=4
892SN/A    mov rax, rax, t2, dataSize=4
902SN/A    srli t2, t2, 32, dataSize=8
912SN/A    mov rdx, rdx, t2, dataSize=4
922680Sktlim@umich.edu};
932SN/A
942SN/Adef macroop WRMSR
952623SN/A{
962SN/A    limm t1, "IntAddrPrefixMSR >> 3"
972SN/A    mov t2, t2, rax, dataSize=4
982SN/A    slli t3, rdx, 32, dataSize=8
99180SN/A    or t2, t2, t3, dataSize=8
1002623SN/A    st t2, intseg, [8, t1, rcx], dataSize=8, addressSize=4
101393SN/A};
102393SN/A
103393SN/Adef macroop RDTSC
104393SN/A{
105384SN/A    rdtsc t1
106384SN/A    mov rax, rax, t1, dataSize=4
107393SN/A    srli t1, t1, 32, dataSize=8
1082623SN/A    mov rdx, rdx, t1, dataSize=4
109393SN/A};
110393SN/A'''
111393SN/A