diff --git a/urjtag/include/urjtag/bitmask.h b/urjtag/include/urjtag/bitmask.h
index 59917021..d1a9da25 100644
--- a/urjtag/include/urjtag/bitmask.h
+++ b/urjtag/include/urjtag/bitmask.h
@@ -36,6 +36,7 @@
#define URJ_BITMASK_H
#ifdef UNUSED /* RFHH */
+/* @@@@ RFHH remove? */
#ifndef LANGUAGE
# ifdef __ASSEMBLY__
# define LANGUAGE ASM
@@ -44,10 +45,12 @@
# endif
#endif
+/* @@@@ RFHH remove? */
#ifndef ASM
#define ASM 0
#endif
+/* @@@@ RFHH remove? */
#ifndef C
#define C 1
#endif
diff --git a/urjtag/include/urjtag/bsbit.h b/urjtag/include/urjtag/bsbit.h
index 1352fb7f..e5565c71 100644
--- a/urjtag/include/urjtag/bsbit.h
+++ b/urjtag/include/urjtag/bsbit.h
@@ -25,9 +25,7 @@
#ifndef URJ_BSBIT_BSBIT_H
#define URJ_BSBIT_BSBIT_H
-typedef struct urj_bsbit urj_bsbit_t;
-
-#include "bssignal.h"
+#include "types.h"
#define URJ_BSBIT_INPUT 1
#define URJ_BSBIT_OUTPUT 2
@@ -49,8 +47,35 @@ struct urj_bsbit
int control_state;
};
-urj_bsbit_t *urj_part_bsbit_alloc (int bit, const char *name, int type,
- urj_part_signal_t *signal, int safe);
+/**
+ * Define new BSR (Boundary Scan Register) bit for signal name
.
+ *
+ * @param chain
+ * @param bit
+ * @param name associated signal name
+ * @param type URJ_BSBIT_{INPUT|OUTPUT|BIDIR|CONTROL|INTERNAL}
+ * @param safe default (safe) value (0|1)
+ */
+urj_bsbit_t *urj_part_bsbit_alloc (urj_chain_t *chain, int bit,
+ const char *name, int type, int safe);
+/**
+ * Define new BSR (Boundary Scan Register) bit for signal name
.
+ * Additionally, define control bit.
+ *
+ * @param chain
+ * @param bit
+ * @param name associated signal name
+ * @param type URJ_BSBIT_{INPUT|OUTPUT|BIDIR|CONTROL|INTERNAL}
+ * @param safe default (safe) value (0|1)
+ * @param ctrl_num control bit number
+ * @param ctrl_val control value
+ * @param ctrl_state control state; valid statis is only URJ_BSBIT_STATE_Z
+ */
+urj_bsbit_t *urj_part_bsbit_alloc_control (urj_chain_t *chain, int bit,
+ const char *name, int type, int safe,
+ int ctrl_num, int ctrl_val,
+ int ctrl_state);
+
void urj_part_bsbit_free (urj_bsbit_t *b);
#endif /* URJ_BSBIT_BSBIT_H */
diff --git a/urjtag/include/urjtag/bsdl.h b/urjtag/include/urjtag/bsdl.h
index baa10b5e..d9fc5594 100644
--- a/urjtag/include/urjtag/bsdl.h
+++ b/urjtag/include/urjtag/bsdl.h
@@ -25,7 +25,9 @@
#ifndef URJ_BSDL_BSDL_H
#define URJ_BSDL_BSDL_H
-#include
+#include "types.h"
+
+#include "bsdl_mode.h"
typedef struct
{
@@ -39,8 +41,6 @@ typedef struct
bsdl.debug = 0; \
} while (0)
-#include "chain.h"
-
int urj_bsdl_read_file (urj_chain_t *, const char *, int, const char *);
void urj_bsdl_set_path (urj_chain_t *, const char *);
int urj_bsdl_scan_files (urj_chain_t *, const char *, int);
diff --git a/urjtag/include/urjtag/bssignal.h b/urjtag/include/urjtag/bssignal.h
index 016b5c7f..467c4dcd 100644
--- a/urjtag/include/urjtag/bssignal.h
+++ b/urjtag/include/urjtag/bssignal.h
@@ -26,9 +26,7 @@
#ifndef URJ_BSSIGNAL_H
#define URJ_BSSIGNAL_H
-typedef struct urj_part_signal urj_part_signal_t;
-
-#include "bsbit.h"
+#include "types.h"
struct urj_part_signal
{
@@ -39,8 +37,6 @@ struct urj_part_signal
urj_bsbit_t *output;
};
-typedef struct urj_part_salias urj_part_salias_t;
-
struct urj_part_salias
{
char *name;
@@ -55,4 +51,28 @@ urj_part_salias_t *urj_part_salias_alloc (const char *name,
const urj_part_signal_t *signal);
void urj_part_salias_free (urj_part_salias_t *salias);
+/**
+ * Define a signal and its associated pin (name)
+ */
+urj_part_signal_t *urj_part_signal_define_pin (urj_chain_t *chain,
+ const char *signal_name,
+ const char *pin_name);
+/**
+ * Define a signal without pin (name)
+ */
+urj_part_signal_t *urj_part_signal_define (urj_chain_t *chain,
+ const char *signal_name);
+/**
+ * Redefine the pin name for a signal
+ */
+int urj_part_signal_redefine_pin (urj_chain_t *chain, urj_part_signal_t *s,
+ const char *pin_name);
+
+/**
+ * Check whether a chain has an active part
+ *
+ * @return if error, NULL, and sets urj_error.
+ */
+urj_part_t *urj_part_active_part(urj_chain_t *chain);
+
#endif /* URJ_BSSIGNAL_H */
diff --git a/urjtag/include/urjtag/bus.h b/urjtag/include/urjtag/bus.h
index 61bd6448..3f0fb784 100644
--- a/urjtag/include/urjtag/bus.h
+++ b/urjtag/include/urjtag/bus.h
@@ -26,9 +26,11 @@
#ifndef URJ_BUS_H
#define URJ_BUS_H
+/* @@@@ this had better be an internal include file RFHH */
+
#include
-#include
+#include "bus_driver.h"
typedef struct
{
diff --git a/urjtag/include/urjtag/bus_driver.h b/urjtag/include/urjtag/bus_driver.h
index 7063c8eb..dd91fdd6 100644
--- a/urjtag/include/urjtag/bus_driver.h
+++ b/urjtag/include/urjtag/bus_driver.h
@@ -37,7 +37,7 @@
#include
-#include "chain.h"
+#include "types.h"
typedef struct
{
@@ -47,9 +47,6 @@ typedef struct
unsigned int width;
} urj_bus_area_t;
-typedef struct urj_bus urj_bus_t;
-typedef struct urj_bus_driver urj_bus_driver_t;
-
struct urj_bus_driver
{
const char *name;
diff --git a/urjtag/include/urjtag/cable.h b/urjtag/include/urjtag/cable.h
index d1327799..e6f11f5c 100644
--- a/urjtag/include/urjtag/cable.h
+++ b/urjtag/include/urjtag/cable.h
@@ -28,11 +28,8 @@
#include
-typedef struct urj_cable urj_cable_t;
+#include "types.h"
-#include "usbconn.h"
-#include "parport.h"
-#include "chain.h"
#include "pod.h"
typedef struct urj_cable_driver urj_cable_driver_t;
@@ -135,7 +132,8 @@ struct urj_cable
void urj_tap_cable_free (urj_cable_t *cable);
int urj_tap_cable_init (urj_cable_t *cable);
void urj_tap_cable_done (urj_cable_t *cable);
-void urj_tap_cable_flush (urj_cable_t *cable, urj_cable_flush_amount_t);
+void urj_tap_cable_flush (urj_cable_t *cable,
+ urj_cable_flush_amount_t);
void urj_tap_cable_clock (urj_cable_t *cable, int tms, int tdi, int n);
int urj_tap_cable_defer_clock (urj_cable_t *cable, int tms, int tdi, int n);
int urj_tap_cable_get_tdo (urj_cable_t *cable);
diff --git a/urjtag/include/urjtag/chain.h b/urjtag/include/urjtag/chain.h
index a423e77a..4e691c5b 100644
--- a/urjtag/include/urjtag/chain.h
+++ b/urjtag/include/urjtag/chain.h
@@ -25,13 +25,11 @@
#ifndef URJ_CHAIN_H
#define URJ_CHAIN_H
-#include "part.h"
-#include "pod.h"
-
-typedef struct urj_chain urj_chain_t;
+#include "types.h"
-#include "cable.h"
+#include "pod.h"
#include "bsdl.h"
+#include "error.h"
#define URJ_CHAIN_EXITMODE_SHIFT 0
#define URJ_CHAIN_EXITMODE_IDLE 1
diff --git a/urjtag/include/urjtag/data_register.h b/urjtag/include/urjtag/data_register.h
index 53c38af6..c69e696e 100644
--- a/urjtag/include/urjtag/data_register.h
+++ b/urjtag/include/urjtag/data_register.h
@@ -25,12 +25,10 @@
#ifndef URJ_DATA_REGISTER_H
#define URJ_DATA_REGISTER_H
-#include "tap_register.h"
+#include "types.h"
#define URJ_DATA_REGISTER_MAXLEN 32
-typedef struct urj_data_register urj_data_register_t;
-
struct urj_data_register
{
char name[URJ_DATA_REGISTER_MAXLEN + 1]; /* (public) register name */
diff --git a/urjtag/include/urjtag/fclock.h b/urjtag/include/urjtag/fclock.h
index 6c0fa274..eb72c34b 100644
--- a/urjtag/include/urjtag/fclock.h
+++ b/urjtag/include/urjtag/fclock.h
@@ -24,6 +24,8 @@
#ifndef URJ_FCLOCK_FCLOCK_H
#define URJ_FCLOCK_FCLOCK_H
+/* @@@@ this had better be an internal include file RFHH */
+
#ifdef __cplusplus
extern "C"
diff --git a/urjtag/include/urjtag/flash.h b/urjtag/include/urjtag/flash.h
index 5b56df75..bd0d9525 100644
--- a/urjtag/include/urjtag/flash.h
+++ b/urjtag/include/urjtag/flash.h
@@ -37,7 +37,7 @@
#include
#include
-#include
+#include "types.h"
#if 0
/* Following moved here from brux/cfi.h */
@@ -96,6 +96,8 @@ void urj_flash_detectflash (urj_bus_t *bus, uint32_t adr);
void urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int);
void urj_flashmsbin (urj_bus_t *bus, FILE * f, int);
+void urj_flasherase (urj_bus_t *bus, uint32_t addr, int number);
+
/* end of original brux/flash.h */
extern urj_flash_driver_t *urj_flash_flash_drivers[];
diff --git a/urjtag/include/urjtag/jtag.h b/urjtag/include/urjtag/jtag.h
index cba41e1d..33dd6d84 100644
--- a/urjtag/include/urjtag/jtag.h
+++ b/urjtag/include/urjtag/jtag.h
@@ -28,16 +28,7 @@
#include
#include
-#include
-
-#include "chain.h"
-#include "bus.h"
-#include "part.h"
-
-#define URJ_STATUS_OK 0
-#define URJ_STATUS_FAIL 1
-#define URJ_STATUS_SYNTAX_ERROR (-1)
-
+#include "types.h"
extern urj_bus_t *urj_bus;
extern int urj_big_endian;
@@ -53,6 +44,7 @@ int urj_cmd_jtag_parse_file (urj_chain_t *chain, const char *filename);
int urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line);
int urj_cmd_jtag_parse_stream (urj_chain_t *chain, FILE * f);
+/* @@@@ RFHH shouldn't these be in their module's .h file? */
int urj_tap_detect_parts (urj_chain_t *chain, const char *db_path);
int urj_tap_manual_add (urj_chain_t *chain, int instr_len);
int urj_tap_detect_register_size (urj_chain_t *chain);
@@ -62,6 +54,4 @@ void urj_tap_urj_tap_idcode (urj_chain_t *chain, unsigned int bytes);
void urj_bus_readmem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len);
void urj_bus_writemem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len);
-void urj_flasherase (urj_bus_t *bus, uint32_t addr, int number);
-
#endif /* URJ_JTAG_H */
diff --git a/urjtag/include/urjtag/parport.h b/urjtag/include/urjtag/parport.h
index b485080d..244d0b6d 100644
--- a/urjtag/include/urjtag/parport.h
+++ b/urjtag/include/urjtag/parport.h
@@ -28,9 +28,7 @@
#include
-typedef struct urj_parport urj_parport_t;
-
-#include "cable.h"
+#include "types.h"
typedef struct
{
diff --git a/urjtag/include/urjtag/part.h b/urjtag/include/urjtag/part.h
index 5ce852f5..d1ad4a56 100644
--- a/urjtag/include/urjtag/part.h
+++ b/urjtag/include/urjtag/part.h
@@ -27,16 +27,11 @@
#include
-#include "bssignal.h"
-#include "part_instruction.h"
-#include "data_register.h"
-#include "bsbit.h"
+#include "types.h"
#define URJ_PART_MANUFACTURER_MAXLEN 25
#define URJ_PART_PART_MAXLEN 20
-#define URJ_PART_STEPPING_MAXLEN 8
-
-typedef struct urj_part urj_part_t;
+#define URJ_PART_STEPPING_MAXLEN 8
struct urj_part
{
@@ -69,8 +64,24 @@ void urj_part_set_signal (urj_part_t *p, urj_part_signal_t *s, int out,
int val);
int urj_part_get_signal (urj_part_t *p, urj_part_signal_t *s);
void urj_part_print (urj_part_t *p);
-
-typedef struct urj_parts urj_parts_t;
+/**
+ * Set the length of the instructions of a part
+ */
+int urj_part_instruction_length_set (urj_part_t *part, int length);
+/**
+ * Create a new instruction for a part.
+ * @param part
+ * @param instruction name for the new instruction
+ * @param code string that contains the bit pattern for the default instruction
+ * @param data_register default data register for instruction (e.g. BR)
+ */
+urj_part_instruction_t *urj_part_instruction_define (urj_part_t *part,
+ const char *instruction,
+ const char *code,
+ const char *data_register);
+/**
+ * parts
+ */
struct urj_parts
{
diff --git a/urjtag/include/urjtag/part_instruction.h b/urjtag/include/urjtag/part_instruction.h
index 0f676cda..b99743ec 100644
--- a/urjtag/include/urjtag/part_instruction.h
+++ b/urjtag/include/urjtag/part_instruction.h
@@ -25,13 +25,10 @@
#ifndef URJ_PART_INSTRUCTION_H
#define URJ_PART_INSTRUCTION_H
-#include "tap_register.h"
-#include "data_register.h"
+#include "types.h"
#define URJ_INSTRUCTION_MAXLEN_INSTRUCTION 20
-typedef struct urj_part_instruction urj_part_instruction_t;
-
struct urj_part_instruction
{
char name[URJ_INSTRUCTION_MAXLEN_INSTRUCTION + 1];
diff --git a/urjtag/include/urjtag/svf.h b/urjtag/include/urjtag/svf.h
index 0ec7ff2b..060abc66 100644
--- a/urjtag/include/urjtag/svf.h
+++ b/urjtag/include/urjtag/svf.h
@@ -25,7 +25,12 @@
#ifndef URJ_SVF_H
#define URJ_SVF_H
-#include "chain.h"
+#include "sysdep.h"
+
+#include
+#include
+
+#include "types.h"
void urj_svf_run (urj_chain_t *chain, FILE *, int, int, uint32_t);
diff --git a/urjtag/include/urjtag/tap.h b/urjtag/include/urjtag/tap.h
index 3c05ff72..ff414754 100644
--- a/urjtag/include/urjtag/tap.h
+++ b/urjtag/include/urjtag/tap.h
@@ -25,8 +25,9 @@
#ifndef URJ_TAP_H
#define URJ_TAP_H
+#include "types.h"
+
#include "tap_register.h"
-#include "chain.h"
void urj_tap_reset (urj_chain_t *chain);
void urj_tap_reset_bypass (urj_chain_t *chain);
diff --git a/urjtag/include/urjtag/tap_register.h b/urjtag/include/urjtag/tap_register.h
index a53fe7e8..e6056c86 100644
--- a/urjtag/include/urjtag/tap_register.h
+++ b/urjtag/include/urjtag/tap_register.h
@@ -25,12 +25,14 @@
#ifndef URJ_TAP_REGISTER_H
#define URJ_TAP_REGISTER_H
-typedef struct urj_tap_register
+#include "types.h"
+
+struct urj_tap_register
{
char *data; /* (public, r/w) register data */
int len; /* (public, r/o) register length */
char *string; /* (private) string representation of register data */
-} urj_tap_register_t;
+};
urj_tap_register_t *urj_tap_register_alloc (int len);
urj_tap_register_t *urj_tap_register_duplicate (const urj_tap_register_t *tr);
diff --git a/urjtag/include/urjtag/tap_state.h b/urjtag/include/urjtag/tap_state.h
index 68b41ffc..c0ba3b3f 100644
--- a/urjtag/include/urjtag/tap_state.h
+++ b/urjtag/include/urjtag/tap_state.h
@@ -25,9 +25,9 @@
#ifndef URJ_TAP_STATE_H
#define URJ_TAP_STATE_H
-#include
+#include "bitmask.h"
-#include "chain.h"
+#include "types.h"
#define URJ_TAP_STATE_DR URJ_BIT (0)
#define URJ_TAP_STATE_IR URJ_BIT (1)
diff --git a/urjtag/include/urjtag/usbconn.h b/urjtag/include/urjtag/usbconn.h
index e1351991..52698ccd 100644
--- a/urjtag/include/urjtag/usbconn.h
+++ b/urjtag/include/urjtag/usbconn.h
@@ -27,11 +27,8 @@
#define URJ_USBCONN_H
#include
-#include
-typedef struct urj_usbconn urj_usbconn_t;
-
-#include "cable.h"
+#include "types.h"
typedef struct
{