xed-state.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2011 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_DLL_EXPORT 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 
00152 
00153 static XED_INLINE void xed_state_set_address_width(xed_state_t* p,
00154                                                    xed_address_width_enum_t arg_addr_width) {
00155     (void)p;
00156     (void)arg_addr_width;
00157 }
00158 
00161 static XED_INLINE xed_address_width_enum_t  xed_state_get_address_width(const xed_state_t* p) {
00162     switch(xed_state_get_machine_mode(p)) {
00163       case XED_MACHINE_MODE_LONG_64:
00164         return XED_ADDRESS_WIDTH_64b;
00165 
00166       case XED_MACHINE_MODE_REAL_16:
00167         /* should be 20b... but if you are working w/real mode then you're
00168            going to have to deal with somehow. Could easily make this be
00169            20b if anyone cares. */
00170         return XED_ADDRESS_WIDTH_32b; 
00171 
00172       case XED_MACHINE_MODE_LEGACY_32:
00173       case XED_MACHINE_MODE_LONG_COMPAT_32:
00174         return XED_ADDRESS_WIDTH_32b;
00175       case XED_MACHINE_MODE_LEGACY_16:
00176       case XED_MACHINE_MODE_LONG_COMPAT_16:
00177         return XED_ADDRESS_WIDTH_16b;
00178       default:
00179         return XED_ADDRESS_WIDTH_INVALID;
00180     }
00181 }
00182 
00184 
00186 
00187 
00188 
00189 static XED_INLINE void  xed_state_set_stack_address_width(xed_state_t* p,
00190                               xed_address_width_enum_t arg_addr_width) {
00191     p->stack_addr_width = arg_addr_width;
00192 }
00193 
00194 
00197 static XED_INLINE xed_address_width_enum_t  xed_state_get_stack_address_width(const xed_state_t* p) {
00198     return p->stack_addr_width;
00199 }
00201 
00203 XED_DLL_EXPORT int xed_state_print(const xed_state_t* p, char* buf, int buflen);
00204 
00205 #endif
00206 
00208 //Local Variables:
00209 //pref: "../../xed-state.c"
00210 //End:

Generated on Tue Nov 22 12:27:07 2011 for XED2 by  doxygen 1.4.6