[cooja] Removed offset from SectionMoteMemory to make it more generic
This commit is contained in:
parent
c5ff3555a0
commit
66d4dad1e1
4 changed files with 10 additions and 17 deletions
|
@ -212,6 +212,9 @@ public class ContikiMoteType implements MoteType {
|
|||
// Initial memory for all motes of this type
|
||||
private SectionMoteMemory initialMemory = null;
|
||||
|
||||
/** Offset between native (cooja) and contiki address space */
|
||||
long offset;
|
||||
|
||||
/**
|
||||
* Creates a new uninitialized Cooja mote type. This mote type needs to load
|
||||
* a library file and parse a map file before it can be used.
|
||||
|
@ -484,9 +487,8 @@ public class ContikiMoteType implements MoteType {
|
|||
*
|
||||
* This offset will be used in Cooja in the memory abstraction to match
|
||||
* Contiki's and Cooja's address spaces */
|
||||
int offset;
|
||||
{
|
||||
SectionMoteMemory tmp = new SectionMoteMemory(variables, 0);
|
||||
SectionMoteMemory tmp = new SectionMoteMemory(variables);
|
||||
VarMemory varMem = new VarMemory(tmp);
|
||||
tmp.addMemorySection("tmp.data", dataSecParser.parse());
|
||||
|
||||
|
@ -508,7 +510,7 @@ public class ContikiMoteType implements MoteType {
|
|||
}
|
||||
|
||||
/* Create initial memory: data+bss+optional common */
|
||||
initialMemory = new SectionMoteMemory(variables, offset);
|
||||
initialMemory = new SectionMoteMemory(variables);
|
||||
|
||||
initialMemory.addMemorySection("data", dataSecParser.parse());
|
||||
|
||||
|
|
|
@ -963,7 +963,7 @@ public class ConfigurationWizard extends JDialog {
|
|||
byte[] initialBssSection = new byte[bssSectionSize];
|
||||
javaLibrary.getMemory(relDataSectionAddr, dataSectionSize, initialDataSection);
|
||||
javaLibrary.getMemory(relBssSectionAddr, bssSectionSize, initialBssSection);
|
||||
SectionMoteMemory memory = new SectionMoteMemory(addresses, 0);
|
||||
SectionMoteMemory memory = new SectionMoteMemory(addresses);
|
||||
VarMemory varMem = new VarMemory(memory);
|
||||
memory.setMemorySegment(relDataSectionAddr, initialDataSection);
|
||||
memory.setMemorySegment(relBssSectionAddr, initialBssSection);
|
||||
|
|
|
@ -57,16 +57,11 @@ public class SectionMoteMemory implements MemoryInterface {
|
|||
private MemoryLayout memLayout;
|
||||
private long startAddr = Long.MAX_VALUE;
|
||||
|
||||
/* used to map Cooja's address space to native (Contiki's) addresses */
|
||||
private final int offset;
|
||||
|
||||
/**
|
||||
* @param symbols Symbol addresses
|
||||
* @param offset Offset for internally used addresses
|
||||
*/
|
||||
public SectionMoteMemory(Map<String, Symbol> symbols, int offset) {
|
||||
public SectionMoteMemory(Map<String, Symbol> symbols) {
|
||||
this.symbols = symbols;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,10 +243,6 @@ public class SectionMoteMemory implements MemoryInterface {
|
|||
address, address + data.length - 1);
|
||||
}
|
||||
|
||||
public void setMemorySegmentNative(long address, byte[] data) throws MoteMemoryException {
|
||||
setMemorySegment(address + offset, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartAddr() {
|
||||
return startAddr;
|
||||
|
@ -292,7 +283,7 @@ public class SectionMoteMemory implements MemoryInterface {
|
|||
@Override
|
||||
public SectionMoteMemory clone() {
|
||||
|
||||
SectionMoteMemory clone = new SectionMoteMemory(symbols, offset);
|
||||
SectionMoteMemory clone = new SectionMoteMemory(symbols);
|
||||
|
||||
for (String secname : sections.keySet()) {
|
||||
// Copy section memory to new ArrayMemory
|
||||
|
|
|
@ -92,7 +92,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
setSimulation(sim);
|
||||
this.moteType = moteType;
|
||||
MemoryLayout.getNative();
|
||||
this.memory = new SectionMoteMemory(new HashMap<String, Symbol>(), 0);
|
||||
this.memory = new SectionMoteMemory(new HashMap<String, Symbol>());
|
||||
this.moteInterfaces = new MoteInterfaceHandler(this, moteType.getMoteInterfaceClasses());
|
||||
this.moteInterfaces.getRadio().addObserver(radioDataObserver);
|
||||
requestImmediateWakeup();
|
||||
|
@ -152,7 +152,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
public boolean setConfigXML(Simulation simulation,
|
||||
Collection<Element> configXML, boolean visAvailable) {
|
||||
setSimulation(simulation);
|
||||
this.memory = new SectionMoteMemory(new HashMap<String, Symbol>(), 0);
|
||||
this.memory = new SectionMoteMemory(new HashMap<String, Symbol>());
|
||||
moteInterfaces.getRadio().addObserver(radioDataObserver);
|
||||
|
||||
for (Element element : configXML) {
|
||||
|
|
Loading…
Reference in a new issue