| Line 1185... |
Line 1185... |
| 1185 |
def malloc(self, size):
|
1185 |
def malloc(self, size):
|
| 1186 |
""" Allocates <size> bytes and returns a pointer to the allocated memory """
|
1186 |
""" Allocates <size> bytes and returns a pointer to the allocated memory """
|
| 1187 |
size = self._hexint(size)
|
1187 |
size = self._hexint(size)
|
| 1188 |
self.logger.info("Allocating %d bytes of memory\n" % size)
|
1188 |
self.logger.info("Allocating %d bytes of memory\n" % size)
|
| 1189 |
addr = self.emcore.malloc(size)
|
1189 |
addr = self.emcore.malloc(size)
|
| 1190 |
self.logger.info("Allocated %d bytes of memory at 0x%x\n" % (size, addr))
|
1190 |
self.logger.info("Allocated %d bytes of memory at 0x%X\n" % (size, addr))
|
| 1191 |
|
1191 |
|
| 1192 |
@command
|
1192 |
@command
|
| 1193 |
def memalign(self, align, size):
|
1193 |
def memalign(self, align, size):
|
| 1194 |
""" Allocates <size> bytes aligned to <align> and returns a pointer to the allocated memory """
|
1194 |
""" Allocates <size> bytes aligned to <align> and returns a pointer to the allocated memory """
|
| 1195 |
align = self._hexint(align)
|
1195 |
align = self._hexint(align)
|
| 1196 |
size = self._hexint(size)
|
1196 |
size = self._hexint(size)
|
| 1197 |
self.logger.info("Allocating %d bytes of memory aligned to 0x%x\n" % (size, align))
|
1197 |
self.logger.info("Allocating %d bytes of memory aligned to 0x%X\n" % (size, align))
|
| 1198 |
addr = self.emcore.memalign(align, size)
|
1198 |
addr = self.emcore.memalign(align, size)
|
| 1199 |
self.logger.info("Allocated %d bytes of memory at 0x%x\n" % (size, addr))
|
1199 |
self.logger.info("Allocated %d bytes of memory at 0x%X\n" % (size, addr))
|
| 1200 |
|
1200 |
|
| 1201 |
@command
|
1201 |
@command
|
| 1202 |
def realloc(self, ptr, size):
|
1202 |
def realloc(self, ptr, size):
|
| 1203 |
""" The size of the memory block pointed to by <ptr> is changed to the <size> bytes,
|
1203 |
""" The size of the memory block pointed to by <ptr> is changed to the <size> bytes,
|
| 1204 |
expanding or reducing the amount of memory available in the block.
|
1204 |
expanding or reducing the amount of memory available in the block.
|
| 1205 |
Returns a pointer to the reallocated memory.
|
1205 |
Returns a pointer to the reallocated memory.
|
| 1206 |
"""
|
1206 |
"""
|
| 1207 |
ptr = self._hexint(ptr)
|
1207 |
ptr = self._hexint(ptr)
|
| 1208 |
size = self._hexint(size)
|
1208 |
size = self._hexint(size)
|
| 1209 |
self.logger.info("Reallocating 0x%x to have the new size %d\n" % (ptr, size))
|
1209 |
self.logger.info("Reallocating 0x%X to have the new size %d\n" % (ptr, size))
|
| 1210 |
addr = self.emcore.realloc(ptr, size)
|
1210 |
addr = self.emcore.realloc(ptr, size)
|
| 1211 |
self.logger.info("Reallocated memory at 0x%x to 0x%x with the new size %d\n" % (ptr, addr, size))
|
1211 |
self.logger.info("Reallocated memory at 0x%X to 0x%X with the new size %d\n" % (ptr, addr, size))
|
| 1212 |
|
1212 |
|
| 1213 |
@command
|
1213 |
@command
|
| 1214 |
def reownalloc(self, ptr, owner):
|
1214 |
def reownalloc(self, ptr, owner):
|
| 1215 |
""" Changes the owner of the memory allocation <ptr> to the thread struct at addr <owner> """
|
1215 |
""" Changes the owner of the memory allocation <ptr> to the thread struct at addr <owner> """
|
| 1216 |
ptr = self._hexint(ptr)
|
1216 |
ptr = self._hexint(ptr)
|
| 1217 |
owner = self._hexint(owner)
|
1217 |
owner = self._hexint(owner)
|
| 1218 |
self.logger.info("Changing owner of the memory region 0x%x to 0x%x\n" % (ptr, owner))
|
1218 |
self.logger.info("Changing owner of the memory region 0x%X to 0x%X\n" % (ptr, owner))
|
| 1219 |
self.emcore.reownalloc(ptr, owner)
|
1219 |
self.emcore.reownalloc(ptr, owner)
|
| 1220 |
self.logger.info("Successfully changed owner of 0x%x to 0x%x\n" % (ptr, owner))
|
1220 |
self.logger.info("Successfully changed owner of 0x%X to 0x%X\n" % (ptr, owner))
|
| 1221 |
|
1221 |
|
| 1222 |
@command
|
1222 |
@command
|
| 1223 |
def free(self, ptr):
|
1223 |
def free(self, ptr):
|
| 1224 |
""" Frees the memory space pointed to by 'ptr' """
|
1224 |
""" Frees the memory space pointed to by 'ptr' """
|
| 1225 |
ptr = self._hexint(ptr)
|
1225 |
ptr = self._hexint(ptr)
|
| 1226 |
self.logger.info("Freeing the memory region at 0x%x\n" % ptr)
|
1226 |
self.logger.info("Freeing the memory region at 0x%X\n" % ptr)
|
| 1227 |
self.emcore.free(ptr)
|
1227 |
self.emcore.free(ptr)
|
| 1228 |
self.logger.info("Successfully freed the memory region at 0x%x\n" % ptr)
|
1228 |
self.logger.info("Successfully freed the memory region at 0x%X\n" % ptr)
|
| 1229 |
|
1229 |
|
| 1230 |
@command
|
1230 |
@command
|
| 1231 |
def free_all(self):
|
1231 |
def free_all(self):
|
| 1232 |
""" Frees all memory allocations created by the monitor thread """
|
1232 |
""" Frees all memory allocations created by the monitor thread """
|
| 1233 |
self.logger.info("Freeing all memory allocations created by the monitor thread\n")
|
1233 |
self.logger.info("Freeing all memory allocations created by the monitor thread\n")
|