#!/usr/bin/env python # SPDX-License-Identifier: GPL-2.0 # libxed.py: Python wrapper for libxed.so # Copyright (c) 2014-2021, Intel Corporation. # To use Intel XED, libxed.so must be present. To build and install # libxed.so: # git clone https://github.com/intelxed/mbuild.git mbuild # git clone https://github.com/intelxed/xed # cd xed # ./mfile.py --share # sudo ./mfile.py --prefix=/usr/local install # sudo ldconfig # import sys from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \ c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong # XED Disassembler class xed_state_t(Structure): _fields_ = [ ("mode", c_int), ("width", c_int) ] class XEDInstruction(): def __init__(self, libxed): # Current xed_decoded_inst_t structure is 192 bytes. Use 512 to allow for future expansion xedd_t = c_byte * 512 self.xedd = xedd_t() self.xedp = addressof(self.xedd) libxed.xed_decoded_inst_zero(self.xedp) self.state = xed_state_t() self.statep = addressof(self.state) # Buffer for disassembled instruction text self.buffer = create_string_buffer(256) self.bufferp = addressof(self.buffer) class LibXED(): def __init__(self): try: self.libxed = CDLL("libxed.so") except: self.libxed = None if not self.libxed: self.libxed = CDLL("/usr/local/lib/libxed.so") self.xed_tables_init = self.libxed.xed_tables_init self.xed_tables_init.restype = None self.xed_tables_init.argtypes = [] self.xed_decoded_inst_zero = self.libxed.xed_decoded_inst_zero self.xed_decoded_inst_zero.restype = None self.xed_decoded_inst_zero.argtypes = [ c_void_p ] self.xed_operand_values_set_mode = self.libxed.xed_operand_values_set_mode self.xed_operand_values_set_mode.restype = None self.xed_operand_values_set_mode.argtypes = [ c_void_p, c_void_p ] self.xed_decoded_inst_zero_keep_mode = self.libxed.xed_decoded_inst_zero_keep_mode self.xed_decoded_inst_zero_keep_mode.restype = None self.xed_decoded_inst_zero_keep_mode.argtypes = [ c_void_p ] self.xed_decode = self.libxed.xed_decode self.xed_decode.restype = c_int self.xed_decode.argtypes = [ c_void_p, c_void_p, c_uint ] self.xed_format_context = self.libxed.xed_format_context self.xed_format_context.restype = c_uint self.xed_format_context.argtypes = [ c_int, c_void_p, c_void_p, c_int, c_ulonglong, c_void_p, c_void_p ] self.xed_tables_init() def Instruction(self): return XEDInstruction(self) def SetMode(self, inst, mode): if mode: inst.state.mode = 4 # 32-bit inst.state.width = 4 # 4 bytes else: inst.state.mode = 1 # 64-bit inst.state.width = 8 # 8 bytes self.xed_operand_values_set_mode(inst.xedp, inst.statep) def DisassembleOne(self, inst, bytes_ptr, bytes_cnt, ip): self.xed_decoded_inst_zero_keep_mode(inst.xedp) err = self.xed_decode(inst.xedp, bytes_ptr, bytes_cnt) if err: return 0, "" # Use AT&T mode (2), alternative is Intel (3) ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) if not ok: return 0, "" if sys.version_info[0] == 2: result = inst.buffer.value else: result = inst.buffer.value.decode() # Return instruction length and the disassembled instruction text # For now, assume the length is in byte 166 return inst.xedd[166], result .6.y Hosts the 0x221E linux distro kernel.Ubuntu
summaryrefslogtreecommitdiff
path: root/drivers/staging/winbond
AgeCommit message (Expand)Author
2012-08-17USB: winbond: remove __devinit* from the struct usb_device_id tableGreg Kroah-Hartman
2012-07-16staging/winbond: use err and remove nrDevendra Naga
2012-06-12staging: Fix typo in winbondMasanari Iida
2011-11-18USB: convert drivers/staging/* to use module_usb_driver()Greg Kroah-Hartman
2011-10-31staging: Add module.h to more drivers implicitly using it.Paul Gortmaker
2011-10-26Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/...Linus Torvalds
2011-09-27mac80211: add ieee80211_vif param to tsf functionsEliad Peller
2011-08-23Staging : winbond : fix coding style issue in phy_calibration.cVincent Abel-Grimalt
2011-07-26atomic: use <linux/atomic.h>Arun Sharma
2011-06-28Staging: Winbond: Fix assorted spacing issues.Akshay Joshi
2011-04-20Staging: winbond: wb35tx.c: Fixed coding styleKarthigan Srinivasan
2011-04-13Staging: merge 2.6.39-rc3 into staging-nextGreg Kroah-Hartman
2011-04-04staging: winbond/mto.c: remove unused variablesJonathan Neuschäfer
2011-04-04staging: winbond: fixing some code styles issuesChihau Chau
2011-03-31Fix common misspellingsLucas De Marchi
2011-03-16Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6Linus Torvalds
2011-03-14staging: winbond: Remove NULL check before kfreeIlia Mirkin
2011-02-28staging: winbond: needs <linux/delay.h> for msleep and friendsJeff Mahoney
2011-02-25mac80211: make tx() operation return voidJohannes Berg
2010-12-01Staging: w35und: Kill struct wb_usbPekka Enberg
2010-12-01Staging: w35und: Remove unused fields from struct wb_usbPekka Enberg
2010-12-01Staging: w35und: Kill wblinux_f.h headerPekka Enberg
2010-12-01Staging: w35und: Merge mlmetxrx.c to mds.cPekka Enberg
2010-12-01Staging: w35und: Kill _IBSS_BEACON_SEQ_STICK_Pekka Enberg
2010-12-01Staging: w35und: Kill write-only ->TxTogglePekka Enberg
2010-12-01Staging: w35und: Kill Vendor2 ifdef from hal_init_hardwarePekka Enberg
2010-12-01Staging: w35und: Remove empty sysdef.h headerPekka Enberg
2010-12-01Staging: w35und: Use pr_debug() for debuggingPekka Enberg
2010-12-01Staging: w35und: Kill unused code in mac_structures.hPekka Enberg
2010-12-01Staging: w35und: Kill WPA2 definitionsPekka Enberg
2010-12-01Staging: w35und: Kill _USE_FALLBACK_RATE_ macroPekka Enberg
2010-12-01Staging: w35und: Remove unused defines from sysdef.hPekka Enberg
2010-11-09Staging: w35und: Kill struct hwdata ->SurpriseRemoveCountPekka Enberg
2010-11-09Staging: w35und: Kill struct hwdata ->HwStopPekka Enberg
2010-11-09Staging: w35und: Kill struct hwdata ->NullPacketCountPekka Enberg
2010-11-09Staging: w35und: Kill empty Mds_Destroy functionPekka Enberg
2010-11-09Staging: w35und: Rename wbhal_s.h to wbhal.hPekka Enberg
2010-11-09Staging: w35und: Merge wbhal_f.h to wbhal_s.hPekka Enberg