Author: wmb
Date: 2008-09-30 23:06:51 +0200 (Tue, 30 Sep 2008)
New Revision: 954
Added:
dev/amd7990/
dev/amd7990/lance32.fth
dev/amd7990/lancecom.fth
dev/amd7990/lancetst.fth
dev/amd7990/lancevar.fth
dev/amd7990/regbits.fth
dev/amd7990/timedrec.fth
dev/amd7990/vmlance.fth
dev/amd79970/
dev/amd79970/79c970.fth
dev/amd79970/amd79970.bth
dev/amd79970/amd7997m.bth
dev/amd79970/build/
dev/amd79970/loadfcod.fth
dev/amd79970/loadpkg.fth
dev/amd79970/map.fth
dev/amd79970/methods.fth
dev/amd79970/setup.fth
dev/amd79970/vmlance.bth
Log:
Added old AMD Ethernet driver to tree for use with VMWare and VirtualBox.
Added: dev/amd7990/lance32.fth
===================================================================
--- dev/amd7990/lance32.fth (rev 0)
+++ dev/amd7990/lance32.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,225 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: lance32.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 ============================================
+purpose: Definitions for the 32-bit LANCE interface
+copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
+
+\ Register access
+
+\ The chips that support 32-bit descriptor addresses usually
+\ have two modes for accessing the control registers. In the
+\ "normal" word I/O mode, the registers are accessed with 16-bit
+\ bus cycles and appear at adjacent 16-bit locations (0x10, 0x12, ...)
+\ In double-word I/O mode, they are accessed with 32-bit bus
+\ cycles and appear at adjacent 32-bit locations (0x10, 0x14, ...)
+\ In either case, they contain only 16 bits of useful data, so
+\ there is no real advantage to using 32-bit accesses.
+\ The chip determines the mode from the first access cycle, and
+\ "locks" into that mode. The only way to change the mode thereafter
+\ is to issue a hardware reset to it; a software reset won't do it.
+\ We use 16-bit mode as the default, for the benefit of client programs
+\ that use older driver code.
+
+[ifdef] 32-bit-cycles
+: >reg ( offset -- adr ) la swap la+ h# 10 + ;
+: reg@ ( offset -- data ) >reg rl@ ;
+: reg! ( data offset -- ) >reg rl! ;
+[else]
+: >reg ( offset -- adr ) la swap wa+ h# 10 + ;
+: reg@ ( offset -- data ) >reg rw@ ;
+: reg! ( data offset -- ) >reg rw! ;
+[then]
+
+: rdp! ( val -- ) 0 reg! ;
+: rdp@ ( -- val ) 0 reg@ ;
+
+: rap! ( val -- ) 1 reg! ;
+: rap@ ( -- val ) 1 reg@ ;
+
+: reset ( -- ) 2 reg@ drop ;
+
+: bdp! ( val -- ) 3 reg! ;
+: bdp@ ( -- val ) 3 reg@ ;
+
+\ Control and Status Register
+: csr! ( value reg# -- ) rap! rdp! ;
+: csr@ ( reg# -- value ) rap! rdp@ ;
+
+\ Bus Control Register
+: bcr! ( value reg# -- ) rap! bdp! ;
+: bcr@ ( reg# -- value ) rap! bdp@ ;
+
+
+\ In addition to the 16/32-bit register access, some AMD Ethernet
+\ chips allow you to choose 16-bit and 32-bit versions of the
+\ descriptor data structures. Unlike the register access, there
+\ is a compelling reason to use the 32-bit data structures, for
+\ they contain 32-bit DMA pointers. The 16-bit data structures
+\ use 24-bit DMA pointers, thus restricting DMA to the lower 16 MBytes.
+
+\ Message descriptor access
+
+struct ( message-descriptor )
+4 field >addr
+2 field >bytecnt
+1 field >reserved1
+1 field >laflags
+0 field >tmd2
+2 field >mcnt
+0 field >xerrors
+1 field >rpc
+1 field >rcc
+4 field >reserved2
+( total-length ) constant /md
+
+/md value /rmd
+/md value /tmd
+
+\ Little-endian reads and writes
+: lew@ ( addr -- w ) dup c@ swap 1+ c@ bwjoin ;
+: lew! ( addr w -- ) >r wbsplit r@ 1+ c! r> c! ;
+
+: lel@ ( addr -- l ) dup lew@ swap 2+ lew@ wljoin ;
+: lel! ( addr l -- ) >r lwsplit r@ 2+ lew! r> lew! ;
+
+: dump-regs ( -- )
+ hex la . cr
+ h# 80 0 do i decimal 3 u.r hex i csr@ 9 u.r cr loop
+;
+
+\ Get virtual address of buffer from message descriptor
+: addr@ ( rmd/tmd-vaddr -- buff-vaddr ) >addr lel@ devaddr> ;
+
+\ gets length of incoming message - receive only
+: length@ ( rmdaddr -- messagelength ) >mcnt lew@ ;
+
+\ gets transmit errors - transmit only
+: xerrors@ ( tmdaddr -- errorsflag )
+ >xerrors lew@ dup rtry and 0= if \ mask TDR unless RTRY set
+ h# fc00 and
+ then
+;
+
+\ Store buffer address into message descriptor
+\ The message descriptor must have a DMA address in it because
+\ the chip reads it.
+: addr! ( buff-vaddr rmd/tmd-vaddr -- ) swap >devaddr swap >addr lel! ;
+
+\ Set length of message to be sent - transmit only
+: length! ( length rmd/tmd-addr -- ) swap negate swap >bytecnt lew! ;
+
+\ Clear transmit error flags
+: clear-errors ( tmd-addr -- ) 0 swap >xerrors lew! ;
+
+
+\ Initialization
+
+0 constant /ib \ We use direct CSR access for initialization - no IB needed
+
+: set-this-addr ( addr -- )
+ \ Load physical address in CSR12/13/14
+ d# 12 swap 6 bounds do ( csr# )
+ i c@ i 1+ c@ bwjoin over csr! 1+ ( csr#' )
+ 2 +loop drop
+;
+
+\ Initialize the Lance chip
+: lance-init ( -- flag )
+ 0 rdp! \ Write to RDP to set the access mode
+ \ We are just hoping that there are no
+ \ side effects of this write.
+
+ \ The stop bit must be set before accesses to the following CSRs
+ stopb 0 csr!
+
+\ Disable transmitter and receiver
+\ mode @ 3 or 15 csr!
+ this-en-addr set-this-addr \ Physical Ethernet Address (CSR12/13/14)
+ 0 8 csr! 0 9 csr! 0 10 csr! \ Logical Address Filter (CSR8/9/10/11)
+ 0 11 csr!
+ rmd0 >devaddr lwsplit 25 csr! 24 csr! \ Receive Ring Base Address (CSR24/25)
+ #rmds negate h# ffff and \ Receive Ring Length (CSR76)
+ 76 csr!
+ tmd0 >devaddr lwsplit 31 csr! 30 csr! \ Transmit Ring Base Address (CSR30/31)
+ 1 negate h# ffff and 78 csr! \ Transmit Ring Length (CSR78)
+ 0 47 csr! \ Polling Interval (CSR47)
+
+\ h# 1115 4 csr! \ Disable polling
+
+ \ This value would be "2" for auto-selection
+ 0 2 bcr! \ Force selection of 10BASE-T vs. AUI
+
+ tp? if \ Set TMAULOOP for 10BASE-T external loopback
+ mode @ lpbk and if
+ mode @ intl and 0= if h# 4000 2 bcr! then
+ then
+ then
+
+\ h# 4002 2 bcr! \ Miscellaneous configuration
+
+ h# 2180 18 bcr! \ Turn off bursting
+\ h# 0161 18 bcr! \ Burst size and bus control
+
+ h# 0002 20 bcr! \ Software style = PCnet-PCI, SSIZE = 1
+
+ \ Set the mode register after all the others because otherwise
+ \ VMware's emulated 79c970 screws up. Apparently it enables
+ \ transmit and receive as soon as you write the mode register,
+ \ instead of waiting for the STRT bit to be set. If you write
+ \ the mode register before establishing the descriptor addresses,
+ \ it tries to access bogus descriptors.
+ mode @ tp? if h# 80 or then 15 csr! \ Mode (CSR15)
+
+ \ The start bit must now be set. **DO NOT SET INIT BIT OR ABOVE REGISTERS
+ \ WILL BE OVERWRITTEN**
+
+ strt 0 csr!
+ true
+;
+
+\ Restore the chip to its default modes for the benefit of client programs
+: lance-uninit ( -- ) \ Call from close, after setting STOP
+ reset \ Issue software reset
+ h# 200 d# 20 bcr! \ Restore default "PCnet-ISA" programing interface
+ h# 200 d# 58 csr! \ Restore default "PCnet-ISA" programing interface
+ h# 9060 d# 18 bcr! \ Re-enable burst modes
+ 2 2 bcr! \ Re-enable auto-selection of media
+;
Added: dev/amd7990/lancecom.fth
===================================================================
--- dev/amd7990/lancecom.fth (rev 0)
+++ dev/amd7990/lancecom.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,228 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: lancecom.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 ============================================
+purpose: Code common to all LANCE versions
+copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
+
+d# 1514 encode-int " max-frame-size" property
+
+headers
+
+\ buffer# to address calculations
+: rmd#>rmdaddr ( n -- addr ) /rmd * rmd0 + ;
+: rbuf#>rbufaddr ( n -- addr ) /rbuf * rbuf0 + ;
+
+1 #rmdsfactor lshift to #rmds
+#rmds /rmd * to /rmds
+
+\ patch routine to change buffer count
+: set-factor ( rmdsfactor -- ) \ 1=2bufs, 2=4bufs, 3=8bufs, etc.
+ 8 min \ max buffers is 256
+ to #rmdsfactor
+ 1 #rmdsfactor lshift to #rmds
+ #rmds /rmd * to /rmds
+;
+
+: status@ ( rmd/tmd-addr -- statusflag ) >laflags c@ ;
+
+\ Masks out OWN, ENP and STP bits; they aren't errors
+: rerrors@ ( rmd/tmd-addr -- errorsflag ) status@ ready invert and ;
+
+
+\ *** Lance message descriptor ring value storage ***
+
+\ Put a buffer back in the chip's ready list
+: give-buffer ( rmd/tmd-addr -- ) >laflags ready swap c! synchronize ;
+
+\ *** Initialization routines ***
+
+: set-address ( en-addr len -- ) drop this-en-addr 6 cmove ;
+
+\ Initialize a single message descriptor
+: rmd-init ( rbufaddr rmdaddr -- )
+ /rbuf over length! \ Buffer length
+ addr! \ Buffer address
+;
+
+\ Set up the data structures necessary to receive a packet
+instance variable nextrmd
+: rinit ( -- )
+ rmd0 nextrmd !
+ #rmds 0 do i rbuf#>rbufaddr i rmd#>rmdaddr rmd-init loop
+ #rmds 0 do i rmd#>rmdaddr give-buffer loop
+;
+
+\ *** Receive packet routines ***
+
+: .err-text ( err-code -- err-code )
+ enp over and if
+ fram over and if ." Framing error " then
+ crc over and if ." CRC error " then
+ else
+ oflo over and if ." FIFO overflow " then
+ then
+ buff over and if ." No buffers " then
+;
+
+instance defer .error
+: (.error ( buf-handle buffer length -- buf-handle buffer length )
+ 2 pick rerrors@ if
+ 2 pick status@ dup mser and if .err-text then drop
+ drop 0
+ then
+;
+
+: receive-ready? ( -- packet-waiting? )
+ synchronize
+ nextrmd @ status@ own and 0=
+;
+
+: receive ( -- buf-handle buffer len ) \ len non-zero if packet ok
+ nextrmd @ dup addr@ over ( nlover ) ( rmd bufferaddr rmd )
+ length@ .error
+;
+
+: to-next-rmd ( -- )
+ /rmd nextrmd +!
+ nextrmd @ rmd0 - /rmds >= if rmd0 nextrmd ! then
+;
+
+: return-buffer ( buf-handle -- ) give-buffer to-next-rmd ;
+
+
+\ *** start of transmit routines ***
+
+instance variable nexttmd \ tmd0 nexttmd !, never changes presently
+
+\ Wait until transmission completed
+: send-wait ( -- ) begin 0 csr@ tint and until tint 0 csr! ;
+
+\ *** Transmit initialization routines ***
+
+\ transmit buffer initialize routine
+: tinit ( -- )
+ tmd0 nexttmd !
+ tbuf0 nexttmd @ addr!
+ nexttmd @ clear-errors
+;
+
+\ Set up CPU page maps
+: map-lance-buffers ( -- )
+ #rmdsfactor set-factor
+ #rmds /rbuf * ( rbuf-size )
+
+ \ Figure out how much total DMA space we're going to need
+
+ /ib + /tmd + /rmds + /tbuf + ( total-dma-size )
+ to lance-dma-size
+
+ \ Allocate and map that space
+ lance-dma-size lance-allocate-dma ( dma-area-adr )
+ dup to dma-base
+
+ \ Set the addresses of the various DMA regions used by the chip
+ dup to ib /ib + ( next-address )
+ dup to tmd0 /tmd + ( next-address )
+ dup to rmd0 /rmds + ( next-address )
+ dup to tbuf0 /tbuf + ( next-address ) \ Enough for max packet
+ to rbuf0 ( )
+;
+
+: unmap-lance-buffers ( -- )
+ dma-base lance-dma-size lance-free-dma
+ 0 to dma-base
+;
+
+\ Initializes the chip, allocating the necessary memory, and enabling the
+\ transmitter and receiver.
+: net-on ( -- flag ) \ true if net-on succeeds
+ mac-address set-address
+ tinit rinit
+ lance-init
+;
+
+: net-off ( -- ) stopb 0 csr! ;
+
+\ *** Main transmit routines ***
+
+\ Ignores the size argument, and uses the standard buffer.
+: get-buffer ( dummysize -- buffer ) drop nexttmd @ addr@ ;
+
+\ Display time domain reflectometry information
+: .tdr ( xerrors -- ) h# 3ff and ." TDR: (decimal) " .d ;
+
+: .terr-text ( tmd -- )
+ xerrors@ >r
+ xbuf r@ and if ." Buffer Error " then
+ uflo r@ and if ." Underflow " then
+ lcol r@ and if ." Late Collision " r@ .tdr then
+ lcar r@ and if ." Lost Carrier (transceiver cable problem?) " then
+ rtry r@ and if ." Too Many Retries " r@ .tdr then
+ r> drop cr
+;
+
+\ print summary of any HARD errors
+: (.transmit-error ( tmd len -- tmd len )
+ over status@ mser and if over .terr-text then
+;
+instance defer .transmit-error
+
+\ This send routine does not enforce the minimum packet length. It is
+\ used by the loopback test routines. Loopback only works with packets
+\ whose length is <= 32 bytes.
+: short-send ( buffer length -- error? )
+ tuck nexttmd @ length! ( length buffer )
+ drop \ discard buffer address, assumes using nexttmd
+ nexttmd @ give-buffer \ Give tmd to chip
+ tdmd 0 csr! \ Force chip to look at it right away
+ send-wait \ wait for completion
+ nexttmd @ swap ( tmd length )
+ .transmit-error ( tmd length )
+ drop xerrors@ dup if nexttmd @ clear-errors then ( error? )
+;
+
+\ transmit packet routine
+: net-send ( buffer length -- error? )
+ d# 64 max \ force minimum length to be 64
+ short-send ( error? )
+;
+
+headers
Added: dev/amd7990/lancetst.fth
===================================================================
--- dev/amd7990/lancetst.fth (rev 0)
+++ dev/amd7990/lancetst.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,166 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: lancetst.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 ============================================
+purpose: LANCE selftest
+copyright: Copyright 1990 Sun Microsystems, Inc. All Rights Reserved
+
+hex
+headers
+instance variable lance-verbose?
+instance variable ext-lbt? ext-lbt? off
+
+create loopback-prototype
+ ff c, 00 c, \ Ones and zeroes
+ 01 c, 02 c, 04 c, 08 c, 10 c, 20 c, 40 c, 80 c, \ Walking ones
+ fe c, fd c, fb c, f7 c, ef c, 0df c, 0bf c, 7f c, \ Walking zeroes
+
+: loopback-buffer ( -- adr len )
+ /loopback get-buffer ( adr )
+ mac-address drop over 6 cmove \ Set source address
+ mac-address drop over 6 + 6 cmove \ Set destination address
+ loopback-prototype over d# 12 + d# 20 cmove \ Set buffer contents
+ /loopback
+;
+
+: pdump ( adr -- )
+ base @ >r hex
+ dup d# 10 bounds do i c@ 3 u.r loop cr
+ d# 10 + d# 10 bounds do i c@ 3 u.r loop cr
+ r> base !
+;
+
+: .loopback ( -- )
+ mode @ intl and if ." Internal " else ." External " then
+ ." loopback test -- "
+;
+
+: ?.loopback ( -- )
+ lance-verbose? @ 0= if .loopback then ;
+
+: switch-off ( -- false )
+ lance-verbose? off false
+;
+
+: bad-rx-data ( buf-handle data-address -- false )
+ ?.loopback
+ ." Received packet contained incorrect data. Expected: " cr
+ loopback-prototype pdump
+ ." Observed:" cr
+ d# 12 + pdump
+ switch-off
+;
+
+: check-data ( buf-handle data-address length -- flag )
+ \ flag is true if data ok
+ drop ( buf-handle data-address )
+ dup d# 12 + loopback-prototype d# 20 comp
+ if bad-rx-data
+ else drop ( buf-handle )
+ return-buffer
+ lance-verbose? @ if ." succeeded." cr then
+ mode off true
+ then
+;
+
+: check-len&data ( buf-handle data-address length -- flag )
+ \ flag is true if data, len ok
+ \ The CRC is appended to the packet, thus it is 4 bytes longer than
+ \ the packet we sent.
+ dup /loopback 4 + <> if
+ ?.loopback
+ ." Wrong packet length; expected " /loopback 4 + 2 .r
+ ." , observed " .d cr
+ switch-off
+ else
+ check-data
+ then
+;
+
+: loopback-test ( internal/external -- flag ) \ flag is true if test passed
+ lpbk or mode !
+ lance-verbose? @ if ." " .loopback then
+ net-on if
+ loopback-buffer short-send if
+ ?.loopback ." send failed." cr
+ switch-off
+ else
+ d# 2000 timed-receive if
+ ?.loopback
+ ." Did not receive expected loopback packet." cr
+ switch-off
+ else ( buf-handle data-address length )
+ check-len&data
+ then
+ then
+ else
+ switch-off
+ then
+ net-off mode off
+;
+
+: net-init ( -- flag ) \ flag is true if net-init succeeds
+ mode @ \ Save requested mode because loopback changes it
+ intl loopback-test if \ mode_saved ; passed int. loopback test
+ ext-lbt? @ if 0 loopback-test else true then ( saved-mode flag )
+ swap mode ! if net-on else false then
+ else
+ mode ! false
+ then
+;
+
+: wait-for-packet ( -- )
+ begin key? receive-ready? or until
+;
+
+: watch-test ( -- )
+ ." Looking for Ethernet packets." cr
+ ." '.' is a good packet. 'X' is a bad packet." cr
+ ." Type any key to stop." cr
+ begin
+ wait-for-packet
+ receive-ready? if
+ receive if ." ." else ." X" then
+ drop return-buffer
+ then
+ key? dup if key drop then
+ until
+;
+headers
Added: dev/amd7990/lancevar.fth
===================================================================
--- dev/amd7990/lancevar.fth (rev 0)
+++ dev/amd7990/lancevar.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,80 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: lancevar.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 ============================================
+purpose: Variables for AMD7990 Ethernet driver
+copyright: Copyright 1994 Firmworks All Rights Reserved
+
+headers
+
+6 buffer: macbuf
+
+\ Virtual addresses within the DMA buffer area.
+\ The actual addresses will be assigned later
+
+0 instance value dma-base
+0 instance value ib \ initialization block
+0 instance value tmd0 \ transmit message descriptor#0
+0 instance value rmd0 \ receive message descriptor#0
+0 instance value tbuf0 \ transmit buffer#0
+0 instance value rbuf0 \ receive buffer#0
+
+0 instance value #rmds
+0 instance value /rmds
+
+0 instance value lance-dma-size \ Amount of memory mapped
+0 instance value dma-offset \ virtual-address minus dma-address
+: >devaddr ( virt -- devaddr ) dma-offset - ;
+: devaddr> ( devaddr -- virt ) dma-offset + ;
+
+instance variable mode \ Chip mode - loopback, etc
+
+6 instance buffer: this-en-addr \ Station address
+
+\ *** buffer sizes and counts ***
+
+d# 1600 constant /rbuf \ receive buffer size
+
+d# 1700 value /tbuf \ transmit buffer size
+
+true value tp? \ True to use twisted pair (10BASE-T)
+
+\ I/O base address of the lance. The actual address will be assigned later.
+0 value la
Added: dev/amd7990/regbits.fth
===================================================================
--- dev/amd7990/regbits.fth (rev 0)
+++ dev/amd7990/regbits.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,93 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: regbits.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 ============================================
+purpose: Generic LANCE register bits
+copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
+
+\ Common code
+
+hex
+headers
+
+\ Control/Status Register Bits (CSR0)
+ 01 constant initb 02 constant strt
+ 04 constant stopb 08 constant tdmd
+ 10 constant txon 20 constant rxon
+ 40 constant inea 80 constant intrp
+ 100 constant idon 200 constant tint
+ 400 constant rint 800 constant merr
+1000 constant miss 2000 constant cerr
+4000 constant babl 8000 constant err
+
+\ CSR3 bits
+ 01 constant bcon 02 constant acon 04 constant bswp
+
+\ Mode Register Bits (CSR15)
+ 01 constant drx 02 constant dtx
+ 04 constant lpbk 08 constant dxmtfcs
+ 10 constant fcoll 20 constant drty
+ 40 constant intl 8000 constant prom
+
+\ Message Descriptor Bits ( use a byte access with these bits )
+ 1 constant enp 2 constant stp
+ 10 constant ltint \ '971 extension: Interrupt after loopback transmit
+ 40 constant mser 80 constant own
+
+\ Receive Message Descriptor Bits ( use a byte access )
+ 4 constant buff 8 constant crc
+ 10 constant oflo 20 constant fram
+
+\ Transmit Message Descriptor Bits (use a byte access )
+ 4 constant def 8 constant one-err
+ 10 constant more-errs
+def one-err or more-errs or constant retries
+
+\ Value to write to message descriptor to enable it for use
+enp stp or own or ltint or constant ready
+
+\ TMD3 Bits
+ 400 constant rtry
+ 800 constant lcar
+1000 constant lcol
+4000 constant uflo
+8000 constant xbuf
+
+decimal
Added: dev/amd7990/timedrec.fth
===================================================================
--- dev/amd7990/timedrec.fth (rev 0)
+++ dev/amd7990/timedrec.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,105 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: timedrec.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 ============================================
+purpose: Network reception with timeout
+copyright: Copyright 1990 Sun Microsystems, Inc. All Rights Reserved
+
+\ Defines:
+\ timed-receive ( timeout-msecs -- [ buffer-handle data-address length ] err?)
+\ set-timeout ( timeout-msecs -- )
+\ receive-unicast ( -- [ buffer-handle data-address length ] err? )
+\
+\ defer handle-broadcast-packet ' noop to handle-broadcast-packet
+\ ( buff-handle data-addr len flag -- buff-handle data-addr len flag )
+\
+
+\ Uses this interface to the lower level receiver functions:
+
+\ receive-ready? ( -- flag ) \ true if a packet has arrived
+\ receive ( -- buf-handle buffer length )
+\ return-buffer ( buf-handle -- ) \ give receive buffer back to chip
+\ .error ( buffer-handle data-address length -- handle address length )
+\
+
+decimal
+
+instance variable alarmtime
+
+: set-timeout ( interval -- ) get-msecs + alarmtime ! ;
+: timeout? ( -- flag ) get-msecs alarmtime @ >= ;
+
+instance defer handle-broadcast-packet
+ ( buff-handle data-addr len flag -- buff-handle data-addr len flag )
+
+: multicast? ( handle data-address length -- handle data-address length flag )
+ \ Check for multicast/broadcast packets
+ over ( ... data-address )
+ c@ h# 80 and dup if \ Look at the multicast bit
+ ( handle data-address length multicast? )
+ handle-broadcast-packet
+ then
+;
+
+: receive-good-packet ( -- [ buffer-handle data-address length ] | 0 )
+ begin
+ begin
+ timeout? if false exit then
+ receive-ready?
+ until
+ receive dup 0=
+ while
+ .error 2drop return-buffer
+ repeat
+;
+: receive-unicast-packet ( -- [ buffer-handle data-address length ] | 0 )
+ begin
+ receive-good-packet dup 0= if exit then
+ multicast?
+ while
+ 2drop return-buffer
+ repeat
+;
+\ Receive a packet, filtering out broadcast packets and timing
+\ out if no packet comes in within a certain time.
+: timed-receive ( timeout-msecs -- [ buffer-handle data-address length ] err?)
+ set-timeout receive-unicast-packet ?dup 0=
+;
+headers
Added: dev/amd7990/vmlance.fth
===================================================================
--- dev/amd7990/vmlance.fth (rev 0)
+++ dev/amd7990/vmlance.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,231 @@
+\ ========== Copyright Header Begin ==========================================
+\
+\ Hypervisor Software File: vmlance.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 ============================================
+purpose: Definitions for the VMware PCNET - sort of - virtual ethernet
+copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
+
+\ Register access
+
+\ The chips that support 32-bit descriptor addresses usually
+\ have two modes for accessing the control registers. In the
+\ "normal" word I/O mode, the registers are accessed with 16-bit
+\ bus cycles and appear at adjacent 16-bit locations (0x10, 0x12, ...)
+\ In double-word I/O mode, they are accessed with 32-bit bus
+\ cycles and appear at adjacent 32-bit locations (0x10, 0x14, ...)
+\ In either case, they contain only 16 bits of useful data, so
+\ there is no real advantage to using 32-bit accesses.
+\ The chip determines the mode from the first access cycle, and
+\ "locks" into that mode. The only way to change the mode thereafter
+\ is to issue a hardware reset to it; a software reset won't do it.
+\ We use 16-bit mode as the default, for the benefit of client programs
+\ that use older driver code.
+
+[ifdef] 32-bit-cycles
+: >reg ( offset -- adr ) la swap la+ h# 10 + ;
+: reg@ ( offset -- data ) >reg rl@ ;
+: reg! ( data offset -- ) >reg rl! ;
+[else]
+: >reg ( offset -- adr ) la swap wa+ h# 10 + ;
+: reg@ ( offset -- data ) >reg rw@ ;
+: reg! ( data offset -- ) >reg rw! ;
+[then]
+
+: rdp! ( val -- ) 0 reg! ;
+: rdp@ ( -- val ) 0 reg@ ;
+
+: rap! ( val -- ) 1 reg! ;
+: rap@ ( -- val ) 1 reg@ ;
+
+: reset ( -- ) 2 reg@ drop ;
+
+: bdp! ( val -- ) 3 reg! ;
+: bdp@ ( -- val ) 3 reg@ ;
+
+\ Control and Status Register
+: csr! ( value reg# -- ) rap! rdp! ;
+: csr@ ( reg# -- value ) rap! rdp@ ;
+
+\ Bus Control Register
+: bcr! ( value reg# -- ) rap! bdp! ;
+: bcr@ ( reg# -- value ) rap! bdp@ ;
+
+
+\ In addition to the 16/32-bit register access, some AMD Ethernet
+\ chips allow you to choose 16-bit and 32-bit versions of the
+\ descriptor data structures. Unlike the register access, there
+\ is a compelling reason to use the 32-bit data structures, for
+\ they contain 32-bit DMA pointers. The 16-bit data structures
+\ use 24-bit DMA pointers, thus restricting DMA to the lower 16 MBytes.
+
+\ Message descriptor access
+
+struct ( message-descriptor )
+4 field >addr
+2 field >bytecnt
+1 field >reserved1
+1 field >laflags
+0 field >tmd2
+2 field >mcnt
+0 field >xerrors
+1 field >rpc
+1 field >rcc
+4 field >reserved2
+( total-length ) constant /md
+
+/md value /rmd
+/md value /tmd
+
+\ Little-endian reads and writes
+: lew@ ( addr -- w ) dup c@ swap 1+ c@ bwjoin ;
+: lew! ( addr w -- ) >r wbsplit r@ 1+ c! r> c! ;
+
+: lel@ ( addr -- l ) dup lew@ swap 2+ lew@ wljoin ;
+: lel! ( addr l -- ) >r lwsplit r@ 2+ lew! r> lew! ;
+
+: dump-regs ( -- )
+ hex la . cr
+ h# 80 0 do i decimal 3 u.r hex i csr@ 9 u.r cr loop
+;
+
+\ Get virtual address of buffer from message descriptor
+: addr@ ( rmd/tmd-vaddr -- buff-vaddr ) >addr lel@ devaddr> ;
+
+\ gets length of incoming message - receive only
+: length@ ( rmdaddr -- messagelength ) >mcnt lew@ ;
+
+\ gets transmit errors - transmit only
+: xerrors@ ( tmdaddr -- errorsflag )
+ >xerrors lew@ dup rtry and 0= if \ mask TDR unless RTRY set
+ h# fc00 and
+ then
+;
+
+\ Store buffer address into message descriptor
+\ The message descriptor must have a DMA address in it because
+\ the chip reads it.
+: addr! ( buff-vaddr rmd/tmd-vaddr -- ) swap >devaddr swap >addr lel! ;
+
+\ Set length of message to be sent - transmit only
+: length! ( length rmd/tmd-addr -- ) swap negate swap >bytecnt lew! ;
+
+\ Clear transmit error flags
+: clear-errors ( tmd-addr -- ) 0 swap >xerrors lew! ;
+
+
+\ Initialization
+
+\ Initialization
+
+h# 40 constant /ib
+
+\ Tool for storing and incrementing
+: ,, ( addr val -- addr' ) over lew! wa1+ ;
+
+: mac-addr,, ( ibaddr buf -- ibaddr' )
+ 3 /w* bounds do i lew@ ( wbflip ) ,, /w +loop
+;
+
+: init-setup ( -- )
+ ib ( addr )
+ mode @ ,, \ Mode
+ h# 0 #rmdsfactor 4 lshift or ,, \ TLEN(2^0 = 1) and RLEN
+
+ this-en-addr mac-addr,, 0 ,, \ Physical Ethernet Address
+ 0 ,, 0 ,, 0 ,, 0 ,, \ Logical Address Filter
+ rmd0 >devaddr lwsplit \ Receive Descriptor Ring Pointer
+ >r ,, r> ,, \ Put in low word and high word
+ tmd0 >devaddr lwsplit \ Transmit Descriptor Ring Pointer
+ >r ,, r> ,, \ Put in low word
+ drop
+
+ stopb 0 csr!
+ 2 d# 58 csr! \ 32-bit descriptor mode
+
+ ib >devaddr lwsplit 2 csr! 1 csr!
+;
+
+: wait-init ( -- flag ) \ true if init succeeds
+ initb 0 csr! \ rap is now 0, so we can use rdp@ and rdp! below.
+ false
+ 300 0 do rdp@ idon and if drop true leave then loop ( okay? )
+ dup if
+\ idon rdp! \ XXX may cause a problem
+ else
+ ." Ethernet chip initialization failed"
+ then
+;
+
+\ Initialize the Lance chip
+: lance-init ( -- flag ) \ true if init succeeds
+ 0 rdp! \ Write to RDP to set the access mode
+ \ We are just hoping that there are no
+ \ side effects of this write.
+
+ init-setup wait-init dup if ( flag )
+ h# 100 0 csr! \ Ack the init done int ( flag )
+ strt 0 csr! \ go ( flag )
+ then ( flag )
+;
+
+: dr ( n -- ) dup decimal 3 u.r hex ." : " csr@ 5 u.r 3 spaces ;
+base @ decimal
+\ 6 7
+: dumpregs ( -- )
+ 0 csr@ 2 and if stopb 0 csr! then
+ 0 dr 1 dr 2 dr 3 dr cr
+ 4 dr 5 dr 8 dr 8 dr cr
+ 9 dr 10 dr 11 dr 12 dr cr
+ 13 dr 14 dr 15 dr cr
+ 24 dr 25 dr 30 dr 31 dr cr
+ 58 dr 76 dr 77 dr cr
+ 80 dr 82 dr 88 dr 89 dr cr
+ 112 dr 124 dr cr
+;
+base !
+
+\ Restore the chip to its default modes for the benefit of client programs
+: lance-uninit ( -- ) \ Call from close, after setting STOP
+ reset \ Issue software reset
+ h# 200 d# 20 bcr! \ Restore default "PCnet-ISA" programing interface
+ h# 200 d# 58 csr! \ Restore default "PCnet-ISA" programing interface
+ h# 9060 d# 18 bcr! \ Re-enable burst modes
+ 2 2 bcr! \ Re-enable auto-selection of media
+;
Added: dev/amd79970/79c970.fth
===================================================================
--- dev/amd79970/79c970.fth (rev 0)
+++ dev/amd79970/79c970.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,92 @@
+purpose: Driver for AMD 79C970 Ethernet controller
+\ See license at end of file
+
+headers
+hex
+: map-chips ( -- )
+ 0 0 0100.0010 my-space + h# 20 " map-in" $call-parent to la
+ \ Enable card response
+ h# c100 my-space 6 + " config-w!" $call-parent
+ my-space 4 + dup " config-w@" $call-parent 5 or
+ swap " config-w!" $call-parent
+;
+: unmap-chips ( -- )
+ la h# 20 " map-out" $call-parent 0 to la
+ \ Disable card response
+ my-space 4 + dup " config-w@" $call-parent 5 invert and
+ swap " config-w!" $call-parent
+;
+
+0 instance value dma-region
+0 instance value dma-region-size
+
+0 instance value dma-virt
+0 instance value dma-phys
+0 instance value dma-size
+
+: 3drop ( n n n -- ) 2drop drop ;
+defer dma-sync ' 3drop to dma-sync
+
+: synchronize ( -- ) dma-virt dma-phys dma-size dma-sync ;
+
+: lance-allocate-dma ( size -- vadr )
+ to dma-size
+
+ \ In 32-bit mode, the DMA message descriptors must be 16-byte aligned,
+ \ so we allocate extra space and round up the beginning address
+ dma-size h# 10 + to dma-region-size
+
+ " dma-sync" my-parent ihandle>phandle find-method if
+ to dma-sync
+ then
+
+ dma-size " dma-alloc" $call-parent to dma-region
+
+ dma-region h# f + h# f invert and to dma-virt
+
+ dma-virt dma-size false " dma-map-in" $call-parent to dma-phys
+ dma-virt dma-phys - to dma-offset
+
+ dma-virt
+;
+
+decimal
+
+: lance-free-dma ( adr size -- )
+ 2drop
+ dma-virt dma-phys dma-size " dma-map-out" $call-parent
+
+ dma-region dma-region-size " dma-free" $call-parent
+;
+
+\ *** Initialization routines ***
+
+: extra-init ( -- ) ;
+
+64 constant /loopback
+
+headers
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1995 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/amd79970.bth
===================================================================
--- dev/amd79970/amd79970.bth (rev 0)
+++ dev/amd79970/amd79970.bth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,39 @@
+purpose: Load file for AMD 79970 Ethernet FCode driver
+\ See license at end of file
+
+command: &tokenize &this
+build-now
+
+silent on
+
+begin-tokenizing amd79970.fc
+
+FCode-version2
+fload ${BP}/dev/amd79970/loadpkg.fth
+end0
+
+end-tokenizing
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/amd7997m.bth
===================================================================
--- dev/amd79970/amd7997m.bth (rev 0)
+++ dev/amd79970/amd7997m.bth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,40 @@
+purpose: Load file for AMD 79970 Ethernet FCode driver using AUI
+\ See license at end of file
+
+command: &tokenize &this
+build-now
+
+silent on
+
+begin-tokenizing amd7997m.fc
+
+FCode-version2
+fload ${BP}/dev/amd79970/loadpkg.fth
+false to tp? \ Use AUI interface
+end0
+
+end-tokenizing
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/loadfcod.fth
===================================================================
--- dev/amd79970/loadfcod.fth (rev 0)
+++ dev/amd79970/loadfcod.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,30 @@
+purpose: Load file for AMD 79970 Ethernet FCode driver
+\ See license at end of file
+
+FCode-version2
+fload ${BP}/dev/amd79970/loadpkg.fth
+end0
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/loadpkg.fth
===================================================================
--- dev/amd79970/loadpkg.fth (rev 0)
+++ dev/amd79970/loadpkg.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,59 @@
+purpose: Load file for driver for AMD 79970 PCI Ethernet chip
+\ See license at end of file
+
+5 value #rmdsfactor \ #rmds = 2 ** #rmdsfactor
+
+fload ${BP}/dev/amd79970/setup.fth
+fload ${BP}/dev/amd7990/lancevar.fth
+fload ${BP}/dev/amd79970/79c970.fth
+fload ${BP}/dev/amd7990/regbits.fth
+fload ${BP}/dev/amd7990/lance32.fth
+fload ${BP}/dev/amd7990/lancecom.fth
+
+fload ${BP}/dev/amd7990/timedrec.fth
+fload ${BP}/dev/amd7990/lancetst.fth
+fload ${BP}/dev/amd79970/methods.fth
+
+: close ( -- )
+ obp-tftp ?dup if close-package then
+ net-off
+
+ la h# 14 + rw@ drop \ Reset
+ h# 200 d# 20 bcr! h# 200 d# 58 csr! \ Force some modes
+ h# 9060 h# 12 bcr! 2 2 bcr! \ and some more
+
+ unmap-lance-buffers
+ unmap-chips
+;
+
+map-chips
+get-mac-address ( b0 ... b5 )
+6 alloc-mem ( b0 ... b5 adr )
+dup 5 bounds swap do swap i c! -1 +loop ( adr )
+dup 6 encode-bytes " local-mac-address" property ( adr )
+6 free-mem
+unmap-chips
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/map.fth
===================================================================
--- dev/amd79970/map.fth (rev 0)
+++ dev/amd79970/map.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,70 @@
+purpose: Map registers, allocate and map DMA space
+\ See license at end of file
+
+\ Possibly-unaligned addresses. We allocate a bit extra and return a
+\ 16-byte-aligned address within the allocated piece.
+0 value real-vaddr
+0 value real-size
+
+: lance-allocate-dma ( size -- vadr )
+ h# 10 + to real-size ( )
+
+ real-size " dma-alloc" my-parent $call-method to real-vaddr
+
+ real-vaddr real-size false " dma-map-in" $call-parent ( real-paddr )
+
+ real-vaddr swap - to dma-offset
+
+ real-vaddr h# f + h# f invert and ( vadr )
+;
+
+: lance-free-dma ( adr size -- )
+ 2drop real-vaddr real-size " dma-free" my-parent $call-method
+;
+
+\ Dma-sync could be dummy routine if parent device doesn't support.
+: dma-sync ( virt-addr dev-addr size -- )
+ " dma-sync" my-parent ['] $call-method catch if
+ 2drop 2drop 2drop
+ then ( nbytes eb )
+;
+
+\ Set PCI configuration registers
+: my-config-w! ( w-value offset -- ) my-space + " config-w!" $call-parent ;
+
+: map-chips ( -- )
+ 0 0 my-space h# 100.0010 + h# 20 " map-in" $call-parent to la
+
+ \ Status field: Clear PERR, SERR and DATAPERR = c100
+ \ Command field: Set BMEN and IOEN = 0005
+ h# c100 6 my-config-w! 0005 4 my-config-w!
+;
+
+: unmap-chips ( -- )
+ la h# 20 " map-out" my-parent $call-method
+ 0 to la
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/methods.fth
===================================================================
--- dev/amd79970/methods.fth (rev 0)
+++ dev/amd79970/methods.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,131 @@
+purpose: Standard interface methods for the LANCE driver
+\ See license at end of file
+
+headers
+
+instance variable le-nbytes
+instance variable le-buf
+
+0 instance value obp-tftp
+: init-obp-tftp ( -- okay? )
+ " obp-tftp" find-package if ( phandle )
+ my-args rot open-package ( ihandle )
+ else 0
+ then
+ dup to obp-tftp ( ihandle | 0 )
+ dup 0= if
+ ." Can't open OBP standard TFTP package" cr
+ then
+;
+
+: le-xmit ( bufaddr nbytes -- #sent )
+ tuck get-buffer ( nbytes bufaddr ether-buffer )
+ tuck 3 pick cmove ( nbytes ether-buffer )
+ dup dup >devaddr 3 pick ( nbytes eb eb eb_p nbytes )
+ dma-sync ( nbytes eb )
+ over net-send if drop 0 then ( #sent )
+;
+
+: le-poll ( bufaddr nbytes -- #received )
+ le-nbytes ! le-buf !
+
+ receive-ready? 0= if 0 exit then \ Bail out if no packet ready
+ receive ?dup if ( buffer-handle ether-buffer length )
+ over dup >devaddr 2 pick
+ dma-sync ( buffer-handle ether-buffer length )
+ dup >r ( buffer-handle ether-buffer length )
+ le-nbytes @ min ( buffer-handle ether-buffer length' )
+ le-buf @ swap cmove ( handle )
+ return-buffer r>
+ else
+ drop return-buffer 0
+ then
+;
+
+: (set-vectors ( -- )
+ rmd0 nextrmd ! tmd0 nexttmd !
+ ['] (.error to .error
+ ['] (.transmit-error to .transmit-error
+ ['] noop to handle-broadcast-packet
+;
+instance defer set-vectors ' (set-vectors to set-vectors
+
+external
+
+\ Access the address ROM area in 16-bit mode to establish the I/O width
+: get-mac-address ( -- b0 b1 b2 b3 b4 b5 )
+ la rw@ wbsplit la 2 + rw@ wbsplit la 4 + rw@ wbsplit
+;
+
+headers
+
+external
+: watch-net ( -- )
+ map-chips
+ map-lance-buffers
+ set-vectors
+ prom mode !
+ lance-verbose? off
+ ext-lbt? off
+ net-init if watch-test net-off then
+ unmap-lance-buffers
+ unmap-chips
+;
+
+: read ( buf len -- -2 | actual-len )
+ le-poll ?dup 0= if -2 then
+;
+: write ( buf len -- actual-len ) le-xmit ;
+
+: load ( adr -- len ) " load" obp-tftp $call-method ;
+: close ( -- )
+ obp-tftp ?dup if close-package then
+ net-off
+ [ifdef] lance-uninit lance-uninit [then]
+ unmap-lance-buffers
+ unmap-chips
+;
+: open ( -- okay? )
+ map-chips
+ set-vectors
+ \ routine to allocate memory and fire up device
+ mode off lance-verbose? off
+ map-lance-buffers
+ net-init 0= if unmap-lance-buffers unmap-chips false exit then
+
+ mac-address drop macbuf 6 cmove \ Update macbuf.
+ macbuf 6 encode-bytes " mac-address" property \ FIXME should be later.
+
+ init-obp-tftp 0= if close false exit then
+ true
+;
+: reset ( -- flag )
+ tmd0 if unmap-lance-buffers then
+ la if net-off unmap-chips then
+ true
+;
+headers
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/setup.fth
===================================================================
--- dev/amd79970/setup.fth (rev 0)
+++ dev/amd79970/setup.fth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,44 @@
+purpose: Properties for AMD 79970 PCI Ethernet chip
+\ See license at end of file
+
+" ethernet" device-name
+" AMD,79c970" model
+" AMD,79c970" encode-string " compatible" property
+" network" device-type
+
+my-address my-space encode-phys
+ 0 encode-int encode+ h# 0 encode-int encode+
+
+my-address my-space h# 100.0010 + encode-phys encode+
+ 0 encode-int encode+ h# 20 encode-int encode+
+
+my-address my-space h# 200.0014 + encode-phys encode+
+ 0 encode-int encode+ h# 20 encode-int encode+
+
+my-address my-space h# 200.0030 + encode-phys encode+
+ 0 encode-int encode+ h# 10000 encode-int encode+
+" reg" property
+
+\ LICENSE_BEGIN
+\ Copyright (c) 1994 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Added: dev/amd79970/vmlance.bth
===================================================================
--- dev/amd79970/vmlance.bth (rev 0)
+++ dev/amd79970/vmlance.bth 2008-09-30 21:06:51 UTC (rev 954)
@@ -0,0 +1,70 @@
+purpose: Load file for VMware emulated LANCE chip
+\ See license at end of file
+
+command: &tokenize &this
+build-now
+
+silent on
+
+begin-tokenizing vmlance.fc
+
+FCode-version2
+5 value #rmdsfactor \ #rmds = 2 ** #rmdsfactor
+
+fload ${BP}/dev/amd79970/setup.fth
+fload ${BP}/dev/amd7990/lancevar.fth
+fload ${BP}/dev/amd79970/79c970.fth
+fload ${BP}/dev/amd7990/regbits.fth
+fload ${BP}/dev/amd7990/vmlance.fth
+fload ${BP}/dev/amd7990/lancecom.fth
+
+fload ${BP}/dev/amd7990/timedrec.fth
+fload ${BP}/dev/amd7990/lancetst.fth
+fload ${BP}/dev/amd79970/methods.fth
+
+: close ( -- )
+ obp-tftp ?dup if close-package then
+ net-off
+
+ la h# 14 + rw@ drop \ Reset
+ h# 200 d# 20 bcr! h# 200 d# 58 csr! \ Force some modes
+ h# 9060 h# 12 bcr! 2 2 bcr! \ and some more
+
+ unmap-lance-buffers
+ unmap-chips
+;
+
+map-chips
+get-mac-address ( b0 ... b5 )
+6 alloc-mem ( b0 ... b5 adr )
+dup 5 bounds swap do swap i c! -1 +loop ( adr )
+dup 6 encode-bytes " local-mac-address" property ( adr )
+6 free-mem
+unmap-chips
+end0
+
+end-tokenizing
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2002 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END