xed-state.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2015 Intel Corporation. All rights reserved.
00005  
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are
00008 met:
00009 
00010 Redistributions of source code must retain the above copyright notice,
00011 this list of conditions and the following disclaimer.  Redistributions
00012 in binary form must reproduce the above copyright notice, this list of
00013 conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.  Neither the name of
00015 the Intel Corporation nor the names of its contributors may be used to
00016 endorse or promote products derived from this software without
00017 specific prior written permission.
00018  
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
00023 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 END_LEGAL */
00033 
00034 
00035 
00036 #ifndef _XED_STATE_H_
00037 # define _XED_STATE_H_
00038 #include "xed-types.h"
00039 #include "xed-portability.h"
00040 #include "xed-address-width-enum.h" // generated
00041 #include "xed-machine-mode-enum.h" // generated
00042 
00043 
00052 typedef struct xed_state_s {
00054   xed_machine_mode_enum_t mmode; 
00056   xed_address_width_enum_t stack_addr_width; 
00057 } xed_state_t;
00058 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 static XED_INLINE void xed_state_init(xed_state_t* p,
00074                                       xed_machine_mode_enum_t arg_mmode,
00075                                       xed_address_width_enum_t arg_ignored,
00076                                       xed_address_width_enum_t arg_stack_addr_width) {
00077     p->mmode=arg_mmode;
00078     p->stack_addr_width=arg_stack_addr_width;
00079     (void) arg_ignored; //pacify compiler unused arg warning
00080 }
00081 
00092 static XED_INLINE void xed_state_init2(xed_state_t* p,
00093                                       xed_machine_mode_enum_t arg_mmode,
00094                                       xed_address_width_enum_t arg_stack_addr_width) {
00095     p->mmode=arg_mmode;
00096     p->stack_addr_width=arg_stack_addr_width;
00097 }
00098 
00101 static XED_INLINE void xed_state_zero(xed_state_t* p) {
00102     p->mmode= XED_MACHINE_MODE_INVALID;
00103     p->stack_addr_width=XED_ADDRESS_WIDTH_INVALID;
00104 }
00105 
00107 
00109 
00110 
00111 
00112 static XED_INLINE xed_machine_mode_enum_t   xed_state_get_machine_mode(const xed_state_t* p) {
00113     return p->mmode; 
00114 }
00115 
00116 
00119 static XED_INLINE xed_bool_t xed_state_long64_mode(const xed_state_t* p) { 
00120     return xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_64;
00121 }
00122 
00124 static XED_INLINE xed_bool_t xed_state_real_mode(const xed_state_t* p) {
00125     return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_REAL_16);
00126 }
00127 
00129 static XED_INLINE xed_bool_t xed_state_mode_width_16(const xed_state_t* p) {
00130     return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_16) ||
00131         (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_16);
00132 }
00133 
00135 static XED_INLINE xed_bool_t xed_state_mode_width_32(const xed_state_t* p) {
00136     return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_32) ||
00137         (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_32);
00138 }
00139   
00140 
00143 static XED_INLINE void  xed_state_set_machine_mode( xed_state_t* p,
00144                         xed_machine_mode_enum_t arg_mode)  {
00145     p->mmode = arg_mode;
00146 }
00148 
00150 
00151 
00154 static XED_INLINE xed_address_width_enum_t
00155 xed_state_get_address_width(const xed_state_t* p)
00156 {
00157     switch(xed_state_get_machine_mode(p)) {
00158       case XED_MACHINE_MODE_LONG_64:
00159         return XED_ADDRESS_WIDTH_64b;
00160 
00161       case XED_MACHINE_MODE_REAL_16:
00162         /* should be 20b... but if you are working w/real mode then you're
00163            going to have to deal with somehow. Could easily make this be
00164            20b if anyone cares. */
00165         return XED_ADDRESS_WIDTH_32b; 
00166 
00167       case XED_MACHINE_MODE_LEGACY_32:
00168       case XED_MACHINE_MODE_LONG_COMPAT_32:
00169         return XED_ADDRESS_WIDTH_32b;
00170       case XED_MACHINE_MODE_LEGACY_16:
00171       case XED_MACHINE_MODE_LONG_COMPAT_16:
00172         return XED_ADDRESS_WIDTH_16b;
00173       default:
00174         return XED_ADDRESS_WIDTH_INVALID;
00175     }
00176 }
00177 
00179 
00181 
00182 
00183 
00184 static XED_INLINE void
00185 xed_state_set_stack_address_width(xed_state_t* p,
00186                                   xed_address_width_enum_t arg_addr_width)
00187 {
00188     p->stack_addr_width = arg_addr_width;
00189 }
00190 
00191 
00194 static XED_INLINE xed_address_width_enum_t  xed_state_get_stack_address_width(const xed_state_t* p) {
00195     return p->stack_addr_width;
00196 }
00198 
00200 XED_DLL_EXPORT int xed_state_print(const xed_state_t* p, char* buf, int buflen);
00201 
00202 #endif
00203 

Generated on Wed Jan 21 02:18:32 2015 for XED by  doxygen 1.5.1-p1