xed-flags.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 #ifndef _XED_FLAGS_H_
00035 # define  _XED_FLAGS_H_
00036 
00037 #include "xed-types.h"
00038 #include "xed-portability.h"
00039 #include "xed-flag-enum.h"
00040 #include "xed-flag-action-enum.h"
00041 #include "xed-gen-table-defs.h"
00042 
00043 
00047 union  XED_DLL_EXPORT xed_flag_set_s {
00048     struct {
00049         xed_uint32_t cf:1;
00050         xed_uint32_t must_be_1:1;
00051         xed_uint32_t pf:1;
00052         xed_uint32_t must_be_0a:1;
00053         xed_uint32_t af:1;
00054         xed_uint32_t must_be_0b:1;
00055         xed_uint32_t zf:1;
00056         xed_uint32_t sf:1;
00057         xed_uint32_t tf:1;
00058         xed_uint32_t _if:1;  
00059         xed_uint32_t df:1;
00060         xed_uint32_t of:1;
00061         xed_uint32_t iopl:1;
00062         xed_uint32_t nt:1;
00063         xed_uint32_t must_be_0c:1;
00064         xed_uint32_t rf:1;
00065         xed_uint32_t vm:1;
00066         xed_uint32_t ac:1;
00067         xed_uint32_t vif:1;
00068         xed_uint32_t vip:1; 
00069         xed_uint32_t id:1;
00070         xed_uint32_t mbz:6;  
00071         xed_uint32_t fc0:1;  
00072         xed_uint32_t fc1:1;  
00073         xed_uint32_t fc2:1;  
00074         xed_uint32_t fc3:1;  
00075     } s;
00076     xed_uint32_t flat;
00077 };
00078 
00079 typedef union xed_flag_set_s xed_flag_set_t;
00082 
00083 
00084 
00085 XED_DLL_EXPORT int  xed_flag_set_print(const xed_flag_set_t* p, char* buf, int buflen);
00089 XED_DLL_EXPORT xed_bool_t xed_flag_set_is_subset_of(const xed_flag_set_t* p,
00090                                const xed_flag_set_t* other);
00092 
00093 
00095 
00098 typedef struct XED_DLL_EXPORT xed_flag_enum_s {
00099     xed_flag_enum_t flag;
00100     // there are at most two actions per flag. The 2nd may be invalid.
00101     xed_flag_action_enum_t action;
00102 }  xed_flag_action_t;
00103 
00104 
00105 
00106 
00109 
00110 
00111 
00112 XED_DLL_EXPORT xed_flag_enum_t
00113 xed_flag_action_get_flag_name(const xed_flag_action_t* p);
00116 XED_DLL_EXPORT xed_flag_action_enum_t
00117 xed_flag_action_get_action(const xed_flag_action_t* p, unsigned int i);
00120 XED_DLL_EXPORT xed_bool_t 
00121 xed_flag_action_action_invalid(const xed_flag_action_enum_t a);
00124 XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t* p, char* buf, int buflen);
00127 XED_DLL_EXPORT xed_bool_t 
00128 xed_flag_action_read_flag(const xed_flag_action_t* p );
00131 XED_DLL_EXPORT xed_bool_t 
00132 xed_flag_action_writes_flag(const xed_flag_action_t* p);
00133   
00136 XED_DLL_EXPORT xed_bool_t 
00137 xed_flag_action_read_action( xed_flag_action_enum_t a);
00140 XED_DLL_EXPORT xed_bool_t 
00141 xed_flag_action_write_action( xed_flag_action_enum_t a);
00143 
00145 
00146 #define XED_MAX_FLAG_ACTIONS (XED_MAX_ACTIONS_PER_SIMPLE_FLAG)
00149 typedef struct  XED_DLL_EXPORT xed_simple_flag_s 
00150 {
00151     xed_uint8_t nflags;
00152 
00153     xed_uint8_t may_write; /* 1/0,  only using one bit */
00154     xed_uint8_t must_write;  /* 1/0,  only using one bit */
00155 
00157     xed_flag_set_t read;
00158 
00160     xed_flag_set_t written;
00161 
00163     xed_flag_set_t undefined;
00164 
00165     // index in to the xed_flag_action_table. nflags limits the # of entries.
00166     xed_uint16_t fa_index;
00167 
00168 } xed_simple_flag_t;
00169 
00172 
00173 
00174 
00175 XED_DLL_EXPORT unsigned int 
00176 xed_simple_flag_get_nflags(const xed_simple_flag_t* p);
00177 
00180 XED_DLL_EXPORT const xed_flag_set_t* 
00181 xed_simple_flag_get_read_flag_set(const xed_simple_flag_t* p);
00182 
00185 XED_DLL_EXPORT const xed_flag_set_t*
00186 xed_simple_flag_get_written_flag_set(const xed_simple_flag_t* p);
00187 
00188 
00191 XED_DLL_EXPORT const xed_flag_set_t*
00192 xed_simple_flag_get_undefined_flag_set(const xed_simple_flag_t* p);
00193 
00197 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_may_write(const xed_simple_flag_t* p);
00198 
00201 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_must_write(const xed_simple_flag_t* p);
00202 
00205 XED_DLL_EXPORT const xed_flag_action_t*
00206 xed_simple_flag_get_flag_action(const xed_simple_flag_t* p, unsigned int i);
00207 
00210 XED_DLL_EXPORT xed_bool_t
00211 xed_simple_flag_reads_flags(const xed_simple_flag_t* p);
00212 
00215 XED_DLL_EXPORT xed_bool_t xed_simple_flag_writes_flags(const xed_simple_flag_t* p);
00216 
00219 XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t* p, char* buf, int buflen);
00220 
00223 static XED_INLINE int xed_flag_set_mask(const xed_flag_set_t* p) {
00224     return p->flat; // FIXME: could mask out the X87 flags
00225 }
00226 
00228 
00230 
00231 
00233 
00234 #endif

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