Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / sun4v-devices / vpci / vpci.tok
\ ========== Copyright Header Begin ==========================================
\
\ Hypervisor Software File: vpci.tok
\
\ 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: @(#)vpci.tok 1.5 07/08/06
purpose:
copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved.
copyright: Use is subject to license terms.
fcode-version3
headerless
fload ${BP}/dev/sun4v-devices/utilities/md-parse.fth
fload ${BP}/dev/sun4v-devices/vpci/hv-iface.fth
fload ${BP}/dev/sun4v-devices/vpci/common.fth
fload ${BP}/dev/sun4v-devices/iommu/iommu.fth
fload ${BP}/dev/sun4v-devices/vpci/msi-props.fth
fload ${BP}/dev/sun4v-devices/vpci/bus-ops.fth
fload ${BP}/dev/pci/pcibus.fth
fload ${BP}/dev/pci/map64.fth
[ifdef] N2-ERRATUM-106
\ The code dealing with erratum 106 can be removed once we
\ decommision support for N2 1.x parts
[message] VPCI driver still supporting 1.x N2 parts
0 value n2-erratum-106?
create get-hver
\ First setup the RDHPR opcode to read the HVER reg (see
\ UltraSPARC Architecture 2006 document)
\ '8' is %o0
\ '6' is for HVER
b# 10 d# 30 << 8 d# 25 << or b# 10.1001 d# 19 << or 6 d# 14 << or l,
\ Now we setup the DONE opcode as required by the diagnostic API
b# 10 d# 30 << b# 11.1110 d# 19 << or l,
: check-n2-erratum-106 ( -- )
\ First attempt to negotiate the diagnostic API. This will succeed if
\ the SP NVRAM variable 'sc_ssqamode' is true, or if we are using a N2 1.x part.
\ 0x300 negotiates the diagnostic API
\ 1 is the major version
\ 0 is the minor version
\ 3 is the number of input args
\ 0 is the number of output args (we don't care about them)
\ 0 is the API_SET_VERSION function number
\ 0xff is the CORE_TRAP group
h# 300 1 0 3 0 0 h# ff htrap ( )
get-hver >physical drop ( RA )
\ HV-ENOACCESS (0xa) will be returned if we can't use the diagnostic APIs,
\ so check that the return status is zero before moving on. 0x200 translates
\ the real address to a physical address
1 2 h# 200 h# 80 htrap 0= if ( PA | x )
\ 0x201 invokes the diagnostic API
1 1 h# 201 h# 80 htrap ( HVER )
d# 28 >> h# f and 1 = if ( )
true to n2-erratum-106? ( )
cmn-note[ ( )
" Downrev N2 part (v1.x) detected. Setting erratum 106 flag"
]cmn-end ( )
then ( )
else ( x )
drop ( )
then ( )
;
check-n2-erratum-106
[then] \ N2-ERRATUM-106
: enx+ ( xdr,len x -- xdr,len ) xlsplit swap >r en+ r> en+ ;
0 h# 8000.0000 lxjoin constant 4v-io-type
: make-reg-prop ( -- )
0 0 encode-bytes
0 my-space lxjoin enx+ 0 enx+ \ cfg-handle
" reg" property
;
: make-ranges ( I/O /io Mem32 /mem32 Mem64 /mem64-- )
>r >r ( I/O /io Mem32 /mem32)
>r >r ( I/O /io )
>r >r ( -- )
0 0 encode-bytes ( xdr,len )
h# 0100.0000 en+ 0 en+
[ifdef] N2-ERRATUM-106
n2-erratum-106? if h# 1000.0000 else 0 then
[else]
0
[then]
en+ \ PCI I/O
r> 4v-io-type or enx+ r> enx+ \ Offset, len
h# 0200.0000 en+ 0 en+ 0 en+ \ PCI Mem 32
r> 4v-io-type or enx+ r> enx+ \ Offset, len
h# 0300.0000 en+ 0 en+ 0 en+ \ PCI Mem 64
r> 4v-io-type or enx+ r> enx+ \ Offset, len
" ranges" property ( -- )
;
fload ${BP}/dev/sun4v-devices/vpci/methods.fth
pci-iobase pci-iosize \ IO spaces
pci-mem32base pci-mem32size \ memory spaces
pci-mem64base pci-mem64size
make-ranges
make-reg-prop
fload ${BP}/pkg/asr/pci-prober-support.fth
1meg pci-mem32size over - my-memlist free-memrange
1 d# 32 << pci-mem64size my-mem64list free-memrange
[ifdef] N2-ERRATUM-106
n2-erratum-106? if
h# 1000.0000 pci-iosize
else
0 pci-iosize
then
[else]
0 pci-iosize
[then]
my-io-list free-memrange
end0