msrs.py revision 12585:d8dc3be32b91
16019SN/A# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
26019SN/A# All rights reserved.
37102SN/A#
47102SN/A# The license below extends only to copyright in the software and shall
57102SN/A# not be construed as granting a license to any other intellectual
67102SN/A# property including but not limited to intellectual property relating
77102SN/A# to a hardware implementation of the functionality of the software
87102SN/A# licensed hereunder.  You may use the software subject to the license
97102SN/A# terms below provided that you ensure that this notice is replicated
107102SN/A# unmodified and in its entirety in all distributions of the software,
117102SN/A# modified or unmodified, in source code or in binary form.
127102SN/A#
137102SN/A# Copyright (c) 2008 The Regents of The University of Michigan
147102SN/A# All rights reserved.
156019SN/A#
166019SN/A# Redistribution and use in source and binary forms, with or without
176019SN/A# modification, are permitted provided that the following conditions are
186019SN/A# met: redistributions of source code must retain the above copyright
196019SN/A# notice, this list of conditions and the following disclaimer;
206019SN/A# redistributions in binary form must reproduce the above copyright
216019SN/A# notice, this list of conditions and the following disclaimer in the
226019SN/A# documentation and/or other materials provided with the distribution;
236019SN/A# neither the name of the copyright holders nor the names of its
246019SN/A# contributors may be used to endorse or promote products derived from
256019SN/A# this software without specific prior written permission.
266019SN/A#
276019SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
286019SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
296019SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
306019SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
316019SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
326019SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
336019SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
346019SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
356019SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
366019SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
376019SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
386019SN/A#
396019SN/A# Authors: Gabe Black
406019SN/A
416019SN/Amicrocode = '''
426019SN/Adef macroop RDMSR
436019SN/A{
446019SN/A    ld t2, intseg, [8, rcx, t0], "IntAddrPrefixMSR << 3", \
456019SN/A        dataSize=8, addressSize=8
466019SN/A    mov rax, rax, t2, dataSize=4
476019SN/A    srli t2, t2, 32, dataSize=8
486019SN/A    mov rdx, rdx, t2, dataSize=4
496019SN/A};
506019SN/A
516019SN/Adef macroop WRMSR
526310SN/A{
537102SN/A    .serialize_after
546268SN/A    mov t2, t2, rax, dataSize=4
556268SN/A    slli t3, rdx, 32, dataSize=8
566268SN/A    or t2, t2, t3, dataSize=8
576268SN/A    st t2, intseg, [8, rcx, t0], "IntAddrPrefixMSR << 3", \
586268SN/A        dataSize=8, addressSize=8
596276SN/A};
606280SN/A
616268SN/Adef macroop RDTSC
626268SN/A{
636268SN/A    .serialize_before
646268SN/A    rdtsc t1
656268SN/A    mov rax, rax, t1, dataSize=4
666741SN/A    srli t1, t1, 32, dataSize=8
677102SN/A    mov rdx, rdx, t1, dataSize=4
687102SN/A};
697102SN/A'''
706741SN/A