[openfirmware] r1454 - in cpu/x86: . pc/olpc/via

svn at openfirmware.info svn at openfirmware.info
Tue Nov 3 02:07:21 CET 2009


Author: wmb
Date: 2009-11-03 02:07:21 +0100 (Tue, 03 Nov 2009)
New Revision: 1454

Added:
   cpu/x86/acpiio.fth
Modified:
   cpu/x86/acpitimer.fth
   cpu/x86/pc/olpc/via/config.fth
   cpu/x86/pc/olpc/via/devices.fth
   cpu/x86/pc/olpc/via/fw.bth
   cpu/x86/pc/olpc/via/probemem.fth
   cpu/x86/tsc.fth
Log:
OLPC trac 9574 - Fixed memory size reporting problem for 32-bit memory
interface.  Also switched the timing test words "t( .. )t" to use the
ACPI timer instead of the timestamp counter, because the latter's
frequency changes with thermal throttling.


Added: cpu/x86/acpiio.fth
===================================================================
--- cpu/x86/acpiio.fth	                        (rev 0)
+++ cpu/x86/acpiio.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -0,0 +1,34 @@
+\ See license at end of file
+purpose: Access ACPI registers
+
+: acpi-b@  ( reg# -- b )  acpi-io-base + pc@  ;
+: acpi-b!  ( b reg# -- )  acpi-io-base + pc!  ;
+: acpi-w@  ( reg# -- w )  acpi-io-base + pw@  ;
+: acpi-w!  ( w reg# -- )  acpi-io-base + pw!  ;
+: acpi-l@  ( reg# -- l )  acpi-io-base + pl@  ;
+: acpi-l!  ( l reg# -- )  acpi-io-base + pl!  ;
+
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2009 FirmWorks
+\ 
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\ 
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\ 
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END

Modified: cpu/x86/acpitimer.fth
===================================================================
--- cpu/x86/acpitimer.fth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/acpitimer.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -1,16 +1,10 @@
 \ See license at end of file
 purpose: Timing functions using the ACPI timer
 
-: acpi-b@  ( reg# -- b )  acpi-io-base + pc@  ;
-: acpi-b!  ( b reg# -- )  acpi-io-base + pc!  ;
-: acpi-w@  ( reg# -- w )  acpi-io-base + pw@  ;
-: acpi-w!  ( w reg# -- )  acpi-io-base + pw!  ;
-: acpi-l@  ( reg# -- l )  acpi-io-base + pl@  ;
-: acpi-l!  ( l reg# -- )  acpi-io-base + pl!  ;
-
 \ The ACPI timer counts at 3.579545 MHz.
 \ 3.579545 * 1024 is 3665
 : acpi-timer@  ( -- counts )  8 acpi-l@  ;
+
 : acpi-us  ( us -- )
    d# 3664 * d# 10 rshift  acpi-timer@ +  ( end )
    begin   dup acpi-timer@ -  0< until    ( end )
@@ -22,26 +16,44 @@
    drop
 ;
 
-[ifdef] tsc@
 : acpi-calibrate-tsc  ( -- )
    tsc@  d# 100 acpi-ms  tsc@           ( d.start d.end )
    2swap d-                             ( d.delta )
    2dup d# 100 um/mod nip to ms-factor  ( d.delta ms )
    d# 100,000  um/mod nip to us-factor  ( )
 ;
-[else]
+
+[ifdef] use-acpi-timing
 : us  ( us -- )  acpi-us  ;
 ' acpi-ms to ms
+
 \ Timing tools
 variable timestamp1
 : t(  ( -- )  acpi-timer@ timestamp1 ! ;
+: ))t1  ( -- ticks )  acpi-timer@  timestamp1 @  -  ;
 : )t  ( -- )
-   acpi-timer@  timestamp1 @  -  d# 1000 d# 3580 */  ( microseconds )
+   ))t1  d# 1000 d# 3580 */  ( microseconds )
    push-decimal
    <#  u# u# u#  [char] , hold  u# u#s u#>  type  ."  uS "
    pop-base
 ;
-
+: ))t-sec  ( -- sec )    ))t1  d# 3,580,000 /  ;
+: )t-sec  ( -- )
+   ))t-sec  ( seconds )
+   push-decimal
+   <# u# u#s u#>  type  ." S "
+   pop-base
+;
+: .hms  ( seconds -- )
+   d# 60 /mod   d# 60 /mod    ( sec min hrs )
+   push-decimal
+   <# u# u#s u#> type ." :" <# u# u# u#> type ." :" <# u# u# u#>  type
+   pop-base
+;
+: )t-hms
+   ))t-sec  d# 3,580,000 /  ( seconds )
+   .hms
+;
 [then]
 
 \ LICENSE_BEGIN

