Graeme Russ [Sat, 31 Dec 2011 11:58:15 +0000 (22:58 +1100)]
x86: Use fs for global data
Use the base address of the 'F' segment as a pointer to the global data
structure. By adding the linear address (i.e. the 'D' segment address) as
the first word of the global data structure, the address of the global data
relative to the 'D' segment can be found simply, for example, by:
fs movl 0, %eax
This makes the gd 'pointer' writable prior to relocation (by reloading the
Global Desctriptor Table) which brings x86 into line with all other arches
NOTE: Writing to the gd 'pointer' is expensive (but we only do it
twice) but using it to access global data members (read and write) is
still fairly cheap
--
Changes for v2:
- Rebased against changes made to patch #3
- Removed extra indent
- Tweaked commit message
Move the relocation offset calculation out of assembler and into C. This
also paves the way for the upcoming init sequence simplification by adding
the board_init_f_r flash to RAM transitional function
--
Changes for v2:
- Added commit message
- Minor adjustment to new stack address comment
Graeme Russ [Thu, 29 Dec 2011 10:45:33 +0000 (21:45 +1100)]
x86: Rework Global Descriptor Table loading
The inline assembler is ugly and uses hard coded magic numbers. Make it more
elegant to allow cleaner implementation of future GDT related patches. The
compiler seems smart enough to generate the same code anyway
--
Changes for v2:
- Rebased against revised patch #3
- Use GDT size define instead of magic number
- Added commit message
Wolfgang Denk [Fri, 23 Dec 2011 19:53:58 +0000 (20:53 +0100)]
Merge branch 'next' of ../next
* 'next' of ../next:
mkenvimage: Add version info switch (-V)
mkenvimage: Fix getopt() error handling
mkenvimage: Fix some typos
phy: add Micrel KS8721BL phy definition
net: introduce per device index
mvgbe: remove setting of ethaddr within the driver
x86: Add support for specifying an initrd with the zboot command
x86: Refactor the zboot innards so they can be reused with a vboot image
x86: Add infrastructure to extract an e820 table from the coreboot tables
x86: Add support for booting Linux using the 32 bit boot protocol
x86: Clean up the x86 zimage code in preparation to extend it
x86: Import code from coreboot's libpayload to parse the coreboot table
x86: Initial commit for running as a coreboot payload
CHECKPATCH: ./board/esd/hh405/logo_320_240_8bpp.c
CHECKPATCH: ./board/esd/hh405/logo_1024_768_8bpp.c
CHECKPATCH: ./board/esd/hh405/logo_320_240_4bpp.c
CHECKPATCH: ./board/esd/hh405/logo_640_480_24bpp.c
CHECKPATCH: ./board/esd/apc405/logo_640_480_24bpp.c
CHECKPATCH: ./board/esd/voh405/logo_320_240_4bpp.c
CHECKPATCH: ./board/esd/voh405/logo_640_480_24bpp.c
CHECKPATCH: ./board/esd/hh405/fpgadata.c
CHECKPATCH: ./board/esd/pci405/fpgadata.c
CHECKPATCH: ./board/esd/tasreg/fpgadata.c
CHECKPATCH: ./board/esd/apc405/fpgadata.c
CHECKPATCH: ./board/esd/voh405/fpgadata.c
CHECKPATCH: ./board/esd/ash405/fpgadata.c
CHECKPATCH: ./board/esd/dasa_sim/fpgadata.c
CHECKPATCH: ./board/esd/ar405/fpgadata_xl30.c
CHECKPATCH: ./board/esd/ar405/fpgadata.c
CHECKPATCH: ./board/esd/plu405/fpgadata.c
CHECKPATCH: ./board/esd/wuh405/fpgadata.c
CHECKPATCH: ./board/esd/cpci405/fpgadata_cpci405.c
CHECKPATCH: ./board/esd/cpci405/fpgadata_cpci405ab.c
CHECKPATCH: ./board/esd/cpci405/fpgadata_cpci4052.c
CHECKPATCH: ./board/esd/canbt/fpgadata.c
CHECKPATCH: ./board/esd/du405/fpgadata.c
CHECKPATCH: ./board/esd/cpciiser4/fpgadata.c
CHECKPATCH: ./board/dave/PPChameleonEVB/fpgadata.c
avr32:mmu.c: fix printf() length modifier
fat.c: fix printf() length modifier
cmd_sf.c: fix printf() length modifier
Make printf and vprintf safe from buffer overruns
vsprintf: Move function documentation into header file
Add safe vsnprintf and snprintf library functions
Move vsprintf functions into their own header
The code and comment disagreed: the comment claimed that r6...r31
were copied, and consequently the arrays for "src" and "dst" were
declared with 26 entries, but the actual code ("lmw r5,0(r3)" and
"stmw r5,0(r4)") copied _27_ words (r5 through r31), which resulted
in false "POST cpu Error at multi test" messages.
Fix the comment and the array sizes.
Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Anatolij Gustschin <agust@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Kim Phillips <kim.phillips@freescale.com> Cc: Andy Fleming <afleming@gmail.com> Acked-by: Anatolij Gustschin <agust@denx.de> Tested-by: Anatolij Gustschin <agust@denx.de>
Wolfgang Denk [Fri, 23 Dec 2011 01:29:11 +0000 (01:29 +0000)]
post/lib_powerpc/multi.c: code cleanup
Clean up and document the code:
- get rid of unneeded code block
- add comment which code is generated
Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Anatolij Gustschin <agust@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Kim Phillips <kim.phillips@freescale.com> Cc: Andy Fleming <afleming@gmail.com> Acked-by: Anatolij Gustschin <agust@denx.de>
Wolfgang Denk [Fri, 23 Dec 2011 01:29:10 +0000 (01:29 +0000)]
post/lib_powerpc/multi.c: make checkpatch clean
Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Anatolij Gustschin <agust@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Kim Phillips <kim.phillips@freescale.com> Cc: Andy Fleming <afleming@gmail.com> Acked-by: Anatolij Gustschin <agust@denx.de>
Wolfgang Denk [Thu, 22 Dec 2011 04:29:41 +0000 (04:29 +0000)]
PPC: fix "Warning: FOO uses hard float, BAR uses soft float".
It appears that with recent versions of GCC the explicit
"-mhard-float" command line option takes precedence over the
``asm(".gnu_attribute 4, 2");'' in the source file, so this no longer
helps to avoid the warnings we get when linking code that uses FP
instructions with other code that was built using soft-float.
We can remove the ".gnu_attribute" (which appears to carry no other
information, at least so far) from the object files, but we also have
to make sure we don't pull in the __gcc_qsub() and __gcc_qmul()
functions from the standard libgcc, as these would again "infect" our
linking. We copy this code from:
gcc-4.2.2/gcc/config/rs6000/darwin-ldouble.c
This old version was chosen because it was still available under a
compatible license (GCC v2+). The file was stripped down to the
needed parts, and reformatted so it passes checkpatch with only one
warning (do not add new typedefs).
Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Stefan Roese <sr@denx.de> Cc: Andy Fleming <afleming@gmail.com> Cc: Kim Phillips <kim.phillips@freescale.com> Tested-by: Stefan Roese <sr@denx.de> Tested-by: Anatolij Gustschin <agust@denx.de>
Thierry Reding [Wed, 16 Nov 2011 23:48:22 +0000 (23:48 +0000)]
tegra2: Fix out-of-tree build for Ventana.
Since Ventana is derived from Seaboard and requires seaboard.c to build,
make sure board/nvidia/seaboard is created in the build tree.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Acked-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Wolfgang Denk <wd@denx.de>
Tom Warren [Tue, 6 Dec 2011 13:00:19 +0000 (13:00 +0000)]
arm: Tegra: fix undefined instruction hang immediately after reset
commit 0d479b53 (Aneesh V) added code for OMAP4 that doesn't
execute on Tegra, due to the AVP (ARM7TDI) not having a CP15.
Result was an undefined instruction hang just after reset.
Signed-off-by: Tom Warren <twarren@nvidia.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Tom Rini <trini@ti.com> Acked-by: Aneesh V <aneesh@ti.com>
Since the original implementation indicates explicit error handling
we turn off getopt()'s internal error messaging to avoid duplicate
error messages. Additionally we add ':' (missing option argument)
error handling.
Fix:
e1000.c: In function 'e1000_read_mac_addr':
e1000.c:1149:2: warning: dereferencing type-punned pointer
will break strict-aliasing rules [-Wstrict-aliasing]
e1000.c:1149:2: warning: dereferencing type-punned pointer
will break strict-aliasing rules [-Wstrict-aliasing]
Fix:
mv_eth.c: In function 'mv64360_eth_real_open':
mv_eth.c:425:6: warning: variable 'port_status' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_stop':
mv_eth.c:643:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_xmit':
mv_eth.c:719:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_receive':
mv_eth.c:804:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_get_stats':
mv_eth.c:903:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_update_stat':
mv_eth.c:931:24: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
mv_eth.c:930:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'mv64360_eth_print_stat':
mv_eth.c:1012:15: warning: variable 'port_num' set but not used [-Wunused-but-set-variable]
mv_eth.c: In function 'eth_clear_mib_counters':
mv_eth.c:2069:15: warning: variable 'dummy' set but not used [-Wunused-but-set-variable
Fix:
In file included from s3c_udc_otg.c:216:0:
s3c_udc_otg_xfer_dma.c: In function 'complete_tx':
s3c_udc_otg_xfer_dma.c:280:33: warning: variable 'is_short' set but not used
s3c_udc_otg_xfer_dma.c:280:6: warning: variable 'ep_tsr' set but not used
s3c_udc_otg_xfer_dma.c: In function 's3c_udc_irq':
s3c_udc_otg_xfer_dma.c:469:16: warning: variable 'flags' set but not used
s3c_udc_otg_xfer_dma.c:468:18: warning: variable 'gintmsk' set but not used
s3c_udc_otg_xfer_dma.c: In function 's3c_queue':
s3c_udc_otg_xfer_dma.c:582:14: warning: variable 'gintsts' set but not used
s3c_udc_otg_xfer_dma.c:581:16: warning: variable 'flags' set but not used
s3c_udc_otg_xfer_dma.c: In function 's3c_ep0_read':
s3c_udc_otg_xfer_dma.c:778:6: warning: variable 'ret' set but not used
s3c_udc_otg_xfer_dma.c: In function 's3c_udc_set_halt':
s3c_udc_otg_xfer_dma.c:1020:16: warning: variable 'flags' set but not used
s3c_udc_otg_xfer_dma.c: In function 's3c_ep0_setup':
s3c_udc_otg_xfer_dma.c:1258:13: warning: initialization from incompatible
pointer type [enabled by default]
s3c_udc_otg_xfer_dma.c:1239:16: warning: variable 'is_in' set but not used
s3c_udc_otg_xfer_dma.c:1239:9: warning: variable 'bytes' set but not used
s3c_udc_otg.c: In function 'usb_gadget_register_driver':
s3c_udc_otg.c:292:16: warning: variable 'flags' set but not used
s3c_udc_otg.c: In function 'usb_gadget_unregister_driver':
s3c_udc_otg.c:338:16: warning: variable 'flags' set but not used
s3c_udc_otg.c: In function 's3c_ep_enable':
s3c_udc_otg.c:582:16: warning: variable 'flags' set but not used
s3c_udc_otg.c: In function 's3c_ep_disable':
s3c_udc_otg.c:646:16: warning: variable 'flags' set but not used
s3c_udc_otg.c: In function 's3c_dequeue':
s3c_udc_otg.c:704:16: warning: variable 'flags' set but not used
Writing a file to the FAT partition didn't work while a
test using a CF card. The test was done on mpc5200 based
board (powerpc). There is a number of problems in FAT
write code:
Compiler warning:
fat_write.c: In function 'file_fat_write':
fat_write.c:326: warning: 'counter' may be used uninitialized
in this function
fat_write.c:326: note: 'counter' was declared here
'l_filename' string is not terminated, so a file name
with garbage at the end is used as a file name as shown
by debug code.
Return value of set_contents() is not checked properly
so actually a file won't be written at all (as checked
using 'fatls' after a write attempt with 'fatwrite'
command).
do_fat_write() doesn't return the number of written bytes
if no error happened. However the return value of this
function is used to show the number of written bytes
in do_fat_fswrite().
The patch adds some debug code and fixes above mentioned
problems and also fixes a typo in error output.
NOTE: after a successful write to the FAT partition (under
U-Boot) the partition was checked under Linux using fsck.
The partition needed fixing FATs:
-bash-3.2# fsck -a /dev/sda1
fsck 1.39 (29-May-2006)
dosfsck 2.11, 12 Mar 2005, FAT32, LFN
FATs differ but appear to be intact. Using first FAT.
Performing changes.
Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Donggeun Kim <dg77.kim@samsung.com> Cc: Aaron Williams <Aaron.Williams@cavium.com> Acked-by: Donggeun Kim <dg77.kim@samsung.com>
Fix:
e1000_spi.c: In function 'spi_free_slave':
e1000_spi.c:115: warning: unused variable 'hw'
e1000_spi.c: In function 'do_e1000_spi':
e1000_spi.c:472: warning: 'checksum' may be used uninitialized in this function
e1000_spi.c:472: note: 'checksum' was declared here
Simon Glass [Mon, 19 Dec 2011 16:10:43 +0000 (16:10 +0000)]
net: Fix arguments in tftpput command
The switch to strict_strtoul() was not done correctly - this fixes
the compile error when CONFIG_CMD_TFTPPUT is active.
There appears to very little use of strict_strtoul() in commands, so
it might be easier to switch to simple_strtoul(). If not, we should
decide the best way to use strict_strtoul(). For now I have added a
friendly message which will of course increase code size.
Sven Schnelle [Tue, 4 Oct 2011 19:53:32 +0000 (21:53 +0200)]
AVR32: fix timer_init() function
timer_init() now returns an int (the error code) instead of void.
This makes compilation fail with:
interrupts.c:111: error: conflicting types for 'timer_init'
/home/svens/u-boot/u-boot/include/common.h:246: error: previous
declaration of 'timer_init' was here
make[1]: *** [interrupts.o] Error 1
Signed-off-by: Sven Schnelle <svens@stackframe.org> Acked-by: Andreas Bießmann <andreas.devel@googlemail.com> Signed-off-by: Anatolij Gustschin <agust@denx.de>
Michael Walle [Thu, 27 Oct 2011 11:31:35 +0000 (11:31 +0000)]
net: introduce per device index
Instead of counting the device index everytime a functions needs it, store
it in the eth_device struct. eth_register() keeps track of the indices and
updates the device's index number. This simplifies some functions in
net/eth.c.
Additionally, a network driver can now query its index, eg. to get the
correct environment ethaddr name.
Signed-off-by: Michael Walle <michael@walle.cc> Cc: Prafulla Wadaskar <prafulla@marvell.com> Cc: Mike Frysinger <vapier@gentoo.com> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
Michael Walle [Thu, 17 Nov 2011 12:52:29 +0000 (12:52 +0000)]
mvgbe: remove setting of ethaddr within the driver
A network driver should not touch the environment at all. This patch fixes
this behaviour by removing the code for setting a default/randomized MAC
address.
Signed-off-by: Michael Walle <michael@walle.cc> Acked-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Prafulla Wadaskar <prafulla@marvell.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Prafulla Wadaskar <prafulla@marvell.com> Cc: Valentin Longchamp <valentin.longchamp@keymile.com> Cc: Eric Cooper <ecc@cmu.edu> Cc: Jason Cooper <u-boot@lakedaemon.net> Cc: Siddarth Gore <gores@marvell.com> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Cc: Simon Guinot <simon.guinot@sequanux.org> Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
Heiko Schocher [Mon, 12 Dec 2011 20:37:17 +0000 (20:37 +0000)]
common/cmd_pxe.c: Fix GCC 4.6 build warnings
Fix:
cmd_pxe.c: In function 'parse_pxefile_top':
cmd_pxe.c:941:5: warning: 'err' may be used uninitialized in this
function [-Wuninitialized]
cmd_pxe.c:921:6: note: 'err' was declared here
Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Jason Hobbs <jason.hobbs@calxeda.com> Acked-by: Jason Hobbs <jason.hobbs@calxeda.com>
Sven Schnelle [Tue, 4 Oct 2011 19:53:32 +0000 (21:53 +0200)]
AVR32: fix timer_init() function
timer_init() now returns an int (the error code) instead of void.
This makes compilation fail with:
interrupts.c:111: error: conflicting types for 'timer_init'
/home/svens/u-boot/u-boot/include/common.h:246: error: previous
declaration of 'timer_init' was here
make[1]: *** [interrupts.o] Error 1
Signed-off-by: Sven Schnelle <svens@stackframe.org> Acked-by: Andreas Bießmann <andreas.devel@googlemail.com> Signed-off-by: Anatolij Gustschin <agust@denx.de>
arm, fdt: update ethernet mac address before booting Linux
Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Cc: Gerald van Baren <gvb.uboot@gmail.com> Acked-by: Wolfgang Denk <wd@denx.de>
This patch adds support for "print_cpuinfo" on Samsung s3c24x0
based targets. If activated by "#define CONFIG_DISPLAY_CPUINFO", the
chip ID and the 3 main cpu frequencies will be displayed.
Chris Lalancette [Tue, 13 Dec 2011 09:41:12 +0000 (09:41 +0000)]
omap4_panda: Initialize the USB phy
During misc_init_r, make sure to setup the clocks
properly for the USB hub on the pandaboard. With
this in place, the USB hub and the ethernet works
on the pandaboard.
Signed-off-by: Chris Lalancette <clalancette@gmail.com> Acked-by: Aneesh V <aneesh@ti.com>
Ilya Yanok [Sun, 11 Dec 2011 13:09:28 +0000 (13:09 +0000)]
arm926ejs: remove noop flush_dcache_all function
Commit 2f3427c added noop cache functions implementation for arm926ejs
to fix compilation of drivers depending on these functions (DaVinci
EMAC in particular).
Unfortunately, the bug was introduced: noop implementation calls
dcache_disable which calls flush_dcache_all which in turn calls
dcache_disable thus creating an infinite loop.
This patch removes noop implementation for flush_dcache_all, we already
have default one in arch/arm/lib/cache.c and it should be used instead.
Fix:
mx51evk.c:206:6: error: conflicting types for 'board_ehci_hcd_init'
/u-boot/include/usb/ehci-fsl.h:254:5: note: previous declaration of
'board_ehci_hcd_init' was here
We also fix board_ehci_hcd_init() for mx53loco board.
Building for mx53loco worked since <usb/ehci-fsl.h> is
not included here.
common/cmd_nvedit.c: Fix size calculation in do_env_import()
do_env_import() missed the final '\0' terminator when calculating the
size of an environment data block. This led to an erroneous 'bad CRC,
import failed' message for a checksum protected environment (-c.)
Gabe Black [Mon, 5 Dec 2011 12:09:27 +0000 (12:09 +0000)]
x86: Add support for specifying an initrd with the zboot command
This change finishes plumbing the initrd support built into the zboot
mechanism out to the command interface.
It also fixes a bug in the command declaration where the kernel size could
be passed as an optional second parameter but not enough arguments were
allowed.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Mon, 5 Dec 2011 12:09:26 +0000 (12:09 +0000)]
x86: Refactor the zboot innards so they can be reused with a vboot image
If vboot successfully verifies a kernel, it will leave it in place and
basically ready to boot. The zeropage table which is part of the x86 boot
protocol is at the end of the kernel, though, instead of the beginning, and
because the image is already in place there's no need to copy it around.
This change refactors the code which implements the zboot command so that
the configuration of the zeropage table and loading the pieces of the
kernel into memory are done separately. Also, because the command line goes
before the zeropage table in vboot which is somewhat incompatible with the
normal protocol, where to put the command line is a now a parameter instead
of being hard coded.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Mon, 5 Dec 2011 12:09:25 +0000 (12:09 +0000)]
x86: Add infrastructure to extract an e820 table from the coreboot tables
Also approximate the size of RAM using the largest RAM address available
in the tables. There may be areas which are marked as reserved which are
actually at the end of RAM.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Mon, 5 Dec 2011 12:09:24 +0000 (12:09 +0000)]
x86: Add support for booting Linux using the 32 bit boot protocol
This change conditionally modifies the zboot command so that it can use the
32 bit boot protocol. This is necessary because the 16 bit realmode entry
point assumes that it can call BIOS services which neither coreboot nor
u-boot provide.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Mon, 5 Dec 2011 12:09:23 +0000 (12:09 +0000)]
x86: Clean up the x86 zimage code in preparation to extend it
This change cleans up some formatting issues in the zimage handling code, and
converts it from using offsets added to a base pointer to using the available
structure definitions which were already being included.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Mon, 5 Dec 2011 12:09:22 +0000 (12:09 +0000)]
x86: Import code from coreboot's libpayload to parse the coreboot table
This change also forces the lib_sysinfo structure to be in the .data
section. Otherwise it ends up in the .bss section. U-boot assumes that it
doesn't need to copy it over during relocation, and instead fills that
whole section with zeroes. If we really were booting from ROM that would be
appropriate, but we need some information from the coreboot tables (memory
size) before then and have to fill that structure before relocation. We
skirt u-boot's assumption by putting this in .data where it assumes there
is still read only but non-zero data.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Gabe Black [Tue, 29 Nov 2011 18:05:07 +0000 (18:05 +0000)]
x86: Initial commit for running as a coreboot payload
Add a target for running u-boot as a coreboot payload in boards.cfg, a
board, CPU and a config. This is a skeleton implementation which always
reports the size of memory as 64 MB.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Andreas Bießmann [Thu, 15 Dec 2011 08:56:55 +0000 (09:56 +0100)]
avr32:mmu.c: fix printf() length modifier
avr32 uses unsigned long addresses, fix the printf() length modifier for that
fact.
Before this patch following warning occours:
---8<---
mmu.c: In function 'mmu_init_r':
mmu.c:25: warning: format '%08x' expects type 'unsigned int', but argument 2 has type 'uintptr_t'
--->8---
Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
cc: Mike Frysinger <vapier@gentoo.org>
cc: Thomas Chou <thomas@wytron.com.tw>
cc: Reinhard Meyer <u-boot@emk-elektronik.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
Andreas Bießmann [Thu, 15 Dec 2011 08:56:54 +0000 (09:56 +0100)]
fat.c: fix printf() length modifier
The DIRENTSPERBLOCK utilizes sizeof() which will return a size_t which has no
fixed size. Therefor use correct length modifer for printf() statement to
prevent compiler warnings.
This patch fixes following warning:
---8<---
fat.c: In function 'do_fat_read':
fat.c:879: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'
--->8---
Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
cc: Mike Frysinger <vapier@gentoo.org>
cc: Thomas Chou <thomas@wytron.com.tw>
cc: rjones@nexus-tech.net
cc: kharris@nexus-tech.net Acked-by: Mike Frysinger <vapier@gentoo.org>
Andreas Bießmann [Thu, 15 Dec 2011 08:56:53 +0000 (09:56 +0100)]
cmd_sf.c: fix printf() length modifier
size_t is not always 'unsigned int', use corret length modifer.
This patch fixes following warning:
---8<---
cmd_sf.c: In function 'spi_flash_update_block':
cmd_sf.c:130: warning: format '%#x' expects type 'unsigend int', but argument 4 has type 'size_t'
cmd_sf.c:135: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'size_t'
--->8---
Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
cc: Mike Frysinger <vapier@gentoo.org>
cc: Thomas Chou <thomas@wytron.com.tw> Acked-by: Mike Frysinger <vapier@gentoo.org>
Sonny Rao [Mon, 10 Oct 2011 09:22:31 +0000 (09:22 +0000)]
Make printf and vprintf safe from buffer overruns
From: Sonny Rao <sonnyrao@chromium.org>
utilize the added vscnprintf functions to avoid buffer overruns
The implementation is fairly dumb in that it doesn't detect
that the buffer is too small, but at least will not cause crashes.
Sonny Rao [Wed, 2 Nov 2011 09:52:08 +0000 (09:52 +0000)]
Add safe vsnprintf and snprintf library functions
From: Sonny Rao <sonnyrao@chromium.org>
These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.
Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.
(Simon Glass <sjg@chromium.org> modified this commit a little)