[U-Boot-Users] Spartan FPGA patch

Andreas Schweigstill andreas at schweigstill.de
Wed Nov 7 17:49:36 CET 2007


Hello!

Wolfgang Denk schrieb:
> Oops? I can't parse that. What's the difference between "signed char"
> and "int" except the number of bits?

Like mentioned before, accessing data via a (signed|unsigned|.) char *
is independant of the processor endianess. If you want to read a
bitstream which is bytewise formatted you don't want to care about
endianess. Or do you also want some endianess string definitions?

#ifdef __LITTLE_ENDIAN
const char my_text[] = "sihT si xe a \0\0te";
#endif
#ifdef __BIG_ENDIAN
const char my_text[] = "This is a text";
#endif

int * p_text = (int *)my_text;


And it is even worse; on some architectures, like ARM, it is not
allowed to do a 16/32 bit memory access on a non-aligned address,
e.g.:

int val;
int * p_data;

p_data = (int *)0x23400001;
val = *p_data;


Depending of the ARM implementation you either get a data abort or
an "implementation depending" wrong value in val. For write access
it is even worse because this can overwrite some memory.

With best regards
Andreas Schweigstill

-- 
Dipl.-Phys. Andreas Schweigstill
Schweigstill IT | Embedded Systems
Schauenburgerstraße 116, D-24118 Kiel, Germany
Phone: (+49) 431 5606-435, Fax: (+49) 431 5606-436
Mobile: (+49) 171 6921973, Web: http://www.schweigstill.de/




More information about the U-Boot mailing list