17087Snate@binkert.org# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
27087Snate@binkert.org# All rights reserved.
37087Snate@binkert.org#
47087Snate@binkert.org# The license below extends only to copyright in the software and shall
57087Snate@binkert.org# not be construed as granting a license to any other intellectual
67087Snate@binkert.org# property including but not limited to intellectual property relating
77087Snate@binkert.org# to a hardware implementation of the functionality of the software
87087Snate@binkert.org# licensed hereunder.  You may use the software subject to the license
97087Snate@binkert.org# terms below provided that you ensure that this notice is replicated
107087Snate@binkert.org# unmodified and in its entirety in all distributions of the software,
117087Snate@binkert.org# modified or unmodified, in source code or in binary form.
127087Snate@binkert.org#
135325Sgblack@eecs.umich.edu# Copyright (c) 2008 The Regents of The University of Michigan
145325Sgblack@eecs.umich.edu# All rights reserved.
155325Sgblack@eecs.umich.edu#
165325Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
175325Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
185325Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
195325Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
205325Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
215325Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
225325Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
235325Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
245325Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
255325Sgblack@eecs.umich.edu# this software without specific prior written permission.
265325Sgblack@eecs.umich.edu#
275325Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
285325Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
295325Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
305325Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
315325Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
325325Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
335325Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
345325Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
355325Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365325Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
375325Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
385325Sgblack@eecs.umich.edu#
395325Sgblack@eecs.umich.edu# Authors: Gabe Black
405325Sgblack@eecs.umich.edu
415149Sgblack@eecs.umich.edumicrocode = '''
425243Sgblack@eecs.umich.edudef macroop RDMSR
435149Sgblack@eecs.umich.edu{
445418Sgblack@eecs.umich.edu    ld t2, intseg, [8, rcx, t0], "IntAddrPrefixMSR << 3", \
455968Sgblack@eecs.umich.edu        dataSize=8, addressSize=8
465149Sgblack@eecs.umich.edu    mov rax, rax, t2, dataSize=4
475149Sgblack@eecs.umich.edu    srli t2, t2, 32, dataSize=8
485149Sgblack@eecs.umich.edu    mov rdx, rdx, t2, dataSize=4
495149Sgblack@eecs.umich.edu};
505149Sgblack@eecs.umich.edu
515243Sgblack@eecs.umich.edudef macroop WRMSR
525149Sgblack@eecs.umich.edu{
5312584Sgabeblack@google.com    .serialize_after
545149Sgblack@eecs.umich.edu    mov t2, t2, rax, dataSize=4
555325Sgblack@eecs.umich.edu    slli t3, rdx, 32, dataSize=8
565325Sgblack@eecs.umich.edu    or t2, t2, t3, dataSize=8
575418Sgblack@eecs.umich.edu    st t2, intseg, [8, rcx, t0], "IntAddrPrefixMSR << 3", \
585968Sgblack@eecs.umich.edu        dataSize=8, addressSize=8
595149Sgblack@eecs.umich.edu};
605409Sgblack@eecs.umich.edu
615409Sgblack@eecs.umich.edudef macroop RDTSC
625409Sgblack@eecs.umich.edu{
6312585Sgabeblack@google.com    .serialize_before
645409Sgblack@eecs.umich.edu    rdtsc t1
655409Sgblack@eecs.umich.edu    mov rax, rax, t1, dataSize=4
6612587Sgabeblack@google.com    srli rdx, t1, 32, dataSize=8
675409Sgblack@eecs.umich.edu};
6812586Sgabeblack@google.com
6912586Sgabeblack@google.comdef macroop RDTSCP
7012586Sgabeblack@google.com{
7112586Sgabeblack@google.com    .serialize_before
7212586Sgabeblack@google.com    mfence
7312586Sgabeblack@google.com    rdtsc t1
7412586Sgabeblack@google.com    mov rax, rax, t1, dataSize=4
7512587Sgabeblack@google.com    srli rdx, t1, 32, dataSize=8
7612586Sgabeblack@google.com    rdval rcx, "InstRegIndex(MISCREG_TSC_AUX)", dataSize=4
7712586Sgabeblack@google.com};
785149Sgblack@eecs.umich.edu'''
79