uCdot
search uCdot:
 
Embedded Linux and uClinux Developer Forum
 
uCdot
- FAQ
- Dev Boards
- Submit Story
- Submit FAQ
- Submit Dev Board
- Topics
- Authors
- About

- Preferences
- Older Stuff
- Past Polls
- Discussions
- Journals
- Messages

Embedded Linux
Mailing Lists
uClinux-dev (search)
Coldfire (search)
MTD
Microblaze (search)
ELUG
BDM-devel
Blackfin

Embedded Linux
Sites
uClinux.org
uClinux-Dist
uClibc
uClinux Directory
LinuxDevices
ARMulator
uClinux-elf-tools
Colilo
Kernel Archives
H8-uClinux
TLDP
Microblaze uClinux
BDM Tools
SkyEye (emulator)
LOM
SETR live CD
Blackfin uClinux

Embedded Linux
Companies
SecureComputing
SDCS
CodePoet
Arcturus
Cadenux
ARMtwister
uClinux.net
Xiptech
senTec
embedded^cl
Cwlinux
emlix
TimeSys
eSpark Infotech
SSV Embedded Systems
Embedded Minds
PeerSec Networks
Vortech Consulting
swissEmbedded
Synertronixx
Mbedthis Software
.vantronix
Aday
GraceLabs
Pengutronix
metux ITS
Codito Technologies
Firmix Software
PetaLogix
NuDesign
Merritt Technologies
WindRiver
OpenGear
Rubico
Analog Devices
Artila Electronics
Vyatta
Embest Info&Tech
Katalix Systems
WorkWare Systems
Kdev
Intellimetrix
Virtual Cogs
SYSGO
coresystems
ExactCODE
KOAN
EzHomeTech
Linux4biz
Linkodas
Trego
EMBEST
Boardcon
HITEG
FemtoLinux
Prosoft World
Witech

 
gettimeofday can go backwards on coldfire
Linux Felix Daners writes "The gettimeofday call can go backwards on coldfire

Coldfire do_gettimeofday system call calls the function coldfire_timer_offset() to get the accurate actual pit timer value.

The issue is probably compiler dependant. The 20030314 m68k-elf-gcc splits the

 pcntr = tp->pcntr;
statement into two movb instructions
.stabn 68,0,113,.LM21-coldfire_timer_offset
.LM21:
	move.b 1075118084,%d2
	and.l #0xFF,%d2
	lsl.l #8,%d2
	move.b 1075118085,%d0
	and.l #0xFF,%d0
	or.l %d2,%d0

This is not safe because there might be an overflow in the low byte of the counter. It leads to a value in pcntr not representing the offset.

Below I have a patch that resolves this problem. It replaces the compiler dependant code by inline assembler that reads the 16 bit counter with a movew instruction."

The patch and some more comments on it's implementation follow.

The config.c file is probably not the right place to define the macros for the atomic register access. It just shows the concept of how to overcome this problem.

This patch can be used for config.c in uClinux dist 20040408. It probably fits for all m68knommu platforms and for 2.6 kernels.

Felix Daners

RCS file: /home/cvs/cvsroot/./uClinux-dist/linux-2.4.x/arch/ m68knommu/platform/5280/config.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 config.c
--- config.c	3 May 2004 16:26:50 -0000	1.1.1.1
+++ config.c	3 Jun 2004 09:36:40 -0000
@@ -100,6 +100,10 @@
 
 /************************************************* **************************/
 
+#define CONFIG_POINTER(x) ((unsigned long *)(x))
+#define CONFIG_ATOMIC_MOVE(x,ptr,bwl) __asm__ ("move" #bwl " %1,%0" : "=d" (x) : "m" (*CONFIG_POINTER(ptr)))
+
+
 unsigned long coldfire_timer_offset(void)
 {
 	volatile struct mcfpit *tp;
@@ -110,7 +114,7 @@
 	ipr = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IPRH);
 
 	pmr = tp->pmr;

-	pcntr = tp->pcntr;
+	CONFIG_ATOMIC_MOVE(pcntr, &(tp->pcntr), w);
 
 	/*
 	 * If we are still in the first half of the downcount and a

uClinux for Nios II | GCC 3.4 ColdFire/ARM toolchain for uClinux  >

 

 
uCdot Login
Nickname:

Password:

[ Create a new account ]

Related Links
  • Linux
  • Coldfire
  • uClinux
  • Felix Daners
  • More on Linux
  • Also by davidm
  • This discussion has been archived. No new comments can be posted.
    gettimeofday can go backwards on coldfire | Login/Create an Account | Top | 2 comments | Search Discussion
    Threshold:
    The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
    already fixed in 2.6 code (Score:2)
    by gerg ({gerg} {at} {snapgear.com}) on Friday June 04, @04:43AM (#254)
    User #5 Info | http://www.snapgear.com/
    I fixed this in the 2.6 timer code about a year ago. I should have applied the fix to the 2.4 code as well - just forgot :-)
    [ Parent ]

    The Embedded Linux and uClinux Developer Forum is hosted by: SnapGear A celebrity is a person who is known for his well-knownness.

    [ home | contribute story | older articles | past polls | faq | authors | preferences ]