Commit Graph

9 Commits

Author SHA1 Message Date
Reinhard Meyer 150f723665 display_buffer: fix misaligned buffer
use a union to cause necessary alignment per architecture

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
2010-09-13 13:15:07 +02:00
Mike Frysinger 64419e4751 print_buffer: optimize & shrink
Applying a little creative format string allows us to shrink the initial
data read & display loop by only calling printf once.  Re-using the local
data buffer to generate the string we want to display then allows us to
output everything with just one printf call instead of multiple calls to
the putc function.

The local stack buffer needs increasing by 1 byte, but the resulting code
shrink and speed up is worth it I think.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-09 00:28:38 +02:00
Wolfgang Denk 54841ab50c Make sure that argv[] argument pointers are not modified.
The hush shell dynamically allocates (and re-allocates) memory for the
argument strings in the "char *argv[]" argument vector passed to
commands.  Any code that modifies these pointers will cause serious
corruption of the malloc data structures and crash U-Boot, so make
sure the compiler can check that no such modifications are being done
by changing the code into "char * const argv[]".

This modification is the result of debugging a strange crash caused
after adding a new command, which used the following argument
processing code which has been working perfectly fine in all Unix
systems since version 6 - but not so in U-Boot:

int main (int argc, char **argv)
{
	while (--argc > 0 && **++argv == '-') {
/* ====> */	while (*++*argv) {
			switch (**argv) {
			case 'd':
				debug++;
				break;
			...
			default:
				usage ();
			}
		}
	}
	...
}

The line marked "====>" will corrupt the malloc data structures and
usually cause U-Boot to crash when the next command gets executed by
the shell.  With the modification, the compiler will prevent this with
an
	error: increment of read-only location '*argv'

N.B.: The code above can be trivially rewritten like this:

	while (--argc > 0 && **++argv == '-') {
		char *arg = *argv;
		while (*++arg) {
			switch (*arg) {
			...

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-07-04 23:55:42 +02:00
Nick Thompson f2d76ae4fd Avoid use of divides in print_size
Modification of print_size to avoid use of divides and especially
long long divides. Keep the binary scale factor in terms of bit
shifts instead. This should be faster, since the previous code
gave the compiler no clues that the divides where always powers
of two, preventing optimisation.

Signed-off-by: Nick Thompson <nick.thompson@ge.com>
Acked-by: Timur Tabi <timur@freescale.com>
2010-05-17 23:23:39 +02:00
Timur Tabi 4b42c9059e allow print_size to print large numbers on 32-bit systems
Modify print_size() so that it can accept numbers larger than 4GB on 32-bit
systems.

Add support for display terabyte, petabyte, and exabyte sizes.  Change the
output to use International Electrotechnical Commission binary prefix standard.

Signed-off-by: Timur Tabi <timur@freescale.com>
2010-05-05 22:17:34 +02:00
Timur Tabi 52dbac69c2 fix print_size printing fractional gigabyte numbers on 32-bit platforms
In print_size(), the math that calculates the fractional remainder of a number
used the same integer size as a physical address.  However, the "10 *" factor
of the algorithm means that a large number (e.g. 1.5GB) can overflow the
integer if we're running on a 32-bit system.  Therefore, we need to
disassociate this function from the size of a physical address.

Signed-off-by: Timur Tabi <timur@freescale.com>
2010-05-05 22:17:07 +02:00
Stefan Roese a47a12becf Move arch/ppc to arch/powerpc
As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>
2010-04-21 23:42:38 +02:00
Peter Tyser 0de71d5071 Move libfdt/ into lib/
Move the libfdt directory into the common lib/ directory to clean up the
top-level directory.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2010-04-13 09:13:04 +02:00
Peter Tyser 78acc472d9 Rename lib_generic/ to lib/
Now that the other architecture-specific lib directories have been
moved out of the top-level directory there's not much reason to have the
'_generic' suffix on the common lib directory.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2010-04-13 09:13:04 +02:00