Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / scsi / targets / scsicom.fth
\ ========== Copyright Header Begin ==========================================
\
\ Hypervisor Software File: scsicom.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
\ conditions are met:
\
\ - 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
\ any nuclear facility.
\
\ ========== Copyright Header End ============================================
id: @(#)scsicom.fth 1.2 00/06/07
purpose:
copyright: Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved
\ This file contains some words which are useful for both SCSI disk and
\ SCSI tape device drivers.
\ The SCSI disk and SCSI tape packages need to export dma-alloc and dma-free
\ methods so the deblocker can allocate DMA-capable buffer memory.
external
: dma-alloc ( n -- vaddr ) " dma-alloc" $call-parent ;
: dma-free ( vaddr n -- ) " dma-free" $call-parent ;
headers
: parent-max-transfer ( -- n ) " max-transfer" $call-parent ;
\ Calls the parent device's "retry-command" method. The parent device is
\ assumed to be a driver for a SCSI host adapter (device-type = "scsi")
: retry-command ( dma-addr dma-len dma-dir cmd-addr cmd-len #retries -- ... )
( ... -- false ) \ No error
( ... -- true true ) \ Hardware error
( ... -- sensebuf false true ) \ Fatal error with extended status
" retry-command" $call-parent
;
\ Simplified command execution routines for common simple command forms
: no-data-command ( cmdbuf -- error? ) " no-data-command" $call-parent ;
: short-data-command ( data-len cmdbuf cmdlen -- true | buffer false )
" short-data-command" $call-parent
;
\ Some tools for reading and writing 2, 3, and 4 byte numbers to and from
\ SCSI command and data buffers. The ones defined below are used both in
\ the SCSI disk and the SCSI tape packages. Other variations that are
\ used only by one of the packages are defined in the package where they
\ are used.
: +c! ( n addr -- addr' ) tuck c! 1+ ;
: 3c! ( n addr -- ) >r lbsplit drop r> +c! +c! c! ;
: -c@ ( addr -- n addr' ) dup c@ swap 1- ;
: 3c@ ( addr -- n ) 2 + -c@ -c@ c@ 0 bljoin ;
: 4c@ ( addr -- n ) 3 + -c@ -c@ -c@ c@ bljoin ;
\ "Scratch" command buffer useful for construction of read and write commands
create cmdbuf 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c,
: cb! ( byte index -- ) cmdbuf + c! ; \ Write byte to command buffer
\ The deblocker converts a block/record-oriented interface to a byte-oriented
\ interface, using internal buffering. Disk and tape devices are usually
\ block or record oriented, but the OBP external interface is byte-oriented,
\ in order to be independent of particular device block sizes.
0 instance value deblocker
\ Fix read records at no larger than 32K.
headers
h# 8000 value deblock-defbufsize
headerless
: init-deblocker ( -- okay? )
" " " deblocker" $open-package to deblocker
deblocker if
true
else
." Can't open deblocker package" cr false
then
;
headers