- register element attributes added/changed:

* name -> mnemonic
* altmnemonic
* accessmode
* accessattr
- register dict updated
- Register class redesigned

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@114 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-03-16 07:47:05 +00:00
parent 751814e2f2
commit 8708aa2e0e
9 changed files with 2052 additions and 477 deletions

View File

@@ -7,6 +7,8 @@ package ch.ntb.mcdp.dict;
*/
public abstract class Register {
private static final String INIT_STRING = "***";
/**
* Register specific type values. <br>
* The index of each type in the types array represents its numeric value.
@@ -19,59 +21,154 @@ public abstract class Register {
protected static String[] types = null;
/**
* Name of the register. Registers are identified by this value.
* Menemoic of the register. Registers are identified by this value.
*/
public String name = "NOT INITIALISED";
private String mnemonic = INIT_STRING;
/**
* Alternative mnemonic of the register
*/
private String altmnemonic = INIT_STRING;
/**
* Register specific type
*/
public int type;
private int type;
/**
* Address or a register specific value (e.g. BDI-identifier)
*/
public int value;
private int value;
/**
* Size in bytes (width)
*/
public int size;
private int size;
/**
* A string description of the register
*/
public String description;
private String description;
/**
* @param name
* name of the register. Registers are identified by this value.
* @param type
* register specific type
* @param value
* address or a register specific value (e.g. BDI-identifier)
* @param size
* size in bytes
* @param description
* a string description of the register
* @return the mnemonic of this register
*/
public void init(String name, int type, int value, int size,
String description) {
this.name = name;
this.type = type;
this.value = value;
this.size = size;
public String getMnemonic() {
return mnemonic;
}
/**
* Set the mnemonic of this register
*
* @param name
*/
public void setMnemonic(String name) {
this.mnemonic = name;
}
/**
* @return alternative mnemonic of the register
*/
public String getAltmnemonic() {
return altmnemonic;
}
/**
* Set the alternative name of the register.
*
* @param altname
*/
public void setAltmnemonic(String altname) {
this.altmnemonic = altname;
}
/**
* @return the register description
*/
public String getDescription() {
return description;
}
/**
* Set the register description.
*
* @param description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the size in bytes (width)
*/
public int getSize() {
return size;
}
/**
* Set the size in bytes (width)
*
* @param size
*/
public void setSize(int size) {
this.size = size;
}
/**
* @return the type of the register. This is the index of the static
* <code>types</code> String array.
*/
public int getType() {
return type;
}
/**
* Set the type of the register. This is the index of the static
* <code>types</code> String array.
*
* @param type
*/
public void setType(int type) {
this.type = type;
}
/**
* @return the address or a register specific value (e.g. BDI-identifier)
*/
public int getValue() {
return value;
}
/**
* Set the address or a register specific value (e.g. BDI-identifier).
*
* @param value
*/
public void setValue(int value) {
this.value = value;
}
/**
* @return true if a mnemonic was set and the size is valid (size > 0), else
* false
*/
public boolean isValid() {
if ((mnemonic == INIT_STRING) || (size <= 0))
return false;
return true;
}
@Override
public String toString() {
return new String(name + "\t" + types[type] + "\t0x"
+ Integer.toHexString(value) + "\t" + size + "\t" + description);
return new String(mnemonic + "\t" + altmnemonic + "\t" + types[type]
+ "\t0x" + Integer.toHexString(value) + "\t" + size + "\t"
+ description);
}
/**
* Get the register specific type strings.
* Get the register specific type strings. This value has to be initialised
* in the <code>static</code> section of the derived Register class as
* this is Register specific.
*
* @return types strings
*/

View File

@@ -52,7 +52,7 @@ public abstract class RegisterDict {
private static final String DESCRIPTION = "description";
private static final String REG_ATTR_NAME = "name";
private static final String REG_ATTR_MNEMONIC = "mnemonic";
private static final String REG_ATTR_TYPE = "type";
@@ -104,16 +104,22 @@ public abstract class RegisterDict {
String description) {
// remove before add for updates
for (Iterator i = registers.iterator(); i.hasNext();) {
if (((Register) i.next()).name.equals(name)) {
Register r = (Register) i.next();
if (r.getMnemonic().equals(name) || r.getAltmnemonic().equals(name)) {
i.remove();
}
}
Register reg = null;
try {
reg = (Register) regClass.newInstance();
reg.init(name, type, value, size, description);
reg.setMnemonic(name);
reg.setType(type);
reg.setValue(value);
reg.setSize(size);
reg.setDescription(description);
} catch (Exception e) {
e.printStackTrace();
// TODO exception handling
System.exit(1);
}
registers.add(reg);
@@ -149,7 +155,7 @@ public abstract class RegisterDict {
public Register getRegister(String name) {
for (Iterator i = registers.iterator(); i.hasNext();) {
Register r = (Register) i.next();
if (r.name.equals(name)) {
if (r.getMnemonic().equals(name) || r.getAltmnemonic().equals(name)) {
return r;
}
}
@@ -162,7 +168,8 @@ public abstract class RegisterDict {
public void printRegisters() {
System.out
.println("******************** register dictionary *********************");
System.out.println("Name\tType\tAddress\tSize\tDescription");
System.out
.println("Mnemonic\tAltmnemonic\tType\tAddress\tSize\tDescription");
System.out
.println("**************************************************************");
for (Iterator i = registers.iterator(); i.hasNext();) {
@@ -235,7 +242,7 @@ public abstract class RegisterDict {
} else if (list.item(j).getNodeName().equals(REGISTER)) {
NamedNodeMap attributes = list.item(j).getAttributes();
// attributes: name, type, offset, size
Node n = attributes.getNamedItem(REG_ATTR_NAME);
Node n = attributes.getNamedItem(REG_ATTR_MNEMONIC);
String name = n.getNodeValue();
n = attributes.getNamedItem(REG_ATTR_TYPE);
String typeStr = n.getNodeValue();
@@ -266,7 +273,7 @@ public abstract class RegisterDict {
if (list.item(i).getNodeName().equals(REGISTER)) {
NamedNodeMap attributes = list.item(i).getAttributes();
// attributes: name, type, offset, size
Node n = attributes.getNamedItem(REG_ATTR_NAME);
Node n = attributes.getNamedItem(REG_ATTR_MNEMONIC);
String name = n.getNodeValue();
n = attributes.getNamedItem(REG_ATTR_TYPE);
String typeStr = n.getNodeValue();

View File

@@ -3,11 +3,15 @@ package ch.ntb.mcdp.mc68332;
import ch.ntb.mcdp.dict.Register;
/**
* Representation of a MC68332 Register
*
* For system and user registers the <code>value</code> value is used as BDI
* specific identifier (code specific to each register from the Technical
* Reference Manual).
*
* @author schlaepfer
*
*/
public class MC68332Register extends Register {
// Register Types

View File

@@ -2,6 +2,12 @@ package ch.ntb.mcdp.mpc555;
import ch.ntb.mcdp.dict.Register;
/**
* Representation of a MPC555 Register
*
* @author schlaepfer
*
*/
public class MPC555Register extends Register {
// Register Types