Modified: cpu/x86/pc/olpc/via/config.fth
===================================================================
--- cpu/x86/pc/olpc/via/config.fth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/pc/olpc/via/config.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -28,6 +28,7 @@
 
 \ create use-timestamp-counter \ Use CPU's timestamp counter for timing ...
 			\ ... this is worthwhile if your CPU has one.
+create use-acpi-timing
 
 create resident-packages
 \ create use-watch-all

Modified: cpu/x86/pc/olpc/via/devices.fth
===================================================================
--- cpu/x86/pc/olpc/via/devices.fth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/pc/olpc/via/devices.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -12,8 +12,7 @@
 
 fload ${BP}/dev/pciprobe.fth		\ Generic PCI probing
 
-\ Use the CPU chip's Time Stamp Counter for timing; it does just what we want
-fload ${BP}/cpu/x86/tsc.fth
+fload ${BP}/cpu/x86/tsc.fth             \ Timestamp counter access words
 
 \ Calibrate the Time Stamp Counter using the ACPI timer
 fload ${BP}/cpu/x86/acpitimer.fth

Modified: cpu/x86/pc/olpc/via/fw.bth
===================================================================
--- cpu/x86/pc/olpc/via/fw.bth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/pc/olpc/via/fw.bth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -109,6 +109,8 @@
 ;
 [then]
 
+fload ${BP}/cpu/x86/acpiio.fth          \ ACPI register access
+
 fload ${BP}/cpu/x86/pc/olpc/via/probemem.fth	\ Memory probing
 
 [ifdef] virtual-mode

Modified: cpu/x86/pc/olpc/via/probemem.fth
===================================================================
--- cpu/x86/pc/olpc/via/probemem.fth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/pc/olpc/via/probemem.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -6,6 +6,7 @@
 : total-ram  ( -- ramsize )
    total-ram-cached ?dup  if  exit  then
    h# 385 config-b@ d# 24 lshift
+   h# 48 acpi-l@ h# 1000.0000 and  if  2/  then  \ Account for possible 32-bit width
    dup to total-ram-cached
 ;
 

Modified: cpu/x86/tsc.fth
===================================================================
--- cpu/x86/tsc.fth	2009-11-02 07:05:33 UTC (rev 1453)
+++ cpu/x86/tsc.fth	2009-11-03 01:07:21 UTC (rev 1454)
@@ -38,6 +38,7 @@
 : (ms)  ( #ms -- )  0  ?do  1ms  loop  ;
 ' (ms) to ms
 
+[ifdef] use-tsc-timing   \ These are precise but inaccurate, as the TSC varies with clock throttling
 \ Timing tools
 2variable timestamp
 : t(  ( -- )  tsc@ timestamp 2! ;
@@ -64,6 +65,7 @@
    ))t  us-factor d# 1,000,000 *  um/mod nip  ( seconds )
    .hms
 ;
+[then]
 
 \ LICENSE_BEGIN
 \ Copyright (c) 2006 FirmWorks




More information about the openfirmware mailing list