Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #2085

New discovery with Uthernet II/W5100 buffers

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From D Finnigan <dog_cow@macgui.com>
Newsgroups comp.sys.apple2.programmer
Subject New discovery with Uthernet II/W5100 buffers
Date Sat, 9 Jan 2016 22:04:35 -0000 (UTC)
Organization Mac GUI
Lines 50
Message-ID <dog_cow-1452377234@macgui.com> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Sat, 9 Jan 2016 22:04:35 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="ac9e0e4d7dd3957fb97803ee6801bab8"; logging-data="1191"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+leMd+MxlqCZUpDNVcA348"
User-Agent Mac GUI Usenet
Cancel-Lock sha1:kCmai03FKWgd4D2h/MsewmwVVpY=
Xref csiph.com comp.sys.apple2.programmer:2085

Show key headers only | View raw


While spending more time debugging the new send sequence algorithm for the
Uthernet II driver in Marina, I discovered a really excellent feature in the
W5100 that as far as I know is not mentioned in any of the documentation, or
anywhere else that I've read.

I was trying to debug the code that resets the W5100 address pointer back to
the start of the RX buffer. I inserted some debug lines to print the present
value of the W5100 address pointer *before* I reset it back to $6000.

Well imagine my surprise when I saw that it was printing out $6001! So not
only did I have an off-by-one error in my code, but somehow the address was
wrapping around before my code reset it!

So I poked around in the Monitor, manually setting and testing the address
ports and the reading the data port.

And now, here is my good discovery:

The W5100 will automatically wrap the address pointer from $7FFF back to
$6000, -AND- it will also automatically wrap the address pointer from $5FFF
back to $4000.

And there was much rejoicing. :-D

What this means is that if you're coding for the case where you're only
using 1 socket (in any mode-- TCP, UDP, Raw, it doesn't matter) and your
buffer sizes are both 8 KB (why wouldn't they be???) then you don't need to
worry about buffer wrap around at all. Not a thing to concern yourself with.
Just make sure your reads or writes start at the correct address in the
W5100, and away you go!

These two wrap around addresses seem to be hardwired, and as far as I can
tell, can't be changed even if you change the RX and TX buffer sizes. So if
you're writing code that uses more than 1 socket, you can't use this
wonderful technique.


Another discovery I made, is less important, but also mildly interesting:
What lies beyond $7FFF, the official end of the memory space in the W5100?
Well it turns out that internally it is treated as wrapping around back to
0. Address auto-increment still works, so you set the pointer to $8000, read
or write, and it advances to $8001. What happens when you get to $FFFF? It
wraps back to $E000! I don't recommend writing any programs that read or
write beyond $7FFF, of course! :-)

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

Back to comp.sys.apple2.programmer | Previous | NextNext in thread | Find similar


Thread

New discovery with Uthernet II/W5100 buffers D Finnigan <dog_cow@macgui.com> - 2016-01-09 22:04 +0000
  Re: New discovery with Uthernet II/W5100 buffers ol.sc@web.de (Oliver Schmidt) - 2016-01-19 22:20 +0000
    Re: New discovery with Uthernet II/W5100 buffers ol.sc@web.de (Oliver Schmidt) - 2016-01-20 18:33 +0000
      Re: New discovery with Uthernet II/W5100 buffers D Finnigan <dog_cow@macgui.com> - 2016-01-20 19:34 +0000
        Re: New discovery with Uthernet II/W5100 buffers ol.sc@web.de (Oliver Schmidt) - 2016-01-21 18:20 +0000
          Re: New discovery with Uthernet II/W5100 buffers D Finnigan <dog_cow@macgui.com> - 2016-01-22 23:47 +0000
            Re: New discovery with Uthernet II/W5100 buffers ol.sc@web.de (Oliver Schmidt) - 2016-01-24 01:01 +0000
              Re: New discovery with Uthernet II/W5100 buffers D Finnigan <dog_cow@macgui.com> - 2016-01-25 16:03 +0000

csiph-web