00001 #include "local.h" 00002 00003 #include <linux/timer.h> 00004 #include <linux/fs.h> 00005 #include <asm/delay.h> 00006 00007 DECLARE_INITVAR(dde26_timer); 00008 00009 /* Definitions from linux/kernel/timer.c */ 00010 00011 /* 00012 * per-CPU timer vector definitions: 00013 */ 00014 #define TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6) 00015 #define TVR_BITS (CONFIG_BASE_SMALL ? 6 : 8) 00016 #define TVN_SIZE (1 << TVN_BITS) 00017 #define TVR_SIZE (1 << TVR_BITS) 00018 #define TVN_MASK (TVN_SIZE - 1) 00019 #define TVR_MASK (TVR_SIZE - 1) 00020 00021 typedef struct tvec_s { 00022 struct list_head vec[TVN_SIZE]; 00023 } tvec_t; 00024 00025 typedef struct tvec_root_s { 00026 struct list_head vec[TVR_SIZE]; 00027 } tvec_root_t; 00028 00029 struct tvec_base { 00030 spinlock_t lock; 00031 struct timer_list *running_timer; 00032 unsigned long timer_jiffies; 00033 tvec_root_t tv1; 00034 tvec_t tv2; 00035 tvec_t tv3; 00036 tvec_t tv4; 00037 tvec_t tv5; 00038 } ____cacheline_aligned_in_smp; 00039 00040 typedef struct tvec_t_base_s tvec_base_t; 00041 00042 struct tvec_base boot_tvec_bases __attribute__((unused)); 00043 00044 static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) __attribute__((unused)) = &boot_tvec_bases; 00045 00046 void init_timer(struct timer_list *timer) 00047 { 00048 timer->ddekit_timer_id = DDEKIT_INVALID_TIMER_ID; 00049 } 00050 00051 void add_timer(struct timer_list *timer) 00052 { 00053 CHECK_INITVAR(dde26_timer); 00054 /* DDE2.6 uses jiffies and HZ as exported from L4IO. Therefore 00055 * we just need to hand over the timeout to DDEKit. */ 00056 timer->ddekit_timer_id = ddekit_add_timer((void *)timer->function, 00057 (void *)timer->data, 00058 timer->expires); 00059 } 00060 00061 00062 void add_timer_on(struct timer_list *timer, int cpu) 00063 { 00064 add_timer(timer); 00065 } 00066 00067 00068 int del_timer(struct timer_list * timer) 00069 { 00070 int ret; 00071 CHECK_INITVAR(dde26_timer); 00072 ret = ddekit_del_timer(timer->ddekit_timer_id); 00073 timer->ddekit_timer_id = DDEKIT_INVALID_TIMER_ID; 00074 00075 return ret >= 0; 00076 } 00077 00078 int del_timer_sync(struct timer_list *timer) 00079 { 00080 return del_timer(timer); 00081 } 00082 00083 00084 int __mod_timer(struct timer_list *timer, unsigned long expires) 00085 { 00086 /* XXX: Naive implementation. If we really need to be fast with 00087 * this function, we can implement a faster version inside 00088 * the DDEKit. Bjoern just does not think that this is the 00089 * case. 00090 */ 00091 int r; 00092 00093 CHECK_INITVAR(dde26_timer); 00094 r = del_timer(timer); 00095 00096 timer->expires = expires; 00097 add_timer(timer); 00098 00099 return (r > 0); 00100 } 00101 00102 00103 int mod_timer(struct timer_list *timer, unsigned long expires) 00104 { 00105 return __mod_timer(timer, expires); 00106 } 00107 00108 00109 int timer_pending(const struct timer_list *timer) 00110 { 00111 CHECK_INITVAR(dde26_timer); 00112 /* There must be a valid DDEKit timer ID in the timer field 00113 * *AND* it must be pending in the DDEKit. 00114 */ 00115 return ((timer->ddekit_timer_id != DDEKIT_INVALID_TIMER_ID) 00116 && ddekit_timer_pending(timer->ddekit_timer_id)); 00117 } 00118 00119 00120 /** 00121 * msleep - sleep safely even with waitqueue interruptions 00122 * @msecs: Time in milliseconds to sleep for 00123 */ 00124 void msleep(unsigned int msecs) 00125 { 00126 ddekit_thread_msleep(msecs); 00127 } 00128 00129 00130 void __const_udelay(unsigned long xloops) 00131 { 00132 ddekit_thread_usleep(xloops); 00133 } 00134 00135 00136 void __udelay(unsigned long usecs) 00137 { 00138 ddekit_thread_usleep(usecs); 00139 } 00140 00141 00142 void __ndelay(unsigned long nsecs) 00143 { 00144 ddekit_thread_nsleep(nsecs); 00145 } 00146 00147 00148 void __init l4dde26_init_timers(void) 00149 { 00150 ddekit_init_timers(); 00151 00152 l4dde26_process_from_ddekit(ddekit_get_timer_thread()); 00153 00154 INITIALIZE_INITVAR(dde26_timer); 00155 } 00156 00157 core_initcall(l4dde26_init_timers); 00158 00159 extern unsigned long volatile __jiffy_data jiffies; 00160 00161 __attribute__((weak)) void do_gettimeofday (struct timeval *tv) 00162 { 00163 WARN_UNIMPL; 00164 } 00165 00166 struct timespec current_fs_time(struct super_block *sb) 00167 { 00168 struct timespec now = {0,0}; 00169 WARN_UNIMPL; 00170 return now; 00171 } 00172 00173 ktime_t ktime_get_real(void) 00174 { 00175 struct timespec now = {0,0}; 00176 WARN_UNIMPL; 00177 return timespec_to_ktime(now); 00178 } 00179 00180 00181 void native_io_delay(void) 00182 { 00183 udelay(2); 00184 }
1.5.6