Discussion:
[UrJTAG-dev] [PATCH] Add Analog Devices BF609 support
Jie Zhang
2012-09-24 02:43:16 UTC
Permalink
Hi,

This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.

Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.

This patch also add a bus driver for BF609 EZ-BOARD.

Any comments?

Thank you.

Jie
Mike Frysinger
2012-09-24 04:38:15 UTC
Permalink
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely ADI-specific.
similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename "sdu" in user visible
strings to "bfin-sdu" or something.

it should also include parts.h and stdint.h since it uses things from them.

it would simplify things if we always initialized part->params->data. is that
not possible ?

i generally over looked the API ugliness in the bfin.h because it was such a
large blob and only Blackfin-specific stuff would include it. but you can't add
that stuff to part.h w/out a URJ_xxx prefix. i'm not sure why even bother
putting PART_XXX() helpers in the header in the first place. update the funcs
like so:
bool
urj_part_get_bypassed (urj_part_t *part)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
return part_data->bypass;
}
else
return true;
}

i would convert the urj_part_bypass to a single set func:
void
urj_part_set_bypass (urj_part_t *part, bool bypass)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
part_data->bypass = bypass;
}
}

the help string in src/cmd/cmd_part.c needs to be line wrapped.

urj_tap_manual_add_at should take a const char *name. the strncpy in there
probably mishandles NUL if someone passes in a really long name, so i'd make
sure the last byte is always set to '\0'.

in urj_tap_manual_init, pretty sure you don't need to line wrap the calls to
urj_part_find_instruction. also, why do you have to construct the full path to
the data_file ? doesn't the default parse func search the urjtag data dir ? i
think the error handling in that func is also incorrect. pretty sure it
should just be:
urj_log_error_describe (URJ_LOG_LEVEL_ERROR);
also, all calls to assert() are wrong. return an error instead.

in src/part/part.c:urj_part_parts_add_part_at, rather than a for loop, why not
use memmove() ? you should also do checking on the "n" variable to make sure
it isn't <0 or >p->len. similarly, urj_part_parts_remove_part_at should use
memmove().

the changes to src/bus/blackfin.c should be using the new
urj_part_set_signal_high() helper funcs.

i didn't look too closely at the new sdu.c file. i did see some assert()'s
which need fixing, and sdu_part_data_initializer should get marked static.

the header files in src/cmd/cmd_sdu.c need trimming. no need for wait.h. it
also needs to wrap the error messages with _(...) for translation. and drop
all calls to assert(). when it comes to checking params, you wouldn't have to
indent so much if you changed the logic. instead of doing:
if (check param count) {
... normal code ...
} else {
... show error ...
}
you just had it return early:
if (check param count) {
... show error & return ...
}
... normal code ...
there's one place where you use "reseting" when it's spelled "resetting"

the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired up
to the bf609 cores ? or is everything routed through the sdu ? if the
latter, then there should be a "sdu-bf609" file with the common sdu stuff
remaining in the "sdu" file. also, how come bf609/bf609 isn't including
bfin/bfin like all the other blackfin parts ?

in the src/bfin/bfin.c:bfin_set_scan() change, you deleted the major if check,
but didn't re-indent the body.
-mike
Jie Zhang
2012-09-24 20:22:26 UTC
Permalink
Hi Mike,

