This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/sim/ppc] When #size-cells is zero don't expect a size
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 14 Nov 2001 14:56:19 -0500
- Subject: [patch/sim/ppc] When #size-cells is zero don't expect a size
Hello,
The attached tweek fixes a bug in PSIM's device tree parser where it
always required a size parameter.
Andrew
2001-10-29 Andrew Cagney <ac131313@redhat.com>
* tree.c (parse_size): Assert #size-cells > 0.
(parse_address): Ditto for #address-cells.
(parse_reg_property): Only parse the size when #size-cells is
non-zero.
Index: tree.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/tree.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 tree.c
*** tree.c 1999/04/16 01:35:11 1.1.1.1
--- tree.c 2001/11/14 19:53:31
*************** parse_address(device *current,
*** 463,468 ****
--- 463,469 ----
const char *chp,
device_unit *address)
{
+ ASSERT(device_nr_address_cells(bus) > 0);
if (device_decode_unit(bus, chp, address) < 0)
device_error(current, "invalid unit address in %s", chp);
return skip_token(chp);
*************** parse_size(device *current,
*** 485,490 ****
--- 486,492 ----
/* parse the numeric list */
size->nr_cells = device_nr_size_cells(bus);
nr = 0;
+ ASSERT(size->nr_cells > 0);
while (1) {
char *next;
size->cells[nr] = strtoul(curr, &next, 0);
*************** parse_reg_property(device *current,
*** 521,529 ****
int reg_nr;
reg_property_spec *regs;
const char *chp;
/* determine the number of reg entries by counting tokens */
! nr_regs = count_entries(current, property_name, property_value, 2);
/* create working space */
regs = zalloc(nr_regs * sizeof(*regs));
--- 523,533 ----
int reg_nr;
reg_property_spec *regs;
const char *chp;
+ device *bus = device_parent(current);
/* determine the number of reg entries by counting tokens */
! nr_regs = count_entries(current, property_name, property_value,
! 1 + (device_nr_size_cells(bus) > 0));
/* create working space */
regs = zalloc(nr_regs * sizeof(*regs));
*************** parse_reg_property(device *current,
*** 531,540 ****
/* fill it in */
chp = property_value;
for (reg_nr = 0; reg_nr < nr_regs; reg_nr++) {
! chp = parse_address(current, device_parent(current),
! chp, ®s[reg_nr].address);
! chp = parse_size(current, device_parent(current),
! chp, ®s[reg_nr].size);
}
/* create it */
--- 535,545 ----
/* fill it in */
chp = property_value;
for (reg_nr = 0; reg_nr < nr_regs; reg_nr++) {
! chp = parse_address(current, bus, chp, ®s[reg_nr].address);
! if (device_nr_size_cells(bus) > 0)
! chp = parse_size(current, bus, chp, ®s[reg_nr].size);
! else
! memset(®s[reg_nr].size, sizeof (®s[reg_nr].size), 0);
}
/* create it */