move container_of to types.h
[fw/openocd] / src / jtag / driver.c
index da48fdc23ffe496379718486840766b6fe46b350..6469358d9bfc3ebe73013ca97bb73eea28b7cc1c 100644 (file)
@@ -56,11 +56,11 @@ static void jtag_callback_queue_reset(void)
 }
 
 /**
- * Copy a scan_field_t for insertion into the queue.
+ * Copy a struct scan_field for insertion into the queue.
  *
  * This allocates a new copy of out_value using cmd_queue_alloc.
  */
-static void cmd_queue_scan_field_clone(scan_field_t * dst, const scan_field_t * src)
+static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct scan_field * src)
 {
        dst->tap                = src->tap;
        dst->num_bits   = src->num_bits;
@@ -73,13 +73,13 @@ static void cmd_queue_scan_field_clone(scan_field_t * dst, const scan_field_t *
  * see jtag_add_ir_scan()
  *
  */
-int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
 {
        size_t num_taps = jtag_tap_count_enabled();
 
-       jtag_command_t * cmd            = cmd_queue_alloc(sizeof(jtag_command_t));
-       scan_command_t * scan           = cmd_queue_alloc(sizeof(scan_command_t));
-       scan_field_t * out_fields       = cmd_queue_alloc(num_taps  * sizeof(scan_field_t));
+       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
+       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
+       struct scan_field * out_fields  = cmd_queue_alloc(num_taps  * sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
@@ -92,7 +92,7 @@ int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields,
        scan->end_state                 = state;
 
 
-       scan_field_t * field = out_fields;      /* keep track where we insert data */
+       struct scan_field * field = out_fields; /* keep track where we insert data */
 
        /* loop over all enabled TAPs */
 
@@ -147,12 +147,12 @@ int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields,
  * see jtag_add_plain_ir_scan()
  *
  */
-int interface_jtag_add_plain_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
 {
 
-       jtag_command_t * cmd            = cmd_queue_alloc(sizeof(jtag_command_t));
-       scan_command_t * scan           = cmd_queue_alloc(sizeof(scan_command_t));
-       scan_field_t * out_fields       = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
+       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
+       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
+       struct scan_field * out_fields  = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
@@ -176,7 +176,7 @@ int interface_jtag_add_plain_ir_scan(int in_num_fields, const scan_field_t *in_f
  * see jtag_add_dr_scan()
  *
  */
-int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
 {
        /* count devices in bypass */
 
@@ -188,9 +188,9 @@ int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields,
                        bypass_devices++;
        }
 
-       jtag_command_t * cmd            = cmd_queue_alloc(sizeof(jtag_command_t));
-       scan_command_t * scan           = cmd_queue_alloc(sizeof(scan_command_t));
-       scan_field_t * out_fields       = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
+       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
+       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
+       struct scan_field * out_fields  = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
@@ -203,7 +203,7 @@ int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields,
        scan->end_state                 = state;
 
 
-       scan_field_t * field = out_fields;      /* keep track where we insert data */
+       struct scan_field * field = out_fields; /* keep track where we insert data */
 
        /* loop over all enabled TAPs */
 
@@ -213,7 +213,7 @@ int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields,
 
                if (!tap->bypass)
                {
-                       scan_field_t * start_field = field;     /* keep initial position for assert() */
+                       struct scan_field * start_field = field;        /* keep initial position for assert() */
 
                        for (int j = 0; j < in_num_fields; j++)
                        {
@@ -278,9 +278,9 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
        }
 
 
-       jtag_command_t * cmd            = cmd_queue_alloc(sizeof(jtag_command_t));
-       scan_command_t * scan           = cmd_queue_alloc(sizeof(scan_command_t));
-       scan_field_t * out_fields       = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
+       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
+       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
+       struct scan_field * out_fields  = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
@@ -295,7 +295,7 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
 
        bool target_tap_match   = false;
 
-       scan_field_t * field = out_fields;      /* keep track where we insert data */
+       struct scan_field * field = out_fields; /* keep track where we insert data */
 
        /* loop over all enabled TAPs */
 
@@ -344,11 +344,11 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
  * see jtag_add_plain_dr_scan()
  *
  */
-int interface_jtag_add_plain_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_plain_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
 {
-       jtag_command_t * cmd            = cmd_queue_alloc(sizeof(jtag_command_t));
-       scan_command_t * scan           = cmd_queue_alloc(sizeof(scan_command_t));
-       scan_field_t * out_fields       = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
+       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
+       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
+       struct scan_field * out_fields  = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
@@ -371,13 +371,13 @@ int interface_jtag_add_tlr(void)
        tap_state_t state = TAP_RESET;
 
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_STATEMOVE;
 
-       cmd->cmd.statemove = cmd_queue_alloc(sizeof(statemove_command_t));
+       cmd->cmd.statemove = cmd_queue_alloc(sizeof(struct statemove_command));
        cmd->cmd.statemove->end_state = state;
 
        return ERROR_OK;
@@ -386,13 +386,13 @@ int interface_jtag_add_tlr(void)
 int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
 {
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_PATHMOVE;
 
-       cmd->cmd.pathmove = cmd_queue_alloc(sizeof(pathmove_command_t));
+       cmd->cmd.pathmove = cmd_queue_alloc(sizeof(struct pathmove_command));
        cmd->cmd.pathmove->num_states = num_states;
        cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states);
 
@@ -405,13 +405,13 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
 int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
 {
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_RUNTEST;
 
-       cmd->cmd.runtest = cmd_queue_alloc(sizeof(runtest_command_t));
+       cmd->cmd.runtest = cmd_queue_alloc(sizeof(struct runtest_command));
        cmd->cmd.runtest->num_cycles = num_cycles;
        cmd->cmd.runtest->end_state = state;
 
@@ -421,13 +421,13 @@ int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
 int interface_jtag_add_clocks(int num_cycles)
 {
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_STABLECLOCKS;
 
-       cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(stableclocks_command_t));
+       cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(struct stableclocks_command));
        cmd->cmd.stableclocks->num_cycles = num_cycles;
 
        return ERROR_OK;
@@ -436,13 +436,13 @@ int interface_jtag_add_clocks(int num_cycles)
 int interface_jtag_add_reset(int req_trst, int req_srst)
 {
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_RESET;
 
-       cmd->cmd.reset = cmd_queue_alloc(sizeof(reset_command_t));
+       cmd->cmd.reset = cmd_queue_alloc(sizeof(struct reset_command));
        cmd->cmd.reset->trst = req_trst;
        cmd->cmd.reset->srst = req_srst;
 
@@ -452,13 +452,13 @@ int interface_jtag_add_reset(int req_trst, int req_srst)
 int interface_jtag_add_sleep(uint32_t us)
 {
        /* allocate memory for a new list member */
-       jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+       struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
 
        jtag_queue_command(cmd);
 
        cmd->type = JTAG_SLEEP;
 
-       cmd->cmd.sleep = cmd_queue_alloc(sizeof(sleep_command_t));
+       cmd->cmd.sleep = cmd_queue_alloc(sizeof(struct sleep_command));
        cmd->cmd.sleep->us = us;
 
        return ERROR_OK;