| Line 818... |
Line 818... |
| 818 |
result = self.lib.monitorcommand(struct.pack("IIII", 51, volume, 0, 0), "III", ("rc", None, None))
|
818 |
result = self.lib.monitorcommand(struct.pack("IIII", 51, volume, 0, 0), "III", ("rc", None, None))
|
| 819 |
if result.rc > 0x80000000:
|
819 |
if result.rc > 0x80000000:
|
| 820 |
raise DeviceError("disk_unmount(volume=%d) failed with RC=0x%08X, errno=%d" % (volume, result.rc, self.errno()))
|
820 |
raise DeviceError("disk_unmount(volume=%d) failed with RC=0x%08X, errno=%d" % (volume, result.rc, self.errno()))
|
| 821 |
return result.rc
|
821 |
return result.rc
|
| 822 |
|
822 |
|
| - |
|
823 |
@command()
|
| - |
|
824 |
def malloc(self, size):
|
| - |
|
825 |
""" Allocates 'size' bytes and returns a pointer to the allocated memory """
|
| - |
|
826 |
result = self.lib.monitorcommand(struct.pack("IIII", 52, size, 0, 0), "III", ("ptr", None, None))
|
| - |
|
827 |
return result.ptr
|
| - |
|
828 |
|
| - |
|
829 |
@command()
|
| - |
|
830 |
def memalign(self, align, size):
|
| - |
|
831 |
""" Allocates 'size' bytes aligned to 'align' and returns a pointer to the allocated memory """
|
| - |
|
832 |
result = self.lib.monitorcommand(struct.pack("IIII", 53, align, size, 0), "III", ("ptr", None, None))
|
| - |
|
833 |
return result.ptr
|
| - |
|
834 |
|
| - |
|
835 |
@command()
|
| - |
|
836 |
def realloc(self, ptr, size):
|
| - |
|
837 |
""" The size of the memory block pointed to by 'ptr' is changed to the 'size' bytes,
|
| - |
|
838 |
expanding or reducing the amount of memory available in the block.
|
| - |
|
839 |
Returns a pointer to the reallocated memory.
|
| - |
|
840 |
"""
|
| - |
|
841 |
result = self.lib.monitorcommand(struct.pack("IIII", 54, ptr, size, 0), "III", ("ptr", None, None))
|
| - |
|
842 |
return result.ptr
|
| - |
|
843 |
|
| - |
|
844 |
@command()
|
| - |
|
845 |
def reownalloc(self, ptr, owner):
|
| - |
|
846 |
""" Changes the owner of the memory allocation 'ptr' to the thread struct at addr 'owner' """
|
| - |
|
847 |
return self.lib.monitorcommand(struct.pack("IIII", 55, ptr, owner, 0), "III", (None, None, None))
|
| - |
|
848 |
|
| - |
|
849 |
@command()
|
| - |
|
850 |
def free(self, ptr):
|
| - |
|
851 |
""" Frees the memory space pointed to by 'ptr' """
|
| - |
|
852 |
return self.lib.monitorcommand(struct.pack("IIII", 56, addr, 0, 0), "III", (None, None, None))
|
| - |
|
853 |
|
| 823 |
|
854 |
|
| 824 |
class Lib(object):
|
855 |
class Lib(object):
|
| 825 |
def __init__(self, logger):
|
856 |
def __init__(self, logger):
|
| 826 |
self.logger = logger
|
857 |
self.logger = logger
|
| 827 |
self.logger.debug("Initializing Lib object\n")
|
858 |
self.logger.debug("Initializing Lib object\n")
|
| Line 1022... |
Line 1053... |
| 1022 |
cmddict = {}
|
1053 |
cmddict = {}
|
| 1023 |
for attr, value in Emcore.__dict__.iteritems():
|
1054 |
for attr, value in Emcore.__dict__.iteritems():
|
| 1024 |
if getattr(value, 'func', False):
|
1055 |
if getattr(value, 'func', False):
|
| 1025 |
if getattr(value.func, '_command', False):
|
1056 |
if getattr(value.func, '_command', False):
|
| 1026 |
cmddict[value.func.__name__] = value
|
1057 |
cmddict[value.func.__name__] = value
|
| 1027 |
logger.log(gendoc(cmddict))
|
- |
|
| 1028 |
|
1058 |
logger.log(gendoc(cmddict))
|
| - |
|
1059 |
|
| - |
|
1060 |
elif sys.argv[1] == "malloctest":
|
| - |
|
1061 |
emcore = Emcore()
|
| - |
|
1062 |
logger.log("Allocating 200 bytes of memory: ")
|
| - |
|
1063 |
addr = emcore.malloc(200)
|
| - |
|
1064 |
logger.log("0x%x\n" % addr)
|
| - |
|
1065 |
logger.log("Reallocating to 2000 bytes: ")
|
| - |
|
1066 |
addr = emcore.realloc(addr, 2000)
|
| - |
|
1067 |
logger.log("0x%x\n" % addr)
|
| - |
|
1068 |
logger.log("Freeing 0x%x\n" % addr)
|
| - |
|
1069 |
emcore.free(addr)
|
| - |
|
1070 |
logger.log("Allocating 1000 bytes of memory aligned to 100 bytes: ")
|
| - |
|
1071 |
addr = emcore.memalign(100, 1000)
|
| - |
|
1072 |
logger.log("0x%x\n" % addr)
|
| - |
|
1073 |
logger.log("Freeing 0x%x\n" % addr)
|
| - |
|
1074 |
emcore.free(addr)
|
| - |
|
1075 |
|
| 1029 |
|
1076 |
|