Author: wmb Date: Sun Oct 16 02:01:43 2011 New Revision: 2612 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2612
Log: Core - added deferred time&date to kernel so it can be used uniformly.
Modified: forth/kernel/kernel.fth forth/kernel/sysio.fth forth/lib/date.fth ofw/core/date.fth ofw/core/ofwfw.fth
Modified: forth/kernel/kernel.fth ============================================================================== --- forth/kernel/kernel.fth Sun Oct 16 01:21:46 2011 (r2611) +++ forth/kernel/kernel.fth Sun Oct 16 02:01:43 2011 (r2612) @@ -3134,6 +3134,10 @@ bye ; [then] +defer time&date ( -- s m h d m y ) +: now ( -- s m h ) time&date 3drop ; +: today ( -- d m y ) time&date >r >r >r 3drop r> r> r> ; +
\ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks
Modified: forth/kernel/sysio.fth ============================================================================== --- forth/kernel/sysio.fth Sun Oct 16 01:21:46 2011 (r2611) +++ forth/kernel/sysio.fth Sun Oct 16 02:01:43 2011 (r2612) @@ -169,6 +169,12 @@ $cstr d# 84 syscall drop retval dup if cscount false else drop true then ;
+: l@+ ( adr -- l adr' ) dup l@ swap la1+ ; +: sys-time&date ( -- s m h d m y ) + d# 64 syscall retval ( adr ) + l@+ l@+ l@+ l@+ l@+ l@+ drop d# 1900 + ( s m h d m y ) +; + : install-wrapper-alloc ( -- ) \ Don't use "is" in case a relocation map needs to be allocated first ['] sys-alloc-mem ['] alloc-mem >body >user token! @@ -194,6 +200,7 @@ \ init-relocation goes here, for versions that need it install-wrapper-key ['] sys-$getenv is $getenv + ['] sys-time&date is time&date ;
headers
Modified: forth/lib/date.fth ============================================================================== --- forth/lib/date.fth Sun Oct 16 01:21:46 2011 (r2611) +++ forth/lib/date.fth Sun Oct 16 02:01:43 2011 (r2612) @@ -1,30 +1,7 @@ \ See license at end of file -purpose: Date and Time-of-day access +purpose: Date and Time-of-day display
decimal -variable tmstruct -: tmfield \ name ( offset -- offset' ) - create dup , la1+ - does> @ tmstruct @ + -; - -struct \ tm struct returned by 4.2 localtime call -tmfield tm_sec -tmfield tm_min -tmfield tm_hour -tmfield tm_mday -tmfield tm_mon -tmfield tm_year -tmfield tm_wday -tmfield tm_yday -tmfield tm_isdst -drop - -: (today ( -- timeval-struct-adr ) 64 syscall retval tmstruct ! ; -: today ( -- day month year) - (today tm_mday l@ tm_mon l@ 1+ tm_year l@ 1900 + -; -: now ( -- sec min hour ) (today tm_sec l@ tm_min l@ tm_hour l@ ; : time-zone ( -- minutes-west-of-GMT) 68 syscall retval ; : .time-zone ( -- ) 72 syscall retval cscount type ;
@@ -76,6 +53,7 @@ ; : .now ( -- ) now .time ; : .today ( -- ) today .date ; + \ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks \
Modified: ofw/core/date.fth ============================================================================== --- ofw/core/date.fth Sun Oct 16 01:21:46 2011 (r2611) +++ ofw/core/date.fth Sun Oct 16 02:01:43 2011 (r2612) @@ -3,7 +3,7 @@
variable clock-node ' clock-node " clock" chosen-variable
-: time&date ( -- s m h d m y ) +: ofw-time&date ( -- s m h d m y ) " get-date" clock-node @ ihandle>phandle find-method if drop " get-time" clock-node @ $call-method swap rot @@ -12,14 +12,16 @@ " get-time" clock-node @ $call-method then ; -: now ( -- s m h ) time&date 3drop ; -: today ( -- d m y ) time&date >r >r >r 3drop r> r> r> ; +stand-init: + ['] ofw-time&date to time&date +;
headerless : 2.d ( n -- ) push-decimal (.2) type pop-base ; +: 4.d ( n -- ) push-decimal <# u# u# u# u# u#> type pop-base ;
headers -: .date ( d m y -- ) swap 2.d ." /" swap 2.d ." /" d# 100 mod 2.d ; +: .date ( d m y -- ) 4.d ." -" 2.d ." -" 2.d ; : .time ( s m h -- ) 2.d ." :" 2.d ." :" 2.d ;
\ Interactive diagnostic
Modified: ofw/core/ofwfw.fth ============================================================================== --- ofw/core/ofwfw.fth Sun Oct 16 01:21:46 2011 (r2611) +++ ofw/core/ofwfw.fth Sun Oct 16 02:01:43 2011 (r2612) @@ -4,7 +4,7 @@
variable clock-node ' clock-node " clock" chosen-variable
-: time&date ( -- s m h d m y ) +: ofw-time&date ( -- s m h d m y ) " get-date" clock-node @ ihandle>phandle find-method if drop " get-time" clock-node @ $call-method swap rot @@ -13,8 +13,9 @@ " get-time" clock-node @ $call-method then ; -: now ( -- s m h ) time&date 3drop ; -: today ( -- d m y ) time&date >r >r >r 3drop r> r> r> ; +stand-init: + ['] ofw-time&date to time&date +;
headerless : 2.d ( n -- ) push-decimal (.2) type pop-base ;