[timer] Rewrite the 8254 Programmable Interval Timer support

The 8254 timer code (used to implement udelay()) has an unknown
provenance.  Rewrite this code to avoid potential licensing
uncertainty.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-02-17 16:24:02 +00:00
parent 320e786d3d
commit 08189df4e0
6 changed files with 153 additions and 107 deletions

View File

@@ -27,7 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <assert.h>
#include <ipxe/timer.h>
#include <ipxe/timer2.h>
#include <ipxe/pit8254.h>
/**
* Number of TSC ticks per microsecond
@@ -56,10 +56,10 @@ static void rdtsc_udelay ( unsigned long usecs ) {
elapsed = ( currticks() - start );
} while ( elapsed < ( usecs * rdtsc_ticks_per_usec ) );
} else {
/* Not yet calibrated; use timer2 and calibrate
/* Not yet calibrated; use 8254 PIT and calibrate
* based on result.
*/
timer2_udelay ( usecs );
pit8254_udelay ( usecs );
elapsed = ( currticks() - start );
rdtsc_ticks_per_usec = ( elapsed / usecs );
DBG ( "RDTSC timer calibrated: %ld ticks in %ld usecs "