\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: util.fth
\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
\ - Do no alter or remove copyright notices
\ - Redistribution and use of this software in source and binary forms, with
\ or without modification, are permitted provided that the following
\ - Redistribution of source code must retain the above copyright notice,
\ this list of conditions and the following disclaimer.
\ - Redistribution in binary form must reproduce the above copyright notice,
\ this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
\ Neither the name of Sun Microsystems, Inc. or the names of contributors
\ may be used to endorse or promote products derived from this software
\ without specific prior written permission.
\ This software is provided "AS IS," without a warranty of any kind.
\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ You acknowledge that this software is not designed, licensed or
\ intended for use in the design, construction, operation or maintenance of
\ ========== Copyright Header End ============================================
id: @(#)util.fth 1.1 07/01/23
copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
copyright: Use is subject to license terms.
swap xlsplit rot ( lo hi n )
dup d# 32 >= if ( lo hi n )
rot drop 0 swap d# 32 - ( lo' 0 n' )
2dup rshift >r ( lo' hi' n' )( R: res.hi )
1 over lshift 1- rot and ( lo' n' bits )
d# 32 2 pick - lshift -rot rshift or ( res.lo )
r> ( res.lo res.hi )( R: )
\ 0<> tokenizes into l0<>, which doesn't pick up the
: wait-status ( timeout check-acf -- ok? )
swap ( check-acf timeout )
0 ( check-acf timeout 0 )
dup ( check-acf check-acf )
execute ( check-acf ??? ) \ ??? is the return value of check-acf
drop ( ) \ drop check-acf
\ The difference between this and wait-status is that this word passes
\ one argument to check-acf. For example, we can pass a DMA channel
\ number to a check-acf function.
: wait-status-with-arg ( timeout arg check-acf -- ok? )
rot 0 ?do ( arg check-acf )
2dup execute if ( arg check-acf )
: timed-out? ( when -- flag ) get-msecs - 0< ;
: set-default-link-params
auto-duplex to user-duplex
auto-link-clock to user-link-clock
d# 128 constant my-path-len
my-path-len buffer: my-path$
my-path$ my-path-len 0 fill \ Clear device path.
my-path-len 2 - my-path$ 1+ ( len' va' )
my-self ihandle>phandle " package-to-path" ( len' va' ihandle method$ )
" /openprom/client-services" find-package ( ... [false | phandle true] )
0= if 3drop 2drop exit then ( ... ihandle method$ phandle )
find-method ( ... ihandle [false | xt true] )
0= if 3drop exit then ( ... ihandle xt )
\ Append ": " to the device-path.
1+ dup 1+ my-path$ tuck c! + ( [len''+1+va] )
: path$ ( -- str,len ) my-path$ count ;
\ Print byte with 3 character alignment
i 1+ d# 8 mod 0= if cr then