Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentimer.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS HAL 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: hal/halarm/generic/timer.c 00005 * PURPOSE: Timer Routines 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <hal.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 VOID 00016 FASTCALL 00017 KeUpdateSystemTime( 00018 IN PKTRAP_FRAME TrapFrame, 00019 IN ULONG Increment, 00020 IN KIRQL OldIrql 00021 ); 00022 00023 /* GLOBALS ********************************************************************/ 00024 00025 ULONG HalpCurrentTimeIncrement, HalpNextTimeIncrement, HalpNextIntervalCount; 00026 00027 /* PRIVATE FUNCTIONS **********************************************************/ 00028 00029 VOID 00030 HalpClockInterrupt(VOID) 00031 { 00032 /* Clear the interrupt */ 00033 ASSERT(KeGetCurrentIrql() == CLOCK2_LEVEL); 00034 WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1); 00035 00036 /* FIXME: Update HAL Perf counters */ 00037 00038 /* FIXME: Check if someone changed the clockrate */ 00039 00040 /* Call the kernel */ 00041 KeUpdateSystemTime(KeGetCurrentThread()->TrapFrame, 00042 HalpCurrentTimeIncrement, 00043 CLOCK2_LEVEL); 00044 } 00045 00046 VOID 00047 HalpStallInterrupt(VOID) 00048 { 00049 /* Clear the interrupt */ 00050 WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1); 00051 } 00052 00053 VOID 00054 HalpInitializeClock(VOID) 00055 { 00056 PKIPCR Pcr = (PKIPCR)KeGetPcr(); 00057 ULONG ClockInterval; 00058 SP804_CONTROL_REGISTER ControlRegister; 00059 00060 /* Setup the clock and profile interrupt */ 00061 Pcr->InterruptRoutine[CLOCK2_LEVEL] = HalpStallInterrupt; 00062 00063 /* 00064 * Configure the interval to 10ms 00065 * (INTERVAL (10ms) * TIMCLKfreq (1MHz)) 00066 * --------------------------------------- == 10^4 00067 * (TIMCLKENXdiv (1) * PRESCALEdiv (1)) 00068 */ 00069 ClockInterval = 0x2710; 00070 00071 /* Configure the timer */ 00072 ControlRegister.AsUlong = 0; 00073 ControlRegister.Wide = TRUE; 00074 ControlRegister.Periodic = TRUE; 00075 ControlRegister.Interrupt = TRUE; 00076 ControlRegister.Enabled = TRUE; 00077 00078 /* Enable the timer */ 00079 WRITE_REGISTER_ULONG(TIMER0_LOAD, ClockInterval); 00080 WRITE_REGISTER_ULONG(TIMER0_CONTROL, ControlRegister.AsUlong); 00081 } 00082 00083 /* PUBLIC FUNCTIONS ***********************************************************/ 00084 00085 /* 00086 * @implemented 00087 */ 00088 VOID 00089 NTAPI 00090 HalCalibratePerformanceCounter(IN volatile PLONG Count, 00091 IN ULONGLONG NewCount) 00092 { 00093 UNIMPLEMENTED; 00094 while (TRUE); 00095 } 00096 00097 /* 00098 * @implemented 00099 */ 00100 ULONG 00101 NTAPI 00102 HalSetTimeIncrement(IN ULONG Increment) 00103 { 00104 UNIMPLEMENTED; 00105 while (TRUE); 00106 return Increment; 00107 } 00108 00109 /* 00110 * @implemented 00111 */ 00112 VOID 00113 NTAPI 00114 KeStallExecutionProcessor(IN ULONG Microseconds) 00115 { 00116 SP804_CONTROL_REGISTER ControlRegister; 00117 00118 /* Enable the timer */ 00119 WRITE_REGISTER_ULONG(TIMER1_LOAD, Microseconds); 00120 00121 /* Configure the timer */ 00122 ControlRegister.AsUlong = 0; 00123 ControlRegister.OneShot = TRUE; 00124 ControlRegister.Wide = TRUE; 00125 ControlRegister.Periodic = TRUE; 00126 ControlRegister.Enabled = TRUE; 00127 WRITE_REGISTER_ULONG(TIMER1_CONTROL, ControlRegister.AsUlong); 00128 00129 /* Now we will loop until the timer reached 0 */ 00130 while (READ_REGISTER_ULONG(TIMER1_VALUE)); 00131 } 00132 00133 /* 00134 * @implemented 00135 */ 00136 LARGE_INTEGER 00137 NTAPI 00138 KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq) 00139 { 00140 LARGE_INTEGER Value; 00141 00142 UNIMPLEMENTED; 00143 while (TRUE); 00144 00145 Value.QuadPart = 0; 00146 return Value; 00147 } 00148 00149 /* EOF */ Generated on Fri May 25 2012 04:16:33 for ReactOS by
1.7.6.1
|