\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: common.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: @(#)common.fth 1.1 06/02/16
copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
copyright: Use is subject to license terms.
: unaligned-w@ ( adr -- val ) dup c@ swap 1+ c@ swap bwjoin ;
\ 512 max mtu minus 8 byte queue ptk minus header
h# 200 8 - /send-hdr - constant blocksize
: setup-pkt ( len cmd -- tx-bytes )
outbuf >command c! ( len )
blocksize min dup outbuf >send-size w! ( len' )
>r d# 100 begin r@ execute 0= over 0<> and while 1 - 10 ms repeat
cmn-error[ " ASR transfer timed out" ]cmn-end
: svc-enable ( adr len -- status )
enable-cmd setup-pkt ( adr bytes )
swap outbuf /send-hdr + ( bytes adr dest )
outbuf >send-size unaligned-w@ move ( bytes )
['] recv? poll recv if ( )
inbuf >status c@ ( status )
asr-rx-error throw ( err )
: svc-disable ( adr len -- status )
disable-cmd setup-pkt ( adr bytes )
swap outbuf /send-hdr + ( bytes adr dest )
outbuf >send-size unaligned-w@ move ( bytes )
['] recv? poll recv if ( )
inbuf >status c@ ( status )
asr-rx-error throw ( err )
: svc-state ( adr -- buflen|0 status )
0 state-cmd setup-pkt ( adr bytes )
['] send? poll send ( adr )
['] recv? poll recv if ( adr )
inbuf >status c@ ?dup if ( adr status )
inbuf /reply-hdr + swap ( state adr )
inbuf >reply-size unaligned-w@ dup >r move ( len status )
r> asr-cmd-ok ( len status )
drop asr-rx-error throw ( err )
: svc-statelen ( -- len|0 status )
0 statelen-cmd setup-pkt ( bytes )
['] recv? poll recv if ( )
inbuf >status c@ ?dup if ( status )
inbuf /reply-hdr + unaligned-w@ asr-cmd-ok ( len status )
asr-rx-error throw ( err )
: svc-query ( buf len -- flags )
query-cmd setup-pkt ( adr bytes )
swap outbuf /send-hdr + ( bytes adr dest )
outbuf >send-size unaligned-w@ move ( bytes )
['] recv? poll recv if ( )
inbuf >status c@ ?dup if ( error )
inbuf /reply-hdr + c@ ( flags )
asr-rx-error throw ( error )
asr-sid /send-hdr blocksize + init-svc