[18] | 1 | /* $Id: timer.c,v 1.1.1.1 2003/07/02 13:57:04 eleph Exp $ */
|
---|
| 2 | /*
|
---|
| 3 | * OS/2 implementation of Linux timer kernel functions
|
---|
| 4 | *
|
---|
| 5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
| 6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
| 7 | *
|
---|
| 8 | * This program is free software; you can redistribute it and/or
|
---|
| 9 | * modify it under the terms of the GNU General Public License as
|
---|
| 10 | * published by the Free Software Foundation; either version 2 of
|
---|
| 11 | * the License, or (at your option) any later version.
|
---|
| 12 | *
|
---|
| 13 | * This program is distributed in the hope that it will be useful,
|
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | * GNU General Public License for more details.
|
---|
| 17 | *
|
---|
| 18 | * You should have received a copy of the GNU General Public
|
---|
| 19 | * License along with this program; if not, write to the Free
|
---|
| 20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
| 21 | * USA.
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 |
|
---|
| 25 | #include "linux.h"
|
---|
| 26 | #include <linux/init.h>
|
---|
| 27 | #include <linux/poll.h>
|
---|
| 28 | #include <asm/uaccess.h>
|
---|
| 29 | #include <asm/hardirq.h>
|
---|
| 30 | #include <asm/io.h>
|
---|
| 31 | #include <linux/time.h>
|
---|
| 32 |
|
---|
| 33 | #define LINUX
|
---|
| 34 | #include <ossidc.h>
|
---|
| 35 | #include <irqos2.h>
|
---|
| 36 | #include <dbgos2.h>
|
---|
| 37 |
|
---|
| 38 | static long jiffiems = 1000/HZ;
|
---|
| 39 | static long lasttime = 0;
|
---|
| 40 | unsigned long volatile jiffies = 0;
|
---|
| 41 |
|
---|
| 42 | //******************************************************************************
|
---|
| 43 | //Timer handler that is called on each timer tick (32 times/second)
|
---|
| 44 | //******************************************************************************
|
---|
| 45 | void ALSA_TIMER()
|
---|
| 46 | {
|
---|
| 47 | long delta, newtime, remainder;
|
---|
| 48 |
|
---|
| 49 | newtime = os2gettimemsec();
|
---|
| 50 | delta = newtime - lasttime;
|
---|
| 51 |
|
---|
| 52 | jiffies += delta/jiffiems;
|
---|
| 53 | remainder = delta%jiffiems;
|
---|
| 54 |
|
---|
| 55 | lasttime = newtime - remainder;
|
---|
| 56 | }
|
---|
| 57 | //******************************************************************************
|
---|
| 58 | //timeout is in 'jiffies', linux talk for units of 1000/HZ ms
|
---|
| 59 | //******************************************************************************
|
---|
| 60 | signed long schedule_timeout(signed long timeout)
|
---|
| 61 | {
|
---|
| 62 | dprintf2(("schedule_timeout %d jiffies %x", timeout, jiffies));
|
---|
| 63 | mdelay(timeout*jiffiems);
|
---|
| 64 | return 0;
|
---|
| 65 | }
|
---|
| 66 | //******************************************************************************
|
---|
| 67 | //iodelay is in 500ns units
|
---|
| 68 | void iodelay32(unsigned long);
|
---|
| 69 | #pragma aux iodelay32 parm nomemory [ecx] modify nomemory exact [eax ecx];
|
---|
| 70 | //******************************************************************************
|
---|
| 71 | //microsecond delay
|
---|
| 72 | //******************************************************************************
|
---|
| 73 | void __udelay(unsigned long usecs)
|
---|
| 74 | {
|
---|
| 75 | if(usecs == 0) {
|
---|
| 76 | DebugInt3();
|
---|
| 77 | usecs = 1;
|
---|
| 78 | }
|
---|
| 79 | iodelay32(usecs*2);
|
---|
| 80 | }
|
---|
| 81 | //******************************************************************************
|
---|
| 82 | //millisecond delay
|
---|
| 83 | //******************************************************************************
|
---|
| 84 | void mdelay(unsigned long msecs)
|
---|
| 85 | {
|
---|
| 86 | if(msecs == 0) {
|
---|
| 87 | DebugInt3();
|
---|
| 88 | msecs = 1;
|
---|
| 89 | }
|
---|
| 90 | iodelay32(msecs*2*1000);
|
---|
| 91 | }
|
---|
| 92 | //******************************************************************************
|
---|
| 93 | //******************************************************************************
|
---|
| 94 | void do_gettimeofday(struct timeval *tv)
|
---|
| 95 | {
|
---|
| 96 | tv->tv_sec = 0; //os2gettimesec();
|
---|
| 97 | tv->tv_usec = os2gettimemsec() * 1000;
|
---|
| 98 | }
|
---|
| 99 | //******************************************************************************
|
---|
| 100 | //******************************************************************************
|
---|
| 101 | void add_timer(struct timer_list * timer)
|
---|
| 102 | {
|
---|
| 103 |
|
---|
| 104 | }
|
---|
| 105 | //******************************************************************************
|
---|
| 106 | //******************************************************************************
|
---|
| 107 | int del_timer(struct timer_list * timer)
|
---|
| 108 | {
|
---|
| 109 | return 0;
|
---|
| 110 | }
|
---|
| 111 | //******************************************************************************
|
---|
| 112 | /*
|
---|
| 113 | * mod_timer is a more efficient way to update the expire field of an
|
---|
| 114 | * active timer (if the timer is inactive it will be activated)
|
---|
| 115 | * mod_timer(a,b) is equivalent to del_timer(a); a->expires = b; add_timer(a)
|
---|
| 116 | */
|
---|
| 117 | void mod_timer(struct timer_list *timer, unsigned long expires)
|
---|
| 118 | {
|
---|
| 119 |
|
---|
| 120 | }
|
---|
| 121 | //******************************************************************************
|
---|
| 122 | //******************************************************************************
|
---|
| 123 |
|
---|