// Helper functions
template <class Type>
-bus::status
+void
read_bus_word(gdbserv* gdbserv,
sid::bus* bus,
host_int_4 address,
for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
gdbserv_output_byte (gdbserv, value.read_byte(i));
}
- // misaligned will be handled by the caller
- else if (s != bus::misaligned)
+ else if (s == bus::misaligned)
+ {
+ // Try it one byte at a time
+ for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
+ {
+ big_int_1 b; // endianness of a single byte is irrelevent
+ s = bus->read (address + i, b);
+ if (s == bus::ok)
+ gdbserv_output_byte (gdbserv, b);
+ else
+ gdbserv_output_string (gdbserv, "E05");
+ }
+ }
+ else
gdbserv_output_string (gdbserv, "E05");
- return s;
}
template <class Type>
-bus::status
+void
write_bus_word(gdbserv* gdbserv,
int binary,
sid::bus* bus,
}
bus::status s = bus->write (address, value);
- if (s == bus::ok || s == bus::misaligned)
- ; // No response means "OK" -- misaligned will be handled by the caller
- else
+ if (s == bus::misaligned)
+ {
+ // Try it a byte at a time
+ for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
+ {
+ // endianness of a single byte is irrelevent
+ big_int_1 b = value.read_byte (i);
+ s = bus->write (address + i, b);
+ if (s != bus::ok)
+ gdbserv_output_string (gdbserv, "E05");
+ }
+ }
+ else if (s != bus::ok)
gdbserv_output_string (gdbserv, "E05");
- return s;
}
}
host_int_4 addr = addr8; // truncate
- bus::status b = bus::misaligned;
if (len==1 && e==endian_big)
- b = read_bus_word (gdbserv, memory, addr, big_int_1());
+ read_bus_word (gdbserv, memory, addr, big_int_1());
else if (len==1 && e==endian_little)
- b = read_bus_word (gdbserv, memory, addr, little_int_1());
+ read_bus_word (gdbserv, memory, addr, little_int_1());
else if (len==2 && e==endian_big)
- b = read_bus_word (gdbserv, memory, addr, big_int_2());
+ read_bus_word (gdbserv, memory, addr, big_int_2());
else if (len==2 && e==endian_little)
- b = read_bus_word (gdbserv, memory, addr, little_int_2());
+ read_bus_word (gdbserv, memory, addr, little_int_2());
else if (len==4 && e==endian_big)
- b = read_bus_word (gdbserv, memory, addr, big_int_4());
+ read_bus_word (gdbserv, memory, addr, big_int_4());
else if (len==4 && e==endian_little)
- b = read_bus_word (gdbserv, memory, addr, little_int_4());
+ read_bus_word (gdbserv, memory, addr, little_int_4());
else if (len==8 && e==endian_big)
- b = read_bus_word (gdbserv, memory, addr, big_int_8());
+ read_bus_word (gdbserv, memory, addr, big_int_8());
else if (len==8 && e==endian_little)
- b = read_bus_word (gdbserv, memory, addr, little_int_8());
-
- if (b != bus::misaligned)
- return;
-
- // Unaligned access or unsupported size.
- if (e==endian_little)
+ read_bus_word (gdbserv, memory, addr, little_int_8());
+ else if (e==endian_little)
{
for (unsigned long i=0; i<len; i++)
read_bus_word (gdbserv, memory, addr + i, little_int_1());
}
host_int_4 addr = addr8; // truncate
- bus::status b = bus::misaligned;
if (len==1 && e==endian_big)
- b = write_bus_word (gdbserv, binary, memory, addr, big_int_1());
- if (len==1 && e==endian_little)
- b = write_bus_word (gdbserv, binary, memory, addr, little_int_1());
- if (len==2 && e==endian_big)
- b = write_bus_word (gdbserv, binary, memory, addr, big_int_2());
- if (len==2 && e==endian_little)
- b = write_bus_word (gdbserv, binary, memory, addr, little_int_2());
- if (len==4 && e==endian_big)
- b = write_bus_word (gdbserv, binary, memory, addr, big_int_4());
- if (len==4 && e==endian_little)
- b = write_bus_word (gdbserv, binary, memory, addr, little_int_4());
- if (len==8 && e==endian_big)
- b = write_bus_word (gdbserv, binary, memory, addr, big_int_8());
- if (len==8 && e==endian_little)
- b = write_bus_word (gdbserv, binary, memory, addr, little_int_8());
-
- if (b != bus::misaligned)
- return;
-
- // Unaligned access or unsupported size.
- if (e==endian_little)
+ write_bus_word (gdbserv, binary, memory, addr, big_int_1());
+ else if (len==1 && e==endian_little)
+ write_bus_word (gdbserv, binary, memory, addr, little_int_1());
+ else if (len==2 && e==endian_big)
+ write_bus_word (gdbserv, binary, memory, addr, big_int_2());
+ else if (len==2 && e==endian_little)
+ write_bus_word (gdbserv, binary, memory, addr, little_int_2());
+ else if (len==4 && e==endian_big)
+ write_bus_word (gdbserv, binary, memory, addr, big_int_4());
+ else if (len==4 && e==endian_little)
+ write_bus_word (gdbserv, binary, memory, addr, little_int_4());
+ else if (len==8 && e==endian_big)
+ write_bus_word (gdbserv, binary, memory, addr, big_int_8());
+ else if (len==8 && e==endian_little)
+ write_bus_word (gdbserv, binary, memory, addr, little_int_8());
+ else if (e==endian_little)
{
for (unsigned long i=0; i<len; i++)
write_bus_word (gdbserv, binary, memory, addr + i, little_int_1());