Author: wmb Date: Mon Mar 26 19:35:34 2012 New Revision: 2917 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2917
Log: Core - Converted config-int, chosen-int, chosen-value, and chosen-variable to cell size intead of explicit 32-bit. Those values often contain pointers that need the full width of the processors native cell size, and represent dynamically-determined information that does not need portability across processor types. Property values in the device description portion of the device tree remain as explicit 32-bit chunks. The OFW client library code needs to be changed accordingly, but has not yet been changed.
Modified: cpu/arm/linux.fth cpu/arm/loadmach.fth forth/kernel/endian.fth ofw/confvar/conftype.fth ofw/confvar/nameval.fth ofw/core/fdt.fth ofw/core/ofwcore.fth ofw/fs/ext2fs/recovery.fth ofw/wifi/data.fth
Modified: cpu/arm/linux.fth ============================================================================== --- cpu/arm/linux.fth Mon Mar 26 19:29:01 2012 (r2916) +++ cpu/arm/linux.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -126,8 +126,8 @@ \ dup to linux-memtop to ramdisk-adr
- ramdisk-adr " linux,initrd-start" chosen-int-property - ramdisk-adr /ramdisk + " linux,initrd-end" chosen-int-property + ramdisk-adr " linux,initrd-start" chosen-cell-property + ramdisk-adr /ramdisk + " linux,initrd-end" chosen-cell-property ; : $load-ramdisk ( name$ -- ) 0 to /ramdisk ( name$ )
Modified: cpu/arm/loadmach.fth ============================================================================== --- cpu/arm/loadmach.fth Mon Mar 26 19:29:01 2012 (r2916) +++ cpu/arm/loadmach.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -13,8 +13,6 @@
fload ${BP}/cpu/arm/decompm.fth
-: be-l, ( l -- ) here 4 note-string allot be-l! ; - \needs $save-forth transient fload ${BP}/cpu/arm/savefort.fth resident \ alias $save-forth $save-forth
Modified: forth/kernel/endian.fth ============================================================================== --- forth/kernel/endian.fth Mon Mar 26 19:29:01 2012 (r2916) +++ forth/kernel/endian.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -28,13 +28,32 @@ [then]
: le-l, ( l -- ) here /l allot le-l! ; +: be-l, ( l -- ) here /l allot be-l! ;
-64\ : le-x@ ( a -- l ) dup le-l@ swap la1+ le-l@ lxjoin ; -64\ : be-x@ ( a -- l ) dup la1+ be-l@ swap be-l@ lxjoin ; +[ifndef] /x +8 constant /x +[then] + +32\ : le-x@ ( adr -- d ) dup le-l@ swap la1+ le-l@ ; +32\ : be-x@ ( adr -- d ) dup la1+ be-l@ swap be-l@ ; +32\ : le-x! ( d adr -- ) tuck la1+ le-l! le-l! ; +32\ : be-x! ( d adr -- ) tuck be-l! la1+ be-l! ; + +64\ : le-x@ ( a -- l ) dup le-l@ swap la1+ le-l@ lxjoin ; +64\ : be-x@ ( a -- l ) dup la1+ be-l@ swap be-l@ lxjoin ; 64\ : le-x! ( l a -- ) >r xlsplit r@ la1+ le-l! r> le-l! ; 64\ : be-x! ( l a -- ) >r xlsplit r@ be-l! r> la1+ be-l! ; -64\ : le-x, ( x -- ) here /x allot le-x! ; -64\ : be-x, ( x -- ) here /x allot be-x! ; + +: le-x, ( x -- ) here /x allot le-x! ; +: be-x, ( x -- ) here /x allot be-x! ; + +32\ alias be-n@ be-l@ +32\ alias be-n! be-l! +32\ alias be-n, be-l, + +64\ alias be-n@ be-x@ +64\ alias be-n! be-x! +64\ alias be-n, be-x,
\ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks
Modified: ofw/confvar/conftype.fth ============================================================================== --- ofw/confvar/conftype.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/confvar/conftype.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -124,7 +124,7 @@ ;
headers -: set-config-int-default ( n xt -- ) >body la1+ unaligned-! ; +: set-config-int-default ( n xt -- ) >body na1+ unaligned-! ;
6 actions action: ( apf -- n ) cv-int@ ; @@ -132,7 +132,7 @@ action: ( apf -- adr ) cv-adr drop ; action: ( n apf -- adr len ) drop (.d) ; action: ( adr len apf -- n ) drop $>number ; -action: ( apf -- n ) la1+ @ ; +action: ( apf -- n ) na1+ @ ;
: config-int ( "name" default-value -- ) config-create use-actions , ; : nodefault-int ( "name" -- ) 0 config-int nodefault ;
Modified: ofw/confvar/nameval.fth ============================================================================== --- ofw/confvar/nameval.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/confvar/nameval.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -268,8 +268,6 @@ over - ( cv-adr cv-len ) ;
-: config-adr ( apf -- adr ) l@ config-mem + ; - : (cv-flag@) ( apf -- flag ) cv-adr if >cv$ $>flag else @ 0<> then ; : (cv-flag!) ( flag apf -- ) 2dup default-value? 2>r flag>$ 2r> put-env$ ;
Modified: ofw/core/fdt.fth ============================================================================== --- ofw/core/fdt.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/core/fdt.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -155,8 +155,8 @@ [ifdef] notdef \ This is redundant because the Linux kernel reserves the initrd explicitly, \ independent of the reserve map (and it reserves the device tree blob too). - " linux,initrd-start" get-chosen-int dup fdt h# 40 + be-l! ( start ) - " linux,initrd-end" get-chosen-int swap - ( length ) + " linux,initrd-start" get-chosen-cell dup fdt h# 40 + be-l! ( start ) + " linux,initrd-end" get-chosen-cell swap - ( length ) fdt h# 4c + be-l! ( start ) [then]
Modified: ofw/core/ofwcore.fth ============================================================================== --- ofw/core/ofwcore.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/core/ofwcore.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -664,6 +664,13 @@ over be-l@ >r /l /string r> l->n ; : get-encoded-int ( adr len -- n ) drop be-l@ ; + +: encode-cell ( n -- adr len ) here swap be-n, /n ; + +: decode-cell ( adr len -- adr' len' n ) + over be-x@ >r /x /string r> +; +: get-encoded-cell ( adr len -- n ) drop be-n@ ; headers
\ From devtree.fth @@ -2936,9 +2943,9 @@ \ "chosen-variable" is a convenient way to report the contents of a \ variable in a "/chosen" property. Example: stdout " stdout" chosen-variable 5 actions -action: token@ execute @ encode-int over here - allot ; \ get -action: token@ execute >r get-encoded-int r> ! ; \ set -action: token@ execute ; \ addr +action: token@ execute @ encode-cell over here - allot ; \ get +action: token@ execute >r get-encoded-cell r> ! ; \ set +action: token@ execute ; \ addr action: drop ; action: drop ;
@@ -2951,9 +2958,9 @@ \ "chosen-value" is like chosen-variable, but with value semantics \ variable in a "/chosen" property. Example: stdout " stdout" chosen-variable 5 actions -action: token@ execute encode-int over here - allot ; \ get -action: token@ >r get-encoded-int r> 1 perform-action ; \ set -action: token@ 2 perform-action ; \ addr +action: token@ execute encode-cell over here - allot ; \ get +action: token@ >r get-encoded-cell r> 1 perform-action ; \ set +action: token@ 2 perform-action ; \ addr action: drop ; action: drop ;
@@ -3038,16 +3045,16 @@ dup if ihandle>phandle = else 2drop false then ;
-: chosen-int-property ( int name-str -- ) +: chosen-cell-property ( n name-str -- ) " /chosen" find-device \ XXX this eats up some space every time it's called ... - \ We really want an "set-encoded-int" - rot encode-int 2swap (property) + \ We really want "set-encoded-cell" + rot encode-cell 2swap (property) device-end ; : set-stdin ( ihandle -- ) stdin @ swap stdin ! ( old-ihandle ) - stdin @ " stdin" chosen-int-property + stdin @ " stdin" chosen-cell-property
" install-abort" stdin @ $call-method ( old-ihandle ) ?dup if ( old-ihandle ) @@ -3093,7 +3100,7 @@ -1 ( unknown-#lines ) else ( adr len ) \ Report the value of the "#lines" property - get-encoded-int ( #lines ) + get-encoded-cell ( #lines ) then ( #lines ) then ( #lines ) stdout-#lines ! @@ -3101,7 +3108,7 @@ : set-stdout ( ihandle -- ) stdout @ swap stdout ! ( old-ihandle ) ?close - stdout @ " stdout" chosen-int-property + stdout @ " stdout" chosen-cell-property report-#lines ; : output ( pathname-adr,len -- ) @@ -4462,7 +4469,7 @@ my-self if ( adr len ) my-voc (push-package) ( adr len ) " address" get-property 0= if ( adr len value-adr,len ) - get-encoded-int 2 pick = if ( adr len ) + get-encoded-cell 2 pick = if ( adr len ) " address" delete-property ( adr len ) then ( adr len ) then ( adr len )
Modified: ofw/fs/ext2fs/recovery.fth ============================================================================== --- ofw/fs/ext2fs/recovery.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/fs/ext2fs/recovery.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -354,7 +354,6 @@ next-commit-id 1+ to next-commit-id ;
-: be-x@ ( adr -- d ) dup la1+ be-l@ swap be-l@ ; : do-revoke-block ( -- ) revoking? 0= if exit then
Modified: ofw/wifi/data.fth ============================================================================== --- ofw/wifi/data.fth Mon Mar 26 19:29:01 2012 (r2916) +++ ofw/wifi/data.fth Mon Mar 26 19:35:34 2012 (r2917) @@ -177,8 +177,6 @@ : my-mac! ( adr -- ) wifi >my-mac /mac-adr move ; : ssid$ ( -- $ ) wifi >ssid cscount ; : ssid! ( $ -- ) /ssid 1- min wifi >ssid dup /ssid erase swap move ; -32\ : be-x! ( d adr -- ) tuck be-l! la1+ be-l! ; -32\ : be-x@ ( adr -- d ) dup la1+ be-l@ swap be-l@ ; : last-rcnt@ ( -- d ) wifi >last-rcnt be-x@ ; : last-rcnt! ( d -- ) wifi >last-rcnt be-x! ;