Thanks for review.
Post by Mike Frysinger
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely ADI-specific.
similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename "sdu" in user visible
strings to "bfin-sdu" or something.
Although SDU is a ADI-specific thing, it's not a Blackfin specific
thing. Putting sdu/ under bfin/ is not correct. There is still some
code mixed between sdu and bfin, but I'm going to separate them
further in future.
Post by Mike Frysinger
it should also include parts.h and stdint.h since it uses things from them.
Done.
Post by Mike Frysinger
it would simplify things if we always initialized part->params->data. is that
not possible ?
It's a good idea. Done.
Post by Mike Frysinger
i generally over looked the API ugliness in the bfin.h because it was such a
large blob and only Blackfin-specific stuff would include it. but you can't add
that stuff to part.h w/out a URJ_xxx prefix. i'm not sure why even bother
putting PART_XXX() helpers in the header in the first place. update the funcs
bool
urj_part_get_bypassed (urj_part_t *part)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
return part_data->bypass;
}
else
return true;
}
Now every part has its own data, this can be simplified further. Done.
Post by Mike Frysinger
void
urj_part_set_bypass (urj_part_t *part, bool bypass)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
part_data->bypass = bypass;
}
}
Done. I also changed the interface for accessing magic and scan, so
they have an consistent interface.
Post by Mike Frysinger
the help string in src/cmd/cmd_part.c needs to be line wrapped.
Done.
Post by Mike Frysinger
urj_tap_manual_add_at should take a const char *name. the strncpy in there
probably mishandles NUL if someone passes in a really long name, so i'd make
sure the last byte is always set to '\0'.
I added a check of string length before strcpy.
Post by Mike Frysinger
in urj_tap_manual_init, pretty sure you don't need to line wrap the calls to
urj_part_find_instruction. also, why do you have to construct the full path to
the data_file ? doesn't the default parse func search the urjtag data dir ? i
think the error handling in that func is also incorrect. pretty sure it
urj_log_error_describe (URJ_LOG_LEVEL_ERROR);
also, all calls to assert() are wrong. return an error instead.
All done.
Post by Mike Frysinger
in src/part/part.c:urj_part_parts_add_part_at, rather than a for loop, why not
use memmove() ? you should also do checking on the "n" variable to make sure
it isn't <0 or >p->len. similarly, urj_part_parts_remove_part_at should use
memmove().
Done.
Post by Mike Frysinger
the changes to src/bus/blackfin.c should be using the new
urj_part_set_signal_high() helper funcs.
Done.
Post by Mike Frysinger
i didn't look too closely at the new sdu.c file. i did see some assert()'s
which need fixing, and sdu_part_data_initializer should get marked static.
There is only one assert in sdu.c. That function
(sdu_mac_memory_write_1) is a static one. So it's not likely for
library user to use that function and pass a wrong argument. That
assert is only for library developer.

Done for sdu_part_data_initializer.
Post by Mike Frysinger
the header files in src/cmd/cmd_sdu.c need trimming. no need for wait.h. it
Done.
Post by Mike Frysinger
also needs to wrap the error messages with _(...) for translation. and drop
all calls to assert(). when it comes to checking params, you wouldn't have to
if (check param count) {
... normal code ...
} else {
... show error ...
}
if (check param count) {
... show error & return ...
}
... normal code ...
there's one place where you use "reseting" when it's spelled "resetting"
All done.
Post by Mike Frysinger
the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired up
to the bf609 cores ? or is everything routed through the sdu ? if the
latter, then there should be a "sdu-bf609" file with the common sdu stuff
remaining in the "sdu" file. also, how come bf609/bf609 isn't including
bfin/bfin like all the other blackfin parts ?
Everything is routed through the sdu. But I'd rather do that change
when there is a second processor using sdu. If there is no more such
processors, I can save a little time.

Because BF609 part does not have IDCODE instruction or DIR register,
including common bfin file is not correct. Since I'm not sure if there
will be more processors using sdu in future, I don't bother to put
more effort into it.
Post by Mike Frysinger
in the src/bfin/bfin.c:bfin_set_scan() change, you deleted the major if check,
but didn't re-indent the body.
This will make review a little easier. I usually do this and clean up
the code later. But since you have already looked at that code, I will
do the indent in this version of the patch.


Regards,
Jie
Jie Zhang
2012-09-25 12:35:54 UTC
Permalink
Just found two errors in the 2nd version patch. A new patch is attached.

