Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Leger2012-09-24 10:45:02 -0400
committerAnton Leherbauer2012-09-24 10:45:02 -0400
commit9b59f7ed4b5292f49c9e244d17365acf601d3c4f (patch)
treeb40ea338961254516fa79418622d9f4f6629580e /python/src/tcf/services/memory.py
parent40e77cd79e5344d6cab49acdc7808de9434668ed (diff)
downloadorg.eclipse.tcf-9b59f7ed4b5292f49c9e244d17365acf601d3c4f.tar.gz
org.eclipse.tcf-9b59f7ed4b5292f49c9e244d17365acf601d3c4f.tar.xz
org.eclipse.tcf-9b59f7ed4b5292f49c9e244d17365acf601d3c4f.zip
TCF Python: Bug 390178 - Missing APIs/properties in python services
interfaces and proxies
Diffstat (limited to 'python/src/tcf/services/memory.py')
-rw-r--r--python/src/tcf/services/memory.py160
1 files changed, 107 insertions, 53 deletions
diff --git a/python/src/tcf/services/memory.py b/python/src/tcf/services/memory.py
index 40a0c007a..2bdc4fc74 100644
--- a/python/src/tcf/services/memory.py
+++ b/python/src/tcf/services/memory.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v1.0
# * which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
"""
Memory service provides basic operations to read/write memory on a target.
@@ -18,34 +18,72 @@ from tcf import services
NAME = "Memory"
# Context property names.
-PROP_ID = "ID" # String, ID of the context, same as getContext command argument
-PROP_PARENT_ID = "ParentID" # String, ID of a parent context
-PROP_PROCESS_ID = "ProcessID" # String, process ID, see Processes service
-PROP_BIG_ENDIAN = "BigEndian" # Boolean, True if memory is big-endian
-PROP_ADDRESS_SIZE = "AddressSize" # Number, size of memory address in bytes
-PROP_NAME = "Name" # String, name of the context, can be used for UI purposes
-PROP_START_BOUND = "StartBound" # Number, lowest address (inclusive) which is valid for the context
-PROP_END_BOUND = "EndBound" # Number, highest address (inclusive) which is valid for the context
-PROP_ACCESS_TYPES = "AccessTypes" # Array of String, the access types allowed for this context
+# String, ID of the context, same as getContext command argument
+PROP_ID = "ID"
+
+# String, ID of a parent context
+PROP_PARENT_ID = "ParentID"
+
+# String, process ID, see Processes service
+PROP_PROCESS_ID = "ProcessID"
+
+# Boolean, True if memory is big-endian
+PROP_BIG_ENDIAN = "BigEndian"
+
+# Number, size of memory address in bytes
+PROP_ADDRESS_SIZE = "AddressSize"
+
+# String, name of the context, can be used for UI purposes
+PROP_NAME = "Name"
+
+# Number, lowest address (inclusive) which is valid for the context
+PROP_START_BOUND = "StartBound"
+
+# Number, highest address (inclusive) which is valid for the context
+PROP_END_BOUND = "EndBound"
+
+# Array of String, the access types allowed for this context
+PROP_ACCESS_TYPES = "AccessTypes"
# Values of "AccessTypes".
-# Target system can support multiple different memory access types, like instruction and data access.
-# Different access types can use different logic for address translation and memory mapping, so they can
-# end up accessing different data bits, even if address is the same.
+# Target system can support multiple different memory access types, like
+# instruction and data access. Different access types can use different logic
+# for address translation and memory mapping, so they can end up accessing
+# different data bits, even if address is the same.
# Each distinct access type should be represented by separate memory context.
-# A memory context can represent multiple access types if they are equivalent - all access same memory bits.
+# A memory context can represent multiple access types if they are
+# equivalent - all access same memory bits.
# Same data bits can be exposed through multiple memory contexts.
-ACCESS_INSTRUCTION = "instruction" # Context represent instructions fetch access
-ACCESS_DATA = "data" # Context represents data access
-ACCESS_IO = "io" # Context represents IO peripherals
-ACCESS_USER = "user" # Context represents a user (e.g. application running in Linux) view to memory
-ACCESS_SUPERVISOR = "supervisor" # Context represents a supervisor (e.g. Linux kernel) view to memory
-ACCESS_HYPERVISOR = "hypervisor" # Context represents a hypervisor view to memory
-ACCESS_VIRTUAL = "virtual" # Context uses virtual addresses
-ACCESS_PHYSICAL = "physical" # Context uses physical addresses
-ACCESS_CACHE = "cache" # Context is a cache
-ACCESS_TLB = "tlb" # Context is a TLB memory
+# Context represent instructions fetch access
+ACCESS_INSTRUCTION = "instruction"
+
+# Context represents data access
+ACCESS_DATA = "data"
+
+# Context represents IO peripherals
+ACCESS_IO = "io"
+
+# Context represents a user (e.g. application running in Linux) view to memory
+ACCESS_USER = "user"
+
+# Context represents a supervisor (e.g. Linux kernel) view to memory
+ACCESS_SUPERVISOR = "supervisor"
+
+# Context represents a hypervisor view to memory
+ACCESS_HYPERVISOR = "hypervisor"
+
+# Context uses virtual addresses
+ACCESS_VIRTUAL = "virtual"
+
+# Context uses physical addresses
+ACCESS_PHYSICAL = "physical"
+
+# Context is a cache
+ACCESS_CACHE = "cache"
+
+# Context is a TLB memory
+ACCESS_TLB = "tlb"
# Memory access mode:
# Carry on when some of the memory cannot be accessed and
@@ -57,7 +95,9 @@ MODE_CONTINUEONERROR = 0x1
# Verify result of memory operations (by reading and comparing).
MODE_VERIFY = 0x2
+
class MemoryContext(object):
+
def __init__(self, props):
self._props = props or {}
@@ -67,7 +107,8 @@ class MemoryContext(object):
def getProperties(self):
"""
Get context properties. See PROP_* definitions for property names.
- Context properties are read only, clients should not try to modify them.
+ Context properties are read only, clients should not try to modify
+ them.
@return Map of context properties.
"""
return self._props
@@ -136,10 +177,10 @@ class MemoryContext(object):
"""
return self._props.get(PROP_ACCESS_TYPES)
- def set(self, addr, word_size, buf, offs, size, mode, done):
+ def set(self, addr, ws, buf, offs, sz, mode, done): # @ReservedAssignment
"""
Set target memory.
- If 'word_size' is 0 it means client does not care about word size.
+ If 'ws' is 0 it means client does not care about word size.
"""
raise NotImplementedError("Abstract method")
@@ -156,6 +197,7 @@ class MemoryContext(object):
"""
raise NotImplementedError("Abstract method")
+
class DoneMemory(object):
"""
Client call back interface for set(), get() and fill() commands.
@@ -163,9 +205,11 @@ class DoneMemory(object):
def doneMemory(self, token, error):
pass
-class MemoryError(Exception):
+
+class MemoryError(Exception): # @ReservedAssignment
pass
+
class ErrorOffset(object):
"""
ErrorOffset may be implemented by MemoryError object,
@@ -179,16 +223,16 @@ class ErrorOffset(object):
possible reasons of partial memory operation.
"""
# Error may have per byte information
- BYTE_VALID = 0x00
- BYTE_UNKNOWN = 0x01 # e.g. out of range
- BYTE_INVALID = 0x02
- BYTE_CANNOT_READ = 0x04
+ BYTE_VALID = 0x00
+ BYTE_UNKNOWN = 0x01 # e.g. out of range
+ BYTE_INVALID = 0x02
+ BYTE_CANNOT_READ = 0x04
BYTE_CANNOT_WRITE = 0x08
- RANGE_KEY_ADDR = "addr"
- RANGE_KEY_SIZE = "size"
- RANGE_KEY_STAT = "stat"
- RANGE_KEY_MSG = "msg"
+ RANGE_KEY_ADDR = "addr"
+ RANGE_KEY_SIZE = "size"
+ RANGE_KEY_STAT = "stat"
+ RANGE_KEY_MSG = "msg"
def getStatus(self, offset):
raise NotImplementedError("Abstract method")
@@ -196,15 +240,17 @@ class ErrorOffset(object):
def getMessage(self, offset):
raise NotImplementedError("Abstract method")
+
class MemoryService(services.Service):
+
def getName(self):
return NAME
- def getContext(self, id, done):
+ def getContext(self, contextID, done):
"""
Retrieve context info for given context ID.
- @param id - context ID.
+ @param contextID - context ID.
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
@@ -213,17 +259,20 @@ class MemoryService(services.Service):
def getChildren(self, parent_context_id, done):
"""
Retrieve contexts available for memory commands.
- A context corresponds to an execution thread, process, address space, etc.
- A context can belong to a parent context. Contexts hierarchy can be simple
- plain list or it can form a tree. It is up to target agent developers to choose
- layout that is most descriptive for a given target. Context IDs are valid across
- all services. In other words, all services access same hierarchy of contexts,
- with same IDs, however, each service accesses its own subset of context's
- attributes and functionality, which is relevant to that service.
-
- @param parent_context_id - parent context ID. Can be None -
- to retrieve top level of the hierarchy, or one of context IDs retrieved
- by previous getChildren commands.
+ A context corresponds to an execution thread, process, address space,
+ etc.
+ A context can belong to a parent context. Contexts hierarchy can be
+ simple plain list or it can form a tree. It is up to target agent
+ developers to choose layout that is most descriptive for a given
+ target. Context IDs are valid across all services. In other words, all
+ services access same hierarchy of contexts, with same IDs, however,
+ each service accesses its own subset of context's attributes and
+ functionality, which is relevant to that service.
+
+ @param parent_context_id - parent context ID. Can be None - to retrieve
+ top level of the hierarchy, or one of
+ context IDs retrieved by previous
+ getChildren commands.
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
@@ -243,6 +292,7 @@ class MemoryService(services.Service):
"""
raise NotImplementedError("Abstract method")
+
class MemoryListener(object):
"""
Memory event listener is notified when memory context hierarchy
@@ -278,6 +328,7 @@ class MemoryListener(object):
"""
pass
+
class DoneGetContext(object):
"""
Client call back interface for getContext().
@@ -285,11 +336,13 @@ class DoneGetContext(object):
def doneGetContext(self, token, error, context):
"""
Called when context data retrieval is done.
- @param error - error description if operation failed, None if succeeded.
+ @param error - error description if operation failed, None if
+ succeeded.
@param context - context data.
"""
pass
+
class DoneGetChildren(object):
"""
Client call back interface for getChildren().
@@ -297,7 +350,8 @@ class DoneGetChildren(object):
def doneGetChildren(self, token, error, context_ids):
"""
Called when context list retrieval is done.
- @param error - error description if operation failed, None if succeeded.
+ @param error - error description if operation failed, None if
+ succeeded.
@param context_ids - array of available context IDs.
"""
pass

Back to the top