00001 00008 #include <kernel.h> 00009 #include <platform.h> 00010 #include <interrupt.h> 00011 #include <clock.h> 00012 #include <queue.h> 00013 00014 #ifdef RTCLOCK 00015 ulong time_base_freq = 0; 00016 ulong time_intr_freq = 0; 00017 ulong ctr_mS = 0; 00018 ulong clocktime = 0; 00019 queue sleepq; 00020 ulong preempt; 00025 void clockinit(void) 00026 { 00027 sleepq = newqueue(); /* initialize sleep queue */ 00028 00029 preempt = QUANTUM; /* initial time quantum */ 00030 ctr_mS = 1000; /* Set millisecond counter. */ 00031 00032 if (0 == platform.time_base_freq) /* Sensible default for freq. */ 00033 { platform.time_base_freq = 100000000; } 00034 00035 /* Program timer to trip every millisecond. */ 00036 time_intr_freq = platform.time_base_freq / 1000; 00037 00038 #ifdef DETAIL 00039 kprintf("Time base %dHz, Clock interrupt at %dHz\r\n", 00040 platform.time_base_freq, 00041 (platform.time_base_freq / time_intr_freq) ); 00042 #endif 00043 00044 /* Register clock interrupt */ 00045 interruptVector[IRQ_TIMER] = clockintr; 00046 enable_irq(IRQ_TIMER); 00047 clock_update(time_intr_freq); 00048 } 00049 #endif