diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-05-23 23:00:35 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2011-05-23 23:00:35 +0000 |
commit | dd931b2ff2bf7cecc09dba03e8916e4adc9406be (patch) | |
tree | 60333cbde32ee46188f95187798ee100dd3d9df6 | |
parent | 0e31da218e04915bca80802b87fa418b49780378 (diff) | |
download | fsf-binutils-gdb-dd931b2ff2bf7cecc09dba03e8916e4adc9406be.zip fsf-binutils-gdb-dd931b2ff2bf7cecc09dba03e8916e4adc9406be.tar.gz fsf-binutils-gdb-dd931b2ff2bf7cecc09dba03e8916e4adc9406be.tar.bz2 |
sim: glue: allow bitwise devices to only glue ints
Some Blackfin parts tie a bunch of interrupt lines into a single OR
gate before feeding the result into the SIC. The glue-or device in
the sim provides a nice way of modeling this exact behavior. At the
moment though, it requires the device to be mapped into the address
space so that things could write to it directly. This is not needed
for the Blackfin usage, so make it optional. Now the glue devices
can be used to simply tie interrupt lines together.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | sim/common/ChangeLog | 7 | ||||
-rw-r--r-- | sim/common/dv-glue.c | 101 |
2 files changed, 61 insertions, 47 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index bd6a7ee..d37e912 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,5 +1,12 @@ 2011-05-23 Mike Frysinger <vapier@gentoo.org> + * dv-glue.c (hw_glue_finish): Move "name" to function scope and + remove now-unnecessary sub-scope for glue->type setting. + Check to see if the "reg" property exists before we use it, and + if it doesn't exist, error out for "glue" devices. + +2011-05-23 Mike Frysinger <vapier@gentoo.org> + * dv-glue.c (hw_glue_finish): Set type to glue_or when name is glue-or, and set type to glue_xor when name is glue-xor. (hw_glue_port_event): Return immediately when type is glue_io diff --git a/sim/common/dv-glue.c b/sim/common/dv-glue.c index b99487d..b3a88ad 100644 --- a/sim/common/dv-glue.c +++ b/sim/common/dv-glue.c @@ -195,6 +195,7 @@ static void hw_glue_finish (struct hw *me) { struct hw_glue *glue = HW_ZALLOC (me, struct hw_glue); + const char *name = hw_name (me); /* establish our own methods */ set_hw_data (me, glue); @@ -207,39 +208,49 @@ hw_glue_finish (struct hw *me) do_hw_attach_regs (me); /* establish the output registers */ - { - reg_property_spec unit; - int reg_nr; - - /* find a relevant reg entry */ - reg_nr = 0; - while (hw_find_reg_array_property (me, "reg", reg_nr, &unit) - && !hw_unit_size_to_attach_size (hw_parent (me), - &unit.size, - &glue->sizeof_output, - me)) - reg_nr++; - - /* check out the size */ - if (glue->sizeof_output == 0) - hw_abort (me, "at least one reg property size must be nonzero"); - if (glue->sizeof_output % sizeof (unsigned_word) != 0) - hw_abort (me, "reg property size must be %ld aligned", - (long) sizeof (unsigned_word)); - - /* and the address */ - hw_unit_address_to_attach_address (hw_parent (me), - &unit.address, - &glue->space, - &glue->address, - me); - if (glue->address % (sizeof (unsigned_word) * max_nr_ports) != 0) - hw_abort (me, "reg property address must be %ld aligned", - (long) (sizeof (unsigned_word) * max_nr_ports)); - - glue->nr_outputs = glue->sizeof_output / sizeof (unsigned_word); - glue->output = hw_zalloc (me, glue->sizeof_output); - } + if (hw_find_property (me, "reg")) + { + reg_property_spec unit; + int reg_nr; + + /* Find a relevant reg entry. */ + reg_nr = 0; + while (hw_find_reg_array_property (me, "reg", reg_nr, &unit) + && !hw_unit_size_to_attach_size (hw_parent (me), + &unit.size, + &glue->sizeof_output, + me)) + reg_nr++; + + /* Check out the size ... */ + if (glue->sizeof_output == 0) + hw_abort (me, "at least one reg property size must be nonzero"); + if (glue->sizeof_output % sizeof (unsigned_word) != 0) + hw_abort (me, "reg property size must be %ld aligned", + (long) sizeof (unsigned_word)); + + /* ... and the address. */ + hw_unit_address_to_attach_address (hw_parent (me), + &unit.address, + &glue->space, + &glue->address, + me); + if (glue->address % (sizeof (unsigned_word) * max_nr_ports) != 0) + hw_abort (me, "reg property address must be %ld aligned", + (long) (sizeof (unsigned_word) * max_nr_ports)); + + glue->nr_outputs = glue->sizeof_output / sizeof (unsigned_word); + } + else + { + /* Allow bitwise glue devices to declare only ports. */ + if (!strcmp (name, "glue")) + hw_abort (me, "Missing \"reg\" property"); + + glue->nr_outputs = 1; + glue->sizeof_output = sizeof (unsigned_word); + } + glue->output = hw_zalloc (me, glue->sizeof_output); /* establish the input ports */ { @@ -267,20 +278,16 @@ hw_glue_finish (struct hw *me) } /* determine our type */ - { - const char *name = hw_name(me); - - if (strcmp (name, "glue") == 0) - glue->type = glue_io; - else if (strcmp (name, "glue-and") == 0) - glue->type = glue_and; - else if (strcmp (name, "glue-or") == 0) - glue->type = glue_or; - else if (strcmp (name, "glue-xor") == 0) - glue->type = glue_xor; - else - hw_abort (me, "unimplemented glue type"); - } + if (strcmp (name, "glue") == 0) + glue->type = glue_io; + else if (strcmp (name, "glue-and") == 0) + glue->type = glue_and; + else if (strcmp (name, "glue-or") == 0) + glue->type = glue_or; + else if (strcmp (name, "glue-xor") == 0) + glue->type = glue_xor; + else + hw_abort (me, "unimplemented glue type"); HW_TRACE ((me, "int-number %d, nr_inputs %d, nr_outputs %d", glue->int_number, glue->nr_inputs, glue->nr_outputs)); |