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