bios_timer.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020
00021
00022
00023
00024
00025
00026
00027 #include <gpxe/timer.h>
00028 #include <realmode.h>
00029 #include <bios.h>
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 static unsigned long bios_currticks ( void ) {
00041 static int days = 0;
00042 uint32_t ticks;
00043 uint8_t midnight;
00044
00045
00046 __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
00047 "nop\n\t"
00048 "nop\n\t"
00049 "cli\n\t" ) : : );
00050
00051 get_real ( ticks, BDA_SEG, 0x006c );
00052 get_real ( midnight, BDA_SEG, 0x0070 );
00053
00054 if ( midnight ) {
00055 midnight = 0;
00056 put_real ( midnight, BDA_SEG, 0x0070 );
00057 days += 0x1800b0;
00058 }
00059
00060 return ( days + ticks );
00061 }
00062
00063 PROVIDE_TIMER_INLINE ( pcbios, udelay );
00064 PROVIDE_TIMER ( pcbios, currticks, bios_currticks );
00065 PROVIDE_TIMER_INLINE ( pcbios, ticks_per_sec );