openfirmware
Threads by month
- ----- 2025 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
September 2008
- 3 participants
- 59 discussions
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
1
0
Author: wmb
Date: 2008-09-30 22:40:11 +0200 (Tue, 30 Sep 2008)
New Revision: 953
Modified:
cpu/x86/pc/olpc/usb8388.bth
cpu/x86/pc/olpc/versions.fth
Log:
OLPC - upgrade WLAN driver version to 5.110.22.p18 .
Modified: cpu/x86/pc/olpc/usb8388.bth
===================================================================
--- cpu/x86/pc/olpc/usb8388.bth 2008-09-30 20:38:42 UTC (rev 952)
+++ cpu/x86/pc/olpc/usb8388.bth 2008-09-30 20:40:11 UTC (rev 953)
@@ -11,7 +11,7 @@
" wget -q http://dev.laptop.org/pub/firmware/libertas/usb8388-${WLAN_VERSION}.bin.md5" expand$ $sh
-" md5sum -b usb8388-${WLAN_VERSION}.bin | cmp - usb8388-${WLAN_VERSION}.bin.md5" expand$ $sh
+" md5sum usb8388-${WLAN_VERSION}.bin | cmp - usb8388-${WLAN_VERSION}.bin.md5" expand$ $sh
" mv usb8388-${WLAN_VERSION}.bin usb8388.bin" expand$ $sh
" rm usb8388-${WLAN_VERSION}.bin.md5" expand$ $sh
Modified: cpu/x86/pc/olpc/versions.fth
===================================================================
--- cpu/x86/pc/olpc/versions.fth 2008-09-30 20:38:42 UTC (rev 952)
+++ cpu/x86/pc/olpc/versions.fth 2008-09-30 20:40:11 UTC (rev 953)
@@ -2,7 +2,7 @@
\ The overall firmware revision
macro: FW_MAJOR E
-macro: FW_MINOR 18
+macro: FW_MINOR 18a
\ The EC microcode
macro: EC_VERSION e15
@@ -15,8 +15,8 @@
\ macro: KEYS testkeys
\ The wireless LAN module firmware
-macro: WLAN_RPM ${WLAN_VERSION}-1.olpc1
-macro: WLAN_VERSION 5.110.22.p1
+macro: WLAN_RPM ${WLAN_VERSION}.olpc1
+macro: WLAN_VERSION 5.110.22.p18
\ The bios_verify image
macro: CRYPTO_VERSION 0.2
1
0
Author: wmb
Date: 2008-09-30 22:38:42 +0200 (Tue, 30 Sep 2008)
New Revision: 952
Modified:
dev/3c90xb/loadpkg.fth
dev/i8255x/loadpkg.fth
Log:
Fixed a couple of typos in the source code for FCode drivers for old
Ethernet chips (the addition of license text had broken the code).
Modified: dev/3c90xb/loadpkg.fth
===================================================================
--- dev/3c90xb/loadpkg.fth 2008-09-30 20:35:12 UTC (rev 951)
+++ dev/3c90xb/loadpkg.fth 2008-09-30 20:38:42 UTC (rev 952)
@@ -17,7 +17,9 @@
mac-address encode-bytes " mac-address" property
unmap-regs
;
-init\ LICENSE_BEGIN
+init
+
+\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
\ Permission is hereby granted, free of charge, to any person obtaining
Modified: dev/i8255x/loadpkg.fth
===================================================================
--- dev/i8255x/loadpkg.fth 2008-09-30 20:35:12 UTC (rev 951)
+++ dev/i8255x/loadpkg.fth 2008-09-30 20:38:42 UTC (rev 952)
@@ -17,7 +17,9 @@
encode-bytes " local-mac-address" property ( )
unmap-regs
;
-init\ LICENSE_BEGIN
+init
+
+\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
\ Permission is hereby granted, free of charge, to any person obtaining
1
0
Author: wmb
Date: 2008-09-30 22:35:12 +0200 (Tue, 30 Sep 2008)
New Revision: 951
Added:
cpu/x86/pc/olpc/mcastnand.bth
Modified:
ofw/inet/ip.fth
ofw/inet/netload.fth
Log:
OLPC - beginning of support for multicast NAND reflashing.
Added: cpu/x86/pc/olpc/mcastnand.bth
===================================================================
--- cpu/x86/pc/olpc/mcastnand.bth (rev 0)
+++ cpu/x86/pc/olpc/mcastnand.bth 2008-09-30 20:35:12 UTC (rev 951)
@@ -0,0 +1,23 @@
+purpose: Fetch and compile the multicast NAND reflash program
+
+command: &builder &this
+build-now
+
+\ fload ${BP}/cpu/x86/pc/olpc/versions.fth
+
+" rm -rf multicast-nand" $sh
+
+" wget -q -O multicast-nand.tar.gz http://dev.laptop.org/git?p=users/wmb/multicast-nand\;a=snapshot" $sh
+" tar xfz multicast-nand.tar.gz" $sh
+" mv users/wmb/multicast-nand ." $sh
+" rm -rf users/wmb" $sh
+" rm multicast-nand.tar.gz" $sh
+
+\ " git clone --depth 1 -q git://dev.laptop.org/users/wmb/multicast-nand" expand$ $sh
+
+" (cd multicast-nand; make BPDIR=../../../../../.. rx_ofw; strip -o ../mcastnand.bin rx_ofw)" expand$ $sh
+
+\ This forces the creation of a .log file, so we don't re-fetch
+writing mcastnand.version
+\ " ${WLAN_VERSION}"n" expand$ ofd @ fputs
+ofd @ fclose
Modified: ofw/inet/ip.fth
===================================================================
--- ofw/inet/ip.fth 2008-09-30 20:27:58 UTC (rev 950)
+++ ofw/inet/ip.fth 2008-09-30 20:35:12 UTC (rev 951)
@@ -61,6 +61,7 @@
: ip= ( ip-addr1 ip-addr2 -- flag ) /i comp 0= ;
+: multicast? ( adr-buf -- flag ) c@ h# f0 and h# e0 = ;
: unknown-ip-addr? ( adr-buf -- flag ) unknown-ip-addr ip= ;
: known? ( adr-buf -- flag ) unknown-ip-addr? 0= ;
Modified: ofw/inet/netload.fth
===================================================================
--- ofw/inet/netload.fth 2008-09-30 20:27:58 UTC (rev 950)
+++ ofw/inet/netload.fth 2008-09-30 20:35:12 UTC (rev 951)
@@ -400,9 +400,37 @@
2drop false
;
+: setup-multicast ( -- )
+ server-ip-addr my-ip-addr copy-ip-addr
+ " set-multicast" my-parent ihandle>phandle find-method if ( acf )
+ " "(01 00 5e)" his-en-addr swap move ( acf )
+ my-ip-addr 1+ his-en-addr 3 + 3 move ( acf )
+ his-en-addr 3 + c@ h# 7f and his-en-addr 3 + c! ( )
+ his-en-addr /e rot my-parent call-package ( )
+ exit
+ then
+ " enable-promiscuous" my-parent ihandle>phandle find-method if ( acf )
+ my-parent call-package
+ exit
+ then
+ " promiscuous-mode" my-parent ihandle>phandle find-method if ( acf )
+ my-parent call-package
+ exit
+ then
+ " promiscuous" my-parent ihandle>phandle find-method if ( acf )
+ my-parent call-package
+ exit
+ then
+ \ Try setting the unicast address to the multicast address?
+ ." Can't enable multicast reception in network driver" cr
+;
+
defer configured ' noop to configured
: configure ( -- )
use-last? if configured exit then
+
+ server-ip-addr multicast? if setup-multicast exit then
+
use-bootp? if
nvram-ip? 0= if process-bootp then
else
1
0
Author: wmb
Date: 2008-09-30 22:27:58 +0200 (Tue, 30 Sep 2008)
New Revision: 950
Modified:
cpu/x86/pc/linux.fth
Log:
Linux support - move ramdisk to top of memory for compatibility
with recent kernels that use boot protocols >= 2.03 . The previous
ramdisk location (at load-base, e.g. 0x800000) was vulnerable to
being overwritten by kernel initialization, especially for large kernels.
This helps when using recent Fedora kernels, for example.
Modified: cpu/x86/pc/linux.fth
===================================================================
--- cpu/x86/pc/linux.fth 2008-09-30 20:23:34 UTC (rev 949)
+++ cpu/x86/pc/linux.fth 2008-09-30 20:27:58 UTC (rev 950)
@@ -167,7 +167,19 @@
cr ( throw-code r: xt )
r> to load-path ( throw-code )
throw
- loaded to /ramdisk to ramdisk-adr
+
+ loaded to /ramdisk ( adr )
+
+ \ Move ramdisk to top of memory
+
+ \ The initrd_addr_max field appeared in boot protocol 2.03
+ h# 22c +lp l@ ( adr ramdisk-limit )
+ ?dup if 1+ else h# 8000.0000 then ( adr ramdisk-limit )
+
+ memory-limit umin /ramdisk - ( adr new-ramdisk-adr )
+ dup to ramdisk-adr ( adr new-ramdisk-adr )
+
+ /ramdisk move ( )
;
: cv-load-ramdisk ( -- )
" ramdisk" eval dup 0= if 2drop exit then ( name$ )
@@ -180,7 +192,6 @@
0 0 1meg -1 mmu-map ( ) \ Make the parameter area accessible
[then]
0 +lp h# 1000 0 mem-claim drop \ Play nice with memory reporting
- 0 +lp h# 1000 erase
;
0 value linux-loaded?
1
0
Author: wmb
Date: 2008-09-30 22:23:34 +0200 (Tue, 30 Sep 2008)
New Revision: 949
Modified:
cpu/x86/pc/biosload/addrs.fth
cpu/x86/pc/biosload/biostart.bth
cpu/x86/pc/biosload/devices.fth
cpu/x86/pc/biosload/probemem.fth
cpu/x86/pc/biosload/start.bth
cpu/x86/pc/getms.fth
Log:
Biosload build - more support for building to run under VirtualBox.
Modified: cpu/x86/pc/biosload/addrs.fth
===================================================================
--- cpu/x86/pc/biosload/addrs.fth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/biosload/addrs.fth 2008-09-30 20:23:34 UTC (rev 949)
@@ -20,6 +20,14 @@
h# 08.0000 constant dropin-size
[then]
+[ifdef] virtualbox-loaded
+ h# f0.0000 constant dropin-base \ Location of payload in RAM
+ h# 08.0000 constant dropin-size
+ h# 1.0000 constant dma-base \ DMA heap
+ h# 8.0000 constant dma-size
+
+[then]
+
[ifdef] preof-loaded
h# 2000.0000 constant ramsize
h# fff8.0020 constant dropin-base \ Location of payload in ROM
Modified: cpu/x86/pc/biosload/biostart.bth
===================================================================
--- cpu/x86/pc/biosload/biostart.bth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/biosload/biostart.bth 2008-09-30 20:23:34 UTC (rev 949)
@@ -15,7 +15,7 @@
hex
-fload ${BP}/cpu/x86/pc/biosload/addrs.fth
+fload ${BP}/cpu/x86/pc/biosload/config.fth
h# 0.0400 constant gdt-pa
h# 0.1000 constant stacktop
Modified: cpu/x86/pc/biosload/devices.fth
===================================================================
--- cpu/x86/pc/biosload/devices.fth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/biosload/devices.fth 2008-09-30 20:23:34 UTC (rev 949)
@@ -23,10 +23,6 @@
[then]
fload ${BP}/cpu/x86/pc/biosload/pcinode.fth \ System-specific words for PCI
- [ifdef] use-mediagx
- h# 4100.0000 to first-mem \ Avoid scratchpad RAM
- h# ff00.0000 to mem-space-top
- [then]
end-package
stand-init: PCI host bridge
" /pci" " init" execute-device-method drop
@@ -58,46 +54,30 @@
fload ${BP}/cpu/x86/pc/getms.fth
[then]
-[ifdef] use-mediagx
-fload ${BP}/dev/mediagx/reg.fth \ MediaGX constants and access
-fload ${BP}/dev/mediagx/dump.fth
-[then]
-
[ifdef] use-pci-isa
[ifdef] addresses-assigned
\ This must precede isamisc.fth in the load file, to execute it first
-fload ${BP}/cpu/x86/pc/biosload/moveisa.fth
+fload ${BP}/cpu/x86/pc/moveisa.fth
[then]
0 0 " 0" " /pci" begin-package
fload ${BP}/dev/pci/isa.fth \ ISA bus bridge under PCI node
fload ${BP}/dev/pci/isamisc.fth
end-package
-
-[ifdef] addresses-assigned
-fload ${BP}/dev/mediagx/cx5530/nomapsmi.fth
[then]
-[then]
-dev /interrupt-controller
-h# 20 to vector-base0
-h# 28 to vector-base1
-device-end
-
-[ifdef] use-mediagx
-0 0 " 40008100" " /" begin-package
- fload ${BP}/dev/mediagx/video/loadpkg.fth
-end-package
-devalias screen /display
-[then]
-
[ifdef] use-pc87560
0 0 " 5,1" " /pci" begin-package \ ISA bus bridge
fload ${BP}/dev/pc87560.fth \ SouthBridge ISA bus bridge
end-package
[then]
+dev /interrupt-controller
+h# 20 to vector-base0
+h# 28 to vector-base1
+device-end
+
[ifdef] use-pc87317
fload ${BP}/dev/pc87317.fth \ National PC87317 superIO
[then]
@@ -109,22 +89,30 @@
dup value /device
constant /device-phys
my-address my-space /device-phys reg
- fload ${BP}/cpu/x86/pc/flashpkg.fth
+\ fload ${BP}/cpu/x86/pc/flashpkg.fth
+ fload ${BP}/dev/flashpkg.fth
+end-package
- : init ( comp$ /device -- )
- to /device 2>r
- 0 0 encode-bytes
- 2r> encode-string encode+
- " rom" encode-string encode+
- " compatible" property
-[ifdef] enable-flash-select
- /device /device-phys <> if enable-flash-select then
-[then]
- ;
+[ifdef] notdef
+\ Create a node below the top-level FLASH node to accessing the portion
+\ containing the dropin modules
+0 0 0 0 " flash" begin-package
+ " dropins" device-name
+ dropin-size constant /device
+ fload ${BP}/dev/subrange.fth
end-package
-" rom" dropin-base <# u#s " /flash@" hold$ u#> $devalias
+[then]
+\ devalias dropins /dropins
+devalias dropins /flash
+
+\ Create a pseudo-device that presents the dropin modules as a filesystem.
+fload ${BP}/ofw/fs/dropinfs.fth
+
+\ This devalias lets us say, for example, "dir rom:"
+devalias rom /dropin-fs
+
fload ${BP}/cpu/x86/forthint.fth \ Low-level interrupt handling code
fload ${BP}/dev/isa/irq.fth \ ISA interrupt dispatcher
fload ${BP}/cpu/x86/pc/isatick.fth \ Use ISA timer as the alarm tick timer
@@ -195,8 +183,8 @@
[ifdef] pseudo-nvram
fload ${BP}/cpu/x86/pc/biosload/filenv.fth
dev /file-nvram
-: floppy-nv-file ( -- ) " a:\nvram.dat" ;
-' floppy-nv-file to nv-file
+: hd-nv-file ( -- ) " c:\nvram.dat" ;
+' hd-nv-file to nv-file
device-end
stand-init: Pseudo-NVRAM
" /file-nvram" open-dev to nvram-node
Modified: cpu/x86/pc/biosload/probemem.fth
===================================================================
--- cpu/x86/pc/biosload/probemem.fth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/biosload/probemem.fth 2008-09-30 20:23:34 UTC (rev 949)
@@ -41,9 +41,9 @@
fw-pa /fw-ram + heap-base heap-size + umax /ram release
then
- dropin-base /ram u< if
- dropin-base dropin-size + /ram over - release
- then
+\ dropin-base /ram u< if
+\ dropin-base dropin-size + /ram over - release
+\ then
[then]
;
Modified: cpu/x86/pc/biosload/start.bth
===================================================================
--- cpu/x86/pc/biosload/start.bth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/biosload/start.bth 2008-09-30 20:23:34 UTC (rev 949)
@@ -28,7 +28,7 @@
label startup
[ifdef] debug-startup
-ascii x report
+\ ascii x report
[then]
ret
Modified: cpu/x86/pc/getms.fth
===================================================================
--- cpu/x86/pc/getms.fth 2008-09-30 20:18:05 UTC (rev 948)
+++ cpu/x86/pc/getms.fth 2008-09-30 20:23:34 UTC (rev 949)
@@ -56,7 +56,7 @@
\ We use "0<" instead of "0<=" so that we are sure to wait at least
\ the requested time; otherwise we might not wait long enough if the
\ first call to get-msecs were to occur just before the timer ticked.
- begin dup get-msecs - 0<= until \ Loop until target time reached
+ begin dup ?halt get-msecs - 0<= until \ Loop until target time reached
drop ( )
else ( #ms )
1
0
Author: wmb
Date: 2008-09-30 22:18:05 +0200 (Tue, 30 Sep 2008)
New Revision: 948
Modified:
cpu/x86/interrup.fth
Log:
Added "halt" and "?halt" words to save power on x86 systems.
Also helps when running under an emulator by yielding the host CPU.
Modified: cpu/x86/interrup.fth
===================================================================
--- cpu/x86/interrup.fth 2008-09-30 20:15:44 UTC (rev 947)
+++ cpu/x86/interrup.fth 2008-09-30 20:18:05 UTC (rev 948)
@@ -20,6 +20,25 @@
h# 200 # bx test 0<> if ax dec then \ Test interrupt flag bit
ax push
c;
+
+\ Unconditional halt - stops instruction execution until an interrupt.
+\ If interrupts are disabled, this could hang forever.
+code halt hlt c;
+
+\ Safe halt that is a no-op if interrupts are disabled
+code ?halt ( -- )
+ pushf ax pop
+ h# 200 # ax test 0<> if hlt then
+c;
+
+\ You can install this in "key" to lower the idle power or to make
+\ the system use fewer CPU cycles when running on an emulator.
+
+: halting-key ( -- )
+ begin key? 0= while ?halt repeat
+ (key
+;
+
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
1
0
Author: wmb
Date: 2008-09-30 22:15:44 +0200 (Tue, 30 Sep 2008)
New Revision: 947
Modified:
clients/lib/1275.h
clients/lib/lib.c
clients/lib/printf.c
clients/lib/stdio.h
clients/lib/wrappers.c
Log:
Client library improvments in support of the multicast NAND updater.
Modified: clients/lib/1275.h
===================================================================
--- clients/lib/1275.h 2008-09-26 01:02:15 UTC (rev 946)
+++ clients/lib/1275.h 2008-09-30 20:15:44 UTC (rev 947)
@@ -24,6 +24,60 @@
#define new(t) (t *)zalloc(sizeof(t));
+#ifdef SPRO
+typedef long long cell_t;
+#else
+typedef unsigned long cell_t ;
+#endif
+
+#ifdef CIF64
+#define LOW(index) ((index*2) + 1)
+#else
+#define LOW(index) (index)
+#endif
+
+extern int call_firmware(ULONG *);
+extern void warn(char *fmt, ...);
+
+#ifdef CIF64
+#define CIF_HANDLER_IN 6
+#else
+#define CIF_HANDLER_IN 3
+#endif
+
+extern int call_firmware(ULONG *);
+extern void warn(char *fmt, ...);
+int atoi(char *s);
+
+void OFClose(ihandle id);
+phandle OFPeer(phandle device_id);
+phandle OFChild(phandle device_id);
+phandle OFParent(phandle device_id);
+long OFGetproplen(phandle device_id, char *name);
+long OFGetprop(phandle device_id, char *name, char *buf, ULONG buflen);
+long OFNextprop(phandle device_id, char *name, char *buf);
+long OFSetprop(phandle device_id, char *name, char *buf, ULONG buflen);
+phandle OFFinddevice(char *devicename);
+ihandle OFOpen(char *devicename);
+ihandle OFCreate(char *devicename);
+void OFClose(ihandle id);
+long OFRead(ihandle instance_id, char *addr, ULONG len);
+long OFWrite(ihandle instance_id, char *addr, ULONG len);
+long OFSeek(ihandle instance_id, ULONG poshi, ULONG poslo);
+ULONG OFClaim(char *addr, ULONG size, ULONG align);
+VOID OFRelease(char *addr, ULONG size);
+long OFPackageToPath(phandle device_id, char *addr, ULONG buflen);
+phandle OFInstanceToPackage(ihandle ih);
+long OFCallMethod(char *method, ihandle id, ULONG arg);
+long OFInterpret0(char *cmd);
+ULONG OFMilliseconds(VOID);
+void (*OFSetCallback(void (*func)(void)))(void);
+long OFBoot(char *bootspec);
+VOID OFEnter(VOID);
+VOID OFExit(VOID);
+long OFCallMethodV(char *method, ihandle id, int nargs, int nrets, ...);
+long OFInterpretV(char *cmd, int nargs, int nrets, ...);
+
// LICENSE_BEGIN
// Copyright (c) 2006 FirmWorks
//
Modified: clients/lib/lib.c
===================================================================
--- clients/lib/lib.c 2008-09-26 01:02:15 UTC (rev 946)
+++ clients/lib/lib.c 2008-09-30 20:15:44 UTC (rev 947)
@@ -9,15 +9,24 @@
extern int get_int_prop();
extern int get_int_prop_def();
+#include "stdio.h"
+
+FILE _stdin = { -1, 0, 0};
+FILE _stdout = { -1, 0, 0};
+FILE *stdin = &_stdin;
+FILE *stdout = &_stdout;
+
void
abort()
{
+ fflush(stdout);
OFExit();
}
void
-exit()
+exit(int code)
{
+ fflush(stdout);
OFExit();
}
@@ -31,13 +40,6 @@
/* files */
-#include "stdio.h"
-
-FILE _stdin = { -1, 0, 0};
-FILE _stdout = { -1, 0, 0};
-FILE *stdin = &_stdin;
-FILE *stdout = &_stdout;
-
char _homedir[128];
char *
Modified: clients/lib/printf.c
===================================================================
--- clients/lib/printf.c 2008-09-26 01:02:15 UTC (rev 946)
+++ clients/lib/printf.c 2008-09-30 20:15:44 UTC (rev 947)
@@ -83,6 +83,7 @@
char c, *s;
int n = 0;
int fieldlen;
+ unsigned long mask;
char padchar;
while (c = *fmt++) {
@@ -91,6 +92,7 @@
n++;
continue;
}
+ mask = 0xffffffff;
if ((c = *fmt++) == '\0')
goto out;
@@ -112,21 +114,34 @@
goto out;
}
+ if (c == 'l') { // Ignore "long" modifier
+ if ((c = *fmt++) == '\0')
+ goto out;
+ }
+ while (c == 'h') { // Mask for short modifier
+ if (mask = 0xffff)
+ mask = 0xff;
+ else
+ mask = 0xffff;
+ if ((c = *fmt++) == '\0')
+ goto out;
+ }
+
switch (c) {
case 'x':
- x = va_arg(args, ULONG);
+ x = va_arg(args, ULONG) & mask;
n += printbase(x, 16, fieldlen, padchar, 0);
break;
case 'X':
- x = va_arg(args, ULONG);
+ x = va_arg(args, ULONG) & mask;
n += printbase(x, 16, fieldlen, padchar, 1);
break;
case 'o':
- x = va_arg(args, ULONG);
+ x = va_arg(args, ULONG) & mask;
n += printbase(x, 8, fieldlen, padchar, 0);
break;
case 'd':
- x = va_arg(args, ULONG);
+ x = va_arg(args, ULONG) & mask;
n += printbase(x, 10, fieldlen, padchar, 0);
break;
case 'c':
@@ -180,8 +195,8 @@
va_start(args, fmt);
(void)_printf(fmt, args);
- OFExit();
va_end(args);
+ exit();
}
// LICENSE_BEGIN
Modified: clients/lib/stdio.h
===================================================================
--- clients/lib/stdio.h 2008-09-26 01:02:15 UTC (rev 946)
+++ clients/lib/stdio.h 2008-09-30 20:15:44 UTC (rev 947)
@@ -15,6 +15,8 @@
#define EOF -1
extern FILE *fopen();
+void fflush (FILE *fp);
+int printf(char *fmt, ...);
// LICENSE_BEGIN
// Copyright (c) 2006 FirmWorks
Modified: clients/lib/wrappers.c
===================================================================
--- clients/lib/wrappers.c 2008-09-26 01:02:15 UTC (rev 946)
+++ clients/lib/wrappers.c 2008-09-30 20:15:44 UTC (rev 947)
@@ -36,27 +36,6 @@
#include "1275.h"
-#ifdef SPRO
-typedef long long cell_t;
-#else
-typedef unsigned long cell_t ;
-#endif
-
-#ifdef CIF64
-#define LOW(index) ((index*2) + 1)
-#else
-#define LOW(index) (index)
-#endif
-
-extern int call_firmware(ULONG *);
-extern void warn(char *fmt, ...);
-
-#ifdef CIF64
-#define CIF_HANDLER_IN 6
-#else
-#define CIF_HANDLER_IN 3
-#endif
-
// Device tree routines
//
@@ -449,7 +428,57 @@
return ((LONG)argarray[CIF_HANDLER_IN+LOW(3)]);
}
+#include <stdarg.h>
+
+#define MAXARGS 12
long
+OFCallMethodV(
+ char *method,
+ ihandle id,
+ int numargs,
+ int numres,
+ ...
+ )
+{
+#ifdef CIF64
+ ULONG argarray[(MAXARGS+6)*2] = { 0 };
+#else
+ cell_t argarray[MAXARGS+6] = { 0 };
+#endif
+ va_list ap;
+ int retval;
+ int *intp;
+ int argnum = 0;
+ unsigned long flags;
+
+ argarray[LOW(argnum++)] = (cell_t)"call-method";
+ argarray[LOW(argnum++)] = (cell_t)numargs+2;
+ argarray[LOW(argnum++)] = (cell_t)numres+1;
+ argarray[LOW(argnum++)] = (cell_t)method;
+ argarray[LOW(argnum++)] = (cell_t)id;
+
+ if ((numargs + numres) > MAXARGS)
+ return -1;
+
+ va_start(ap, numres);
+ while (numargs--)
+ argarray[LOW(argnum++)] = va_arg(ap, int);
+
+ retval = call_firmware(argarray);
+ if (retval == 0) {
+ retval = argarray[LOW(argnum++)]; // Catch result
+ if (retval == 0) {
+ while (numres--) {
+ intp = va_arg(ap, int *);
+ *intp = argarray[LOW(argnum++)];
+ }
+ }
+ }
+ va_end(ap);
+ return retval;
+}
+
+long
OFInterpret0(
char *cmd
)
@@ -468,6 +497,52 @@
return ((LONG)argarray[CIF_HANDLER_IN+LOW(1)]);
}
+long
+OFInterpretV(
+ char *cmd,
+ int numargs,
+ int numres,
+ ...
+ )
+{
+#ifdef CIF64
+ ULONG argarray[(MAXARGS+5)*2] = { 0 };
+#else
+ cell_t argarray[MAXARGS+5] = { 0 };
+#endif
+ va_list ap;
+ int retval;
+ int *intp;
+ int argnum = 0;
+ unsigned long flags;
+
+ argarray[LOW(argnum++)] = (cell_t)"interpret";
+ argarray[LOW(argnum++)] = (cell_t)numargs+1;
+ argarray[LOW(argnum++)] = (cell_t)numres+1;
+ argarray[LOW(argnum++)] = (cell_t)cmd;
+
+ if ((numargs + numres) > MAXARGS)
+ return -1;
+
+ va_start(ap, numres);
+ while (numargs--)
+ argarray[LOW(argnum++)] = va_arg(ap, int);
+
+ retval = call_firmware(argarray);
+ if (retval == 0) {
+ retval = argarray[LOW(argnum++)]; // Catch result
+ if (retval == 0) {
+ while (numres--) {
+ intp = va_arg(ap, int *);
+ *intp = argarray[LOW(argnum++)];
+ }
+ }
+ }
+ va_end(ap);
+ return retval;
+}
+
+
ULONG
OFMilliseconds( VOID )
{
1
0
Author: wmb
Date: 2008-09-26 03:02:15 +0200 (Fri, 26 Sep 2008)
New Revision: 946
Modified:
cpu/x86/pc/biosload/fw.bth
Log:
Biosload build - don't load rmenter.fth as it is unnecessary and breaks some configurations.
Modified: cpu/x86/pc/biosload/fw.bth
===================================================================
--- cpu/x86/pc/biosload/fw.bth 2008-09-25 23:40:06 UTC (rev 945)
+++ cpu/x86/pc/biosload/fw.bth 2008-09-26 01:02:15 UTC (rev 946)
@@ -206,7 +206,7 @@
fload ${BP}/cpu/x86/pc/biosload/usb.fth
fload ${BP}/cpu/x86/pc/rmtools.fth
fload ${BP}/cpu/x86/pc/biosload/callbios.fth
-fload ${BP}/cpu/x86/pc/biosload/rmenter.fth
+\ fload ${BP}/cpu/x86/pc/biosload/rmenter.fth
\ false to stand-init-debug?
true to stand-init-debug?
1
0
Hi all,
I'm hoping someone can tell me whats wrong or why I can't build
OpenFirmware rev 795.
I'm trying to follow the instructions at
http://www.openfirmware.info/Open_Firmware#Build_Open_Firmware but
they're not working. I keep getting errors when running 'make'.
I have tried modifying the configuration as the above site suggests, and
I've also tried without making any changes at all, both fail with the
same error at the same place.
My primary goal right now is to simply play with coreboot and
OpenFirmware in qemu, then I might consider trying it on some real hardware.
Any help is appreciated.
make[1]: Entering directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/Linux'
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/wrapper.c -o wrapper.o
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/logger.c -o logger.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/zipmem.c -o zipmem.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/deflate.c -o deflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/trees.c -o trees.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/bits.c -o bits.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/util.c -o util.o
cc -c -m32 -O0 -fpic ../../../forth/wrapper/zip/inflate.c -o inflate.o
cc -m32 -o forth wrapper.o logger.o zipmem.o deflate.o trees.o bits.o util.o inflate.o
make[1]: Leaving directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/Linux'
make[1]: Entering directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/build'
make -C ../Linux ../build/inflate.bin
make[2]: Entering directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/Linux'
objcopy -O binary inflate.o ../build/inflate.bin
make[2]: Leaving directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/Linux'
make[1]: Leaving directory `/usr/src/coreboot/build-qemu/openfirmware/cpu/x86/build'
./build ofw.c32
--- Rebuilding reset.di
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../reset.bth
--- Rebuilding start.di
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../start.bth
--- Rebuilding kernel.dic
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../kernel.bth
--- Saving kernel.dic ---
--- Rebuilding tools.dic
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/kernel.dic ../tools.bth
--- Saving tools.dic ---
--- Rebuilding basefw.dic
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/tools.dic ../basefw.bth
--- Saving basefw.dic ---
--- Rebuilding bootsec.hex
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../bootsec.bth
1fe 1f0
400 400
--- Rebuilding fw.img
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/basefw.dic ../fw.bth
${BP}/cpu/x86/pc/biosload/rmenter.fth:152: >off ?
make: *** [ofw.c32] Error 1
--
Regards,
Robert Davidson.
Obsidian Consulting Group.
Ph. 03-9355-7844
E-Mail: support(a)obsidian.com.au
2
3