00001 /*BEGIN_LEGAL 00002 Copyright (c) 2007, Intel Corp. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 00012 * Redistributions in binary form must reproduce the above 00013 copyright notice, this list of conditions and the following 00014 disclaimer in the documentation and/or other materials provided 00015 with the distribution. 00016 00017 * Neither the name of Intel Corporation nor the names of its 00018 contributors may be used to endorse or promote products derived 00019 from this software without specific prior written permission. 00020 00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00025 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00027 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 END_LEGAL */ 00035 00036 00037 00038 #ifndef _XED_STATE_H_ 00039 # define _XED_STATE_H_ 00040 #include "xed-types.h" 00041 #include "xed-portability.h" 00042 #include "xed-address-width-enum.h" // generated 00043 #include "xed-machine-mode-enum.h" // generated 00044 00045 00053 typedef struct XED_DLL_EXPORT xed_state_s { 00055 xed_machine_mode_enum_t mmode; 00056 00058 xed_address_width_enum_t addr_width; 00059 00061 xed_address_width_enum_t stack_addr_width; 00062 } xed_state_t; 00063 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 static XED_INLINE void xed_state_init(xed_state_t* p, 00078 xed_machine_mode_enum_t arg_mmode, 00079 xed_address_width_enum_t arg_addr_width, 00080 xed_address_width_enum_t arg_stack_addr_width) { 00081 p->mmode=arg_mmode; 00082 p->addr_width=arg_addr_width; 00083 p->stack_addr_width=arg_stack_addr_width; 00084 } 00085 00088 static XED_INLINE void xed_state_zero(xed_state_t* p) { 00089 p->mmode= XED_MACHINE_MODE_INVALID; 00090 p->addr_width=XED_ADDRESS_WIDTH_INVALID; 00091 p->stack_addr_width=XED_ADDRESS_WIDTH_INVALID; 00092 } 00093 00095 00097 00098 00099 00100 static XED_INLINE xed_machine_mode_enum_t xed_state_get_machine_mode(const xed_state_t* p) { 00101 return p->mmode; 00102 } 00103 00104 00107 static XED_INLINE xed_bool_t xed_state_long64_mode(const xed_state_t* p) { 00108 return xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_64; 00109 } 00110 00112 static XED_INLINE xed_bool_t xed_state_mode_width_16(const xed_state_t* p) { 00113 return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_16) || 00114 (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_16); 00115 } 00116 00118 static XED_INLINE xed_bool_t xed_state_mode_width_32(const xed_state_t* p) { 00119 return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_32) || 00120 (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_32); 00121 } 00122 00123 00126 static XED_INLINE void xed_state_set_machine_mode( xed_state_t* p, 00127 xed_machine_mode_enum_t arg_mode) { 00128 p->mmode = arg_mode; 00129 } 00131 00133 00134 00135 00136 static XED_INLINE void xed_state_set_address_width(xed_state_t* p, 00137 xed_address_width_enum_t arg_addr_width) { 00138 p->addr_width = arg_addr_width; 00139 } 00140 00143 static XED_INLINE xed_address_width_enum_t xed_state_get_address_width(const xed_state_t* p) { 00144 return p->addr_width; 00145 } 00146 00148 00150 00151 00152 00153 static XED_INLINE void xed_state_set_stack_address_width(xed_state_t* p, 00154 xed_address_width_enum_t arg_addr_width) { 00155 p->stack_addr_width = arg_addr_width; 00156 } 00157 00158 00161 static XED_INLINE xed_address_width_enum_t xed_state_get_stack_address_width(const xed_state_t* p) { 00162 return p->stack_addr_width; 00163 } 00165 00167 XED_DLL_EXPORT int xed_state_print(const xed_state_t* p, char* buf, int buflen); 00168 00169 #endif 00170 00172 //Local Variables: 00173 //pref: "../../xed-state.c" 00174 //End: