[OpenBIOS] [commit] r1074 - trunk/openbios-devel/forth/device

repository service svn at openbios.org
Fri Nov 30 00:02:22 CET 2012


Author: mcayland
Date: Fri Nov 30 00:02:22 2012
New Revision: 1074
URL: http://tracker.coreboot.org/trac/openbios/changeset/1074

Log:
Add a default "decode-unit" word for devices that don't implement their own.

When a device does not implement its own "encode-unit" word, OpenBIOS
currently supplies a default implementation that encodes a hex string
to a single cell.

This commit does the same for "decode-unit" ensuring that it is also
possible to open a device path containing a unit address generated by
a device that doesn't implement its own "encode-unit" word.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>

Modified:
   trunk/openbios-devel/forth/device/pathres.fs

Modified: trunk/openbios-devel/forth/device/pathres.fs
==============================================================================
--- trunk/openbios-devel/forth/device/pathres.fs	Sat Nov 24 15:43:11 2012	(r1073)
+++ trunk/openbios-devel/forth/device/pathres.fs	Fri Nov 30 00:02:22 2012	(r1074)
@@ -177,28 +177,33 @@
 \ 4.3.3 match child node
 \ 
 
+\ used if package lacks a decode-unit method
+: def-decode-unit ( str len -- unitaddr ... )
+  parse-hex
+;
+
+: get-decode-unit-xt ( phandle -- xt )
+  " decode-unit" rot find-method
+  0= if ['] def-decode-unit then
+;
+
 : find-child ( sinfo -- phandle )
   >r
   \ decode unit address string
   r@ >si.unit_addr 2@ dup if
     ( str len )
-    " decode-unit" active-package find-method
-    if
-      depth 3 - >r execute depth r@ - r> swap
-      ( ... a_lo ... a_hi olddepth n )
-      4 min 0 max
-      dup r@ >si.unit_phys_len !
-      ( ... a_lo ... a_hi olddepth n )
-      r@ >si.unit_phys >r
-      begin 1- dup 0>= while
-        rot r> dup la1+ >r l!-be
-      repeat
-      r> 2drop
-      depth!
-    else
-      \ no decode-unit method... failure
-      -99 throw
-    then
+    active-package get-decode-unit-xt
+    depth 3 - >r execute depth r@ - r> swap
+    ( ... a_lo ... a_hi olddepth n )
+    4 min 0 max
+    dup r@ >si.unit_phys_len !
+    ( ... a_lo ... a_hi olddepth n )
+    r@ >si.unit_phys >r
+    begin 1- dup 0>= while
+      rot r> dup la1+ >r l!-be
+    repeat
+    r> 2drop
+    depth!
   else
     2drop
     \ clear unit_phys



More information about the OpenBIOS mailing list