Jie
Post by Jie Zhang
Hi Mike,
Thanks for review.
Post by Mike Frysinger
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely ADI-specific.
similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename "sdu" in user visible
strings to "bfin-sdu" or something.
Although SDU is a ADI-specific thing, it's not a Blackfin specific
thing. Putting sdu/ under bfin/ is not correct. There is still some
code mixed between sdu and bfin, but I'm going to separate them
further in future.
Post by Mike Frysinger
it should also include parts.h and stdint.h since it uses things from them.
Done.
Post by Mike Frysinger
it would simplify things if we always initialized part->params->data. is that
not possible ?
It's a good idea. Done.
Post by Mike Frysinger
i generally over looked the API ugliness in the bfin.h because it was such a
large blob and only Blackfin-specific stuff would include it. but you can't add
that stuff to part.h w/out a URJ_xxx prefix. i'm not sure why even bother
putting PART_XXX() helpers in the header in the first place. update the funcs
bool
urj_part_get_bypassed (urj_part_t *part)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
return part_data->bypass;
}
else
return true;
}
Now every part has its own data, this can be simplified further. Done.
Post by Mike Frysinger
void
urj_part_set_bypass (urj_part_t *part, bool bypass)
{
if (urj_part_has_data (part))
{
urj_part_data_t *part_data = part->params->data;
part_data->bypass = bypass;
}
}
Done. I also changed the interface for accessing magic and scan, so
they have an consistent interface.
Post by Mike Frysinger
the help string in src/cmd/cmd_part.c needs to be line wrapped.
Done.
Post by Mike Frysinger
urj_tap_manual_add_at should take a const char *name. the strncpy in there
probably mishandles NUL if someone passes in a really long name, so i'd make
sure the last byte is always set to '\0'.
I added a check of string length before strcpy.
Post by Mike Frysinger
in urj_tap_manual_init, pretty sure you don't need to line wrap the calls to
urj_part_find_instruction. also, why do you have to construct the full path to
the data_file ? doesn't the default parse func search the urjtag data dir ? i
think the error handling in that func is also incorrect. pretty sure it
urj_log_error_describe (URJ_LOG_LEVEL_ERROR);
also, all calls to assert() are wrong. return an error instead.
All done.
Post by Mike Frysinger
in src/part/part.c:urj_part_parts_add_part_at, rather than a for loop, why not
use memmove() ? you should also do checking on the "n" variable to make sure
it isn't <0 or >p->len. similarly, urj_part_parts_remove_part_at should use
memmove().
Done.
Post by Mike Frysinger
the changes to src/bus/blackfin.c should be using the new
urj_part_set_signal_high() helper funcs.
Done.
Post by Mike Frysinger
i didn't look too closely at the new sdu.c file. i did see some assert()'s
which need fixing, and sdu_part_data_initializer should get marked static.
There is only one assert in sdu.c. That function
(sdu_mac_memory_write_1) is a static one. So it's not likely for
library user to use that function and pass a wrong argument. That
assert is only for library developer.
Done for sdu_part_data_initializer.
Post by Mike Frysinger
the header files in src/cmd/cmd_sdu.c need trimming. no need for wait.h. it
Done.
Post by Mike Frysinger
also needs to wrap the error messages with _(...) for translation. and drop
all calls to assert(). when it comes to checking params, you wouldn't have to
if (check param count) {
... normal code ...
} else {
... show error ...
}
if (check param count) {
... show error & return ...
}
... normal code ...
there's one place where you use "reseting" when it's spelled "resetting"
All done.
Post by Mike Frysinger
the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired up
to the bf609 cores ? or is everything routed through the sdu ? if the
latter, then there should be a "sdu-bf609" file with the common sdu stuff
remaining in the "sdu" file. also, how come bf609/bf609 isn't including
bfin/bfin like all the other blackfin parts ?
Everything is routed through the sdu. But I'd rather do that change
when there is a second processor using sdu. If there is no more such
processors, I can save a little time.
Because BF609 part does not have IDCODE instruction or DIR register,
including common bfin file is not correct. Since I'm not sure if there
will be more processors using sdu in future, I don't bother to put
more effort into it.
Post by Mike Frysinger
in the src/bfin/bfin.c:bfin_set_scan() change, you deleted the major if check,
but didn't re-indent the body.
This will make review a little easier. I usually do this and clean up
the code later. But since you have already looked at that code, I will
do the indent in this version of the patch.
Regards,
Jie
Mike Frysinger
2012-09-27 02:03:06 UTC
Permalink
Post by Jie Zhang
Post by Mike Frysinger
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely
ADI-specific. similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename
"sdu" in user visible strings to "bfin-sdu" or something.
Although SDU is a ADI-specific thing, it's not a Blackfin specific
thing. Putting sdu/ under bfin/ is not correct. There is still some
code mixed between sdu and bfin, but I'm going to separate them
further in future.
ok, but they still don't belong directly under src/ as "sdu" is too generic a
name. maybe we should start a src/cpu/ dir and put both bfin & sdu inside of
there ? similarly, start a cpu/ subdir in the include tree.
Post by Jie Zhang
Post by Mike Frysinger
the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired
up to the bf609 cores ? or is everything routed through the sdu ? if
the latter, then there should be a "sdu-bf609" file with the common sdu
stuff remaining in the "sdu" file. also, how come bf609/bf609 isn't
including bfin/bfin like all the other blackfin parts ?
Everything is routed through the sdu. But I'd rather do that change
when there is a second processor using sdu. If there is no more such
processors, I can save a little time.
...
Since I'm not sure if there
will be more processors using sdu in future, I don't bother to put
more effort into it.
well, then separating out the sdu/ and bfin/ dirs doesn't make much sense when
the current sdu data files are so Blackfin-centric :). at least on the data
side, you could call it SDU609 as that should be a quick change.
Post by Jie Zhang
Because BF609 part does not have IDCODE instruction or DIR register,
including common bfin file is not correct.
well, i think every part on that jtag bus has to have an IDCODE. that it
returns all 1's means it doesn't have an idcode assigned to it. as for the
DIR register, i don't think having it defined is a problem is it ? it might be
a little confusing ...
Post by Jie Zhang
+static struct URJ_PART_DATA_COMMON urj_unknown_part_data_initializer =
i think you can make this const
Post by Jie Zhang
+#define URJ_UNKNOWN_PART_DATA(part) ((struct URJ_PART_DATA_COMMON *)((part)-
params->data))
i would just call this URJ_PART_DATA()
Post by Jie Zhang
+static void
+urj_unknown_part_init (urj_part_t *part)
+{
+ if (!part || !part->params)
+ {
+ urj_error_set (URJ_ERROR_INVALID, "initialization failed for
unknown part");

needs _(...)
Post by Jie Zhang
+ return;
+}
pointless return here
Post by Jie Zhang
+void
+urj_part_init (urj_part_t *part)
+{
+ urj_part_init_func_t part_init_func;
+
+ part->params = malloc (sizeof (urj_part_params_t));
+ part_init_func = urj_part_find_init (part->part);
+ if (part_init_func)
+ (*part_init_func) (part);
+ else
+ urj_unknown_part_init (part);
+}
what if urj_part_find_init just return urj_unknown_part_init when it couldn't
find one ?
Post by Jie Zhang
+#define PART_MAGIC(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->magic)
+#define PART_BYPASS(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->bypass)
+#define PART_SCAN(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->scan)
you can make one macro to rule them all:
#define PART_FIELD(part, field) \
(((struct URJ_PART_DATA_COMMON *)((part)->params->data))->field)
Post by Jie Zhang
+int
+urj_part_is_bypassed (urj_part_t *part)
bool urj_part_get_bypass (...)

that keeps the form of the other get/set accessors API
Post by Jie Zhang
+uint32_t
+urj_part_get_magic (urj_part_t *part)
+{
+ return PART_MAGIC(part);
needs spaces before the paren
Post by Jie Zhang
+int
+urj_part_get_scan (urj_part_t *part)
+{
+ return PART_SCAN(part);
here too
Post by Jie Zhang
+void
+urj_part_set_scan (urj_part_t *part, int scan)
+{
+ PART_SCAN(part) = scan;
here too
-mike
Jie Zhang
2012-09-27 03:27:46 UTC
Permalink
Hi Mike,

Thank you again.
Post by Mike Frysinger
Post by Jie Zhang
Post by Mike Frysinger
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely
ADI-specific. similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename
"sdu" in user visible strings to "bfin-sdu" or something.
Although SDU is a ADI-specific thing, it's not a Blackfin specific
thing. Putting sdu/ under bfin/ is not correct. There is still some
code mixed between sdu and bfin, but I'm going to separate them
further in future.
ok, but they still don't belong directly under src/ as "sdu" is too generic a
name. maybe we should start a src/cpu/ dir and put both bfin & sdu inside of
there ? similarly, start a cpu/ subdir in the include tree.
I agree, although cpu is not a good name since sdu is not a cpu. I'd
like call it emu or emulation. But I don't want to do it with this
patch. I would like to do it after this patch but before adding
another one.
Post by Mike Frysinger
Post by Jie Zhang
Post by Mike Frysinger
the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired
up to the bf609 cores ? or is everything routed through the sdu ? if
the latter, then there should be a "sdu-bf609" file with the common sdu
stuff remaining in the "sdu" file. also, how come bf609/bf609 isn't
including bfin/bfin like all the other blackfin parts ?
Everything is routed through the sdu. But I'd rather do that change
when there is a second processor using sdu. If there is no more such
processors, I can save a little time.
...
Since I'm not sure if there
will be more processors using sdu in future, I don't bother to put
more effort into it.
well, then separating out the sdu/ and bfin/ dirs doesn't make much sense when
the current sdu data files are so Blackfin-centric :). at least on the data
side, you could call it SDU609 as that should be a quick change.
It makes sense since sdu and bfin are separate logically. Each one can
exist without the other. When there is another processor using sdu, we
can find a naming solution at that time. For now, it should be OK to
just call it sdu.
Post by Mike Frysinger
Post by Jie Zhang
Because BF609 part does not have IDCODE instruction or DIR register,
including common bfin file is not correct.
well, i think every part on that jtag bus has to have an IDCODE. that it
returns all 1's means it doesn't have an idcode assigned to it. as for the
DIR register, i don't think having it defined is a problem is it ? it might be
a little confusing ...
IDCODE is optional. I think being correct is more important. If it
does not have IDCODE, just don't define it. If you really want to
share things, we can create a bfin-no-idcode file which does not
contain the IDCODE, then let bfin include it + IDCODE. But I wonder it
will be worth to do it.
Post by Mike Frysinger
Post by Jie Zhang
+static struct URJ_PART_DATA_COMMON urj_unknown_part_data_initializer =
i think you can make this const
Actually all initializers can be const. Will do it in a follow-up patch.
Post by Mike Frysinger
Post by Jie Zhang
+#define URJ_UNKNOWN_PART_DATA(part) ((struct URJ_PART_DATA_COMMON *)((part)-
params->data))
i would just call this URJ_PART_DATA()
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+static void
+urj_unknown_part_init (urj_part_t *part)
+{
+ if (!part || !part->params)
+ {
+ urj_error_set (URJ_ERROR_INVALID, "initialization failed for
unknown part");
needs _(...)
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+ return;
+}
pointless return here
Will remove it.
Post by Mike Frysinger
Post by Jie Zhang
+void
+urj_part_init (urj_part_t *part)
+{
+ urj_part_init_func_t part_init_func;
+
+ part->params = malloc (sizeof (urj_part_params_t));
+ part_init_func = urj_part_find_init (part->part);
+ if (part_init_func)
+ (*part_init_func) (part);
+ else
+ urj_unknown_part_init (part);
+}
what if urj_part_find_init just return urj_unknown_part_init when it couldn't
find one ?
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+#define PART_MAGIC(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->magic)
+#define PART_BYPASS(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->bypass)
+#define PART_SCAN(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->scan)
#define PART_FIELD(part, field) \
(((struct URJ_PART_DATA_COMMON *)((part)->params->data))->field)
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+int
+urj_part_is_bypassed (urj_part_t *part)
bool urj_part_get_bypass (...)
that keeps the form of the other get/set accessors API
I think urj_part_is_bypassed is more readable than urj_part_get_bypass. Compare

if (urj_part_is_bypassed (part))

with

if (urj_part_get_bypassed (part))

.
Post by Mike Frysinger
Post by Jie Zhang
+uint32_t
+urj_part_get_magic (urj_part_t *part)
+{
+ return PART_MAGIC(part);
needs spaces before the paren
Post by Jie Zhang
+int
+urj_part_get_scan (urj_part_t *part)
+{
+ return PART_SCAN(part);
here too
Post by Jie Zhang
+void
+urj_part_set_scan (urj_part_t *part, int scan)
+{
+ PART_SCAN(part) = scan;
here too
Will fix all of three.


Jie
Jie Zhang
2012-09-27 12:48:21 UTC
Permalink
Attached is the updated patch, which changed all places I said "will
do", except I changed URJ_UNKNOWN_PART_DATA to PART_DATA instead of
URJ_PART_DATA since it's not a public API. We need not add a URJ_
prefix before it.

Jie
Post by Jie Zhang
Hi Mike,
Thank you again.
Post by Mike Frysinger
Post by Jie Zhang
Post by Mike Frysinger
Post by Jie Zhang
This patch adds Analog Devices BF609 support to UrJTAG. BF609 has an
SDU (System Debug Unit), which does not exist in previous Blackfin
processors. This patch treats SDU as a new part type.
Because the special design of TAPs in BF609 processors, new functions
are added to manually add/remove Blackfin core TAPs in/from scan
chain, like urj_part_parts_add_part_at and
urj_part_parts_remove_part_at in src/part/part.c.
This patch also add a bus driver for BF609 EZ-BOARD.
the sdu.h header needs a comment block at the top like other headers. it
probably should also be named "bfin-sdu.h" since it's entirely
ADI-specific. similarly, i'd move src/sdu/ to src/bfin/sdu/ and rename
"sdu" in user visible strings to "bfin-sdu" or something.
Although SDU is a ADI-specific thing, it's not a Blackfin specific
thing. Putting sdu/ under bfin/ is not correct. There is still some
code mixed between sdu and bfin, but I'm going to separate them
further in future.
ok, but they still don't belong directly under src/ as "sdu" is too generic a
name. maybe we should start a src/cpu/ dir and put both bfin & sdu inside of
there ? similarly, start a cpu/ subdir in the include tree.
I agree, although cpu is not a good name since sdu is not a cpu. I'd
like call it emu or emulation. But I don't want to do it with this
patch. I would like to do it after this patch but before adding
another one.
Post by Mike Frysinger
Post by Jie Zhang
Post by Mike Frysinger
the signals in data/analog/sdu/sdu (and lack there of in
data/analog/bf609/bf609) make me suspicious. shouldn't the pins be wired
up to the bf609 cores ? or is everything routed through the sdu ? if
the latter, then there should be a "sdu-bf609" file with the common sdu
stuff remaining in the "sdu" file. also, how come bf609/bf609 isn't
including bfin/bfin like all the other blackfin parts ?
Everything is routed through the sdu. But I'd rather do that change
when there is a second processor using sdu. If there is no more such
processors, I can save a little time.
...
Since I'm not sure if there
will be more processors using sdu in future, I don't bother to put
more effort into it.
well, then separating out the sdu/ and bfin/ dirs doesn't make much sense when
the current sdu data files are so Blackfin-centric :). at least on the data
side, you could call it SDU609 as that should be a quick change.
It makes sense since sdu and bfin are separate logically. Each one can
exist without the other. When there is another processor using sdu, we
can find a naming solution at that time. For now, it should be OK to
just call it sdu.
Post by Mike Frysinger
Post by Jie Zhang
Because BF609 part does not have IDCODE instruction or DIR register,
including common bfin file is not correct.
well, i think every part on that jtag bus has to have an IDCODE. that it
returns all 1's means it doesn't have an idcode assigned to it. as for the
DIR register, i don't think having it defined is a problem is it ? it might be
a little confusing ...
IDCODE is optional. I think being correct is more important. If it
does not have IDCODE, just don't define it. If you really want to
share things, we can create a bfin-no-idcode file which does not
contain the IDCODE, then let bfin include it + IDCODE. But I wonder it
will be worth to do it.
Post by Mike Frysinger
Post by Jie Zhang
+static struct URJ_PART_DATA_COMMON urj_unknown_part_data_initializer =
i think you can make this const
Actually all initializers can be const. Will do it in a follow-up patch.
Post by Mike Frysinger
Post by Jie Zhang
+#define URJ_UNKNOWN_PART_DATA(part) ((struct URJ_PART_DATA_COMMON *)((part)-
params->data))
i would just call this URJ_PART_DATA()
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+static void
+urj_unknown_part_init (urj_part_t *part)
+{
+ if (!part || !part->params)
+ {
+ urj_error_set (URJ_ERROR_INVALID, "initialization failed for
unknown part");
needs _(...)
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+ return;
+}
pointless return here
Will remove it.
Post by Mike Frysinger
Post by Jie Zhang
+void
+urj_part_init (urj_part_t *part)
+{
+ urj_part_init_func_t part_init_func;
+
+ part->params = malloc (sizeof (urj_part_params_t));
+ part_init_func = urj_part_find_init (part->part);
+ if (part_init_func)
+ (*part_init_func) (part);
+ else
+ urj_unknown_part_init (part);
+}
what if urj_part_find_init just return urj_unknown_part_init when it couldn't
find one ?
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+#define PART_MAGIC(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->magic)
+#define PART_BYPASS(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->bypass)
+#define PART_SCAN(part) (((struct URJ_PART_DATA_COMMON *)((part)-
params->data))->scan)
#define PART_FIELD(part, field) \
(((struct URJ_PART_DATA_COMMON *)((part)->params->data))->field)
Will do.
Post by Mike Frysinger
Post by Jie Zhang
+int
+urj_part_is_bypassed (urj_part_t *part)
bool urj_part_get_bypass (...)
that keeps the form of the other get/set accessors API
I think urj_part_is_bypassed is more readable than urj_part_get_bypass. Compare
if (urj_part_is_bypassed (part))
with
if (urj_part_get_bypassed (part))
.
Post by Mike Frysinger
Post by Jie Zhang
+uint32_t
+urj_part_get_magic (urj_part_t *part)
+{
+ return PART_MAGIC(part);
needs spaces before the paren
Post by Jie Zhang
+int
+urj_part_get_scan (urj_part_t *part)
+{
+ return PART_SCAN(part);
here too
Post by Jie Zhang
+void
+urj_part_set_scan (urj_part_t *part, int scan)
+{
+ PART_SCAN(part) = scan;
here too
Will fix all of three.
Jie
Loading...