LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-08-2005, 11:06 PM   #1
chandansingh
LQ Newbie
 
Registered: Mar 2005
Location: bangalore india
Posts: 3

Rep: Reputation: 0
How to use udelay() in uclinux-2.4.x


hi friends,
I have search the udelay() function in the uclinux-2.4.x/include/asm but i found only the prototype there, the declaration is not there.How i can use the delay in the uclinx-2.4.x.
please give me the code if any body is having. I am using motarola 5272 coldfire.

regards
chandan
 
Old 05-09-2005, 06:48 AM   #2
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
the file is /usr/src/linux/include/asm-m68k/delay.h and here is the code:
Code:
#ifndef _M68K_DELAY_H
#define _M68K_DELAY_H

#include <asm/param.h>

/*
 * Copyright (C) 1994 Hamish Macdonald
 *
 * Delay routines, using a pre-computed "loops_per_jiffy" value.
 */

static inline void __delay(unsigned long loops)
{
        __asm__ __volatile__ ("1: subql #1,%0; jcc 1b"
                : "=d" (loops) : "0" (loops));
}

extern void __bad_udelay(void);
extern void __bad_ndelay(void);

/*
 * Use only for very small delays ( < 1 msec).  Should probably use a
 * lookup table, really, as the multiplications take much too long with
 * short delays.  This is a "reasonable" implementation, though (and the
 * first constant multiplications gets optimized away if the delay is
 * a constant)  
 */
static inline void __const_udelay(unsigned long xloops)
{
        unsigned long tmp;

        __asm__ ("mulul %2,%0:%1"
                : "=d" (xloops), "=d" (tmp)
                : "d" (xloops), "1" (loops_per_jiffy));
        __delay(xloops * HZ);
}

static inline void __udelay(unsigned long usecs)
{
        __const_udelay(usecs * 4295);   /* 2**32 / 1000000 */
}

static inline void __ndelay(unsigned long nsecs)
{
        __const_udelay(nsecs * 5);      /* 2**32 / 1000000000 */
}

#define udelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 4295)) : \
        __udelay(n))

#define ndelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5)) : \
        __ndelay(n))

static inline unsigned long muldiv(unsigned long a, unsigned long b,
                                   unsigned long c)
{
        unsigned long tmp;

        __asm__ ("mulul %2,%0:%1; divul %3,%0:%1"
                : "=d" (tmp), "=d" (a)
                : "d" (b), "d" (c), "1" (a));
        return a;
}

#endif /* defined(_M68K_DELAY_H) */
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
which browser is nice in uClinux freedomli Linux - Laptop and Netbook 1 10-16-2005 10:25 PM
uclinux moonz Linux - Software 0 09-20-2005 12:18 PM
uClinux port error richardji Linux - Hardware 0 08-30-2005 10:51 PM
To bad we don't have a uCLinux area here.... perry Linux - Distributions 1 08-24-2004 10:57 AM
iptable usage on uCLinux? DiablosPet Linux - Software 1 08-06-2003 11:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration