u-boot-brain/arch
Chris Packham 73a4152b25 mips: Use unsigned int when reading c0 registers
In commit a18a477 (MIPS: use common code from lib/time.c) MIPS platforms
started using common the common timer functions which are based around
the fact that many platforms have a 32-bit free running counter register
that can be used see commit 8dfafdd (Introduce common timer functions).

Even MIPS64 has such a 32-bit register (some have an additional 64-bit free
running counter, but that's something for another time).

The problem is that in __read_32bit_c0_register() we read the value from
this register into an _signed_ int and as it's returned up the call
chain to timer_read_counter() it gets assigned to an unsigned long. On a
32-bit system there is no problem. On a 64-bit system odd things happen,
sign extension seems to kick in and all of a sudden if the counter
register happens to have the MSb (i.e. the sign bit) set the negative
int gets sign extended into a very large unsigned long value. This in
turn throws out things from get_ticks() up.

Update __read_32bit_c0_register() and __read_32bit_c0_ctrl_register() to
use "unsigned int res;" instead of "int res;". There seems to be little
reason to treat these register values as signed. They are either
counters (which by definition are unsigned) or are made up of various
bit fields to be interpreted as per the CPU datasheet.

Reported-by: Sachin Surendran <sachin.surendran@alliedtelesis.co.nz>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
2015-08-21 15:22:41 +02:00
..
arc arc: significant cache rework 2015-07-01 17:17:27 +03:00
arm ARM: davinci: remove support for cam_enc_4xx 2015-08-20 12:55:50 -04:00
avr32 avr32: delete ancient board.c 2015-06-10 14:03:26 +02:00
blackfin arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
m68k m68k: cache: add an empty stub functions for invalidate/flush dcache 2015-08-12 20:47:46 -04:00
microblaze arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
mips mips: Use unsigned int when reading c0 registers 2015-08-21 15:22:41 +02:00
nds32 arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
nios2 arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
openrisc arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
powerpc Correct License and Copyright information on few files 2015-08-12 20:47:46 -04:00
sandbox dm: test: Add a size to each reg property 2015-07-21 17:39:33 -06:00
sh Move default y configs out of arch/board Kconfig 2015-06-25 22:17:55 -04:00
sparc arch: Make board selection choices optional 2015-05-12 18:10:02 -04:00
x86 x86: minnowmax: Define and enable interrupt setup 2015-08-14 09:50:14 -06:00
.gitignore .gitignore: drop include/asm/proc from ignore pattern 2014-06-19 11:18:54 -04:00
Kconfig kbuild: create symbolic link only for ARM, AVR32, SPARC, PowerPC, x86 2015-07-27 15:02:00 -04:00