1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
14 \ Use the HPET to calculate various frequencies.
19 \ Set PMC1 to count CPU cycles.
22 d# 1000000000000000 4 hpet@ / CONSTANT hpet-freq
24 : get-times tbl@ pmc1@ f0 hpet@ ;
26 \ Calculate the CPU and TB frequencies.
27 : calibrate get-times dup >r swap >r swap >r hpet-freq d# 100 / + >r
28 BEGIN get-times dup r@ < WHILE 3drop REPEAT r> drop
29 rot r> - ffffffff and \ TB
30 rot r> - ffffffff and \ CPU
35 : round-to tuck 2/ + over / * ;
36 calibrate TO tb-frequency d# 100000000 round-to TO cpu-frequency