00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 00011 __facility__ = "Online" 00012 __abstract__ = "GLAST remote memory accessors" 00013 __author__ = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST LAT I&T/Online" 00014 __date__ = ("$Date: 2004/09/20 18:13:04 $").split(' ')[1] 00015 __version__ = "$Revision: 1.5 $" 00016 __release__ = "$Name: R04-12-00 $" 00017 __credits__ = "SLAC" 00018 00019 import LATTE.copyright_SLAC 00020 00021 import struct 00022 import gDb 00023 import gAttr 00024 00025 class GMem(gDb.Gdb): 00026 """\brief Memory node. 00027 00028 Has GMem specific registers 00029 00030 Dataless Commands: 00031 none 00032 00033 """ 00034 __VX_READ = 0 00035 __VX_WRITE = 1 00036 00037 __fmt = {1 : 'B', 2 : 'H', 4 : 'I', 8 : 'Q'} 00038 00039 def __init__(self, client): 00040 """\brief Initialize valid registers as Gattrs. 00041 """ 00042 gDb.Gdb.__init__(self, client, None, 0) 00043 00044 def gMEMread(self, addr, size=4): 00045 """SBC MEM read command 00046 00047 \param addr SBC address 00048 \param size Addressing used (1=8bit, 2=16bit, 4=32bit, 8=64bit, default is 4) 00049 \return A tuple containing the user id, status and value 00050 00051 """ 00052 payload = '!' + self.__fmt[size] 00053 return self.cmdrsp('vxMemProbe', addr, GMem.__VX_READ, size, payload) 00054 00055 def gMEMload(self, addr, val, size=4): 00056 """SBC MEM load command 00057 00058 \param addr SBC address 00059 \param val Value to be set at address \a addr 00060 \param size Addressing used (1=8bit, 2=16bit, 4=32bit, 8=64bit, default is 4) 00061 \return A tuple containing the user id, status and timestamp 00062 """ 00063 input = '>' + struct.pack('>'+self.__fmt[size], val) # val to big endian 00064 return self.cmdrsp('vxMemProbe', addr, GMem.__VX_WRITE, size, input) 00065 00066 def gMEMbusToLocal(self, space, addr): 00067 """Translate an address in some space to local (PPC) space 00068 00069 \param space Bus address space in which \a addr resides 00070 \param addr Bus address to convert 00071 \return A tuple containing the user id, status, local address value and timestamp 00072 00073 """ 00074 return self.cmdrsp('sysBusToLocalAdrs', space, addr, '!I') 00075 00076 def gMEMlocalToBus(self, space, addr): 00077 """Translate an address in local (PPC) space to some space 00078 00079 \param space Bus address space in which \a addr resides 00080 \param addr Local address to convert 00081 \return A tuple containing the user id, status, bus address value and timestamp 00082 00083 """ 00084 return self.cmdrsp('sysLocalToBusAdrs', space, addr, '!I')