[cooja] Reintroduced offset handling for absolute address space
This commit is contained in:
parent
3da6c6d55a
commit
0f2837320c
|
@ -474,19 +474,6 @@ public class ContikiMoteType implements MoteType {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Symbol> vars = bssSecParser.parseSymbols();
|
|
||||||
for (Symbol s : vars.values()) {
|
|
||||||
if (s.name.equals("referenceVar")) {
|
|
||||||
/* Relative <-> absolute addresses offset */
|
|
||||||
int referenceVar = (int) s.addr;
|
|
||||||
myCoreComm.setReferenceAddress(referenceVar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new MoteTypeCreationException("JNI call error: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We first need the value of Contiki's referenceVar, which tells us the
|
/* We first need the value of Contiki's referenceVar, which tells us the
|
||||||
* memory offset between Contiki's variable and the relative addresses that
|
* memory offset between Contiki's variable and the relative addresses that
|
||||||
* were calculated directly from the library file.
|
* were calculated directly from the library file.
|
||||||
|
@ -496,9 +483,9 @@ public class ContikiMoteType implements MoteType {
|
||||||
{
|
{
|
||||||
SectionMoteMemory tmp = new SectionMoteMemory(variables);
|
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(0));
|
||||||
|
|
||||||
tmp.addMemorySection("tmp.bss", bssSecParser.parse());
|
tmp.addMemorySection("tmp.bss", bssSecParser.parse(0));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int referenceVar = (int) varMem.getVariable("referenceVar").addr;
|
int referenceVar = (int) varMem.getVariable("referenceVar").addr;
|
||||||
|
@ -507,25 +494,24 @@ public class ContikiMoteType implements MoteType {
|
||||||
throw new MoteTypeCreationException("JNI call error: " + e.getMessage(), e);
|
throw new MoteTypeCreationException("JNI call error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getCoreMemory(tmp);
|
getCoreMemory(tmp);
|
||||||
|
|
||||||
offset = varMem.getIntValueOf("referenceVar");
|
offset = varMem.getIntValueOf("referenceVar") & 0xFFFFFFFFL;
|
||||||
logger.info(getContikiFirmwareFile().getName()
|
logger.info(getContikiFirmwareFile().getName()
|
||||||
+ ": offsetting Cooja mote address space: " + Long.toHexString(offset));
|
+ ": offsetting Cooja mote address space: 0x" + Long.toHexString(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create initial memory: data+bss+optional common */
|
/* Create initial memory: data+bss+optional common */
|
||||||
initialMemory = new SectionMoteMemory(variables);
|
initialMemory = new SectionMoteMemory(variables);
|
||||||
|
|
||||||
initialMemory.addMemorySection("data", dataSecParser.parse());
|
initialMemory.addMemorySection("data", dataSecParser.parse(offset));
|
||||||
|
|
||||||
initialMemory.addMemorySection("bss", bssSecParser.parse());
|
initialMemory.addMemorySection("bss", bssSecParser.parse(offset));
|
||||||
|
|
||||||
initialMemory.addMemorySection("common", commonSecParser.parse());
|
initialMemory.addMemorySection("common", commonSecParser.parse(offset));
|
||||||
|
|
||||||
if (readonlySecParser != null) {
|
if (readonlySecParser != null) {
|
||||||
initialMemory.addMemorySection("readonly", readonlySecParser.parse());
|
initialMemory.addMemorySection("readonly", readonlySecParser.parse(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
getCoreMemory(initialMemory);
|
getCoreMemory(initialMemory);
|
||||||
|
@ -560,7 +546,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
|
|
||||||
protected abstract void parseSize();
|
protected abstract void parseSize();
|
||||||
|
|
||||||
abstract Map<String, Symbol> parseSymbols();
|
abstract Map<String, Symbol> parseSymbols(long offset);
|
||||||
|
|
||||||
protected int parseFirstHexInt(String regexp, String[] data) {
|
protected int parseFirstHexInt(String regexp, String[] data) {
|
||||||
String retString = getFirstMatchGroup(data, regexp, 1);
|
String retString = getFirstMatchGroup(data, regexp, 1);
|
||||||
|
@ -572,7 +558,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
return Integer.parseInt(retString.trim(), 16);
|
return Integer.parseInt(retString.trim(), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemoryInterface parse() {
|
public MemoryInterface parse(long offset) {
|
||||||
|
|
||||||
/* Parse start address and size of section */
|
/* Parse start address and size of section */
|
||||||
parseStartAddr();
|
parseStartAddr();
|
||||||
|
@ -582,10 +568,10 @@ public class ContikiMoteType implements MoteType {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Symbol> variables = parseSymbols();
|
Map<String, Symbol> variables = parseSymbols(offset);
|
||||||
|
|
||||||
logger.info(String.format("Parsed section at 0x%x ( %d == 0x%x bytes)",
|
logger.info(String.format("Parsed section at 0x%x ( %d == 0x%x bytes)",
|
||||||
getStartAddr(),
|
getStartAddr() + offset,
|
||||||
getSize(),
|
getSize(),
|
||||||
getSize()));
|
getSize()));
|
||||||
|
|
||||||
|
@ -598,9 +584,8 @@ public class ContikiMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ArrayMemory(
|
return new ArrayMemory(
|
||||||
getStartAddr(),
|
getStartAddr() + offset,
|
||||||
getSize(),
|
getSize(),
|
||||||
MemoryLayout.getNative(),
|
MemoryLayout.getNative(),
|
||||||
variables);
|
variables);
|
||||||
|
@ -641,7 +626,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Symbol> parseSymbols() {
|
public Map<String, Symbol> parseSymbols(long offset) {
|
||||||
Map<String, Symbol> varNames = new HashMap<>();
|
Map<String, Symbol> varNames = new HashMap<>();
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(Cooja.getExternalToolsSetting("MAPFILE_VAR_NAME"));
|
Pattern pattern = Pattern.compile(Cooja.getExternalToolsSetting("MAPFILE_VAR_NAME"));
|
||||||
|
@ -654,7 +639,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
varNames.put(varName, new Symbol(
|
varNames.put(varName, new Symbol(
|
||||||
Symbol.Type.VARIABLE,
|
Symbol.Type.VARIABLE,
|
||||||
varName,
|
varName,
|
||||||
getMapFileVarAddress(getData(), varName),
|
getMapFileVarAddress(getData(), varName) + offset,
|
||||||
getMapFileVarSize(getData(), varName)));
|
getMapFileVarSize(getData(), varName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +746,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Symbol> parseSymbols() {
|
public Map<String, Symbol> parseSymbols(long offset) {
|
||||||
HashMap<String, Symbol> addresses = new HashMap<>();
|
HashMap<String, Symbol> addresses = new HashMap<>();
|
||||||
/* Replace "<SECTION>" in regexp by section specific regex */
|
/* Replace "<SECTION>" in regexp by section specific regex */
|
||||||
Pattern pattern = Pattern.compile(
|
Pattern pattern = Pattern.compile(
|
||||||
|
@ -774,7 +759,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
/* Line matched variable address */
|
/* Line matched variable address */
|
||||||
String symbol = matcher.group(1);
|
String symbol = matcher.group(1);
|
||||||
int varAddr = Integer.parseInt(matcher.group(2), 16);
|
long varAddr = Integer.parseInt(matcher.group(2), 16) + offset;
|
||||||
int varSize;
|
int varSize;
|
||||||
if (matcher.group(3) != null) {
|
if (matcher.group(3) != null) {
|
||||||
varSize = Integer.parseInt(matcher.group(3), 16);
|
varSize = Integer.parseInt(matcher.group(3), 16);
|
||||||
|
@ -827,7 +812,10 @@ public class ContikiMoteType implements MoteType {
|
||||||
*/
|
*/
|
||||||
public void getCoreMemory(SectionMoteMemory mem) {
|
public void getCoreMemory(SectionMoteMemory mem) {
|
||||||
for (MemoryInterface section : mem.getSections().values()) {
|
for (MemoryInterface section : mem.getSections().values()) {
|
||||||
getCoreMemory((int) section.getStartAddr(), section.getTotalSize(), section.getMemory());
|
getCoreMemory(
|
||||||
|
(int) (section.getStartAddr() - offset),
|
||||||
|
section.getTotalSize(),
|
||||||
|
section.getMemory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +832,10 @@ public class ContikiMoteType implements MoteType {
|
||||||
*/
|
*/
|
||||||
public void setCoreMemory(SectionMoteMemory mem) {
|
public void setCoreMemory(SectionMoteMemory mem) {
|
||||||
for (MemoryInterface section : mem.getSections().values()) {
|
for (MemoryInterface section : mem.getSections().values()) {
|
||||||
setCoreMemory((int) section.getStartAddr(), section.getTotalSize(), section.getMemory());
|
setCoreMemory(
|
||||||
|
(int) (section.getStartAddr() - offset),
|
||||||
|
section.getTotalSize(),
|
||||||
|
section.getMemory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -776,8 +776,8 @@ public class ConfigurationWizard extends JDialog {
|
||||||
mapData,
|
mapData,
|
||||||
Cooja.getExternalToolsSetting("MAPFILE_BSS_START"),
|
Cooja.getExternalToolsSetting("MAPFILE_BSS_START"),
|
||||||
Cooja.getExternalToolsSetting("MAPFILE_BSS_SIZE"));
|
Cooja.getExternalToolsSetting("MAPFILE_BSS_SIZE"));
|
||||||
dataSecParser.parse();
|
dataSecParser.parse(0);
|
||||||
bssSecParser.parse();
|
bssSecParser.parse(0);
|
||||||
relDataSectionAddr = dataSecParser.getStartAddr();
|
relDataSectionAddr = dataSecParser.getStartAddr();
|
||||||
dataSectionSize = dataSecParser.getSize();
|
dataSectionSize = dataSecParser.getSize();
|
||||||
relBssSectionAddr = bssSecParser.getStartAddr();
|
relBssSectionAddr = bssSecParser.getStartAddr();
|
||||||
|
@ -869,8 +869,8 @@ public class ConfigurationWizard extends JDialog {
|
||||||
Cooja.getExternalToolsSetting("COMMAND_BSS_SIZE"),
|
Cooja.getExternalToolsSetting("COMMAND_BSS_SIZE"),
|
||||||
Cooja.getExternalToolsSetting("COMMAND_VAR_SEC_BSS"));
|
Cooja.getExternalToolsSetting("COMMAND_VAR_SEC_BSS"));
|
||||||
|
|
||||||
dataSecParser.parse();
|
dataSecParser.parse(0);
|
||||||
bssSecParser.parse();
|
bssSecParser.parse(0);
|
||||||
relDataSectionAddr = dataSecParser.getStartAddr();
|
relDataSectionAddr = dataSecParser.getStartAddr();
|
||||||
dataSectionSize = dataSecParser.getSize();
|
dataSectionSize = dataSecParser.getSize();
|
||||||
relBssSectionAddr = bssSecParser.getStartAddr();
|
relBssSectionAddr = bssSecParser.getStartAddr();
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class SectionMoteMemory implements MemoryInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addSegmentMonitor(SegmentMonitor.EventType flag, long address, int size, SegmentMonitor monitor) {
|
public boolean addSegmentMonitor(SegmentMonitor.EventType flag, long address, int size, SegmentMonitor monitor) {
|
||||||
PolledMemorySegments t = new PolledMemorySegments(monitor, (int) address, size);
|
PolledMemorySegments t = new PolledMemorySegments(monitor, address, size);
|
||||||
polledMemories.add(t);
|
polledMemories.add(t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -304,11 +304,11 @@ public class SectionMoteMemory implements MemoryInterface {
|
||||||
|
|
||||||
private class PolledMemorySegments {
|
private class PolledMemorySegments {
|
||||||
public final SegmentMonitor mm;
|
public final SegmentMonitor mm;
|
||||||
public final int address;
|
public final long address;
|
||||||
public final int size;
|
public final int size;
|
||||||
private byte[] oldMem;
|
private byte[] oldMem;
|
||||||
|
|
||||||
public PolledMemorySegments(SegmentMonitor mm, int address, int size) {
|
public PolledMemorySegments(SegmentMonitor mm, long address, int size) {
|
||||||
this.mm = mm;
|
this.mm = mm;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
Loading…
Reference in a new issue