locked_opcodes.isa revision 6098
1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// Redistribution and use of this software in source and binary forms,
5// with or without modification, are permitted provided that the
6// following conditions are met:
7//
8// The software must be used only for Non-Commercial Use which means any
9// use which is NOT directed to receiving any direct monetary
10// compensation for, or commercial advantage from such use.  Illustrative
11// examples of non-commercial use are academic research, personal study,
12// teaching, education and corporate research & development.
13// Illustrative examples of commercial use are distributing products for
14// commercial advantage and providing services using the software for
15// commercial advantage.
16//
17// If you wish to use this software or functionality therein that may be
18// covered by patents for commercial use, please contact:
19//     Director of Intellectual Property Licensing
20//     Office of Strategy and Technology
21//     Hewlett-Packard Company
22//     1501 Page Mill Road
23//     Palo Alto, California  94304
24//
25// Redistributions of source code must retain the above copyright notice,
26// this list of conditions and the following disclaimer.  Redistributions
27// in binary form must reproduce the above copyright notice, this list of
28// conditions and the following disclaimer in the documentation and/or
29// other materials provided with the distribution.  Neither the name of
30// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
31// contributors may be used to endorse or promote products derived from
32// this software without specific prior written permission.  No right of
33// sublicense is granted herewith.  Derivatives of the software and
34// output created using the software may be prepared, but only for
35// Non-Commercial Uses.  Derivatives of the software may be shared with
36// others provided: (i) the others agree to abide by the list of
37// conditions herein which includes the Non-Commercial Use restrictions;
38// and (ii) such Derivatives of the software include the above copyright
39// notice to acknowledge the contribution from this software where
40// applicable, this list of conditions and the disclaimer below.
41//
42// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53//
54// Authors: Gabe Black
55
56////////////////////////////////////////////////////////////////////
57//
58// Decode opcodes with the lock prefix. Opcodes which shouldn't have that
59// prefix should effectively decode to UD2.
60//
61
62// All the memory references in these instructions happen through modrm bytes.
63// We therefore only need to make sure the modrm byte encodes a memory
64// reference to make sure these are the memory forms of these instructions.
650x1: decode MODRM_MOD {
66    format Inst {
67        0x3: UD2();
68        default: decode OPCODE_NUM {
69            0x1: decode OPCODE_OP_TOP5 {
70                0x00: decode OPCODE_OP_BOTTOM3 {
71                    default: MultiInst::ADD_LOCKED(OPCODE_OP_BOTTOM3,
72                                            [Mb,Gb], [Mv,Gv]);
73                }
74                0x01: decode OPCODE_OP_BOTTOM3 {
75                    default: MultiInst::OR_LOCKED(OPCODE_OP_BOTTOM3,
76                                           [Mb,Gb], [Mv,Gv]);
77                }
78                0x02: decode OPCODE_OP_BOTTOM3 {
79                    default: MultiInst::ADC_LOCKED(OPCODE_OP_BOTTOM3,
80                                            [Mb,Gb], [Mv,Gv]);
81                }
82                0x03: decode OPCODE_OP_BOTTOM3 {
83                    default: MultiInst::SBB_LOCKED(OPCODE_OP_BOTTOM3,
84                                            [Mb,Gb], [Mv,Gv]);
85                }
86                0x04: decode OPCODE_OP_BOTTOM3 {
87                    default: MultiInst::AND_LOCKED(OPCODE_OP_BOTTOM3,
88                                            [Mb,Gb], [Mv,Gv]);
89                }
90                0x05: decode OPCODE_OP_BOTTOM3 {
91                    default: MultiInst::SUB_LOCKED(OPCODE_OP_BOTTOM3,
92                                            [Mb,Gb], [Mv,Gv]);
93                }
94                0x06: decode OPCODE_OP_BOTTOM3 {
95                    default: MultiInst::XOR_LOCKED(OPCODE_OP_BOTTOM3,
96                                            [Mb,Gb], [Mv,Gv]);
97                }
98                0x10: decode OPCODE_OP_BOTTOM3 {
99                    0x0: decode MODRM_REG {
100                        0x0: ADD_LOCKED(Mb,Ib);
101                        0x1: OR_LOCKED(Mb,Ib);
102                        0x2: ADC_LOCKED(Mb,Ib);
103                        0x3: SBB_LOCKED(Mb,Ib);
104                        0x4: AND_LOCKED(Mb,Ib);
105                        0x5: SUB_LOCKED(Mb,Ib);
106                        0x6: XOR_LOCKED(Mb,Ib);
107                    }
108                    0x1: decode MODRM_REG {
109                        0x0: ADD_LOCKED(Mv,Iz);
110                        0x1: OR_LOCKED(Mv,Iz);
111                        0x2: ADC_LOCKED(Mv,Iz);
112                        0x3: SBB_LOCKED(Mv,Iz);
113                        0x4: AND_LOCKED(Mv,Iz);
114                        0x5: SUB_LOCKED(Mv,Iz);
115                        0x6: XOR_LOCKED(Mv,Iz);
116                    }
117                    0x2: decode MODE_SUBMODE {
118                        0x0: UD2();
119                        default: decode MODRM_REG {
120                            0x0: ADD_LOCKED(Mb,Ib);
121                            0x1: OR_LOCKED(Mb,Ib);
122                            0x2: ADC_LOCKED(Mb,Ib);
123                            0x3: SBB_LOCKED(Mb,Ib);
124                            0x4: AND_LOCKED(Mb,Ib);
125                            0x5: SUB_LOCKED(Mb,Ib);
126                            0x6: XOR_LOCKED(Mb,Ib);
127                        }
128                    }
129                    //0x3: group1_Ev_Ib();
130                    0x3: decode MODRM_REG {
131                        0x0: ADD_LOCKED(Mv,Ib);
132                        0x1: OR_LOCKED(Mv,Ib);
133                        0x2: ADC_LOCKED(Mv,Ib);
134                        0x3: SBB_LOCKED(Mv,Ib);
135                        0x4: AND_LOCKED(Mv,Ib);
136                        0x5: SUB_LOCKED(Mv,Ib);
137                        0x6: XOR_LOCKED(Mv,Ib);
138                    }
139                    0x6: XCHG_LOCKED(Mb,Gb);
140                    0x7: XCHG_LOCKED(Mv,Gv);
141                }
142                0x1E: decode OPCODE_OP_BOTTOM3 {
143                    //0x6: group3_Eb();
144                    0x6: decode MODRM_REG {
145                        0x2: NOT_LOCKED(Mb);
146                        0x3: NEG_LOCKED(Mb);
147                    }
148                    //0x7: group3_Ev();
149                    0x7: decode MODRM_REG {
150                        0x2: NOT_LOCKED(Mv);
151                        0x3: NEG_LOCKED(Mv);
152                    }
153                }
154                0x1F: decode OPCODE_OP_BOTTOM3 {
155                    0x6: decode MODRM_REG {
156                        0x0: INC_LOCKED(Mb);
157                        0x1: DEC_LOCKED(Mb);
158                        default: UD2();
159                    }
160                    //0x7: group5();
161                    0x7: decode MODRM_REG {
162                        0x0: INC_LOCKED(Mv);
163                        0x1: DEC_LOCKED(Mv);
164                    }
165                }
166            }
167            0x2: decode OPCODE_PREFIXA {
168                0x0F: decode OPCODE_OP_TOP5 {
169                    0x15: decode OPCODE_OP_BOTTOM3 {
170                        0x3: BTS_LOCKED(Mv,Gv);
171                    }
172                    0x16: decode OPCODE_OP_BOTTOM3 {
173                        0x0: CMPXCHG_LOCKED(Mb,Gb);
174                        0x1: CMPXCHG_LOCKED(Mv,Gv);
175                        0x3: BTR_LOCKED(Mv,Gv);
176                    }
177                    0x17: decode OPCODE_OP_BOTTOM3 {
178                        0x2: decode MODRM_REG {
179                            0x5: BTS_LOCKED(Mv,Ib);
180                            0x6: BTR_LOCKED(Mv,Ib);
181                            0x7: BTC_LOCKED(Mv,Ib);
182                        }
183                        0x3: BTC_LOCKED(Mv,Gv);
184                    }
185                    0x18: decode OPCODE_OP_BOTTOM3 {
186                        0x0: XADD_LOCKED(Mb,Gb);
187                        0x1: XADD_LOCKED(Mv,Gv);
188                        //0x7: group9();
189                        0x7: decode MODRM_REG {
190                            0x1: WarnUnimpl::cmpxchg_Mq_LOCKED();
191                        }
192                    }
193                }
194                default: M5InternalError::error(
195                    {{"Unexpected first opcode byte in two byte opcode!"}});
196            }
197        }
198    }
199}
200